@astryxdesign/cli 0.7.15 → 0.7.16-canary.g22213fd

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 (222) hide show
  1. package/README.md +6 -4
  2. package/api/build/_adapter.d.mts +10 -0
  3. package/api/build/_adapter.mjs +24 -0
  4. package/api/build/blocks/blocks.d.mts +1 -0
  5. package/api/build/blocks/blocks.mjs +18 -1
  6. package/api/build/kit/shell.weights.json +1 -0
  7. package/api/build/kit/shellcall.d.mts +26 -0
  8. package/api/build/kit/shellcall.mjs +87 -0
  9. package/api/build/kit/start.mjs +67 -4
  10. package/api/build/kit/weights.d.mts +15 -0
  11. package/api/build/kit/weights.mjs +27 -0
  12. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  13. package/api/component/_adapter.d.mts +1 -1
  14. package/api/component/_adapter.mjs +28 -1
  15. package/api/doctor/_adapter.d.mts +38 -2
  16. package/api/doctor/_adapter.mjs +76 -1
  17. package/api/doctor/built-checks.mjs +1 -1
  18. package/api/doctor/doctor.d.mts +26 -0
  19. package/api/doctor/doctor.doc.mjs +1 -1
  20. package/api/doctor/doctor.mjs +156 -11
  21. package/api/doctor/theme-checks.mjs +163 -18
  22. package/api/icon/_adapter.d.mts +7 -3
  23. package/api/icon/_adapter.mjs +12 -3
  24. package/api/icon/icon.type.d.mts +15 -0
  25. package/api/icon/icon.type.mjs +10 -3
  26. package/api/icon/iconUse.doc.mjs +19 -5
  27. package/api/icon/list/list.mjs +7 -1
  28. package/api/icon/use/use.d.mts +8 -5
  29. package/api/icon/use/use.mjs +95 -13
  30. package/api/init/run/run.mjs +1 -0
  31. package/api/integration/add-contribution.mjs +3 -3
  32. package/api/integration/pack-check.mjs +14 -8
  33. package/api/integration/validate-integration.mjs +1 -1
  34. package/api/search/_adapter.mjs +15 -16
  35. package/api/search/_entries.d.mts +2 -1
  36. package/api/search/_entries.mjs +28 -1
  37. package/api/swizzle/_moduleGraph.mjs +1 -1
  38. package/api/template/template.type.d.mts +6 -2
  39. package/api/template/template.type.mjs +2 -1
  40. package/api/theme/_adapter.d.mts +5 -2
  41. package/api/theme/_adapter.mjs +59 -14
  42. package/api/theme/_fork.mjs +1 -1
  43. package/api/theme/build/build.d.mts +120 -32
  44. package/api/theme/build/build.mjs +471 -111
  45. package/api/theme/eject/eject.mjs +22 -1
  46. package/api/theme/generateTonalPalette.doc.mjs +2 -2
  47. package/api/theme/palette/generate/generator.mjs +141 -2
  48. package/api/theme/template/template.d.mts +19 -0
  49. package/api/theme/template/template.mjs +102 -25
  50. package/api/theme/theme.type.d.mts +44 -1
  51. package/api/theme/theme.type.mjs +23 -1
  52. package/api/theme/themeBuild.doc.mjs +4 -4
  53. package/api/theme/themeEject.doc.mjs +1 -1
  54. package/api/theme/themePaletteGenerate.doc.mjs +1 -1
  55. package/api/theme/themeTemplate.doc.mjs +9 -3
  56. package/api/theme-edit/_adapter.d.mts +33 -2
  57. package/api/theme-edit/_adapter.mjs +276 -41
  58. package/api/theme-edit/_check.d.mts +93 -4
  59. package/api/theme-edit/_check.mjs +1712 -223
  60. package/api/theme-edit/_color.d.mts +2 -8
  61. package/api/theme-edit/_color.mjs +292 -219
  62. package/api/theme-edit/_compiler.d.mts +1 -0
  63. package/api/theme-edit/_compiler.mjs +20 -1
  64. package/api/theme-edit/_context.d.mts +31 -1
  65. package/api/theme-edit/_context.mjs +445 -41
  66. package/api/theme-edit/_css.d.mts +60 -1
  67. package/api/theme-edit/_css.mjs +404 -28
  68. package/api/theme-edit/_edit.d.mts +25 -0
  69. package/api/theme-edit/_edit.mjs +1620 -154
  70. package/api/theme-edit/_how-commands.d.mts +11 -26
  71. package/api/theme-edit/_how-commands.mjs +30 -2
  72. package/api/theme-edit/_how-question.d.mts +15 -0
  73. package/api/theme-edit/_how-question.mjs +1469 -194
  74. package/api/theme-edit/_how.mjs +144 -30
  75. package/api/theme-edit/_marks.d.mts +13 -0
  76. package/api/theme-edit/_marks.mjs +15 -0
  77. package/api/theme-edit/_overview.mjs +2 -0
  78. package/api/theme-edit/_palette.d.mts +38 -0
  79. package/api/theme-edit/_palette.mjs +306 -73
  80. package/api/theme-edit/_parts.d.mts +33 -0
  81. package/api/theme-edit/_parts.mjs +138 -9
  82. package/api/theme-edit/_png.d.mts +18 -0
  83. package/api/theme-edit/_png.mjs +95 -14
  84. package/api/theme-edit/_preview-app.d.mts +55 -1
  85. package/api/theme-edit/_preview-app.mjs +1552 -101
  86. package/api/theme-edit/_preview.d.mts +71 -3
  87. package/api/theme-edit/_preview.mjs +565 -35
  88. package/api/theme-edit/_project.d.mts +15 -0
  89. package/api/theme-edit/_project.mjs +68 -13
  90. package/api/theme-edit/_settings.d.mts +299 -5
  91. package/api/theme-edit/_settings.mjs +2806 -158
  92. package/api/theme-edit/_tables.d.mts +24 -0
  93. package/api/theme-edit/_tables.mjs +212 -150
  94. package/api/theme-edit/_vet.d.mts +42 -0
  95. package/api/theme-edit/_vet.mjs +144 -0
  96. package/api/theme-edit/theme-edit.type.d.mts +31 -2
  97. package/api/theme-edit/theme-edit.type.mjs +10 -2
  98. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  99. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  100. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  101. package/api/upgrade/registry/registry.mjs +6 -1
  102. package/assets/codemods/parse.mjs +2 -2
  103. package/assets/docs/author-a-theme.doc.mjs +1 -1
  104. package/assets/docs/theme.doc.dense.mjs +1 -1
  105. package/assets/docs/theme.doc.mjs +1 -1
  106. package/assets/docs/theme.doc.zh.mjs +4 -3
  107. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  108. package/assets/docs/tree/icon-sets.doc.mjs +63 -8
  109. package/assets/docs/tree/single-component.doc.mjs +11 -2
  110. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  111. package/assets/docs.generated.json +2 -2
  112. package/assets/preview-app/next.config.mjs +7 -1
  113. package/assets/preview-app/package.json +1 -0
  114. package/assets/preview-app/src/app/globals.css +1 -0
  115. package/assets/self-audit.generated.json +1 -1
  116. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
  117. package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
  118. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  119. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  120. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  121. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  122. package/assets/templates/components.generated.json +1 -1
  123. package/assets/templates/pages/ai-chat/page.tsx +20 -2
  124. package/assets/templates/pages/dashboard/page.tsx +1 -1
  125. package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
  126. package/authoring/config/config.doc.mjs +8 -0
  127. package/authoring/config/parse.d.mts +1 -0
  128. package/authoring/config/parse.mjs +12 -0
  129. package/authoring/config/type.ts +8 -0
  130. package/authoring/doctypes/_schema.d.mts +52 -5
  131. package/authoring/doctypes/_schema.mjs +62 -7
  132. package/authoring/doctypes/base/type.ts +10 -0
  133. package/authoring/doctypes/component/component.doc.mjs +1 -1
  134. package/authoring/doctypes/function/function.doc.mjs +6 -0
  135. package/authoring/doctypes/function/type.ts +3 -0
  136. package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
  137. package/authoring/doctypes/legacy.mjs +5 -1
  138. package/authoring/index.d.ts +1 -0
  139. package/authoring/shadcn/source-variants.d.mts +1 -1
  140. package/authoring/shadcn/source-variants.mjs +32 -10
  141. package/clients/cli/build-id.generated.json +1 -1
  142. package/clients/cli/commands/doctor.doc.mjs +2 -2
  143. package/clients/cli/commands/experimental/icon.mjs +61 -6
  144. package/clients/cli/commands/experimental/theme.mjs +244 -45
  145. package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
  146. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  147. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  148. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  149. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  150. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  151. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  152. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  153. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  154. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  155. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  156. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  157. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  158. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  159. package/clients/cli/commands/theme.doc.mjs +7 -2
  160. package/clients/cli/commands/theme.mjs +222 -55
  161. package/clients/cli/commands.generated.json +1 -1
  162. package/clients/cli/formatters/index.mjs +7 -4
  163. package/clients/cli/index.mjs +25 -5
  164. package/clients/cli/lib/cli-error.mjs +9 -3
  165. package/clients/cli/lib/component-format.mjs +27 -9
  166. package/clients/cli/lib/json-shim.mjs +72 -2
  167. package/clients/cli/manifest.generated.json +1 -1
  168. package/clients/cli/run.mjs +49 -0
  169. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  170. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  171. package/foundation/agent-docs/agent-docs.mjs +4 -3
  172. package/foundation/config/config-writer.d.mts +23 -0
  173. package/foundation/config/config-writer.mjs +152 -58
  174. package/foundation/config/project.mjs +103 -16
  175. package/foundation/discovery/component-discovery.mjs +11 -22
  176. package/foundation/discovery/icon-set-checks.mjs +164 -48
  177. package/foundation/discovery/icon-set-discovery.d.mts +38 -5
  178. package/foundation/discovery/icon-set-discovery.mjs +50 -6
  179. package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
  180. package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
  181. package/foundation/discovery/icon-set-writer.d.mts +2 -3
  182. package/foundation/discovery/icon-set-writer.mjs +58 -17
  183. package/foundation/discovery/module-exports.mjs +1 -15
  184. package/foundation/discovery/template-adapter.mjs +44 -19
  185. package/foundation/discovery/template-icons.d.mts +27 -10
  186. package/foundation/discovery/template-icons.mjs +142 -26
  187. package/foundation/discovery/template-source-tree.mjs +3 -16
  188. package/foundation/discovery/theme-discovery.d.mts +30 -1
  189. package/foundation/discovery/theme-discovery.mjs +109 -50
  190. package/foundation/fs/exact-codec.d.mts +35 -0
  191. package/foundation/fs/exact-codec.mjs +148 -0
  192. package/foundation/fs/gather-cache.d.mts +15 -5
  193. package/foundation/fs/gather-cache.mjs +129 -31
  194. package/foundation/fs/paths.d.mts +39 -0
  195. package/foundation/fs/paths.mjs +44 -11
  196. package/foundation/fs/read-record.mjs +11 -1
  197. package/foundation/integrations/autolink.d.mts +4 -2
  198. package/foundation/integrations/autolink.mjs +4 -2
  199. package/foundation/integrations/cli-requirement.d.mts +16 -5
  200. package/foundation/integrations/cli-requirement.mjs +27 -6
  201. package/foundation/integrations/contribution-fixes.mjs +1 -16
  202. package/foundation/integrations/may-have-integrations.mjs +7 -3
  203. package/foundation/integrations/missing-dependency.d.mts +9 -0
  204. package/foundation/integrations/missing-dependency.mjs +100 -0
  205. package/foundation/integrations/public-imports.mjs +1 -1
  206. package/foundation/render/embedded-imports.mjs +1 -1
  207. package/foundation/render/host-exit.d.mts +8 -0
  208. package/foundation/render/host-exit.mjs +11 -0
  209. package/foundation/render/page-host.mjs +56 -10
  210. package/foundation/render/page-worker.mjs +14 -0
  211. package/foundation/render/render-page.mjs +37 -2
  212. package/foundation/response/error-codes.d.mts +2 -1
  213. package/foundation/response/error-codes.d.ts +1 -0
  214. package/foundation/response/error-codes.doc.mjs +5 -0
  215. package/foundation/response/error-codes.mjs +3 -0
  216. package/foundation/response/json.d.mts +15 -0
  217. package/foundation/response/json.mjs +52 -1
  218. package/foundation/response/response-types.doc.mjs +1 -1
  219. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  220. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  221. package/foundation/xle/browser.d.mts +2 -2
  222. package/package.json +7 -6
