@astryxdesign/cli 0.7.14 → 0.7.15-canary.g06b7e61

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 (203) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/README.md +63 -63
  3. package/api/build/_adapter.d.mts +4 -0
  4. package/api/build/_adapter.mjs +28 -2
  5. package/api/build/blocks/blocks.d.mts +10 -1
  6. package/api/build/blocks/blocks.mjs +84 -7
  7. package/api/build/build.mjs +6 -1
  8. package/api/build/tree.d.mts +4 -0
  9. package/api/build/tree.mjs +9 -2
  10. package/api/doctor/_adapter.d.mts +3 -1
  11. package/api/doctor/_adapter.mjs +14 -1
  12. package/api/doctor/_authoring-audit.d.mts +42 -0
  13. package/api/doctor/_authoring-audit.mjs +106 -0
  14. package/api/doctor/doctor.d.mts +7 -0
  15. package/api/doctor/doctor.mjs +24 -39
  16. package/api/doctor/theme-checks.mjs +56 -21
  17. package/api/integration/add-helpers.mjs +5 -0
  18. package/api/integration/add-theme.mjs +15 -110
  19. package/api/integration/validate-integration.mjs +17 -3
  20. package/api/integration/validateIntegration.doc.mjs +1 -1
  21. package/api/search/_adapter.mjs +124 -3
  22. package/api/search/_candidate-score.mjs +63 -9
  23. package/api/search/_entries.d.mts +10 -0
  24. package/api/search/_entries.mjs +68 -1
  25. package/api/search/_gather-templates.d.mts +11 -0
  26. package/api/search/_gather-templates.mjs +22 -2
  27. package/api/search/_words.mjs +26 -6
  28. package/api/swizzle/copy/copy.mjs +1 -1
  29. package/api/theme/_adapter.d.mts +37 -5
  30. package/api/theme/_adapter.mjs +381 -57
  31. package/api/theme/_fork.d.mts +90 -0
  32. package/api/theme/_fork.mjs +246 -0
  33. package/api/theme/build/build.d.mts +40 -2
  34. package/api/theme/build/build.mjs +477 -66
  35. package/api/theme/eject/eject.mjs +36 -15
  36. package/api/theme/list/list.mjs +3 -6
  37. package/api/theme/palette/generate/generator.d.mts +13 -0
  38. package/api/theme/palette/generate/generator.mjs +32 -2
  39. package/api/theme/targets/targets.d.mts +8 -0
  40. package/api/theme/targets/targets.mjs +24 -4
  41. package/api/theme/template/template.mjs +48 -2
  42. package/api/theme/theme.type.d.mts +8 -0
  43. package/api/theme/theme.type.mjs +5 -1
  44. package/api/theme/themeBuild.doc.mjs +7 -4
  45. package/api/theme/themeEject.doc.mjs +3 -3
  46. package/api/theme/themeRemove.doc.mjs +5 -2
  47. package/api/theme/themeTargets.doc.mjs +1 -1
  48. package/api/theme/themeTemplate.doc.mjs +2 -2
  49. package/api/theme/themeUse.doc.mjs +8 -2
  50. package/api/theme-edit/_adapter.d.mts +46 -3
  51. package/api/theme-edit/_adapter.mjs +496 -112
  52. package/api/theme-edit/_catalog.d.mts +1 -6
  53. package/api/theme-edit/_catalog.mjs +5 -268
  54. package/api/theme-edit/_check.d.mts +9 -4
  55. package/api/theme-edit/_check.mjs +1232 -229
  56. package/api/theme-edit/_color.d.mts +19 -0
  57. package/api/theme-edit/_color.mjs +280 -34
  58. package/api/theme-edit/_compiler.d.mts +3 -1
  59. package/api/theme-edit/_compiler.mjs +52 -13
  60. package/api/theme-edit/_context.d.mts +4 -1
  61. package/api/theme-edit/_context.mjs +126 -13
  62. package/api/theme-edit/_css.d.mts +84 -0
  63. package/api/theme-edit/_css.mjs +700 -0
  64. package/api/theme-edit/_edit.d.mts +9 -3
  65. package/api/theme-edit/_edit.mjs +806 -103
  66. package/api/theme-edit/_how-commands.d.mts +38 -7
  67. package/api/theme-edit/_how-commands.mjs +64 -45
  68. package/api/theme-edit/_how-question.d.mts +33 -0
  69. package/api/theme-edit/_how-question.mjs +2553 -381
  70. package/api/theme-edit/_how.mjs +402 -31
  71. package/api/theme-edit/_overview.mjs +2 -7
  72. package/api/theme-edit/_palette.d.mts +60 -13
  73. package/api/theme-edit/_palette.mjs +826 -295
  74. package/api/theme-edit/_parts.d.mts +42 -10
  75. package/api/theme-edit/_parts.mjs +280 -69
  76. package/api/theme-edit/_png.d.mts +4 -4
  77. package/api/theme-edit/_png.mjs +4 -2
  78. package/api/theme-edit/_preview-app.d.mts +14 -0
  79. package/api/theme-edit/_preview-app.mjs +1675 -235
  80. package/api/theme-edit/_preview.d.mts +7 -16
  81. package/api/theme-edit/_preview.mjs +79 -86
  82. package/api/theme-edit/_project.d.mts +32 -2
  83. package/api/theme-edit/_project.mjs +80 -19
  84. package/api/theme-edit/_settings.d.mts +199 -52
  85. package/api/theme-edit/_settings.mjs +1422 -217
  86. package/api/theme-edit/_tables.d.mts +19 -6
  87. package/api/theme-edit/_tables.mjs +150 -92
  88. package/api/theme-edit/theme-edit.type.d.mts +20 -1
  89. package/api/theme-edit/theme-edit.type.mjs +6 -3
  90. package/api/theme-edit/themeEditHow.doc.mjs +6 -0
  91. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  92. package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
  93. package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
  94. package/api/theme-edit/themeEditPreviewList.doc.mjs +2 -2
  95. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
  96. package/api/theme-edit/themeEditSet.doc.mjs +1 -1
  97. package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
  98. package/api/upgrade/_adapter.d.mts +1 -0
  99. package/assets/codemods/run-codemod.mjs +61 -0
  100. package/assets/codemods/runner.mjs +5 -4
  101. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
  102. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
  103. package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
  104. package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
  105. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
  106. package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
  107. package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
  108. package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
  109. package/assets/docs/tree/calendars.doc.mjs +1 -3
  110. package/assets/docs/tree/checks.doc.mjs +22 -1
  111. package/assets/docs/tree/publishing.doc.mjs +1 -0
  112. package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
  113. package/assets/docs.generated.json +2 -1
  114. package/assets/preview-app/next.config.mjs +7 -1
  115. package/assets/self-audit.generated.json +1 -0
  116. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
  117. package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
  118. package/assets/templates/components.generated.json +1 -1
  119. package/authoring/integration/integration.doc.mjs +8 -0
  120. package/authoring/integration/schema.d.mts +8 -0
  121. package/authoring/integration/schema.mjs +1 -0
  122. package/authoring/integration/type.ts +9 -0
  123. package/clients/cli/bin/astryx.mjs +19 -15
  124. package/clients/cli/build-id.generated.json +1 -0
  125. package/clients/cli/commands/ensure-core-built.mjs +12 -5
  126. package/clients/cli/commands/experimental/index.mjs +10 -10
  127. package/clients/cli/commands/experimental/theme.mjs +200 -81
  128. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  129. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
  130. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +3 -3
  131. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
  132. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  133. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  134. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  135. package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
  136. package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
  137. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  138. package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
  139. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
  140. package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
  141. package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
  142. package/clients/cli/commands/integration.mjs +8 -0
  143. package/clients/cli/commands/manifest.mjs +5 -2
  144. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  145. package/clients/cli/commands/theme-list.doc.mjs +1 -1
  146. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  147. package/clients/cli/commands/theme.mjs +439 -66
  148. package/clients/cli/index.mjs +27 -6
  149. package/clients/cli/lib/cli-error.mjs +118 -3
  150. package/clients/cli/lib/manifest.mjs +37 -0
  151. package/clients/cli/lib/resolve-theme.mjs +2 -1
  152. package/clients/cli/manifest.generated.json +1 -0
  153. package/foundation/config/project.mjs +34 -8
  154. package/foundation/config/theme-state.d.mts +16 -0
  155. package/foundation/config/theme-state.mjs +84 -13
  156. package/foundation/discovery/module-exports.mjs +16 -2
  157. package/foundation/discovery/stored-self-audit.d.mts +31 -0
  158. package/foundation/discovery/stored-self-audit.mjs +119 -0
  159. package/foundation/discovery/template-adapter.d.mts +48 -2
  160. package/foundation/discovery/template-adapter.mjs +51 -19
  161. package/foundation/discovery/template-needs.d.mts +19 -0
  162. package/foundation/discovery/template-needs.mjs +50 -16
  163. package/foundation/discovery/template-source-tree.d.mts +7 -0
  164. package/foundation/discovery/template-source-tree.mjs +15 -0
  165. package/foundation/discovery/theme-discovery.d.mts +2 -1
  166. package/foundation/discovery/theme-discovery.mjs +16 -10
  167. package/foundation/discovery/theme-imports.d.mts +16 -0
  168. package/foundation/discovery/theme-imports.mjs +30 -2
  169. package/foundation/discovery/theme-module-extensions.d.mts +18 -0
  170. package/foundation/discovery/theme-module-extensions.mjs +30 -0
  171. package/foundation/doc-compiler/import.mjs +22 -15
  172. package/foundation/doc-compiler/stored-docs.d.mts +18 -12
  173. package/foundation/doc-compiler/stored-docs.mjs +52 -19
  174. package/foundation/env/private-dir.d.mts +17 -0
  175. package/foundation/env/private-dir.mjs +42 -0
  176. package/foundation/fs/gather-cache.d.mts +108 -0
  177. package/foundation/fs/gather-cache.mjs +783 -0
  178. package/foundation/fs/jiti-cache.d.mts +21 -0
  179. package/foundation/fs/jiti-cache.mjs +66 -0
  180. package/foundation/fs/module-loader.mjs +14 -3
  181. package/foundation/fs/read-record.d.mts +31 -1
  182. package/foundation/fs/read-record.mjs +100 -7
  183. package/foundation/integrations/autolink.d.mts +1 -24
  184. package/foundation/integrations/autolink.mjs +7 -60
  185. package/foundation/integrations/declared-dependencies.d.mts +27 -0
  186. package/foundation/integrations/declared-dependencies.mjs +73 -0
  187. package/foundation/integrations/integrations.d.mts +8 -0
  188. package/foundation/integrations/integrations.mjs +4 -0
  189. package/foundation/integrations/may-have-integrations.d.mts +8 -0
  190. package/foundation/integrations/may-have-integrations.mjs +47 -0
  191. package/foundation/integrations/validate-contributions.d.mts +62 -1
  192. package/foundation/integrations/validate-contributions.mjs +476 -40
  193. package/foundation/release/cache.d.mts +32 -4
  194. package/foundation/release/cache.mjs +105 -16
  195. package/foundation/release/folder-lock.d.mts +28 -0
  196. package/foundation/release/folder-lock.mjs +205 -0
  197. package/foundation/release/lock-lease.d.mts +2 -1
  198. package/foundation/release/lock-lease.mjs +7 -2
  199. package/foundation/response/error-codes.doc.mjs +1 -1
  200. package/foundation/response/response-types.doc.mjs +5 -5
  201. package/package.json +8 -6
  202. package/api/theme-edit/_css-properties.d.mts +0 -10
  203. package/api/theme-edit/_css-properties.mjs +0 -556
