@astryxdesign/cli 0.7.14 → 0.7.15-canary.g061b2fa

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 (164) hide show
  1. package/README.md +63 -63
  2. package/api/build/_adapter.d.mts +4 -0
  3. package/api/build/_adapter.mjs +28 -2
  4. package/api/build/blocks/blocks.d.mts +10 -1
  5. package/api/build/blocks/blocks.mjs +84 -7
  6. package/api/build/build.mjs +6 -1
  7. package/api/build/tree.d.mts +4 -0
  8. package/api/build/tree.mjs +9 -2
  9. package/api/doctor/_adapter.d.mts +3 -1
  10. package/api/doctor/_adapter.mjs +14 -1
  11. package/api/doctor/_authoring-audit.d.mts +42 -0
  12. package/api/doctor/_authoring-audit.mjs +106 -0
  13. package/api/doctor/doctor.d.mts +7 -0
  14. package/api/doctor/doctor.mjs +24 -39
  15. package/api/doctor/theme-checks.mjs +56 -21
  16. package/api/integration/validate-integration.mjs +17 -3
  17. package/api/integration/validateIntegration.doc.mjs +1 -1
  18. package/api/search/_adapter.mjs +124 -3
  19. package/api/search/_candidate-score.mjs +63 -9
  20. package/api/search/_entries.d.mts +10 -0
  21. package/api/search/_entries.mjs +68 -1
  22. package/api/search/_gather-templates.d.mts +11 -0
  23. package/api/search/_gather-templates.mjs +22 -2
  24. package/api/search/_words.mjs +26 -6
  25. package/api/swizzle/copy/copy.mjs +1 -1
  26. package/api/theme/_adapter.d.mts +17 -1
  27. package/api/theme/_adapter.mjs +185 -40
  28. package/api/theme/build/build.d.mts +29 -1
  29. package/api/theme/build/build.mjs +426 -65
  30. package/api/theme/eject/eject.mjs +10 -6
  31. package/api/theme/targets/targets.d.mts +8 -0
  32. package/api/theme/targets/targets.mjs +24 -4
  33. package/api/theme/template/template.mjs +48 -2
  34. package/api/theme/theme.type.d.mts +8 -0
  35. package/api/theme/theme.type.mjs +5 -1
  36. package/api/theme/themeBuild.doc.mjs +7 -4
  37. package/api/theme/themeEject.doc.mjs +3 -3
  38. package/api/theme/themeRemove.doc.mjs +5 -2
  39. package/api/theme/themeTargets.doc.mjs +1 -1
  40. package/api/theme/themeTemplate.doc.mjs +2 -2
  41. package/api/theme/themeUse.doc.mjs +8 -2
  42. package/api/theme-edit/_adapter.d.mts +46 -3
  43. package/api/theme-edit/_adapter.mjs +372 -109
  44. package/api/theme-edit/_check.d.mts +6 -3
  45. package/api/theme-edit/_check.mjs +665 -87
  46. package/api/theme-edit/_color.mjs +4 -2
  47. package/api/theme-edit/_compiler.d.mts +2 -1
  48. package/api/theme-edit/_compiler.mjs +27 -13
  49. package/api/theme-edit/_context.d.mts +2 -1
  50. package/api/theme-edit/_context.mjs +47 -8
  51. package/api/theme-edit/_edit.d.mts +9 -3
  52. package/api/theme-edit/_edit.mjs +484 -66
  53. package/api/theme-edit/_how-commands.d.mts +33 -7
  54. package/api/theme-edit/_how-commands.mjs +57 -45
  55. package/api/theme-edit/_how-question.d.mts +4 -0
  56. package/api/theme-edit/_how-question.mjs +1004 -223
  57. package/api/theme-edit/_how.mjs +96 -9
  58. package/api/theme-edit/_palette.d.mts +38 -13
  59. package/api/theme-edit/_palette.mjs +620 -223
  60. package/api/theme-edit/_parts.mjs +63 -7
  61. package/api/theme-edit/_png.d.mts +4 -4
  62. package/api/theme-edit/_png.mjs +4 -2
  63. package/api/theme-edit/_preview-app.d.mts +6 -0
  64. package/api/theme-edit/_preview-app.mjs +1194 -207
  65. package/api/theme-edit/_preview.mjs +2 -2
  66. package/api/theme-edit/_project.d.mts +12 -1
  67. package/api/theme-edit/_project.mjs +37 -6
  68. package/api/theme-edit/_settings.d.mts +104 -33
  69. package/api/theme-edit/_settings.mjs +818 -118
  70. package/api/theme-edit/_tables.d.mts +7 -0
  71. package/api/theme-edit/_tables.mjs +61 -0
  72. package/api/theme-edit/theme-edit.type.d.mts +11 -1
  73. package/api/theme-edit/theme-edit.type.mjs +4 -3
  74. package/api/theme-edit/themeEditHow.doc.mjs +6 -0
  75. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  76. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  77. package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
  78. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
  79. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  80. package/api/upgrade/_adapter.d.mts +1 -0
  81. package/assets/codemods/run-codemod.mjs +61 -0
  82. package/assets/codemods/runner.mjs +5 -4
  83. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
  84. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
  85. package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
  86. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
  87. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
  88. package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
  89. package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
  90. package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
  91. package/assets/docs/tree/calendars.doc.mjs +1 -3
  92. package/assets/docs/tree/checks.doc.mjs +22 -1
  93. package/assets/docs.generated.json +2 -1
  94. package/assets/self-audit.generated.json +1 -0
  95. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
  96. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
  97. package/assets/templates/components.generated.json +1 -1
  98. package/authoring/integration/integration.doc.mjs +8 -0
  99. package/authoring/integration/schema.d.mts +8 -0
  100. package/authoring/integration/schema.mjs +1 -0
  101. package/authoring/integration/type.ts +9 -0
  102. package/clients/cli/bin/astryx.mjs +19 -15
  103. package/clients/cli/build-id.generated.json +1 -0
  104. package/clients/cli/commands/ensure-core-built.mjs +12 -5
  105. package/clients/cli/commands/experimental/theme.mjs +178 -78
  106. package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
  107. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
  108. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
  109. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  110. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  111. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  112. package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
  113. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  114. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  115. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
  116. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
  117. package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
  118. package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
  119. package/clients/cli/commands/manifest.mjs +5 -2
  120. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  121. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  122. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  123. package/clients/cli/commands/theme.mjs +374 -42
  124. package/clients/cli/index.mjs +9 -3
  125. package/clients/cli/lib/manifest.mjs +37 -0
  126. package/clients/cli/lib/resolve-theme.mjs +2 -1
  127. package/clients/cli/manifest.generated.json +1 -0
  128. package/foundation/config/theme-state.d.mts +16 -0
  129. package/foundation/config/theme-state.mjs +84 -13
  130. package/foundation/discovery/module-exports.mjs +16 -2
  131. package/foundation/discovery/stored-self-audit.d.mts +31 -0
  132. package/foundation/discovery/stored-self-audit.mjs +119 -0
  133. package/foundation/discovery/template-adapter.d.mts +48 -2
  134. package/foundation/discovery/template-adapter.mjs +51 -19
  135. package/foundation/discovery/template-needs.d.mts +19 -0
  136. package/foundation/discovery/template-needs.mjs +50 -16
  137. package/foundation/discovery/template-source-tree.d.mts +7 -0
  138. package/foundation/discovery/template-source-tree.mjs +15 -0
  139. package/foundation/discovery/theme-discovery.d.mts +2 -1
  140. package/foundation/discovery/theme-discovery.mjs +2 -8
  141. package/foundation/discovery/theme-module-extensions.d.mts +18 -0
  142. package/foundation/discovery/theme-module-extensions.mjs +30 -0
  143. package/foundation/doc-compiler/import.mjs +22 -15
  144. package/foundation/doc-compiler/stored-docs.d.mts +18 -12
  145. package/foundation/doc-compiler/stored-docs.mjs +52 -19
  146. package/foundation/env/private-dir.d.mts +17 -0
  147. package/foundation/env/private-dir.mjs +42 -0
  148. package/foundation/fs/gather-cache.d.mts +108 -0
  149. package/foundation/fs/gather-cache.mjs +741 -0
  150. package/foundation/fs/jiti-cache.d.mts +21 -0
  151. package/foundation/fs/jiti-cache.mjs +66 -0
  152. package/foundation/fs/module-loader.mjs +14 -3
  153. package/foundation/fs/read-record.d.mts +31 -1
  154. package/foundation/fs/read-record.mjs +100 -7
  155. package/foundation/integrations/integrations.d.mts +8 -0
  156. package/foundation/integrations/integrations.mjs +4 -0
  157. package/foundation/integrations/validate-contributions.d.mts +62 -1
  158. package/foundation/integrations/validate-contributions.mjs +476 -40
  159. package/foundation/release/cache.d.mts +11 -2
  160. package/foundation/release/cache.mjs +59 -10
  161. package/foundation/release/folder-lock.d.mts +21 -0
  162. package/foundation/release/folder-lock.mjs +171 -0
  163. package/foundation/response/response-types.doc.mjs +1 -1
  164. package/package.json +8 -6
