@astryxdesign/cli 0.7.15 → 0.7.16-canary.g07c77c0

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 (159) 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 +17 -0
  8. package/api/doctor/_adapter.mjs +43 -0
  9. package/api/doctor/built-checks.mjs +1 -1
  10. package/api/doctor/doctor.mjs +18 -4
  11. package/api/doctor/theme-checks.mjs +1 -1
  12. package/api/integration/add-contribution.mjs +3 -3
  13. package/api/integration/pack-check.mjs +14 -8
  14. package/api/integration/validate-integration.mjs +1 -1
  15. package/api/search/_adapter.mjs +15 -16
  16. package/api/search/_entries.d.mts +2 -1
  17. package/api/search/_entries.mjs +28 -1
  18. package/api/swizzle/_moduleGraph.mjs +1 -1
  19. package/api/theme/_adapter.d.mts +5 -2
  20. package/api/theme/_adapter.mjs +43 -12
  21. package/api/theme/_fork.mjs +1 -1
  22. package/api/theme/build/build.d.mts +116 -32
  23. package/api/theme/build/build.mjs +449 -102
  24. package/api/theme/eject/eject.mjs +22 -1
  25. package/api/theme/template/template.d.mts +19 -0
  26. package/api/theme/template/template.mjs +102 -25
  27. package/api/theme/theme.type.d.mts +5 -1
  28. package/api/theme/theme.type.mjs +2 -1
  29. package/api/theme/themeBuild.doc.mjs +3 -3
  30. package/api/theme/themeEject.doc.mjs +1 -1
  31. package/api/theme/themeTemplate.doc.mjs +9 -3
  32. package/api/theme-edit/_adapter.d.mts +32 -2
  33. package/api/theme-edit/_adapter.mjs +213 -36
  34. package/api/theme-edit/_check.d.mts +69 -3
  35. package/api/theme-edit/_check.mjs +1517 -218
  36. package/api/theme-edit/_color.d.mts +2 -8
  37. package/api/theme-edit/_color.mjs +292 -219
  38. package/api/theme-edit/_compiler.d.mts +1 -0
  39. package/api/theme-edit/_compiler.mjs +20 -1
  40. package/api/theme-edit/_context.d.mts +29 -0
  41. package/api/theme-edit/_context.mjs +426 -40
  42. package/api/theme-edit/_css.d.mts +60 -1
  43. package/api/theme-edit/_css.mjs +404 -28
  44. package/api/theme-edit/_edit.d.mts +9 -0
  45. package/api/theme-edit/_edit.mjs +1300 -135
  46. package/api/theme-edit/_how-commands.d.mts +11 -26
  47. package/api/theme-edit/_how-commands.mjs +30 -2
  48. package/api/theme-edit/_how-question.d.mts +7 -0
  49. package/api/theme-edit/_how-question.mjs +1304 -176
  50. package/api/theme-edit/_how.mjs +144 -30
  51. package/api/theme-edit/_overview.mjs +2 -0
  52. package/api/theme-edit/_palette.d.mts +11 -0
  53. package/api/theme-edit/_palette.mjs +194 -65
  54. package/api/theme-edit/_parts.d.mts +33 -0
  55. package/api/theme-edit/_parts.mjs +138 -9
  56. package/api/theme-edit/_png.d.mts +18 -0
  57. package/api/theme-edit/_png.mjs +95 -14
  58. package/api/theme-edit/_preview-app.d.mts +9 -0
  59. package/api/theme-edit/_preview-app.mjs +1191 -71
  60. package/api/theme-edit/_preview.d.mts +16 -3
  61. package/api/theme-edit/_preview.mjs +335 -30
  62. package/api/theme-edit/_project.d.mts +11 -0
  63. package/api/theme-edit/_project.mjs +46 -12
  64. package/api/theme-edit/_settings.d.mts +240 -5
  65. package/api/theme-edit/_settings.mjs +2561 -115
  66. package/api/theme-edit/_tables.d.mts +24 -0
  67. package/api/theme-edit/_tables.mjs +211 -149
  68. package/api/theme-edit/_vet.d.mts +42 -0
  69. package/api/theme-edit/_vet.mjs +144 -0
  70. package/api/theme-edit/theme-edit.type.d.mts +2 -1
  71. package/api/theme-edit/theme-edit.type.mjs +1 -1
  72. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  73. package/api/theme-edit/themeEditShow.doc.mjs +11 -3
  74. package/api/upgrade/registry/registry.mjs +6 -1
  75. package/assets/codemods/parse.mjs +2 -2
  76. package/assets/docs/tree/single-component.doc.mjs +11 -2
  77. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  78. package/assets/docs.generated.json +2 -2
  79. package/assets/preview-app/next.config.mjs +7 -1
  80. package/assets/preview-app/package.json +1 -0
  81. package/assets/preview-app/src/app/globals.css +1 -0
  82. package/assets/self-audit.generated.json +1 -1
  83. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
  84. package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
  85. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
  86. package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
  87. package/assets/templates/components.generated.json +1 -1
  88. package/assets/templates/pages/dashboard/page.tsx +1 -1
  89. package/authoring/doctypes/_schema.d.mts +52 -5
  90. package/authoring/doctypes/_schema.mjs +62 -7
  91. package/authoring/doctypes/base/type.ts +10 -0
  92. package/authoring/doctypes/component/component.doc.mjs +1 -1
  93. package/authoring/doctypes/function/function.doc.mjs +6 -0
  94. package/authoring/doctypes/function/type.ts +3 -0
  95. package/authoring/doctypes/legacy.mjs +5 -1
  96. package/authoring/index.d.ts +1 -0
  97. package/authoring/shadcn/source-variants.d.mts +1 -1
  98. package/authoring/shadcn/source-variants.mjs +32 -10
  99. package/clients/cli/build-id.generated.json +1 -1
  100. package/clients/cli/commands/doctor.doc.mjs +2 -2
  101. package/clients/cli/commands/experimental/theme.mjs +237 -45
  102. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  103. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  104. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
  105. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
  106. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  108. package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
  109. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  110. package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
  111. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  112. package/clients/cli/commands/theme-eject.doc.mjs +1 -1
  113. package/clients/cli/commands/theme-template.doc.mjs +3 -1
  114. package/clients/cli/commands/theme.mjs +190 -46
  115. package/clients/cli/formatters/index.mjs +7 -4
  116. package/clients/cli/lib/cli-error.mjs +9 -3
  117. package/clients/cli/lib/component-format.mjs +27 -9
  118. package/clients/cli/lib/json-shim.mjs +72 -2
  119. package/clients/cli/manifest.generated.json +1 -1
  120. package/clients/cli/run.mjs +49 -0
  121. package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
  122. package/foundation/agent-docs/agent-docs-target.mjs +9 -17
  123. package/foundation/agent-docs/agent-docs.mjs +3 -2
  124. package/foundation/config/config-writer.mjs +2 -2
  125. package/foundation/config/project.mjs +60 -14
  126. package/foundation/discovery/component-discovery.mjs +5 -17
  127. package/foundation/discovery/icon-set-writer.mjs +1 -1
  128. package/foundation/discovery/module-exports.mjs +1 -15
  129. package/foundation/discovery/template-adapter.mjs +44 -19
  130. package/foundation/discovery/template-source-tree.mjs +3 -16
  131. package/foundation/discovery/theme-discovery.d.mts +5 -1
  132. package/foundation/discovery/theme-discovery.mjs +30 -35
  133. package/foundation/fs/exact-codec.d.mts +35 -0
  134. package/foundation/fs/exact-codec.mjs +148 -0
  135. package/foundation/fs/gather-cache.d.mts +15 -5
  136. package/foundation/fs/gather-cache.mjs +123 -30
  137. package/foundation/fs/paths.d.mts +39 -0
  138. package/foundation/fs/paths.mjs +44 -11
  139. package/foundation/fs/read-record.mjs +11 -1
  140. package/foundation/integrations/contribution-fixes.mjs +1 -16
  141. package/foundation/integrations/may-have-integrations.mjs +3 -2
  142. package/foundation/integrations/public-imports.mjs +1 -1
  143. package/foundation/render/embedded-imports.mjs +1 -1
  144. package/foundation/render/host-exit.d.mts +8 -0
  145. package/foundation/render/host-exit.mjs +11 -0
  146. package/foundation/render/page-host.mjs +56 -10
  147. package/foundation/render/page-worker.mjs +14 -0
  148. package/foundation/render/render-page.mjs +37 -2
  149. package/foundation/response/error-codes.d.mts +2 -1
  150. package/foundation/response/error-codes.d.ts +1 -0
  151. package/foundation/response/error-codes.doc.mjs +5 -0
  152. package/foundation/response/error-codes.mjs +3 -0
  153. package/foundation/response/json.d.mts +15 -0
  154. package/foundation/response/json.mjs +52 -1
  155. package/foundation/response/response-types.doc.mjs +1 -1
  156. package/foundation/runtime/lazy-dependencies.d.mts +14 -0
  157. package/foundation/runtime/lazy-dependencies.mjs +82 -0
  158. package/foundation/xle/browser.d.mts +2 -2
  159. package/package.json +7 -6