@@ -185,18 +185,43 @@ export function recentFailedInstall(version: string, cacheDir: string, now?: num
185
185
  failures: number;
186
186
  waitMs: number;
187
187
  } | null;
188
+ /**
189
+ * This process's process-id space (Linux: the pid namespace), or null where
190
+ * process ids are one space for the whole computer.
191
+ * @returns {string | null}
192
+ */
193
+ export function pidSpace(): string | null;
194
+ /**
195
+ * Is process `pid` on this computer still running?
196
+ * @param {number} pid
197
+ * @returns {boolean}
198
+ */
199
+ export function isAlive(pid: number): boolean;
188
200
  /**
189
201
  * Take a lock folder, or return false when another live run holds it. A lock
190
202
  * whose holder has gone, such as a run stopped with Ctrl-C or killed, is taken
191
203
  * over at once, and one from another computer once its holder has stopped
192
204
  * renewing it. Throws when the cache folder cannot be written.
193
205
  * @param {string} lockDir
194
- * @param {{now?: number}} [options] the clock, for tests
206
+ * @param {{now?: number, leased?: boolean}} [options] the clock, for tests;
207
+ * `leased` for a lock whose holder renews it (lock-lease.mjs): its record
208
+ * names its process space, and a holder on this computer that looks gone
209
+ * from another space (a container with the same computer name) is taken
210
+ * over only once its record has stood unrenewed for three renewals.
195
211
  * @returns {boolean}
196
212
  */
