@smoothbricks/nx-plugin 0.7.17 → 0.7.19

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 (199) hide show
  1. package/README.md +315 -114
  2. package/dist/.build-inputs.json +47 -38
  3. package/dist/built-output-packages.js +1 -1
  4. package/dist/bun-lock-scope.d.ts +128 -20
  5. package/dist/bun-lock-scope.d.ts.map +1 -1
  6. package/dist/bun-lock-scope.js +267 -44
  7. package/dist/cargo-closure-input.d.ts +8 -6
  8. package/dist/cargo-closure-input.d.ts.map +1 -1
  9. package/dist/cargo-closure-input.js +15 -12
  10. package/dist/cargo-source-hash.d.ts +26 -25
  11. package/dist/cargo-source-hash.d.ts.map +1 -1
  12. package/dist/cargo-source-hash.js +84 -105
  13. package/dist/cargo-toolchain-paths.d.ts +2 -2
  14. package/dist/cargo-toolchain-paths.js +2 -2
  15. package/dist/cargo-workspace.d.ts +20 -2
  16. package/dist/cargo-workspace.d.ts.map +1 -1
  17. package/dist/cargo-workspace.js +43 -22
  18. package/dist/ensure-built-receipt.d.ts +3 -2
  19. package/dist/ensure-built-receipt.d.ts.map +1 -1
  20. package/dist/ensure-built-receipt.js +3 -2
  21. package/dist/eslint-config-closure.d.ts +8 -3
  22. package/dist/eslint-config-closure.d.ts.map +1 -1
  23. package/dist/eslint-config-closure.js +24 -5
  24. package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
  25. package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
  26. package/dist/executors/bounded-exec/admission-queue.js +9 -10
  27. package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
  28. package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
  29. package/dist/executors/bounded-exec/awake-clock.js +22 -0
  30. package/dist/executors/bounded-exec/bounds.d.ts +19 -6
  31. package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
  32. package/dist/executors/bounded-exec/bounds.js +22 -15
  33. package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
  34. package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
  35. package/dist/executors/bounded-exec/case-gate.js +342 -0
  36. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
  37. package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
  38. package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
  39. package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
  40. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  41. package/dist/executors/bounded-exec/cpu-pool.js +102 -16
  42. package/dist/executors/bounded-exec/cpu-rise.d.ts +73 -0
  43. package/dist/executors/bounded-exec/cpu-rise.d.ts.map +1 -0
  44. package/dist/executors/bounded-exec/cpu-rise.js +111 -0
  45. package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
  46. package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
  47. package/dist/executors/bounded-exec/endpoint-life.js +228 -0
  48. package/dist/executors/bounded-exec/executor.d.ts +1 -1
  49. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  50. package/dist/executors/bounded-exec/executor.js +256 -86
  51. package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
  52. package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
  53. package/dist/executors/bounded-exec/gateway-lease.js +8 -1
  54. package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
  55. package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
  56. package/dist/executors/bounded-exec/go-run-summary.js +98 -0
  57. package/dist/executors/bounded-exec/hang-diagnostics.d.ts +11 -3
  58. package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
  59. package/dist/executors/bounded-exec/hang-diagnostics.js +125 -47
  60. package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
  61. package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
  62. package/dist/executors/bounded-exec/lease-wait.js +1 -0
  63. package/dist/executors/bounded-exec/mbx-pool.d.ts +42 -7
  64. package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
  65. package/dist/executors/bounded-exec/mbx-pool.js +45 -8
  66. package/dist/executors/bounded-exec/mbx-reservations.d.ts +12 -6
  67. package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
  68. package/dist/executors/bounded-exec/mbx-reservations.js +190 -284
  69. package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
  70. package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
  71. package/dist/executors/bounded-exec/parent-grant.js +1 -0
  72. package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
  73. package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
  74. package/dist/executors/bounded-exec/pool-admission.js +47 -1
  75. package/dist/executors/bounded-exec/progress-channel.d.ts +38 -0
  76. package/dist/executors/bounded-exec/progress-channel.d.ts.map +1 -0
  77. package/dist/executors/bounded-exec/progress-channel.js +113 -0
  78. package/dist/executors/bounded-exec/progress.d.ts +5 -1
  79. package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
  80. package/dist/executors/bounded-exec/progress.js +31 -1
  81. package/dist/executors/bounded-exec/ram-temp.d.ts +24 -1
  82. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  83. package/dist/executors/bounded-exec/ram-temp.js +123 -16
  84. package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
  85. package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
  86. package/dist/executors/bounded-exec/reservation-connection.js +248 -0
  87. package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
  88. package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
  89. package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
  90. package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
  91. package/dist/executors/bounded-exec/runner-sizing.js +13 -9
  92. package/dist/executors/bounded-exec/schema.d.ts +7 -2
  93. package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
  94. package/dist/executors/bounded-exec/schema.js +17 -1
  95. package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
  96. package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
  97. package/dist/executors/bounded-exec/suite-minimum.js +85 -0
  98. package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
  99. package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
  100. package/dist/executors/bounded-exec/test-result-writer.js +1 -0
  101. package/dist/executors/bounded-exec/test-results.d.ts +5 -0
  102. package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
  103. package/dist/executors/bounded-exec/test-results.js +2 -2
  104. package/dist/executors/bounded-exec/verdict.d.ts +39 -10
  105. package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
  106. package/dist/executors/bounded-exec/verdict.js +60 -14
  107. package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
  108. package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
  109. package/dist/executors/cargo-zigbuild/executor.js +32 -19
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +294 -152
  112. package/dist/managed-files/ci-workflow.d.ts +4 -1
  113. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  114. package/dist/managed-files/ci-workflow.js +9 -14
  115. package/dist/managed-files/files.d.ts +3 -3
  116. package/dist/managed-files/files.js +3 -3
  117. package/dist/managed-files/generator.d.ts +5 -1
  118. package/dist/managed-files/generator.d.ts.map +1 -1
  119. package/dist/managed-files/generator.js +22 -7
  120. package/dist/managed-files/render-memo.d.ts +13 -0
  121. package/dist/managed-files/render-memo.d.ts.map +1 -0
  122. package/dist/managed-files/render-memo.js +94 -0
  123. package/dist/task-results.js +2 -1
  124. package/dist/test-program.d.ts +11 -6
  125. package/dist/test-program.d.ts.map +1 -1
  126. package/dist/test-program.js +39 -35
  127. package/dist/tool-bins.d.ts +12 -0
  128. package/dist/tool-bins.d.ts.map +1 -1
  129. package/dist/tool-bins.js +31 -6
  130. package/dist/typecheck-test-policy.d.ts +10 -1
  131. package/dist/typecheck-test-policy.d.ts.map +1 -1
  132. package/dist/typecheck-test-policy.js +40 -24
  133. package/dist/workspace-config-policy.d.ts.map +1 -1
  134. package/dist/workspace-config-policy.js +135 -42
  135. package/dist/workspace-index.d.ts +14 -1
  136. package/dist/workspace-index.d.ts.map +1 -1
  137. package/dist/workspace-index.js +36 -4
  138. package/executors.json +2 -0
  139. package/managed/raw/envrc +24 -0
  140. package/managed/raw/patches/nx@24.0.3.patch +1851 -221
  141. package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
  142. package/managed/raw/tooling/direnv/developer-links.ts +122 -14
  143. package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
  144. package/managed/templates/github/actions/save-nix-devenv/action.yml +19 -1
  145. package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
  146. package/package.json +68 -11
  147. package/runtime/nx-publish/.build-inputs.json +2 -2
  148. package/runtime/nx-publish/cache_adapter.js +293 -3
  149. package/runtime/nx-publish/nx_publish.js +36 -14
  150. package/src/built-output-packages.ts +1 -1
  151. package/src/bun-lock-scope.ts +293 -40
  152. package/src/cargo-closure-input.ts +20 -12
  153. package/src/cargo-source-hash.ts +119 -145
  154. package/src/cargo-toolchain-paths.ts +2 -2
  155. package/src/cargo-workspace.ts +59 -21
  156. package/src/ensure-built-receipt.ts +3 -2
  157. package/src/eslint-config-closure.ts +27 -6
  158. package/src/executors/bounded-exec/admission-queue.ts +11 -10
  159. package/src/executors/bounded-exec/awake-clock.ts +20 -0
  160. package/src/executors/bounded-exec/bounds.ts +41 -19
  161. package/src/executors/bounded-exec/case-gate.ts +365 -0
  162. package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
  163. package/src/executors/bounded-exec/cpu-pool.ts +139 -12
  164. package/src/executors/bounded-exec/cpu-rise.ts +156 -0
  165. package/src/executors/bounded-exec/endpoint-life.ts +279 -0
  166. package/src/executors/bounded-exec/executor.ts +341 -123
  167. package/src/executors/bounded-exec/gateway-lease.ts +6 -0
  168. package/src/executors/bounded-exec/go-run-summary.ts +137 -0
  169. package/src/executors/bounded-exec/hang-diagnostics.ts +150 -50
  170. package/src/executors/bounded-exec/lease-wait.ts +1 -0
  171. package/src/executors/bounded-exec/mbx-pool.ts +57 -9
  172. package/src/executors/bounded-exec/mbx-reservations.ts +216 -183
  173. package/src/executors/bounded-exec/parent-grant.ts +3 -0
  174. package/src/executors/bounded-exec/pool-admission.ts +59 -2
  175. package/src/executors/bounded-exec/progress-channel.ts +129 -0
  176. package/src/executors/bounded-exec/progress.ts +39 -3
  177. package/src/executors/bounded-exec/ram-temp.ts +137 -17
  178. package/src/executors/bounded-exec/reservation-connection.ts +221 -0
  179. package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
  180. package/src/executors/bounded-exec/runner-sizing.ts +13 -8
  181. package/src/executors/bounded-exec/schema.json +1 -1
  182. package/src/executors/bounded-exec/schema.ts +21 -2
  183. package/src/executors/bounded-exec/suite-minimum.ts +81 -0
  184. package/src/executors/bounded-exec/test-result-writer.ts +3 -0
  185. package/src/executors/bounded-exec/test-results.ts +5 -0
  186. package/src/executors/bounded-exec/verdict.ts +83 -22
  187. package/src/executors/cargo-zigbuild/executor.ts +30 -19
  188. package/src/index.ts +357 -166
  189. package/src/managed-files/ci-workflow.ts +13 -17
  190. package/src/managed-files/files.ts +3 -3
  191. package/src/managed-files/generator.ts +21 -6
  192. package/src/managed-files/render-memo.ts +135 -0
  193. package/src/test-program.ts +36 -41
  194. package/src/tool-bins.ts +35 -6
  195. package/src/typecheck-test-policy.ts +49 -24
  196. package/src/workspace-config-policy.ts +161 -43
  197. package/src/workspace-index.ts +40 -5
  198. package/test-timings.json +157 -141
  199. package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
