@gate-forge/cli 0.7.1 → 0.9.0

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 (296) hide show
  1. package/README.md +91 -704
  2. package/dist/adapter-audit.d.ts +208 -0
  3. package/dist/adapter-audit.d.ts.map +1 -0
  4. package/dist/adapter-audit.js +579 -0
  5. package/dist/adapter-audit.js.map +1 -0
  6. package/dist/adapter-scaffold.d.ts +91 -0
  7. package/dist/adapter-scaffold.d.ts.map +1 -0
  8. package/dist/adapter-scaffold.js +474 -0
  9. package/dist/adapter-scaffold.js.map +1 -0
  10. package/dist/adopted-baseline.d.ts +10 -0
  11. package/dist/adopted-baseline.d.ts.map +1 -1
  12. package/dist/adopted-baseline.js +18 -1
  13. package/dist/adopted-baseline.js.map +1 -1
  14. package/dist/args.d.ts +15 -0
  15. package/dist/args.d.ts.map +1 -1
  16. package/dist/args.js +61 -2
  17. package/dist/args.js.map +1 -1
  18. package/dist/behavior-setup.d.ts +239 -0
  19. package/dist/behavior-setup.d.ts.map +1 -0
  20. package/dist/behavior-setup.js +751 -0
  21. package/dist/behavior-setup.js.map +1 -0
  22. package/dist/broker.d.ts.map +1 -1
  23. package/dist/broker.js +28 -2
  24. package/dist/broker.js.map +1 -1
  25. package/dist/cache-exclusions.d.ts +45 -0
  26. package/dist/cache-exclusions.d.ts.map +1 -0
  27. package/dist/cache-exclusions.js +205 -0
  28. package/dist/cache-exclusions.js.map +1 -0
  29. package/dist/candidate-tree.d.ts +86 -14
  30. package/dist/candidate-tree.d.ts.map +1 -1
  31. package/dist/candidate-tree.js +236 -62
  32. package/dist/candidate-tree.js.map +1 -1
  33. package/dist/ci-witnessed-template.d.ts +43 -0
  34. package/dist/ci-witnessed-template.d.ts.map +1 -0
  35. package/dist/ci-witnessed-template.js +283 -0
  36. package/dist/ci-witnessed-template.js.map +1 -0
  37. package/dist/cli.d.ts +1 -1
  38. package/dist/cli.d.ts.map +1 -1
  39. package/dist/cli.js +31 -4
  40. package/dist/cli.js.map +1 -1
  41. package/dist/commands/adapters.d.ts +15 -0
  42. package/dist/commands/adapters.d.ts.map +1 -0
  43. package/dist/commands/adapters.js +355 -0
  44. package/dist/commands/adapters.js.map +1 -0
  45. package/dist/commands/adopt.d.ts +7 -0
  46. package/dist/commands/adopt.d.ts.map +1 -1
  47. package/dist/commands/adopt.js +44 -2
  48. package/dist/commands/adopt.js.map +1 -1
  49. package/dist/commands/baseline.d.ts.map +1 -1
  50. package/dist/commands/baseline.js +42 -1
  51. package/dist/commands/baseline.js.map +1 -1
  52. package/dist/commands/blocking.d.ts +105 -2
  53. package/dist/commands/blocking.d.ts.map +1 -1
  54. package/dist/commands/blocking.js +395 -53
  55. package/dist/commands/blocking.js.map +1 -1
  56. package/dist/commands/check.d.ts +36 -0
  57. package/dist/commands/check.d.ts.map +1 -1
  58. package/dist/commands/check.js +1068 -64
  59. package/dist/commands/check.js.map +1 -1
  60. package/dist/commands/classify.d.ts +2 -1
  61. package/dist/commands/classify.d.ts.map +1 -1
  62. package/dist/commands/classify.js +188 -5
  63. package/dist/commands/classify.js.map +1 -1
  64. package/dist/commands/enforce.d.ts +4 -4
  65. package/dist/commands/enforce.d.ts.map +1 -1
  66. package/dist/commands/enforce.js +41 -9
  67. package/dist/commands/enforce.js.map +1 -1
  68. package/dist/commands/enforcement.d.ts +13 -1
  69. package/dist/commands/enforcement.d.ts.map +1 -1
  70. package/dist/commands/enforcement.js +880 -33
  71. package/dist/commands/enforcement.js.map +1 -1
  72. package/dist/commands/explain.d.ts +1 -1
  73. package/dist/commands/explain.d.ts.map +1 -1
  74. package/dist/commands/explain.js +162 -3
  75. package/dist/commands/explain.js.map +1 -1
  76. package/dist/commands/history.d.ts +12 -0
  77. package/dist/commands/history.d.ts.map +1 -0
  78. package/dist/commands/history.js +45 -0
  79. package/dist/commands/history.js.map +1 -0
  80. package/dist/commands/init-presets.d.ts +155 -0
  81. package/dist/commands/init-presets.d.ts.map +1 -0
  82. package/dist/commands/init-presets.js +203 -0
  83. package/dist/commands/init-presets.js.map +1 -0
  84. package/dist/commands/init.d.ts +7 -12
  85. package/dist/commands/init.d.ts.map +1 -1
  86. package/dist/commands/init.js +987 -99
  87. package/dist/commands/init.js.map +1 -1
  88. package/dist/commands/keys.d.ts.map +1 -1
  89. package/dist/commands/keys.js +29 -13
  90. package/dist/commands/keys.js.map +1 -1
  91. package/dist/commands/next.d.ts.map +1 -1
  92. package/dist/commands/next.js +846 -19
  93. package/dist/commands/next.js.map +1 -1
  94. package/dist/commands/pre-commit.d.ts +25 -0
  95. package/dist/commands/pre-commit.d.ts.map +1 -1
  96. package/dist/commands/pre-commit.js +91 -6
  97. package/dist/commands/pre-commit.js.map +1 -1
  98. package/dist/commands/quarantine.d.ts +16 -0
  99. package/dist/commands/quarantine.d.ts.map +1 -0
  100. package/dist/commands/quarantine.js +213 -0
  101. package/dist/commands/quarantine.js.map +1 -0
  102. package/dist/commands/run.d.ts +39 -0
  103. package/dist/commands/run.d.ts.map +1 -0
  104. package/dist/commands/run.js +196 -0
  105. package/dist/commands/run.js.map +1 -0
  106. package/dist/commands/test-gates.d.ts +284 -2
  107. package/dist/commands/test-gates.d.ts.map +1 -1
  108. package/dist/commands/test-gates.js +3620 -187
  109. package/dist/commands/test-gates.js.map +1 -1
  110. package/dist/commands/tests.d.ts +1 -1
  111. package/dist/commands/tests.d.ts.map +1 -1
  112. package/dist/commands/tests.js +264 -29
  113. package/dist/commands/tests.js.map +1 -1
  114. package/dist/docs-exclusions.d.ts.map +1 -1
  115. package/dist/docs-exclusions.js +18 -3
  116. package/dist/docs-exclusions.js.map +1 -1
  117. package/dist/endpoint-compiler.d.ts.map +1 -1
  118. package/dist/endpoint-compiler.js +78 -9
  119. package/dist/endpoint-compiler.js.map +1 -1
  120. package/dist/engine-browser.d.ts +183 -0
  121. package/dist/engine-browser.d.ts.map +1 -0
  122. package/dist/engine-browser.js +381 -0
  123. package/dist/engine-browser.js.map +1 -0
  124. package/dist/engine-identity.d.ts +100 -0
  125. package/dist/engine-identity.d.ts.map +1 -0
  126. package/dist/engine-identity.js +182 -0
  127. package/dist/engine-identity.js.map +1 -0
  128. package/dist/evaluate.d.ts +105 -1
  129. package/dist/evaluate.d.ts.map +1 -1
  130. package/dist/evaluate.js +149 -18
  131. package/dist/evaluate.js.map +1 -1
  132. package/dist/execution.d.ts +253 -9
  133. package/dist/execution.d.ts.map +1 -1
  134. package/dist/execution.js +309 -12
  135. package/dist/execution.js.map +1 -1
  136. package/dist/gateforge-owned.d.ts +78 -0
  137. package/dist/gateforge-owned.d.ts.map +1 -0
  138. package/dist/gateforge-owned.js +254 -0
  139. package/dist/gateforge-owned.js.map +1 -0
  140. package/dist/git-hooks.d.ts +35 -0
  141. package/dist/git-hooks.d.ts.map +1 -1
  142. package/dist/git-hooks.js +140 -1
  143. package/dist/git-hooks.js.map +1 -1
  144. package/dist/git-ignored.d.ts +27 -0
  145. package/dist/git-ignored.d.ts.map +1 -0
  146. package/dist/git-ignored.js +102 -0
  147. package/dist/git-ignored.js.map +1 -0
  148. package/dist/git-objects.d.ts +60 -0
  149. package/dist/git-objects.d.ts.map +1 -0
  150. package/dist/git-objects.js +152 -0
  151. package/dist/git-objects.js.map +1 -0
  152. package/dist/glob.d.ts +33 -14
  153. package/dist/glob.d.ts.map +1 -1
  154. package/dist/glob.js +96 -5
  155. package/dist/glob.js.map +1 -1
  156. package/dist/history.d.ts +52 -0
  157. package/dist/history.d.ts.map +1 -0
  158. package/dist/history.js +116 -0
  159. package/dist/history.js.map +1 -0
  160. package/dist/host-load.d.ts +49 -0
  161. package/dist/host-load.d.ts.map +1 -0
  162. package/dist/host-load.js +78 -0
  163. package/dist/host-load.js.map +1 -0
  164. package/dist/index.d.ts +4 -1
  165. package/dist/index.d.ts.map +1 -1
  166. package/dist/index.js +2 -1
  167. package/dist/index.js.map +1 -1
  168. package/dist/input-snapshot.d.ts +63 -9
  169. package/dist/input-snapshot.d.ts.map +1 -1
  170. package/dist/input-snapshot.js +195 -17
  171. package/dist/input-snapshot.js.map +1 -1
  172. package/dist/io.d.ts +49 -0
  173. package/dist/io.d.ts.map +1 -1
  174. package/dist/io.js +22 -0
  175. package/dist/io.js.map +1 -1
  176. package/dist/mapping.d.ts +84 -1
  177. package/dist/mapping.d.ts.map +1 -1
  178. package/dist/mapping.js +276 -5
  179. package/dist/mapping.js.map +1 -1
  180. package/dist/native-freeze.d.ts +217 -0
  181. package/dist/native-freeze.d.ts.map +1 -0
  182. package/dist/native-freeze.js +332 -0
  183. package/dist/native-freeze.js.map +1 -0
  184. package/dist/pipeline.d.ts +67 -1
  185. package/dist/pipeline.d.ts.map +1 -1
  186. package/dist/pipeline.js +164 -6
  187. package/dist/pipeline.js.map +1 -1
  188. package/dist/planes-inference.d.ts +12 -5
  189. package/dist/planes-inference.d.ts.map +1 -1
  190. package/dist/planes-inference.js +13 -15
  191. package/dist/planes-inference.js.map +1 -1
  192. package/dist/playwright-browsers.d.ts +210 -0
  193. package/dist/playwright-browsers.d.ts.map +1 -0
  194. package/dist/playwright-browsers.js +364 -0
  195. package/dist/playwright-browsers.js.map +1 -0
  196. package/dist/plugins.d.ts +15 -5
  197. package/dist/plugins.d.ts.map +1 -1
  198. package/dist/plugins.js +59 -9
  199. package/dist/plugins.js.map +1 -1
  200. package/dist/progress.d.ts +148 -0
  201. package/dist/progress.d.ts.map +1 -0
  202. package/dist/progress.js +263 -0
  203. package/dist/progress.js.map +1 -0
  204. package/dist/providers.d.ts +26 -1
  205. package/dist/providers.d.ts.map +1 -1
  206. package/dist/providers.js +39 -0
  207. package/dist/providers.js.map +1 -1
  208. package/dist/receipts.d.ts +1 -0
  209. package/dist/receipts.d.ts.map +1 -1
  210. package/dist/receipts.js +35 -7
  211. package/dist/receipts.js.map +1 -1
  212. package/dist/repo-scan.d.ts +15 -1
  213. package/dist/repo-scan.d.ts.map +1 -1
  214. package/dist/repo-scan.js +329 -34
  215. package/dist/repo-scan.js.map +1 -1
  216. package/dist/reseal-chain.d.ts +184 -0
  217. package/dist/reseal-chain.d.ts.map +1 -0
  218. package/dist/reseal-chain.js +735 -0
  219. package/dist/reseal-chain.js.map +1 -0
  220. package/dist/reseal-evidence.d.ts +241 -0
  221. package/dist/reseal-evidence.d.ts.map +1 -0
  222. package/dist/reseal-evidence.js +319 -0
  223. package/dist/reseal-evidence.js.map +1 -0
  224. package/dist/reseal.d.ts +181 -0
  225. package/dist/reseal.d.ts.map +1 -0
  226. package/dist/reseal.js +1620 -0
  227. package/dist/reseal.js.map +1 -0
  228. package/dist/response-field-guidance.d.ts +82 -0
  229. package/dist/response-field-guidance.d.ts.map +1 -0
  230. package/dist/response-field-guidance.js +184 -0
  231. package/dist/response-field-guidance.js.map +1 -0
  232. package/dist/route-plane-proposals.d.ts +100 -0
  233. package/dist/route-plane-proposals.d.ts.map +1 -0
  234. package/dist/route-plane-proposals.js +213 -0
  235. package/dist/route-plane-proposals.js.map +1 -0
  236. package/dist/run-cache.d.ts +260 -0
  237. package/dist/run-cache.d.ts.map +1 -0
  238. package/dist/run-cache.js +771 -0
  239. package/dist/run-cache.js.map +1 -0
  240. package/dist/run-preflight.d.ts +77 -0
  241. package/dist/run-preflight.d.ts.map +1 -0
  242. package/dist/run-preflight.js +774 -0
  243. package/dist/run-preflight.js.map +1 -0
  244. package/dist/run-recipe.d.ts +107 -0
  245. package/dist/run-recipe.d.ts.map +1 -0
  246. package/dist/run-recipe.js +295 -0
  247. package/dist/run-recipe.js.map +1 -0
  248. package/dist/run-reliability.d.ts +126 -0
  249. package/dist/run-reliability.d.ts.map +1 -0
  250. package/dist/run-reliability.js +221 -0
  251. package/dist/run-reliability.js.map +1 -0
  252. package/dist/runtime.d.ts +15 -0
  253. package/dist/runtime.d.ts.map +1 -1
  254. package/dist/runtime.js +11 -1
  255. package/dist/runtime.js.map +1 -1
  256. package/dist/scope.d.ts +20 -0
  257. package/dist/scope.d.ts.map +1 -1
  258. package/dist/scope.js +26 -5
  259. package/dist/scope.js.map +1 -1
  260. package/dist/secret-guard.d.ts +36 -0
  261. package/dist/secret-guard.d.ts.map +1 -0
  262. package/dist/secret-guard.js +63 -0
  263. package/dist/secret-guard.js.map +1 -0
  264. package/dist/singleton-guidance.d.ts +82 -0
  265. package/dist/singleton-guidance.d.ts.map +1 -0
  266. package/dist/singleton-guidance.js +138 -0
  267. package/dist/singleton-guidance.js.map +1 -0
  268. package/dist/staged-candidate.d.ts +17 -0
  269. package/dist/staged-candidate.d.ts.map +1 -1
  270. package/dist/staged-candidate.js +50 -0
  271. package/dist/staged-candidate.js.map +1 -1
  272. package/dist/state-artifacts.d.ts +70 -0
  273. package/dist/state-artifacts.d.ts.map +1 -0
  274. package/dist/state-artifacts.js +215 -0
  275. package/dist/state-artifacts.js.map +1 -0
  276. package/dist/state.d.ts +170 -2
  277. package/dist/state.d.ts.map +1 -1
  278. package/dist/state.js +248 -8
  279. package/dist/state.js.map +1 -1
  280. package/dist/unmatched-routes.d.ts +60 -0
  281. package/dist/unmatched-routes.d.ts.map +1 -0
  282. package/dist/unmatched-routes.js +131 -0
  283. package/dist/unmatched-routes.js.map +1 -0
  284. package/dist/verifier-keys.d.ts +33 -2
  285. package/dist/verifier-keys.d.ts.map +1 -1
  286. package/dist/verifier-keys.js +95 -9
  287. package/dist/verifier-keys.js.map +1 -1
  288. package/guides/CONNECT-YOUR-PROJECT.md +425 -0
  289. package/guides/QUICKSTART.md +306 -26
  290. package/guides/REFERENCE.md +1710 -0
  291. package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
  292. package/guides/TEST-ENVIRONMENT.md +1044 -6
  293. package/guides/UPGRADE-0.6-to-0.7.md +3 -3
  294. package/guides/UPGRADE-0.7-to-0.8.md +114 -0
  295. package/guides/UPGRADE-0.8-to-0.9.md +104 -0
  296. package/package.json +10 -9
