@astryxdesign/cli 0.7.15 → 0.7.16-canary.g3aa244b

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 (163) hide show
  1. package/README.md +5 -3
  2. package/api/build/_adapter.d.mts +1 -0
  3. package/api/build/blocks/blocks.d.mts +1 -0
  4. package/api/build/blocks/blocks.mjs +18 -1
  5. package/api/component/_adapter.d.mts +1 -1
  6. package/api/component/_adapter.mjs +28 -1
  7. package/api/doctor/_adapter.d.mts +35 -0
  8. package/api/doctor/_adapter.mjs +69 -0
  9. package/api/doctor/built-checks.mjs +1 -1
  10. package/api/doctor/doctor.d.mts +18 -0
  11. package/api/doctor/doctor.doc.mjs +1 -1
  12. package/api/doctor/doctor.mjs +104 -4
  13. package/api/doctor/theme-checks.mjs +6 -10
  14. package/api/integration/add-contribution.mjs +3 -3
  15. package/api/integration/pack-check.mjs +14 -8
  16. package/api/integration/validate-integration.mjs +1 -1
  17. package/api/search/_adapter.mjs +15 -16
  18. package/api/search/_entries.d.mts +2 -1
  19. package/api/search/_entries.mjs +28 -1
  20. package/api/swizzle/_moduleGraph.mjs +1 -1
  21. package/api/theme/_adapter.d.mts +5 -2
  22. package/api/theme/_adapter.mjs +43 -12
  23. package/api/theme/_fork.mjs +1 -1
  24. package/api/theme/build/build.d.mts +116 -32
  25. package/api/theme/build/build.mjs +449 -102
  26. package/api/theme/eject/eject.mjs +22 -1
  27. package/api/theme/template/template.d.mts +19 -0
  28. package/api/theme/template/template.mjs +102 -25
  29. package/api/theme/theme.type.d.mts +5 -1
  30. package/api/theme/theme.type.mjs +2 -1
  31. package/api/theme/themeBuild.doc.mjs +3 -3
  32. package/api/theme/themeEject.doc.mjs +1 -1
  33. package/api/theme/themeTemplate.doc.mjs +9 -3
  34. package/api/theme-edit/_adapter.d.mts +32 -2
  35. package/api/theme-edit/_adapter.mjs +264 -40
  36. package/api/theme-edit/_check.d.mts +93 -4
  37. package/api/theme-edit/_check.mjs +1727 -223
  38. package/api/theme-edit/_color.d.mts +2 -8
  39. package/api/theme-edit/_color.mjs +292 -219
  40. package/api/theme-edit/_compiler.d.mts +1 -0
  41. package/api/theme-edit/_compiler.mjs +20 -1
  42. package/api/theme-edit/_context.d.mts +31 -1
  43. package/api/theme-edit/_context.mjs +445 -41
  44. package/api/theme-edit/_css.d.mts +60 -1
  45. package/api/theme-edit/_css.mjs +404 -28
  46. package/api/theme-edit/_edit.d.mts +25 -0
  47. package/api/theme-edit/_edit.mjs +1532 -149
  48. package/api/theme-edit/_how-commands.d.mts +11 -26
  49. package/api/theme-edit/_how-commands.mjs +30 -2
  50. package/api/theme-edit/_how-question.d.mts +7 -0
  51. package/api/theme-edit/_how-question.mjs +1304 -176
  52. package/api/theme-edit/_how.mjs +144 -30
  53. package/api/theme-edit/_overview.mjs +2 -0
  54. package/api/theme-edit/_palette.d.mts +38 -0
  55. package/api/theme-edit/_palette.mjs +305 -71
  56. package/api/theme-edit/_parts.d.mts +33 -0
  57. package/api/theme-edit/_parts.mjs +138 -9
  58. package/api/theme-edit/_png.d.mts +18 -0
  59. package/api/theme-edit/_png.mjs +95 -14
  60. package/api/theme-edit/_preview-app.d.mts +36 -1
  61. package/api/theme-edit/_preview-app.mjs +1415 -96
  62. package/api/theme-edit/_preview.d.mts +64 -3
  63. package/api/theme-edit/_preview.mjs +514 -31
  64. package/api/theme-edit/_project.d.mts +11 -0
  65. package/api/theme-edit/_project.mjs +46 -12
  66. package/api/theme-edit/_settings.d.mts +278 -5
  67. package/api/theme-edit/_settings.mjs +2741 -195
  68. package/api/theme-edit/_tables.d.mts +24 -0
  69. package/api/theme-edit/_tables.mjs +211 -149
  70. package/api/theme-edit/_vet.d.mts +42 -0
  71. package/api/theme-edit/_vet.mjs +144 -0
  72. package/api/theme-edit/theme-edit.type.d.mts +20 -2
  73. package/api/theme-edit/theme-edit.type.mjs +6 -2
  74. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  75. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  76. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  77. package/api/upgrade/registry/registry.mjs +6 -1
  78. package/assets/codemods/parse.mjs +2 -2
  79. package/assets/docs/tree/single-component.doc.mjs +11 -2
  80. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  81. package/assets/docs.generated.json +2 -2
  82. package/assets/preview-app/next.config.mjs +7 -1
  83. package/assets/preview-app/package.json +1 -0
  84. package/assets/preview-app/src/app/globals.css +1 -0
  85. package/assets/self-audit.generated.json +1 -1
  86. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  87. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  88. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  89. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  90. package/assets/templates/components.generated.json +1 -1
  91. package/assets/templates/pages/dashboard/page.tsx +1 -1
  92. package/authoring/doctypes/_schema.d.mts +52 -5
  93. package/authoring/doctypes/_schema.mjs +62 -7
  94. package/authoring/doctypes/base/type.ts +10 -0
  95. package/authoring/doctypes/component/component.doc.mjs +1 -1
  96. package/authoring/doctypes/function/function.doc.mjs +6 -0
  97. package/authoring/doctypes/function/type.ts +3 -0
  98. package/authoring/doctypes/legacy.mjs +5 -1
  99. package/authoring/index.d.ts +1 -0
  100. package/authoring/shadcn/source-variants.d.mts +1 -1
  101. package/authoring/shadcn/source-variants.mjs +32 -10
  102. package/clients/cli/build-id.generated.json +1 -1
  103. package/clients/cli/commands/doctor.doc.mjs +2 -2
  104. package/clients/cli/commands/experimental/theme.mjs +239 -45
  105. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  106. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  108. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  109. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  110. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  111. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  112. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  113. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  114. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  115. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  116. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  117. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  118. package/clients/cli/commands/theme.mjs +190 -46
  119. package/clients/cli/formatters/index.mjs +7 -4
  120. package/clients/cli/lib/cli-error.mjs +9 -3
  121. package/clients/cli/lib/component-format.mjs +27 -9
  122. package/clients/cli/lib/json-shim.mjs +72 -2
  123. package/clients/cli/manifest.generated.json +1 -1
  124. package/clients/cli/run.mjs +49 -0
  125. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  126. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  127. package/foundation/agent-docs/agent-docs.mjs +3 -2
  128. package/foundation/config/config-writer.mjs +2 -2
  129. package/foundation/config/project.mjs +60 -14
  130. package/foundation/discovery/component-discovery.mjs +5 -17
  131. package/foundation/discovery/icon-set-writer.mjs +1 -1
  132. package/foundation/discovery/module-exports.mjs +1 -15
  133. package/foundation/discovery/template-adapter.mjs +44 -19
  134. package/foundation/discovery/template-source-tree.mjs +3 -16
  135. package/foundation/discovery/theme-discovery.d.mts +5 -1
  136. package/foundation/discovery/theme-discovery.mjs +61 -43
  137. package/foundation/fs/exact-codec.d.mts +35 -0
  138. package/foundation/fs/exact-codec.mjs +148 -0
  139. package/foundation/fs/gather-cache.d.mts +15 -5
  140. package/foundation/fs/gather-cache.mjs +129 -31
  141. package/foundation/fs/paths.d.mts +39 -0
  142. package/foundation/fs/paths.mjs +44 -11
  143. package/foundation/fs/read-record.mjs +11 -1
  144. package/foundation/integrations/contribution-fixes.mjs +1 -16
  145. package/foundation/integrations/may-have-integrations.mjs +3 -2
  146. package/foundation/integrations/public-imports.mjs +1 -1
  147. package/foundation/render/embedded-imports.mjs +1 -1
  148. package/foundation/render/host-exit.d.mts +8 -0
  149. package/foundation/render/host-exit.mjs +11 -0
  150. package/foundation/render/page-host.mjs +56 -10
  151. package/foundation/render/page-worker.mjs +14 -0
  152. package/foundation/render/render-page.mjs +37 -2
  153. package/foundation/response/error-codes.d.mts +2 -1
  154. package/foundation/response/error-codes.d.ts +1 -0
  155. package/foundation/response/error-codes.doc.mjs +5 -0
  156. package/foundation/response/error-codes.mjs +3 -0
  157. package/foundation/response/json.d.mts +15 -0
  158. package/foundation/response/json.mjs +52 -1
  159. package/foundation/response/response-types.doc.mjs +1 -1
  160. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  161. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  162. package/foundation/xle/browser.d.mts +2 -2
  163. package/package.json +7 -6