@@ -8,17 +8,25 @@ import { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-depe
8
8
  *
9
9
  * A lock-scope node is the part of bun.lock one manifest reaches: what the
10
10
  * package can load. Its edges go to the npm nodes the manifest's dependencies
11
- * resolve to; a member's also go to the node of each workspace member it
12
- * depends on and to the root's, since a member's `node_modules` lookup ends in
13
- * the root's. The root's node has no member edges: every member reaches it, so
14
- * one would key every member on the packages of whichever members the root
15
- * manifest lists, which a member loads only through its own declaration (or an
16
- * import Nx turns into a project edge, which a `^` input follows). Nx's
17
- * lockfile parser links each npm node to the packages it depends on, so a
18
- * target naming a node in its `externalDependencies` is keyed on every package
19
- * of that closure by the hash bun.lock records for it, and on nothing else in
20
- * the lockfile. That replaces bun.lock as a file input: a lockfile edit re-keys
21
- * the tasks that can load what changed.
11
+ * resolve to and to the node of each workspace member it depends on, the
12
+ * root's manifest included. Nx's lockfile parser links each versioned npm node
13
+ * to the packages it depends on, and the plugin links each unversioned alias
14
+ * to its versioned node ({@link bunVersionAliasDependencies}), so a target naming a node in its
15
+ * `externalDependencies` is keyed on every package of that closure by the hash
16
+ * bun.lock records for it, and on nothing else in the lockfile. That replaces
17
+ * bun.lock as a file input: a lockfile edit re-keys the tasks that can load
18
+ * what changed.
19
+ *
20
+ * A member's node has no edge to the root's. Bun's isolated linker links into
21
+ * a directory's `node_modules` exactly the packages its manifest declares, but
22
+ * Node's lookup from a member continues into the root's `node_modules`, so a
23
+ * member can load any package the root declares. Two rules keep the member's
24
+ * own closure the whole of what it loads: a source import of a package outside
25
+ * that closure refuses the graph ({@link undeclaredImports}), and a tool a
26
+ * target runs names each package it loads by name from a directory by the
27
+ * scope that declares it ({@link bunLoadInput}). The root's own tooling (Nx
28
+ * plugins and generators, release and mutation tooling) then keys only the
29
+ * tasks that load it.
22
30
  *