@@ -0,0 +1,210 @@
1
+ /** One browser build a Playwright release pins. */
2
+ export interface BrowserBuild {
3
+ /** Registry browser name (e.g. `chromium-headless-shell`). */
4
+ name: string;
5
+ /** The revision this release pins for that browser. */
6
+ revision: string;
7
+ }
8
+ /** The outcome of one browser-build inspection. */
9
+ export interface BrowserBuildReadiness {
10
+ /** The registry file the facts came from, or null when there is none. */
11
+ registry: string | null;
12
+ /** Browser cache directory the check looked in. */
13
+ browsersPath: string;
14
+ /** Every build the resolved runner pins. */
15
+ required: BrowserBuild[];
16
+ /** The subset that is installed in the cache. */
17
+ installed: BrowserBuild[];
18
+ /** The subset that is missing (the run cannot launch these). */
19
+ missing: BrowserBuild[];
20
+ }
21
+ /** The cache directory Playwright installs browsers into by default. */
22
+ export declare function defaultBrowsersPath(env?: NodeJS.ProcessEnv): string;
23
+ /**
24
+ * The on-disk directory name Playwright gives one browser build: the
25
+ * registry name with dashes replaced by underscores, then the revision
26
+ * (`chromium_headless_shell-1208`).
27
+ *
28
+ * Args:
29
+ * build: one pinned browser build.
30
+ *
31
+ * Returns:
32
+ * string: the cache directory name for that build.
33
+ */
34
+ export declare function browserDirectoryName(build: BrowserBuild): string;
35
+ /** The outcome of launching one installed browser build. */
36
+ export interface BrowserLaunchProbe {
37
+ /** The build that was launched. */
38
+ build: BrowserBuild;
39
+ /** The build directory inside the browser cache. */
40
+ directory: string;
41
+ /** The executable that was launched. */
42
+ executable: string;
43
+ /** True when the build started and reported a version. */
44
+ started: boolean;
45
+ /** The first non-empty stderr line, when the build did not start. */
46
+ reason: string;
47
+ }
48
+ /** Injection points for {@link probeBrowserLaunch} (tests supply both). */
49
+ export interface BrowserLaunchProbeOptions {
50
+ /** Platform the probe runs on; the loader diagnosis is a Linux one. */
51
+ platform?: string;
52
+ /** Millisecond budget for the launch. */
53
+ timeoutMs?: number;
54
+ }
55
+ /**
56
+ * Launches one INSTALLED chromium-family build with `--version` and
57
+ * reports whether this machine can actually start it.
58
+ *
59
+ * Installed is not startable: a bare Linux image (a container, a CI
60
+ * image, WSL) has no browser system libraries, and the dynamic loader
61
+ * then fails before `main` — the browser's own output is empty, the
62
+ * exit code is 127, and the only diagnostic anywhere is the loader's
63
+ * own line. The probe reads that one line so the operator is told the
64
+ * cause instead of a downstream "Target page, context or browser has
65
+ * been closed".
66
+ *
67
+ * It claims NOTHING it did not observe: a non-Linux platform, a
68
+ * non-chromium-family build, and a build with no executable file all
69
+ * return `null`, which every caller reports as silence, never as a
70
+ * failure.
71
+ *
72
+ * Args:
73
+ build: the installed build to launch.
74
+ browsersPath: the browser cache directory.
75
+ options: platform and deadline overrides.
76
+ *
77
+ * Returns:
78
+ BrowserLaunchProbe | null: the observed launch, or null when there
79
+ is nothing to claim.
80
+ */
81
+ export declare function probeBrowserLaunch(build: BrowserBuild, browsersPath: string, options?: BrowserLaunchProbeOptions): BrowserLaunchProbe | null;
82
+ /**
83
+ * The builds that are installed but cannot start on this machine.
84
+ *
85
+ * Args:
86
+ readiness: the inspection result.
87
+ options: platform and deadline overrides.
88
+ *
89
+ * Returns:
90
+ BrowserLaunchProbe[]: one entry per unlaunchable build, in registry
91
+ order; empty when every installed build starts (or is unprobeable).
92
+ */
93
+ export declare function unlaunchableBuilds(readiness: BrowserBuildReadiness, options?: BrowserLaunchProbeOptions): BrowserLaunchProbe[];
94
+ /**
95
+ * The one-line summary for builds that are installed but cannot start:
96
+ * the loader's own first line plus the exact `npx playwright
97
+ * install-deps` that installs the browser's system libraries (which
98
+ * needs root or sudo — the reason a bare container is red out of the
99
+ * box).
100
+ *
101
+ * Args:
102
+ probes: the unlaunchable builds.
103
+ installCwd: the directory the fix command must run in.
104
+ *
105
+ * Returns:
106
+ string: the sentence for the runner's readiness line; '' when
107
+ nothing was observed.
108
+ */
109
+ export declare function browserLaunchSummary(probes: readonly BrowserLaunchProbe[], installCwd: string): string;
110
+ /**
111
+ * Finds the `browsers.json` of the Playwright release a resolved runner
112
+ * package will launch: the `playwright-core` registry it resolves to
113
+ * (its own nested install first, then the owning `node_modules`
114
+ * upward), else a registry the package ships itself.
115
+ *
116
+ * Args:
117
+ * manifest: absolute path of the resolved runner's `package.json`.
118
+ *
119
+ * Returns:
120
+ * string | null: the absolute registry path, or null when the runner
121
+ * ships no readable registry (an unresolvable install never invents
122
+ * revisions).
123
+ */
124
+ export declare function findBrowsersRegistry(manifest: string): string | null;
125
+ /**
126
+ * Parses a Playwright `browsers.json` into the builds it pins.
127
+ *
128
+ * Args:
129
+ * registry: absolute path of the registry file.
130
+ *
131
+ * Returns:
132
+ * BrowserBuild[]: the pinned builds in file order; empty when the file
133
+ * is unreadable or names no browser.
134
+ */
135
+ export declare function readBrowserBuilds(registry: string): BrowserBuild[];
136
+ /**
137
+ * The browsers a Playwright config's own projects launch: every
138
+ * `browserName` it names, or chromium when it names none. A config is
139
+ * TypeScript, so this reads its text — the cheapest honest source for
140
+ * "which browser will this suite open".
141
+ *
142
+ * Args:
143
+ * configText: the Playwright config's source.
144
+ *
145
+ * Returns:
146
+ * {browsers, headless}: the browser names in first-declaration order,
147
+ * and whether the config leaves headless mode on (the default).
148
+ */
149
+ export declare function configBrowsers(configText: string): {
150
+ browsers: string[];
151
+ headless: boolean;
152
+ };
153
+ /**
154
+ * Selects the builds one config would launch from a registry: each
155
+ * named browser's own build, plus its headless shell while the config
156
+ * leaves headless mode on (that is the build a headless launch opens).
157
+ *
158
+ * Args:
159
+ * builds: every build the registry pins.
160
+ * wanted: the browsers the config launches.
161
+ * headless: whether headless mode stays on.
162
+ *
163
+ * Returns:
164
+ * BrowserBuild[]: the builds to require, in registry order.
165
+ */
166
+ export declare function requiredBuilds(builds: readonly BrowserBuild[], wanted: readonly string[], headless: boolean): BrowserBuild[];
167
+ /**
168
+ * Inspects whether every build the resolved runner needs for the
169
+ * config's projects is present in the browser cache. A runner without a
170
+ * readable registry is reported as `registry: null` with no required
171
+ * builds: the caller then keeps its historical wording rather than
172
+ * inventing revisions.
173
+ *
174
+ * Args:
175
+ * manifest: absolute path of the resolved runner's `package.json`.
176
+ * configText: the Playwright config's source ('' when there is none).
177
+ * env: operator environment (`PLAYWRIGHT_BROWSERS_PATH`).
178
+ *
179
+ * Returns:
180
+ * BrowserBuildReadiness: the needed builds, present and missing.
181
+ */
182
+ export declare function inspectBrowserBuilds(manifest: string, configText: string, env?: NodeJS.ProcessEnv): BrowserBuildReadiness;
183
+ /**
184
+ * The `npx playwright install` argument that installs every missing
185
+ * build: the browser names behind them (chromium covers its headless
186
+ * shell), in first-appearance order.
187
+ *
188
+ * Args:
189
+ * missing: the builds the run cannot launch.
190
+ *
191
+ * Returns:
192
+ * string: the space-separated install arguments ('' when empty).
193
+ */
194
+ export declare function installArguments(missing: readonly BrowserBuild[]): string;
195
+ /**
196
+ * The one-line summary of a readiness inspection, naming the exact
197
+ * `npx playwright install` a missing build needs — run from the
198
+ * directory whose config resolves this runner, which is where the
199
+ * consumer's Playwright lives.
200
+ *
201
+ * Args:
202
+ * readiness: the inspection result.
203
+ * installCwd: the directory the fix command must run in.
204
+ *
205
+ * Returns:
206
+ * string: the sentence appended to the runner's readiness line; ''
207
+ * when the runner pins no readable registry.
208
+ */
209
+ export declare function browserBuildSummary(readiness: BrowserBuildReadiness, installCwd: string): string;
210
+ //# sourceMappingURL=playwright-browsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright-browsers.d.ts","sourceRoot":"","sources":["../src/playwright-browsers.ts"],"names":[],"mappings":"AAwBA,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mDAAmD;AACnD,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,iDAAiD;IACjD,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,gEAAgE;IAChE,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAQD,wEAAwE;AACxE,wBAAgB,mBAAm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AC,UAAU,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAU5F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,QAAQ,EAAE,OAAO,GAChB,YAAY,EAAE,CAKhB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,qBAAqB,CAevB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAOzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiBhG"}
@@ -0,0 +1,364 @@
1
+ /**
2
+ * Browser-build readiness for the resolved Playwright runner.
3
+ *
4
+ * A supervised run launches the CONSUMER's Playwright — the package that
5
+ * resolves next to its own config (see `findRunnerManifest`), often a
6
+ * different release from the one Gateforge hoists. Every release pins
7
+ * its own browser revisions in the `browsers.json` of the package it
8
+ * will launch, so a cache holding ANOTHER release's builds satisfies
9
+ * "the directory is nonempty" while every test still dies with
10
+ * `Executable doesn't exist at .../chromium_headless_shell-<rev>/…`.
11
+ *
12
+ * This module reads the resolved runner's own registry and reports the
13
+ * builds the config's own projects would launch, whether each is
14
+ * installed in the browser cache, and — on Linux, for an INSTALLED
15
+ * chromium-family build — whether this machine can actually start it.
16
+ * The launch probe executes the browser's own binary with `--version`
17
+ * and nothing else: it never writes to the cache, never opens a
18
+ * browser, and never touches a browser that is not there.
19
+ */
20
+ import { spawnSync } from 'node:child_process';
21
+ import { existsSync, readFileSync } from 'node:fs';
22
+ import { homedir } from 'node:os';
23
+ import { dirname, join } from 'node:path';
24
+ /** The npm packages whose `browsers.json` pins a Playwright release. */
25
+ const REGISTRY_PACKAGES = ['playwright-core', 'playwright', '@playwright/test'];
26
+ /** The browser a Playwright project uses when its config names none. */
27
+ const DEFAULT_BROWSER = 'chromium';
28
+ /** The cache directory Playwright installs browsers into by default. */
29
+ export function defaultBrowsersPath(env = process.env) {
30
+ return env['PLAYWRIGHT_BROWSERS_PATH'] ?? join(homedir(), '.cache', 'ms-playwright');
31
+ }
32
+ /**
33
+ * The on-disk directory name Playwright gives one browser build: the
34
+ * registry name with dashes replaced by underscores, then the revision
35
+ * (`chromium_headless_shell-1208`).
36
+ *
37
+ * Args:
38
+ * build: one pinned browser build.
39
+ *
40
+ * Returns:
41
+ * string: the cache directory name for that build.
42
+ */
43
+ export function browserDirectoryName(build) {
44
+ return `${build.name.replace(/-/g, '_')}-${build.revision}`;
45
+ }
46
+ /** Milliseconds allowed for one browser `--version` launch probe. */
47
+ const LAUNCH_PROBE_TIMEOUT_MS = 10_000;
48
+ /** Maximum bytes read from the probe's own streams. */
49
+ const LAUNCH_PROBE_BUFFER = 64 * 1024;
50
+ /**
51
+ * Where each chromium-family build keeps its executable inside the
52
+ * build directory, as the installed Playwright's own registry lays it
53
+ * out (`playwright-core/lib/server/registry/index.js`,
54
+ * `EXECUTABLE_PATHS`). x64 first, then arm64: the first entry that
55
+ * exists is the one this machine installed, and a build with neither is
56
+ * not probed at all.
57
+ */
58
+ const CHROMIUM_LINUX_EXECUTABLES = {
59
+ chromium: ['chrome-linux64/chrome', 'chrome-linux/chrome'],
60
+ 'chromium-headless-shell': [
61
+ 'chrome-headless-shell-linux64/chrome-headless-shell',
62
+ 'chrome-linux/headless_shell',
63
+ ],
64
+ 'chromium-tip-of-tree': ['chrome-linux64/chrome', 'chrome-linux/chrome'],
65
+ 'chromium-tip-of-tree-headless-shell': [
66
+ 'chrome-headless-shell-linux64/chrome-headless-shell',
67
+ 'chrome-linux/headless_shell',
68
+ ],
69
+ };
70
+ /**
71
+ * Launches one INSTALLED chromium-family build with `--version` and
72
+ * reports whether this machine can actually start it.
73
+ *
74
+ * Installed is not startable: a bare Linux image (a container, a CI
75
+ * image, WSL) has no browser system libraries, and the dynamic loader
76
+ * then fails before `main` — the browser's own output is empty, the
77
+ * exit code is 127, and the only diagnostic anywhere is the loader's
78
+ * own line. The probe reads that one line so the operator is told the
79
+ * cause instead of a downstream "Target page, context or browser has
80
+ * been closed".
81
+ *
82
+ * It claims NOTHING it did not observe: a non-Linux platform, a
83
+ * non-chromium-family build, and a build with no executable file all
84
+ * return `null`, which every caller reports as silence, never as a
85
+ * failure.
86
+ *
87
+ * Args:
88
+ build: the installed build to launch.
89
+ browsersPath: the browser cache directory.
90
+ options: platform and deadline overrides.
91
+ *
92
+ * Returns:
93
+ BrowserLaunchProbe | null: the observed launch, or null when there
94
+ is nothing to claim.
95
+ */
96
+ export function probeBrowserLaunch(build, browsersPath, options = {}) {
97
+ if ((options.platform ?? process.platform) !== 'linux')
98
+ return null;
99
+ const candidates = CHROMIUM_LINUX_EXECUTABLES[build.name];
100
+ if (candidates === undefined)
101
+ return null;
102
+ const directory = join(browsersPath, browserDirectoryName(build));
103
+ for (const candidate of candidates) {
104
+ const executable = join(directory, ...candidate.split('/'));
105
+ if (!existsSync(executable))
106
+ continue;
107
+ const result = spawnSync(executable, ['--version'], {
108
+ // No shell: the executable is a path inside a browser cache, not
109
+ // something an operator's config could shape into a command.
110
+ shell: false,
111
+ env: process.env,
112
+ encoding: 'utf8',
113
+ timeout: options.timeoutMs ?? LAUNCH_PROBE_TIMEOUT_MS,
114
+ maxBuffer: LAUNCH_PROBE_BUFFER,
115
+ stdio: ['ignore', 'pipe', 'pipe'],
116
+ });
117
+ const reason = (result.stderr ?? '')
118
+ .split('\n')
119
+ .map((line) => line.trim())
120
+ .find((line) => line.length > 0) ?? '';
121
+ return {
122
+ build,
123
+ directory,
124
+ executable,
125
+ started: result.error === undefined && result.status === 0,
126
+ reason,
127
+ };
128
+ }
129
+ return null;
130
+ }
131
+ /**
132
+ * The builds that are installed but cannot start on this machine.
133
+ *
134
+ * Args:
135
+ readiness: the inspection result.
136
+ options: platform and deadline overrides.
137
+ *
138
+ * Returns:
139
+ BrowserLaunchProbe[]: one entry per unlaunchable build, in registry
140
+ order; empty when every installed build starts (or is unprobeable).
141
+ */
142
+ export function unlaunchableBuilds(readiness, options = {}) {
143
+ return readiness.installed
144
+ .map((build) => probeBrowserLaunch(build, readiness.browsersPath, options))
145
+ .filter((probe) => probe !== null && !probe.started);
146
+ }
147
+ /**
148
+ * The one-line summary for builds that are installed but cannot start:
149
+ * the loader's own first line plus the exact `npx playwright
150
+ * install-deps` that installs the browser's system libraries (which
151
+ * needs root or sudo — the reason a bare container is red out of the
152
+ * box).
153
+ *
154
+ * Args:
155
+ probes: the unlaunchable builds.
156
+ installCwd: the directory the fix command must run in.
157
+ *
158
+ * Returns:
159
+ string: the sentence for the runner's readiness line; '' when
160
+ nothing was observed.
161
+ */
162
+ export function browserLaunchSummary(probes, installCwd) {
163
+ const first = probes[0];
164
+ if (first === undefined)
165
+ return '';
166
+ // ONE build is named, with its own loader line: a second broken build
167
+ // of the same browser fails for the same reason, and repeating the
168
+ // sentence per build buries the fix. The fix still covers every one.
169
+ const named = `'${first.directory}' is installed but cannot start on this machine` +
170
+ (first.reason === '' ? '' : `: ${first.reason}`);
171
+ return (`the browser build ${named}; ` +
172
+ `fix: run \`npx playwright install-deps ${installArguments(probes.map((probe) => probe.build))}\` in '${installCwd}' ` +
173
+ "(installs the browser's system libraries; needs root or sudo)");
174
+ }
175
+ /**
176
+ * Finds the `browsers.json` of the Playwright release a resolved runner
177
+ * package will launch: the `playwright-core` registry it resolves to
178
+ * (its own nested install first, then the owning `node_modules`
179
+ * upward), else a registry the package ships itself.
180
+ *
181
+ * Args:
182
+ * manifest: absolute path of the resolved runner's `package.json`.
183
+ *
184
+ * Returns:
185
+ * string | null: the absolute registry path, or null when the runner
186
+ * ships no readable registry (an unresolvable install never invents
187
+ * revisions).
188
+ */
189
+ export function findBrowsersRegistry(manifest) {
190
+ let cursor = dirname(manifest);
191
+ for (let depth = 0; depth < 6; depth += 1) {
192
+ for (const name of REGISTRY_PACKAGES) {
193
+ const candidate = join(cursor, 'node_modules', name, 'browsers.json');
194
+ if (existsSync(candidate))
195
+ return candidate;
196
+ }
197
+ const own = join(cursor, 'browsers.json');
198
+ if (existsSync(own))
199
+ return own;
200
+ const parent = dirname(cursor);
201
+ if (parent === cursor)
202
+ break;
203
+ cursor = parent;
204
+ }
205
+ return null;
206
+ }
207
+ /**
208
+ * Parses a Playwright `browsers.json` into the builds it pins.
209
+ *
210
+ * Args:
211
+ * registry: absolute path of the registry file.
212
+ *
213
+ * Returns:
214
+ * BrowserBuild[]: the pinned builds in file order; empty when the file
215
+ * is unreadable or names no browser.
216
+ */
217
+ export function readBrowserBuilds(registry) {
218
+ let parsed;
219
+ try {
220
+ parsed = JSON.parse(readFileSync(registry, 'utf8'));
221
+ }
222
+ catch {
223
+ return [];
224
+ }
225
+ const entries = typeof parsed === 'object' && parsed !== null && 'browsers' in parsed
226
+ ? parsed.browsers
227
+ : [];
228
+ if (!Array.isArray(entries))
229
+ return [];
230
+ const builds = [];
231
+ for (const entry of entries) {
232
+ if (typeof entry !== 'object' || entry === null)
233
+ continue;
234
+ const name = entry.name;
235
+ const revision = entry.revision;
236
+ if (typeof name === 'string' && typeof revision === 'string')
237
+ builds.push({ name, revision });
238
+ }
239
+ return builds;
240
+ }
241
+ /**
242
+ * The browsers a Playwright config's own projects launch: every
243
+ * `browserName` it names, or chromium when it names none. A config is
244
+ * TypeScript, so this reads its text — the cheapest honest source for
245
+ * "which browser will this suite open".
246
+ *
247
+ * Args:
248
+ * configText: the Playwright config's source.
249
+ *
250
+ * Returns:
251
+ * {browsers, headless}: the browser names in first-declaration order,
252
+ * and whether the config leaves headless mode on (the default).
253
+ */
254
+ export function configBrowsers(configText) {
255
+ const browsers = [];
256
+ for (const match of configText.matchAll(/browserName\s*:\s*['"]([a-z]+)['"]/g)) {
257
+ const name = match[1];
258
+ if (name !== undefined && !browsers.includes(name))
259
+ browsers.push(name);
260
+ }
261
+ return {
262
+ browsers: browsers.length > 0 ? browsers : [DEFAULT_BROWSER],
263
+ headless: !/headless\s*:\s*false/.test(configText),
264
+ };
265
+ }
266
+ /**
267
+ * Selects the builds one config would launch from a registry: each
268
+ * named browser's own build, plus its headless shell while the config
269
+ * leaves headless mode on (that is the build a headless launch opens).
270
+ *
271
+ * Args:
272
+ * builds: every build the registry pins.
273
+ * wanted: the browsers the config launches.
274
+ * headless: whether headless mode stays on.
275
+ *
276
+ * Returns:
277
+ * BrowserBuild[]: the builds to require, in registry order.
278
+ */
279
+ export function requiredBuilds(builds, wanted, headless) {
280
+ return builds.filter((build) => wanted.includes(build.name) || (headless && wanted.includes(build.name.replace(/-headless-shell$/, ''))));
281
+ }
282
+ /**
283
+ * Inspects whether every build the resolved runner needs for the
284
+ * config's projects is present in the browser cache. A runner without a
285
+ * readable registry is reported as `registry: null` with no required
286
+ * builds: the caller then keeps its historical wording rather than
287
+ * inventing revisions.
288
+ *
289
+ * Args:
290
+ * manifest: absolute path of the resolved runner's `package.json`.
291
+ * configText: the Playwright config's source ('' when there is none).
292
+ * env: operator environment (`PLAYWRIGHT_BROWSERS_PATH`).
293
+ *
294
+ * Returns:
295
+ * BrowserBuildReadiness: the needed builds, present and missing.
296
+ */
297
+ export function inspectBrowserBuilds(manifest, configText, env = process.env) {
298
+ const browsersPath = defaultBrowsersPath(env);
299
+ const registry = findBrowsersRegistry(manifest);
300
+ if (registry === null) {
301
+ return { registry: null, browsersPath, required: [], installed: [], missing: [] };
302
+ }
303
+ const { browsers, headless } = configBrowsers(configText);
304
+ const required = requiredBuilds(readBrowserBuilds(registry), browsers, headless);
305
+ const installed = [];
306
+ const missing = [];
307
+ for (const build of required) {
308
+ if (existsSync(join(browsersPath, browserDirectoryName(build))))
309
+ installed.push(build);
310
+ else
311
+ missing.push(build);
312
+ }
313
+ return { registry, browsersPath, required, installed, missing };
314
+ }
315
+ /**
316
+ * The `npx playwright install` argument that installs every missing
317
+ * build: the browser names behind them (chromium covers its headless
318
+ * shell), in first-appearance order.
319
+ *
320
+ * Args:
321
+ * missing: the builds the run cannot launch.
322
+ *
323
+ * Returns:
324
+ * string: the space-separated install arguments ('' when empty).
325
+ */
326
+ export function installArguments(missing) {
327
+ const names = [];
328
+ for (const build of missing) {
329
+ const name = build.name.replace(/-headless-shell$/, '');
330
+ if (!names.includes(name))
331
+ names.push(name);
332
+ }
333
+ return names.join(' ');
334
+ }
335
+ /**
336
+ * The one-line summary of a readiness inspection, naming the exact
337
+ * `npx playwright install` a missing build needs — run from the
338
+ * directory whose config resolves this runner, which is where the
339
+ * consumer's Playwright lives.
340
+ *
341
+ * Args:
342
+ * readiness: the inspection result.
343
+ * installCwd: the directory the fix command must run in.
344
+ *
345
+ * Returns:
346
+ * string: the sentence appended to the runner's readiness line; ''
347
+ * when the runner pins no readable registry.
348
+ */
349
+ export function browserBuildSummary(readiness, installCwd) {
350
+ if (readiness.registry === null)
351
+ return '';
352
+ if (readiness.required.length === 0) {
353
+ return `its browser registry names no build this configuration launches (nothing to install)`;
354
+ }
355
+ if (readiness.missing.length === 0) {
356
+ return (`every browser build this runner pins for these projects is installed ` +
357
+ `(${readiness.required.map((build) => browserDirectoryName(build)).join(', ')}) under '${readiness.browsersPath}'`);
358
+ }
359
+ const missing = readiness.missing.map((build) => browserDirectoryName(build)).join(', ');
360
+ return (`the browser builds this runner pins for these projects are NOT installed: ${missing} — the cache holds ` +
361
+ 'other Playwright revisions, so every supervised test would fail with "Executable doesn\'t exist"; ' +
362
+ `fix: run \`npx playwright install ${installArguments(readiness.missing)}\` in '${installCwd}'`);
363
+ }
364
+ //# sourceMappingURL=playwright-browsers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playwright-browsers.js","sourceRoot":"","sources":["../src/playwright-browsers.ts"],"names":[],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-forge/core';
2
- /** One plugin run: detector contributions + pinned registrations. */
2
+ import { type CacheControl, type CacheCounts } from './run-cache.js';
3
+ /** One plugin run: detector contributions + pinned registrations + cache accounting. */
3
4
  export interface PluginRunResult {
4
5
  contributions: DetectorOutput[];
5
6
  registrations: PluginRegistration[];
7
+ /** Cache accounting for this run (0/0 when the cache is disabled). */
8
+ cache: CacheCounts;
6
9
  }
7
10
  /** Default export shape every in-process plugin must provide. */
8
11
  export interface InProcessPluginModule {
@@ -19,21 +22,28 @@ export interface InProcessPluginModule {
19
22
  };
20
23
  }
21
24
  /**
22
- * Runs every configured plugin over the same path list.
25
+ * Runs every configured plugin over the same path list, reusing cached
26
+ * discovery results when a cache control is provided and every key input
27
+ * (plugin config, module bytes, input bytes, interpreter identity) is
28
+ * unchanged. A cache miss runs the plugin exactly as before and stores
29
+ * the validated result; any doubt (unreadable input, unprobeable
30
+ * interpreter, corrupt entry) runs fresh — the cache only ever skips
31
+ * work whose inputs are byte-identical.
23
32
  *
24
33
  * Args:
25
34
  * plugins: plugin entries from `.gateforge.yml` (config order).
26
35
  * paths: expanded repo-relative include paths (possibly empty).
27
36
  * cwd: repo root; subprocess cwd and in-process module base.
37
+ * cache: cache control; omitted or disabled means a full scan.
28
38
  *
29
39
  * Returns:
30
- * PluginRunResult: one validated contribution per plugin, plus the
31
- * pinned registrations for the run manifest.
40
+ * PluginRunResult: one validated contribution per plugin, the pinned
41
+ * registrations for the run manifest, and the cache hit/miss counts.
32
42
  *
33
43
  * Throws:
34
44
  * UsageError (exit 2): config/usage problems — spawn failures,
35
45
  * GPP/2 protocol violations, import failures, invalid discovery
36
46
  * documents. A failed plugin never yields a partial contribution.
37
47
  */
38
- export declare function runPlugins(plugins: readonly ConfigPlugin[], paths: readonly string[], cwd: string): Promise<PluginRunResult>;
48
+ export declare function runPlugins(plugins: readonly ConfigPlugin[], paths: readonly string[], cwd: string, cache?: CacheControl): Promise<PluginRunResult>;
39
49
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAoCA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAI1B,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,cAAc,EAAE,CAAC;IAChC,aAAa,EAAE,kBAAkB,EAAE,CAAC;CACrC;AAED,iEAAiE;AACjE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CACN,KAAK,EAAE,SAAS,MAAM,EAAE,GAEtB,OAAO,CAAC;QACN,SAAS,EAAE,OAAO,EAAE,CAAC;QACrB,UAAU,EAAE,OAAO,EAAE,CAAC;QACtB,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,qBAAqB,EAAE,OAAO,EAAE,CAAC;KAClC,CAAC,GACF;QACE,SAAS,EAAE,OAAO,EAAE,CAAC;QACrB,UAAU,EAAE,OAAO,EAAE,CAAC;QACtB,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,qBAAqB,EAAE,OAAO,EAAE,CAAC;KAClC,CAAC;CACP;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,eAAe,CAAC,CAY1B"}
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAoCA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,wFAAwF;AACxF,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,cAAc,EAAE,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