@@ -32,6 +32,20 @@ export function openProject(cwd: string): Promise<ThemeProject>;
32
32
  * @returns {string | null}
33
33
  */
34
34
  export function importPathOf(project: ThemeProject, name: string): string | null;
35
+ /**
36
+ * The built module of a base's theme package, resolved the way the theme
37
+ * resolves it: from the project (an open project, or its folder, relative
38
+ * or not). Null when it is not installed there. The one base resolution:
39
+ * `new`, `set base`, `how` and every suggestion ask this.
40
+ *
41
+ * Only the packages the project installs count, as the app's bundler reads
42
+ * them: its node_modules folders, or Plug'n'Play. NODE_PATH and Node's global
43
+ * folders do not: a base found only there would not build.
44
+ * @param {ThemeProject | string} from
45
+ * @param {string} like
46
+ * @returns {string | null}
47
+ */
48
+ export function baseModule(from: ThemeProject | string, like: string): string | null;
35
49
  /**
36
50
  * The built-in theme package for a base, or a refusal naming its install line.
37
51
  * @param {ThemeProject} project
@@ -51,6 +65,7 @@ export function baseResolved(project: ThemeProject, like: string | undefined): P
51
65
  components: Record<string, any>;
52
66
  }>;
53
67
  export function literals(type: string): string[];
68
+ export function baseInstalled(from: ThemeProject | string, like: string): boolean;
54
69
  export type ThemeProject = {
55
70
  cwd: string;
56
71
  /**
@@ -21,7 +21,14 @@ import {loadComponentDoc} from '../../foundation/discovery/component-loader.mjs'
21
21
  import {collectThemingTargets} from '../../foundation/discovery/theming-targets.mjs';
22
22
  import {resolveImportPath} from '../../foundation/discovery/component-discovery.mjs';
23
23
  import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
24
- import {findProjectCoreDir} from '../../foundation/fs/paths.mjs';
24
+ import {
25
+ findInstalledPackage,
26
+ findProjectCoreDir,
27
+ } from '../../foundation/fs/paths.mjs';
28
+ import {
29
+ oncePerListing,
30
+ withListingCache,
31
+ } from '../../foundation/fs/listing-cache.mjs';
25
32
 
26
33
  /**
27
34
  * @typedef {object} ThemeProject
@@ -278,11 +285,13 @@ export async function openProject(cwd) {
278
285
  // Not cached yet.
279
286
  }
280
287
  if (!docs) {
281
- docs = {
288
+ // Each component's import path walks Core's source tree. One listing
289
+ // cache reads each folder once for all of them.
290
+ docs = await withListingCache(async () => ({
282
291
  version: DOCS_VERSION,
283
292
  targets: await collectThemingTargets(path.join(coreDir, 'src')),
284
293
  components: await readComponents(coreDir),
285
- };
294
+ }));
286
295
  try {
287
296
  fs.mkdirSync(cacheDir, {recursive: true});
288
297
  fs.writeFileSync(docsFile, JSON.stringify(docs));
@@ -317,10 +326,58 @@ export async function openProject(cwd) {
317
326
  export function importPathOf(project, name) {
318
327
  const spec =
319
328
  project.components[name]?.importPath ??
320
- resolveImportPath(project.coreDir, name);
329
+ oncePerListing(`importPath ${project.coreDir} ${name}`, () =>
330
+ resolveImportPath(project.coreDir, name),
331
+ );
321
332
  return spec && spec !== '@astryxdesign/core' ? spec : null;
322
333
  }
323
334
 
335
+ /**
336
+ * The built module of a base's theme package, resolved the way the theme
337
+ * resolves it: from the project (an open project, or its folder, relative
338
+ * or not). Null when it is not installed there. The one base resolution:
339
+ * `new`, `set base`, `how` and every suggestion ask this.
340
+ *
341
+ * Only the packages the project installs count, as the app's bundler reads
342
+ * them: its node_modules folders, or Plug'n'Play. NODE_PATH and Node's global
343
+ * folders do not: a base found only there would not build.
344
+ * @param {ThemeProject | string} from
345
+ * @param {string} like
346
+ * @returns {string | null}
347
+ */
348
+ export function baseModule(from, like) {
349
+ const name = `@astryxdesign/theme-${like}`;
350
+ const start = typeof from === 'string' ? path.resolve(from) : from.cwd;
351
+ const pkg = findInstalledPackage(start, name, Infinity);
352
+ return pkg == null ? null : builtModule(pkg, name);
353
+ }
354
+
355
+ /**
356
+ * The `built` export of the package in `pkg`, or null. A file Node finds
357
+ * anywhere else (it searches NODE_PATH after a miss) does not count.
358
+ * @param {string} pkg
359
+ * @param {string} name
360
+ * @returns {string | null}
361
+ */
362
+ function builtModule(pkg, name) {
363
+ try {
364
+ const file = createRequire(path.join(pkg, 'package.json')).resolve(
365
+ `${name}/built`,
366
+ );
367
+ const root = fs.realpathSync(pkg) + path.sep;
368
+ return fs.realpathSync(file).startsWith(root) ? file : null;
369
+ } catch {
370
+ return null;
371
+ }
372
+ }
373
+
374
+ /**
375
+ * Whether a base's theme package is installed in the project.
376
+ * @param {ThemeProject | string} from
377
+ * @param {string} like
378
+ */
379
+ export const baseInstalled = (from, like) => baseModule(from, like) != null;
380
+
324
381
  /**
325
382
  * The built-in theme package for a base, or a refusal naming its install line.
326
383
  * @param {ThemeProject} project
@@ -329,15 +386,13 @@ export function importPathOf(project, name) {
329
386
  */