@@ -118,7 +118,7 @@ export function demoProps(project, name) {
118
118
  // A doc that declares no props of its own name is a family page,
119
119
  // not a component the Core exports.
120
120
  !Object.keys(info.props ?? {}).length ||
121
- (info.subComponentOf && isItemOf(project, name)))
121
+ needsParent(project, name))
122
122
  )
123
123
  return null;
124
124
  const props = given ?? {};
@@ -144,6 +144,22 @@ export function demoProps(project, name) {
144
144
  return props;
145
145
  }
146
146
 
147
+ /**
148
+ * Whether a part works only inside its parent: its parent lists it as an
149
+ * item, or it is a piece of its parent by name (TableBody of Table) and
150
+ * its doc gives no playground of its own.
151
+ * @param {import('./_project.mjs').ThemeProject} project
152
+ * @param {string} name
153
+ */
154
+ export function needsParent(project, name) {
155
+ const info = project.components[name];
156
+ const parent = info?.subComponentOf;
157
+ if (!parent) return false;
158
+ if (isItemOf(project, name)) return true;
159
+ const own = info.defaults && typeof info.defaults === 'object';
160
+ return !own && name.startsWith(parent) && name !== parent;
161
+ }
162
+
147
163
  /**
148
164
  * Whether a part's parent lists it as an item of its children.
149
165
  * @param {import('./_project.mjs').ThemeProject} project
@@ -172,14 +188,25 @@ export function isItemOf(project, name) {
172
188
  */
