@flanksource/page-runtime 0.0.0-stage → 0.1.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 (312) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +494 -2
  3. package/dist/build/README.md +96 -0
  4. package/dist/build/cjs-export-names.mjs +24 -0
  5. package/dist/build/dependencies.mjs +279 -0
  6. package/dist/build/dependencies.mjs.map +1 -0
  7. package/dist/build/dependency-cache-Zg-FGasE.mjs +2130 -0
  8. package/dist/build/dependency-cache-Zg-FGasE.mjs.map +1 -0
  9. package/dist/build/index.mjs +42 -0
  10. package/dist/build/index.mjs.map +1 -0
  11. package/dist/build/package.json +19 -0
  12. package/dist/build/types/activity-schema.d.ts +62 -0
  13. package/dist/build/types/build/barrels.d.ts +70 -0
  14. package/dist/build/types/build/base.d.ts +2 -0
  15. package/dist/build/types/build/browser-runtime-exports.d.ts +19 -0
  16. package/dist/build/types/build/check-fragment.d.ts +5 -0
  17. package/dist/build/types/build/commonjs-exports.d.ts +5 -0
  18. package/dist/build/types/build/convert-commonjs.d.ts +12 -0
  19. package/dist/build/types/build/dependencies.d.ts +6 -0
  20. package/dist/build/types/build/dependency-barrel-index.d.ts +5 -0
  21. package/dist/build/types/build/dependency-barrels.d.ts +7 -0
  22. package/dist/build/types/build/dependency-cache.d.ts +7 -0
  23. package/dist/build/types/build/dependency-optional.d.ts +4 -0
  24. package/dist/build/types/build/dependency-plugin.d.ts +8 -0
  25. package/dist/build/types/build/dependency-runtime.d.ts +20 -0
  26. package/dist/build/types/build/dependency-workers.d.ts +8 -0
  27. package/dist/build/types/build/errors.d.ts +9 -0
  28. package/dist/build/types/build/fragment.d.ts +13 -0
  29. package/dist/build/types/build/index.d.ts +7 -0
  30. package/dist/build/types/build/library-runtime.d.ts +21 -0
  31. package/dist/build/types/build/module-utils.d.ts +3 -0
  32. package/dist/build/types/build/recipe-dependencies.d.ts +2 -0
  33. package/dist/build/types/build/runtime-entries.d.ts +4 -0
  34. package/dist/build/types/build/runtime-layer.d.ts +17 -0
  35. package/dist/build/types/build/trace.d.ts +140 -0
  36. package/dist/build/types/design-schema.d.ts +98 -0
  37. package/dist/build/types/host/agent-source.d.ts +2 -0
  38. package/dist/build/types/host/agent-validation.d.ts +3 -0
  39. package/dist/build/types/host/design-validation.d.ts +2 -0
  40. package/dist/build/types/host/message-values.d.ts +8 -0
  41. package/dist/build/types/host/review/validation.d.ts +5 -0
  42. package/dist/build/types/host/validation.d.ts +6 -0
  43. package/dist/build/types/link/page-sources.d.ts +31 -0
  44. package/dist/build/types/link/types.d.ts +62 -0
  45. package/dist/build/types/link/validation.d.ts +9 -0
  46. package/dist/build/types/markers.d.ts +10 -0
  47. package/dist/build/types/review-schema.d.ts +60 -0
  48. package/dist/build/types/schema.d.ts +319 -0
  49. package/dist/build/types/sw/barrels.d.ts +9 -0
  50. package/dist/build/types/sw/compiler-plugins.d.ts +6 -0
  51. package/dist/build/types/sw/composition.d.ts +8 -0
  52. package/dist/build/types/sw/module-transform.d.ts +68 -0
  53. package/dist/build/types/sw/profile.d.ts +7 -0
  54. package/dist/build/types/sw/source-provider.d.ts +7 -0
  55. package/dist/build/types/sw/versions.d.ts +10 -0
  56. package/dist/node/catalog.mjs +1 -0
  57. package/dist/node/chunks/publication-RchcQvxD.mjs +229 -0
  58. package/dist/node/chunks/publication-RchcQvxD.mjs.map +1 -0
  59. package/dist/node/chunks/schema-CaRTfg2x.mjs +12 -0
  60. package/dist/node/chunks/schema-CaRTfg2x.mjs.map +1 -0
  61. package/dist/node/dev.mjs +410 -0
  62. package/dist/node/dev.mjs.map +1 -0
  63. package/dist/node/publication/cli.mjs +13 -0
  64. package/dist/node/publication/cli.mjs.map +1 -0
  65. package/dist/node/publication.mjs +1 -0
  66. package/dist/node/schema.mjs +1 -0
  67. package/dist/node/styles.mjs +49 -0
  68. package/dist/node/styles.mjs.map +1 -0
  69. package/dist/static/boot.js +40938 -0
  70. package/dist/static/boot.js.map +1 -0
  71. package/dist/static/bootstrap.html +1 -0
  72. package/dist/static/devtools-hook.js +118 -0
  73. package/dist/static/document-bundle.js +1 -0
  74. package/dist/static/document.js +2621 -0
  75. package/dist/static/editing.js +37 -0
  76. package/dist/static/export-compiler.js +81521 -0
  77. package/dist/static/export-compiler.js.map +1 -0
  78. package/dist/static/page-agent.js +17193 -0
  79. package/dist/static/page-agent.js.map +1 -0
  80. package/dist/static/sw.js +86112 -0
  81. package/dist/static/sw.js.map +1 -0
  82. package/package.json +110 -3
  83. package/scripts/build-builder.ts +27 -0
  84. package/scripts/build-library-runtime.ts +9 -0
  85. package/scripts/build-node.ts +26 -0
  86. package/scripts/build-static.ts +86 -0
  87. package/scripts/build.ts +7 -0
  88. package/scripts/check-fragment.ts +12 -0
  89. package/scripts/local-workspaces.ts +55 -0
  90. package/scripts/react-externals.ts +18 -0
  91. package/scripts/release-version.ts +47 -0
  92. package/scripts/run-package-build.ts +8 -0
  93. package/scripts/serve-packages.ts +8 -0
  94. package/src/activity-schema.ts +92 -0
  95. package/src/build/README.md +96 -0
  96. package/src/build/barrels.ts +306 -0
  97. package/src/build/base.ts +2 -0
  98. package/src/build/browser-runtime-exports.ts +52 -0
  99. package/src/build/check-fragment.ts +45 -0
  100. package/src/build/cjs-export-names.mjs +24 -0
  101. package/src/build/commonjs-exports.ts +24 -0
  102. package/src/build/convert-commonjs.ts +183 -0
  103. package/src/build/dependencies.ts +6 -0
  104. package/src/build/dependency-barrel-index.ts +48 -0
  105. package/src/build/dependency-barrels.ts +80 -0
  106. package/src/build/dependency-cache.ts +40 -0
  107. package/src/build/dependency-optional.ts +15 -0
  108. package/src/build/dependency-plugin.ts +58 -0
  109. package/src/build/dependency-runtime.ts +182 -0
  110. package/src/build/dependency-workers.ts +41 -0
  111. package/src/build/errors.ts +9 -0
  112. package/src/build/fragment.ts +89 -0
  113. package/src/build/index.ts +7 -0
  114. package/src/build/library-runtime.ts +101 -0
  115. package/src/build/module-utils.ts +11 -0
  116. package/src/build/recipe-dependencies.ts +14 -0
  117. package/src/build/runtime-entries.ts +10 -0
  118. package/src/build/runtime-layer.ts +99 -0
  119. package/src/build/trace.ts +431 -0
  120. package/src/design-schema.ts +25 -0
  121. package/src/dev/README.md +78 -0
  122. package/src/dev/catalog.ts +79 -0
  123. package/src/dev/cli.ts +25 -0
  124. package/src/dev/index.ts +118 -0
  125. package/src/dev/runtime-origin.ts +63 -0
  126. package/src/editing.ts +25 -0
  127. package/src/form/entry-source.ts +68 -0
  128. package/src/form/form-page.ts +63 -0
  129. package/src/form/index.ts +2 -0
  130. package/src/form/source-update.ts +17 -0
  131. package/src/frame/activity.browser.ts +34 -0
  132. package/src/frame/activity.ts +52 -0
  133. package/src/frame/agent/README.md +47 -0
  134. package/src/frame/agent/agent.browser.ts +127 -0
  135. package/src/frame/agent/design.ts +62 -0
  136. package/src/frame/agent/frame-layout.ts +54 -0
  137. package/src/frame/agent/index.ts +151 -0
  138. package/src/frame/agent/overlay.ts +104 -0
  139. package/src/frame/agent/owner.ts +61 -0
  140. package/src/frame/agent/provider.tsx +14 -0
  141. package/src/frame/agent/react-override.ts +55 -0
  142. package/src/frame/agent/review.browser.ts +65 -0
  143. package/src/frame/agent/review.ts +108 -0
  144. package/src/frame/agent/testing/callsite.tsx +5 -0
  145. package/src/frame/agent/testing/client.ts +99 -0
  146. package/src/frame/agent/testing/library.ts +3 -0
  147. package/src/frame/agent/testing/modal.tsx +5 -0
  148. package/src/frame/agent/testing/review-client.ts +43 -0
  149. package/src/frame/agent/testing/review-server.ts +31 -0
  150. package/src/frame/agent/testing/server.ts +72 -0
  151. package/src/frame/agent/testing/vocabulary-host.ts +20 -0
  152. package/src/frame/agent/testing/vocabulary.tsx +10 -0
  153. package/src/frame/agent/vitest.browser.config.ts +6 -0
  154. package/src/frame/agent/vocabulary.browser.ts +30 -0
  155. package/src/frame/agent/vocabulary.ts +13 -0
  156. package/src/frame/agent.ts +3 -0
  157. package/src/frame/boot-styles.ts +50 -0
  158. package/src/frame/boot.ts +269 -0
  159. package/src/frame/bridge.ts +27 -0
  160. package/src/frame/devtools-hook.ts +1 -0
  161. package/src/frame/document-assets.ts +76 -0
  162. package/src/frame/document-entry.ts +68 -0
  163. package/src/frame/document-modules.ts +113 -0
  164. package/src/frame/document-mount.ts +32 -0
  165. package/src/frame/entry.ts +4 -0
  166. package/src/frame/export-compiler.ts +18 -0
  167. package/src/frame/export-page.ts +61 -0
  168. package/src/frame/export.ts +89 -0
  169. package/src/frame/index.ts +8 -0
  170. package/src/frame/local-runtime.browser.ts +36 -0
  171. package/src/frame/mount-page.ts +36 -0
  172. package/src/frame/page-agent.ts +2 -0
  173. package/src/frame/readiness.ts +51 -0
  174. package/src/frame/render-job.ts +101 -0
  175. package/src/frame/review-integration.browser.ts +48 -0
  176. package/src/frame/runtime.browser.ts +90 -0
  177. package/src/frame/tailwind/README.md +49 -0
  178. package/src/frame/tailwind/boot-styles.browser.ts +18 -0
  179. package/src/frame/tailwind/cache.ts +20 -0
  180. package/src/frame/tailwind/load.ts +75 -0
  181. package/src/frame/tailwind/recipe.ts +76 -0
  182. package/src/frame/tailwind/runtime.ts +113 -0
  183. package/src/frame/tailwind/store.ts +55 -0
  184. package/src/frame/tailwind/stylesheets.ts +42 -0
  185. package/src/frame/tailwind/tailwind.browser.ts +71 -0
  186. package/src/frame/tailwind/testing/client.ts +133 -0
  187. package/src/frame/tailwind/testing/compare.ts +91 -0
  188. package/src/frame/tailwind/testing/pages.ts +14 -0
  189. package/src/frame/tailwind/testing/server.ts +89 -0
  190. package/src/frame/tailwind/vitest.browser.config.ts +7 -0
  191. package/src/frame/testing/boot-layout.ts +3 -0
  192. package/src/frame/testing/boot-page.ts +3 -0
  193. package/src/frame/testing/host.ts +78 -0
  194. package/src/frame/testing/local-host.tsx +33 -0
  195. package/src/frame/testing/server.ts +135 -0
  196. package/src/host/BuildLog.tsx +28 -0
  197. package/src/host/DEBUG_CONSOLE.md +13 -0
  198. package/src/host/PageForm.tsx +63 -0
  199. package/src/host/PageFrame.tsx +49 -0
  200. package/src/host/RuntimeActivity.tsx +77 -0
  201. package/src/host/RuntimeDebugPanel.tsx +18 -0
  202. package/src/host/activity-state.ts +69 -0
  203. package/src/host/agent-source.ts +14 -0
  204. package/src/host/agent-validation.ts +73 -0
  205. package/src/host/bridge.ts +56 -0
  206. package/src/host/build-log.ts +29 -0
  207. package/src/host/clear-cache.ts +66 -0
  208. package/src/host/debug-runtime.tsx +17 -0
  209. package/src/host/design-validation.ts +96 -0
  210. package/src/host/index.ts +12 -0
  211. package/src/host/link/index.ts +66 -0
  212. package/src/host/link/transport.ts +68 -0
  213. package/src/host/link/watch.ts +62 -0
  214. package/src/host/message-values.ts +55 -0
  215. package/src/host/origin.ts +7 -0
  216. package/src/host/review/README.md +32 -0
  217. package/src/host/review/index.ts +43 -0
  218. package/src/host/review/validation.ts +55 -0
  219. package/src/host/runtime-diagnostics.ts +41 -0
  220. package/src/host/validation.ts +148 -0
  221. package/src/link/README.md +115 -0
  222. package/src/link/barrels.ts +5 -0
  223. package/src/link/build-cli.ts +12 -0
  224. package/src/link/build.ts +99 -0
  225. package/src/link/commonjs.ts +39 -0
  226. package/src/link/examples/server.ts +18 -0
  227. package/src/link/index.ts +6 -0
  228. package/src/link/link.browser.ts +66 -0
  229. package/src/link/local-relay.browser.ts +22 -0
  230. package/src/link/overrides.ts +69 -0
  231. package/src/link/page-sources.ts +69 -0
  232. package/src/link/source.ts +25 -0
  233. package/src/link/storage.ts +32 -0
  234. package/src/link/testing/client.ts +96 -0
  235. package/src/link/testing/folder.ts +19 -0
  236. package/src/link/testing/local-client.ts +30 -0
  237. package/src/link/testing/local-server.ts +26 -0
  238. package/src/link/testing/local-worker.ts +17 -0
  239. package/src/link/testing/server.ts +131 -0
  240. package/src/link/testing/worker.ts +32 -0
  241. package/src/link/testing-cache.ts +20 -0
  242. package/src/link/testing-fixtures.ts +16 -0
  243. package/src/link/types.ts +27 -0
  244. package/src/link/validation.ts +44 -0
  245. package/src/link/vitest.browser.config.ts +3 -0
  246. package/src/markers.ts +18 -0
  247. package/src/publication/build.ts +27 -0
  248. package/src/publication/fixtures/build.mjs +2 -0
  249. package/src/publication/index.ts +3 -0
  250. package/src/publication/lock.ts +32 -0
  251. package/src/publication/manifest.ts +14 -0
  252. package/src/publication/publish.ts +80 -0
  253. package/src/publication/runtime.ts +28 -0
  254. package/src/publication/schema.ts +13 -0
  255. package/src/review-schema.ts +17 -0
  256. package/src/schema.ts +175 -0
  257. package/src/storage/db.ts +64 -0
  258. package/src/styles.ts +40 -0
  259. package/src/sw/activity.ts +66 -0
  260. package/src/sw/barrels.ts +44 -0
  261. package/src/sw/candidates.ts +14 -0
  262. package/src/sw/compile.ts +92 -0
  263. package/src/sw/compiler-columns.ts +44 -0
  264. package/src/sw/compiler-internals.d.ts +8 -0
  265. package/src/sw/compiler-plugins.ts +18 -0
  266. package/src/sw/compiler.ts +93 -0
  267. package/src/sw/composition.ts +86 -0
  268. package/src/sw/content-types.ts +28 -0
  269. package/src/sw/converted.browser.ts +31 -0
  270. package/src/sw/converted.ts +64 -0
  271. package/src/sw/editable-sites.ts +42 -0
  272. package/src/sw/errors.ts +30 -0
  273. package/src/sw/esm-sh-fixtures/browser-client.ts +18 -0
  274. package/src/sw/esm-sh-fixtures/browser-server.ts +104 -0
  275. package/src/sw/esm-sh-fixtures/fixtures/copy-to-clipboard-entry.headers +15 -0
  276. package/src/sw/esm-sh-fixtures/fixtures/copy-to-clipboard-entry.mjs.txt +3 -0
  277. package/src/sw/esm-sh-fixtures/fixtures/copy-to-clipboard-module.headers +13 -0
  278. package/src/sw/esm-sh-fixtures/fixtures/copy-to-clipboard-module.mjs.txt +142 -0
  279. package/src/sw/esm-sh-fixtures/fixtures/react-copy-to-clipboard-entry.headers +15 -0
  280. package/src/sw/esm-sh-fixtures/fixtures/react-copy-to-clipboard-entry.mjs.txt +3 -0
  281. package/src/sw/esm-sh-fixtures/fixtures/react-copy-to-clipboard-module.headers +11 -0
  282. package/src/sw/esm-sh-fixtures/fixtures/react-copy-to-clipboard-module.mjs.txt +222 -0
  283. package/src/sw/esm-sh-fixtures/fixtures/toggle-selection-entry.headers +14 -0
  284. package/src/sw/esm-sh-fixtures/fixtures/toggle-selection-entry.mjs.txt +3 -0
  285. package/src/sw/esm-sh-fixtures/fixtures/toggle-selection-module.headers +11 -0
  286. package/src/sw/esm-sh-fixtures/fixtures/toggle-selection-module.mjs.txt +76 -0
  287. package/src/sw/esm-sh-fixtures/fixtures.ts +54 -0
  288. package/src/sw/esm-sh-fixtures/redact.ts +1 -0
  289. package/src/sw/index.ts +7 -0
  290. package/src/sw/integrity.ts +10 -0
  291. package/src/sw/legacy-storage.ts +18 -0
  292. package/src/sw/link-activity.ts +21 -0
  293. package/src/sw/link-cache.ts +19 -0
  294. package/src/sw/link-compiler.ts +120 -0
  295. package/src/sw/link-folder.ts +29 -0
  296. package/src/sw/link-relay.ts +40 -0
  297. package/src/sw/link-route.ts +239 -0
  298. package/src/sw/link-source.ts +41 -0
  299. package/src/sw/markers.ts +128 -0
  300. package/src/sw/module-transform.ts +364 -0
  301. package/src/sw/page-clients.ts +45 -0
  302. package/src/sw/profile.ts +90 -0
  303. package/src/sw/resolver.ts +224 -0
  304. package/src/sw/router.ts +360 -0
  305. package/src/sw/runtime-exports.ts +39 -0
  306. package/src/sw/runtime-module.ts +13 -0
  307. package/src/sw/source-hash.ts +37 -0
  308. package/src/sw/source-provider.ts +20 -0
  309. package/src/sw/versions.ts +96 -0
  310. package/src/sw/worker.ts +91 -0
  311. package/static/README.md +15 -0
  312. package/static/profile.example.json +15 -0
