@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
@@ -11,11 +11,38 @@ import { convertJsToTs, convertJsxToTsx } from '../../utils/conversion.js';
11
11
  import { getCurrentCommit } from '../../utils/git.js';
12
12
  import { cleanDirectory, existsAny, readdir } from './sync-filesystem.js';
13
13
  import { createExternalFunction, createKonvaExternalFunction } from './sync-externals.js';
14
- import { fixImportsInFile, containsJsx } from './sync-imports.js';
14
+ import { containsJsx } from './sync-imports.js';
15
15
  import { createReactComponentTransformPipeline } from './sync-transforms.js';
16
16
  import { ensureElementPackageJson } from './sync-package-manager.js';
17
17
  import { isSubdirectoryCompatible } from './sync-compatibility.js';
18
18
  import { EXCLUDED_UPSTREAM_ELEMENTS } from './sync-constants.js';
19
+ import { collectEntryPoints } from './sync-entry-discovery.js';
20
+ import { syncSourceTree } from './sync-source-tree.js';
21
+ import { seedContractForElement } from '../docs/contracts.js';
22
+ const PRIVATE_CHILD_TAGS = {
23
+ ebsr: [
24
+ { name: 'EBSR_MULTIPLE_CHOICE_TAG', tag: 'ebsr-multiple-choice' },
25
+ { name: 'EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG', tag: 'ebsr-multiple-choice-configure' },
26
+ ],
27
+ 'complex-rubric': [
28
+ { name: 'COMPLEX_RUBRIC_SIMPLE_TAG', tag: 'complex-rubric-simple' },
29
+ { name: 'COMPLEX_RUBRIC_MULTI_TRAIT_TAG', tag: 'complex-rubric-multi-trait' },
30
+ { name: 'COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG', tag: 'rubric-configure' },
31
+ { name: 'COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG', tag: 'multi-trait-rubric-configure' },
32
+ ],
33
+ };
34
+ export function collectElementViteEntryPoints(elementDir) {
35
+ return collectEntryPoints(elementDir, [
36
+ ['index', 'src/index'],
37
+ ['controller/index', 'src/controller/index'],
38
+ ['configure/index', 'src/configure/index'],
39
+ ['delivery/index', 'src/delivery/index'],
40
+ ['author/index', 'src/author/index'],
41
+ ['print/index', 'src/print/index'],
42
+ ['types/index', 'src/types/index'],
43
+ ['runtime-support', 'src/runtime-support'],
44
+ ]);
45
+ }
19
46
  export class ReactComponentsStrategy {
20
47
  touchedElementPackages = new Set();
21
48
  result = {
@@ -54,6 +81,19 @@ export class ReactComponentsStrategy {
54
81
  const packages = await readdir(upstreamElementsDir);
55
82
  for (const pkg of packages) {
56
83
  if (EXCLUDED_UPSTREAM_ELEMENTS.includes(pkg)) {
84
+ if (context.packageFilter && pkg !== context.packageFilter) {
85
+ continue;
86
+ }
87
+ const targetDir = join(targetBaseDir, pkg);
88
+ const hasControllerSource = existsAny([
89
+ join(targetDir, 'src/controller/index.ts'),
90
+ join(targetDir, 'src/controller/index.tsx'),
91
+ join(targetDir, 'src/controller/index.js'),
92
+ join(targetDir, 'src/controller/index.jsx'),
93
+ ]);
94
+ if (!config.dryRun && existsSync(targetDir) && hasControllerSource) {
95
+ await ensureElementPackageJson(pkg, targetDir, config);
96
+ }
57
97
  continue;
58
98
  }
59
99
  if (context.packageFilter && pkg !== context.packageFilter) {
@@ -82,7 +122,7 @@ export class ReactComponentsStrategy {
82
122
  const targetSrcDir = join(targetDir, 'src');
83
123
  // Clean target src subtree first so removed upstream files don't linger
84
124
  // BUT: preserve controller/ subdirectory if it exists (synced separately)
85
- await this.cleanTargetDirExcept(targetSrcDir, ['controller'], `elements-react/${pkg}/src`, logger);
125
+ await this.cleanTargetDirExcept(targetSrcDir, ['controller'], `elements-react/${pkg}/src`, logger, config.dryRun);
86
126
  // Recursively sync all files from src/ directory to delivery/ subdirectory
87
127
  const beforeChanges = this.result.filesCopied + this.result.filesUpdated;
88
128
  const targetDeliveryDir = join(targetDir, 'src/delivery');
@@ -118,6 +158,7 @@ export class ReactComponentsStrategy {
118
158
  const printFilesProcessed = await this.syncPrintFile(upstreamPrintFile, targetPrintDir, pkg, upstreamCommit);
119
159
  elementFilesProcessed += printFilesProcessed;
120
160
  }
161
+ const wrotePrivateChildSupport = await this.ensurePrivateChildElementSupport(pkg, targetDir);
121
162
  // Generate src/index.ts that re-exports from delivery/
122
163
  const mainIndexPath = join(targetDir, 'src/index.ts');
123
164
  const mainIndexContent = `export { default } from './delivery/index.js';\n`;
@@ -134,13 +175,32 @@ export class ReactComponentsStrategy {
134
175
  await this.ensureIifeViteConfig(pkg, elementDir, config, logger);
135
176
  // Ensure package.json has ESM module support and expected exports.
136
177
  let wrotePkgJson = false;
137
- wrotePkgJson = await ensureElementPackageJson(pkg, elementDir, config);
178
+ wrotePkgJson = await ensureElementPackageJson(pkg, elementDir, config, {
179
+ includeBrowserExports: true,
180
+ });
138
181
  await this.ensureElementViteConfig(pkg, elementDir, logger);
139
182
  const wroteTsConfig = await this.ensureTsConfig(pkg, elementDir, logger);
140
183
  // Ensure demo structure
141
184
  await this.ensureElementDemoStructure(pkg, elementDir, config, logger);
142
185
  // Demo configs are maintained locally - we do NOT apply overrides from upstream
143
- if (elementChanged || wrotePkgJson || wroteTsConfig) {
186
+ if (!config.dryRun) {
187
+ const packageJsonPath = join(elementDir, 'package.json');
188
+ const packageJsonRaw = existsSync(packageJsonPath)
189
+ ? JSON.parse(await readFile(packageJsonPath, 'utf-8'))
190
+ : {};
191
+ const packageInfo = {
192
+ elementName: pkg,
193
+ packageName: typeof packageJsonRaw.name === 'string' ? packageJsonRaw.name : `@pie-element/${pkg}`,
194
+ framework: 'react',
195
+ packageDir: elementDir,
196
+ packageDescription: typeof packageJsonRaw.description === 'string' ? packageJsonRaw.description : undefined,
197
+ exportsMap: packageJsonRaw.exports && typeof packageJsonRaw.exports === 'object'
198
+ ? packageJsonRaw.exports
199
+ : undefined,
200
+ };
201
+ await seedContractForElement(packageInfo, config.pieElementsNg, { refresh: true });
202
+ }
203
+ if (elementChanged || wrotePrivateChildSupport || wrotePkgJson || wroteTsConfig) {
144
204
  this.touchedElementPackages.add(pkg);
145
205
  }
146
206
  }
@@ -156,97 +216,26 @@ export class ReactComponentsStrategy {
156
216
  packageNames: Array.from(this.touchedElementPackages).sort(),
157
217
  };
158
218
  }
159
- async cleanTargetDirExcept(targetDir, preserveDirs, label, logger) {
160
- await cleanDirectory(targetDir, label, { dryRun: false, verbose: false, preserve: preserveDirs }, logger);
219
+ async cleanTargetDirExcept(targetDir, preserveDirs, label, logger, dryRun) {
220
+ await cleanDirectory(targetDir, label, { dryRun, verbose: false, preserve: preserveDirs }, logger);
161
221
  }
162
222
  async syncDirectory(sourceDir, targetDir, relativePath, pkg, upstreamCommit) {
163
- let filesProcessed = 0;
164
- const defaultExportFiles = new Set(); // Track files with default exports
165
- const items = await readdir(sourceDir);
166
- for (const item of items) {
167
- const srcPath = join(sourceDir, item);
168
- const stat = await fsStat(srcPath);
169
- if (stat.isDirectory()) {
170
- // Skip __tests__, __mocks__, etc.
171
- if (item.startsWith('__')) {
172
- continue;
173
- }
174
- // Recursively sync subdirectories
175
- const subFilesProcessed = await this.syncDirectory(srcPath, join(targetDir, item), join(relativePath, item), pkg, upstreamCommit);
176
- filesProcessed += subFilesProcessed;
177
- continue;
178
- }
179
- // Only process .js and .jsx files
180
- if (!item.endsWith('.js') && !item.endsWith('.jsx')) {
181
- continue;
182
- }
183
- // Skip print.js/print.jsx files - they're synced to src/print/ separately
184
- if (item === 'print.js' || item === 'print.jsx') {
185
- continue;
186
- }
187
- this.result.filesChecked++;
188
- filesProcessed++;
189
- // Read source
190
- let sourceContent = await readFile(srcPath, 'utf-8');
191
- // Apply all standard transformations
192
- const packageName = `@pie-element/${pkg}`;
193
- const transformPipeline = createReactComponentTransformPipeline(packageName);
194
- sourceContent = transformPipeline(sourceContent, join(relativePath, item));
195
- const hasJsx = item.endsWith('.jsx') || (item.endsWith('.js') && containsJsx(sourceContent));
196
- // Convert .js → .ts/.tsx and .jsx → .tsx
197
- const targetFile = item.replace(/\.jsx?$/, hasJsx ? '.tsx' : '.ts');
198
- const targetPath = join(targetDir, targetFile);
199
- // Convert based on file extension
200
- const conversionResult = hasJsx
201
- ? convertJsxToTsx(sourceContent, {
202
- sourcePath: `pie-elements/packages/${pkg}/${relativePath}/${item}`,
203
- commit: upstreamCommit,
204
- })
205
- : convertJsToTs(sourceContent, {
206
- sourcePath: `pie-elements/packages/${pkg}/${relativePath}/${item}`,
207
- commit: upstreamCommit,
208
- });
209
- const converted = conversionResult.code;
210
- // Track files that export default objects (for import fixing later)
211
- if (conversionResult.hasDefaultObjectExport) {
212
- // Store the file name without extension for import matching
213
- const fileNameWithoutExt = targetFile.replace(/\.(ts|tsx)$/, '');
214
- defaultExportFiles.add(fileNameWithoutExt);
215
- }
216
- // Check if different
217
- // NOTE: This comparison is exact (===) to ensure any changes in:
218
- // - Upstream source code
219
- // - Transformation logic (lodash-es, event packages, etc.)
220
- // - Sync version (tracked in @sync-version header)
221
- // will trigger a file update. This prioritizes correctness over speed.
222
- const isNew = !existsSync(targetPath);
223
- if (!isNew) {
224
- const currentContent = await readFile(targetPath, 'utf-8');
225
- if (currentContent === converted) {
226
- this.result.filesSkipped++;
227
- continue;
228
- }
229
- this.result.filesUpdated++;
230
- }
231
- else {
232
- this.result.filesCopied++;
233
- }
234
- // Write
235
- await mkdir(dirname(targetPath), { recursive: true });
236
- await writeFile(targetPath, converted, 'utf-8');
237
- }
238
- // After all files are synced, fix import statements in consuming files
239
- if (defaultExportFiles.size > 0) {
240
- const targetDirItems = await readdir(targetDir);
241
- for (const item of targetDirItems) {
242
- const itemPath = join(targetDir, item);
243
- const stat = await fsStat(itemPath);
244
- if (stat.isFile() && (item.endsWith('.tsx') || item.endsWith('.ts'))) {
245
- await fixImportsInFile(itemPath, defaultExportFiles);
246
- }
247
- }
248
- }
249
- return filesProcessed;
223
+ const packageName = `@pie-element/${pkg}`;
224
+ const transformPipeline = createReactComponentTransformPipeline(packageName);
225
+ const stats = await syncSourceTree({
226
+ sourceDir,
227
+ targetDir,
228
+ relativePath,
229
+ sourcePathPrefix: `pie-elements/packages/${pkg}`,
230
+ upstreamCommit,
231
+ transform: (content, context) => transformPipeline(content, context.relativeFilePath),
232
+ skipFile: (fileName) => fileName === 'print.js' || fileName === 'print.jsx',
233
+ });
234
+ this.result.filesChecked += stats.filesChecked;
235
+ this.result.filesCopied += stats.filesCopied;
236
+ this.result.filesSkipped += stats.filesSkipped;
237
+ this.result.filesUpdated += stats.filesUpdated;
238
+ return stats.filesProcessed;
250
239
  }
251
240
  /**
252
241
  * Sync root-level .js files from configure/ directory (not including subdirectories)
@@ -313,6 +302,245 @@ export class ReactComponentsStrategy {
313
302
  }
314
303
  return filesProcessed;
315
304
  }
305
+ async ensurePrivateChildElementSupport(pkg, elementDir) {
306
+ const tags = PRIVATE_CHILD_TAGS[pkg];
307
+ if (!tags) {
308
+ return false;
309
+ }
310
+ let changed = await this.ensurePrivateTagsFile(elementDir, tags);
311
+ if (pkg === 'ebsr') {
312
+ changed = (await this.ensureEbsrPrivateChildReferences(elementDir)) || changed;
313
+ }
314
+ if (pkg === 'complex-rubric') {
315
+ changed = (await this.ensureComplexRubricPrivateChildReferences(elementDir)) || changed;
316
+ }
317
+ return changed;
318
+ }
319
+ async ensurePrivateTagsFile(elementDir, tags) {
320
+ const privateTagsPath = join(elementDir, 'src/private-tags.ts');
321
+ const exports = tags.map(({ name, tag }) => `export const ${name} = \`${tag}\${ownerVersionSuffix}\`;`);
322
+ const content = `declare const __PIE_PACKAGE_VERSION__: string | undefined;
323
+
324
+ const encodeVersionForTag = (version: string): string =>
325
+ version
326
+ .trim()
327
+ .toLowerCase()
328
+ .replace(/[.+]/g, '-')
329
+ .replace(/[^0-9A-Za-z-]/g, '-')
330
+ .replace(/-{2,}/g, '-');
331
+
332
+ const ownerVersion =
333
+ typeof __PIE_PACKAGE_VERSION__ === 'string' && __PIE_PACKAGE_VERSION__.trim()
334
+ ? __PIE_PACKAGE_VERSION__
335
+ : 'local';
336
+ const ownerVersionSuffix = \`--version-\${encodeVersionForTag(ownerVersion)}\`;
337
+
338
+ ${exports.join('\n')}
339
+ `;
340
+ const current = existsSync(privateTagsPath)
341
+ ? await readFile(privateTagsPath, 'utf-8').catch(() => null)
342
+ : null;
343
+ if (current === content) {
344
+ return false;
345
+ }
346
+ await mkdir(dirname(privateTagsPath), { recursive: true });
347
+ await writeFile(privateTagsPath, content, 'utf-8');
348
+ return true;
349
+ }
350
+ async ensureEbsrPrivateChildReferences(elementDir) {
351
+ let changed = false;
352
+ changed =
353
+ (await this.replaceInSyncedFile(join(elementDir, 'src/delivery/index.tsx'), [
354
+ {
355
+ from: "import debug from 'debug';\n",
356
+ to: "import debug from 'debug';\nimport { EBSR_MULTIPLE_CHOICE_TAG } from '../private-tags.js';\n",
357
+ },
358
+ {
359
+ from: "const MC_TAG_NAME = 'ebsr-multiple-choice';",
360
+ to: 'const MC_TAG_NAME = EBSR_MULTIPLE_CHOICE_TAG;',
361
+ },
362
+ ])) || changed;
363
+ changed =
364
+ (await this.replaceInSyncedFile(join(elementDir, 'src/print/index.tsx'), [
365
+ {
366
+ from: "import { SessionChangedEvent } from '@pie-element/shared-player-events';\n",
367
+ to: "import { SessionChangedEvent } from '@pie-element/shared-player-events';\nimport { EBSR_MULTIPLE_CHOICE_TAG } from '../private-tags.js';\n",
368
+ },
369
+ {
370
+ from: "const MC_TAG_NAME = 'ebsr-multiple-choice';",
371
+ to: 'const MC_TAG_NAME = EBSR_MULTIPLE_CHOICE_TAG;',
372
+ },
373
+ ])) || changed;
374
+ changed =
375
+ (await this.replaceInSyncedFile(join(elementDir, 'src/author/index.ts'), [
376
+ {
377
+ from: "import Main from './main';\n",
378
+ to: "import Main from './main';\nimport { EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG } from '../private-tags.js';\n",
379
+ },
380
+ {
381
+ from: "const MC_TAG_NAME = 'ebsr-multiple-choice-configure';",
382
+ to: 'const MC_TAG_NAME = EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG;',
383
+ },
384
+ {
385
+ from: ' configuration: this._configuration,\n',
386
+ to: ' configuration: this._configuration,\n multipleChoiceTagName: MC_TAG_NAME,\n',
387
+ },
388
+ ])) || changed;
389
+ changed =
390
+ (await this.replaceInSyncedFile(join(elementDir, 'src/author/main.tsx'), [
391
+ {
392
+ from: "import { styled } from '@mui/material/styles';\n",
393
+ to: "import { styled } from '@mui/material/styles';\nimport { EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG } from '../private-tags.js';\n",
394
+ },
395
+ {
396
+ from: ` configuration: PropTypes.object,
397
+ model: PropTypes.object,
398
+ onModelChanged: PropTypes.func,
399
+ onConfigurationChanged: PropTypes.func,`,
400
+ to: ` configuration: PropTypes.object,
401
+ model: PropTypes.object,
402
+ multipleChoiceTagName: PropTypes.string,
403
+ onModelChanged: PropTypes.func,
404
+ onConfigurationChanged: PropTypes.func,`,
405
+ },
406
+ {
407
+ from: ' const { model, configuration, onConfigurationChanged } = this.props;\n',
408
+ to: ` const {
409
+ model,
410
+ configuration,
411
+ multipleChoiceTagName = EBSR_MULTIPLE_CHOICE_CONFIGURE_TAG,
412
+ onConfigurationChanged,
413
+ } = this.props;
414
+ const MultipleChoiceConfigureElement = multipleChoiceTagName;
415
+ `,
416
+ },
417
+ {
418
+ from: '<ebsr-multiple-choice-configure',
419
+ to: '<MultipleChoiceConfigureElement',
420
+ },
421
+ {
422
+ from: '</ebsr-multiple-choice-configure>',
423
+ to: '</MultipleChoiceConfigureElement>',
424
+ },
425
+ ])) || changed;
426
+ return changed;
427
+ }
428
+ async ensureComplexRubricPrivateChildReferences(elementDir) {
429
+ let changed = false;
430
+ changed =
431
+ (await this.replaceInSyncedFile(join(elementDir, 'src/delivery/index.ts'), [
432
+ {
433
+ from: "import { RUBRIC_TYPES } from '@pie-lib/rubric';\n",
434
+ to: "import { RUBRIC_TYPES } from '@pie-lib/rubric';\nimport { COMPLEX_RUBRIC_MULTI_TRAIT_TAG, COMPLEX_RUBRIC_SIMPLE_TAG } from '../private-tags.js';\n",
435
+ },
436
+ {
437
+ from: "const RUBRIC_TAG_NAME = 'complex-rubric-simple';",
438
+ to: 'const RUBRIC_TAG_NAME = COMPLEX_RUBRIC_SIMPLE_TAG;',
439
+ },
440
+ {
441
+ from: "const MULTI_TRAIT_RUBRIC_TAG_NAME = 'complex-rubric-multi-trait';",
442
+ to: 'const MULTI_TRAIT_RUBRIC_TAG_NAME = COMPLEX_RUBRIC_MULTI_TRAIT_TAG;',
443
+ },
444
+ ])) || changed;
445
+ changed =
446
+ (await this.replaceInSyncedFile(join(elementDir, 'src/print/index.ts'), [
447
+ {
448
+ from: "import { RUBRIC_TYPES } from '@pie-lib/rubric';\n",
449
+ to: "import { RUBRIC_TYPES } from '@pie-lib/rubric';\nimport { COMPLEX_RUBRIC_MULTI_TRAIT_TAG, COMPLEX_RUBRIC_SIMPLE_TAG } from '../private-tags.js';\n",
450
+ },
451
+ {
452
+ from: "const RUBRIC_TAG_NAME = 'complex-rubric-simple';",
453
+ to: 'const RUBRIC_TAG_NAME = COMPLEX_RUBRIC_SIMPLE_TAG;',
454
+ },
455
+ {
456
+ from: "const MULTI_TRAIT_RUBRIC_TAG_NAME = 'complex-rubric-multi-trait';",
457
+ to: 'const MULTI_TRAIT_RUBRIC_TAG_NAME = COMPLEX_RUBRIC_MULTI_TRAIT_TAG;',
458
+ },
459
+ ])) || changed;
460
+ changed =
461
+ (await this.replaceInSyncedFile(join(elementDir, 'src/author/index.ts'), [
462
+ {
463
+ from: "import sensibleDefaults from './defaults';\n",
464
+ to: "import sensibleDefaults from './defaults';\nimport {\n COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG,\n COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG,\n} from '../private-tags.js';\n",
465
+ },
466
+ {
467
+ from: "const RUBRIC_TAG_NAME = 'rubric-configure';",
468
+ to: 'const RUBRIC_TAG_NAME = COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG;',
469
+ },
470
+ {
471
+ from: "const MULTI_TRAIT_RUBRIC_TAG_NAME = 'multi-trait-rubric-configure';",
472
+ to: 'const MULTI_TRAIT_RUBRIC_TAG_NAME = COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG;',
473
+ },
474
+ {
475
+ from: ' configuration: this._configuration,\n',
476
+ to: ' configuration: this._configuration,\n multiTraitRubricTagName: MULTI_TRAIT_RUBRIC_TAG_NAME,\n',
477
+ },
478
+ {
479
+ from: ' onConfigurationChanged: this.onConfigurationChanged,\n',
480
+ to: ' onConfigurationChanged: this.onConfigurationChanged,\n simpleRubricTagName: RUBRIC_TAG_NAME,\n',
481
+ },
482
+ ])) || changed;
483
+ changed =
484
+ (await this.replaceInSyncedFile(join(elementDir, 'src/author/main.tsx'), [
485
+ {
486
+ from: "import { color } from '@pie-lib/render-ui';\n",
487
+ to: "import { color } from '@pie-lib/render-ui';\nimport {\n COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG,\n COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG,\n} from '../private-tags.js';\n",
488
+ },
489
+ {
490
+ from: ` canUpdateModel: PropTypes.bool,
491
+ configuration: PropTypes.object,
492
+ model: PropTypes.object,
493
+ onModelChanged: PropTypes.func,
494
+ onConfigurationChanged: PropTypes.func,`,
495
+ to: ` canUpdateModel: PropTypes.bool,
496
+ configuration: PropTypes.object,
497
+ multiTraitRubricTagName: PropTypes.string,
498
+ model: PropTypes.object,
499
+ onModelChanged: PropTypes.func,
500
+ onConfigurationChanged: PropTypes.func,
501
+ simpleRubricTagName: PropTypes.string,`,
502
+ },
503
+ {
504
+ from: ' const { model, configuration, canUpdateModel } = this.props;\n',
505
+ to: ` const {
506
+ model,
507
+ configuration,
508
+ canUpdateModel,
509
+ multiTraitRubricTagName = COMPLEX_RUBRIC_MULTI_TRAIT_CONFIGURE_TAG,
510
+ simpleRubricTagName = COMPLEX_RUBRIC_SIMPLE_CONFIGURE_TAG,
511
+ } = this.props;
512
+ const MultiTraitRubricConfigureElement = multiTraitRubricTagName;
513
+ const SimpleRubricConfigureElement = simpleRubricTagName;
514
+ `,
515
+ },
516
+ { from: '<rubric-configure', to: '<SimpleRubricConfigureElement' },
517
+ { from: '</rubric-configure>', to: '</SimpleRubricConfigureElement>' },
518
+ { from: '<multi-trait-rubric-configure', to: '<MultiTraitRubricConfigureElement' },
519
+ {
520
+ from: '</multi-trait-rubric-configure>',
521
+ to: '</MultiTraitRubricConfigureElement>',
522
+ },
523
+ ])) || changed;
524
+ return changed;
525
+ }
526
+ async replaceInSyncedFile(filePath, replacements) {
527
+ if (!existsSync(filePath)) {
528
+ return false;
529
+ }
530
+ const original = await readFile(filePath, 'utf-8');
531
+ let next = original;
532
+ for (const { from, to } of replacements) {
533
+ if (!next.includes(from)) {
534
+ continue;
535
+ }
536
+ next = next.split(from).join(to);
537
+ }
538
+ if (next === original) {
539
+ return false;
540
+ }
541
+ await writeFile(filePath, next, 'utf-8');
542
+ return true;
543
+ }
316
544
  /**
317
545
  * Sync a single print file (src/print.js -> src/print/index.ts)
318
546
  */
@@ -389,44 +617,7 @@ export class ReactComponentsStrategy {
389
617
  const viteConfigPath = join(elementDir, 'vite.config.ts');
390
618
  // Always regenerate to reflect current directory structure
391
619
  // (e.g., if configure/ was skipped due to ESM incompatibility)
392
- // Detect entry points
393
- const entryPoints = {};
394
- // Helper to find which file extension exists (.ts or .tsx)
395
- const findEntry = (basePath) => {
396
- if (existsSync(join(elementDir, `${basePath}.tsx`)))
397
- return `${basePath}.tsx`;
398
- if (existsSync(join(elementDir, `${basePath}.ts`)))
399
- return `${basePath}.ts`;
400
- return null;
401
- };
402
- const indexEntry = findEntry('src/index');
403
- if (indexEntry) {
404
- entryPoints.index = indexEntry;
405
- }
406
- const controllerEntry = findEntry('src/controller/index');
407
- if (controllerEntry) {
408
- entryPoints['controller/index'] = controllerEntry;
409
- }
410
- const configureEntry = findEntry('src/configure/index');
411
- if (configureEntry) {
412
- entryPoints['configure/index'] = configureEntry;
413
- }
414
- const deliveryEntry = findEntry('src/delivery/index');
415
- if (deliveryEntry) {
416
- entryPoints['delivery/index'] = deliveryEntry;
417
- }
418
- const authorEntry = findEntry('src/author/index');
419
- if (authorEntry) {
420
- entryPoints['author/index'] = authorEntry;
421
- }
422
- const printEntry = findEntry('src/print/index');
423
- if (printEntry) {
424
- entryPoints['print/index'] = printEntry;
425
- }
426
- const typesEntry = findEntry('src/types/index');
427
- if (typesEntry) {
428
- entryPoints['types/index'] = typesEntry;
429
- }
620
+ const entryPoints = collectElementViteEntryPoints(elementDir);
430
621
  if (Object.keys(entryPoints).length === 0) {
431
622
  return; // No entry points, skip vite config
432
623
  }
@@ -459,12 +650,22 @@ export class ReactComponentsStrategy {
459
650
  // Build mode: build the library
460
651
  return {`
461
652
  : `{`;
462
- return `import { resolve } from 'node:path';
653
+ return `import { readFileSync } from 'node:fs';
654
+ import { resolve } from 'node:path';
463
655
  import react from '@vitejs/plugin-react';
464
656
  import { defineConfig } from 'vite';
465
657
 
658
+ const packageJson = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8')) as {
659
+ name?: string;
660
+ version?: string;
661
+ };
662
+
466
663
  export default defineConfig(${demoModeConfig}
467
664
  plugins: [react()],
665
+ define: {
666
+ __PIE_PACKAGE_NAME__: JSON.stringify(packageJson.name ?? ''),
667
+ __PIE_PACKAGE_VERSION__: JSON.stringify(packageJson.version ?? 'local'),
668
+ },
468
669
  build: {
469
670
  lib: {
470
671
  entry: {
@@ -567,11 +768,16 @@ export default Element;
567
768
  .split('-')
568
769
  .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
569
770
  .join('') + 'Element';
570
- const config = `import { existsSync } from 'node:fs';
771
+ const config = `import { existsSync, readFileSync } from 'node:fs';
571
772
  import { resolve } from 'node:path';
572
773
  import react from '@vitejs/plugin-react';
573
774
  import { defineConfig } from 'vite';
574
775
 
776
+ const packageJson = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8')) as {
777
+ name?: string;
778
+ version?: string;
779
+ };
780
+
575
781
  const resolveWorkspaceEntry = (baseDir: string): string | null => {
576
782
  const candidates = ['index.ts', 'index.tsx', 'index.js', 'index.jsx'];
577
783
  for (const candidate of candidates) {
@@ -625,6 +831,8 @@ export default defineConfig({
625
831
  ],
626
832
  define: {
627
833
  'process.env.NODE_ENV': JSON.stringify('production'),
834
+ __PIE_PACKAGE_NAME__: JSON.stringify(packageJson.name ?? ''),
835
+ __PIE_PACKAGE_VERSION__: JSON.stringify(packageJson.version ?? 'local'),
628
836
  },
629
837
  build: {
630
838
  emptyOutDir: false, // Don't wipe existing ESM builds
@@ -719,7 +927,7 @@ export default defineConfig({
719
927
  }
720
928
  generateTsConfig() {
721
929
  return `{
722
- "extends": "../../../tsconfig.base.json",
930
+ "extends": "../../../tsconfig.declarations.json",
723
931
  "compilerOptions": {
724
932
  "outDir": "dist",
725
933
  "declarationDir": "dist",