173
189
  export function catalogVariants(project, name, cap, opts = {}) {
174
190
  const info = project.components[name];
175
- const demo = demoProps(project, name);
176
- if (!demo) return [];
177
- if (info.opens && opts.shown)
178
- return [
179
- {label: '', props: 'isOpen' in demo ? demo : {...demo, isOpen: true}},
180
- ];
181
- const base =
182
- info.opens && !('isOpen' in demo) ? {...demo, isOpen: true} : demo;
191
+ const own = demoProps(project, name);
192
+ if (!own) return [];
193
+ // No demo takes focus as it mounts: on a page of many, each would pull
194
+ // the page to itself.
195
+ /** @type {Record<string, unknown>} */
196
+ const demo = {
197
+ ...own,
198
+ ...(info.props?.hasAutoFocus ? {hasAutoFocus: false} : {}),
199
+ ...(info.props?.autoFocus && own.autoFocus ? {autoFocus: false} : {}),
200
+ };
201
+ // An overlay shown open, named, as a dialog must be.
202
+ /** @param {Record<string, unknown>} d @returns {Record<string, unknown>} */
203
+ const opened = d => ({
204
+ ...d,
205
+ ...('isOpen' in d ? {} : {isOpen: true}),
206
+ ...(info.props?.label && d.label == null ? {label: `${name} example`} : {}),
207
+ });
208
+ if (info.opens && opts.shown) return [{label: '', props: opened(demo)}];
209
+ const base = info.opens ? opened(demo) : demo;
183
210
  const values = info.targets[0]?.values ?? {};
184
211
  const variants = [{label: '', props: base}];
185
212
  for (const p of ['variant', 'status', 'color'])
@@ -479,6 +506,108 @@ async function buildPartData(project) {
479
506
  };
480
507
  }