330
387
  export function baseThemeFile(project, like) {
331
388
  const pkg = `@astryxdesign/theme-${like}`;
332
- try {
333
- return project.req.resolve(`${pkg}/built`);
334
- } catch {
335
- throw new AstryxError(
336
- `The ${like} theme is not installed, so a theme cannot build on it. Install ${pkg}, or build on no theme. Nothing was changed.`,
337
- [{name: installLine(project.cwd, [pkg]), reason: 'install it'}],
338
- ERROR_CODES.ERR_UNKNOWN_THEME,
339
- );
340
- }
389
+ const file = baseModule(project, like);
390
+ if (file) return file;
391
+ throw new AstryxError(
392
+ `The ${like} theme is not installed, so a theme cannot build on it. Install ${pkg}, or build on no theme. Nothing was changed.`,
393
+ [{name: installLine(project.cwd, [pkg]), reason: 'install it'}],
394
+ ERROR_CODES.ERR_UNKNOWN_THEME,
395
+ );
341
396
  }
342
397
 
343
398
  /**
@@ -18,8 +18,87 @@ export function themeFiles(cwd: string, slug: string): {
18
18
  preview: string;
19
19
  sheet: string;
20
20
  previewPng: string;
21
+ pictures: string;
21
22
  sheetPng: string;
22
23
  };
24
+ /**
25
+ * Whether `dir` holds nothing of anyone's: absent, empty, or only system
26
+ * files (what `git rm -r` or a branch switch leaves). A path that is not a
27
+ * folder, or one that does not read, is not empty.
28
+ * @param {string} dir
29
+ */
30
+ export function folderIsEmpty(dir: string): boolean;
31
+ /**
32
+ * Whether a value fits what a dial takes, read from the dial's own list of
33
+ * values: a named rung in any case, or a value of the kind it names (a size,
34
+ * a color, a number). `set` still checks the value in full.
35
+ * @param {string} dial
36
+ * @param {string} value
37
+ */
38
+ export function dialValueFits(dial: string, value: string): boolean;
39
+ /**
40
+ * Record files the editor just wrote into a theme folder.
41
+ * @param {string} cwd
42
+ * @param {string} slug
43
+ * @param {string[]} files
44
+ */
45
+ export function recordWritten(cwd: string, slug: string, files: string[]): void;
46
+ /**
47
+ * Whether the editor wrote this file in the theme folder and it is
48
+ * unchanged since.
49
+ * @param {string} cwd
50
+ * @param {string} slug
51
+ * @param {string} file
52
+ */
53
+ export function editorWrote(cwd: string, slug: string, file: string): boolean;
54
+ /**
55
+ * Adopt a picture an older editor took (before it recorded or stamped its
56
+ * pictures) into the record: only while the theme has no record at all, the
57
+ * name is one the editor writes, and the picture is the editor's 1280-pixel
58
+ * wide window. Returns whether it was adopted.
59
+ * @param {string} cwd
60
+ * @param {string} slug
61
+ * @param {string} file
62
+ */
63
+ export function adoptOlderPicture(cwd: string, slug: string, file: string): boolean;
64
+ /**
65
+ * A name `new` takes, for a suggestion: `name` itself when it is valid, not a
66
+ * built-in theme and its folder is free; `my-<name>` for a built-in theme's
67
+ * name; else the first free numbered name.
68
+ * @param {string} cwd
69
+ * @param {string} name
70
+ */
71
+ export function usableNewName(cwd: string, name: string): string;
72
+ /**
73
+ * A theme name near `name` that is valid and whose folder is free: `name-2`,
74
+ * `name-3`, …, shortened to fit the name's length limit.
75
+ * @param {string} cwd
76
+ * @param {string} name
77
+ */
78
+ export function freeThemeName(cwd: string, name: string): string;
79
+ /**
80
+ * Why the editor cannot read one of its files, or null when it can (or the
81
+ * file is not there): a folder in the file's place, or no permission to read
82
+ * it. Bad content is a different problem, judged where the file is parsed.
83
+ * @param {string} file
84
+ * @returns {string | null}
85
+ */
86
+ export function unreadableReason(file: string): string | null;
87
+ /**
88
+ * Refuse, by name, when a file of the theme is a folder or cannot be read:
89
+ * every command reads them, and none should crash on one. The fix is to
90
+ * look at the file and give it back its place; a file is never deleted.
91
+ * @param {string} cwd
92
+ * @param {string} slug
93
+ */
94
+ export function refuseUnreadableFiles(cwd: string, slug: string): void;
95
+ /**
96
+ * Refuse when the app's themes/ is a file or a link to something other
97
+ * than a folder: every editor theme lives in themes/<name>/. The run lists
98
+ * what is there; the message says to rename or move it.
99
+ * @param {string} cwd
100
+ */
101
+ export function refuseThemesNotFolder(cwd: string): void;
23
102
  /**
24
103
  * The themes the editor made in the app (a settings file of its own), by
25
104
  * name, or with `changed` the one an editor command changed last first: the
@@ -51,6 +130,23 @@ export function refuse(code: string, message: string, extra?: {
51
130
  fix?: string;
52
131
  also?: string[];
53
132
  }): never;
133
+ /**
134
+ * A theme name without a pasted label: `theme: t`, `name=t`, `--theme t`
135
+ * and `slug: "t"` name t; quotes and backticks around it go. Case is kept.
136
+ * A space is no label separator without dashes: "Theme Park" stays.
137
+ * The one reader of such labels, for --theme and every editor command.
138
+ * @param {unknown} s
139
+ * @returns {string}
140
+ */
141
+ export function unlabeledThemeName(s: unknown): string;
142
+ /**
143
+ * A theme name as typed, read the way the editor reads it: a path to its
144
+ * folder or a file in it (t.theme.ts, Brand.settings.json), in any case,
145
+ * or a pasted label (`theme: t`, `name: t`), names the theme. The result may still need slugFor.
146
+ * @param {unknown} s
147
+ * @returns {string}
148
+ */
149
+ export function typedThemeName(s: unknown): string;
54
150
  /**
55
151
  * The settings of a theme, or a refusal naming the command that makes it.
56
152
  * @param {string} cwd
@@ -106,6 +202,66 @@ export function withoutBadValues(data: ThemeData): {
106
202
  * @returns {string | null}
107
203
  */
