@astryxdesign/cli 0.7.15 → 0.7.16-canary.g723a112

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 (122) hide show
  1. package/README.md +5 -3
  2. package/api/component/_adapter.d.mts +1 -1
  3. package/api/component/_adapter.mjs +28 -1
  4. package/api/doctor/_adapter.d.mts +17 -0
  5. package/api/doctor/_adapter.mjs +35 -0
  6. package/api/doctor/doctor.mjs +18 -4
  7. package/api/integration/validate-integration.mjs +1 -1
  8. package/api/theme/_adapter.d.mts +5 -2
  9. package/api/theme/_adapter.mjs +43 -12
  10. package/api/theme/build/build.d.mts +15 -23
  11. package/api/theme/build/build.mjs +285 -47
  12. package/api/theme/eject/eject.mjs +22 -1
  13. package/api/theme/template/template.d.mts +19 -0
  14. package/api/theme/template/template.mjs +102 -25
  15. package/api/theme/theme.type.d.mts +5 -1
  16. package/api/theme/theme.type.mjs +2 -1
  17. package/api/theme/themeBuild.doc.mjs +3 -3
  18. package/api/theme/themeEject.doc.mjs +1 -1
  19. package/api/theme/themeTemplate.doc.mjs +9 -3
  20. package/api/theme-edit/_adapter.d.mts +33 -0
  21. package/api/theme-edit/_adapter.mjs +208 -31
  22. package/api/theme-edit/_check.d.mts +38 -0
  23. package/api/theme-edit/_check.mjs +1326 -211
  24. package/api/theme-edit/_color.d.mts +2 -8
  25. package/api/theme-edit/_color.mjs +292 -219
  26. package/api/theme-edit/_compiler.d.mts +1 -0
  27. package/api/theme-edit/_compiler.mjs +20 -1
  28. package/api/theme-edit/_context.d.mts +29 -0
  29. package/api/theme-edit/_context.mjs +329 -30
  30. package/api/theme-edit/_css.d.mts +60 -1
  31. package/api/theme-edit/_css.mjs +404 -28
  32. package/api/theme-edit/_edit.d.mts +9 -0
  33. package/api/theme-edit/_edit.mjs +1025 -126
  34. package/api/theme-edit/_how-commands.d.mts +11 -26
  35. package/api/theme-edit/_how-commands.mjs +30 -2
  36. package/api/theme-edit/_how-question.d.mts +7 -0
  37. package/api/theme-edit/_how-question.mjs +1304 -176
  38. package/api/theme-edit/_how.mjs +144 -30
  39. package/api/theme-edit/_overview.mjs +2 -0
  40. package/api/theme-edit/_palette.d.mts +11 -0
  41. package/api/theme-edit/_palette.mjs +194 -65
  42. package/api/theme-edit/_parts.d.mts +16 -0
  43. package/api/theme-edit/_parts.mjs +59 -7
  44. package/api/theme-edit/_png.mjs +19 -14
  45. package/api/theme-edit/_preview-app.d.mts +3 -0
  46. package/api/theme-edit/_preview-app.mjs +843 -45
  47. package/api/theme-edit/_preview.d.mts +15 -2
  48. package/api/theme-edit/_preview.mjs +288 -28
  49. package/api/theme-edit/_project.d.mts +11 -0
  50. package/api/theme-edit/_project.mjs +35 -9
  51. package/api/theme-edit/_settings.d.mts +178 -5
  52. package/api/theme-edit/_settings.mjs +2035 -86
  53. package/api/theme-edit/_tables.d.mts +24 -0
  54. package/api/theme-edit/_tables.mjs +211 -149
  55. package/api/theme-edit/_vet.d.mts +42 -0
  56. package/api/theme-edit/_vet.mjs +144 -0
  57. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  58. package/api/theme-edit/theme-edit.type.mjs +1 -1
  59. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  60. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  61. package/api/upgrade/registry/registry.mjs +6 -1
  62. package/assets/docs/tree/single-component.doc.mjs +11 -2
  63. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  64. package/assets/docs.generated.json +2 -2
  65. package/assets/preview-app/next.config.mjs +7 -1
  66. package/assets/preview-app/package.json +1 -0
  67. package/assets/preview-app/src/app/globals.css +1 -0
  68. package/assets/self-audit.generated.json +1 -1
  69. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  70. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  71. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  72. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  73. package/assets/templates/components.generated.json +1 -1
  74. package/assets/templates/pages/dashboard/page.tsx +1 -1
  75. package/authoring/doctypes/_schema.d.mts +52 -5
  76. package/authoring/doctypes/_schema.mjs +62 -7
  77. package/authoring/doctypes/base/type.ts +10 -0
  78. package/authoring/doctypes/component/component.doc.mjs +1 -1
  79. package/authoring/doctypes/function/function.doc.mjs +6 -0
  80. package/authoring/doctypes/function/type.ts +3 -0
  81. package/authoring/doctypes/legacy.mjs +5 -1
  82. package/authoring/index.d.ts +1 -0
  83. package/clients/cli/build-id.generated.json +1 -1
  84. package/clients/cli/commands/doctor.doc.mjs +2 -2
  85. package/clients/cli/commands/experimental/theme.mjs +190 -37
  86. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  87. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
  88. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  89. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  90. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  91. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  92. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  93. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  94. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  95. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  96. package/clients/cli/commands/theme.mjs +153 -37
  97. package/clients/cli/formatters/index.mjs +7 -4
  98. package/clients/cli/lib/cli-error.mjs +9 -3
  99. package/clients/cli/lib/component-format.mjs +27 -9
  100. package/clients/cli/lib/json-shim.mjs +40 -2
  101. package/clients/cli/manifest.generated.json +1 -1
  102. package/clients/cli/run.mjs +49 -0
  103. package/foundation/config/project.mjs +50 -14
  104. package/foundation/discovery/theme-discovery.d.mts +5 -1
  105. package/foundation/discovery/theme-discovery.mjs +24 -3
  106. package/foundation/fs/gather-cache.d.mts +9 -2
  107. package/foundation/fs/gather-cache.mjs +79 -15
  108. package/foundation/fs/paths.d.mts +31 -0
  109. package/foundation/fs/paths.mjs +43 -10
  110. package/foundation/render/host-exit.d.mts +8 -0
  111. package/foundation/render/host-exit.mjs +11 -0
  112. package/foundation/render/page-host.mjs +56 -10
  113. package/foundation/render/page-worker.mjs +14 -0
  114. package/foundation/render/render-page.mjs +37 -2
  115. package/foundation/response/error-codes.d.mts +2 -1
  116. package/foundation/response/error-codes.d.ts +1 -0
  117. package/foundation/response/error-codes.doc.mjs +5 -0
  118. package/foundation/response/error-codes.mjs +3 -0
  119. package/foundation/response/json.d.mts +15 -0
  120. package/foundation/response/json.mjs +52 -1
  121. package/foundation/response/response-types.doc.mjs +1 -1
  122. package/package.json +7 -6
