@mostra/runtime 0.2.0 → 0.3.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 (58) hide show
  1. package/dist/bin.js +7 -7
  2. package/dist/bin.js.map +1 -1
  3. package/dist/builder/child/main.js +18 -17
  4. package/dist/builder/child/main.js.map +1 -1
  5. package/dist/{child-xrHmytks.js → child-BQc3arf7.js} +5 -2
  6. package/dist/{child-xrHmytks.js.map → child-BQc3arf7.js.map} +1 -1
  7. package/dist/deps/child/install.js +9 -6
  8. package/dist/deps/child/install.js.map +1 -1
  9. package/dist/files-KxzOxckl.js +674 -0
  10. package/dist/files-KxzOxckl.js.map +1 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/{instance-CzBkUyHu.js → instance-DiKSe7s6.js} +1148 -737
  15. package/dist/instance-DiKSe7s6.js.map +1 -0
  16. package/package.json +5 -5
  17. package/src/bin.ts +4 -10
  18. package/src/builder/child/dev.ts +4 -3
  19. package/src/builder/child/plugins.ts +12 -7
  20. package/src/builder/child/spa.ts +15 -9
  21. package/src/builder/index.ts +3 -6
  22. package/src/deps/child/install.ts +3 -2
  23. package/src/deps/index.ts +21 -16
  24. package/src/deps/warm.ts +3 -16
  25. package/src/faults.ts +9 -2
  26. package/src/gateway/capabilities.ts +2 -2
  27. package/src/home/acquire.ts +27 -11
  28. package/src/home/paths.ts +45 -135
  29. package/src/home/platform.ts +17 -9
  30. package/src/home/record.ts +3 -3
  31. package/src/home/settings.ts +5 -16
  32. package/src/instance/index.ts +31 -7
  33. package/src/ledger/index.ts +5 -27
  34. package/src/platform/control.ts +409 -0
  35. package/src/platform/directories.ts +212 -0
  36. package/src/platform/environment.ts +64 -0
  37. package/src/platform/files.ts +368 -0
  38. package/src/platform/helper.ts +152 -0
  39. package/src/{processes → platform}/identity.ts +40 -8
  40. package/src/platform/index.ts +46 -0
  41. package/src/platform/launch.ts +373 -0
  42. package/src/processes/child.ts +4 -1
  43. package/src/processes/environment.ts +22 -3
  44. package/src/processes/index.ts +2 -1
  45. package/src/processes/manager.ts +76 -179
  46. package/src/protocol-server/client.ts +19 -18
  47. package/src/protocol-server/server.ts +75 -54
  48. package/src/publish/publisher.ts +16 -9
  49. package/src/publish/source.ts +7 -4
  50. package/src/registry/store.ts +7 -65
  51. package/src/secrets/index.ts +2 -2
  52. package/src/service/unit.ts +3 -2
  53. package/src/verify/index.ts +5 -3
  54. package/src/verify/typecheck.ts +3 -2
  55. package/src/workers/launcher.ts +3 -1
  56. package/dist/instance-CzBkUyHu.js.map +0 -1
  57. package/dist/types-NjNy7gXX.js +0 -57
  58. package/dist/types-NjNy7gXX.js.map +0 -1