108
204
  export function valueProblem(s: any): string | null;
205
+ /**
206
+ * The tokens a base theme's own component rules for a part read through
207
+ * var() (neutral's progress-bar reads --color-border-emphasized), from its
208
+ * built module; an empty set when it is not installed.
209
+ * @param {string} cwd
210
+ * @param {string | null | undefined} like
211
+ * @param {string} target
212
+ * @returns {Set<string>}
213
+ */
214
+ export function baseComponentReads(cwd: string, like: string | null | undefined, target: string): Set<string>;
215
+ /**
216
+ * The top-level tokens a base theme's built module gives (what the
217
+ * editor's settings extend), or an empty map when it is not installed.
218
+ * @param {string} cwd
219
+ * @param {string | null | undefined} like
220
+ * @returns {Map<string, string | null>}
221
+ */
222
+ export function baseTopTokens(cwd: string, like: string | null | undefined): Map<string, string | null>;
223
+ /**
224
+ * What a part's plain rule (its `base` block) holds in the theme as built
225
+ * (the base theme's, the settings' and the own source's together), else in
226
+ * the base theme alone when there is no build: tokens and properties by
227
+ * name. Kebab-case property names, as the editor names them.
228
+ * @param {string} cwd
229
+ * @param {string} slug
230
+ * @param {string | null | undefined} like
231
+ * @param {string} part
232
+ * @returns {Map<string, string | null>}
233
+ */
234
+ export function partRuleTokens(cwd: string, slug: string, like: string | null | undefined, part: string): Map<string, string | null>;
235
+ /**
236
+ * The tokens and properties a theme's own source sets on a part's plain
237
+ * rule, read from the build as ownTokens reads page-wide ones: what the
238
+ * built rule holds that the settings module and the base theme do not give
239
+ * as they are, and that the person's files name.
240
+ * @param {string} cwd
241
+ * @param {string} slug
242
+ * @param {string} part
243
+ * @param {string} [scope] the rule: `base` (the plain one), or a variant
244
+ * such as `variant:primary`
245
+ * @param {string | null} [state] a state block inside that rule (`:hover`)
246
+ * @returns {Map<string, string | null>}
247
+ */
248
+ export function ownPartTokens(cwd: string, slug: string, part: string, scope?: string, state?: string | null): Map<string, string | null>;
249
+ /**
250
+ * The page-wide tokens a theme's own source sets itself (see ownTokens):
251
+ * they win over the settings it extends.
252
+ * @param {string} cwd
253
+ * @param {string} slug
254
+ * @returns {string[]}
255
+ */
256
+ export function ownSourceTokens(cwd: string, slug: string): string[];
257
+ /**
258
+ * The values a theme's own source gives page-wide tokens as plain text, by
259
+ * token (see ownTokens).
260
+ * @param {string} cwd
261
+ * @param {string} slug
262
+ * @returns {Record<string, string>}
263
+ */
264
+ export function ownSourceTokenValues(cwd: string, slug: string): Record<string, string>;
109
265
  /** One line for a setting. @param {Setting} s */