package/README.md CHANGED
@@ -223,6 +223,7 @@ if (isError(result)) {
223
223
  | `ERR_WRITE_FAILED` | Writing output files failed (and was rolled back). |
224
224
  | `ERR_THEME_INVALID` | A theme definition or contributed theme descriptor is invalid. |
225
225
  | `ERR_THEME_LOAD` | A theme file could not be loaded / parsed into a defineTheme result. |
226
+ | `ERR_THEME_STALE` | `theme build --check` found stale or missing outputs: exit 1, in the check result (`code`), not an error. |
226
227
  | `ERR_PALETTE_GENERATION` | A palette generation request or one of its constraints was invalid. |
227
228
  | `ERR_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
228
229
  | `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
@@ -511,7 +512,7 @@ Every response has a `type` discriminant. The full set is below (generated from
511
512
  | `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |
512
513
  | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |
513
514
  | `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |
514
- | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |
515
+ | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), the full list of checked paths, and, when any is stale or missing, code ERR_THEME_STALE. Writes nothing. |
515
516
  | `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |
516
517
  | `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, owner package or local root, source, added, and default fields. Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |
517
518
  | `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. After add, the envelope package names the npm package that owns the added theme; a local theme has none. |
@@ -540,8 +541,9 @@ Every response has a `type` discriminant. The full set is below (generated from
540
541
 
541
542
  ## Doctor
542
543
 
543
- `astryx doctor` runs read-only health checks against your project and
544
- environment. Each record uses `[ok]`, `[warn]`, `[fail]`, or `[info]`, and
544
+ `astryx doctor` runs health checks against your project and environment. It
545
+ changes nothing in the project; once the per-user cache folder exists, it
546
+ keeps its docs checks and integration check results there. Each record uses `[ok]`, `[warn]`, `[fail]`, or `[info]`, and
545
547
  includes an actionable `fix` when one is available. Field names match the
546
548
  `--json` keys. The exact checks and values depend on the project; the output
547
549
  shape is stable:
@@ -206,7 +206,7 @@ export function extractProps(docs: LoadedComponentDoc): any[];
206
206
  * Augment a loaded `component.detail` doc with ownership metadata. Adds
207
207
  * `package`, the resolved `import` specifier, and `sourceAvailable` (whether a
208
208
  * swizzleable source file exists for the owner). Existing doc fields (name,
209
- * usage, props, …) are preserved.
209
+ * usage, props, …) are preserved; each example carries its `kind`.
210
210
  * @param {LoadedComponentDoc} docs
211
211
  * @param {OwnershipSubject} owner
212
212
  * @param {string} componentName
@@ -589,11 +589,26 @@ export function extractProps(docs) {
589
589
  );
590
590
  }
591
591
 
592
+ /**
593
+ * Give every example its `kind`, so a JSON reader never has to know the
594
+ * default: an example with no `kind` is a `demo`.
595
+ * @param {unknown} examples
596
+ * @returns {unknown}
597
+ */
598
+ function withExampleKinds(examples) {
599
+ if (!Array.isArray(examples)) return examples;
600
+ return examples.map(example =>
601
+ example && typeof example === 'object'
602
+ ? {...example, kind: example.kind ?? 'demo'}
603
+ : example,
604
+ );
605
+ }
606
+
592
607
  /**
593
608
  * Augment a loaded `component.detail` doc with ownership metadata. Adds
594
609
  * `package`, the resolved `import` specifier, and `sourceAvailable` (whether a
595
610
  * swizzleable source file exists for the owner). Existing doc fields (name,
596
- * usage, props, …) are preserved.
611
+ * usage, props, …) are preserved; each example carries its `kind`.
597
612
  * @param {LoadedComponentDoc} docs
598
613
  * @param {OwnershipSubject} owner
599
614
  * @param {string} componentName
@@ -605,8 +620,20 @@ export function withOwnership(docs, owner, componentName, coreDir) {
605
620
  owner.package === CORE_PACKAGE
606
621
  ? (docs.import ?? resolveImportPath(coreDir, componentName))
607
622
  : resolveIntegrationImportPath(owner, componentName, docs.import);
623
+ /** @type {any} */
624
+ const doc = docs;
608
625
  return /** @type {any} */ ({
609
626
  ...docs,
627
+ ...(doc.examples ? {examples: withExampleKinds(doc.examples)} : {}),
628
+ ...(Array.isArray(doc.components)
629
+ ? {
630
+ components: doc.components.map((/** @type {any} */ entry) =>
631
+ entry?.examples
632
+ ? {...entry, examples: withExampleKinds(entry.examples)}
633
+ : entry,
634
+ ),
635
+ }
636
+ : {}),
610
637
  package: owner.package,
611
638
  import: importSpec,
612
639
  sourceAvailable: owner.sourcePath != null,
@@ -1,6 +1,23 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * A doctor check that reads only files, kept between runs through the kept
6
+ * gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
7
+ * folder, module and environment variable it read unchanged reads the check
8
+ * back. Only the docs checks go through here; a check that depends on the
9
+ * time, the network or anything else the stamps do not see never does.
10
+ * @template T
11
+ * @param {{name: string, cwd: string, coreDir: string | null}} where - The
12
+ * check, the project folder, and the Core folder the project loads.
13
+ * @param {() => Promise<T>} check
14
+ * @returns {Promise<T>}
15
+ */
16
+ export function keptFileCheck<T>({ name, cwd, coreDir }: {
17
+ name: string;
18
+ cwd: string;
19
+ coreDir: string | null;
20
+ }, check: () => Promise<T>): Promise<T>;
4
21
  /**
5
22
  * Package written to the generated app record for one discovered theme.
6
23
  * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
@@ -45,6 +45,11 @@ export {unlistedIconSets} from '../../foundation/discovery/icon-set-discovery.mj
45
45
  import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
46
46
  import {cssImports} from '../../foundation/render/embedded-imports.mjs';
47
47
  import * as path from 'node:path';
48
+ import {
49
+ persistedGather,
50
+ recordedRun,
51
+ } from '../../foundation/fs/gather-cache.mjs';
52
+ import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
48
53
  import {
49
54
  Project,
50
55
  availableComputerIntegrations,
@@ -83,6 +88,36 @@ export {
83
88
  authoringAuditData,
84
89
  } from './_authoring-audit.mjs';
85
90
 
91
+ /** A doctor check record, kept as it is. */
92
+ const CHECK_CODEC = {
93
+ encode: (/** @type {any} */ check) => check,
94
+ decode: (/** @type {any} */ check) => check,
95
+ };
96
+
97
+ /**
98
+ * A doctor check that reads only files, kept between runs through the kept
99
+ * gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
100
+ * folder, module and environment variable it read unchanged reads the check
101
+ * back. Only the docs checks go through here; a check that depends on the
102
+ * time, the network or anything else the stamps do not see never does.
103
+ * @template T
104
+ * @param {{name: string, cwd: string, coreDir: string | null}} where - The
105
+ * check, the project folder, and the Core folder the project loads.
106
+ * @param {() => Promise<T>} check
107
+ * @returns {Promise<T>}
108
+ */
109
+ export function keptFileCheck({name, cwd, coreDir}, check) {
110
+ // Only a recorded run (a plain `doctor` from the bin) reads or keeps one: a
111
+ // hosted run names its commands its own way, so it always checks.
112
+ if (!recordedRun()) return check();
113
+ return persistedGather(
114
+ // With the command name the checks print commands with.
115
+ ['doctor-check', name, cwd, coreDir, getCliInvocation(cwd)],
116
+ check,
117
+ CHECK_CODEC,
118
+ );
119
+ }
120
+
86
121
  /**
87
122
  * Package written to the generated app record for one discovered theme.
88
123
  * @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
@@ -100,6 +100,7 @@ import {
100
100
  COMPUTER_INSTALL_STEP,
101
101
  } from '../../foundation/agent-docs/computer-agent-text.mjs';
102
102
  import {
103
+ keptFileCheck,
103
104
  alignCommand,
104
105
  addCliCommandFor,
105
106
  computerAgentTextState,
@@ -2192,7 +2193,7 @@ export function checkGatherCache() {
2192
2193
  id: 'gather-cache',
2193
2194
  label: 'Kept catalog cache',
2194
2195
  status: 'info',
2195
- message: `search, build, component, template, theme and discover keep what they gather (search's catalogs and each integration's check results) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
2196
+ message: `search, build, component, template, theme, discover and doctor keep what they gather (search's catalogs, each integration's check results, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
2196
2197
  };
2197
2198
  }
2198
2199
 
@@ -2465,9 +2466,22 @@ export async function runChecks(options = {}) {
2465
2466
  );
2466
2467
  }
2467
2468
  checks.push(await checkAuthoringDocs(ctx));
2468
- checks.push(await checkCliDocs(ctx));
2469
- checks.push(await checkDocsTree(ctx));
2470
- checks.push(await checkDocsProgressiveDisclosure(ctx));
2469
+ // The checks that read only files, each kept while every file it read is
2470
+ // unchanged; the Core the project loads is part of what they read.
2471
+ const where = {cwd, coreDir: coreDir ?? null};
2472
+ checks.push(
2473
+ await keptFileCheck({name: 'cli-docs', ...where}, () => checkCliDocs(ctx)),
2474
+ );
2475
+ checks.push(
2476
+ await keptFileCheck({name: 'docs-tree', ...where}, () =>
2477
+ checkDocsTree(ctx),
2478
+ ),
2479
+ );
2480
+ checks.push(
2481
+ await keptFileCheck({name: 'docs-progressive', ...where}, () =>
2482
+ checkDocsProgressiveDisclosure(ctx),
2483
+ ),
2484
+ );
2471
2485
 
2472
2486
  const summary = {pass: 0, warn: 0, fail: 0, info: 0};
2473
2487
  for (const c of checks) summary[c.status] += 1;
@@ -293,7 +293,7 @@ async function findUnreachableContributionIssues(
293
293
  issues.push(
294
294
  warning(
295
295
  'unreachable_contribution',
296
- `Found contribution metadata "${path.relative(packageDir, full)}" outside every declared integration root, so it contributes nothing. ${unreachableFix(context, full, stamp)}`,
296
+ `Found contribution metadata "${path.relative(packageDir, full).split(path.sep).join('/')}" outside every declared integration root, so it contributes nothing. ${unreachableFix(context, full, stamp)}`,
297
297
  ),
298
298
  );
299
299
  }
@@ -78,8 +78,10 @@ export function listUnmigratedThemeCopies(cwd: string): import("../../foundation
78
78
  * @param {{cwd: string, targetPath?: string, overwrite?: boolean, takenSlugs?: Set<string>}} options
79
79
  * `takenSlugs`: the slugs of the themes the project can use, which a fork's
80
80
  * new folder name may not take
81
- * @returns {{outputDir: string, files: string[]}} the project-relative output
82
- * directory and the files written, named as the fork names them
81
+ * @returns {{outputDir: string, files: string[], editorFolder: string | null}}
82
+ * the output directory relative to the working folder, the files written,
83
+ * named as the fork names them, and the folder the theme editor made that
84
+ * holds the fork, relative to the working folder, or null
83
85
  */
84
86
  export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, { cwd, targetPath: typedPath, overwrite, takenSlugs }: {
85
87
  cwd: string;
@@ -89,6 +91,7 @@ export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-
89
91
  }): {
90
92
  outputDir: string;
91
93
  files: string[];
94
+ editorFolder: string | null;
92
95
  };
93
96
  /**
94
97
  * The packages the fork imports that the app does not declare. A fork that
@@ -16,6 +16,7 @@ import {createRequire} from 'node:module';
16
16
  import {
17
17
  findCarriedCoreDir,
18
18
  findPackageRoot,
19
+ projectWritePath,
19
20
  requireCoreDir,
20
21
  } from '../../foundation/fs/paths.mjs';
21
22
  import {tryLock, userCacheDir} from '../../foundation/release/cache.mjs';
@@ -645,8 +646,10 @@ function themeDescriptorName(file) {
645
646
  * @param {{cwd: string, targetPath?: string, overwrite?: boolean, takenSlugs?: Set<string>}} options
646
647
  * `takenSlugs`: the slugs of the themes the project can use, which a fork's
647
648
  * new folder name may not take
648
- * @returns {{outputDir: string, files: string[]}} the project-relative output
649
- * directory and the files written, named as the fork names them
649
+ * @returns {{outputDir: string, files: string[], editorFolder: string | null}}
650
+ * the output directory relative to the working folder, the files written,
651
+ * named as the fork names them, and the folder the theme editor made that
652
+ * holds the fork, relative to the working folder, or null
650
653
  */
651
654
  export function ejectThemeFiles(
652
655
  theme,
@@ -655,15 +658,17 @@ export function ejectThemeFiles(
655
658
  // The fork lands in the project, as list and add read it: the default root
656
659
  // is the project's, and a relative [path] is read from the working folder
657
660
  // but must stay inside the project.
658
- const projectDir = findPackageRoot(cwd) ?? path.resolve(cwd);
659
- // A Windows-style path names the same folders on every platform, as
660
- // compile reads it; a folder name with a backslash in it is never meant.
661
- const targetPath = typedPath?.replace(/\\/g, '/');
662
- const target = !targetPath
663
- ? defaultEjectTarget(theme.slug)
664
- : path.isAbsolute(targetPath)
665
- ? targetPath
666
- : path.relative(projectDir, path.resolve(cwd, targetPath)) || '.';
661
+ // Read as every theme command reads a path it writes; a backslash
662
+ // separates folders on every platform.
663
+ const {
664
+ projectDir,
665
+ typed: targetPath,
666
+ relative: target,
667
+ } = projectWritePath(
668
+ cwd,
669
+ typedPath || undefined,
670
+ defaultEjectTarget(theme.slug),
671
+ );
667
672
  let resolvedDir;
668
673
  try {
669
674
  resolvedDir = assertWithin(target, projectDir, {
@@ -830,7 +835,33 @@ export function ejectThemeFiles(
830
835
  throw new AstryxError(message, undefined, ERROR_CODES.ERR_WRITE_FAILED);
831
836
  }
832
837
 
833
- return {outputDir: path.relative(cwd, resolvedDir) || '.', files: names};
838
+ const editorDir = enclosingEditorFolder(resolvedDir, projectDir);
839
+ return {
840
+ outputDir: path.relative(cwd, resolvedDir) || '.',
841
+ files: names,
842
+ editorFolder:
843
+ editorDir == null ? null : path.relative(cwd, editorDir) || '.',
844
+ };
845
+ }
846
+
847
+ /**
848
+ * The nearest folder above `dir`, up to the project root, that the theme
849
+ * editor made, or null. Eject refuses the editor's folder itself; a subfolder
850
+ * of it is written as released CLIs did, with a warning.
851
+ * @param {string} dir
852
+ * @param {string} projectDir
853
+ * @returns {string | null}
854
+ */
855
+ function enclosingEditorFolder(dir, projectDir) {
856
+ const root = path.resolve(projectDir);
857
+ let current = path.resolve(dir);
858
+ while (current !== root) {
859
+ const parent = path.dirname(current);
860
+ if (parent === current) return null;
861
+ current = parent;
862
+ if (editorThemeRecord(current)) return current;
863
+ }
864
+ return null;
834
865
  }
835
866
 
836
867
  /**
@@ -68,6 +68,19 @@ export function themeSourceFiles(filePath: string): string[];
68
68
  * @returns {string[]} at most three paths
69
69
  */
70
70
  export function themeSourceGuesses(file: string, cwd: string): string[];
71
+ /**
72
+ * Hand the theme editor warnings of the builds in this process to
73
+ * `listener` instead of the logger. CLI-internal: the watch child's
74
+ * hand-off to its parent.
75
+ * @param {((warning: string) => void) | null} listener
76
+ */
77
+ export function setEditorFolderListener(listener: ((warning: string) => void) | null): void;
78
+ /**
79
+ * Tell `listener` when a build in this process finds private var errors.
80
+ * CLI-internal.
81
+ * @param {(() => void) | null} listener
82
+ */
83
+ export function setPrivateVarErrorListener(listener: (() => void) | null): void;
71
84
  /**
72
85
  * Publish the outputs a batch deferred, one theme at a time, in build order.
73
86
  * @param {Array<Array<{dest: string, content: string}>>} deferred
@@ -178,36 +191,18 @@ export function themeBuild(file: string, options?: {
178
191
  cwd?: string;
179
192
  projectCore?: boolean;
180
193
  }): Promise<import("../theme.type.mjs").ThemeBuildResponse | import("../theme.type.mjs").ThemeBuildCheckResponse | null>;
181
- /** @param {string[]} files @param {{familyKey: string, check?: boolean, iconsSpecifier?: string, __onPrivateVarError?: () => void, __commandWords?: {group: string, build: string}}} options @param {{cwd?: string}} [ctx] */
194
+ /** @param {string[]} files @param {{familyKey: string, check?: boolean, iconsSpecifier?: string, __commandWords?: {group: string, build: string}}} options @param {{cwd?: string}} [ctx] */
182
195
  export function themeBuildFamily(files: string[], options: {
183
196
  familyKey: string;
184
197
  check?: boolean;
185
198
  iconsSpecifier?: string;
186
- __onPrivateVarError?: () => void;
187
199
  __commandWords?: {
188
200
  group: string;
189
201
  build: string;
190
202
  };
191
203
  }, { cwd }?: {
192
204
  cwd?: string;
193
- }): Promise<{
194
- type: string;
195
- data: {
196
- name: any;
197
- upToDate: boolean;
198
- stale: {
199
- path: string;
200
- reason: "missing" | "outdated";
201
- }[];
202
- checked: string[];
203
- tokenCount?: undefined;
204
- componentCount?: undefined;
205
- sizeKB?: undefined;
206
- outputs?: undefined;
207
- warnings?: undefined;
208
- notices?: undefined;
209
- };
210
- } | {
205
+ }): Promise<import("../theme.type.mjs").ThemeBuildCheckResponse | {
211
206
  type: string;
212
207
  data: {
213
208
  name: any;
@@ -222,9 +217,6 @@ export function themeBuildFamily(files: string[], options: {
222
217
  };
223
218
  warnings: any[];
224
219
  notices: string[];
225
- upToDate?: undefined;
226
- stale?: undefined;
227
- checked?: undefined;
228
220
  };
229
221
  }>;
230
222
  /**