23
31
  * The nodes carry no content of their own; Nx hashes a node's version and the
24
32
  * nodes it reaches.
@@ -28,8 +36,15 @@ export const BUN_LOCK_NODE_PREFIX = 'bun-lock:';
28
36
  export function bunLockNodeName(projectRoot) {
29
37
  return `${BUN_LOCK_NODE_PREFIX}${posix.normalize(projectRoot === '' ? '.' : projectRoot)}`;
30
38
  }
31
- /** The node of the workspace root manifest, which every member's node reaches. */
39
+ /** The node of the workspace root manifest. */
32
40
  export const BUN_ROOT_LOCK_NODE = bunLockNodeName('.');
41
+ /**
42
+ * The named input every `package.json` project defines as its own lock-scope
43
+ * input. `externalDependencies` takes no `{projectRoot}` token, so a
44
+ * workspace-wide named input or target default names this to key each
45
+ * project's targets on its own manifest's closure.
46
+ */
47
+ export const BUN_LOCK_SCOPE_NAMED_INPUT = 'bunLockScope';
33
48
  /** The input that keys a target on the bun.lock entries its project's manifest reaches. */
34
49
  export function bunLockInput(projectRoot) {
35
50
  return { externalDependencies: [bunLockNodeName(projectRoot)] };
@@ -39,16 +54,51 @@ export function bunLockNode(projectRoot) {
39
54
  const name = bunLockNodeName(projectRoot);
40
55
  return { type: 'bun', name, data: { packageName: name, version: '0.0.0' } };
41
56
  }
57
+ /**
58
+ * Every bun runtime-scope node's name starts with this; the rest is a project
59
+ * root. It is the part of bun.lock a dependent loads through that package: the
60
+ * closure of its `dependencies`, `optionalDependencies` and
61
+ * `peerDependencies`. A package's devDependencies are installed for its own
62
+ * targets only, so a dependent's lock-scope node reaches the runtime node of
63
+ * each member it declares, never that member's own node.
64
+ */
65
+ export const BUN_LOCK_RUNTIME_NODE_PREFIX = 'bun-lock-runtime:';
66
+ /** The runtime-scope node of the project at `projectRoot`. */
67
+ export function bunLockRuntimeNodeName(projectRoot) {
68
+ return `${BUN_LOCK_RUNTIME_NODE_PREFIX}${posix.normalize(projectRoot === '' ? '.' : projectRoot)}`;
69
+ }
70
+ /** The runtime-scope node itself, published by its project beside its lock-scope node. */
71
+ export function bunLockRuntimeNode(projectRoot) {
72
+ const name = bunLockRuntimeNodeName(projectRoot);
73
+ return { type: 'bun', name, data: { packageName: name, version: '0.0.0' } };
74
+ }
42
75
  /** The manifest sections Nx reads a project's package dependencies from, in the order it lets them override. */
43
76
  const DEPENDENCY_SECTIONS = ['optionalDependencies', 'peerDependencies', 'devDependencies', 'dependencies'];
77
+ /** The sections a dependent loads through a package: all but its devDependencies. */
78
+ const RUNTIME_SECTIONS = ['optionalDependencies', 'peerDependencies', 'dependencies'];
79
+ /** Each package a manifest declares in `sections`, with the specifier of the section Nx lets win. */
80
+ function declaredSpecifiers(manifest, sections = DEPENDENCY_SECTIONS) {
81
+ const specifiers = new Map();
82
+ for (const section of sections) {
83
+ const declared = manifest[section];
84
+ if (typeof declared !== 'object' || declared === null)
85
+ continue;
86
+ for (const [name, specifier] of Object.entries(declared)) {
87
+ if (typeof specifier === 'string')
88
+ specifiers.set(name, specifier);
89
+ }
90
+ }
91
+ return specifiers;
92
+ }
44
93
  /**
45
- * The edges of every published bun lock-scope node. A manifest's dependencies
46
- * are resolved exactly as Nx resolves a project's own package edges
47
- * (`buildExplicitPackageJsonDependencies`, one `TargetProjectLocator` over
48
- * the same projects and lockfile nodes): an installed package becomes an edge
49
- * to its npm node, a workspace member (outside the root manifest) an edge to
50
- * that member's node, and a package that resolves to no node is skipped
51
- * exactly as Nx skips it.
94
+ * The edges of every published bun lock-scope and runtime-scope node. A
95
+ * manifest's dependencies are resolved exactly as Nx resolves a project's own
96
+ * package edges (`buildExplicitPackageJsonDependencies`, one
97
+ * `TargetProjectLocator` over the same projects and lockfile nodes): an
98
+ * installed package becomes an edge to its npm node, a workspace member an
99
+ * edge to that member's runtime node, and a package that resolves to no node
100
+ * is skipped exactly as Nx skips it. The lock-scope node takes every section,
101
+ * the runtime node all but devDependencies.
52
102
  */
53
103
  export function bunLockDependencies(context) {
54
104
  const externalNodes = context.externalNodes ?? {};
@@ -57,41 +107,214 @@ export function bunLockDependencies(context) {
57
107
  nodes[name] = { name, type: data.projectType === 'application' ? 'app' : 'lib', data };
58
108
  }
59
109
  const locator = new TargetProjectLocator(nodes, externalNodes);
60
- const nodeOfMember = (member) => {
61
- const root = context.projects[member]?.root;
62
- return root === undefined ? null : bunLockNodeName(root);
63
- };
64
110
  const dependencies = [];
65
111
  for (const project of Object.values(context.projects).sort((left, right) => left.root < right.root ? -1 : left.root > right.root ? 1 : 0)) {
66
- const source = bunLockNodeName(project.root);
67
- if (externalNodes[source] === undefined)
68
- continue;
69
112
  const manifestPath = posix.join(project.root, 'package.json');
70
113
  if (!existsSync(join(context.workspaceRoot, manifestPath)))
71
114
  continue;
72
115
  const manifest = readJsonFile(join(context.workspaceRoot, manifestPath));
73
- const specifiers = new Map();
74
- for (const section of DEPENDENCY_SECTIONS) {
75
- const declared = manifest[section];
76
- if (typeof declared !== 'object' || declared === null)
116
+ for (const [source, sections] of [
117
+ [bunLockNodeName(project.root), DEPENDENCY_SECTIONS],
118
+ [bunLockRuntimeNodeName(project.root), RUNTIME_SECTIONS],
119
+ ]) {
120
+ if (externalNodes[source] === undefined)
77
121
  continue;
78
- for (const [name, specifier] of Object.entries(declared)) {
79
- if (typeof specifier === 'string')
80
- specifiers.set(name, specifier);
122
+ const targets = new Set();
123
+ for (const [name, specifier] of declaredSpecifiers(manifest, sections)) {
124
+ const member = locator.findDependencyInWorkspaceProjects(manifestPath, name, specifier);
125
+ const memberRoot = member === null ? undefined : context.projects[member]?.root;
126
+ const target = member === null
127
+ ? locator.findNpmProjectFromImport(name, manifestPath)
128
+ : memberRoot === undefined
129
+ ? null
130
+ : bunLockRuntimeNodeName(memberRoot);
131
+ if (target !== null && target !== source && externalNodes[target] !== undefined)
132
+ targets.add(target);
133
+ }
134
+ for (const target of [...targets].sort()) {
135
+ dependencies.push({ source, target, type: DependencyType.static });
81
136
  }
82
137
  }
83
- const targets = new Set(source === BUN_ROOT_LOCK_NODE ? [] : [BUN_ROOT_LOCK_NODE]);
84
- for (const [name, specifier] of specifiers) {
85
- const member = locator.findDependencyInWorkspaceProjects(manifestPath, name, specifier);
86
- if (member !== null && source === BUN_ROOT_LOCK_NODE)
87
- continue;
88
- const target = member === null ? locator.findNpmProjectFromImport(name, manifestPath) : nodeOfMember(member);
89
- if (target !== null && target !== source && externalNodes[target] !== undefined)
90
- targets.add(target);
138
+ }
139
+ return dependencies;
140
+ }
141
+ /** The package a bare specifier names: its scope and name, without the subpath. */
142
+ export function specifierPackage(specifier) {
143
+ const parts = specifier.split('/');
144
+ return (specifier.startsWith('@') ? parts.slice(0, 2) : parts.slice(0, 1)).join('/');
145
+ }
146
+ /** The manifests at and above the workspace-relative `directory`, nearest first, ending with the root's. */
147
+ export function manifestsAbove(workspaceRoot, directory) {
148
+ const manifests = [];
149
+ for (let current = posix.normalize(directory === '' ? '.' : directory);; current = posix.dirname(current)) {
150
+ const path = join(workspaceRoot, current, 'package.json');
151
+ if (existsSync(path)) {
152
+ manifests.push({ root: current, declared: new Set(declaredSpecifiers(readJsonFile(path)).keys()) });
91
153
  }
92
- for (const target of [...targets].sort()) {
93
- dependencies.push({ source, target, type: DependencyType.static });
154
+ if (current === '.')
155
+ return manifests;
156
+ }
157
+ }
158
+ /**
159
+ * The `externalDependencies` entry that keys package `name` as a process loads
160
+ * it by name from a directory, given the manifests at and above it, nearest
161
+ * first; `null` when none declares it, so nothing on that path loads it. Node's
162
+ * lookup walks the directory's ancestors' `node_modules`, and bun's isolated
163
+ * linker links into each exactly what its manifest declares, so the nearest
164
+ * declaring manifest decides what loads. A member's declaration is keyed by its
165
+ * lock-scope node. The root's is named by itself, and Nx keys that package's
166
+ * node and what it reaches: the root's node would key the whole of the root's
167
+ * tooling.
168
+ */
169
+ export function bunLoadScope(manifests, name) {
170
+ const declaring = manifests.find((manifest) => manifest.declared.has(name));
171
+ if (declaring === undefined)
172
+ return null;
173
+ return declaring.root === '.' ? name : bunLockNodeName(declaring.root);
174
+ }
175
+ /** The lock scope of each package load, from the manifests above its directory; sorted, each once. */
176
+ export function bunLoadScopes(workspaceRoot, loads) {
177
+ const manifests = new Map();
178
+ const scopes = new Set();
179
+ for (const { directory, name } of loads) {
180
+ let above = manifests.get(directory);
181
+ if (above === undefined) {
182
+ above = manifestsAbove(workspaceRoot, directory);
183
+ manifests.set(directory, above);
94
184
  }
185
+ const scope = bunLoadScope(above, name);
186
+ if (scope !== null)
187
+ scopes.add(scope);
95
188
  }
96
- return dependencies;
189
+ return [...scopes].sort();
190
+ }
191
+ /** A target's one `externalDependencies` input: its project's lock-scope node first, then each other scope once, sorted. */
192
+ export function bunScopeInput(projectRoot, ...scopes) {
193
+ const own = bunLockNodeName(projectRoot);
194
+ return { externalDependencies: [own, ...[...new Set(scopes.flat())].filter((scope) => scope !== own).sort()] };
195
+ }
196
+ /** The input keying every package of `names` a process loads by name from the directory `manifests` stand above. */
197
+ export function bunLoadInput(manifests, names) {
198
+ const scopes = new Set();
199
+ for (const name of names) {
200
+ const scope = bunLoadScope(manifests, name);
201
+ if (scope !== null)
202
+ scopes.add(scope);
203
+ }
204
+ return { externalDependencies: [...scopes].sort() };
205
+ }
206
+ /**
207
+ * The packages a TypeScript compile in a directory loads by name beyond its
208
+ * sources' imports: every `@types` package a manifest at or above it declares
209
+ * (TypeScript includes each ancestor's `node_modules/@types` unless the config
210
+ * lists `types`, a narrower set), and the `tslib` an `importHelpers` compile
211
+ * resolves.
212
+ */
213
+ export function typescriptLoads(manifests) {
214
+ const names = new Set(['tslib']);
215
+ for (const manifest of manifests) {
216
+ for (const name of manifest.declared) {
217
+ if (name.startsWith('@types/'))
218
+ names.add(name);
219
+ }
220
+ }
221
+ return [...names].sort();
222
+ }
223
+ /**
224
+ * The npm packages each workspace member's sources import (Nx's own `static`
225
+ * and `dynamic` edges) that its lock-scope node does not reach. Node loads such
226
+ * a package through an ancestor's `node_modules`, the root's, and the
227
+ * project's targets, keyed on the member's own closure, would miss it. The
228
+ * root's project is exempt: its node reaches everything its manifest declares.
229
+ * So is a `@types` package: TypeScript loads it by ancestry, not Node, and
230
+ * every TypeScript target keys the `@types` the manifests above it declare
231
+ * ({@link typescriptLoads}). A package is compared by name and version, never
232
+ * by node name: Nx publishes a hoisted package as both `npm:<name>` and
233
+ * `npm:<name>@<version>`, and its locator resolves a declaration and an
234
+ * import to either ({@link bunVersionAliasDependencies}).
235
+ */
236
+ export function undeclaredImports(graph) {
237
+ const externalNodes = graph.externalNodes ?? {};
238
+ const identity = (name) => {
239
+ const node = externalNodes[name];
240
+ return node?.type === 'npm' ? `${node.data.packageName}@${node.data.version}` : null;
241
+ };
242
+ const namesOf = new Map();
243
+ for (const name of Object.keys(externalNodes)) {
244
+ const key = identity(name);
245
+ if (key !== null)
246
+ namesOf.set(key, [...(namesOf.get(key) ?? []), name]);
247
+ }
248
+ const findings = [];
249
+ for (const [project, node] of Object.entries(graph.nodes).sort(([left], [right]) => (left < right ? -1 : 1))) {
250
+ const scope = bunLockNodeName(node.data.root);
251
+ if (scope === BUN_ROOT_LOCK_NODE || externalNodes[scope] === undefined)
252
+ continue;
253
+ const reached = new Set();
254
+ for (let pending = [scope]; pending.length > 0;) {
255
+ const next = [];
256
+ for (const name of pending) {
257
+ if (reached.has(name))
258
+ continue;
259
+ reached.add(name);
260
+ for (const edge of graph.dependencies[name] ?? [])
261
+ next.push(edge.target);
262
+ const key = identity(name);
263
+ if (key !== null)
264
+ next.push(...(namesOf.get(key) ?? []));
265
+ }
266
+ pending = next;
267
+ }
268
+ const missing = new Set();
269
+ for (const edge of graph.dependencies[project] ?? []) {
270
+ if (edge.type === DependencyType.implicit)
271
+ continue;
272
+ const external = externalNodes[edge.target];
273
+ if (external === undefined || external.type !== 'npm' || reached.has(edge.target))
274
+ continue;
275
+ if (external.data.packageName.startsWith('@types/'))
276
+ continue;
277
+ missing.add(external.data.packageName);
278
+ }
279
+ for (const packageName of [...missing].sort())
280
+ findings.push({ project, root: node.data.root, packageName });
281
+ }
282
+ return findings;
283
+ }
284
+ /**
285
+ * An edge from each unversioned npm node to the versioned node of the same
286
+ * package and version. Nx's bun lockfile parser publishes a hoisted package as
287
+ * both `npm:<name>` and `npm:<name>@<version>`, with one integrity, and links
288
+ * only the versioned node to the package's dependencies. A key on the
289
+ * unversioned node (an `externalDependencies` entry naming a package, or a
290
+ * lock-scope edge the locator resolved to it) then held the package's own
291
+ * integrity and none of its closure; through this edge it holds both.
292
+ */
293
+ export function bunVersionAliasDependencies(externalNodes) {
294
+ const dependencies = [];
295
+ for (const [name, node] of Object.entries(externalNodes)) {
296
+ if (node.type !== 'npm')
297
+ continue;
298
+ const target = `npm:${node.data.packageName}@${node.data.version}`;
299
+ const versioned = externalNodes[target];
300
+ if (target === name || versioned?.type !== 'npm' || versioned.data.version !== node.data.version)
301
+ continue;
302
+ dependencies.push({ source: name, target, type: DependencyType.static });
303
+ }
304
+ return dependencies.sort((left, right) => (left.source < right.source ? -1 : left.source > right.source ? 1 : 0));
305
+ }
306
+ export class UndeclaredImportError extends Error {
307
+ findings;
308
+ constructor(findings) {
309
+ super('Workspace members import packages their package.json does not declare. Node loads each through the root' +
310
+ "'s node_modules, and no lock-scope node of the member keys it; declare each in the member's package.json:\n" +
311
+ findings.map(({ project, root, packageName }) => ` ${project} (${root}): ${packageName}`).join('\n'));
312
+ this.findings = findings;
313
+ this.name = 'UndeclaredImportError';
314
+ }
315
+ }
316
+ export function refuseUndeclaredImports(graph) {
317
+ const findings = undeclaredImports(graph);
318
+ if (findings.length > 0)
319
+ throw new UndeclaredImportError(findings);
97
320
  }
@@ -1,5 +1,5 @@
1
1
  import type { ProjectGraphExternalNode, TargetConfiguration } from 'nx/src/devkit-exports.js';
2
- import { type CargoResolve, type CompiledCargoInput } from './cargo-source-hash.js';
2
+ import { type CargoResolve, type CargoSourceIndex, type CompiledCargoInput } from './cargo-source-hash.js';
3
3
  /**
4
4
  * The named input the plugin infers for every project with crates of a Cargo
5
5
  * workspace under its root: the mutable sources of the Cargo-resolved
@@ -32,20 +32,22 @@ export interface CargoClosureSource {
32
32
  readonly cargo: CargoResolve;
33
33
  /** Every `Cargo.toml` in Nx's file index, relative to the workspace root. */
34
34
  readonly indexed: ReadonlySet<string>;
35
+ /** The Rust sources and packages of Nx's file index the compiled-in scan reads. */
36
+ readonly sources: CargoSourceIndex;
35
37
  readonly compiledFilesCache: Map<string, CompiledCargoInput[]>;
36
38
  }
37
39
  /**
38
- * Every `Cargo.toml` Nx's workspace file index holds: .gitignore and .nxignore
39
- * applied, `node_modules` never entered. A package whose manifest is missing
40
- * here has no files a fileset input can hash.
40
+ * The Cargo manifests and Rust sources of Nx's workspace file index, with Nx's content hash of each source:
41
+ * .gitignore and .nxignore applied, `node_modules` never entered. A package whose manifest is missing here has no
42
+ * files a fileset input can hash. Scans of source texts no longer indexed are forgotten here.
41
43
  */
42
- export declare function indexedCargoManifests(workspaceRoot: string): Promise<ReadonlySet<string>>;
44
+ export declare function indexedCargoSources(workspaceRoot: string): Promise<CargoSourceIndex>;
43
45
  /**
44
46
  * Content-keyed locked offline metadata. A refusal fails graph inference:
45
47
  * a stale closure or runtime whole-workspace fallback cannot establish the
46
48
  * precise set of cache inputs.
47
49
  */
48
- export declare function resolveCargoClosureSource(manifest: string, workspaceRoot: string, indexed: Promise<ReadonlySet<string>>, compiledFilesCache: Map<string, CompiledCargoInput[]>): Promise<CargoClosureSource>;
50
+ export declare function resolveCargoClosureSource(manifest: string, workspaceRoot: string, indexed: Promise<CargoSourceIndex>, compiledFilesCache: Map<string, CompiledCargoInput[]>): Promise<CargoClosureSource>;
49
51
  /**
50
52
  * The `cargoClosure` definition for the project at `projectRoot`: for each
51
53
  * Cargo workspace with crates under it, the resolve closure of those crates,
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-closure-input.d.ts","sourceRoot":"","sources":["../src/cargo-closure-input.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE9F,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAKxB,MAAM,wBAAwB,CAAC;AAIhC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD,uGAAuG;AACvG,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,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IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAMlH"}
@@ -2,9 +2,9 @@ import { createHash } from 'node:crypto';
2
2
  import { realpath } from 'node:fs/promises';
3
3
  import { isAbsolute, join, posix, relative, sep } from 'node:path';
4
4
  import { CARGO_ANCESTOR_INPUTS } from '@smoothbricks/cargo-retain/cargo-ancestor-inputs';
5
- import { compiledInFiles, dependencyClosure, HASH_SKIPPED_DIRECTORIES, readCargoResolve, } from './cargo-source-hash.js';
5
+ import { cargoSourceIndex, compiledInFiles, dependencyClosure, HASH_SKIPPED_DIRECTORIES, readCargoResolve, retainIncludeScans, } from './cargo-source-hash.js';
6
6
  import { runtimeInput, shellWord } from './runtime-input.js';
7
- import { globIndexedFiles } from './workspace-index.js';
7
+ import { globIndexedFiles, indexedFileData } from './workspace-index.js';
8
8
  /**
9
9
  * The named input the plugin infers for every project with crates of a Cargo
10
10
  * workspace under its root: the mutable sources of the Cargo-resolved
@@ -51,12 +51,15 @@ const SKIPPED_TREES = `**/{${HASH_SKIPPED_DIRECTORIES.join(',')}}/**`;
51
51
  /** A path holding any of these would be read as a pattern, not as itself. */
52
52
  const GLOB_SYNTAX = /[*?[\]{}()!,]/;
53
53
  /**
54
- * Every `Cargo.toml` Nx's workspace file index holds: .gitignore and .nxignore
55
- * applied, `node_modules` never entered. A package whose manifest is missing
56
- * here has no files a fileset input can hash.
54
+ * The Cargo manifests and Rust sources of Nx's workspace file index, with Nx's content hash of each source:
55
+ * .gitignore and .nxignore applied, `node_modules` never entered. A package whose manifest is missing here has no
56
+ * files a fileset input can hash. Scans of source texts no longer indexed are forgotten here.
57
57
  */
58
- export async function indexedCargoManifests(workspaceRoot) {
59
- return new Set(await globIndexedFiles(workspaceRoot, ['**/Cargo.toml']));
58
+ export async function indexedCargoSources(workspaceRoot) {
59
+ const [root, files] = await Promise.all([realpath(workspaceRoot), indexedFileData(workspaceRoot)]);
60
+ const index = cargoSourceIndex(root, files);
61
+ retainIncludeScans(index);
62
+ return index;
60
63
  }
61
64
  /**
62
65
  * Content-keyed locked offline metadata. A refusal fails graph inference:
@@ -64,9 +67,9 @@ export async function indexedCargoManifests(workspaceRoot) {
64
67
  * precise set of cache inputs.
65
68
  */
66
69
  export async function resolveCargoClosureSource(manifest, workspaceRoot, indexed, compiledFilesCache) {
67
- const [root, index] = await Promise.all([realpath(workspaceRoot), indexed]);
68
- const cargo = await readCargoResolve(join(root, manifest), root, index);
69
- return { manifest, workspaceRoot, root, cargo, indexed: index, compiledFilesCache };
70
+ const [root, sources] = await Promise.all([realpath(workspaceRoot), indexed]);
71
+ const cargo = await readCargoResolve(join(root, manifest), root, sources.manifests);
72
+ return { manifest, workspaceRoot, root, cargo, indexed: sources.manifests, sources, compiledFilesCache };
70
73
  }
71
74
  /**
72
75
  * The `cargoClosure` definition for the project at `projectRoot`: for each
@@ -135,7 +138,7 @@ async function workspaceClosureInputs(projectRoot, source) {
135
138
  if (!indexed.has(posix.join(directory, 'Cargo.toml'))) {
136
139
  throw new Error(`the Cargo package ${directory} is not in Nx's file index (an ignored directory)`);
137
140
  }
138
- for (const compiled of compiledInFiles(pkg.directory, source.compiledFilesCache)) {
141
+ for (const compiled of compiledInFiles(pkg.directory, source.sources, source.compiledFilesCache)) {
139
142
  const file = indexablePath(root, compiled.file);
140
143
  if (file === null)
141
144
  throw new Error(`${directory} compiles ${compiled.file}, which Nx's file index cannot hold`);
@@ -239,7 +242,7 @@ export async function cargoLockNode(directory, sources) {
239
242
  const paths = new Map(cargo.local.map((pkg) => [pkg.id, `path:${pkg.name}`]));
240
243
  const label = (id) => paths.get(id) ?? id;
241
244
  const rows = [...closure]
242
- .map(([id, built]) => [label(id), cargo.locked.get(id) ?? '', ...built.map(label).sort()].join('\t'))
245
+ .map(([id, built]) => [label(id), cargo.pinned.get(id)?.source ?? '', ...built.map(label).sort()].join('\t'))
243
246
  .sort();
244
247
  hash.update(`${source.manifest}\n${rows.join('\n')}\n\0`);
245
248
  }
@@ -1,11 +1,5 @@
1
- /** One resolved dependency of a package: the package it resolved to, and whether every declaration of it is a dev one. */
2
- export interface CargoEdge {
3
- readonly pkg: string;
4
- /** Cargo builds this dependency for the dependent's tests, examples and benches only. */
5
- readonly devOnly: boolean;
6
- }
7
- /** Every package Cargo builds for a selection, by package id, each with the dependencies Cargo builds for it. */
8
- export type CargoClosure = ReadonlyMap<string, readonly string[]>;
1
+ import { type CargoClosure, type CargoEdge, type PinnedCargoPackage } from '@smoothbricks/build-inputs/cargo-closure';
2
+ import { type FileData } from 'nx/src/native/index.js';
9
3
  /** A mutable (path) package in Cargo's locked resolve. Every path is canonical. */
10
4
  export interface LocalCargoPackage {
11
5
  readonly id: string;
@@ -24,11 +18,8 @@ export interface CargoResolve {
24
18
  /** The workspace's own members: `root`'s manifest governs each of them. */
25
19
  readonly members: ReadonlySet<string>;
26
20
  readonly local: readonly LocalCargoPackage[];
27
- /**
28
- * Every package Cargo.lock pins (registry, git, alternate registry), by package id: its `source`, which for a git
29
- * dependency names the locked commit that the id alone does not.
30
- */
31
- readonly locked: ReadonlyMap<string, string>;
21
+ /** Every package Cargo.lock pins (registry, git, alternate registry), by package id. */
22
+ readonly pinned: ReadonlyMap<string, PinnedCargoPackage>;
32
23
  /** Every dependency edge by package id, or null when Cargo reported no resolution. */
33
24
  readonly edges: ReadonlyMap<string, readonly CargoEdge[]> | null;
34
25
  }
@@ -85,14 +76,6 @@ export declare function hashCargoPathInputs(manifestPath: string, workspaceRoot:
85
76
  * selected.
86
77
  */
87
78
  export declare function dependencyClosure(cargo: CargoResolve, directory: string): Promise<CargoClosure>;
88
- /**
89
- * The packages Cargo compiles to build, test or run the `selected` ones, each with the dependencies Cargo builds for
90
- * it. A selected package's targets reach every dependency kind: its library and binaries the normal ones, its build
91
- * script the build ones, its tests, examples and benches the dev ones. Below the selection Cargo builds a package for
92
- * its library and build script alone, so a dependency's own dev-dependencies never compile into a selected package's
93
- * binaries and are not part of what it builds.
94
- */
95
- export declare function buildClosure(cargo: CargoResolve, selected: readonly string[]): CargoClosure;
96
79
  /** A compiled-in value, with the source spelling that identifies it across checkouts. */
97
80
  export interface CompiledCargoInput {
98
81
  readonly file: string;
@@ -100,9 +83,27 @@ export interface CompiledCargoInput {
100
83
  readonly literal: string;
101
84
  }
102
85
  /**
103
- * Existing literal include_str!/include_bytes! files read by this package's Rust sources.
104
- * One graph owns the memo; runtime hashing consumes the same discovery alongside source
105
- * bytes. Nested packages own their sources separately. Computed paths remain explicit inputs.
86
+ * The Rust sources and Cargo packages of Nx's workspace file index (.gitignore and .nxignore applied, as for every
87
+ * fileset input), canonical and absolute. A graph computation takes a package's sources and nested packages from
88
+ * here, so it lists no directory and probes no path for a manifest.
89
+ */
90
+ export interface CargoSourceIndex {
91
+ /** Every `Cargo.toml` in the index, relative to the workspace root. */
92
+ readonly manifests: ReadonlySet<string>;
93
+ /** Every directory holding an indexed `Cargo.toml`. */
94
+ readonly packageDirectories: ReadonlySet<string>;
95
+ /** Nx's content hash of every indexed `.rs` file. */
96
+ readonly rustSources: ReadonlyMap<string, string>;
97
+ }
98
+ /** {@link CargoSourceIndex} of Nx's file data (workspace-relative paths and content hashes) under the canonical `root`. */
99
+ export declare function cargoSourceIndex(root: string, files: Iterable<FileData>): CargoSourceIndex;
100
+ /** Forgets the scan of every source text `index` no longer holds. */
101
+ export declare function retainIncludeScans(index: CargoSourceIndex): void;
102
+ /**
103
+ * Existing literal include_str!/include_bytes! files read by this package's Rust sources, as Nx's file index holds
104
+ * them: a generated (ignored) source is its producer's output and keys a consumer through its dependency outputs.
105
+ * One graph owns the memo; runtime hashing consumes the same discovery alongside source bytes. Nested packages own
106
+ * their sources separately. Computed paths remain explicit inputs.
106
107
  */
107
- export declare function compiledInFiles(root: string, cache: Map<string, CompiledCargoInput[]>): CompiledCargoInput[];
108
+ export declare function compiledInFiles(root: string, index: CargoSourceIndex, cache: Map<string, CompiledCargoInput[]>): CompiledCargoInput[];
108
109
  //# sourceMappingURL=cargo-source-hash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cargo-source-hash.d.ts","sourceRoot":"","sources":["../src/cargo-source-hash.ts"],"names":[],"mappings":"AAgHA,0HAA0H;AAC1H,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,iHAAiH;AACjH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;AAElE,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iHAAiH;IACjH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,kGAAkG;AAClG,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,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