110
266
  export function describe(s: Setting): string;
111
267
  /**
@@ -134,6 +290,14 @@ export function fontOf(value: string): {
134
290
  fallbacks: string;
135
291
  pkg: string | null;
136
292
  };
293
+ /**
294
+ * Spacing in a font family name as CSS reads a bare name: every Unicode
295
+ * space (a no-break space, a thin space, a tab) is one space, a run of them
296
+ * one, and zero-width and format characters (zero-width space, joiners,
297
+ * word joiner, byte-order mark) are dropped.
298
+ * @param {string} v
299
+ */
300
+ export function familySpaces(v: string): string;
137
301
  /**
138
302
  * A font family name as CSS reads it. A name that is a sequence of CSS
139
303
  * identifiers stays bare; any other is quoted, or the browser drops the
@@ -144,6 +308,21 @@ export function fontOf(value: string): {
144
308
  * @param {boolean} [spaced]
145
309
  */
146
310
  export function cssFamily(name: string, spaced?: boolean): string;
311
+ /**
312
+ * The staleness reason for an own source changed since the editor's build.
313
+ * @param {string} slug
314
+ */
315
+ export function sourceChangedReason(slug: string): string;
316
+ /**
317
+ * Record in an editor theme's generated settings that they were built with
318
+ * its own source as it is now, after `compile` built that source (the
319
+ * settings do not depend on what the source sets), only in a module as the
320
+ * editor wrote it.
321
+ * @param {string} cwd
322
+ * @param {string} slug
323
+ * @returns {boolean} whether it was recorded
324
+ */
325
+ export function refreshSourceStamp(cwd: string, slug: string): boolean;
147
326
  /**
148
327
  * Whether a generated module is as the editor wrote it: true, false for a
149
328
  * hand edit, null for a module with no hash (an earlier editor's).
@@ -163,6 +342,18 @@ export function stopsIn(source: string): Record<string, Record<"light" | "dark",
163
342
  stop: number;
164
343
  alpha?: string;
165
344
  }>>;
345
+ /**
346
+ * Control heights scaled with the spacing dial (a denser theme has shorter
347
+ * controls), each kept distinct and in order: smallest to largest, a
348
+ * control never under 24px (the smallest target a pointer can use
349
+ * comfortably, unless the theme starts below it), each the plain scaled
350
+ * value unless it would meet the one below, which then keeps its own step
351
+ * scaled above it.
352
+ * @param {Array<[string, string]>} sizes token name and the theme's value
353
+ * @param {number} f the spacing rung's factor
354
+ * @returns {Array<[string, string]>} the tokens it writes, in px
355
+ */
356
+ export function controlSizes(sizes: Array<[string, string]>, f: number): Array<[string, string]>;
166
357
  /**
167
358
  * The settings, as a `defineTheme` object.
168
359
  * @param {Ctx} ctx
@@ -178,9 +369,10 @@ export function compileTheme(ctx: Ctx, data: ThemeData, base: {
178
369
  * Settings whose effect a later or stronger setting hides, with why: `type`
179
370
  * loses heading weight and tracking to `headings`.
180
371
  * @param {ThemeData} data
372
+ * @param {Ctx | null} [ctx] with it, a later setting that reaches the parts through a spread counts too
181
373
  * @returns {Map<Setting, string>}
182
374
  */