481
508
 
509
+ /**
510
+ * The value Core falls back to where its stylesheet reads a variable
511
+ * (`var(--astryx-card-padding, var(--spacing-4))` gives `var(--spacing-4)`),
512
+ * or null when it gives none.
513
+ * @param {any} project
514
+ * @param {string} name
515
+ * @returns {string | null}
516
+ */
517
+ export function coreFallback(project, name) {
518
+ /** @type {string} */
519
+ let css;
520
+ try {
521
+ css = fs.readFileSync(
522
+ project.req.resolve('@astryxdesign/core/astryx.css'),
523
+ 'utf8',
524
+ );
525
+ } catch {
526
+ return null;
527
+ }
528
+ const at = css.indexOf(`var(${name},`);
529
+ if (at < 0) return null;
530
+ let depth = 0;
531
+ const from = at + `var(${name},`.length;
532
+ for (let j = from; j < css.length; j++) {
533
+ if (css[j] === '(') depth++;
534
+ else if (css[j] === ')') {
535
+ if (depth === 0) return css.slice(from, j).trim();
536
+ depth--;
537
+ }
538
+ }
539
+ return null;
540
+ }
541
+
542
+ /** @type {Map<string, Set<string>>} */
543
+ const calcCache = new Map();
544
+
545
+ /**
546
+ * The variables Core's stylesheet reads inside a calc() (a composer's
547
+ * padding in its send button's radius): only one length works there.
548
+ * Empty with no stylesheet.
549
+ * @param {any} project
550
+ * @returns {Set<string>}
551
+ */
552
+ export function calcVars(project) {
553
+ /** @type {string} */
554
+ let file;
555
+ try {
556
+ file = project.req.resolve('@astryxdesign/core/astryx.css');
557
+ } catch {
558
+ return new Set();
559
+ }
560
+ const cached = calcCache.get(file);
561
+ if (cached) return cached;
562
+ const css = fs.readFileSync(file, 'utf8');
563
+ /** @type {Set<string>} */
564
+ const out = new Set();
565
+ for (let i = css.indexOf('calc('); i >= 0; i = css.indexOf('calc(', i + 5)) {
566
+ let depth = 0;
567
+ let j = i + 4;
568
+ for (; j < css.length; j++) {
569
+ if (css[j] === '(') depth++;
570
+ else if (css[j] === ')' && --depth === 0) break;
571
+ }
572
+ for (const m of css.slice(i, j).matchAll(/var\((--[a-z0-9_-]+)/gi))
573
+ out.add(m[1].toLowerCase());
574
+ }
575
+ calcCache.set(file, out);
576
+ return out;
577
+ }
578
+
579
+ /** @type {Map<string, Set<string>>} */
580
+ const multipliedCache = new Map();
581
+
582
+ /**
583
+ * The tokens Core's stylesheet multiplies by another value inside calc()
584
+ * (`var(--text-body-size) * var(--text-body-leading)`): a unit there makes
585
+ * the declaration invalid. Empty with no stylesheet.
586
+ * @param {any} project
587
+ * @returns {Set<string>}
588
+ */
589
+ export function multipliedTokens(project) {
590
+ /** @type {string} */
591
+ let file;
592
+ try {
593
+ file = project.req.resolve('@astryxdesign/core/astryx.css');
594
+ } catch {
595
+ return new Set();
596
+ }
597
+ const cached = multipliedCache.get(file);
598
+ if (cached) return cached;
599
+ const css = fs.readFileSync(file, 'utf8');
600
+ /** @type {Set<string>} */
601
+ const out = new Set();
602
+ // Each side of a `*` on its own, so `a * b * c` names all three.
603
+ for (const m of css.matchAll(/var\((--[a-z0-9-]+)\)(?=\s*\*)/gi))
604
+ out.add(m[1].toLowerCase());
605
+ for (const m of css.matchAll(/\*\s*var\((--[a-z0-9-]+)\)/gi))
606
+ out.add(m[1].toLowerCase());
607
+ multipliedCache.set(file, out);
608
+ return out;
609
+ }
610
+
482
611
  /**
483
612
  * Atomic class -> its declarations, with the condition (pseudo-class,
484
613
  * attribute) each one applies under.
@@ -38,6 +38,22 @@ export function mainColors(pic: Picture, count: number): Array<{
38
38
  share: number;
39
39
  where: string;
40
40
  }>;
41
+ /**
42
+ * The `tEXt` chunks of a PNG, keyword to text; empty for a file that is not
43
+ * a PNG or cannot be read whole.
44
+ * @param {Buffer} bytes
45
+ * @returns {Record<string, string>}
46
+ */
47
+ export function pngTexts(bytes: Buffer): Record<string, string>;
48
+ /**
49
+ * A PNG with a `tEXt` chunk added right after its header (any chunk with the
50
+ * same keyword replaced), or the bytes as they were when they are not a PNG.
51
+ * @param {Buffer} bytes
52
+ * @param {string} keyword
53
+ * @param {string} text
54
+ * @returns {Buffer}
55
+ */
56
+ export function withPngText(bytes: Buffer, keyword: string, text: string): Buffer;
41
57
  /**
42
58
  * The most pixels a picture may have: about a 6K screen. A bigger header is
43
59
  * refused before any memory is taken for it.
@@ -45,6 +61,8 @@ export function mainColors(pic: Picture, count: number): Array<{
45
61
  export const MAX_PIXELS: 40000000;
46
62
  /** A 16-bit picture takes twice the memory per pixel, so half as many. */
47
63
  export const MAX_PIXELS_16: 20000000;
64
+ /** The keyword of the text chunk the theme editor stamps its pictures with. */
65
+ export const EDITOR_STAMP: "astryx-theme-editor";
48
66
  export type Picture = {
49
67
  width: number;
50
68
  height: number;
@@ -9,6 +9,7 @@
9
9
  */
10
10
 
11
11
  import * as zlib from 'node:zlib';
12
+ import {wordTable} from './_tables.mjs';
12
13
 
13
14
  const SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
14
15
 
@@ -25,20 +26,24 @@ export const MAX_PIXELS_16 = 20_000_000;
25
26
  const SAMPLE_BUDGET = 4_000_000;
26
27
 
27
28
  /** The bit depths each PNG color type allows. */
28
- const DEPTHS = /** @type {Record<number, number[]>} */ ({
29
- 0: [1, 2, 4, 8, 16],
30
- 2: [8, 16],
31
- 3: [1, 2, 4, 8],
32
- 4: [8, 16],
33
- 6: [8, 16],
34
- });
35
- const CHANNELS = /** @type {Record<number, number>} */ ({
36
- 0: 1,
37
- 2: 3,
38
- 3: 1,
39
- 4: 2,
40
- 6: 4,
41
- });
29
+ const DEPTHS = wordTable(
30
+ /** @type {Record<number, number[]>} */ ({
31
+ 0: [1, 2, 4, 8, 16],
32
+ 2: [8, 16],
33
+ 3: [1, 2, 4, 8],
34
+ 4: [8, 16],
35
+ 6: [8, 16],
36
+ }),
37
+ );
38
+ const CHANNELS = wordTable(
39
+ /** @type {Record<number, number>} */ ({
40
+ 0: 1,
41
+ 2: 3,
42
+ 3: 1,
43
+ 4: 2,
44
+ 6: 4,
45
+ }),
46
+ );
42
47
 
43
48
  /** @typedef {{width: number, height: number, rgba: Uint8Array}} Picture */
44
49
 
@@ -297,3 +302,79 @@ export function mainColors(pic, count) {
297
302
  };
298
303
  });