@@ -0,0 +1,9 @@
1
+ import type { RuntimeProfile } from "../schema.ts";
2
+ import type { LibraryLink } from "./types.ts";
3
+ export declare function assertLinksAllowed(options: {
4
+ profile: Pick<RuntimeProfile, "links">;
5
+ developerOverrides: boolean;
6
+ }): void;
7
+ export declare function linkUrl(id: string, path: string): string;
8
+ export declare function validateLink(link: LibraryLink): void;
9
+ export declare function missingLinkFile(link: LibraryLink, path: string): Error;
@@ -0,0 +1,10 @@
1
+ export type EditableSourceMarker = {
2
+ file: string;
3
+ line: number;
4
+ column: number;
5
+ ordinal: number;
6
+ hash: string;
7
+ };
8
+ export declare const EDITABLE_SOURCE_ATTRIBUTE = "data-source";
9
+ export declare function formatEditableSource({ file, line, column, ordinal, hash }: EditableSourceMarker): string;
10
+ export declare function parseEditableSource(value: string): EditableSourceMarker;
@@ -0,0 +1,60 @@
1
+ import type { AgentSelection } from "./schema.ts";
2
+ export type ReviewAction = "mark" | "approved" | "rejected" | "revision_requested" | "delete" | "export";
3
+ export type ReviewElement = {
4
+ id: string;
5
+ selection: AgentSelection;
6
+ domId?: string;
7
+ };
8
+ export type ReviewContent = {
9
+ html: string;
10
+ svg?: string;
11
+ };
12
+ export type ReviewHostMessage = {
13
+ type: "review-remove";
14
+ requestId: string;
15
+ id: string;
16
+ removed: boolean;
17
+ } | {
18
+ type: "review-list";
19
+ requestId: string;
20
+ } | {
21
+ type: "review-select";
22
+ requestId: string;
23
+ id: string | null;
24
+ } | {
25
+ type: "review-visibility";
26
+ requestId: string;
27
+ visible: boolean;
28
+ showRejected: boolean;
29
+ } | {
30
+ type: "review-action";
31
+ requestId: string;
32
+ id: string;
33
+ action: ReviewAction;
34
+ };
35
+ export type ReviewState = {
36
+ type: "review-state";
37
+ requestId?: string;
38
+ elements: ReviewElement[];
39
+ selected: string | null;
40
+ visible: boolean;
41
+ showRejected: boolean;
42
+ };
43
+ export type ReviewActionRequest = {
44
+ type: "review-action-request";
45
+ requestId: string;
46
+ element: ReviewElement;
47
+ } & ({
48
+ action: "delete";
49
+ containedAnchors: string[];
50
+ content?: never;
51
+ } | {
52
+ action: Exclude<ReviewAction, "delete">;
53
+ content?: ReviewContent;
54
+ containedAnchors?: never;
55
+ });
56
+ export type ReviewFrameMessage = ReviewState | ReviewActionRequest | {
57
+ type: "review-error";
58
+ requestId: string;
59
+ error: string;
60
+ };
@@ -0,0 +1,319 @@
1
+ export type PageStylesRecipe = {
2
+ name: string;
3
+ layer: string;
4
+ /** Published precompiled stylesheet specifiers, linked on every page in library order. */
5
+ base: string[];
6
+ /** Compiler inputs only (theme, utilities, `@config`/`@plugin`, `@theme`); it must not import any `base` stylesheet. */
7
+ entry: string;
8
+ theme: string;
9
+ /** Package specifiers or recipe-relative files loaded by the CSS compiler outside the JS import graph. */
10
+ runtimeDependencies: string[];
11
+ /** Managed libraries whose preset this one extends: only the most-derived recipe is compiled, every base is linked. */
12
+ extends?: string[];
13
+ transform?: (css: string) => string;
14
+ };
15
+ /** What a library publishes as `runtime/importmap.json`: its closure as package-relative import-map entries. */
16
+ export type Fragment = {
17
+ fragment: 1;
18
+ name: string;
19
+ /** Top-level specifiers, including the shared development runtime set. */
20
+ imports: Record<string, string>;
21
+ /** One scope per package version: the bare imports that package's files make. */
22
+ scopes: Record<string, Record<string, string>>;
23
+ /** URL remaps for CommonJS files that ESM code imports by a relative path: file URL to converted URL. */
24
+ remaps: Record<string, string>;
25
+ /** Page-facing specifier prefixes that stand for another prefix, such as facet's `@facet`. */
26
+ aliases: Record<string, string>;
27
+ /** Specifiers the closure imports but leaves to another fragment's top level. */
28
+ inherits: string[];
29
+ /** Subresource integrity for every traced and converted file, by package-relative URL. */
30
+ integrity: Record<string, string>;
31
+ /** Compiler plugins the library contributes to HTML and PDF exports, declared in package.json `pageRuntime.compiler`. */
32
+ compiler?: CompilerPlugins;
33
+ };
34
+ /** A remark plugin: a module the library exports, whose default export is the plugin, with the options it is applied with. */
35
+ export type CompilerPlugin = {
36
+ module: string;
37
+ options?: JsonValue;
38
+ };
39
+ export type CompilerPlugins = {
40
+ remark: CompilerPlugin[];
41
+ };
42
+ export type ImportMap = {
43
+ imports: Record<string, string>;
44
+ scopes: Record<string, Record<string, string>>;
45
+ };
46
+ export type DocumentSource = {
47
+ page: string;
48
+ layout: string;
49
+ files: Record<string, {
50
+ text: string;
51
+ } | {
52
+ base64: string;
53
+ }>;
54
+ dependencies: Record<string, string>;
55
+ managed: Record<string, string>;
56
+ profileUrl?: string;
57
+ dynamicStyles?: boolean;
58
+ };
59
+ /**
60
+ * A library's barrel export index, published as `runtime/barrels.json`: for each entry barrel, the defining module of
61
+ * every named export (`modules[pos]`, or `[pos, importName]` when the name is re-exported under another one).
62
+ */
63
+ export type BarrelIndex = {
64
+ modules: string[];
65
+ barrels: Record<string, Record<string, number | [number, string]>>;
66
+ };
67
+ export type DependencyPolicy = "any" | "ask" | "strict";
68
+ export type RuntimePolicy = {
69
+ dependencies: DependencyPolicy;
70
+ allow?: string[];
71
+ };
72
+ export type RuntimeExports = Pick<Fragment, "imports" | "scopes" | "remaps" | "integrity"> & {
73
+ versions: Record<string, string>;
74
+ };
75
+ export type RuntimeProfile = {
76
+ renderJobs?: true;
77
+ runtimeDomain: string;
78
+ embedders: string[];
79
+ packageOrigin: string;
80
+ registry: string;
81
+ managed: Record<string, string>;
82
+ dependencies?: Record<string, string>;
83
+ runtimeExports?: true;
84
+ /** `any` allows every declared package; `ask` and `strict` allow only the names (or `*` globs) in `allow`. */
85
+ policy: RuntimePolicy;
86
+ /** CommonJS-to-ESM converter for packages without ESM entries; also added to `connect-src`. */
87
+ convert?: {
88
+ origin: string;
89
+ };
90
+ minReleaseAgeDays: number;
91
+ network: {
92
+ allow: string[];
93
+ };
94
+ /** `wasm` lets frames compile WebAssembly (`'wasm-unsafe-eval'`); off by default, and it never enables JS `eval`. */
95
+ csp: {
96
+ add: Record<string, string[]>;
97
+ wasm?: boolean;
98
+ };
99
+ links: "allow" | "deny";
100
+ sources: Array<"host" | "opfs" | "folder" | "url" | "hash">;
101
+ readinessTimeoutMs: number;
102
+ };
103
+ export type PageLock = {
104
+ lock: 2;
105
+ packageOrigin: string;
106
+ page: string;
107
+ versions: Record<string, string>;
108
+ map: ImportMap;
109
+ integrity: Record<string, string>;
110
+ remaps: Record<string, string>;
111
+ barrels: BarrelIndex;
112
+ listings?: Record<string, string>;
113
+ pageSources?: import("./link/page-sources.ts").PageSourceRoot[];
114
+ /** Each library's export compiler plugins, in library order. */
115
+ compiler?: Record<string, CompilerPlugins>;
116
+ };
117
+ export type FolderManifest = {
118
+ dependencies: Record<string, string>;
119
+ pageRuntime?: {
120
+ pages?: Record<string, Record<string, string>>;
121
+ };
122
+ };
123
+ export type RuntimePhase = "resolve" | "fetch" | "compile" | "link" | "render" | "readiness";
124
+ export type RuntimeError = {
125
+ phase: RuntimePhase;
126
+ message: string;
127
+ file: string;
128
+ line?: number;
129
+ column?: number;
130
+ };
131
+ export type Theme = {
132
+ theme: "light" | "dark";
133
+ density: "compact" | "comfortable" | "spacious";
134
+ };
135
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
136
+ [key: string]: JsonValue;
137
+ };
138
+ export type SourceProvider = {
139
+ url: string;
140
+ paths: string[];
141
+ };
142
+ export type HostMessage = AgentHostMessage | {
143
+ type: "open";
144
+ page: string;
145
+ layout?: string;
146
+ manifest: FolderManifest;
147
+ lock?: PageLock;
148
+ files: Record<string, string>;
149
+ sourceProvider?: SourceProvider;
150
+ policy?: RuntimePolicy;
151
+ } | {
152
+ type: "prepare-render";
153
+ open: OpenMessage;
154
+ } | {
155
+ type: "render";
156
+ data: JsonValue;
157
+ } | {
158
+ type: "sources";
159
+ files: Record<string, string | null>;
160
+ data?: JsonValue;
161
+ } | {
162
+ type: "reload";
163
+ } | ({
164
+ type: "theme";
165
+ } & Theme) | {
166
+ type: "data";
167
+ data: JsonValue;
168
+ } | {
169
+ type: "export";
170
+ format: "html" | "print";
171
+ };
172
+ /** The `open` host message without its `type`: what `PageFrame` takes as `open` and what `formPageOpen` builds. */
173
+ export type OpenMessage = Omit<Extract<HostMessage, {
174
+ type: "open";
175
+ }>, "type">;
176
+ export type FrameMessage = import("./activity-schema.ts").ActivityMessage | AgentFrameMessage | {
177
+ type: "lock";
178
+ lock: PageLock;
179
+ } | {
180
+ type: "status";
181
+ state: "connecting" | "booting" | "mounted" | "fonts" | "images" | "stylesheets" | "diagrams" | "hook" | "quiescence" | "ready";
182
+ } | {
183
+ type: "error";
184
+ error: RuntimeError;
185
+ } | {
186
+ type: "snapshot";
187
+ html: string;
188
+ } | {
189
+ type: "prepared-render";
190
+ lock: PageLock;
191
+ navigate: boolean;
192
+ runtimeVersion: string;
193
+ } | {
194
+ type: "rendered";
195
+ html: string;
196
+ modulesMs: number;
197
+ readinessMs: number;
198
+ snapshotMs: number;
199
+ }
200
+ /** A page-defined event with a JSON payload, sent through `host.emit` (see `PageHost`). */
201
+ | {
202
+ type: "emit";
203
+ event: string;
204
+ payload: JsonValue;
205
+ }
206
+ /** The rendered height of the page root in CSS pixels, sent whenever it changes. */
207
+ | {
208
+ type: "size";
209
+ height: number;
210
+ };
211
+ /** What the runtime gives a page component next to its data: the page-to-host half of the bridge. */
212
+ export type PageHost = {
213
+ emit(event: string, payload: JsonValue): void;
214
+ };
215
+ export type BridgeEnvelope<M = HostMessage | FrameMessage> = {
216
+ bridge: "page-runtime-v1";
217
+ session: string;
218
+ id?: string;
219
+ re?: string;
220
+ message: M;
221
+ };
222
+ export type FrameConfig = {
223
+ page: string;
224
+ entry: string;
225
+ layout?: string;
226
+ lock: PageLock;
227
+ profile: RuntimeProfile;
228
+ runtimeVersion: string;
229
+ };
230
+ export type AgentRect = {
231
+ left: number;
232
+ top: number;
233
+ width: number;
234
+ height: number;
235
+ };
236
+ export type AgentLocator = import("@flanksource/clicky-ui/comments").CommentLocator;
237
+ export type AgentSourceContext = {
238
+ mode: "external-document";
239
+ url: string;
240
+ };
241
+ export type AgentElementContext = {
242
+ source: string;
243
+ sourceContext?: AgentSourceContext;
244
+ componentName: string;
245
+ html: string;
246
+ locators: AgentLocator[];
247
+ };
248
+ export type AgentSelection = {
249
+ anchor: string;
250
+ label: string;
251
+ element: AgentElementContext;
252
+ rect: AgentRect;
253
+ };
254
+ export type AgentPin = {
255
+ anchor: string;
256
+ count: number;
257
+ locators: AgentLocator[];
258
+ };
259
+ export type AgentAnchorState = {
260
+ anchor: string;
261
+ state: "found" | "moved" | "orphaned";
262
+ label: string;
263
+ rect: AgentRect | null;
264
+ };
265
+ export type AgentHostMessage = import("./review-schema.ts").ReviewHostMessage | import("./design-schema.ts").DesignHostMessage | {
266
+ type: "mode";
267
+ mode: "off" | "comment" | "design";
268
+ } | {
269
+ type: "pick";
270
+ } | {
271
+ type: "page";
272
+ } | {
273
+ type: "capture-vocabulary";
274
+ } | {
275
+ type: "pins";
276
+ anchors: AgentPin[];
277
+ focus?: string | null;
278
+ } | {
279
+ type: "highlight";
280
+ anchor: string | null;
281
+ } | {
282
+ type: "scroll";
283
+ anchor: string;
284
+ behavior?: ScrollBehavior;
285
+ block?: "start" | "center";
286
+ offset?: number;
287
+ };
288
+ export type AgentFrameMessage = import("./review-schema.ts").ReviewFrameMessage | import("./design-schema.ts").DesignFrameMessage | {
289
+ type: "selection";
290
+ selection: AgentSelection;
291
+ } | {
292
+ type: "vocabulary-previews";
293
+ images: {
294
+ id: string;
295
+ image: string;
296
+ width: number;
297
+ height: number;
298
+ }[];
299
+ } | {
300
+ type: "anchors";
301
+ anchors: AgentAnchorState[];
302
+ } | {
303
+ type: "focus";
304
+ anchor: string;
305
+ } | {
306
+ type: "keys";
307
+ key: "Escape" | "c";
308
+ ctrlKey: boolean;
309
+ metaKey: boolean;
310
+ shiftKey: boolean;
311
+ altKey: boolean;
312
+ } | {
313
+ type: "geometry";
314
+ scrollX: number;
315
+ scrollY: number;
316
+ width: number;
317
+ height: number;
318
+ };
319
+ export type { DesignEdit, DesignWriteRequest, DesignWriteCandidate, DesignWriteResult, DesignHostMessage, DesignFrameMessage } from "./design-schema.ts";
@@ -0,0 +1,9 @@
1
+ import type { BarrelIndex } from "../schema.ts";
2
+ /** Whether a package's `sideEffects` declaration lets a bundler skip the file at a package-relative path. */
3
+ export declare function sideEffectsRule(declaration: unknown, id: string): (path: string) => boolean;
4
+ export declare function guardedBarrels(options: {
5
+ index: BarrelIndex;
6
+ name: string;
7
+ version: string;
8
+ sideEffects?: boolean | string[];
9
+ }): BarrelIndex;
@@ -0,0 +1,6 @@
1
+ import type { CompilerPlugins } from "../schema.ts";
2
+ /** Validates a library's compiler plugin declaration; a library may only contribute modules it exports itself. */
3
+ export declare function validateCompilerPlugins(value: unknown, options: {
4
+ library: string;
5
+ path: string;
6
+ }): CompilerPlugins;
@@ -0,0 +1,8 @@
1
+ import type { Fragment, ImportMap, PageLock, BarrelIndex } from "../schema.ts";
2
+ export declare const BASE_PACKAGES: string[];
3
+ export declare const packageName: (specifier: string) => string;
4
+ export declare function resolveSpecifier(map: ImportMap, specifier: string, referrer: string): string | null;
5
+ export declare function composeFragments(options: {
6
+ fragments: Fragment[];
7
+ }): Pick<PageLock, "map" | "integrity" | "remaps" | "compiler">;
8
+ export declare function mergeBarrels(indices: BarrelIndex[]): BarrelIndex;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * A library version's barrel index, published with its fragment: for each module that forwards exports, the
3
+ * module that defines each name, as a position in `modules`, plus the name to import there when it differs.
4
+ */
5
+ import type { BarrelIndex } from "../schema.ts";
6
+ export type { BarrelIndex } from "../schema.ts";
7
+ export type SpecifierKind = "relative" | "url" | "builtin" | "bare";
8
+ export declare function specifierKind(specifier: string): SpecifierKind;
9
+ export declare const NPM_PREFIX = "/npm/";
10
+ /** Suffixes tried for a relative import that names no file, in the build tool's resolution order. */
11
+ export declare const CANONICAL_CANDIDATES: string[];
12
+ export declare function stylesheetModule(css: string, url: string): string;
13
+ export type ImportBinding = {
14
+ imported: string;
15
+ local: string;
16
+ };
17
+ export type ImportClause = {
18
+ bindings: ImportBinding[];
19
+ namespace: string | null;
20
+ };
21
+ /**
22
+ * Parses the bindings between `import` (or `export`) and `from`. Returns null for anything it does not fully
23
+ * understand, comments included, so the caller leaves that statement as written.
24
+ */
25
+ export declare function parseClause(text: string): ImportClause | null;
26
+ export type TransformStats = {
27
+ /** Relative imports rewritten to the canonical URL of the file they mean. */
28
+ canonical: number;
29
+ /** Import and export-from statements rewritten from a barrel to defining modules. */
30
+ statements: number;
31
+ /** Bindings moved from a barrel to the module that defines them. */
32
+ rewritten: number;
33
+ /** Bindings left on the barrel: names it defines itself, or names outside its index. */
34
+ kept: number;
35
+ /** Barrel statements that cannot be split: namespace imports and `export *`. */
36
+ whole: number;
37
+ /** Barrel statements whose bindings the clause parser did not understand. */
38
+ unparsed: number;
39
+ };
40
+ export declare function emptyTransformStats(): TransformStats;
41
+ export declare function addTransformStats(total: TransformStats, more: TransformStats): void;
42
+ export type ModuleTransformOptions = {
43
+ /** The module's URL path: `/npm/<package-relative URL>` for package files, anything else for page files. */
44
+ url: string;
45
+ /** Whether a package-relative URL names a file the runtime serves. */
46
+ known: (packageUrl: string) => boolean;
47
+ /** Resolves a bare specifier through the page's import map, as the browser would from `referrer`. */
48
+ resolveBare: (specifier: string, referrer: string) => string | null;
49
+ barrels: BarrelIndex | null;
50
+ };
51
+ /**
52
+ * Rewrites a served module's imports: relative imports in package files that name no file become canonical URLs,
53
+ * and named imports from an indexed barrel move to the modules that define them. Everything else stays as written.
54
+ */
55
+ export declare function transformModule(code: string, options: ModuleTransformOptions): {
56
+ code: string;
57
+ stats: TransformStats;
58
+ };
59
+ /**
60
+ * Offsets of `process.env.NODE_ENV` references, skipping comments, strings, template text and regular expressions.
61
+ * A lexer, not a parser: the harness checks it against oxc's AST on every file of the library set.
62
+ */
63
+ export declare function nodeEnvReferences(code: string): number[];
64
+ /** Defines `process.env.NODE_ENV` as development in every served package. */
65
+ export declare function defineNodeEnv(code: string): {
66
+ code: string;
67
+ replaced: number;
68
+ };
@@ -0,0 +1,7 @@
1
+ import type { RuntimePolicy, RuntimeProfile } from "../schema.ts";
2
+ export declare function validateDependencies(value: unknown, path?: string): Record<string, string>;
3
+ export declare function record(value: unknown, path: string): Record<string, unknown>;
4
+ export declare function keys(value: Record<string, unknown>, allowed: string[], path: string): void;
5
+ export declare function validateProfile(value: unknown): RuntimeProfile;
6
+ export declare function validatePolicy(value: unknown, path?: string): RuntimePolicy;
7
+ export declare function permitsNetwork(profile: RuntimeProfile, target: string): boolean;
@@ -0,0 +1,7 @@
1
+ import type { SourceProvider } from "../schema.ts";
2
+ export declare function validateSourceProvider(provider: SourceProvider): void;
3
+ export declare function fetchSource(options: {
4
+ provider: SourceProvider;
5
+ path: string;
6
+ fetch: typeof fetch;
7
+ }): Promise<Response>;
@@ -0,0 +1,10 @@
1
+ export declare function compareVersions(a: string, b: string): number;
2
+ export declare function validateVersionRange(range: string): void;
3
+ export declare function satisfiesVersion(text: string, range: string): boolean;
4
+ export declare function chooseVersion(options: {
5
+ name: string;
6
+ range: string;
7
+ times: Record<string, string>;
8
+ ageDays: number;
9
+ now: number;
10
+ }): string;
@@ -0,0 +1 @@
1
+ export { t as BUILD_ID, n as validateCatalog } from "./chunks/schema-CaRTfg2x.mjs";