183
- export function maskedSettings(data: ThemeData): Map<Setting, string>;
375
+ export function maskedSettings(data: ThemeData, ctx?: Ctx | null): Map<Setting, string>;
184
376
  /**
185
377
  * A plain part setting can lose to a more specific rule for the same part
186
378
  * and property, such as a base theme's `.astryx-heading[data-level="1"]
@@ -204,6 +396,22 @@ export function findOverrides(cssText: string, theme: any): Array<{
204
396
  * @returns {string | null}
205
397
  */
206
398
  export function themeSourceProblem(cwd: string, slug: string): string | null;
399
+ /**
400
+ * Why the person's own theme source does not parse (its line and the
401
+ * parser's message), or null when it parses or is not there.
402
+ * @param {string} cwd
403
+ * @param {string} slug
404
+ * @returns {string | null}
405
+ */
406
+ export function themeSourceParseError(cwd: string, slug: string): string | null;
407
+ /**
408
+ * Refuse, before anything is written or removed, a command whose build
409
+ * would load the person's own theme source when it does not parse: the
410
+ * build would fail part way.
411
+ * @param {string} cwd
412
+ * @param {string} slug
413
+ */
414
+ export function refuseThemeParse(cwd: string, slug: string): void;
207
415
  /**
208
416
  * Refuse a build whose theme source cannot carry the settings, naming the
209
417
  * lines that put it back.
@@ -211,6 +419,34 @@ export function themeSourceProblem(cwd: string, slug: string): string | null;
211
419
  * @param {string} slug
212
420
  */