299
304
  }
305
+
306
+ /** The keyword of the text chunk the theme editor stamps its pictures with. */
307
+ export const EDITOR_STAMP = 'astryx-theme-editor';
308
+
309
+ const PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
310
+
311
+ /**
312
+ * The `tEXt` chunks of a PNG, keyword to text; empty for a file that is not
313
+ * a PNG or cannot be read whole.
314
+ * @param {Buffer} bytes
315
+ * @returns {Record<string, string>}
316
+ */
317
+ export function pngTexts(bytes) {
318
+ /** @type {Record<string, string>} */
319
+ const out = {};
320
+ if (bytes.length < 8 || !bytes.subarray(0, 8).equals(PNG_SIGNATURE))
321
+ return out;
322
+ for (let at = 8; at + 8 <= bytes.length;) {
323
+ const len = bytes.readUInt32BE(at);
324
+ const type = bytes.toString('latin1', at + 4, at + 8);
325
+ const end = at + 12 + len;
326
+ if (end > bytes.length) break;
327
+ if (type === 'tEXt') {
328
+ const data = bytes.subarray(at + 8, at + 8 + len);
329
+ const nul = data.indexOf(0);
330
+ if (nul > 0)
331
+ out[data.toString('latin1', 0, nul)] = data.toString('latin1', nul + 1);
332
+ }
333
+ if (type === 'IEND') break;
334
+ at = end;
335
+ }
336
+ return out;
337
+ }
338
+
339
+ /**
340
+ * A PNG with a `tEXt` chunk added right after its header (any chunk with the
341
+ * same keyword replaced), or the bytes as they were when they are not a PNG.
342
+ * @param {Buffer} bytes
343
+ * @param {string} keyword
344
+ * @param {string} text
345
+ * @returns {Buffer}
346
+ */
347
+ export function withPngText(bytes, keyword, text) {
348
+ if (bytes.length < 33 || !bytes.subarray(0, 8).equals(PNG_SIGNATURE))
349
+ return bytes;
350
+ /** @type {Buffer[]} */
351
+ const chunks = [];
352
+ for (let at = 8; at + 8 <= bytes.length;) {
353
+ const len = bytes.readUInt32BE(at);
354
+ const type = bytes.toString('latin1', at + 4, at + 8);
355
+ const end = at + 12 + len;
356
+ if (end > bytes.length) return bytes;
357
+ const data = bytes.subarray(at + 8, at + 8 + len);
358
+ const same =
359
+ type === 'tEXt' &&
360
+ data.indexOf(0) > 0 &&
361
+ data.toString('latin1', 0, data.indexOf(0)) === keyword;
362
+ if (!same) chunks.push(bytes.subarray(at, end));
363
+ if (type === 'IHDR') {
364
+ const body = Buffer.concat([
365
+ Buffer.from('tEXt', 'latin1'),
366
+ Buffer.from(keyword, 'latin1'),
367
+ Buffer.from([0]),
368
+ Buffer.from(text, 'latin1'),
369
+ ]);
370
+ const head = Buffer.alloc(4);
371
+ head.writeUInt32BE(body.length - 4);
372
+ const crc = Buffer.alloc(4);
373
+ crc.writeUInt32BE(zlib.crc32(body) >>> 0);
374
+ chunks.push(Buffer.concat([head, body, crc]));
375
+ }
376
+ if (type === 'IEND') break;
377
+ at = end;
378
+ }
379
+ return Buffer.concat([PNG_SIGNATURE, ...chunks]);
380
+ }
@@ -1,12 +1,43 @@
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
+ * The steps that put an editor theme into the app through its app copy
6
+ * (src/themes/<theme>/): one `theme add`, which prints the one-time wiring
7
+ * of the app's theme module, and what keeps the copy in step. The one text
8
+ * every place that says how to use an editor theme gives.
9
+ * @param {string} cwd
10
+ * @param {string} slug
11
+ * @param {'light' | 'dark' | 'system'} [mode]
12
+ * @returns {string[]}
13
+ */
14
+ export function addWiring(cwd: string, slug: string, mode?: "light" | "dark" | "system"): string[];
15
+ /**
16
+ * How to use an editor theme in this app: `theme add <theme>` for the app
17
+ * copy the editor writes in src/themes/<theme>/; when a folder of the
18
+ * user's is there instead, step by step by hand: the file of the app's root
19
+ * (a Next app's root layout, else the file that renders the app), the
20
+ * imports the preview route uses for the same theme (its module, its
21
+ * stylesheet and the font stylesheets) and the Theme around the app. Then
22
+ * what builds it.
23
+ * @param {import('./_settings.mjs').Ctx} ctx
24
+ * @param {string} slug
25
+ * @param {import('./_settings.mjs').ThemeData} data
26
+ * @returns {string[]}
27
+ */
28
+ export function appWiring(ctx: import("./_settings.mjs").Ctx, slug: string, data: import("./_settings.mjs").ThemeData): string[];
4
29
  /**
5
30
  * For tests: stop the next preview changes at the step where `when`
6
31
  * returns true, as a kill would, with nothing put back. Null clears it.
7
32
  * @param {((step: string) => boolean) | null} when
8
33
  */