@@ -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
+ }
@@ -7,6 +7,12 @@
7
7
  * @param {((step: string) => boolean) | null} when
8
8
  */
9
9
  export function stopPreviewCommitAt(when: ((step: string) => boolean) | null): void;
10
+ /**
11
+ * For tests: read at most `n` source files when checking for importers
12
+ * (null: the default).
13
+ * @param {number | null} n
14
+ */
15
+ export function setImporterScanMax(n: number | null): void;
10
16
  /**
11
17
  * Rewrite the in-app preview routes of a theme when their imports changed, so
12
18
  * a font package installed after `set` loads on the next change or `show`,
@@ -84,6 +90,8 @@ export type PreviewPage = {
84
90
  file: string;
85
91
  };
86
92
  /**
93
+ * `parents`: how many folders over the preview folder its first add made,
94
+ * which remove takes away again when they are empty.
87
95
  * `hashes`: a short hash of each file as the preview wrote it, so a file
88
96
  * changed by hand is never replaced or deleted
89
97
  */
@@ -93,6 +101,7 @@ export type PreviewData = {
93
101
  pages: PreviewPage[];
94
102
  files: string[];
95
103
  hashes?: Record<string, string>;
104
+ parents?: number;
96
105
  };
97
106
  /**
98
107
  * the command again, with