213
421
  export function refuseThemeSource(cwd: string, slug: string): void;
422
+ /**
423
+ * The tokens that are not colors the theme as it builds now gives a
424
+ * [light, dark] pair (light-dark()), however its file writes them (a
425
+ * constant, `as const`, `satisfies`, a spread from an imported module):
426
+ * read from a build made into the project's cache folder, never beside the
427
+ * theme. Empty when it does not build there (the build names that itself).
428
+ * @param {Ctx} ctx
429
+ * @param {string} slug
430
+ * @returns {Promise<string[]>}
431
+ */
432
+ export function builtPairs(ctx: Ctx, slug: string): Promise<string[]>;
433
+ /**
434
+ * The refusal of a [light, dark] pair on tokens that are not colors.
435
+ * @param {string} slug
436
+ * @param {string[]} names
437
+ */
438
+ export function ownPairMessage(slug: string, names: string[]): string;
439
+ /**
440
+ * Set what runs after every build of a theme.
441
+ * @param {((ctx: Ctx, slug: string, data: ThemeData) => void) | null} fn
442
+ */
443
+ export function setAfterBuild(fn: ((ctx: Ctx, slug: string, data: ThemeData) => void) | null): void;
444
+ /**
445
+ * Hold the after-build hook for this command's builds: the command writes
446
+ * the app copy itself once it succeeds (show).
447
+ * @param {Ctx} ctx
448
+ */
449
+ export function holdAfterBuild(ctx: Ctx): void;
214
450
  /**
215
451
  * Generate the theme source, build it with the theme build, then repeat any
216
452
  * part setting a more specific rule would beat and build again.
@@ -224,6 +460,15 @@ export function buildTheme(ctx: Ctx, slug: string, data: ThemeData): Promise<{
224
460
  lifted: string[];
225
461
  notes: string[];
226
462
  }>;
463
+ /**
464
+ * Why the built outputs differ from what the theme builds now: one that is
465
+ * missing or changed by hand, found the way `compile --check` finds it
466
+ * (the same build, compared and not written), or null when they match.
467
+ * @param {Ctx} ctx
468
+ * @param {string} slug
469
+ * @returns {Promise<string | null>}
470
+ */
471
+ export function outputsDrift(ctx: Ctx, slug: string): Promise<string | null>;
227
472
  /**
228
473
  * Resolved tokens of the built theme in both modes.
229
474
  * @param {Ctx} ctx
@@ -299,12 +544,38 @@ export function radiusTokenOf(ctx: Ctx, part: string, when?: string): string;
299
544
  export function clearNewMarker(dir: string): void;
300
545
  /**
301
546
  * The pseudo key a state writes in a part's styles. Core marks a disabled
302
- * button, link, tab or menu item with aria-disabled (it stays focusable),
303
- * and its own styles match both forms: so does the theme.
547
+ * button, link or tab with aria-disabled (it stays focusable). A form
548
+ * control styled on a wrapper (a typeahead, a complex selector) has its
549
+ * input or button inside marked, so it also matches a disabled form
550
+ * control inside it (never a list row); an action part that holds
551
+ * children (a button group, a segmented control) never does, so one
552
+ * disabled child never makes the whole part look disabled.
304
553
  * @param {string} state
554
+ * @param {boolean} [wrapsControl]
305
555
  * @returns {string}
306
556
  */