9
34
  export function stopPreviewCommitAt(when: ((step: string) => boolean) | null): void;
35
+ /**
36
+ * For tests: read at most `n` source files when checking for importers
37
+ * (null: the default).
38
+ * @param {number | null} n
39
+ */
40
+ export function setImporterScanMax(n: number | null): void;
10
41
  /**
11
42
  * Rewrite the in-app preview routes of a theme when their imports changed, so
12
43
  * a font package installed after `set` loads on the next change or `show`,
@@ -40,7 +71,8 @@ export function refreshPreviewRoute(cwd: string, slug: string): Promise<{
40
71
  export function themeEditPreviewAdd(description?: string, options?: import("./theme-edit.type.mjs").ThemeEditPreviewAddOptions): Promise<import("./theme-edit.type.mjs").ThemeEditPreviewAddResponse>;
41
72
  /**
42
73
  * Make a new starter app (Next.js app router, Core and the neutral theme,
43
- * with the Astryx packages pinned to this CLI's release) in `dir`, with the
74
+ * with the Astryx packages pinned to this CLI's release, or with `theme` to
75
+ * the versions the project has) in `dir`, with the
44
76
  * theme preview route and its default pages inside. With `theme`, the theme
45
77
  * folder is copied into the app and the pages wear it. No install runs.
46
78
  * Every check runs before the first write, so a refusal changes nothing.
@@ -84,6 +116,8 @@ export type PreviewPage = {
84
116
  file: string;
85
117
  };
86
118
  /**
119
+ * `parents`: how many folders over the preview folder its first add made,
120
+ * which remove takes away again when they are empty.
87
121
  * `hashes`: a short hash of each file as the preview wrote it, so a file
88
122
  * changed by hand is never replaced or deleted
89
123
  */
@@ -93,6 +127,7 @@ export type PreviewData = {
93
127
  pages: PreviewPage[];
94
128
  files: string[];
95
129
  hashes?: Record<string, string>;
130
+ parents?: number;
96
131
  };
97
132
  /**
98
133
  * the command again, with