@pie-element/cli 0.1.1 → 0.1.2-next.0

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.
Files changed (281) hide show
  1. package/README.md +48 -10
  2. package/dist/commands/dev/demo/index.d.ts +1 -1
  3. package/dist/commands/dev/demo/index.js +21 -0
  4. package/dist/commands/dev/demo/index.js.map +1 -1
  5. package/dist/commands/dev/test-bundler.d.ts +0 -1
  6. package/dist/commands/dev/test-bundler.js +2 -10
  7. package/dist/commands/dev/test-bundler.js.map +1 -1
  8. package/dist/commands/docs/generate.d.ts +16 -0
  9. package/dist/commands/docs/generate.js +150 -0
  10. package/dist/commands/docs/generate.js.map +1 -0
  11. package/dist/commands/docs/verify.d.ts +12 -0
  12. package/dist/commands/docs/verify.js +40 -0
  13. package/dist/commands/docs/verify.js.map +1 -0
  14. package/dist/commands/packages/create-controllers.d.ts +0 -1
  15. package/dist/commands/packages/create-controllers.js.map +1 -1
  16. package/dist/commands/packages/create-lib-react.d.ts +0 -1
  17. package/dist/commands/packages/create-lib-react.js +1 -3
  18. package/dist/commands/packages/create-lib-react.js.map +1 -1
  19. package/dist/commands/packages/create-react-elements.d.ts +0 -1
  20. package/dist/commands/packages/create-react-elements.js +2 -3
  21. package/dist/commands/packages/create-react-elements.js.map +1 -1
  22. package/dist/commands/packages/enable-publishing.d.ts +0 -1
  23. package/dist/commands/packages/enable-publishing.js +26 -23
  24. package/dist/commands/packages/enable-publishing.js.map +1 -1
  25. package/dist/commands/packages/init-synced-elements.d.ts +0 -1
  26. package/dist/commands/packages/init-synced-elements.js +1 -1
  27. package/dist/commands/packages/init-synced-elements.js.map +1 -1
  28. package/dist/commands/upstream/analyze-esm.d.ts +0 -1
  29. package/dist/commands/upstream/analyze-esm.js +5 -1
  30. package/dist/commands/upstream/analyze-esm.js.map +1 -1
  31. package/dist/commands/upstream/check.d.ts +0 -1
  32. package/dist/commands/upstream/check.js.map +1 -1
  33. package/dist/commands/upstream/deps.d.ts +0 -1
  34. package/dist/commands/upstream/deps.js.map +1 -1
  35. package/dist/commands/upstream/sync.d.ts +11 -2
  36. package/dist/commands/upstream/sync.js +364 -25
  37. package/dist/commands/upstream/sync.js.map +1 -1
  38. package/dist/commands/upstream/track.d.ts +0 -1
  39. package/dist/commands/upstream/track.js.map +1 -1
  40. package/dist/commands/upstream/update.d.ts +0 -1
  41. package/dist/commands/upstream/update.js +37 -7
  42. package/dist/commands/upstream/update.js.map +1 -1
  43. package/dist/commands/verify/controllers.d.ts +0 -1
  44. package/dist/commands/verify/controllers.js +213 -59
  45. package/dist/commands/verify/controllers.js.map +1 -1
  46. package/dist/commands/verify/dependency-integrity.d.ts +18 -0
  47. package/dist/commands/verify/dependency-integrity.js +147 -0
  48. package/dist/commands/verify/dependency-integrity.js.map +1 -0
  49. package/dist/commands/verify/react-build.d.ts +0 -1
  50. package/dist/commands/verify/react-build.js.map +1 -1
  51. package/dist/index.d.ts +0 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/lib/docs/contract-validator.d.ts +12 -0
  54. package/dist/lib/docs/contract-validator.js +38 -0
  55. package/dist/lib/docs/contract-validator.js.map +1 -0
  56. package/dist/lib/docs/contracts.d.ts +11 -0
  57. package/dist/lib/docs/contracts.js +241 -0
  58. package/dist/lib/docs/contracts.js.map +1 -0
  59. package/dist/lib/docs/discovery.d.ts +10 -0
  60. package/dist/lib/docs/discovery.js +91 -0
  61. package/dist/lib/docs/discovery.js.map +1 -0
  62. package/dist/lib/docs/generator.d.ts +14 -0
  63. package/dist/lib/docs/generator.js +450 -0
  64. package/dist/lib/docs/generator.js.map +1 -0
  65. package/dist/lib/docs/source-extractor.d.ts +2 -0
  66. package/dist/lib/docs/source-extractor.js +209 -0
  67. package/dist/lib/docs/source-extractor.js.map +1 -0
  68. package/dist/lib/docs/types.d.ts +77 -0
  69. package/dist/lib/docs/types.js +2 -0
  70. package/dist/lib/docs/types.js.map +1 -0
  71. package/dist/lib/upstream/repo-utils.d.ts +0 -1
  72. package/dist/lib/upstream/repo-utils.js.map +1 -1
  73. package/dist/lib/upstream/sync-compatibility.d.ts +0 -1
  74. package/dist/lib/upstream/sync-compatibility.js.map +1 -1
  75. package/dist/lib/upstream/sync-constants.d.ts +35 -7
  76. package/dist/lib/upstream/sync-constants.js +40 -11
  77. package/dist/lib/upstream/sync-constants.js.map +1 -1
  78. package/dist/lib/upstream/sync-controllers-strategy.d.ts +0 -1
  79. package/dist/lib/upstream/sync-controllers-strategy.js +14 -4
  80. package/dist/lib/upstream/sync-controllers-strategy.js.map +1 -1
  81. package/dist/lib/upstream/sync-demo-metadata.d.ts +0 -1
  82. package/dist/lib/upstream/sync-demo-metadata.js +1 -1
  83. package/dist/lib/upstream/sync-demo-metadata.js.map +1 -1
  84. package/dist/lib/upstream/sync-entry-discovery.d.ts +3 -0
  85. package/dist/lib/upstream/sync-entry-discovery.js +23 -0
  86. package/dist/lib/upstream/sync-entry-discovery.js.map +1 -0
  87. package/dist/lib/upstream/sync-externals.d.ts +7 -7
  88. package/dist/lib/upstream/sync-externals.js +51 -35
  89. package/dist/lib/upstream/sync-externals.js.map +1 -1
  90. package/dist/lib/upstream/sync-filesystem.d.ts +0 -1
  91. package/dist/lib/upstream/sync-filesystem.js.map +1 -1
  92. package/dist/lib/upstream/sync-imports.d.ts +82 -62
  93. package/dist/lib/upstream/sync-imports.js +658 -185
  94. package/dist/lib/upstream/sync-imports.js.map +1 -1
  95. package/dist/lib/upstream/sync-package-json.d.ts +0 -1
  96. package/dist/lib/upstream/sync-package-json.js +7 -0
  97. package/dist/lib/upstream/sync-package-json.js.map +1 -1
  98. package/dist/lib/upstream/sync-package-manager.d.ts +14 -4
  99. package/dist/lib/upstream/sync-package-manager.js +405 -72
  100. package/dist/lib/upstream/sync-package-manager.js.map +1 -1
  101. package/dist/lib/upstream/sync-pielib-strategy.d.ts +2 -1
  102. package/dist/lib/upstream/sync-pielib-strategy.js +228 -110
  103. package/dist/lib/upstream/sync-pielib-strategy.js.map +1 -1
  104. package/dist/lib/upstream/sync-presets.d.ts +52 -0
  105. package/dist/lib/upstream/sync-presets.js +175 -0
  106. package/dist/lib/upstream/sync-presets.js.map +1 -0
  107. package/dist/lib/upstream/sync-react-strategy.d.ts +6 -1
  108. package/dist/lib/upstream/sync-react-strategy.js +342 -134
  109. package/dist/lib/upstream/sync-react-strategy.js.map +1 -1
  110. package/dist/lib/upstream/sync-source-edit.d.ts +14 -0
  111. package/dist/lib/upstream/sync-source-edit.js +89 -0
  112. package/dist/lib/upstream/sync-source-edit.js.map +1 -0
  113. package/dist/lib/upstream/sync-source-tree.d.ts +22 -0
  114. package/dist/lib/upstream/sync-source-tree.js +99 -0
  115. package/dist/lib/upstream/sync-source-tree.js.map +1 -0
  116. package/dist/lib/upstream/sync-strategy.d.ts +1 -1
  117. package/dist/lib/upstream/sync-strategy.js.map +1 -1
  118. package/dist/lib/upstream/sync-summary.d.ts +0 -1
  119. package/dist/lib/upstream/sync-summary.js.map +1 -1
  120. package/dist/lib/upstream/sync-transforms.d.ts +13 -11
  121. package/dist/lib/upstream/sync-transforms.js +23 -17
  122. package/dist/lib/upstream/sync-transforms.js.map +1 -1
  123. package/dist/lib/upstream/sync-vite-config.d.ts +13 -1
  124. package/dist/lib/upstream/sync-vite-config.js +65 -46
  125. package/dist/lib/upstream/sync-vite-config.js.map +1 -1
  126. package/dist/utils/compatibility.d.ts +13 -1
  127. package/dist/utils/compatibility.js +143 -2
  128. package/dist/utils/compatibility.js.map +1 -1
  129. package/dist/utils/conversion.d.ts +0 -1
  130. package/dist/utils/conversion.js.map +1 -1
  131. package/dist/utils/dependency-integrity.d.ts +37 -0
  132. package/dist/utils/dependency-integrity.js +557 -0
  133. package/dist/utils/dependency-integrity.js.map +1 -0
  134. package/dist/utils/git.d.ts +0 -1
  135. package/dist/utils/git.js.map +1 -1
  136. package/dist/utils/logger.d.ts +0 -1
  137. package/dist/utils/logger.js.map +1 -1
  138. package/dist/utils/package-json.d.ts +0 -1
  139. package/dist/utils/package-json.js.map +1 -1
  140. package/package.json +25 -8
  141. package/.compatibility/report.json +0 -2491
  142. package/.turbo/turbo-build.log +0 -1
  143. package/CHANGELOG.md +0 -8
  144. package/REFACTORING.md +0 -131
  145. package/bin/dev.js +0 -5
  146. package/dist/commands/dev/demo/index.d.ts.map +0 -1
  147. package/dist/commands/dev/test-bundler.d.ts.map +0 -1
  148. package/dist/commands/mathquill/migrate.d.ts +0 -20
  149. package/dist/commands/mathquill/migrate.d.ts.map +0 -1
  150. package/dist/commands/mathquill/migrate.js +0 -240
  151. package/dist/commands/mathquill/migrate.js.map +0 -1
  152. package/dist/commands/mathquill/status.d.ts +0 -20
  153. package/dist/commands/mathquill/status.d.ts.map +0 -1
  154. package/dist/commands/mathquill/status.js +0 -231
  155. package/dist/commands/mathquill/status.js.map +0 -1
  156. package/dist/commands/packages/create-controllers.d.ts.map +0 -1
  157. package/dist/commands/packages/create-lib-react.d.ts.map +0 -1
  158. package/dist/commands/packages/create-react-elements.d.ts.map +0 -1
  159. package/dist/commands/packages/enable-publishing.d.ts.map +0 -1
  160. package/dist/commands/packages/init-synced-elements.d.ts.map +0 -1
  161. package/dist/commands/upstream/analyze-esm.d.ts.map +0 -1
  162. package/dist/commands/upstream/check.d.ts.map +0 -1
  163. package/dist/commands/upstream/deps.d.ts.map +0 -1
  164. package/dist/commands/upstream/sync-mathquill.d.ts +0 -12
  165. package/dist/commands/upstream/sync-mathquill.d.ts.map +0 -1
  166. package/dist/commands/upstream/sync-mathquill.js +0 -97
  167. package/dist/commands/upstream/sync-mathquill.js.map +0 -1
  168. package/dist/commands/upstream/sync.d.ts.map +0 -1
  169. package/dist/commands/upstream/track.d.ts.map +0 -1
  170. package/dist/commands/upstream/update.d.ts.map +0 -1
  171. package/dist/commands/verify/controllers.d.ts.map +0 -1
  172. package/dist/commands/verify/react-build.d.ts.map +0 -1
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/lib/mathquill/extension-generator.d.ts +0 -9
  175. package/dist/lib/mathquill/extension-generator.d.ts.map +0 -1
  176. package/dist/lib/mathquill/extension-generator.js +0 -107
  177. package/dist/lib/mathquill/extension-generator.js.map +0 -1
  178. package/dist/lib/mathquill/khan-extractor.d.ts +0 -16
  179. package/dist/lib/mathquill/khan-extractor.d.ts.map +0 -1
  180. package/dist/lib/mathquill/khan-extractor.js +0 -148
  181. package/dist/lib/mathquill/khan-extractor.js.map +0 -1
  182. package/dist/lib/mathquill/learnosity-extractor.d.ts +0 -15
  183. package/dist/lib/mathquill/learnosity-extractor.d.ts.map +0 -1
  184. package/dist/lib/mathquill/learnosity-extractor.js +0 -170
  185. package/dist/lib/mathquill/learnosity-extractor.js.map +0 -1
  186. package/dist/lib/mathquill/migration-orchestrator.d.ts +0 -77
  187. package/dist/lib/mathquill/migration-orchestrator.d.ts.map +0 -1
  188. package/dist/lib/mathquill/migration-orchestrator.js +0 -391
  189. package/dist/lib/mathquill/migration-orchestrator.js.map +0 -1
  190. package/dist/lib/mathquill/package-updater.d.ts +0 -9
  191. package/dist/lib/mathquill/package-updater.d.ts.map +0 -1
  192. package/dist/lib/mathquill/package-updater.js +0 -103
  193. package/dist/lib/mathquill/package-updater.js.map +0 -1
  194. package/dist/lib/mathquill/pie-extractor.d.ts +0 -14
  195. package/dist/lib/mathquill/pie-extractor.d.ts.map +0 -1
  196. package/dist/lib/mathquill/pie-extractor.js +0 -167
  197. package/dist/lib/mathquill/pie-extractor.js.map +0 -1
  198. package/dist/lib/upstream/repo-utils.d.ts.map +0 -1
  199. package/dist/lib/upstream/sync-compatibility.d.ts.map +0 -1
  200. package/dist/lib/upstream/sync-constants.d.ts.map +0 -1
  201. package/dist/lib/upstream/sync-controllers-strategy.d.ts.map +0 -1
  202. package/dist/lib/upstream/sync-demo-metadata.d.ts.map +0 -1
  203. package/dist/lib/upstream/sync-dev-exports.d.ts +0 -13
  204. package/dist/lib/upstream/sync-dev-exports.d.ts.map +0 -1
  205. package/dist/lib/upstream/sync-dev-exports.js +0 -115
  206. package/dist/lib/upstream/sync-dev-exports.js.map +0 -1
  207. package/dist/lib/upstream/sync-externals.d.ts.map +0 -1
  208. package/dist/lib/upstream/sync-filesystem.d.ts.map +0 -1
  209. package/dist/lib/upstream/sync-imports.d.ts.map +0 -1
  210. package/dist/lib/upstream/sync-mathquill.d.ts +0 -19
  211. package/dist/lib/upstream/sync-mathquill.d.ts.map +0 -1
  212. package/dist/lib/upstream/sync-mathquill.js +0 -160
  213. package/dist/lib/upstream/sync-mathquill.js.map +0 -1
  214. package/dist/lib/upstream/sync-package-json.d.ts.map +0 -1
  215. package/dist/lib/upstream/sync-package-manager.d.ts.map +0 -1
  216. package/dist/lib/upstream/sync-pielib-strategy.d.ts.map +0 -1
  217. package/dist/lib/upstream/sync-react-strategy.d.ts.map +0 -1
  218. package/dist/lib/upstream/sync-strategy.d.ts.map +0 -1
  219. package/dist/lib/upstream/sync-summary.d.ts.map +0 -1
  220. package/dist/lib/upstream/sync-transforms.d.ts.map +0 -1
  221. package/dist/lib/upstream/sync-vite-config.d.ts.map +0 -1
  222. package/dist/utils/compatibility.d.ts.map +0 -1
  223. package/dist/utils/conversion.d.ts.map +0 -1
  224. package/dist/utils/git.d.ts.map +0 -1
  225. package/dist/utils/logger.d.ts.map +0 -1
  226. package/dist/utils/package-json.d.ts.map +0 -1
  227. package/packages/cli/bin/dev.js +0 -5
  228. package/packages/cli/bin/run.js +0 -5
  229. package/src/commands/dev/demo/index.ts +0 -313
  230. package/src/commands/dev/test-bundler.ts +0 -345
  231. package/src/commands/mathquill/migrate.ts +0 -269
  232. package/src/commands/mathquill/status.ts +0 -267
  233. package/src/commands/packages/create-controllers.ts +0 -127
  234. package/src/commands/packages/create-lib-react.ts +0 -279
  235. package/src/commands/packages/create-react-elements.ts +0 -306
  236. package/src/commands/packages/enable-publishing.ts +0 -161
  237. package/src/commands/packages/init-synced-elements.ts +0 -259
  238. package/src/commands/upstream/README.md +0 -444
  239. package/src/commands/upstream/analyze-esm.ts +0 -1973
  240. package/src/commands/upstream/check.ts +0 -228
  241. package/src/commands/upstream/deps.ts +0 -222
  242. package/src/commands/upstream/sync-mathquill.ts +0 -108
  243. package/src/commands/upstream/sync.ts +0 -687
  244. package/src/commands/upstream/track.ts +0 -145
  245. package/src/commands/upstream/update.ts +0 -110
  246. package/src/commands/verify/controllers.ts +0 -166
  247. package/src/commands/verify/react-build.ts +0 -171
  248. package/src/index.ts +0 -1
  249. package/src/lib/mathquill/extension-generator.ts +0 -111
  250. package/src/lib/mathquill/khan-extractor.ts +0 -175
  251. package/src/lib/mathquill/learnosity-extractor.ts +0 -198
  252. package/src/lib/mathquill/migration-orchestrator.ts +0 -513
  253. package/src/lib/mathquill/package-updater.ts +0 -120
  254. package/src/lib/mathquill/pie-extractor.ts +0 -194
  255. package/src/lib/upstream/repo-utils.ts +0 -18
  256. package/src/lib/upstream/sync-compatibility.ts +0 -89
  257. package/src/lib/upstream/sync-constants.ts +0 -77
  258. package/src/lib/upstream/sync-controllers-strategy.ts +0 -291
  259. package/src/lib/upstream/sync-demo-metadata.ts +0 -199
  260. package/src/lib/upstream/sync-dev-exports.ts +0 -151
  261. package/src/lib/upstream/sync-externals.ts +0 -159
  262. package/src/lib/upstream/sync-filesystem.ts +0 -87
  263. package/src/lib/upstream/sync-imports.ts +0 -992
  264. package/src/lib/upstream/sync-mathquill.ts +0 -194
  265. package/src/lib/upstream/sync-package-json.ts +0 -86
  266. package/src/lib/upstream/sync-package-manager.ts +0 -694
  267. package/src/lib/upstream/sync-pielib-strategy.ts +0 -441
  268. package/src/lib/upstream/sync-react-strategy.ts +0 -945
  269. package/src/lib/upstream/sync-strategy.ts +0 -61
  270. package/src/lib/upstream/sync-summary.ts +0 -194
  271. package/src/lib/upstream/sync-transforms.ts +0 -154
  272. package/src/lib/upstream/sync-vite-config.ts +0 -243
  273. package/src/types/es-module-lexer.d.ts +0 -4
  274. package/src/utils/compatibility.ts +0 -182
  275. package/src/utils/conversion.ts +0 -153
  276. package/src/utils/git.ts +0 -63
  277. package/src/utils/logger.ts +0 -69
  278. package/src/utils/package-json.ts +0 -43
  279. package/tests/sync-package-manager.test.ts +0 -112
  280. package/tests/transform-assign-props.test.ts +0 -101
  281. package/tsconfig.json +0 -15