@@ -1,57 +0,0 @@
1
- //#region src/builder/types.ts
2
- /** The IPC method the supervisor calls on the builder child. */
3
- const BUILD_METHOD = "builder/build";
4
- /**
5
- * `mostra dev`'s child (D140 item 12): the supervisor asks the builder child for a Vite dev
6
- * server over a mirror of the artifact's source, reached only through the dev sandbox's gateway.
7
- */
8
- const DEV_METHOD = "builder/dev";
9
- /**
10
- * Supervisor to child: these files of the mirror changed (`{ changes: DevChange[] }`). The child
11
- * watches nothing itself: the supervisor, which keeps the mirror, says exactly what changed.
12
- */
13
- const DEV_CHANGED_METHOD = "builder/dev.changed";
14
- /** Supervisor to child: tell every page to load again (a new server bundle runs now). */
15
- const DEV_RELOAD_METHOD = "builder/dev.reload";
16
- /** Child to supervisor: the server bundle was built again (or failed to build). */
17
- const DEV_SERVER_NOTIFICATION = "builder/dev.server";
18
- /** Child to supervisor: the client modules of these files were updated in place (HMR). */
19
- const DEV_UPDATE_NOTIFICATION = "builder/dev.update";
20
- /** The header that carries {@link DevRequest.secret}. */
21
- const DEV_SECRET_HEADER = "x-mostra-dev-secret";
22
- /**
23
- * The files written into the staging root so the bundler's upward searches stop there instead of
24
- * reaching directories above the home (VR-01): a `tsconfig.json` with the compile settings Mostra
25
- * chooses (an artifact's own `tsconfig.json`, part of its source, still applies to its files),
26
- * and a `package.json` that marks the build as ES modules. Their contents are part of
27
- * `buildConfigDigest`.
28
- */
29
- const STAGING_FILES = {
30
- "tsconfig.json": `${JSON.stringify({ compilerOptions: {
31
- target: "ES2022",
32
- useDefineForClassFields: true,
33
- jsx: "react-jsx",
34
- jsxImportSource: "react",
35
- experimentalDecorators: false
36
- } }, null, 2)}\n`,
37
- "package.json": `${JSON.stringify({
38
- private: true,
39
- type: "module"
40
- }, null, 2)}\n`
41
- };
42
- /**
43
- * The declaration that types `useLive` from `live.ts` (D56): client code reads the source types
44
- * through `typeof import`, never by importing server code at run time. Written beside the build's
45
- * other generated files for the type check, never into the artifact's source.
46
- */
47
- const LIVE_DECLARATION = `// Generated by Mostra: the types of this artifact's live sources (D56).
48
- import type { LiveValuesOf } from "@mostra/react";
49
-
50
- declare module "@mostra/react" {
51
- interface LiveSources extends LiveValuesOf<typeof import("../source/live")> {}
52
- }
53
- `;
54
- //#endregion
55
- export { DEV_SECRET_HEADER as a, LIVE_DECLARATION as c, DEV_RELOAD_METHOD as i, STAGING_FILES as l, DEV_CHANGED_METHOD as n, DEV_SERVER_NOTIFICATION as o, DEV_METHOD as r, DEV_UPDATE_NOTIFICATION as s, BUILD_METHOD as t };
56
-
57
- //# sourceMappingURL=types-NjNy7gXX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-NjNy7gXX.js","names":[],"sources":["../src/builder/types.ts"],"sourcesContent":["/**\n * The builder's types, shared by the supervisor side (`index.ts`) and the builder child\n * (`child/`). Nothing here imports the bundler, so the supervisor can use them.\n */\nimport type { ArtifactManifest, Diagnostic } from \"@mostra/protocol\";\nimport type { FieldCoverage } from \"./coverage.ts\";\n\n/** One `\"use server\"` export (D54, D55): what the client stub calls and the worker runs. */\nexport interface ServerFunctionEntry {\n /** `<module>#<export>`, for example `actions.ts#sendReply`. */\n readonly id: string;\n /** The module's path inside the artifact. */\n readonly module: string;\n /** The export's name (`default` for a default export). */\n readonly export: string;\n /** Whether the function references `dryRun()` from `@mostra/server`, opting into `verify`'s smoke test (D55). */\n readonly dryRun: boolean;\n}\n\n/** One route of a `pages/` artifact (D57). */\nexport interface PageRoute {\n /** The React Router path: `/`, `/settings`, `/reports/:id`. */\n readonly path: string;\n /** The page's file inside the artifact. */\n readonly file: string;\n}\n\n/**\n * What a version contains, read by `verify`, the shell, the worker and `results` (INTERFACES §11).\n * Written as `registry.json` in the version directory. Later packages add keys (fields, WP-07).\n */\nexport interface VersionRegistry {\n readonly schemaVersion: 1;\n /** The entry, inside the artifact. */\n readonly entry: string;\n /** Every `\"use server\"` export. */\n readonly actions: readonly ServerFunctionEntry[];\n /**\n * The live sources `live.ts` exports (D56), each with `always` when its `defineLive` literal\n * says it (WP-08); absent when the builder couldn't tell, and the worker reports it.\n */\n readonly liveSources: readonly { readonly key: string; readonly always?: boolean }[];\n /** The routes of `pages/`, empty for a single-page artifact. */\n readonly pages: readonly PageRoute[];\n /** The terminal sessions the manifest declares, by name. */\n readonly terminals: readonly string[];\n /** The web demos the manifest declares, by name. */\n readonly demos: readonly string[];\n /**\n * The field IDs the version's code can use (D109). Absent in versions built before WP-07, which\n * cover every field ID.\n */\n readonly fields?: FieldCoverage;\n}\n\n/** What the supervisor asks the builder child to build (`builder/build`). */\nexport interface BuildRequest {\n /** The staging directory; the artifact's snapshot is in its `source/`. */\n readonly stagingDir: string;\n /** The entry, inside the snapshot. */\n readonly entry: string;\n /** Whether the entry has a default export: the page, or with `pages/` the layout. */\n readonly entryHasDefault: boolean;\n /** The artifact's manifest (with its title resolved). */\n readonly manifest: ArtifactManifest;\n /**\n * The version being built (D89: known from the digests before the build). The page carries it\n * (`<meta name=\"mostra-version\">`), so a frame tells its shell which version it loaded (D98\n * item 5). Same digests, same ID, so the build stays a function of its inputs.\n */\n readonly versionId: string;\n /** The `node_modules` the build links: the warm layout, or the artifact's lock layout (D95). */\n readonly nodeModules: string;\n /** Where the client build goes; a server build goes beside it in `server/`. */\n readonly outDir: string;\n /**\n * Tests only (`MOSTRA_TEST_FAULTS=builder:build:hang`, issue #18): the child never answers,\n * as a builder stuck in a plugin would, so the build limit or a kill ends it.\n */\n readonly hang?: true;\n}\n\n/** The builder child's answer. */\nexport type BuildResponse =\n | { readonly ok: true; readonly registry: VersionRegistry; readonly server: boolean }\n | { readonly ok: false; readonly diagnostics: readonly Diagnostic[] };\n\n/** The IPC method the supervisor calls on the builder child. */\nexport const BUILD_METHOD = \"builder/build\";\n\n/**\n * `mostra dev`'s child (D140 item 12): the supervisor asks the builder child for a Vite dev\n * server over a mirror of the artifact's source, reached only through the dev sandbox's gateway.\n */\nexport const DEV_METHOD = \"builder/dev\";\n/**\n * Supervisor to child: these files of the mirror changed (`{ changes: DevChange[] }`). The child\n * watches nothing itself: the supervisor, which keeps the mirror, says exactly what changed.\n */\nexport const DEV_CHANGED_METHOD = \"builder/dev.changed\";\n\n/** One file of the mirror that changed, relative to its `source/`. */\nexport interface DevChange {\n readonly file: string;\n readonly kind: \"add\" | \"change\" | \"unlink\";\n}\n\n/** Supervisor to child: tell every page to load again (a new server bundle runs now). */\nexport const DEV_RELOAD_METHOD = \"builder/dev.reload\";\n/** Child to supervisor: the server bundle was built again (or failed to build). */\nexport const DEV_SERVER_NOTIFICATION = \"builder/dev.server\";\n/** Child to supervisor: the client modules of these files were updated in place (HMR). */\nexport const DEV_UPDATE_NOTIFICATION = \"builder/dev.update\";\n\n/** What the dev child serves. */\nexport interface DevRequest {\n /** The dev root: generated files, `node_modules`, and the mirror of the source in `source/`. */\n readonly root: string;\n readonly entry: string;\n readonly entryHasDefault: boolean;\n readonly manifest: ArtifactManifest;\n /** The dev version's ID, in every page's `mostra-version` meta (D115). */\n readonly versionId: string;\n readonly nodeModules: string;\n /** Where the server bundle and `registry.json` go: the dev version's directory. */\n readonly outDir: string;\n /** The secret every request from the gateway carries; nothing else reaches the dev server. */\n readonly secret: string;\n}\n\n/** The header that carries {@link DevRequest.secret}. */\nexport const DEV_SECRET_HEADER = \"x-mostra-dev-secret\";\n\n/** A server build of the dev child: what `registry.json` now holds, or why it failed. */\nexport type DevServerBuild =\n | { readonly ok: true; readonly registry: VersionRegistry; readonly server: boolean }\n | { readonly ok: false; readonly diagnostics: readonly Diagnostic[] };\n\n/** The dev child's answer to {@link DEV_METHOD}: its loopback port and its first server build. */\nexport interface DevReady {\n readonly port: number;\n readonly build: DevServerBuild;\n}\n\n/**\n * The files written into the staging root so the bundler's upward searches stop there instead of\n * reaching directories above the home (VR-01): a `tsconfig.json` with the compile settings Mostra\n * chooses (an artifact's own `tsconfig.json`, part of its source, still applies to its files),\n * and a `package.json` that marks the build as ES modules. Their contents are part of\n * `buildConfigDigest`.\n */\nexport const STAGING_FILES: Readonly<Record<string, string>> = {\n \"tsconfig.json\": `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n useDefineForClassFields: true,\n jsx: \"react-jsx\",\n jsxImportSource: \"react\",\n experimentalDecorators: false,\n },\n },\n null,\n 2,\n )}\\n`,\n \"package.json\": `${JSON.stringify({ private: true, type: \"module\" }, null, 2)}\\n`,\n};\n\n/**\n * The declaration that types `useLive` from `live.ts` (D56): client code reads the source types\n * through `typeof import`, never by importing server code at run time. Written beside the build's\n * other generated files for the type check, never into the artifact's source.\n */\nexport const LIVE_DECLARATION: string = `// Generated by Mostra: the types of this artifact's live sources (D56).\nimport type { LiveValuesOf } from \"@mostra/react\";\n\ndeclare module \"@mostra/react\" {\n interface LiveSources extends LiveValuesOf<typeof import(\"../source/live\")> {}\n}\n`;\n"],"mappings":";;AAwFA,MAAa,eAAe;;;;;AAM5B,MAAa,aAAa;;;;;AAK1B,MAAa,qBAAqB;;AASlC,MAAa,oBAAoB;;AAEjC,MAAa,0BAA0B;;AAEvC,MAAa,0BAA0B;;AAmBvC,MAAa,oBAAoB;;;;;;;;AAoBjC,MAAa,gBAAkD;CAC7D,iBAAiB,GAAG,KAAK,UACvB,EACE,iBAAiB;EACf,QAAQ;EACR,yBAAyB;EACzB,KAAK;EACL,iBAAiB;EACjB,wBAAwB;CAC1B,EACF,GACA,MACA,CACF,EAAE;CACF,gBAAgB,GAAG,KAAK,UAAU;EAAE,SAAS;EAAM,MAAM;CAAS,GAAG,MAAM,CAAC,EAAE;AAChF;;;;;;AAOA,MAAa,mBAA2B"}