197
- export function tryLock(lockDir: string, { now }?: {
213
+ export function tryLock(lockDir: string, { now, leased }?: {
198
214
  now?: number;
215
+ leased?: boolean;
199
216
  }): boolean;
217
+ /**
218
+ * Which lock folder this is: its device, inode and creation time, and its
219
+ * owner record. A rename keeps them all; a lock made again in its place
220
+ * differs, even before it has a record. Null when there is no folder.
221
+ * @param {string} lockDir
222
+ * @returns {string | null}
223
+ */
224
+ export function lockIdentity(lockDir: string): string | null;
200
225
  /**
201
226
  * Whether a process's arguments are this CLI's install of `version`, as
202
227
  * runNpm starts it: the program (`argv[0]`) is npm, or a Node running npm's
@@ -224,17 +249,20 @@ export function isReleaseInstall(argv: string[], version: string, { node }?: {
224
249
  * since a recorded process id can name an unrelated process once the install
225
250
  * ended.
226
251
  * @param {string} lockDir a `.lock-<version>` folder
227
- * @param {{now?: number, procRoot?: string, factsOf?: (pid: number) => {argv: string[] | null, startedAt: number | null}}} [options]
252
+ * @param {{now?: number, procRoot?: string, factsOf?: (pid: number) => {argv: string[] | null, startedAt: number | null}, version?: string}} [options]
253
+ * `version` names the release when the folder's name does not (a lock
254
+ * moved aside).
228
255
  * the clock, the process table's folder, and the fact reader, for tests
229
256
  * @returns {'ended' | 'left'} whether a process group was ended
230
257
  */
231
- export function endRecordedInstall(lockDir: string, { now, procRoot, factsOf }?: {
258
+ export function endRecordedInstall(lockDir: string, { now, procRoot, factsOf, version: named }?: {
232
259
  now?: number;
233
260
  procRoot?: string;
234
261
  factsOf?: (pid: number) => {
235
262
  argv: string[] | null;
236
263
  startedAt: number | null;
237
264
  };
265
+ version?: string;
238
266
  }): "ended" | "left";
239
267
  /**
240
268
  * Why a release could not be made available.
@@ -41,7 +41,7 @@ import {fileURLToPath} from 'node:url';
41
41
  import {satisfiesRange} from '../env/semver.mjs';
42
42
  import {readJson} from './project.mjs';
43
43
  import {userCacheDir as userCacheDirFor} from '../env/user-dirs.mjs';
44
- import {foreignLockIsSilent} from './lock-lease.mjs';
44
+ import {foreignLockIsSilent, LEASE_RENEW_MS} from './lock-lease.mjs';
45
45
  import {relativeWithin} from '../fs/path-compare.mjs';
46
46
 
47
47
  /**
@@ -649,12 +649,25 @@ const FOREIGN_LOCK_MS = 20 * 60_000;
649
649
  /** How long a lock with no owner record may stand: its holder died taking it. */
650
650
  const UNOWNED_LOCK_MS = 10_000;
651
651
 
652
+ /**
653
+ * This process's process-id space (Linux: the pid namespace), or null where
654
+ * process ids are one space for the whole computer.
655
+ * @returns {string | null}
656
+ */
657
+ export function pidSpace() {
658
+ try {
659
+ return fs.readlinkSync('/proc/self/ns/pid');
660
+ } catch {
661
+ return null;
662
+ }
663
+ }
664
+
652
665
  /**
653
666
  * Is process `pid` on this computer still running?
654
667
  * @param {number} pid
655
668
  * @returns {boolean}
656
669
  */
657
- function isAlive(pid) {
670
+ export function isAlive(pid) {
658
671
  try {
659
672
  process.kill(pid, 0);
660
673
  return true;
@@ -674,7 +687,7 @@ function isAlive(pid) {
674
687
  * @param {number} now
675
688
  * @returns {boolean}
676
689
  */
677
- function lockIsStale(lockDir, now) {
690
+ function lockIsStale(lockDir, now, leased = false) {
678
691
  let age;
679
692
  try {
680
693
  age = now - fs.statSync(lockDir).mtimeMs;
@@ -688,7 +701,36 @@ function lockIsStale(lockDir, now) {
688
701
  return age > FOREIGN_LOCK_MS || foreignLockIsSilent(lockDir, now);
689
702
  }
690
703
  // A live holder on this computer is installing, however slowly.
691
- return !isAlive(owner.pid);
704
+ if (isAlive(owner.pid)) return false;
705
+ // A leased lock's holder renews its record while it runs. A process id
706
+ // that looks gone may only be out of sight (a container that shares this
707
+ // computer's name, in its own process space): the record must also have
708
+ // stood unrenewed for three renewals.
709
+ if (!leased) return true;
710
+ // Recorded from this process space (or by a version that records none):
711
+ // the process id is judged right.
712
+ const ns = pidSpace();
713
+ if (ns === null || !owner.ns || owner.ns === ns) return true;
714
+ try {
715
+ return (
716
+ now - fs.statSync(path.join(lockDir, 'owner.json')).mtimeMs >
717
+ 3 * LEASE_RENEW_MS
718
+ );
719
+ } catch {
720
+ return true;
721
+ }
722
+ }
723
+
724
+ /**
725
+ * The text of a lock's owner record, or '' when it has none.
726
+ * @param {string} lockDir
727
+ */
728
+ function ownerText(lockDir) {
729
+ try {
730
+ return fs.readFileSync(path.join(lockDir, 'owner.json'), 'utf-8');
731
+ } catch {
732
+ return '';
733
+ }
692
734
  }
693
735
 
694
736
  /**
@@ -697,10 +739,14 @@ function lockIsStale(lockDir, now) {
697
739
  * over at once, and one from another computer once its holder has stopped
698
740
  * renewing it. Throws when the cache folder cannot be written.
699
741
  * @param {string} lockDir
700
- * @param {{now?: number}} [options] the clock, for tests
742
+ * @param {{now?: number, leased?: boolean}} [options] the clock, for tests;
743
+ * `leased` for a lock whose holder renews it (lock-lease.mjs): its record
744
+ * names its process space, and a holder on this computer that looks gone
745
+ * from another space (a container with the same computer name) is taken
746
+ * over only once its record has stood unrenewed for three renewals.
701
747
  * @returns {boolean}
702
748
  */
703
- export function tryLock(lockDir, {now = Date.now()} = {}) {
749
+ export function tryLock(lockDir, {now = Date.now(), leased = false} = {}) {
704
750
  fs.mkdirSync(path.dirname(lockDir), {recursive: true});
705
751
  try {
706
752
  fs.mkdirSync(lockDir);
@@ -708,10 +754,12 @@ export function tryLock(lockDir, {now = Date.now()} = {}) {
708
754
  if (/** @type {NodeJS.ErrnoException} */ (error).code !== 'EEXIST') {
709
755
  throw error;
710
756
  }
711
- if (!lockIsStale(lockDir, now)) return false;
712
- // The run that held it is gone; end the install it left running, if any,
713
- // before starting another.
714
- endRecordedInstall(lockDir, {now});
757
+ // The lock judged stale, read before the judgement: the folder moved
758
+ // aside must be that same folder (by its identity on disk, not only its
759
+ // record, which a new lock lacks for a moment), or another run took the
760
+ // lock in between.
761
+ const judged = lockIdentity(lockDir);
762
+ if (!judged || !lockIsStale(lockDir, now, leased)) return false;
715
763
  const aside = `${lockDir}.stale-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
716
764
  try {
717
765
  fs.renameSync(lockDir, aside);
@@ -719,6 +767,24 @@ export function tryLock(lockDir, {now = Date.now()} = {}) {
719
767
  // Another run took it over first.
720
768
  return false;
721
769
  }
770
+ if (lockIdentity(aside) !== judged) {
771
+ // A live lock taken after the judgement: put it back, and wait. When
772
+ // its place is taken again, it stays aside for its run: this run
773
+ // holds nothing and removes nothing.
774
+ try {
775
+ fs.renameSync(aside, lockDir);
776
+ } catch {
777
+ // Left for its run.
778
+ }
779
+ return false;
780
+ }
781
+ // The run that held it is gone; end the install it left running, if
782
+ // any, before starting another. The moved folder's name holds no
783
+ // version, so it is passed.
784
+ endRecordedInstall(aside, {
785
+ now,
786
+ version: /^\.lock-(.+)$/u.exec(path.basename(lockDir))?.[1],
787
+ });
722
788
  fs.rmSync(aside, {recursive: true, force: true});
723
789
  try {
724
790
  fs.mkdirSync(lockDir);
@@ -729,7 +795,13 @@ export function tryLock(lockDir, {now = Date.now()} = {}) {
729
795
  try {
730
796
  fs.writeFileSync(
731
797
  path.join(lockDir, 'owner.json'),
732
- JSON.stringify({pid: process.pid, host: os.hostname(), at: Date.now()}),
798
+ JSON.stringify({
799
+ pid: process.pid,
800
+ host: os.hostname(),
801
+ at: Date.now(),
802
+ // A leased lock names the process space its id belongs to.
803
+ ...(leased && pidSpace() ? {ns: pidSpace()} : {}),
804
+ }),
733
805
  );
734
806
  } catch {
735
807
  // Without a record the lock still expires on its own.
@@ -737,6 +809,22 @@ export function tryLock(lockDir, {now = Date.now()} = {}) {
737
809
  return true;
738
810
  }
739
811
 
812
+ /**
813
+ * Which lock folder this is: its device, inode and creation time, and its
814
+ * owner record. A rename keeps them all; a lock made again in its place
815
+ * differs, even before it has a record. Null when there is no folder.
816
+ * @param {string} lockDir
817
+ * @returns {string | null}
818
+ */
819
+ export function lockIdentity(lockDir) {
820
+ try {
821
+ const st = fs.statSync(lockDir, {bigint: true});
822
+ return `${st.dev}:${st.ino}:${st.birthtimeNs}:${ownerText(lockDir)}`;
823
+ } catch {
824
+ return null;
825
+ }
826
+ }
827
+
740
828
  /**
741
829
  * What the system says about the process `pid`: its arguments (exact from
742
830
  * `/proc`; split on spaces from `ps` or PowerShell, so a path with a space in
@@ -866,13 +954,15 @@ export function isReleaseInstall(
866
954
  * since a recorded process id can name an unrelated process once the install
867
955
  * ended.
868
956
  * @param {string} lockDir a `.lock-<version>` folder
869
- * @param {{now?: number, procRoot?: string, factsOf?: (pid: number) => {argv: string[] | null, startedAt: number | null}}} [options]
957
+ * @param {{now?: number, procRoot?: string, factsOf?: (pid: number) => {argv: string[] | null, startedAt: number | null}, version?: string}} [options]
958
+ * `version` names the release when the folder's name does not (a lock
959
+ * moved aside).
870
960
  * the clock, the process table's folder, and the fact reader, for tests
871
961
  * @returns {'ended' | 'left'} whether a process group was ended
872
962
  */
873
963
  export function endRecordedInstall(
874
964
  lockDir,
875
- {now = Date.now(), procRoot = '/proc', factsOf} = {},
965
+ {now = Date.now(), procRoot = '/proc', factsOf, version: named} = {},
876
966
  ) {
877
967
  let pid;
878
968
  try {
@@ -881,7 +971,7 @@ export function endRecordedInstall(
881
971
  return 'left';
882
972
  }
883
973
  if (!Number.isInteger(pid) || pid <= 1 || !isAlive(pid)) return 'left';
884
- const version = /^\.lock-(.+)$/u.exec(path.basename(lockDir))?.[1];
974
+ const version = named ?? /^\.lock-(.+)$/u.exec(path.basename(lockDir))?.[1];
885
975
  if (!version) return 'left';
886
976
  const owner = readJson(path.join(lockDir, 'owner.json'));
887
977
  const at = typeof owner?.at === 'number' ? owner.at : null;
@@ -1055,8 +1145,7 @@ function ensureLocked(
1055
1145
  for (const entry of safeList(root)) {
1056
1146
  if (
1057
1147
  entry.startsWith(`.tmp-${version}-`) ||
1058
- entry.startsWith(`${version}.removing-`) ||
1059
- entry.startsWith(`.lock-${version}.stale-`)
1148
+ entry.startsWith(`${version}.removing-`)
1060
1149
  ) {
1061
1150
  fs.rmSync(path.join(root, entry), {recursive: true, force: true});
1062
1151
  }
@@ -0,0 +1,28 @@
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
+ * Throw when the work running under withFolderLock no longer holds its lock
6
+ * (another run took it over while this one was stopped), so it writes
7
+ * nothing more. Outside withFolderLock it does nothing. Call it right
8
+ * before a write.
9
+ */
10
+ export function stillHolds(): void;
11
+ /**
12
+ * Run `fn` holding the lock folder `lockDir`. A run waits while another
13
+ * holds it; the wait starts again each time the lock changes hands, and
14
+ * `onBusy` is called (it throws) when one holder keeps it longer than
15
+ * `waitMs`. The lock is renewed while `fn` runs.
16
+ * @template T
17
+ * @param {string} lockDir
18
+ * @param {() => Promise<T>} fn
19
+ * @param {{waitMs?: number, onBusy: (owner: any, heldSeconds: number | null) => never}} options
20
+ * @returns {Promise<T>}
21
+ */
22
+ export function withFolderLock<T>(lockDir: string, fn: () => Promise<T>, { waitMs, onBusy }: {
23
+ waitMs?: number;
24
+ onBusy: (owner: any, heldSeconds: number | null) => never;
25
+ }): Promise<T>;
26
+ /** How long a held lock's record may stand unrenewed before it is taken over. */
27
+ export const SILENT_MS: number;
28
+ export function holdsFolderLock(lockDir: string): boolean;
@@ -0,0 +1,205 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file A folder lock for a command that may take a while: the release
5
+ * cache's lock (cache.mjs `tryLock`), held with its lease (lock-lease.mjs
6
+ * `renewLock`) for as long as the command runs, so a run on another computer
7
+ * or container never takes it over while it is held.
8
+ *
9
+ * @input a lock folder and the work to run under it
10
+ * @output the work's result; the lock is released on the way out, also on
11
+ * Ctrl-C, and only when it is still this run's own
12
+ * @position foundation/release — used by the theme editor (api/theme-edit/_adapter.mjs).
13
+ */
14
+
15
+ import * as fs from 'node:fs';
16
+ import * as path from 'node:path';
17
+ import {AsyncLocalStorage} from 'node:async_hooks';
18
+ import * as os from 'node:os';
19
+ import {isAlive, lockIdentity, pidSpace, tryLock} from './cache.mjs';
20
+ import {foreignLockIsSilent, LEASE_RENEW_MS, renewLock} from './lock-lease.mjs';
21
+
22
+ /** How long a held lock's record may stand unrenewed before it is taken over. */
23
+ export const SILENT_MS = 3 * LEASE_RENEW_MS;
24
+
25
+ /**
26
+ * Move a silent lock aside and remove it; another run that moved it first
27
+ * wins, and this one tries again.
28
+ * @param {string} lockDir
29
+ * @param {string} judged the record seen silent
30
+ */
31
+ function takeOver(lockDir, judged) {
32
+ const aside = `${lockDir}.silent-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
33
+ try {
34
+ fs.renameSync(lockDir, aside);
35
+ } catch {
36
+ return;
37
+ }
38
+ // The lock moved aside must be the one judged silent (by its identity
39
+ // on disk and its record, as the release cache checks): a lock taken or
40
+ // renewed in between is put back. When its place is taken again, it
41
+ // stays aside for its run, and this run holds nothing.
42
+ if (lockIdentity(aside) !== judged) {
43
+ try {
44
+ fs.renameSync(aside, lockDir);
45
+ } catch {
46
+ // Left for its run.
47
+ }
48
+ return;
49
+ }
50
+ fs.rmSync(aside, {recursive: true, force: true});
51
+ }
52
+
53
+ /**
54
+ * Whether a lock's holder runs on this computer, in this process space: a
55
+ * holder that is only stopped (Ctrl-Z, a sleeping laptop, a debugger) is
56
+ * alive, however long its record stands unrenewed.
57
+ * @param {any} owner
58
+ */
59
+ function aliveHere(owner) {
60
+ if (!owner || owner.host !== os.hostname() || !Number.isInteger(owner.pid))
61
+ return false;
62
+ const ns = pidSpace();
63
+ if (owner.ns && ns && owner.ns !== ns) return false;
64
+ return isAlive(owner.pid);
65
+ }
66
+
67
+ /** The lock the running work holds, for the check before each write. */
68
+ const holding = new AsyncLocalStorage();
69
+
70
+ /**
71
+ * Throw when the work running under withFolderLock no longer holds its lock
72
+ * (another run took it over while this one was stopped), so it writes
73
+ * nothing more. Outside withFolderLock it does nothing. Call it right
74
+ * before a write.
75
+ */
76
+ export function stillHolds() {
77
+ const h =
78
+ /** @type {{ownerFile: string, same: (o: any) => boolean} | undefined} */ (
79
+ holding.getStore()
80
+ );
81
+ if (!h || h.same(readOwner(h.ownerFile))) return;
82
+ const error = /** @type {Error & {code?: string}} */ (
83
+ new Error(
84
+ 'another command took over the lock while this one was stopped, so this one writes nothing more',
85
+ )
86
+ );
87
+ error.code = 'ERR_LOCK_LOST';
88
+ throw error;
89
+ }
90
+
91
+ /** The lock folders this process holds now. */
92
+ const HELD = new Set();
93
+
94
+ /** @param {number} ms */
95
+ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
96
+
97
+ /** @param {string} file @returns {any} */
98
+ const readOwner = file => {
99
+ try {
100
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
101
+ } catch {
102
+ return null;
103
+ }
104
+ };
105
+
106
+ /**
107
+ * Run `fn` holding the lock folder `lockDir`. A run waits while another
108
+ * holds it; the wait starts again each time the lock changes hands, and
109
+ * `onBusy` is called (it throws) when one holder keeps it longer than
110
+ * `waitMs`. The lock is renewed while `fn` runs.
111
+ * @template T
112
+ * @param {string} lockDir
113
+ * @param {() => Promise<T>} fn
114
+ * @param {{waitMs?: number, onBusy: (owner: any, heldSeconds: number | null) => never}} options
115
+ * @returns {Promise<T>}
116
+ */
117
+ export async function withFolderLock(lockDir, fn, {waitMs = 30_000, onBusy}) {
118
+ const ownerFile = path.join(lockDir, 'owner.json');
119
+ /** @returns {number | null} seconds since the holder took the lock */
120
+ const held = () => {
121
+ const at = readOwner(ownerFile)?.at;
122
+ return typeof at === 'number'
123
+ ? Math.max(0, Math.round((Date.now() - at) / 1000))
124
+ : null;
125
+ };
126
+ // A holder is its process, computer and the moment it took the lock: a
127
+ // new holder with the same process id (another container) is a new one.
128
+ const holderOf = () => {
129
+ const o = readOwner(ownerFile);
130
+ return JSON.stringify([o?.pid ?? null, o?.host ?? null, o?.at ?? null]);
131
+ };
132
+ let holder = holderOf();
133
+ // A holder renews its record every LEASE_RENEW_MS. One whose record has
134
+ // not changed for three of those, as this run sees it, has stopped,
135
+ // whatever computer or process id it names (pid 1 in a container, a
136
+ // computer whose processes this run cannot check).
137
+ for (let waited = 0; !tryLock(lockDir, {leased: true}); waited += 50) {
138
+ // The release cache's own judge of silence (what this process saw of
139
+ // the record), with the editor's shorter window. The lock is judged by
140
+ // its identity on disk, so the one moved aside is the one judged.
141
+ const judged = lockIdentity(lockDir);
142
+ if (
143
+ judged &&
144
+ foreignLockIsSilent(lockDir, Date.now(), SILENT_MS) &&
145
+ !aliveHere(readOwner(ownerFile))
146
+ ) {
147
+ takeOver(lockDir, judged);
148
+ continue;
149
+ }
150
+ const now = holderOf();
151
+ if (now !== holder) {
152
+ holder = now;
153
+ waited = 0;
154
+ }
155
+ if (waited > waitMs) onBusy(readOwner(ownerFile), held());
156
+ await sleep(50);
157
+ }
158
+ HELD.add(lockDir);
159
+ const mine = readOwner(ownerFile);
160
+ const same = (/** @type {any} */ o) =>
161
+ o != null &&
162
+ mine != null &&
163
+ o.pid === mine.pid &&
164
+ o.host === mine.host &&
165
+ o.at === mine.at;
166
+ // The lease: renewed while held, so a waiting run on another computer
167
+ // sees it change and never takes it over.
168
+ const lease = setInterval(() => {
169
+ if (same(readOwner(ownerFile))) renewLock(lockDir);
170
+ }, LEASE_RENEW_MS);
171
+ lease.unref();
172
+ // Only this run's own lock is removed, never one another took over.
173
+ const release = () => {
174
+ try {
175
+ if (same(readOwner(ownerFile)))
176
+ fs.rmSync(lockDir, {recursive: true, force: true});
177
+ } catch {
178
+ // Gone already.
179
+ }
180
+ };
181
+ // Stopped by a signal, the lock still goes.
182
+ const onSignal = (/** @type {NodeJS.Signals} */ sig) => {
183
+ release();
184
+ process.kill(process.pid, sig);
185
+ };
186
+ process.once('exit', release);
187
+ process.once('SIGINT', onSignal);
188
+ process.once('SIGTERM', onSignal);
189
+ try {
190
+ return await holding.run({ownerFile, same}, fn);
191
+ } finally {
192
+ clearInterval(lease);
193
+ release();
194
+ HELD.delete(lockDir);
195
+ process.removeListener('exit', release);
196
+ process.removeListener('SIGINT', onSignal);
197
+ process.removeListener('SIGTERM', onSignal);
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Whether this process holds a lock folder now.
203
+ * @param {string} lockDir
204
+ */
205
+ export const holdsFolderLock = lockDir => HELD.has(lockDir);
@@ -12,9 +12,10 @@ export function renewLock(lockDir: string): void;
12
12
  * not changed for `LEASE_SILENCE_MS` of this process's own observation.
13
13
  * @param {string} lockDir
14
14
  * @param {number} [now]
15
+ * @param {number} [window] how long the record must stand unchanged (default `LEASE_SILENCE_MS`)
15
16
  * @returns {boolean}
16
17
  */
17
- export function foreignLockIsSilent(lockDir: string, now?: number): boolean;
18
+ export function foreignLockIsSilent(lockDir: string, now?: number, window?: number): boolean;
18
19
  /** Forget what this process observed (tests). */
19
20
  export function forgetObservedLocks(): void;
20
21
  /** How often the holder renews its record while the package manager works. */
@@ -57,9 +57,14 @@ const observed = new Map();
57
57
  * not changed for `LEASE_SILENCE_MS` of this process's own observation.
58
58
  * @param {string} lockDir
59
59
  * @param {number} [now]
60
+ * @param {number} [window] how long the record must stand unchanged (default `LEASE_SILENCE_MS`)
60
61
  * @returns {boolean}
61
62
  */
62
- export function foreignLockIsSilent(lockDir, now = Date.now()) {
63
+ export function foreignLockIsSilent(
64
+ lockDir,
65
+ now = Date.now(),
66
+ window = LEASE_SILENCE_MS,
67
+ ) {
63
68
  let text;
64
69
  try {
65
70
  text = fs.readFileSync(path.join(lockDir, 'owner.json'), 'utf-8');
@@ -71,7 +76,7 @@ export function foreignLockIsSilent(lockDir, now = Date.now()) {
71
76
  observed.set(lockDir, {text, since: now});
72
77
  return false;
73
78
  }
74
- return now - seen.since >= LEASE_SILENCE_MS;
79
+ return now - seen.since >= window;
75
80
  }
76
81
 
77
82
  /** Forget what this process observed (tests). */
@@ -332,7 +332,7 @@ export const doc = {
332
332
  value: 'ERR_RENDER_FAILED',
333
333
  stability: 'experimental',
334
334
  description:
335
- 'The page threw while rendering, or Node crashed while it rendered the page. Nothing was written. Raised only by the experimental render command.',
335
+ "The page threw while rendering, or Node crashed while it rendered the page. Raised by the experimental render command, which then writes nothing, and by the experimental theme editor when it cannot render a theme's pages (two copies of React, a component that throws, or a render past its time limit; the theme it built is kept, and the refusal says so). A React that is not installed is ERR_RENDER_MISSING_DEPENDENCY.",
336
336
  },
337
337
  {
338
338
  value: 'ERR_RENDER_NOT_ASTRYX',
@@ -117,13 +117,13 @@ export const doc = {
117
117
  value: 'themeEdit.new',
118
118
  stability: 'experimental',
119
119
  description:
120
- 'A theme made by `experimental theme editor new`: `theme`, `like` (the built-in theme it builds on, or null), the `files` written (settings, source, css, module), the dial `settings` it started with, font `notes`, contrast `problems`, the `preview` page, and any `pictures` (with `pictureProblem` when none could be taken). Experimental: may change or be removed in a patch release.',
120
+ 'A theme made by `experimental theme editor new`: `theme`, `like` (the built-in theme it builds on, or null), the `files` written (settings, source, css, module), the dial `settings` it started with, font `notes`, contrast `problems`, the `preview` page, and any `pictures` (with `pictureProblem` when none could be taken), and `sheetStale` when a sheet.html left in the folder shows an older look. Experimental: may change or be removed in a patch release.',
121
121
  },
122
122
  {
123
123
  value: 'themeEdit.set',
124
124
  stability: 'experimental',
125
125
  description:
126
- 'One checked change written: the `setting`, the one it `replaced`, `was` (for base and mode), the `parts` and `group` it styles, resolved `changedTokens`, part styles written (`styled`), part settings a dial `kept`, newly `lifted` variant keys, `notes`, contrast `problems`, build `warnings`, the `preview` page and any `pictures`. Experimental: may change or be removed in a patch release.',
126
+ 'One checked change written: the `setting`, the one it `replaced`, `was` (for base and mode), the `parts` and `group` it styles, resolved `changedTokens`, part styles written (`styled`), part settings a dial `kept`, newly `lifted` variant keys, `notes`, contrast `problems`, build `warnings`, the `preview` page and any `pictures`, and `sheetStale` when sheet.html (made by `show`) still shows the theme as it was before. Experimental: may change or be removed in a patch release.',
127
127
  },
128
128
  {
129
129
  value: 'themeEdit.show',
@@ -135,7 +135,7 @@ export const doc = {
135
135
  value: 'themeEdit.undo',
136
136
  stability: 'experimental',
137
137
  description:
138
- "An undo. One step back (`action` `step`): what was `undone`, the `settings` count now, the `stepsLeft`, the `preview` page and any `pictures`. One setting removed (`action` `undo`): the same fields as `themeEdit.set`, with `setting` and `removed` both naming the setting removed, and `now` saying what applies instead (a whole-theme setting of the same thing, or the base theme's value; `changedTokens` lists the values). Experimental: may change or be removed in a patch release.",
138
+ "An undo. One step back (`action` `step`): what was `undone`, the `settings` count now, the `stepsLeft`, the `preview` page, any `pictures`, and `sheetStale` when sheet.html still shows the theme as it was. One setting removed (`action` `undo`): the same fields as `themeEdit.set`, with `setting` and `removed` both naming the setting removed, and `now` saying what applies instead (a whole-theme setting of the same thing, or the base theme's value; `changedTokens` lists the values). Experimental: may change or be removed in a patch release.",
139
139
  },
140
140
  {
141
141
  value: 'themeEdit.previewAdd',
@@ -153,7 +153,7 @@ export const doc = {
153
153
  value: 'themeEdit.previewList',
154
154
  stability: 'experimental',
155
155
  description:
156
- 'The pages of the theme preview: the route `folder` (null with no preview), the `theme`, and the `pages` (`id`, `label`). Experimental: may change or be removed in a patch release.',
156
+ 'The pages of the theme preview: the route `folder` (null with no preview), the `theme`, `themeMissing` (true when that theme is gone), the `pages` (`id`, `label`) and `notes`. Experimental: may change or be removed in a patch release.',
157
157
  },
158
158
  {
159
159
  value: 'themeEdit.previewRemove',
@@ -487,7 +487,7 @@ export const doc = {
487
487
  {
488
488
  value: 'integration.validate',
489
489
  description:
490
- 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message, next?} information beside the issues (text output marks a next note [next minor]); a note fails nothing by default, and one with next: true counts as a warning under integration check --next, fails integration check --strict --next, and fails --strict from the next minor release. Notes include invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. For the commands a topic writes, runner_command (written with a package runner), plain_command (written bare), package_manager_command (written for one package manager) and doc_token (a token that does not parse) notes each give the file, line and the token to write. A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. So are the examples a package ships: component_without_example (a published component no block shows with exampleFor and isShowcase: true, or names in alsoShowcaseFor), template_category (a category written as a path, such as components/X), showcase_not_standalone (a showcase importing server-only code or reading process.env past NODE_ENV) and template_asset_not_packed (a new URL(…, import.meta.url) asset missing, or left out by npm pack --dry-run). When npm cannot list the files, an asset no files entry can reach is still a note and any other is listed in exampleAssets ({status: checked, findings: [], unchecked}, only when it lists any) as {file, asset, reason}. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on. For the package being authored, olderCliNotes ({file, kind: template | namespace, field, message}) lists each descriptor field a CLI before 0.7.4 refuses, such as stability on a template or namespace doc; it is present only when it has entries, and is never counted or fails a check.',
490
+ 'The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning | error, message, fix?, file?, line?} (fix: the change that resolves it; file and line: where, relative to the package), and notes when there are any: {code, message, next?} information beside the issues (text output marks a next note [next minor]); a note fails nothing by default, and one with next: true counts as a warning under integration check --next, fails integration check --strict --next, and fails --strict from the next minor release. Notes include invalid_cli_command for a malformed cliCommand and cli_peer_version when the running CLI is outside the @astryxdesign/cli peer range of the package, and the package layout findings added after the last minor release, each with its fix in the message (duplicate_component_doc, symlinked_root, unreadable_file, invalid_package_json, no_provider_id, source_without_component_doc where a doc and its source still pair), and doc_name_mismatch and unknown_block_component, until they become warnings in the next minor release. For the commands a topic writes, runner_command (written with a package runner), plain_command (written bare), package_manager_command (written for one package manager) and doc_token (a token that does not parse) notes each give the file, line and the token to write. A doc_target_not_found note names a doc whose replaces or extends names no topic and no guide of the CLI docs or the docs of the package (such as a namespace), and a doc_section_unplaced note a section whose before or after names no section of what it extends (it is added at the end), and a duplicate_guide_replacement note two docs of the package that replace one guide; they become warnings in the next minor release. When the manifest loads, docTypes checks each doc against its published authoring type: status (checked | skipped), reason, typescript, docs, findings (all warnings, each naming the field and a fix), unchecked, and fixtures (test fixture docs not checked). When the manifest loads, docNames lists the component doc names it could not judge: status (checked), findings (always empty; a doc name the module its import names provably does not export is a doc_name_mismatch note, with its fix in the message) and unchecked ({file, name, reason}: a doc whose name differs from the name it is listed under and whose source exports cannot all be read, such as a re-export from another package). When the manifest loads, blockComponents lists the component names templates give in exampleFor or componentsUsed that could not be judged: status (checked), findings (always empty; a name neither the package nor Core has, and the template does not import, is an unknown_block_component note, with its fix in the message) and unchecked ({file, name, reason}: a name the template may reach through anything other than named imports and re-exports from Core, React, StyleX, local helpers or the entry of the package itself, such as an import from another package, a default or namespace import, an alias of or member read off an imported binding, require() or a dynamic import(), or a local module that cannot be read, or any name Core would have to resolve when Core is not installed). Since 0.7.3 each import apps cannot use is also a note (its fix in the message), listed only and failing --strict from the next minor. So are the examples a package ships: component_without_example (a published component no block shows with exampleFor and isShowcase: true, or names in alsoShowcaseFor), template_category (a category written as a path, such as components/X), showcase_not_standalone (a showcase importing server-only code or reading process.env past NODE_ENV) and template_asset_not_packed (a new URL(…, import.meta.url) asset missing, or left out by npm pack --dry-run). When npm cannot list the files, an asset no files entry can reach is still a note and any other is listed in exampleAssets ({status: checked, findings: [], unchecked}, only when it lists any) as {file, asset, reason}. Since 0.7.15, package_without_logo (logo.light in the integration file, or a logo.dark that is set, names no packed PNG, JPEG, WebP or shapes-only SVG of at most 512 KB in the package; package.json marketplace.logo is read when the integration file has no logo) and package_without_example (components, other than those component_without_example exempts, but no block with isShowcase: true and exampleFor, or alsoShowcaseFor; themes-, docs- or codemods-only packages need none) say what a catalog needs to list the package, as notes without next that fail no check under any flag; a logo npm cannot be asked about is listed in exampleAssets with the file that names it. publicImports ({status: checked, findings: [], unchecked}) lists each import the check could not judge as {file, specifier, reason}; never counted or failed on. For the package being authored, olderCliNotes ({file, kind: template | namespace, field, message}) lists each descriptor field a CLI before 0.7.4 refuses, such as stability on a template or namespace doc; it is present only when it has entries, and is never counted or fails a check.',
491
491
  },
492
492
  {
493
493
  value: 'integration.template-conflicts',