@@ -1,194 +0,0 @@
1
- import { writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import type { Logger } from '../../utils/logger.js';
4
-
5
- /**
6
- * PIE Feature Extractor
7
- *
8
- * Extracts PIE-specific customizations from the legacy bundle:
9
- * - Matrix commands (pmatrix, bmatrix, vmatrix)
10
- * - LRN exponent notation
11
- */
12
-
13
- export interface PIEExtractionResult {
14
- features: string[];
15
- files: string[];
16
- }
17
-
18
- export async function extractPIEFeatures(
19
- _mathquillPath: string,
20
- outputPath: string,
21
- logger: Logger
22
- ): Promise<PIEExtractionResult> {
23
- const features: string[] = [];
24
- const files: string[] = [];
25
-
26
- // Extract matrices
27
- logger.progress(' Extracting matrix commands...');
28
- const matricesFile = join(outputPath, 'matrices.ts');
29
- writeFileSync(matricesFile, generateMatricesCode());
30
- features.push('matrices');
31
- files.push(matricesFile);
32
-
33
- // Extract LRN exponent
34
- logger.progress(' Extracting LRN exponent...');
35
- const lrnExponentFile = join(outputPath, 'lrn-exponent.ts');
36
- writeFileSync(lrnExponentFile, generateLRNExponentCode());
37
- features.push('lrn-exponent');
38
- files.push(lrnExponentFile);
39
-
40
- // Copy matrix styles
41
- logger.progress(' Creating matrix styles...');
42
- const stylesFile = join(outputPath, 'styles.css');
43
- writeFileSync(stylesFile, generateMatrixStyles());
44
- files.push(stylesFile);
45
-
46
- // Create index file
47
- const indexFile = join(outputPath, 'index.ts');
48
- writeFileSync(indexFile, generatePIEIndexCode());
49
- files.push(indexFile);
50
-
51
- return { features, files };
52
- }
53
-
54
- function generateMatricesCode(): string {
55
- return `/**
56
- * Matrix Commands (PIE)
57
- *
58
- * Source: PIE fork (2019)
59
- * File: src/legacy/mathquill-bundle.js lines 6600-6980
60
- *
61
- * Adds support for LaTeX matrix commands:
62
- * - \\pmatrix: Matrix with parentheses ()
63
- * - \\bmatrix: Matrix with square brackets []
64
- * - \\vmatrix: Matrix with vertical bars ||
65
- *
66
- * These are standard LaTeX matrix types used in mathematics education.
67
- */
68
-
69
- import type { MathQuillInterface } from 'mathquill';
70
- import './styles.css';
71
-
72
- export function addMatrixCommands(MQ: MathQuillInterface): void {
73
- // Access MathQuill internals
74
- const mqInternal = MQ as any;
75
-
76
- if (!mqInternal.L?.LatexCmds) {
77
- console.warn('MathQuill internals not accessible for matrix commands');
78
- return;
79
- }
80
-
81
- // NOTE: This is a placeholder implementation
82
- // The full PIE matrix implementation from the legacy bundle is complex
83
- // and needs to be carefully ported to work with the Desmos fork.
84
- //
85
- // The legacy implementation (lines 6600-6980 in mathquill-bundle.js) includes:
86
- // - Matrix base class with row/column management
87
- // - Cell navigation and editing
88
- // - LaTeX parsing and generation
89
- // - HTML template generation
90
- // - Reflow and sizing logic
91
- //
92
- // For the initial migration, we document that this needs implementation.
93
- // The matrices from the legacy bundle should be extracted and adapted
94
- // to work with the modern TypeScript Desmos fork.
95
-
96
- // TODO: Extract and port full matrix implementation from legacy bundle
97
- // Lines 6600-6980 in packages/shared/mathquill/src/legacy/mathquill-bundle.js
98
-
99
- console.info('Matrix commands (pmatrix, bmatrix, vmatrix) need implementation');
100
- console.info('See: packages/shared/mathquill/src/legacy/mathquill-bundle.js lines 6600-6980');
101
- }
102
- `;
103
- }
104
-
105
- function generateLRNExponentCode(): string {
106
- return `/**
107
- * LRN Exponent Command (PIE)
108
- *
109
- * Source: PIE fork (2019)
110
- * File: src/legacy/mathquill-bundle.js
111
- *
112
- * Custom exponent notation for learning platforms.
113
- * Provides a specialized exponent input format.
114
- *
115
- * Usage: \\lrnexponent{base}{exponent}
116
- */
117
-
118
- import type { MathQuillInterface } from 'mathquill';
119
-
120
- export function addLRNExponent(MQ: MathQuillInterface): void {
121
- // Access MathQuill internals
122
- const mqInternal = MQ as any;
123
-
124
- if (!mqInternal.L?.LatexCmds) {
125
- console.warn('MathQuill internals not accessible for LRN exponent');
126
- return;
127
- }
128
-
129
- // NOTE: This is a placeholder implementation
130
- // The full PIE lrnexponent implementation needs to be extracted
131
- // from the legacy bundle and ported to TypeScript.
132
- //
133
- // The legacy implementation includes:
134
- // - Custom HTML template with specific styling
135
- // - Special handling for base and exponent parts
136
- // - Text template for plain text representation
137
- //
138
- // TODO: Extract and port lrnexponent implementation from legacy bundle
139
- // Search for 'lrnexponent' in packages/shared/mathquill/src/legacy/mathquill-bundle.js
140
-
141
- console.info('LRN exponent command needs implementation');
142
- console.info('See: packages/shared/mathquill/src/legacy/mathquill-bundle.js (search: lrnexponent)');
143
- }
144
- `;
145
- }
146
-
147
- function generateMatrixStyles(): string {
148
- return `/**
149
- * Matrix Styles (PIE)
150
- *
151
- * CSS styling for matrix rendering
152
- * Ported from packages/shared/mathquill/src/css/matrixed.less
153
- */
154
-
155
- .mq-math-mode .mq-matrix {
156
- display: inline-block;
157
- vertical-align: middle;
158
- }
159
-
160
- .mq-math-mode .mq-matrix table {
161
- border-collapse: collapse;
162
- border-spacing: 0;
163
- margin: 0.1em 0;
164
- }
165
-
166
- .mq-math-mode .mq-matrix td {
167
- padding: 0.2em 0.4em;
168
- text-align: center;
169
- vertical-align: middle;
170
- }
171
-
172
- .mq-math-mode .mq-matrix .mq-paren {
173
- font-size: 1.2em;
174
- vertical-align: middle;
175
- }
176
-
177
- .mq-math-mode .mq-matrix .mq-scaled {
178
- display: inline-block;
179
- transform-origin: center;
180
- }
181
- `;
182
- }
183
-
184
- function generatePIEIndexCode(): string {
185
- return `/**
186
- * PIE Extensions
187
- *
188
- * PIE-specific customizations for educational assessment
189
- */
190
-
191
- export { addMatrixCommands } from './matrices.js';
192
- export { addLRNExponent } from './lrn-exponent.js';
193
- `;
194
- }
@@ -1,18 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
-
3
- type RepoSpec = {
4
- label: string;
5
- path: string;
6
- extraMessage?: string;
7
- };
8
-
9
- export const formatRepoNotFound = (label: string, path: string, extraMessage?: string): string =>
10
- `${label} not found at ${path}${extraMessage ? `\n${extraMessage}` : ''}`;
11
-
12
- export const assertReposExist = (repos: RepoSpec[]): void => {
13
- for (const repo of repos) {
14
- if (!existsSync(repo.path)) {
15
- throw new Error(formatRepoNotFound(repo.label, repo.path, repo.extraMessage));
16
- }
17
- }
18
- };
@@ -1,89 +0,0 @@
1
- /**
2
- * Compatibility checking utilities for upstream sync operations
3
- *
4
- * Consolidates subdirectory-level ESM compatibility checks that were
5
- * duplicated across controllers-strategy and react-strategy.
6
- */
7
-
8
- import type { SyncContext } from './sync-strategy.js';
9
-
10
- export type SubdirectoryType = 'src' | 'configure' | 'controller';
11
-
12
- /**
13
- * Check if a subdirectory is ESM-compatible based on the compatibility report
14
- *
15
- * This function consolidates the duplicated compatibility checking logic from
16
- * ControllersStrategy and ReactComponentsStrategy.
17
- *
18
- * @param elementName - Name of the element (e.g., "multiple-choice")
19
- * @param subdir - Subdirectory to check ("src", "configure", or "controller")
20
- * @param context - Sync context containing the compatibility report
21
- * @returns true if compatible or no report available, false if incompatible
22
- */
23
- export function isSubdirectoryCompatible(
24
- elementName: string,
25
- subdir: SubdirectoryType,
26
- context: SyncContext
27
- ): boolean {
28
- // If no compatibility report, assume compatible (backward compatibility)
29
- if (!context.compatibilityReport) {
30
- return true;
31
- }
32
-
33
- const elementDetail = context.compatibilityReport.elementDetails[elementName];
34
- if (!elementDetail) {
35
- return true; // Element not in report, assume compatible
36
- }
37
-
38
- // Check subdirectory-specific compatibility
39
- switch (subdir) {
40
- case 'configure':
41
- return elementDetail.configure?.compatible ?? elementDetail.compatible;
42
- case 'controller':
43
- return elementDetail.controller?.compatible ?? elementDetail.compatible;
44
- case 'src':
45
- return elementDetail.studentUI?.compatible ?? elementDetail.compatible;
46
- default:
47
- return elementDetail.compatible;
48
- }
49
- }
50
-
51
- /**
52
- * Check if an element is ESM-compatible overall
53
- */
54
- export function isElementCompatible(elementName: string, context: SyncContext): boolean {
55
- if (!context.compatibilityReport) {
56
- return true;
57
- }
58
-
59
- return context.compatibilityReport.elements.includes(elementName);
60
- }
61
-
62
- /**
63
- * Get compatibility blockers for an element subdirectory
64
- */
65
- export function getCompatibilityBlockers(
66
- elementName: string,
67
- subdir: SubdirectoryType,
68
- context: SyncContext
69
- ): string[] {
70
- if (!context.compatibilityReport) {
71
- return [];
72
- }
73
-
74
- const elementDetail = context.compatibilityReport.elementDetails[elementName];
75
- if (!elementDetail) {
76
- return [];
77
- }
78
-
79
- switch (subdir) {
80
- case 'configure':
81
- return elementDetail.configure?.blockers ?? [];
82
- case 'controller':
83
- return elementDetail.controller?.blockers ?? [];
84
- case 'src':
85
- return elementDetail.studentUI?.blockers ?? [];
86
- default:
87
- return [];
88
- }
89
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * Shared constants for upstream sync operations
3
- */
4
-
5
- // Default repository paths
6
- export const DEFAULT_PATHS = {
7
- PIE_ELEMENTS: '../pie-elements',
8
- PIE_LIB: '../pie-lib',
9
- PIE_ELEMENTS_NG: '.',
10
- } as const;
11
-
12
- // Workspace dependency patterns
13
- export const WORKSPACE = {
14
- VERSION: 'workspace:*',
15
- PIE_LIB_PREFIX: '@pie-lib/',
16
- PIE_ELEMENT_PREFIX: '@pie-element/',
17
- PIE_FRAMEWORK_PREFIX: '@pie-framework/',
18
- } as const;
19
-
20
- // Upstream element packages intentionally excluded from sync.
21
- // These templates are not used in pie-elements-ng runtime or are temporarily disabled.
22
- export const EXCLUDED_UPSTREAM_ELEMENTS = [
23
- 'boilerplate-item-type',
24
- 'math-inline',
25
- 'math-templated',
26
- ] as const;
27
-
28
- // Build tool versions
29
- export const BUILD_TOOLS = {
30
- VITE: '^6.0.0',
31
- TYPESCRIPT: '^5.9.3',
32
- VITE_REACT_PLUGIN: '^4.2.0',
33
- LODASH_ES: '^4.17.22',
34
- } as const;
35
-
36
- // React versions
37
- export const REACT = {
38
- VERSION: '^18.0.0',
39
- TYPES_VERSION: '^18.2.0',
40
- } as const;
41
-
42
- // Directory patterns to skip
43
- export const SKIP_PATTERNS = {
44
- TEST_DIRS: ['__tests__', '__mocks__'],
45
- FILE_EXTENSIONS: ['.js', '.jsx', '.ts', '.tsx'],
46
- } as const;
47
-
48
- // File types
49
- export const FILE_TYPES = {
50
- JS: '.js',
51
- JSX: '.jsx',
52
- TS: '.ts',
53
- TSX: '.tsx',
54
- } as const;
55
-
56
- // Package.json defaults
57
- export const PACKAGE_DEFAULTS = {
58
- TYPE: 'module',
59
- SIDE_EFFECTS: false,
60
- FILES: ['dist', 'src'],
61
- } as const;
62
-
63
- // Build scripts
64
- export const SCRIPTS = {
65
- BUILD: 'bun x vite build && bun x tsc --emitDeclarationOnly',
66
- BUILD_WITH_IIFE:
67
- 'bun x vite build && bun x vite build --config vite.config.iife.ts && bun x tsc --emitDeclarationOnly',
68
- DEV: 'bun x vite',
69
- DEMO: 'bun x vite --mode demo',
70
- TEST: 'bun x vitest run',
71
- } as const;
72
-
73
- // Compatibility report file
74
- export const COMPATIBILITY_FILE = './.compatibility/report.json';
75
-
76
- // Upstream history file
77
- export const HISTORY_FILE = '.upstream-sync-history.json';
@@ -1,291 +0,0 @@
1
- /**
2
- * Controller sync strategy - syncs controller logic from upstream pie-elements
3
- *
4
- * Synced from: pie-elements/packages/{element}/controller/src/
5
- * Target: packages/elements-react/{element}/src/controller/
6
- */
7
-
8
- import { existsSync } from 'node:fs';
9
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
10
- import { dirname, join } from 'node:path';
11
- import { convertJsToTs } from '../../utils/conversion.js';
12
- import { getCurrentCommit } from '../../utils/git.js';
13
- import type { SyncStrategy, SyncContext, SyncConfig, SyncResult } from './sync-strategy.js';
14
- import { cleanDirectory, existsAny, readdir } from './sync-filesystem.js';
15
- import { createExternalFunction } from './sync-externals.js';
16
- import { createControllerTransformPipeline } from './sync-transforms.js';
17
- import { ensureElementPackageJson } from './sync-package-manager.js';
18
- import { isSubdirectoryCompatible } from './sync-compatibility.js';
19
- import { EXCLUDED_UPSTREAM_ELEMENTS } from './sync-constants.js';
20
-
21
- interface InternalSyncResult {
22
- filesChecked: number;
23
- filesCopied: number;
24
- filesSkipped: number;
25
- filesUpdated: number;
26
- }
27
-
28
- export class ControllersStrategy implements SyncStrategy {
29
- private touchedElementPackages = new Set<string>();
30
- private result: InternalSyncResult = {
31
- filesChecked: 0,
32
- filesCopied: 0,
33
- filesSkipped: 0,
34
- filesUpdated: 0,
35
- };
36
-
37
- getName(): string {
38
- return 'controllers';
39
- }
40
-
41
- getDescription(): string {
42
- return 'controllers';
43
- }
44
-
45
- shouldRun(config: SyncConfig): boolean {
46
- return config.syncControllers;
47
- }
48
-
49
- async execute(context: SyncContext): Promise<SyncResult> {
50
- const { config, logger } = context;
51
- this.touchedElementPackages.clear();
52
- this.result = {
53
- filesChecked: 0,
54
- filesCopied: 0,
55
- filesSkipped: 0,
56
- filesUpdated: 0,
57
- };
58
-
59
- if (!logger.isVerbose()) {
60
- logger.progressStart('Syncing controllers...');
61
- } else {
62
- logger.section('📦 Syncing controllers');
63
- }
64
-
65
- const upstreamElementsDir = join(config.pieElements, 'packages');
66
- const targetBaseDir = join(config.pieElementsNg, 'packages/elements-react');
67
-
68
- const upstreamCommit = getCurrentCommit(config.pieElements);
69
-
70
- const packages = await readdir(upstreamElementsDir);
71
-
72
- for (const pkg of packages) {
73
- if (EXCLUDED_UPSTREAM_ELEMENTS.includes(pkg as (typeof EXCLUDED_UPSTREAM_ELEMENTS)[number])) {
74
- continue;
75
- }
76
-
77
- if (context.packageFilter && pkg !== context.packageFilter) {
78
- continue;
79
- }
80
-
81
- // Check if controller exists upstream
82
- const controllerPath = join(upstreamElementsDir, pkg, 'controller/src/index.js');
83
- if (!existsSync(controllerPath)) {
84
- continue;
85
- }
86
-
87
- // Check if controller subdirectory is ESM-compatible
88
- const controllerCompatible = isSubdirectoryCompatible(pkg, 'controller', context);
89
- if (!controllerCompatible) {
90
- if (logger.isVerbose()) {
91
- logger.info(` ⏭️ ${pkg}: skipping controller/ (not ESM-compatible)`);
92
- }
93
- continue;
94
- }
95
-
96
- this.result.filesChecked++;
97
-
98
- // Target: packages/elements-react/{element}/src/controller/index.ts
99
- const targetDir = join(targetBaseDir, pkg, 'src/controller');
100
- const targetPath = join(targetDir, 'index.ts');
101
-
102
- // Clean target controller subtree first so removed upstream files don't linger
103
- await this.cleanTargetDir(targetDir, `elements-react/${pkg}/src/controller`, logger);
104
-
105
- // Read source
106
- let sourceContent = await readFile(controllerPath, 'utf-8');
107
-
108
- // Apply all standard transformations
109
- const transformPipeline = createControllerTransformPipeline();
110
- sourceContent = transformPipeline(sourceContent);
111
-
112
- // Convert JS to TS
113
- const { code: converted } = convertJsToTs(sourceContent, {
114
- sourcePath: `pie-elements/packages/${pkg}/controller/src/index.js`,
115
- commit: upstreamCommit,
116
- });
117
-
118
- let elementChanged = false;
119
-
120
- // Sync index.ts
121
- // NOTE: This comparison is exact (===) to ensure any changes in:
122
- // - Upstream source code
123
- // - Transformation logic (lodash-es, event packages, etc.)
124
- // - Sync version (tracked in @sync-version header)
125
- // will trigger a file update. This prioritizes correctness over speed.
126
- const isNew = !existsSync(targetPath);
127
- if (!isNew) {
128
- const currentContent = await readFile(targetPath, 'utf-8');
129
- if (currentContent === converted) {
130
- this.result.filesSkipped++;
131
- } else {
132
- this.result.filesUpdated++;
133
- elementChanged = true;
134
- await mkdir(dirname(targetPath), { recursive: true });
135
- await writeFile(targetPath, converted, 'utf-8');
136
- }
137
- } else {
138
- this.result.filesCopied++;
139
- elementChanged = true;
140
- await mkdir(dirname(targetPath), { recursive: true });
141
- await writeFile(targetPath, converted, 'utf-8');
142
- }
143
-
144
- // Also sync related files (defaults.js, utils.js, scoring.js, tickUtils.js)
145
- const relatedFiles = ['defaults.js', 'utils.js', 'scoring.js', 'tickUtils.js'];
146
- for (const file of relatedFiles) {
147
- const relatedPath = join(upstreamElementsDir, pkg, 'controller/src', file);
148
- if (existsSync(relatedPath)) {
149
- const relatedTarget = join(targetDir, file.replace('.js', '.ts'));
150
- let relatedContent = await readFile(relatedPath, 'utf-8');
151
-
152
- // Apply all standard transformations
153
- relatedContent = transformPipeline(relatedContent);
154
-
155
- const { code: relatedConverted } = convertJsToTs(relatedContent, {
156
- sourcePath: `pie-elements/packages/${pkg}/controller/src/${file}`,
157
- commit: upstreamCommit,
158
- });
159
-
160
- const relatedIsNew = !existsSync(relatedTarget);
161
- if (!relatedIsNew) {
162
- const currentRelated = await readFile(relatedTarget, 'utf-8');
163
- if (currentRelated === relatedConverted) {
164
- this.result.filesSkipped++;
165
- continue;
166
- }
167
- this.result.filesUpdated++;
168
- elementChanged = true;
169
- } else {
170
- this.result.filesCopied++;
171
- elementChanged = true;
172
- }
173
-
174
- await mkdir(dirname(relatedTarget), { recursive: true });
175
- await writeFile(relatedTarget, relatedConverted, 'utf-8');
176
- }
177
- }
178
-
179
- // Ensure package.json has ESM module support (even in controller-only sync)
180
- let wrotePkgJson = false;
181
- const elementDir = join(targetBaseDir, pkg);
182
- wrotePkgJson = await ensureElementPackageJson(pkg, elementDir, config);
183
- await this.ensureElementViteConfig(pkg, elementDir, logger);
184
-
185
- if (elementChanged || wrotePkgJson) {
186
- if (logger.isVerbose()) {
187
- logger.success(` 🔄 ${pkg}: controller package updated`);
188
- }
189
- this.touchedElementPackages.add(pkg);
190
- }
191
- }
192
-
193
- if (!logger.isVerbose()) {
194
- logger.progressCompleteWithCount(this.touchedElementPackages.size, 'packages');
195
- } else {
196
- logger.info(`\nSynced ${this.touchedElementPackages.size} controller package(s)`);
197
- }
198
- return {
199
- count: this.touchedElementPackages.size,
200
- packageNames: Array.from(this.touchedElementPackages).sort(),
201
- };
202
- }
203
-
204
- private async cleanTargetDir(targetDir: string, label: string, logger: any): Promise<void> {
205
- await cleanDirectory(targetDir, label, { dryRun: false, verbose: false }, logger);
206
- }
207
-
208
- private async ensureElementViteConfig(
209
- _elementName: string,
210
- elementDir: string,
211
- _logger: any
212
- ): Promise<void> {
213
- if (!existsSync(elementDir)) {
214
- return;
215
- }
216
-
217
- const viteConfigPath = join(elementDir, 'vite.config.ts');
218
-
219
- // Always regenerate to reflect current directory structure
220
- // (e.g., if configure/ was skipped due to ESM incompatibility)
221
-
222
- // Detect entry points
223
- const entryPoints: Record<string, string> = {};
224
- const indexEntry = existsAny([
225
- join(elementDir, 'src/index.ts'),
226
- join(elementDir, 'src/index.tsx'),
227
- ]);
228
- if (indexEntry) {
229
- entryPoints.index = 'src/index.ts';
230
- }
231
-
232
- const hasController = existsAny([
233
- join(elementDir, 'src/controller/index.ts'),
234
- join(elementDir, 'src/controller/index.tsx'),
235
- ]);
236
- if (hasController) {
237
- entryPoints['controller/index'] = 'src/controller/index.ts';
238
- }
239
-
240
- const hasConfigure = existsAny([
241
- join(elementDir, 'src/configure/index.ts'),
242
- join(elementDir, 'src/configure/index.tsx'),
243
- ]);
244
- if (hasConfigure) {
245
- entryPoints['configure/index'] = 'src/configure/index.ts';
246
- }
247
-
248
- const hasDelivery = existsAny([
249
- join(elementDir, 'src/delivery/index.ts'),
250
- join(elementDir, 'src/delivery/index.tsx'),
251
- ]);
252
- if (hasDelivery) {
253
- entryPoints['delivery/index'] = 'src/delivery/index.ts';
254
- }
255
-
256
- if (Object.keys(entryPoints).length === 0) {
257
- return; // No entry points, skip vite config
258
- }
259
-
260
- // Format entry points for vite config
261
- const entryLines = Object.entries(entryPoints)
262
- .map(([key, value]) => ` '${key}': resolve(__dirname, '${value}'),`)
263
- .join('\n');
264
-
265
- const viteConfig = `import { resolve } from 'node:path';
266
- import react from '@vitejs/plugin-react';
267
- import { defineConfig } from 'vite';
268
-
269
- export default defineConfig({
270
- plugins: [react()],
271
- build: {
272
- lib: {
273
- entry: {
274
- ${entryLines}
275
- },
276
- formats: ['es'],
277
- },
278
- rollupOptions: {
279
- external: ${createExternalFunction('pielib')},
280
- output: {
281
- preserveModules: true,
282
- preserveModulesRoot: 'src',
283
- },
284
- },
285
- },
286
- });
287
- `;
288
-
289
- await writeFile(viteConfigPath, viteConfig, 'utf-8');
290
- }
291
- }