@@ -0,0 +1,21 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The per-user folder for jiti's transpiled code.
6
+ * @returns {string}
7
+ */
8
+ export function jitiCacheDir(): string;
9
+ /**
10
+ * The `fsCache` option for a jiti loader: the per-user folder, made (0700)
11
+ * on first use and used at once, while it is a real folder the user owns and
12
+ * no one else can reach (the kept catalogs' check). A folder that fails the
13
+ * check, or cannot be made, is not used and nothing is cached on disk. Where
14
+ * the system has no user ids (Windows) ownership cannot be checked, and jiti
15
+ * keeps its default, the user's own temp folder there. Worked out once per
16
+ * process.
17
+ * @returns {{fsCache?: string | false}}
18
+ */
19
+ export function jitiCacheOptions(): {
20
+ fsCache?: string | false;
21
+ };
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Where jiti keeps the code it transpiles from TypeScript (integration
5
+ * manifests, config files, codemods, TypeScript template docs).
6
+ * @input The per-user cache folder (foundation/env/user-dirs.mjs) and the
7
+ * private-folder check (foundation/env/private-dir.mjs).
8
+ * @output `jitiCacheOptions()`: the `fsCache` option for the CLI's jiti
9
+ * loaders: `{fsCache: <user cache>/jiti}` when that folder is the user's
10
+ * own and no one else can reach it; `{fsCache: false}` (transpiled in
11
+ * memory only) when it is not; `{}` (jiti's own default) where the system
12
+ * has no user ids (Windows), whose temp folder is the user's own.
13
+ * @position Read by module-loader.mjs, doc-compiler/import.mjs and
14
+ * gather-cache.mjs. jiti's default is a `jiti` folder in the system temp
15
+ * folder, which on Linux every account on a machine shares, and which the
16
+ * system empties from time to time: another account could leave transpiled
17
+ * code there under the name jiti looks for,
18
+ * and after each emptying every TypeScript file is transpiled again. jiti
19
+ * names each cached file for its source's path and checks a hash of its
20
+ * source content before using it, so an edited, upgraded or downgraded
21
+ * file is transpiled again wherever the cache is. A set JITI_FS_CACHE is
22
+ * jiti's own setting and left to jiti.
23
+ */
24
+
25
+ import * as fs from 'node:fs';
26
+ import * as path from 'node:path';
27
+ import {currentUid, isPrivateDir} from '../env/private-dir.mjs';
28
+ import {userCacheDir} from '../env/user-dirs.mjs';
29
+
30
+ /** @type {{fsCache?: string | false} | undefined} */
31
+ let options;
32
+
33
+ /**
34
+ * The per-user folder for jiti's transpiled code.
35
+ * @returns {string}
36
+ */
37
+ export function jitiCacheDir() {
38
+ return path.join(userCacheDir(), 'jiti');
39
+ }
40
+
41
+ /**
42
+ * The `fsCache` option for a jiti loader: the per-user folder, made (0700)
43
+ * on first use and used at once, while it is a real folder the user owns and
44
+ * no one else can reach (the kept catalogs' check). A folder that fails the
45
+ * check, or cannot be made, is not used and nothing is cached on disk. Where
46
+ * the system has no user ids (Windows) ownership cannot be checked, and jiti
47
+ * keeps its default, the user's own temp folder there. Worked out once per
48
+ * process.
49
+ * @returns {{fsCache?: string | false}}
50
+ */
51
+ export function jitiCacheOptions() {
52
+ if (options) return options;
53
+ options = {};
54
+ if (process.env.JITI_FS_CACHE !== undefined || currentUid() == null) {
55
+ return options;
56
+ }
57
+ options = {fsCache: false};
58
+ try {
59
+ const dir = jitiCacheDir();
60
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, {recursive: true, mode: 0o700});
61
+ if (isPrivateDir(dir)) options = {fsCache: dir};
62
+ } catch {
63
+ // No disk cache: every TypeScript file is transpiled in memory.
64
+ }
65
+ return options;
66
+ }
@@ -24,9 +24,9 @@ import {AsyncLocalStorage} from 'node:async_hooks';
24
24
  import {createRequire} from 'node:module';
