feat(org-chart): add core cards and fixed-layout integration
This commit is contained in:
1 parent
d18e3c3380
commit
61c6f8d1f1
161 files changed
+13044
-1
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { build } from 'vite';
|
||||
import { cp, mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createRequire } from 'node:module';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
const root = fileURLToPath(new URL('./', import.meta.url));
|
||||
const require = createRequire(import.meta.url);
|
||||
const engineRoot = path.dirname(require.resolve('orgchart/package.json'));
|
||||
const engine = JSON.parse(await readFile(path.join(engineRoot, 'package.json'), 'utf8'));
|
||||
if (engine.version !== '6.0.0') throw new Error('Expected pinned orgchart 6.0.0');
|
||||
// Keep upstream UMD evaluation inside the deferred import; bundling removes bare imports.
|
||||
for (const format of ['es', 'iife']) {
|
||||
await build({
|
||||
configFile: false, root, publicDir: false,
|
||||
build: {
|
||||
target: 'es2022', outDir: 'dist', emptyOutDir: false, minify: false,
|
||||
lib: {
|
||||
entry: path.join(root, 'src/index.ts'), name: 'HMOrgChart', formats: [format],
|
||||
fileName: () => format === 'es' ? 'index.js' : 'orgchart.browser.js',
|
||||
},
|
||||
rolldownOptions: { output: { codeSplitting: false } },
|
||||
},
|
||||
});
|
||||
}
|
||||
const typescriptManifest = require.resolve('typescript/package.json');
|
||||
const typescript = JSON.parse(await readFile(typescriptManifest, 'utf8'));
|
||||
execFileSync(process.execPath, [path.resolve(path.dirname(typescriptManifest), typescript.bin.tsc), '-p', path.join(root, 'tsconfig.build.json')], { stdio: 'inherit' });
|
||||
// Ship one self-contained public CSS asset. ?url and file:// consumers cannot
|
||||
// rely on source-relative imports or a bundler to discover private style files.
|
||||
const coreStyles = await readFile(path.join(root, 'src/styles/org-chart.css'), 'utf8');
|
||||
const inlinedStyles = await Promise.all(['design-tokens.css', 'employee-card.css', 'summary-sections.css', 'org-chart-content.css', 'org-chart-readonly.css', 'org-chart-p3-summary.css', 'employee-info-dialog.css'].map(async file => [file, await readFile(path.join(root, 'src/styles', file), 'utf8')]));
|
||||
let publicStyles = coreStyles;
|
||||
for (const [file, css] of inlinedStyles) publicStyles = publicStyles.replace(`@import './${file}';`, css);
|
||||
await writeFile(path.join(root, 'dist/style.css'), publicStyles);
|
||||
await cp(path.join(engineRoot, 'dist/css/orgchart.css'), path.join(root, 'dist/engine.css'));
|
||||
await mkdir(path.join(root, 'dist/licenses'), { recursive: true });
|
||||
await cp(path.join(engineRoot, 'LICENSE'), path.join(root, 'dist/licenses/orgchart-MIT.txt'));
|
||||
await writeFile(path.join(root, 'dist/licenses/README.txt'), 'Bundled engine: dabeng orgchart 6.0.0 (MIT). Upstream UMD references html2canvas/jspdf only for export, which this Core disables. Those export libraries are not bundled or supported. json-digger is not imported by the shipped UMD. The npm dependency retains the upstream dependency manifest.\n');
|
||||
Reference in new issue
Block a user