@pie-element/cli 0.1.2-next.1 → 0.1.2-next.13
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.
- package/dist/commands/packages/create-react-elements.js +12 -31
- package/dist/commands/packages/create-react-elements.js.map +1 -1
- package/dist/commands/packages/init-synced-elements.js +3 -5
- package/dist/commands/packages/init-synced-elements.js.map +1 -1
- package/dist/commands/upstream/sync.js +10 -14
- package/dist/commands/upstream/sync.js.map +1 -1
- package/dist/lib/upstream/editor-runtime.d.ts +15 -0
- package/dist/lib/upstream/editor-runtime.js +55 -0
- package/dist/lib/upstream/editor-runtime.js.map +1 -0
- package/dist/lib/upstream/sync-compatibility.d.ts +0 -8
- package/dist/lib/upstream/sync-compatibility.js +0 -31
- package/dist/lib/upstream/sync-compatibility.js.map +1 -1
- package/dist/lib/upstream/sync-constants.d.ts +20 -12
- package/dist/lib/upstream/sync-constants.js +44 -15
- package/dist/lib/upstream/sync-constants.js.map +1 -1
- package/dist/lib/upstream/sync-imports.d.ts +14 -21
- package/dist/lib/upstream/sync-imports.js +106 -77
- package/dist/lib/upstream/sync-imports.js.map +1 -1
- package/dist/lib/upstream/sync-package-json.d.ts +0 -19
- package/dist/lib/upstream/sync-package-json.js +0 -58
- package/dist/lib/upstream/sync-package-json.js.map +1 -1
- package/dist/lib/upstream/sync-package-manager.d.ts +6 -0
- package/dist/lib/upstream/sync-package-manager.js +84 -31
- package/dist/lib/upstream/sync-package-manager.js.map +1 -1
- package/dist/lib/upstream/sync-react-strategy.js +3 -3
- package/dist/lib/upstream/sync-react-strategy.js.map +1 -1
- package/dist/lib/upstream/sync-source-tree.js +3 -1
- package/dist/lib/upstream/sync-source-tree.js.map +1 -1
- package/dist/lib/upstream/sync-transforms.d.ts +2 -2
- package/dist/lib/upstream/sync-transforms.js +5 -3
- package/dist/lib/upstream/sync-transforms.js.map +1 -1
- package/dist/lib/upstream/sync-vite-config.d.ts +0 -4
- package/dist/lib/upstream/sync-vite-config.js +1 -12
- package/dist/lib/upstream/sync-vite-config.js.map +1 -1
- package/dist/lib/upstream/workspace-pie-lib.d.ts +2 -0
- package/dist/lib/upstream/workspace-pie-lib.js +29 -0
- package/dist/lib/upstream/workspace-pie-lib.js.map +1 -0
- package/dist/utils/compatibility.d.ts +0 -15
- package/dist/utils/compatibility.js +0 -34
- package/dist/utils/compatibility.js.map +1 -1
- package/dist/utils/conversion.d.ts +0 -5
- package/dist/utils/conversion.js +0 -21
- package/dist/utils/conversion.js.map +1 -1
- package/dist/utils/git.d.ts +7 -1
- package/dist/utils/git.js +17 -22
- package/dist/utils/git.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,6 +7,17 @@ export const DEFAULT_PATHS = {
|
|
|
7
7
|
PIE_LIB: '../pie-lib',
|
|
8
8
|
PIE_ELEMENTS_NG: '.',
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Module source substituted for `debug` in per-element IIFE builds. Carries the
|
|
12
|
+
* module-level `debug.log` and the instance methods element code calls.
|
|
13
|
+
*/
|
|
14
|
+
export const IIFE_DEBUG_SHIM_SOURCE = "const noop = () => {}; function debug() { const log = function () {}; log.enabled = false; log.log = noop; log.extend = () => log; log.destroy = noop; return log; } debug.log = noop; debug.enable = noop; debug.disable = () => ''; debug.enabled = () => false; export default debug;";
|
|
15
|
+
/**
|
|
16
|
+
* Module source substituted for `prop-types` in per-element IIFE builds. It mirrors
|
|
17
|
+
* prop-types' production shims: every validator is callable and carries `isRequired`,
|
|
18
|
+
* so `PropTypes.oneOf([...]).isRequired` evaluates at module load.
|
|
19
|
+
*/
|
|
20
|
+
export const IIFE_PROP_TYPES_SHIM_SOURCE = 'const shim = function () { return null; }; shim.isRequired = shim; const getShim = () => shim; export const array = shim, bigint = shim, bool = shim, func = shim, number = shim, object = shim, string = shim, symbol = shim, any = shim, element = shim, elementType = shim, node = shim; export const arrayOf = getShim, instanceOf = getShim, objectOf = getShim, oneOf = getShim, oneOfType = getShim, shape = getShim, exact = getShim; export const checkPropTypes = () => {}; export const resetWarningCache = () => {}; const types = { array, bigint, bool, func, number, object, string, symbol, any, element, elementType, node, arrayOf, instanceOf, objectOf, oneOf, oneOfType, shape, exact, checkPropTypes, resetWarningCache }; types.PropTypes = types; export { types as PropTypes }; export default types;';
|
|
10
21
|
// Workspace dependency patterns
|
|
11
22
|
export const WORKSPACE = {
|
|
12
23
|
VERSION: 'workspace:*',
|
|
@@ -19,30 +30,44 @@ export const WORKSPACE = {
|
|
|
19
30
|
export const EXCLUDED_UPSTREAM_ELEMENTS = ['boilerplate-item-type'];
|
|
20
31
|
// Upstream @pie-lib packages intentionally excluded from sync.
|
|
21
32
|
// math-rendering stays local (wrapper re-exports shared MathJax adapter).
|
|
22
|
-
|
|
33
|
+
// translator lives in packages/shared: its strings serve the Svelte elements too.
|
|
34
|
+
export const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering', 'translator'];
|
|
35
|
+
// Upstream source files that sync does not re-emit. Each was reachable from no entry of its
|
|
36
|
+
// package and was deleted here; the values are the files' `@synced-from` paths.
|
|
37
|
+
export const RETIRED_UPSTREAM_SOURCE_FILES = new Set([
|
|
38
|
+
'pie-elements/packages/graphing/src/utils.js',
|
|
39
|
+
'pie-elements/packages/image-cloze-association/src/constants.js',
|
|
40
|
+
'pie-elements/packages/likert/src/session-updater.js',
|
|
41
|
+
'pie-elements/packages/match/configure/src/common.jsx',
|
|
42
|
+
'pie-elements/packages/matrix/src/session-updater.js',
|
|
43
|
+
'pie-elements/packages/number-line/src/number-line/point-chooser/styles.js',
|
|
44
|
+
'pie-elements/packages/placement-ordering/configure/src/help.jsx',
|
|
45
|
+
'pie-lib/packages/charting/src/tool-menu.jsx',
|
|
46
|
+
'pie-lib/packages/drag/src/drag-type.js',
|
|
47
|
+
'pie-lib/packages/drag/src/preview-component.jsx',
|
|
48
|
+
'pie-lib/packages/editable-html-tip-tap/src/components/media/MediaWrapper.jsx',
|
|
49
|
+
'pie-lib/packages/editable-html-tip-tap/src/styles/editorContainerStyles.js',
|
|
50
|
+
'pie-lib/packages/editable-html-tip-tap/src/theme.js',
|
|
51
|
+
'pie-lib/packages/graphing-solution-set/src/toggle-bar.jsx',
|
|
52
|
+
'pie-lib/packages/graphing-solution-set/src/tools/polygon/line.jsx',
|
|
53
|
+
'pie-lib/packages/graphing-solution-set/src/tools/shared/line/line-path.jsx',
|
|
54
|
+
'pie-lib/packages/graphing-solution-set/src/tools/shared/line/with-root-edge.jsx',
|
|
55
|
+
'pie-lib/packages/mask-markup/src/components/correct-input.jsx',
|
|
56
|
+
'pie-lib/packages/mask-markup/src/components/input.jsx',
|
|
57
|
+
'pie-lib/packages/math-input/src/math-input.jsx',
|
|
58
|
+
]);
|
|
23
59
|
// Build tool versions
|
|
24
60
|
export const BUILD_TOOLS = {
|
|
25
61
|
VITE: '^8.0.1',
|
|
26
62
|
TYPESCRIPT: '^5.9.3',
|
|
27
63
|
VITE_REACT_PLUGIN: '^6.0.1',
|
|
28
64
|
};
|
|
29
|
-
// React versions
|
|
65
|
+
// React versions. Library packages take React as a peer from the element that renders them;
|
|
66
|
+
// element packages depend on React at the browser ESM policy version and declare no React peer.
|
|
30
67
|
export const REACT = {
|
|
31
|
-
|
|
68
|
+
LIBRARY_PEER_RANGE: '^18.0.0 || ^19.0.0',
|
|
32
69
|
TYPES_VERSION: '^18.2.0',
|
|
33
70
|
};
|
|
34
|
-
// Directory patterns to skip
|
|
35
|
-
export const SKIP_PATTERNS = {
|
|
36
|
-
TEST_DIRS: ['__tests__', '__mocks__'],
|
|
37
|
-
FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],
|
|
38
|
-
};
|
|
39
|
-
// File types
|
|
40
|
-
export const FILE_TYPES = {
|
|
41
|
-
JS: '.js',
|
|
42
|
-
JSX: '.jsx',
|
|
43
|
-
TS: '.ts',
|
|
44
|
-
TSX: '.tsx',
|
|
45
|
-
};
|
|
46
71
|
// Package.json defaults
|
|
47
72
|
export const PACKAGE_DEFAULTS = {
|
|
48
73
|
TYPE: 'module',
|
|
@@ -51,6 +76,7 @@ export const PACKAGE_DEFAULTS = {
|
|
|
51
76
|
};
|
|
52
77
|
// Build scripts
|
|
53
78
|
export const ELEMENT_BROWSER_VITE_CONFIG = '../../../tools/vite/element-browser.config.ts';
|
|
79
|
+
export const ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG = '../../../tools/vite/element-browser-editor-runtime.config.ts';
|
|
54
80
|
export const ELEMENT_LEGACY_PRINT_VITE_CONFIG = '../../../tools/vite/element-legacy-print.config.ts';
|
|
55
81
|
/**
|
|
56
82
|
* Compose a synced element's build script from the lanes it needs.
|
|
@@ -67,6 +93,9 @@ export function composeElementBuildScript(lanes = {}) {
|
|
|
67
93
|
const steps = ['bun x vite build'];
|
|
68
94
|
if (lanes.browser) {
|
|
69
95
|
steps.push(`bun x vite build --config ${ELEMENT_BROWSER_VITE_CONFIG}`);
|
|
96
|
+
if (lanes.editorRuntime) {
|
|
97
|
+
steps.push(`bun x vite build --config ${ELEMENT_BROWSER_EDITOR_RUNTIME_VITE_CONFIG}`);
|
|
98
|
+
}
|
|
70
99
|
}
|
|
71
100
|
if (lanes.legacyPrint) {
|
|
72
101
|
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,iBAA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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).\nexport const EXCLUDED_UPSTREAM_PIE_LIB_PACKAGES = ['math-rendering'] 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\nexport const REACT = {\n VERSION: '^18.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;;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;;;GAGG;AACH,MAAM,CA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AAE,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/**\n * Module source substituted for `debug` in per-element IIFE builds. Carries the\n * module-level `debug.log` and the instance methods element code calls.\n */\nexport const IIFE_DEBUG_SHIM_SOURCE =\n \"const noop = () => {}; function debug() { const log = function () {}; log.enabled = false; log.log = noop; log.extend = () => log; log.destroy = noop; return log; } debug.log = noop; debug.enable = noop; debug.disable = () => ''; debug.enabled = () => false; export default debug;\";\n\n/**\n * Module source substituted for `prop-types` in per-element IIFE builds. It mirrors\n * prop-types' production shims: every validator is callable and carries `isRequired`,\n * so `PropTypes.oneOf([...]).isRequired` evaluates at module load.\n */\nexport const IIFE_PROP_TYPES_SHIM_SOURCE =\n 'const shim = function () { return null; }; shim.isRequired = shim; const getShim = () => shim; export const array = shim, bigint = shim, bool = shim, func = shim, number = shim, object = shim, string = shim, symbol = shim, any = shim, element = shim, elementType = shim, node = shim; export const arrayOf = getShim, instanceOf = getShim, objectOf = getShim, oneOf = getShim, oneOfType = getShim, shape = getShim, exact = getShim; export const checkPropTypes = () => {}; export const resetWarningCache = () => {}; const types = { array, bigint, bool, func, number, object, string, symbol, any, element, elementType, node, arrayOf, instanceOf, objectOf, oneOf, oneOfType, shape, exact, checkPropTypes, resetWarningCache }; types.PropTypes = types; export { types as PropTypes }; export default types;';\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// Upstream source files that sync does not re-emit. Each was reachable from no entry of its\n// package and was deleted here; the values are the files' `@synced-from` paths.\nexport const RETIRED_UPSTREAM_SOURCE_FILES: ReadonlySet<string> = new Set([\n 'pie-elements/packages/graphing/src/utils.js',\n 'pie-elements/packages/image-cloze-association/src/constants.js',\n 'pie-elements/packages/likert/src/session-updater.js',\n 'pie-elements/packages/match/configure/src/common.jsx',\n 'pie-elements/packages/matrix/src/session-updater.js',\n 'pie-elements/packages/number-line/src/number-line/point-chooser/styles.js',\n 'pie-elements/packages/placement-ordering/configure/src/help.jsx',\n 'pie-lib/packages/charting/src/tool-menu.jsx',\n 'pie-lib/packages/drag/src/drag-type.js',\n 'pie-lib/packages/drag/src/preview-component.jsx',\n 'pie-lib/packages/editable-html-tip-tap/src/components/media/MediaWrapper.jsx',\n 'pie-lib/packages/editable-html-tip-tap/src/styles/editorContainerStyles.js',\n 'pie-lib/packages/editable-html-tip-tap/src/theme.js',\n 'pie-lib/packages/graphing-solution-set/src/toggle-bar.jsx',\n 'pie-lib/packages/graphing-solution-set/src/tools/polygon/line.jsx',\n 'pie-lib/packages/graphing-solution-set/src/tools/shared/line/line-path.jsx',\n 'pie-lib/packages/graphing-solution-set/src/tools/shared/line/with-root-edge.jsx',\n 'pie-lib/packages/mask-markup/src/components/correct-input.jsx',\n 'pie-lib/packages/mask-markup/src/components/input.jsx',\n 'pie-lib/packages/math-input/src/math-input.jsx',\n]);\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. Library packages take React as a peer from the element that renders them;\n// element packages depend on React at the browser ESM policy version and declare no React peer.\nexport const REACT = {\n LIBRARY_PEER_RANGE: '^18.0.0 || ^19.0.0',\n TYPES_VERSION: '^18.2.0',\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"]}
|
|
@@ -35,21 +35,6 @@ export declare function reexportTokenTypes(code: string, filePath: string): stri
|
|
|
35
35
|
* when configure directory is not synced (ESM-incompatible due to Slate v0.x)
|
|
36
36
|
*/
|
|
37
37
|
export declare function inlineConfigureDefaults(code: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Determine if a file should have .tsx extension based on content
|
|
40
|
-
*/
|
|
41
|
-
export declare function shouldUseTsxExtension(content: string, originalPath: string): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Convert CommonJS module.exports to ES module exports
|
|
44
|
-
*
|
|
45
|
-
* Handles patterns like:
|
|
46
|
-
* module.exports = { foo: ..., bar: ... }
|
|
47
|
-
*
|
|
48
|
-
* Converts to:
|
|
49
|
-
* export const foo = ...;
|
|
50
|
-
* export const bar = ...;
|
|
51
|
-
*/
|
|
52
|
-
export declare function convertModuleExportsToEsm(content: string): string;
|
|
53
38
|
/**
|
|
54
39
|
* Transform lodash and lodash-es imports to the vendored shared lodash package.
|
|
55
40
|
*
|
|
@@ -58,7 +43,6 @@ export declare function convertModuleExportsToEsm(content: string): string;
|
|
|
58
43
|
* resolution while keeping import shapes tree-shakeable.
|
|
59
44
|
*/
|
|
60
45
|
export declare function transformLodashToVendoredLodash(content: string): string;
|
|
61
|
-
export declare const transformLodashToLodashEs: typeof transformLodashToVendoredLodash;
|
|
62
46
|
/**
|
|
63
47
|
* Transform classnames imports to clsx.
|
|
64
48
|
*
|
|
@@ -66,6 +50,20 @@ export declare const transformLodashToLodashEs: typeof transformLodashToVendored
|
|
|
66
50
|
* entrypoint, so synced source should prefer it over the CommonJS-era package.
|
|
67
51
|
*/
|
|
68
52
|
export declare function transformClassnamesToClsx(content: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Rewrite js-combinatorics 0.5 `combination(seed, size)` calls to the 2.x `Combination` class.
|
|
55
|
+
*
|
|
56
|
+
* Upstream depends on 0.5, a UMD script with no ESM entrypoint; synced packages depend on 2.x,
|
|
57
|
+
* where `combination(n, k)` counts combinations as a BigInt and throws when given an array.
|
|
58
|
+
* `new Combination(seed, size)` enumerates the same pairs in the same order.
|
|
59
|
+
*/
|
|
60
|
+
export declare function transformJsCombinatoricsToV2(content: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Rewrite named imports from COMMONJS_DEFAULT_IMPORTS packages to a default import plus a
|
|
63
|
+
* destructure, so `import { camelizeKeys } from 'humps'` becomes
|
|
64
|
+
* `import humps from 'humps'; const { camelizeKeys } = humps;`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function transformCommonJsNamedImports(content: string): string;
|
|
69
67
|
/**
|
|
70
68
|
* Replace react-input-autosize with the local ESM autosize input component.
|
|
71
69
|
*
|
|
@@ -83,11 +81,6 @@ export declare function transformReactInputAutosizeToLocal(content: string, sour
|
|
|
83
81
|
* parsing.
|
|
84
82
|
*/
|
|
85
83
|
export declare function transformConfigUiMathjsToLocalFraction(content: string, sourcePath?: string): string;
|
|
86
|
-
/**
|
|
87
|
-
* Compatibility wrapper retained for older callers. Lodash imports now target
|
|
88
|
-
* the vendored shared package rather than lodash-es deep modules.
|
|
89
|
-
*/
|
|
90
|
-
export declare function transformLodashEsDeepImportsToFullySpecified(content: string): string;
|
|
91
84
|
/**
|
|
92
85
|
* Ensure known strict-ESM deep imports include explicit file extensions.
|
|
93
86
|
*
|
|
@@ -208,75 +208,6 @@ const ${importName} = {
|
|
|
208
208
|
};`;
|
|
209
209
|
return code.replace(configureImportRegex, inlinedDefaults);
|
|
210
210
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Determine if a file should have .tsx extension based on content
|
|
213
|
-
*/
|
|
214
|
-
export function shouldUseTsxExtension(content, originalPath) {
|
|
215
|
-
// If original file was .jsx, use .tsx
|
|
216
|
-
if (originalPath.endsWith('.jsx')) {
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
// If content contains JSX, use .tsx
|
|
220
|
-
if (containsJsx(content)) {
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
// Otherwise use .ts
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Convert CommonJS module.exports to ES module exports
|
|
228
|
-
*
|
|
229
|
-
* Handles patterns like:
|
|
230
|
-
* module.exports = { foo: ..., bar: ... }
|
|
231
|
-
*
|
|
232
|
-
* Converts to:
|
|
233
|
-
* export const foo = ...;
|
|
234
|
-
* export const bar = ...;
|
|
235
|
-
*/
|
|
236
|
-
export function convertModuleExportsToEsm(content) {
|
|
237
|
-
// Match: module.exports = { key: value, key2: value2, ... };
|
|
238
|
-
const moduleExportsPattern = /module\.exports\s*=\s*\{([\s\S]*?)\};?/;
|
|
239
|
-
const match = content.match(moduleExportsPattern);
|
|
240
|
-
if (!match) {
|
|
241
|
-
return content;
|
|
242
|
-
}
|
|
243
|
-
const [fullMatch, objectContent] = match;
|
|
244
|
-
// Parse the object content into key-value pairs
|
|
245
|
-
// Match patterns like: key: value, (with value possibly spanning multiple lines)
|
|
246
|
-
const exports = [];
|
|
247
|
-
const lines = objectContent.split('\n');
|
|
248
|
-
let currentKey = null;
|
|
249
|
-
let currentValue = [];
|
|
250
|
-
for (const line of lines) {
|
|
251
|
-
const trimmed = line.trim();
|
|
252
|
-
if (!trimmed || trimmed === '{' || trimmed === '}')
|
|
253
|
-
continue;
|
|
254
|
-
// Check if this line starts a new key
|
|
255
|
-
const keyMatch = trimmed.match(/^(\w+):\s*(.*)/);
|
|
256
|
-
if (keyMatch) {
|
|
257
|
-
// Save previous export if any
|
|
258
|
-
if (currentKey) {
|
|
259
|
-
const value = currentValue.join('\n').replace(/,\s*$/, ''); // Remove trailing comma
|
|
260
|
-
exports.push(`export const ${currentKey} =\n${value};`);
|
|
261
|
-
}
|
|
262
|
-
// Start new export
|
|
263
|
-
currentKey = keyMatch[1];
|
|
264
|
-
currentValue = [keyMatch[2]];
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
// Continuation of current value
|
|
268
|
-
currentValue.push(line);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
// Save last export
|
|
272
|
-
if (currentKey) {
|
|
273
|
-
const value = currentValue.join('\n').replace(/,\s*$/, '');
|
|
274
|
-
exports.push(`export const ${currentKey} =\n${value};`);
|
|
275
|
-
}
|
|
276
|
-
// Replace the module.exports block with ES module exports
|
|
277
|
-
const esmExports = exports.join('\n\n');
|
|
278
|
-
return content.replace(fullMatch, esmExports);
|
|
279
|
-
}
|
|
280
211
|
const VENDORED_LODASH_PACKAGE = '@pie-element/shared-lodash';
|
|
281
212
|
function lodashMemberFromPath(path) {
|
|
282
213
|
return path.replace(/\.js$/i, '').split('/').pop() ?? path;
|
|
@@ -412,7 +343,6 @@ function lodashExportSpecifierBinding(member, specifier) {
|
|
|
412
343
|
function formatLodashBinding(imported, local) {
|
|
413
344
|
return imported === local ? imported : `${imported} as ${local}`;
|
|
414
345
|
}
|
|
415
|
-
export const transformLodashToLodashEs = transformLodashToVendoredLodash;
|
|
416
346
|
/**
|
|
417
347
|
* Transform classnames imports to clsx.
|
|
418
348
|
*
|
|
@@ -422,6 +352,112 @@ export const transformLodashToLodashEs = transformLodashToVendoredLodash;
|
|
|
422
352
|
export function transformClassnamesToClsx(content) {
|
|
423
353
|
return rewriteModuleSpecifiers(content, (specifier) => specifier === 'classnames' ? 'clsx' : undefined);
|
|
424
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Rewrite js-combinatorics 0.5 `combination(seed, size)` calls to the 2.x `Combination` class.
|
|
357
|
+
*
|
|
358
|
+
* Upstream depends on 0.5, a UMD script with no ESM entrypoint; synced packages depend on 2.x,
|
|
359
|
+
* where `combination(n, k)` counts combinations as a BigInt and throws when given an array.
|
|
360
|
+
* `new Combination(seed, size)` enumerates the same pairs in the same order.
|
|
361
|
+
*/
|
|
362
|
+
export function transformJsCombinatoricsToV2(content) {
|
|
363
|
+
if (!content.includes('js-combinatorics')) {
|
|
364
|
+
return content;
|
|
365
|
+
}
|
|
366
|
+
const sourceFile = ts.createSourceFile('source.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
367
|
+
const edits = [];
|
|
368
|
+
const callees = new Map();
|
|
369
|
+
for (const statement of sourceFile.statements) {
|
|
370
|
+
if (!ts.isImportDeclaration(statement) ||
|
|
371
|
+
!ts.isStringLiteral(statement.moduleSpecifier) ||
|
|
372
|
+
statement.moduleSpecifier.text !== 'js-combinatorics') {
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
const bindings = statement.importClause?.namedBindings;
|
|
376
|
+
if (!bindings || !ts.isNamedImports(bindings)) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
for (const element of bindings.elements) {
|
|
380
|
+
if ((element.propertyName ?? element.name).text !== 'combination') {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
const local = element.name.text;
|
|
384
|
+
const aliased = local !== 'combination';
|
|
385
|
+
callees.set(local, aliased ? local : 'Combination');
|
|
386
|
+
edits.push({
|
|
387
|
+
start: element.getStart(sourceFile),
|
|
388
|
+
end: element.getEnd(),
|
|
389
|
+
text: aliased ? `Combination as ${local}` : 'Combination',
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (callees.size === 0) {
|
|
394
|
+
return content;
|
|
395
|
+
}
|
|
396
|
+
const visit = (node) => {
|
|
397
|
+
if (ts.isCallExpression(node) &&
|
|
398
|
+
ts.isIdentifier(node.expression) &&
|
|
399
|
+
callees.has(node.expression.text)) {
|
|
400
|
+
edits.push({
|
|
401
|
+
start: node.expression.getStart(sourceFile),
|
|
402
|
+
end: node.expression.getEnd(),
|
|
403
|
+
text: `new ${callees.get(node.expression.text)}`,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
ts.forEachChild(node, visit);
|
|
407
|
+
};
|
|
408
|
+
visit(sourceFile);
|
|
409
|
+
return applySourceEdits(content, edits);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* CommonJS packages whose exports Node's ESM loader cannot detect, mapped to the binding the
|
|
413
|
+
* rewrite imports them as. A named import from one of them fails to link when a host imports
|
|
414
|
+
* the built controller in Node; a default import is `module.exports` in Node and in bundlers.
|
|
415
|
+
*/
|
|
416
|
+
const COMMONJS_DEFAULT_IMPORTS = {
|
|
417
|
+
humps: 'humps',
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* Rewrite named imports from COMMONJS_DEFAULT_IMPORTS packages to a default import plus a
|
|
421
|
+
* destructure, so `import { camelizeKeys } from 'humps'` becomes
|
|
422
|
+
* `import humps from 'humps'; const { camelizeKeys } = humps;`.
|
|
423
|
+
*/
|
|
424
|
+
export function transformCommonJsNamedImports(content) {
|
|
425
|
+
if (!Object.keys(COMMONJS_DEFAULT_IMPORTS).some((name) => content.includes(name))) {
|
|
426
|
+
return content;
|
|
427
|
+
}
|
|
428
|
+
const sourceFile = ts.createSourceFile('source.tsx', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
429
|
+
const edits = [];
|
|
430
|
+
for (const statement of sourceFile.statements) {
|
|
431
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const specifier = statement.moduleSpecifier.text;
|
|
435
|
+
if (!Object.hasOwn(COMMONJS_DEFAULT_IMPORTS, specifier)) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
const clause = statement.importClause;
|
|
439
|
+
const bindings = clause?.namedBindings;
|
|
440
|
+
if (!clause ||
|
|
441
|
+
clause.isTypeOnly ||
|
|
442
|
+
!bindings ||
|
|
443
|
+
!ts.isNamedImports(bindings) ||
|
|
444
|
+
bindings.elements.length === 0 ||
|
|
445
|
+
bindings.elements.some((element) => element.isTypeOnly)) {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
const moduleBinding = clause.name?.text ?? COMMONJS_DEFAULT_IMPORTS[specifier];
|
|
449
|
+
const properties = bindings.elements.map((element) => element.propertyName
|
|
450
|
+
? `${element.propertyName.text}: ${element.name.text}`
|
|
451
|
+
: element.name.text);
|
|
452
|
+
const quoted = quoteLike(specifier, statement.moduleSpecifier.getText(sourceFile));
|
|
453
|
+
edits.push({
|
|
454
|
+
start: statement.getStart(sourceFile),
|
|
455
|
+
end: statement.getEnd(),
|
|
456
|
+
text: `import ${moduleBinding} from ${quoted};\nconst { ${properties.join(', ')} } = ${moduleBinding};`,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return applySourceEdits(content, edits);
|
|
460
|
+
}
|
|
425
461
|
/**
|
|
426
462
|
* Replace react-input-autosize with the local ESM autosize input component.
|
|
427
463
|
*
|
|
@@ -511,13 +547,6 @@ export function transformConfigUiMathjsToLocalFraction(content, sourcePath) {
|
|
|
511
547
|
}
|
|
512
548
|
return transformed;
|
|
513
549
|
}
|
|
514
|
-
/**
|
|
515
|
-
* Compatibility wrapper retained for older callers. Lodash imports now target
|
|
516
|
-
* the vendored shared package rather than lodash-es deep modules.
|
|
517
|
-
*/
|
|
518
|
-
export function transformLodashEsDeepImportsToFullySpecified(content) {
|
|
519
|
-
return transformLodashToVendoredLodash(content);
|
|
520
|
-
}
|
|
521
550
|
/**
|
|
522
551
|
* Ensure known strict-ESM deep imports include explicit file extensions.
|
|
523
552
|
*
|