25
25
  import {pathToFileURL} from 'node:url';
26
26
  import * as fs from 'node:fs';
27
- import {createJiti} from 'jiti';
28
27
  import {findPresentFiles} from './present-files.mjs';
29
28
  import {importUrl} from './import-url.mjs';
29
+ import {jitiCacheOptions} from './jiti-cache.mjs';
30
30
 
31
31
  export {findPresentFiles};
32
32
 
@@ -34,9 +34,16 @@ export {findPresentFiles};
34
34
  let jitiInstance;
35
35
  let freshImportNonce = 0;
36
36
  const requireFromHere = createRequire(import.meta.url);
37
+
38
+ /**
39
+ * jiti, loaded on first use: only TypeScript files and built theme modules
40
+ * need it, so a run that reads neither never loads it.
41
+ * @type {typeof import('jiti').createJiti}
42
+ */
43
+ const createJiti = (...args) => requireFromHere('jiti').createJiti(...args);
37
44
  function getJiti() {
38
45
  if (!jitiInstance) {
39
- jitiInstance = createJiti(import.meta.url);
46
+ jitiInstance = createJiti(import.meta.url, jitiCacheOptions());
40
47
  }
41
48
  return jitiInstance;
42
49
  }
@@ -195,6 +202,7 @@ function isMissingPackageExport(error) {
195
202
  export async function importThemeArtifact(specifier, cwd) {
196
203
  let themeModule = path.join(cwd, 'package.json');
197
204
  const loader = createJiti(path.join(cwd, 'package.json'), {
205
+ ...jitiCacheOptions(),
198
206
  moduleCache: false,
199
207
  jsx: true,
200
208
  interopDefault: true,
@@ -226,7 +234,10 @@ export async function importThemeArtifact(specifier, cwd) {
226
234
  */
227
235
  async function importModule(file, fresh) {
228
236
  if (fresh && file.endsWith('.ts')) {
229
- return await createJiti(import.meta.url, {moduleCache: false}).import(file);
237
+ return await createJiti(import.meta.url, {
238
+ ...jitiCacheOptions(),
239
+ moduleCache: false,
240
+ }).import(file);
230
241
  }
231
242
  if (file.endsWith('.ts')) {
232
243
  return await getJiti().import(file);
@@ -9,6 +9,14 @@
9
9
  * @returns {string}
10
10
  */
11
11
  export function fileStamp(file: string): string;
12
+ /**
13
+ * Whether a recorded path is still in the state recorded for it, by the kind
14
+ * of state that was recorded.
15
+ * @param {string} file
16
+ * @param {string} state
17
+ * @returns {boolean}
18
+ */
19
+ export function stillInState(file: string, state: string): boolean;
12
20
  /**
13
21
  * Whether every recorded path is still in the state it had when it was read.
14
22
  * @param {Map<string, string>} recorded - From recordReads.
@@ -22,15 +30,37 @@ export function unchangedSince(recorded: Map<string, string>): boolean;
22
30
  * @param {string} file
23
31
  */
24
32
  export function recordContentRead(file: string): void;
33
+ /**
34
+ * Run `fn` with nothing it reads recorded: a cache's own bookkeeping, which
35
+ * is not an input of what it keeps.
36
+ * @template T
37
+ * @param {() => T} fn
38
+ * @returns {T}
39
+ */
40
+ export function withoutRecording<T>(fn: () => T): T;
41
+ /**
42
+ * Count paths as read by the running operations, each with the state given:
43
+ * what a value kept from an earlier read read. Outside `recordReads` it does
44
+ * nothing.
45
+ * @param {Iterable<[string, string]>} states
46
+ */
47
+ export function recordStates(states: Iterable<[string, string]>): void;
25
48
  /**
26
49
  * Run `fn`, adding to `seen` each path it reads, with that path's state when
27
50
  * it was first read (see the file header).
28
51
  * @template T
29
52
  * @param {Map<string, string>} seen
30
53
  * @param {() => T} fn
54
+ * @param {{exact?: boolean}} [options] - `exact`: record a probe (an
55
+ * existence check, a stat, a real path) by the path probed, with its state,
56
+ * instead of by its folder; a listing and a content read are recorded as
57
+ * ever. A folder's time changes whenever any entry in it is added or
58
+ * renamed, so a record kept between runs stays valid longer this way.
31
59
  * @returns {T}
32
60
  */
33
- export function recordReads<T>(seen: Map<string, string>, fn: () => T): T;
61
+ export function recordReads<T>(seen: Map<string, string>, fn: () => T, { exact }?: {
62
+ exact?: boolean;
63
+ }): T;
34
64
  /**
35
65
  * A loader whose value is kept while every file and folder it read is
36
66
  * unchanged, and loaded again after a change, so a long-running process sees
@@ -34,15 +34,41 @@ const reads = new AsyncLocalStorage();
34
34
  * Add `file` to every running operation's map, with its state now, unless it
35
35
  * is there already.
36
36
  * @param {Map<string, string>[]} runs
37
- * @param {string} file
37
+ * @param {string} file - What a run checks: the file read, or the folder of
38
+ * the path probed.
39
+ * @param {string} [probed] - The path itself, which an exact run checks.
38
40
  */
39
- function note(runs, file) {
41
+ function note(runs, file, probed = file) {
40
42
  let state;
43
+ let probedState;
41
44
  for (const seen of runs) {
42
- if (!seen.has(file)) seen.set(file, (state ??= stateOf(file)));
45
+ if (exactRuns.has(seen)) {
46
+ const had = seen.get(probed);
47
+ if (had === undefined) {
48
+ seen.set(
49
+ probed,
50
+ (probedState ??=
51
+ probed === file ? stateOf(probed) : probeStamp(probed)),
52
+ );
53
+ } else if (probed === file && had.startsWith('dir:')) {
54
+ // A folder first only probed, now listed: its listing counts, so it
55
+ // is checked by its full stamp from here on.
56
+ seen.set(probed, (state ??= stateOf(file)));
57
+ }
58
+ } else if (!seen.has(file)) {
59
+ seen.set(file, (state ??= stateOf(file)));
60
+ }
43
61
  }
44
62
  }
45
63
 
64
+ /**
65
+ * The runs that record a probe by the path probed, not by its folder: a
66
+ * record kept across processes, whose folders change for reasons that do not
67
+ * touch the path (see `recordReads`).
68
+ * @type {WeakSet<Map<string, string>>}
69
+ */
70
+ const exactRuns = new WeakSet();
71
+
46
72
  /** node:fs's module object, whose functions every import of it shares. */
47
73
  const fs = createRequire(import.meta.url)('node:fs');
48
74
 
@@ -98,7 +124,7 @@ function installRecorder() {
98
124
  : path.dirname(file);
99
125
  // Its state is taken when it is first read, before the read, so a
100
126
  // change made while the operation runs shows as a change afterwards.
101
- note(runs, checked);
127
+ note(runs, checked, file);
102
128
  }
103
129
  return original.apply(this, args);
104
130
  };
@@ -118,7 +144,12 @@ function installRecorder() {
118
144
  */
119
145
  export function fileStamp(file) {
120
146
  try {
121
- const {size, mtimeMs, ctimeMs, ino} = statSyncRaw(file);
147
+ // An absent path answers without an error: thousands of paths a kept
148
+ // catalog checks are absent, and building an error costs more than the
149
+ // stat.
150
+ const stat = statSyncRaw(file, {throwIfNoEntry: false});
151
+ if (!stat) return '-';
152
+ const {size, mtimeMs, ctimeMs, ino} = stat;
122
153
  return `${size}:${mtimeMs}:${ctimeMs}:${ino}`;
123
154
  } catch {
124
155
  return '-';
@@ -127,6 +158,37 @@ export function fileStamp(file) {
127
158
 
128
159
  const stateOf = fileStamp;
129
160
 
161
+ /**
162
+ * A probed path's state for an exact run: a folder's identity alone (a probe
163
+ * reads whether it is there and what it is, not what it holds, and its time
164
+ * changes whenever an entry in it changes), a file's full stamp, or absent.
165
+ * @param {string} file
166
+ * @returns {string}
167
+ */
168
+ function probeStamp(file) {
169
+ try {
170
+ const stat = statSyncRaw(file, {throwIfNoEntry: false});
171
+ if (!stat) return '-';
172
+ if (stat.isDirectory()) return `dir:${stat.ino}`;
173
+ return `${stat.size}:${stat.mtimeMs}:${stat.ctimeMs}:${stat.ino}`;
174
+ } catch {
175
+ return '-';
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Whether a recorded path is still in the state recorded for it, by the kind
181
+ * of state that was recorded.
182
+ * @param {string} file
183
+ * @param {string} state
184
+ * @returns {boolean}
185
+ */
186
+ export function stillInState(file, state) {
187
+ return (
188
+ (state.startsWith('dir:') ? probeStamp(file) : stateOf(file)) === state
189
+ );
190
+ }
191
+
130
192
  /**
131
193
  * Whether every recorded path is still in the state it had when it was read.
132
194
  * @param {Map<string, string>} recorded - From recordReads.
@@ -134,7 +196,7 @@ const stateOf = fileStamp;
134
196
  */
135
197
  export function unchangedSince(recorded) {
136
198
  for (const [file, state] of recorded) {
137
- if (stateOf(file) !== state) return false;
199
+ if (!stillInState(file, state)) return false;
138
200
  }
139
201
  return true;
140
202
  }
@@ -150,16 +212,47 @@ export function recordContentRead(file) {
150
212
  if (runs) note(runs, path.resolve(file));
151
213
  }
152
214
 
215
+ /**
216
+ * Run `fn` with nothing it reads recorded: a cache's own bookkeeping, which
217
+ * is not an input of what it keeps.
218
+ * @template T
219
+ * @param {() => T} fn
220
+ * @returns {T}
221
+ */
222
+ export function withoutRecording(fn) {
223
+ return reads.exit(fn);
224
+ }
225
+
226
+ /**
227
+ * Count paths as read by the running operations, each with the state given:
228
+ * what a value kept from an earlier read read. Outside `recordReads` it does
229
+ * nothing.
230
+ * @param {Iterable<[string, string]>} states
231
+ */
232
+ export function recordStates(states) {
233
+ const runs = reads.getStore();
234
+ if (!runs) return;
235
+ for (const [file, state] of states) {
236
+ for (const seen of runs) if (!seen.has(file)) seen.set(file, state);
237
+ }
238
+ }
239
+
153
240
  /**
154
241
  * Run `fn`, adding to `seen` each path it reads, with that path's state when
155
242
  * it was first read (see the file header).
156
243
  * @template T
157
244
  * @param {Map<string, string>} seen
158
245
  * @param {() => T} fn
246
+ * @param {{exact?: boolean}} [options] - `exact`: record a probe (an
247
+ * existence check, a stat, a real path) by the path probed, with its state,
248
+ * instead of by its folder; a listing and a content read are recorded as
249
+ * ever. A folder's time changes whenever any entry in it is added or
250
+ * renamed, so a record kept between runs stays valid longer this way.
159
251
  * @returns {T}
160
252
  */
161
- export function recordReads(seen, fn) {
253
+ export function recordReads(seen, fn, {exact = false} = {}) {
162
254
  installRecorder();
255
+ if (exact) exactRuns.add(seen);
163
256
  return reads.run([...(reads.getStore() ?? []), seen], fn);
164
257
  }
165
258
 
@@ -137,6 +137,14 @@ export type LoadedIntegration = {
137
137
  */
138
138
  iconSets?: string | undefined;
139
139
  issuesUrl?: string | undefined;
140
+ /**
141
+ * the manifest's logo
142
+ * paths as written, relative to the package root
143
+ */
144
+ logo?: {
145
+ light: string;
146
+ dark?: string;
147
+ } | undefined;
140
148
  agentDocs?: {
141
149
  append?: readonly string[];
142
150
  } | undefined;
@@ -58,6 +58,8 @@ import {resolveProviders} from './provider-resolution.mjs';
58
58
  * @property {string} [themes]
59
59
  * @property {string} [iconSets] the manifest's `experimental.iconSets` root
60
60
  * @property {string} [issuesUrl]
61
+ * @property {{light: string, dark?: string}} [logo] the manifest's logo
62
+ * paths as written, relative to the package root
61
63
  * @property {{append?: readonly string[]}} [agentDocs]
62
64
  * @property {string} [cliCommand] the command this package's users run the
63
65
  * CLI with; read by the picker in foundation/env (see cli-command.mjs)
@@ -501,6 +503,7 @@ export async function loadLocalIntegration(packageDir, {fresh = false} = {}) {
501
503
  themes: resolveRoot(manifest.themes),
502
504
  iconSets: resolveRoot(manifest.experimental?.iconSets),
503
505
  issuesUrl: manifest.issuesUrl,
506
+ logo: manifest.logo,
504
507
  agentDocs: manifest.agentDocs,
505
508
  cliCommand: manifest.cliCommand,
506
509
  __cliCommandError: cliCommandError,
@@ -629,6 +632,7 @@ export async function loadIntegrations(
629
632
  themes: resolveRoot(manifest.themes),
630
633
  iconSets: resolveRoot(manifest.experimental?.iconSets),
631
634
  issuesUrl: manifest.issuesUrl,
635
+ logo: manifest.logo,
632
636
  agentDocs: manifest.agentDocs,
633
637
  cliCommand: manifest.cliCommand,
634
638
  __cliCommandError: cliCommandError,
@@ -124,8 +124,12 @@ export function negatedFilesEntry(rel: string, files: unknown): string | null;
124
124
  * package (`npm pack --dry-run`). When npm cannot answer, an asset no
125
125
  * `files` entry can reach is still a note, and any other is returned in
126
126
  * `unchecked`.
127
+ * It also returns `examples`, what the package-level listing note needs:
128
+ * whether any block is a showcase, and, when none is, how many components
129
+ * need an example (the exemptions above apply). It is absent when the
130
+ * templates or components cannot be read, so no listing note is drawn.
127
131
  * @param {LoadedIntegration} integration
128
- * @returns {Promise<{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>}>}
132
+ * @returns {Promise<{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>, examples?: ExampleSummary}>}
129
133
  */
130
134
  export function componentExamplesCheck(integration: LoadedIntegration): Promise<{
131
135
  notes: Note[];
@@ -134,6 +138,7 @@ export function componentExamplesCheck(integration: LoadedIntegration): Promise<
134
138
  asset: string;
135
139
  reason: string;
136
140
  }>;
141
+ examples?: ExampleSummary;
137
142
  }>;
138
143
  /**
139
144
  * The component doc names the check could not judge, shaped like the doc type
@@ -192,6 +197,49 @@ export function validateLoadedIntegrationListed(loaded: LoadedIntegration): Prom
192
197
  issues: Issue[];
193
198
  listed: Issue[];
194
199
  }>;
200
+ /**
201
+ * Whether these bytes are an image a catalog can show as a logo, in the
202
+ * format the file's extension names: `.png`, `.jpg` or `.jpeg`, `.webp`, or
203
+ * `.svg` drawn only with shapes; at most 512 KB. A file whose bytes claim
204
+ * another format, or any other extension, is refused.
205
+ * @param {Buffer} bytes
206
+ * @param {string} file the image's path or name
207
+ * @returns {boolean}
208
+ */
209
+ export function isListingImage(bytes: Buffer, file: string): boolean;
210
+ /**
211
+ * What `componentExamplesCheck` found that the package-level note needs.
212
+ * @typedef {object} ExampleSummary
213
+ * @property {number} needed components that need an example and have none
214
+ * @property {boolean} showcase whether any block template is a showcase
215
+ */
216
+ /**
217
+ * What a catalog needs to list the package well, as two information-only
218
+ * notes that fail no check under any flag, each with its fix:
219
+ * - `package_without_logo`: the integration file's `logo.light` (or, when
220
+ * the integration file has no `logo`, package.json `marketplace.logo.light`)
221
+ * names no image the package ships: missing, outside the package, not a
222
+ * file, not a PNG, JPEG, WebP or shapes-only SVG of at most 512 KB, or left
223
+ * out of the packed files. `dark`, when set, is checked the same way.
224
+ * - `package_without_example`: from `examples`, the summary
225
+ * `componentExamplesCheck` returns: the package has components that need
226
+ * an example and no block template is a showcase. A package of themes,
227
+ * docs, codemods or agent docs alone needs none.
228
+ * A package of icon sets alone draws neither note. When npm cannot say
229
+ * whether a logo is packed, it is returned in `unchecked`, listed with the
230
+ * template assets npm could not place.
231
+ * @param {LoadedIntegration} integration
232
+ * @param {ExampleSummary} [examples]
233
+ * @returns {{notes: Note[], unchecked: Array<{file: string, asset: string, reason: string}>}}
234
+ */
235
+ export function packageListingCheck(integration: LoadedIntegration, examples?: ExampleSummary): {
236
+ notes: Note[];
237
+ unchecked: Array<{
238
+ file: string;
239
+ asset: string;
240
+ reason: string;
241
+ }>;
242
+ };
195
243
  /**
196
244
  * @typedef {import('./issue').AstryxIntegrationIssue} Issue
197
245
  * @typedef {import('./integrations.mjs').LoadedIntegration} LoadedIntegration
@@ -210,5 +258,18 @@ export type Note = {
210
258
  code: string;
211
259
  message: string;
212
260
  };
261
+ /**
262
+ * What `componentExamplesCheck` found that the package-level note needs.
263
+ */
264
+ export type ExampleSummary = {
265
+ /**
266
+ * components that need an example and have none
267
+ */
268
+ needed: number;
269
+ /**
270
+ * whether any block template is a showcase
271
+ */
272
+ showcase: boolean;
273
+ };
213
274
  export type Issue = import("./issue").AstryxIntegrationIssue;
214
275
  export type LoadedIntegration = import("./integrations.mjs").LoadedIntegration;