@pie-element/cli 0.1.2-next.6 → 0.1.2-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ export type BrowserEditorRuntime = {
2
+ name: string;
3
+ version: string;
4
+ views: Record<string, string>;
5
+ };
6
+ /**
7
+ * True when `dependencies`, directly or through the workspace @pie-lib packages they reach,
8
+ * include the editor engine, so the element's browser build bundles it.
9
+ */
10
+ export declare function reachesEditorEngine(root: string, dependencies: Record<string, string>): boolean;
11
+ /**
12
+ * pie.browserEditorRuntime for an element with the given ./browser/* views: the runtime's name,
13
+ * its current workspace version, and each view's variant. Null when the workspace has no runtime.
14
+ */
15
+ export declare function browserEditorRuntimeDeclaration(root: string, views: ReadonlySet<string>): BrowserEditorRuntime | null;
@@ -0,0 +1,55 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { WORKSPACE } from './sync-constants.js';
4
+ import { findWorkspacePieLibPackages } from './workspace-pie-lib.js';
5
+ const EDITOR_RUNTIME_MANIFEST = 'packages/shared/editor-runtime/package.json';
6
+ // tiptap and ProseMirror, which @pie-element/shared-editor-runtime provides. @tiptap/react stays
7
+ // inside the element.
8
+ const EDITOR_ENGINE_PACKAGE = /^(?:@tiptap\/(?!react$)|prosemirror-)/;
9
+ const VARIANT_VIEWS = ['delivery', 'author', 'print', 'controller'];
10
+ const readDependencies = (manifestPath) => {
11
+ const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
12
+ return { ...manifest.dependencies, ...manifest.optionalDependencies };
13
+ };
14
+ /**
15
+ * True when `dependencies`, directly or through the workspace @pie-lib packages they reach,
16
+ * include the editor engine, so the element's browser build bundles it.
17
+ */
18
+ export function reachesEditorEngine(root, dependencies) {
19
+ const libraries = findWorkspacePieLibPackages(root);
20
+ const visited = new Set();
21
+ const pending = Object.keys(dependencies);
22
+ while (pending.length > 0) {
23
+ const name = pending.pop();
24
+ if (visited.has(name))
25
+ continue;
26
+ visited.add(name);
27
+ if (EDITOR_ENGINE_PACKAGE.test(name))
28
+ return true;
29
+ const libraryDir = name.startsWith(WORKSPACE.PIE_LIB_PREFIX)
30
+ ? libraries.get(name.slice(WORKSPACE.PIE_LIB_PREFIX.length))
31
+ : undefined;
32
+ if (libraryDir)
33
+ pending.push(...Object.keys(readDependencies(join(libraryDir, 'package.json'))));
34
+ }
35
+ return false;
36
+ }
37
+ /**
38
+ * pie.browserEditorRuntime for an element with the given ./browser/* views: the runtime's name,
39
+ * its current workspace version, and each view's variant. Null when the workspace has no runtime.
40
+ */
41
+ export function browserEditorRuntimeDeclaration(root, views) {
42
+ const manifestPath = join(root, EDITOR_RUNTIME_MANIFEST);
43
+ if (!existsSync(manifestPath))
44
+ return null;
45
+ const runtime = JSON.parse(readFileSync(manifestPath, 'utf8'));
46
+ return {
47
+ name: runtime.name,
48
+ version: runtime.version,
49
+ views: Object.fromEntries(VARIANT_VIEWS.filter((view) => views.has(view)).map((view) => [
50
+ view,
51
+ `editor-runtime/${view}`,
52
+ ])),
53
+ };
54
+ }
55
+ //# sourceMappingURL=editor-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-runtime.js","sourceRoot":"","sources":["../../../src/lib/upstream/editor-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,uBAAuB,GAAG,6CAA6C,CAAC;AAC9E,iGAAiG;AACjG,sBAAsB;AACtB,MAAM,qBAAqB,GAAG,uCAAuC,CAAC;AACtE,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,CAAU,CAAC;AA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+B,CAC7C,IAAY,EACZ,KAA0B;IAE1B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/D,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,MAAM,CAAC,WAAW,CACvB,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC5D,IAAI;YACJ,kBAAkB,IAAI,EAAE;SACzB,CAAC,CACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { WORKSPACE } from './sync-constants.js';\nimport { findWorkspacePieLibPackages } from './workspace-pie-lib.js';\n\nconst EDITOR_RUNTIME_MANIFEST = 'packages/shared/editor-runtime/package.json';\n// tiptap and ProseMirror, which @pie-element/shared-editor-runtime provides. @tiptap/react stays\n// inside the element.\nconst EDITOR_ENGINE_PACKAGE = /^(?:@tiptap\\/(?!react$)|prosemirror-)/;\nconst VARIANT_VIEWS = ['delivery', 'author', 'print', 'controller'] as const;\n\nexport type BrowserEditorRuntime = {\n name: string;\n version: string;\n views: Record<string, string>;\n};\n\nconst readDependencies = (manifestPath: string): Record<string, string> => {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));\n return { ...manifest.dependencies, ...manifest.optionalDependencies };\n};\n\n/**\n * True when `dependencies`, directly or through the workspace @pie-lib packages they reach,\n * include the editor engine, so the element's browser build bundles it.\n */\nexport function reachesEditorEngine(root: string, dependencies: Record<string, string>): boolean {\n const libraries = findWorkspacePieLibPackages(root);\n const visited = new Set<string>();\n const pending = Object.keys(dependencies);\n while (pending.length > 0) {\n const name = pending.pop() as string;\n if (visited.has(name)) continue;\n visited.add(name);\n if (EDITOR_ENGINE_PACKAGE.test(name)) return true;\n const libraryDir = name.startsWith(WORKSPACE.PIE_LIB_PREFIX)\n ? libraries.get(name.slice(WORKSPACE.PIE_LIB_PREFIX.length))\n : undefined;\n if (libraryDir)\n pending.push(...Object.keys(readDependencies(join(libraryDir, 'package.json'))));\n }\n return false;\n}\n\n/**\n * pie.browserEditorRuntime for an element with the given ./browser/* views: the runtime's name,\n * its current workspace version, and each view's variant. Null when the workspace has no runtime.\n */\nexport function browserEditorRuntimeDeclaration(\n root: string,\n views: ReadonlySet<string>\n): BrowserEditorRuntime | null {\n const manifestPath = join(root, EDITOR_RUNTIME_MANIFEST);\n if (!existsSync(manifestPath)) return null;\n const runtime = JSON.parse(readFileSync(manifestPath, 'utf8'));\n return {\n name: runtime.name,\n version: runtime.version,\n views: Object.fromEntries(\n VARIANT_VIEWS.filter((view) => views.has(view)).map((view) => [\n view,\n `editor-runtime/${view}`,\n ])\n ),\n };\n}\n"]}
@@ -40,10 +40,16 @@ export declare const PACKAGE_DEFAULTS: {
40
40
  readonly FILES: readonly ["dist", "src"];
41
41
  };