307
- export function stateKey(state: string): string;
557
+ export function stateKey(state: string, wrapsControl?: boolean): string;
558
+ /**
559
+ * The component docs of a part: its own component's, and the one named like
560
+ * the part (tab is Tab, under TabList), each with its name, for the ones the
561
+ * project has.
562
+ * @param {Ctx} ctx
563
+ * @param {string} part
564
+ * @returns {Array<{name: string, doc: any}>}
565
+ */
566
+ export function partComponentDocs(ctx: Ctx, part: string): Array<{
567
+ name: string;
568
+ doc: any;
569
+ }>;
570
+ /**
571
+ * Whether a part's styled element wraps one control: its component (or the
572
+ * one named like the part) is a form control (Core's own category) that
573
+ * takes a disabled prop. An action part that holds children (a button
574
+ * group) never does.
575
+ * @param {Ctx} ctx
576
+ * @param {string} target
577
+ */
578
+ export function wrapsOneControl(ctx: Ctx, target: string): boolean;
308
579
  /**
309
580
  * The whole-theme radius tokens a generated settings module writes, or null
310
581
  * when it writes none.
@@ -358,6 +629,18 @@ export function settingsStamp(data: ThemeData): string;
358
629
  * @returns {string | null}
359
630
  */
360
631
  export function staleBuild(cwd: string, slug: string, data: ThemeData): string | null;
632
+ /**
633
+ * Every file the editor's build of a theme writes, the one list staleness
634
+ * reads: the generated settings module, the built stylesheet, module and
635
+ * their types, and, with a color dial set, the generated color files.
636
+ * @param {string} cwd
637
+ * @param {string} slug
638
+ * @param {ThemeData} data
639
+ * @param {boolean} [some] the files a build writes only for some themes
640
+ * (the variants types, for a theme with component variants) instead
641
+ * @returns {string[]}
642
+ */
643
+ export function builtFiles(cwd: string, slug: string, data: ThemeData, some?: boolean): string[];
361
644
  /**
362
645
  * A theme's undo history: the settings text before each change, oldest
363
646
  * first, and how many damaged steps were dropped. Every step after the
@@ -400,7 +683,7 @@ export function fontPackages(ctx: Ctx, data: ThemeData): {
400
683
  installed: boolean;
401
684
  of: Setting;
402
685
  }[];
403
- /** @typedef {{project: import('./_project.mjs').ThemeProject, C: import('./_compiler.mjs').Compiler, unchecked?: string | null, uncheckedCode?: string | null, wrote?: Map<string, string | null>, base?: {light: Record<string, string>, dark: Record<string, string>, components?: Record<string, any>}, keepStops?: Record<string, Record<'light' | 'dark', {family: string, stop: number, alpha?: string}>> | null, keepRadii?: Record<string, string> | null}} Ctx */
686
+ /** @typedef {{project: import('./_project.mjs').ThemeProject, C: import('./_compiler.mjs').Compiler, unchecked?: string | null, uncheckedCode?: string | null, wrote?: Map<string, string | null>, base?: {light: Record<string, string>, dark: Record<string, string>, components?: Record<string, any>}, keepStops?: Record<string, Record<'light' | 'dark', {family: string, stop: number, alpha?: string}>> | null, keepRadii?: Record<string, string> | null, derived?: Record<string, Array<{property: string, vars?: string[], replaces?: boolean, expand?: string}>>}} Ctx */
404
687
  /** @typedef {import('./_parts.mjs').PaintSide} PaintSide */
405
688
  /** @typedef {import('./_parts.mjs').TextPair} TextPair */
406
689
  /** What a theme name may be, in words. */
@@ -410,10 +693,14 @@ export function windowsReserved(s: string): boolean;
410
693
  export function slugFor(name: unknown): string;
411
694
  export function kebab(s: string): string;
412
695
  export function camel(s: string): string;
696
+ /** Files a system or a tool puts in any folder; a folder of only these is empty. */
697
+ export const FOLDER_JUNK: Set<string>;
413
698
  export function shown(cwd: string, f: string): string;
414
699
  export function keyOf(s: Setting): string;
415
700
  export function cornerPx(v: string): number;
416
701
  export function textPx(v: string): number;
702
+ /** The type tokens base themes set again for phones: families and weights. */
703
+ export const PHONE_TYPE: RegExp;
417
704
  export function themeSource(slug: string): string;
418
705
  /** The file a `new` keeps beside the files it writes until it is done. */
419
706
  export const NEW_MARKER: ".astryx-new.json";
@@ -423,6 +710,7 @@ export const NEW_MARKER: ".astryx-new.json";
423
710
  * leaves (a designer's `<slug>.design.psd` beside them is never touched).
424
711
  */
425
712
  export const EDITOR_SUFFIXES: string[];
713
+ export function isEditorFile(slug: string, n: string): boolean;
426
714
  /** The undo steps a theme keeps; older ones are dropped. */
427
715
  export const HISTORY_STEPS: 80;
428
716
  /**
@@ -489,6 +777,12 @@ export type Ctx = {
489
777
  alpha?: string;
490
778
  }>> | null;
491
779
  keepRadii?: Record<string, string> | null;
780
+ derived?: Record<string, Array<{
781
+ property: string;
782
+ vars?: string[];
783
+ replaces?: boolean;
784
+ expand?: string;
785
+ }>>;
492
786
  };
493
787
  export type PaintSide = import("./_parts.mjs").PaintSide;
494
788
  export type TextPair = import("./_parts.mjs").TextPair;