42
42
  export declare const ELEMENT_BROWSER_VITE_CONFIG = "../../../tools/vite/element-browser.config.ts";
43
+ export declare const ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG = "../../../tools/vite/element-browser-editor-runtime.config.ts";
43
44
  export declare const ELEMENT_LEGACY_PRINT_VITE_CONFIG = "../../../tools/vite/element-legacy-print.config.ts";
44
45
  export type ElementBuildLanes = {
45
46
  /** dist/browser/** - the browser ESM surface consumed by pie-players. */
46
47
  browser?: boolean;
48
+ /**
49
+ * dist/browser/editor-runtime/** - the browser build with the editor engine imported from
50
+ * @pie-element/shared-editor-runtime, declared in pie.browserEditorRuntime. Needs `browser`.
51
+ */
52
+ editorRuntime?: boolean;
47
53
  /**
48
54
  * module/print.js - a self-contained print bundle (React inlined, zero
49
55
  * externals) for the unmodified @pie-framework/pie-print client loader, which
@@ -54,6 +54,7 @@ export const PACKAGE_DEFAULTS = {
54
54
  };
55
55
  // Build scripts
56
56
  export const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';
57
+ export const ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG = '../../../tools/vite/element-browser-editor-runtime.config.ts';
57
58
  export const ELEMENT_LEGACY_PRINT_VITE_CONFIG = '../../../tools/vite/element-legacy-print.config.ts';
58
59
  /**
59
60
  * Compose a synced element's build script from the lanes it needs.
@@ -70,6 +71,9 @@ export function composeElementBuildScript(lanes = {}) {
70
71
  const steps = ['bun x vite build'];
71
72
  if (lanes.browser) {
72
73
  steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);
74
+ if (lanes.editorRuntime) {
75
+ steps.push(`bun x vite build --config ${ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG}`);
76
+ }
73
77
  }
74
78
  if (lanes.legacyPrint) {
75
79
  steps.push(`bun x vite build --config ${ELEMENT_LEGACY_PRINT_VITE_CONFIG}`);
@@ -1 +1 @@
1
- {"version":3,"file":"sync-constants.js","sourceRoot":"","sources":["../../../src/lib/upstream/sync-constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,iBAAiB;IAC/B,OAAO,EAAE,YAAY;IACrB,eAAe,EAAE,GAAG;CACZ,CAAC;AAEX,gCAAgC;AAChC,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,aAAa;IACtB,cAAc,EAAE,WAAW;IAC3B,kBAAkB,EAAE,eAAe;IACnC,oBAAoB,EAAE,iBAAiB;CAC/B,CAAC;AAEX,8DAA8D;AAC9D,2DAA2D;AAC3D,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AAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,6BAA6B,2BAA2B,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,6BAA6B,gCAAgC,EAAE,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC9D,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED,iFAAiF;AACjF,gFAAgF;AAChF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,KAAK,EAAE,yBAAyB,EAAE;IAClC,kBAAkB,EAAE,yBAAyB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAChE,eAAe,EAAE,yBAAyB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC1D,2BAA2B,EAAE,yBAAyB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrF,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,kBAAkB;CAChB,CAAC;AAEX,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAEjE,wBAAwB;AACxB,MAAM,CAAC,MAAM,YAAY,GAAG,6BAA6B,CAAC","sourcesContent":["/**\n * Shared constants for upstream sync operations\n */\n\n// Default repository paths\nexport const DEFAULT_PATHS = {\n PIE_ELEMENTS: '../pie-elements',\n PIE_LIB: '../pie-lib',\n PIE_ELEMENTS_NG: '.',\n} as const;\n\n// Workspace dependency patterns\nexport const WORKSPACE = {\n VERSION: 'workspace:*',\n PIE_LIB_PREFIX: '@pie-lib/',\n PIE_ELEMENT_PREFIX: '@pie-element/',\n PIE_FRAMEWORK_PREFIX: '@pie-framework/',\n} as const;\n\n// Upstream element packages intentionally excluded from sync.\n// These templates are not used in pie-elements-ng runtime.\nexport const EXCLUDED_UPSTREAM_ELEMENTS = ['boilerplate-item-type'] as const;\n\n// Upstream @pie-lib packages intentionally excluded from sync.\n// math-rendering stays local (wrapper re-exports shared MathJax adapter).\n// translator lives in packages/shared: its strings serve the Svelte elements too.\nexport const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering', 'translator'] as const;\n\n// Build tool versions\nexport const BUILD_TOOLS = {\n VITE: '^8.0.1',\n TYPESCRIPT: '^5.9.3',\n VITE_REACT_PLUGIN: '^6.0.1',\n} as const;\n\n// React versions. Element packages also depend on React from ^18.2.0, the browser ESM policy\n// version, so their peer range starts there.\nexport const REACT = {\n ELEMENT_PEER_RANGE: '^18.2.0 || ^19.0.0',\n LIBRARY_PEER_RANGE: '^18.0.0 || ^19.0.0',\n TYPES_VERSION: '^18.2.0',\n} as const;\n\n// Directory patterns to skip\nexport const SKIP_PATTERNS = {\n TEST_DIRS: ['__tests__', '__mocks__'],\n FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],\n} as const;\n\n// File types\nexport const FILE_TYPES = {\n JS: '.js',\n JSX: '.jsx',\n TS: '.ts',\n TSX: '.tsx',\n} as const;\n\n// Package.json defaults\nexport const PACKAGE_DEFAULTS = {\n TYPE: 'module',\n SIDE_EFFECTS: false,\n FILES: ['dist', 'src'],\n} as const;\n\n// Build scripts\nexport const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';\nexport const ELEMENT_LEGACY_PRINT_VITE_CONFIG =\n '../../../tools/vite/element-legacy-print.config.ts';\n\nexport type ElementBuildLanes = {\n /** dist/browser/** - the browser ESM surface consumed by pie-players. */\n browser?: boolean;\n /**\n * module/print.js - a self-contained print bundle (React inlined, zero\n * externals) for the unmodified @pie-framework/pie-print client loader, which\n * uses a bare import() with no import map and so cannot read exports[\"./print\"].\n * See PIE-839 and docs/PRINT_SUPPORT.md.\n */\n legacyPrint?: boolean;\n /** dist/index.iife.js - the fully self-contained script-tag surface. */\n iife?: boolean;\n};\n\n/**\n * Compose a synced element's build script from the lanes it needs.\n *\n * Composed rather than enumerated on purpose. This used to be four hardcoded\n * constants covering the browser/iife combinations, so when PIE-839 added the\n * legacy print lane there was nowhere for it to live: it was written straight\n * into the twelve print-enabled manifests, and the next sync regenerated\n * `scripts.build` from the constants and silently dropped it. Print then broke\n * for every synced element with no failing check. Adding a lane here keeps it in\n * the generated output instead of relying on a hand-edited manifest surviving.\n */\nexport function composeElementBuildScript(lanes: ElementBuildLanes = {}): string {\n const steps = ['bun x vite build'];\n if (lanes.browser) {\n steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);\n }\n if (lanes.legacyPrint) {\n steps.push(`bun x vite build --config ${ELEMENT_LEGACY_PRINT_VITE_CONFIG}`);\n }\n if (lanes.iife) {\n steps.push('bun x vite build --config vite.config.iife.ts');\n }\n steps.push('bun x tsc --emitDeclarationOnly');\n return steps.join(' && ');\n}\n\n// Derived from composeElementBuildScript so the named variants cannot drift from\n// the composer. Prefer calling the composer directly for new lane combinations.\nexport const SCRIPTS = {\n BUILD: composeElementBuildScript(),\n BUILD_WITH_BROWSER: composeElementBuildScript({ browser: true }),\n BUILD_WITH_IIFE: composeElementBuildScript({ iife: true }),\n BUILD_WITH_IIFE_AND_BROWSER: composeElementBuildScript({ browser: true, iife: true }),\n DEV: 'bun x vite',\n DEMO: 'bun x vite --mode demo',\n TEST: 'bun x vitest run',\n} as const;\n\n// Compatibility report file\nexport const COMPATIBILITY_FILE = './.compatibility/report.json';\n\n// Upstream history file\nexport const HISTORY_FILE = '.upstream-sync-history.json';\n"]}
1
+ {"version":3,"file":"sync-constants.js","sourceRoot":"","sources":["../../../src/lib/upstream/sync-constants.ts"],"names":[],"mappings":"AAAA;;GAE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AAyB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrF,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,kBAAkB;CAChB,CAAC;AAEX,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AAEjE,wBAAwB;AACxB,MAAM,CAAC,MAAM,YAAY,GAAG,6BAA6B,CAAC","sourcesContent":["/**\n * Shared constants for upstream sync operations\n */\n\n// Default repository paths\nexport const DEFAULT_PATHS = {\n PIE_ELEMENTS: '../pie-elements',\n PIE_LIB: '../pie-lib',\n PIE_ELEMENTS_NG: '.',\n} as const;\n\n// Workspace dependency patterns\nexport const WORKSPACE = {\n VERSION: 'workspace:*',\n PIE_LIB_PREFIX: '@pie-lib/',\n PIE_ELEMENT_PREFIX: '@pie-element/',\n PIE_FRAMEWORK_PREFIX: '@pie-framework/',\n} as const;\n\n// Upstream element packages intentionally excluded from sync.\n// These templates are not used in pie-elements-ng runtime.\nexport const EXCLUDED_UPSTREAM_ELEMENTS = ['boilerplate-item-type'] as const;\n\n// Upstream @pie-lib packages intentionally excluded from sync.\n// math-rendering stays local (wrapper re-exports shared MathJax adapter).\n// translator lives in packages/shared: its strings serve the Svelte elements too.\nexport const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering', 'translator'] as const;\n\n// Build tool versions\nexport const BUILD_TOOLS = {\n VITE: '^8.0.1',\n TYPESCRIPT: '^5.9.3',\n VITE_REACT_PLUGIN: '^6.0.1',\n} as const;\n\n// React versions. Element packages also depend on React from ^18.2.0, the browser ESM policy\n// version, so their peer range starts there.\nexport const REACT = {\n ELEMENT_PEER_RANGE: '^18.2.0 || ^19.0.0',\n LIBRARY_PEER_RANGE: '^18.0.0 || ^19.0.0',\n TYPES_VERSION: '^18.2.0',\n} as const;\n\n// Directory patterns to skip\nexport const SKIP_PATTERNS = {\n TEST_DIRS: ['__tests__', '__mocks__'],\n FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],\n} as const;\n\n// File types\nexport const FILE_TYPES = {\n JS: '.js',\n JSX: '.jsx',\n TS: '.ts',\n TSX: '.tsx',\n} as const;\n\n// Package.json defaults\nexport const PACKAGE_DEFAULTS = {\n TYPE: 'module',\n SIDE_EFFECTS: false,\n FILES: ['dist', 'src'],\n} as const;\n\n// Build scripts\nexport const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';\nexport const ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG =\n '../../../tools/vite/element-browser-editor-runtime.config.ts';\nexport const ELEMENT_LEGACY_PRINT_VITE_CONFIG =\n '../../../tools/vite/element-legacy-print.config.ts';\n\nexport type ElementBuildLanes = {\n /** dist/browser/** - the browser ESM surface consumed by pie-players. */\n browser?: boolean;\n /**\n * dist/browser/editor-runtime/** - the browser build with the editor engine imported from\n * @pie-element/shared-editor-runtime, declared in pie.browserEditorRuntime. Needs `browser`.\n */\n editorRuntime?: boolean;\n /**\n * module/print.js - a self-contained print bundle (React inlined, zero\n * externals) for the unmodified @pie-framework/pie-print client loader, which\n * uses a bare import() with no import map and so cannot read exports[\"./print\"].\n * See PIE-839 and docs/PRINT_SUPPORT.md.\n */\n legacyPrint?: boolean;\n /** dist/index.iife.js - the fully self-contained script-tag surface. */\n iife?: boolean;\n};\n\n/**\n * Compose a synced element's build script from the lanes it needs.\n *\n * Composed rather than enumerated on purpose. This used to be four hardcoded\n * constants covering the browser/iife combinations, so when PIE-839 added the\n * legacy print lane there was nowhere for it to live: it was written straight\n * into the twelve print-enabled manifests, and the next sync regenerated\n * `scripts.build` from the constants and silently dropped it. Print then broke\n * for every synced element with no failing check. Adding a lane here keeps it in\n * the generated output instead of relying on a hand-edited manifest surviving.\n */\nexport function composeElementBuildScript(lanes: ElementBuildLanes = {}): string {\n const steps = ['bun x vite build'];\n if (lanes.browser) {\n steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);\n if (lanes.editorRuntime) {\n steps.push(`bun x vite build --config ${ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG}`);\n }\n }\n if (lanes.legacyPrint) {\n steps.push(`bun x vite build --config ${ELEMENT_LEGACY_PRINT_VITE_CONFIG}`);\n }\n if (lanes.iife) {\n steps.push('bun x vite build --config vite.config.iife.ts');\n }\n steps.push('bun x tsc --emitDeclarationOnly');\n return steps.join(' && ');\n}\n\n// Derived from composeElementBuildScript so the named variants cannot drift from\n// the composer. Prefer calling the composer directly for new lane combinations.\nexport const SCRIPTS = {\n BUILD: composeElementBuildScript(),\n BUILD_WITH_BROWSER: composeElementBuildScript({ browser: true }),\n BUILD_WITH_IIFE: composeElementBuildScript({ iife: true }),\n BUILD_WITH_IIFE_AND_BROWSER: composeElementBuildScript({ browser: true, iife: true }),\n DEV: 'bun x vite',\n DEMO: 'bun x vite --mode demo',\n TEST: 'bun x vitest run',\n} as const;\n\n// Compatibility report file\nexport const COMPATIBILITY_FILE = './.compatibility/report.json';\n\n// Upstream history file\nexport const HISTORY_FILE = '.upstream-sync-history.json';\n"]}
@@ -74,6 +74,12 @@ export declare function transformClassnamesToClsx(content: string): string;
74
74
  * `new Combination(seed, size)` enumerates the same pairs in the same order.
75
75
  */
76
76
  export declare function transformJsCombinatoricsToV2(content: string): string;
77
+ /**
78
+ * Rewrite named imports from COMMONJS_DEFAULT_IMPORTS packages to a default import plus a
79
+ * destructure, so `import { camelizeKeys } from 'humps'` becomes
80
+ * `import humps from 'humps'; const { camelizeKeys } = humps;`.
81
+ */
82
+ export declare function transformCommonJsNamedImports(content: string): string;
77
83
  /**
78
84
  * Replace react-input-autosize with the local ESM autosize input component.
79
85
  *
@@ -478,6 +478,56 @@ export function transformJsCombinatoricsToV2(content) {
478
478
  visit(sourceFile);
479
479
  return applySourceEdits(content, edits);
480
480
  }
481
+ /**
482
+ * CommonJS packages whose exports Node's ESM loader cannot detect, mapped to the binding the
483
+ * rewrite imports them as. A named import from one of them fails to link when a host imports
484
+ * the built controller in Node; a default import is `module.exports` in Node and in bundlers.
485
+ */
486
+ const COMMONJS_DEFAULT_IMPORTS = {
487
+ humps: 'humps',
488
+ };
489
+ /**
490
+ * Rewrite named imports from COMMONJS_DEFAULT_IMPORTS packages to a default import plus a
491
+ * destructure, so `import { camelizeKeys } from 'humps'` becomes
492
+ * `import humps from 'humps'; const { camelizeKeys } = humps;`.
493
+ */
494
+ export function transformCommonJsNamedImports(content) {
495
+ if (!Object.keys(COMMONJS_DEFAULT_IMPORTS).some((name) => content.includes(name))) {
496
+ return content;
497
+ }
498
+ const sourceFile = ts.createSourceFile('source.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
499
+ const edits = [];
500
+ for (const statement of sourceFile.statements) {
501
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
502
+ continue;
503
+ }
504
+ const specifier = statement.moduleSpecifier.text;
505
+ if (!Object.hasOwn(COMMONJS_DEFAULT_IMPORTS, specifier)) {
506
+ continue;
507
+ }
508
+ const clause = statement.importClause;
509
+ const bindings = clause?.namedBindings;
510
+ if (!clause ||
511
+ clause.isTypeOnly ||
512
+ !bindings ||
513
+ !ts.isNamedImports(bindings) ||
514
+ bindings.elements.length === 0 ||
515
+ bindings.elements.some((element) => element.isTypeOnly)) {
516
+ continue;
517
+ }
518
+ const moduleBinding = clause.name?.text ?? COMMONJS_DEFAULT_IMPORTS[specifier];
519
+ const properties = bindings.elements.map((element) => element.propertyName
520
+ ? `${element.propertyName.text}: ${element.name.text}`
521
+ : element.name.text);
522
+ const quoted = quoteLike(specifier, statement.moduleSpecifier.getText(sourceFile));
523
+ edits.push({
524
+ start: statement.getStart(sourceFile),
525
+ end: statement.getEnd(),
526
+ text: `import ${moduleBinding} from ${quoted};\nconst { ${properties.join(', ')} } = ${moduleBinding};`,
527
+ });
528
+ }
529
+ return applySourceEdits(content, edits);
530
+ }
481
531
  /**
482
532
  * Replace react-input-autosize with the local ESM autosize input component.
483
533
  *