@crvouga/mockingbird-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 (44) hide show
  1. package/README.md +15 -1
  2. package/dist/adapter-node.d.ts +38 -11
  3. package/dist/adapter-node.js +82 -174
  4. package/dist/adapter-node.js.map +4 -4
  5. package/dist/{chunk-OISPHKE2.js → chunk-KD6FHYQP.js} +98 -17
  6. package/dist/{chunk-OISPHKE2.js.map → chunk-KD6FHYQP.js.map} +4 -4
  7. package/dist/{chunk-LL6NKAJO.js → chunk-M4HUKBLC.js} +3 -2
  8. package/dist/chunk-M4HUKBLC.js.map +7 -0
  9. package/dist/chunk-RI2UQCHP.js +21 -0
  10. package/dist/chunk-RI2UQCHP.js.map +7 -0
  11. package/dist/{chunk-2Y25NPCV.js → chunk-U36J5GCB.js} +290 -1
  12. package/dist/{chunk-2Y25NPCV.js.map → chunk-U36J5GCB.js.map} +3 -3
  13. package/dist/{chunk-5WW5N4TU.js → chunk-ZQBZSSSP.js} +3 -3
  14. package/dist/core.d.ts +86 -2
  15. package/dist/core.js +23 -1
  16. package/dist/http-provider.d.ts +2 -0
  17. package/dist/http-provider.js +7 -7
  18. package/dist/http-provider.js.map +1 -1
  19. package/dist/mqtt-broker/node.d.ts +2 -0
  20. package/dist/mqtt-broker/node.js +4 -4
  21. package/dist/mqtt-broker.d.ts +2 -0
  22. package/dist/mqtt-broker.js +4 -4
  23. package/dist/preview/artifacts.d.ts +4 -9
  24. package/dist/preview/artifacts.js +4 -16
  25. package/dist/preview/artifacts.js.map +2 -2
  26. package/dist/preview/bridge.d.ts +8 -8
  27. package/dist/preview/bridge.js +1 -1
  28. package/dist/preview/harness.d.ts +1 -1
  29. package/dist/preview/harness.js +10 -56
  30. package/dist/preview/harness.js.map +2 -2
  31. package/dist/preview/host.d.ts +4 -9
  32. package/dist/preview/host.js +30 -37
  33. package/dist/preview/host.js.map +2 -2
  34. package/dist/service/admin.js +2 -2
  35. package/dist/service.d.ts +11 -4
  36. package/dist/service.js +6 -4
  37. package/dist/ui.d.ts +1 -37
  38. package/dist/ui.js +2 -701
  39. package/dist/ui.js.map +3 -3
  40. package/package.json +7 -6
  41. package/dist/chunk-EBGYPQPA.js +0 -198
  42. package/dist/chunk-EBGYPQPA.js.map +0 -7
  43. package/dist/chunk-LL6NKAJO.js.map +0 -7
  44. /package/dist/{chunk-5WW5N4TU.js.map → chunk-ZQBZSSSP.js.map} +0 -0
@@ -58,6 +58,8 @@ declare class Collection<T> {
58
58
  namespace: string,
59
59
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
60
60
  collectionName: string);
61
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
62
+ private journalRecord;
61
63
  private bumpCollectionSeq;
62
64
  nextSequence(): number;
63
65
  get(id: string): T | undefined;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  MAX_VARIABLE_BYTE_INTEGER,
3
3
  MQTT_WEBSOCKET_PATH
4
- } from "../chunk-5WW5N4TU.js";
5
- import "../chunk-OISPHKE2.js";
4
+ } from "../chunk-ZQBZSSSP.js";
5
+ import "../chunk-KD6FHYQP.js";
6
6
  import "../chunk-2KDYLZXC.js";
7
- import "../chunk-LL6NKAJO.js";
8
- import "../chunk-2Y25NPCV.js";
7
+ import "../chunk-M4HUKBLC.js";
8
+ import "../chunk-U36J5GCB.js";
9
9
  import "../chunk-EQLY2YOA.js";
10
10
  import "../chunk-HU6IOAFC.js";
11
11
  import "../chunk-4SAK6MQT.js";
@@ -333,6 +333,8 @@ declare class Collection<T> {
333
333
  namespace: string,
334
334
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
335
335
  collectionName: string);
336
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
337
+ private journalRecord;
336
338
  private bumpCollectionSeq;
337
339
  nextSequence(): number;
338
340
  get(id: string): T | undefined;
@@ -14,17 +14,17 @@ import {
14
14
  observeClock,
15
15
  takeConnackFault,
16
16
  webSocketNamespace
17
- } from "./chunk-5WW5N4TU.js";
17
+ } from "./chunk-ZQBZSSSP.js";
18
18
  import {
19
19
  Collection,
20
20
  IdSequence
21
- } from "./chunk-OISPHKE2.js";
21
+ } from "./chunk-KD6FHYQP.js";
22
22
  import "./chunk-2KDYLZXC.js";
23
23
  import {
24
24
  fromBase64,
25
25
  toBase64
26
- } from "./chunk-LL6NKAJO.js";
27
- import "./chunk-2Y25NPCV.js";
26
+ } from "./chunk-M4HUKBLC.js";
27
+ import "./chunk-U36J5GCB.js";
28
28
  import "./chunk-EQLY2YOA.js";
29
29
  import "./chunk-HU6IOAFC.js";
30
30
  import "./chunk-4SAK6MQT.js";
@@ -1,14 +1,9 @@
1
+ import { LegacyPreviewArtifact } from '@crvouga/mockingbird-preview';
2
+
1
3
  type WebFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
2
4
 
3
- type PreviewArtifact = {
4
- version: 1;
5
- /** SHA-256 of the decoded JavaScript bytes, as lowercase hex. */
6
- sha256: string;
7
- url: string;
8
- compression?: "gzip";
9
- };
10
- /** Verify before execution. URLs inside a compressed bundle must be absolute or bundled. */
11
- declare function loadPreviewArtifact(artifact: PreviewArtifact, fetcher?: WebFetch): Promise<Uint8Array<ArrayBuffer>>;
5
+ type PreviewArtifact = LegacyPreviewArtifact;
6
+ declare const loadPreviewArtifact: (artifact: PreviewArtifact, fetcher?: WebFetch) => Promise<Uint8Array<ArrayBuffer>>;
12
7
  declare function createPreviewWorker(artifact: PreviewArtifact, options?: WorkerOptions): Promise<{
13
8
  worker: Worker;
14
9
  identity: string;
@@ -1,20 +1,8 @@
1
1
  // src/preview/artifacts.ts
2
- async function loadPreviewArtifact(artifact, fetcher = fetch) {
3
- if (artifact.version !== 1) throw new Error("Unsupported preview artifact version");
4
- if (!/^[a-f0-9]{64}$/.test(artifact.sha256)) throw new Error("Invalid preview artifact SHA-256");
5
- if (artifact.compression !== void 0 && artifact.compression !== "gzip")
6
- throw new Error("Unsupported preview artifact compression");
7
- const response = await fetcher(artifact.url, { cache: "no-store", credentials: "omit" });
8
- if (!response.ok || !response.body)
9
- throw new Error(`Preview artifact ${artifact.url}: HTTP ${response.status}`);
10
- const stream = artifact.compression === "gzip" ? response.body.pipeThrough(new DecompressionStream("gzip")) : response.body;
11
- const bytes = new Uint8Array(await new Response(stream).arrayBuffer());
12
- const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
13
- const identity = [...digest].map((byte) => byte.toString(16).padStart(2, "0")).join("");
14
- if (identity !== artifact.sha256)
15
- throw new Error(`Preview artifact identity mismatch: ${artifact.url}`);
16
- return bytes;
17
- }
2
+ import {
3
+ loadPreviewArtifact as loadArtifact
4
+ } from "@crvouga/mockingbird-preview";
5
+ var loadPreviewArtifact = (artifact, fetcher = fetch) => loadArtifact(artifact, { fetch: fetcher });
18
6
  async function createPreviewWorker(artifact, options = {}) {
19
7
  const bytes = await loadPreviewArtifact(artifact);
20
8
  const url = URL.createObjectURL(new Blob([bytes], { type: "text/javascript" }));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/preview/artifacts.ts"],
4
- "sourcesContent": ["import type { WebFetch } from \"./types.js\"\n\nexport type PreviewArtifact = {\n version: 1\n /** SHA-256 of the decoded JavaScript bytes, as lowercase hex. */\n sha256: string\n url: string\n compression?: \"gzip\"\n}\n\n/** Verify before execution. URLs inside a compressed bundle must be absolute or bundled. */\nexport async function loadPreviewArtifact(\n artifact: PreviewArtifact,\n fetcher: WebFetch = fetch,\n): Promise<Uint8Array<ArrayBuffer>> {\n if (artifact.version !== 1) throw new Error(\"Unsupported preview artifact version\")\n if (!/^[a-f0-9]{64}$/.test(artifact.sha256)) throw new Error(\"Invalid preview artifact SHA-256\")\n if (artifact.compression !== undefined && artifact.compression !== \"gzip\")\n throw new Error(\"Unsupported preview artifact compression\")\n const response = await fetcher(artifact.url, { cache: \"no-store\", credentials: \"omit\" })\n if (!response.ok || !response.body)\n throw new Error(`Preview artifact ${artifact.url}: HTTP ${response.status}`)\n const stream =\n artifact.compression === \"gzip\"\n ? response.body.pipeThrough(new DecompressionStream(\"gzip\"))\n : response.body\n const bytes = new Uint8Array(await new Response(stream).arrayBuffer())\n const digest = new Uint8Array(await crypto.subtle.digest(\"SHA-256\", bytes))\n const identity = [...digest].map((byte) => byte.toString(16).padStart(2, \"0\")).join(\"\")\n if (identity !== artifact.sha256)\n throw new Error(`Preview artifact identity mismatch: ${artifact.url}`)\n return bytes\n}\n\nexport async function createPreviewWorker(artifact: PreviewArtifact, options: WorkerOptions = {}) {\n const bytes = await loadPreviewArtifact(artifact)\n const url = URL.createObjectURL(new Blob([bytes], { type: \"text/javascript\" }))\n try {\n const worker = new Worker(url, { ...options, type: \"module\" })\n return {\n worker,\n identity: artifact.sha256,\n dispose() {\n worker.terminate()\n URL.revokeObjectURL(url)\n },\n }\n } catch (error) {\n URL.revokeObjectURL(url)\n throw error\n }\n}\n"],
5
- "mappings": ";AAWA,eAAsB,oBACpB,UACA,UAAoB,OACc;AAClC,MAAI,SAAS,YAAY,EAAG,OAAM,IAAI,MAAM,sCAAsC;AAClF,MAAI,CAAC,iBAAiB,KAAK,SAAS,MAAM,EAAG,OAAM,IAAI,MAAM,kCAAkC;AAC/F,MAAI,SAAS,gBAAgB,UAAa,SAAS,gBAAgB;AACjE,UAAM,IAAI,MAAM,0CAA0C;AAC5D,QAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,EAAE,OAAO,YAAY,aAAa,OAAO,CAAC;AACvF,MAAI,CAAC,SAAS,MAAM,CAAC,SAAS;AAC5B,UAAM,IAAI,MAAM,oBAAoB,SAAS,GAAG,UAAU,SAAS,MAAM,EAAE;AAC7E,QAAM,SACJ,SAAS,gBAAgB,SACrB,SAAS,KAAK,YAAY,IAAI,oBAAoB,MAAM,CAAC,IACzD,SAAS;AACf,QAAM,QAAQ,IAAI,WAAW,MAAM,IAAI,SAAS,MAAM,EAAE,YAAY,CAAC;AACrE,QAAM,SAAS,IAAI,WAAW,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK,CAAC;AAC1E,QAAM,WAAW,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AACtF,MAAI,aAAa,SAAS;AACxB,UAAM,IAAI,MAAM,uCAAuC,SAAS,GAAG,EAAE;AACvE,SAAO;AACT;AAEA,eAAsB,oBAAoB,UAA2B,UAAyB,CAAC,GAAG;AAChG,QAAM,QAAQ,MAAM,oBAAoB,QAAQ;AAChD,QAAM,MAAM,IAAI,gBAAgB,IAAI,KAAK,CAAC,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AAC9E,MAAI;AACF,UAAM,SAAS,IAAI,OAAO,KAAK,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAC7D,WAAO;AAAA,MACL;AAAA,MACA,UAAU,SAAS;AAAA,MACnB,UAAU;AACR,eAAO,UAAU;AACjB,YAAI,gBAAgB,GAAG;AAAA,MACzB;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,QAAI,gBAAgB,GAAG;AACvB,UAAM;AAAA,EACR;AACF;",
4
+ "sourcesContent": ["import {\n type LegacyPreviewArtifact,\n loadPreviewArtifact as loadArtifact,\n} from \"@crvouga/mockingbird-preview\"\nimport type { WebFetch } from \"./types.js\"\nexport type PreviewArtifact = LegacyPreviewArtifact\nexport const loadPreviewArtifact = (artifact: PreviewArtifact, fetcher: WebFetch = fetch) =>\n loadArtifact(artifact, { fetch: fetcher })\n\nexport async function createPreviewWorker(artifact: PreviewArtifact, options: WorkerOptions = {}) {\n const bytes = await loadPreviewArtifact(artifact)\n const url = URL.createObjectURL(new Blob([bytes], { type: \"text/javascript\" }))\n try {\n const worker = new Worker(url, { ...options, type: \"module\" })\n return {\n worker,\n identity: artifact.sha256,\n dispose() {\n worker.terminate()\n URL.revokeObjectURL(url)\n },\n }\n } catch (error) {\n URL.revokeObjectURL(url)\n throw error\n }\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EAEE,uBAAuB;AAAA,OAClB;AAGA,IAAM,sBAAsB,CAAC,UAA2B,UAAoB,UACjF,aAAa,UAAU,EAAE,OAAO,QAAQ,CAAC;AAE3C,eAAsB,oBAAoB,UAA2B,UAAyB,CAAC,GAAG;AAChG,QAAM,QAAQ,MAAM,oBAAoB,QAAQ;AAChD,QAAM,MAAM,IAAI,gBAAgB,IAAI,KAAK,CAAC,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;AAC9E,MAAI;AACF,UAAM,SAAS,IAAI,OAAO,KAAK,EAAE,GAAG,SAAS,MAAM,SAAS,CAAC;AAC7D,WAAO;AAAA,MACL;AAAA,MACA,UAAU,SAAS;AAAA,MACnB,UAAU;AACR,eAAO,UAAU;AACjB,YAAI,gBAAgB,GAAG;AAAA,MACzB;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,QAAI,gBAAgB,GAAG;AACvB,UAAM;AAAA,EACR;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,21 +1,21 @@
1
- type WebFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
1
+ import { PreviewPort } from '@crvouga/mockingbird-preview';
2
+ export { PreviewPort } from '@crvouga/mockingbird-preview';
3
+
2
4
  type FetchHandler = (request: Request) => Response | Promise<Response>;
3
5
 
4
- /** MessagePort subset shared by browsers and node:worker_threads. */
5
- type PreviewPort = Pick<MessagePort, "postMessage" | "addEventListener" | "removeEventListener" | "start" | "close">;
6
- /** One channel per request; response chunks are pulled, never buffered without bound. */
6
+ /** Compatibility entry: explicit virtual cookie headers and error messages retain the original API. */
7
7
  declare function createPreviewClient(port: PreviewPort, options?: {
8
8
  timeoutMs?: number;
9
9
  }): {
10
- fetch: WebFetch;
11
- dispose(reason?: Error): void;
10
+ fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
11
+ dispose: (reason?: Error) => void;
12
+ readonly pending: number;
12
13
  };
13
- /** Attach each dedicated-worker or SharedWorker client port to the same handler. */
14
14
  declare function attachPreviewHost(port: PreviewPort, fetch: FetchHandler, options?: {
15
15
  onDisconnect?: () => void;
16
16
  }): {
17
17
  dispose: () => void;
18
+ readonly active: number;
18
19
  };
19
20
 
20
21
  export { attachPreviewHost, createPreviewClient };
21
- export type { PreviewPort };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  attachPreviewHost,
3
3
  createPreviewClient
4
- } from "../chunk-EBGYPQPA.js";
4
+ } from "../chunk-RI2UQCHP.js";
5
5
  export {
6
6
  attachPreviewHost,
7
7
  createPreviewClient
@@ -1,6 +1,6 @@
1
1
  type WebFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
2
2
 
3
- /** Expose the same page-to-worker client to Node E2E clients; no emulator duplication. */
3
+ /** Keep the original logical-origin routing while using the shared HTTP adapter. */
4
4
  declare function startPreviewHarness(fetch: WebFetch, options: {
5
5
  origin: string;
6
6
  port?: number;
@@ -1,63 +1,17 @@
1
1
  // src/preview/harness.ts
2
- import { createServer } from "node:http";
3
- import { Readable } from "node:stream";
4
- import { pipeline } from "node:stream/promises";
2
+ import { listenPreview } from "@crvouga/mockingbird-preview/node";
5
3
  async function startPreviewHarness(fetch, options) {
6
- const server = createServer(async (incoming, outgoing) => {
7
- const controller = new AbortController();
8
- outgoing.on("close", () => controller.abort());
9
- try {
10
- const url = new URL(options.origin);
11
- const path = new URL(incoming.url ?? "/", "http://harness.invalid");
4
+ const origin = new URL(options.origin);
5
+ return listenPreview(
6
+ (request) => {
7
+ const path = new URL(request.url);
8
+ const url = new URL(origin);
12
9
  url.pathname = path.pathname;
13
10
  url.search = path.search;
14
- const headers = new Headers();
15
- for (let i = 0; i < incoming.rawHeaders.length; i += 2)
16
- headers.append(incoming.rawHeaders[i] ?? "", incoming.rawHeaders[i + 1] ?? "");
17
- const chunks = [];
18
- for await (const chunk of incoming) chunks.push(Buffer.from(chunk));
19
- const response = await fetch(url, {
20
- method: incoming.method ?? "GET",
21
- headers,
22
- ...chunks.length ? { body: Buffer.concat(chunks) } : {},
23
- signal: controller.signal,
24
- redirect: "manual"
25
- });
26
- outgoing.statusCode = response.status;
27
- for (const [key, value] of response.headers)
28
- if (key !== "set-cookie") outgoing.setHeader(key, value);
29
- const cookies = response.headers.getSetCookie();
30
- if (cookies.length) outgoing.setHeader("set-cookie", cookies);
31
- outgoing.setHeader("cache-control", "no-store");
32
- outgoing.flushHeaders();
33
- if (response.body)
34
- await pipeline(
35
- Readable.fromWeb(response.body),
36
- outgoing
37
- );
38
- else outgoing.end();
39
- } catch (error) {
40
- if (outgoing.headersSent)
41
- outgoing.destroy(error instanceof Error ? error : new Error(String(error)));
42
- else {
43
- outgoing.statusCode = 502;
44
- outgoing.end("Preview request failed");
45
- }
46
- }
47
- });
48
- await new Promise((resolve, reject) => {
49
- server.once("error", reject);
50
- server.listen(options.port ?? 0, "127.0.0.1", resolve);
51
- });
52
- const address = server.address();
53
- if (!address || typeof address === "string") throw new Error("Preview harness has no address");
54
- return {
55
- url: `http://127.0.0.1:${address.port}`,
56
- close: () => new Promise((resolve, reject) => {
57
- server.close((error) => error ? reject(error) : resolve());
58
- server.closeAllConnections();
59
- })
60
- };
11
+ return fetch(new Request(url, request));
12
+ },
13
+ { ...options.port !== void 0 ? { port: options.port } : {} }
14
+ );
61
15
  }
62
16
  export {
63
17
  startPreviewHarness
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/preview/harness.ts"],
4
- "sourcesContent": ["import { createServer } from \"node:http\"\nimport { Readable } from \"node:stream\"\nimport { pipeline } from \"node:stream/promises\"\nimport type { WebFetch } from \"./types.js\"\n\n/** Expose the same page-to-worker client to Node E2E clients; no emulator duplication. */\nexport async function startPreviewHarness(\n fetch: WebFetch,\n options: { origin: string; port?: number },\n) {\n const server = createServer(async (incoming, outgoing) => {\n const controller = new AbortController()\n outgoing.on(\"close\", () => controller.abort())\n try {\n const url = new URL(options.origin)\n const path = new URL(incoming.url ?? \"/\", \"http://harness.invalid\")\n url.pathname = path.pathname\n url.search = path.search\n const headers = new Headers()\n for (let i = 0; i < incoming.rawHeaders.length; i += 2)\n headers.append(incoming.rawHeaders[i] ?? \"\", incoming.rawHeaders[i + 1] ?? \"\")\n const chunks: Buffer[] = []\n for await (const chunk of incoming) chunks.push(Buffer.from(chunk))\n const response = await fetch(url, {\n method: incoming.method ?? \"GET\",\n headers,\n ...(chunks.length ? { body: Buffer.concat(chunks) } : {}),\n signal: controller.signal,\n redirect: \"manual\",\n })\n outgoing.statusCode = response.status\n for (const [key, value] of response.headers)\n if (key !== \"set-cookie\") outgoing.setHeader(key, value)\n const cookies = response.headers.getSetCookie()\n if (cookies.length) outgoing.setHeader(\"set-cookie\", cookies)\n outgoing.setHeader(\"cache-control\", \"no-store\")\n outgoing.flushHeaders()\n if (response.body)\n await pipeline(\n Readable.fromWeb(response.body as unknown as Parameters<typeof Readable.fromWeb>[0]),\n outgoing,\n )\n else outgoing.end()\n } catch (error) {\n if (outgoing.headersSent)\n outgoing.destroy(error instanceof Error ? error : new Error(String(error)))\n else {\n outgoing.statusCode = 502\n outgoing.end(\"Preview request failed\")\n }\n }\n })\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject)\n server.listen(options.port ?? 0, \"127.0.0.1\", resolve)\n })\n const address = server.address()\n if (!address || typeof address === \"string\") throw new Error(\"Preview harness has no address\")\n return {\n url: `http://127.0.0.1:${address.port}`,\n close: () =>\n new Promise<void>((resolve, reject) => {\n server.close((error) => (error ? reject(error) : resolve()))\n server.closeAllConnections()\n }),\n }\n}\n"],
5
- "mappings": ";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AAIzB,eAAsB,oBACpB,OACA,SACA;AACA,QAAM,SAAS,aAAa,OAAO,UAAU,aAAa;AACxD,UAAM,aAAa,IAAI,gBAAgB;AACvC,aAAS,GAAG,SAAS,MAAM,WAAW,MAAM,CAAC;AAC7C,QAAI;AACF,YAAM,MAAM,IAAI,IAAI,QAAQ,MAAM;AAClC,YAAM,OAAO,IAAI,IAAI,SAAS,OAAO,KAAK,wBAAwB;AAClE,UAAI,WAAW,KAAK;AACpB,UAAI,SAAS,KAAK;AAClB,YAAM,UAAU,IAAI,QAAQ;AAC5B,eAAS,IAAI,GAAG,IAAI,SAAS,WAAW,QAAQ,KAAK;AACnD,gBAAQ,OAAO,SAAS,WAAW,CAAC,KAAK,IAAI,SAAS,WAAW,IAAI,CAAC,KAAK,EAAE;AAC/E,YAAM,SAAmB,CAAC;AAC1B,uBAAiB,SAAS,SAAU,QAAO,KAAK,OAAO,KAAK,KAAK,CAAC;AAClE,YAAM,WAAW,MAAM,MAAM,KAAK;AAAA,QAChC,QAAQ,SAAS,UAAU;AAAA,QAC3B;AAAA,QACA,GAAI,OAAO,SAAS,EAAE,MAAM,OAAO,OAAO,MAAM,EAAE,IAAI,CAAC;AAAA,QACvD,QAAQ,WAAW;AAAA,QACnB,UAAU;AAAA,MACZ,CAAC;AACD,eAAS,aAAa,SAAS;AAC/B,iBAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,YAAI,QAAQ,aAAc,UAAS,UAAU,KAAK,KAAK;AACzD,YAAM,UAAU,SAAS,QAAQ,aAAa;AAC9C,UAAI,QAAQ,OAAQ,UAAS,UAAU,cAAc,OAAO;AAC5D,eAAS,UAAU,iBAAiB,UAAU;AAC9C,eAAS,aAAa;AACtB,UAAI,SAAS;AACX,cAAM;AAAA,UACJ,SAAS,QAAQ,SAAS,IAAyD;AAAA,UACnF;AAAA,QACF;AAAA,UACG,UAAS,IAAI;AAAA,IACpB,SAAS,OAAO;AACd,UAAI,SAAS;AACX,iBAAS,QAAQ,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;AAAA,WACvE;AACH,iBAAS,aAAa;AACtB,iBAAS,IAAI,wBAAwB;AAAA,MACvC;AAAA,IACF;AAAA,EACF,CAAC;AACD,QAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AAC3C,WAAO,KAAK,SAAS,MAAM;AAC3B,WAAO,OAAO,QAAQ,QAAQ,GAAG,aAAa,OAAO;AAAA,EACvD,CAAC;AACD,QAAM,UAAU,OAAO,QAAQ;AAC/B,MAAI,CAAC,WAAW,OAAO,YAAY,SAAU,OAAM,IAAI,MAAM,gCAAgC;AAC7F,SAAO;AAAA,IACL,KAAK,oBAAoB,QAAQ,IAAI;AAAA,IACrC,OAAO,MACL,IAAI,QAAc,CAAC,SAAS,WAAW;AACrC,aAAO,MAAM,CAAC,UAAW,QAAQ,OAAO,KAAK,IAAI,QAAQ,CAAE;AAC3D,aAAO,oBAAoB;AAAA,IAC7B,CAAC;AAAA,EACL;AACF;",
4
+ "sourcesContent": ["import { listenPreview } from \"@crvouga/mockingbird-preview/node\"\nimport type { WebFetch } from \"./types.js\"\n\n/** Keep the original logical-origin routing while using the shared HTTP adapter. */\nexport async function startPreviewHarness(\n fetch: WebFetch,\n options: { origin: string; port?: number },\n) {\n const origin = new URL(options.origin)\n return listenPreview(\n (request) => {\n const path = new URL(request.url)\n const url = new URL(origin)\n url.pathname = path.pathname\n url.search = path.search\n return fetch(new Request(url, request))\n },\n { ...(options.port !== undefined ? { port: options.port } : {}) },\n )\n}\n"],
5
+ "mappings": ";AAAA,SAAS,qBAAqB;AAI9B,eAAsB,oBACpB,OACA,SACA;AACA,QAAM,SAAS,IAAI,IAAI,QAAQ,MAAM;AACrC,SAAO;AAAA,IACL,CAAC,YAAY;AACX,YAAM,OAAO,IAAI,IAAI,QAAQ,GAAG;AAChC,YAAM,MAAM,IAAI,IAAI,MAAM;AAC1B,UAAI,WAAW,KAAK;AACpB,UAAI,SAAS,KAAK;AAClB,aAAO,MAAM,IAAI,QAAQ,KAAK,OAAO,CAAC;AAAA,IACxC;AAAA,IACA,EAAE,GAAI,QAAQ,SAAS,SAAY,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC,EAAG;AAAA,EAClE;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,6 @@
1
- type FetchHandler = (request: Request) => Response | Promise<Response>;
1
+ import { PreviewPort } from '@crvouga/mockingbird-preview';
2
2
 
3
- /** MessagePort subset shared by browsers and node:worker_threads. */
4
- type PreviewPort = Pick<MessagePort, "postMessage" | "addEventListener" | "removeEventListener" | "start" | "close">;
3
+ type FetchHandler = (request: Request) => Response | Promise<Response>;
5
4
 
6
5
  type PreviewApplication = {
7
6
  fetch: FetchHandler;
@@ -12,16 +11,12 @@ type PreviewState = {
12
11
  status: "starting" | "ready" | "error" | "disposed";
13
12
  error?: string;
14
13
  };
15
- /** Shared application lifetime, independent of any single page connection. */
14
+ /** Preserve the original generation numbering and promise-shaped readiness on the shared host. */
16
15
  declare function createPreviewHost(create: (generation: number) => Promise<PreviewApplication> | PreviewApplication): {
17
16
  ready: Promise<void>;
18
17
  fetch: FetchHandler;
19
18
  reset: () => Promise<void>;
20
- state: () => {
21
- generation: number;
22
- status: "starting" | "ready" | "error" | "disposed";
23
- error?: string;
24
- };
19
+ state(): PreviewState;
25
20
  connect(port: PreviewPort): () => void;
26
21
  dispose(): Promise<void>;
27
22
  };
@@ -1,50 +1,48 @@
1
1
  import {
2
2
  attachPreviewHost
3
- } from "../chunk-EBGYPQPA.js";
3
+ } from "../chunk-RI2UQCHP.js";
4
4
 
5
5
  // src/preview/host.ts
6
+ import { createPreviewHost as createHost } from "@crvouga/mockingbird-preview";
6
7
  function createPreviewHost(create) {
7
- let state = { generation: 0, status: "starting" };
8
- let application;
9
- let closed = false;
10
- const clients = /* @__PURE__ */ new Set();
11
- let work = Promise.resolve();
12
- const reset = () => {
13
- if (closed) return Promise.reject(new Error("Preview host disposed"));
14
- work = work.catch(() => void 0).then(async () => {
15
- if (closed) return;
16
- state = { generation: state.generation + 1, status: "starting" };
8
+ let failure;
9
+ const host = createHost({
10
+ artifact: "runtime-preview-compatibility",
11
+ boot: async ({ generation }) => {
12
+ failure = void 0;
17
13
  try {
18
- const previous = application;
19
- application = void 0;
20
- await previous?.dispose();
21
- const next = await create(state.generation);
22
- if (closed) {
23
- await next.dispose();
24
- return;
25
- }
26
- application = next;
27
- state = { generation: state.generation, status: "ready" };
14
+ return await create(generation + 1);
28
15
  } catch (error) {
29
- state = { generation: state.generation, status: "error", error: String(error) };
16
+ failure = error;
30
17
  throw error;
31
18
  }
32
- });
33
- return work;
19
+ }
20
+ });
21
+ const checked = async (work) => {
22
+ await work;
23
+ if (host.status().state === "failed") throw failure ?? new Error("Preview host unavailable");
34
24
  };
35
- const ready = reset();
25
+ const ready = checked(host.ready());
26
+ const clients = /* @__PURE__ */ new Set();
36
27
  const fetch = async (request) => {
37
- await work;
38
- if (closed || !application) throw new Error("Preview host unavailable");
39
- return application.fetch(request);
28
+ await checked(host.ready());
29
+ if (host.status().state === "disposed") throw new Error("Preview host unavailable");
30
+ return host.fetch(request);
40
31
  };
41
32
  return {
42
33
  ready,
43
34
  fetch,
44
- reset,
45
- state: () => ({ ...state }),
35
+ reset: () => checked(host.reset()),
36
+ state() {
37
+ const current = host.status();
38
+ return {
39
+ generation: current.generation + 1,
40
+ status: current.state === "failed" ? "error" : current.state,
41
+ ...current.state === "failed" ? { error: String(failure ?? "Preview host unavailable") } : {}
42
+ };
43
+ },
46
44
  connect(port) {
47
- if (closed) throw new Error("Preview host disposed");
45
+ if (host.status().state === "disposed") throw new Error("Preview host disposed");
48
46
  const client = attachPreviewHost(port, fetch, { onDisconnect: () => clients.delete(client) });
49
47
  clients.add(client);
50
48
  return () => {
@@ -53,14 +51,9 @@ function createPreviewHost(create) {
53
51
  };
54
52
  },
55
53
  async dispose() {
56
- if (closed) return;
57
- closed = true;
58
54
  for (const client of clients) client.dispose();
59
55
  clients.clear();
60
- await work.catch(() => void 0);
61
- await application?.dispose();
62
- application = void 0;
63
- state = { generation: state.generation, status: "disposed" };
56
+ await host.dispose();
64
57
  }
65
58
  };
66
59
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/preview/host.ts"],
4
- "sourcesContent": ["import { attachPreviewHost, type PreviewPort } from \"./bridge.js\"\nimport type { FetchHandler } from \"./types.js\"\n\nexport type PreviewApplication = { fetch: FetchHandler; dispose(): void | Promise<void> }\nexport type PreviewState = {\n generation: number\n status: \"starting\" | \"ready\" | \"error\" | \"disposed\"\n error?: string\n}\n\n/** Shared application lifetime, independent of any single page connection. */\nexport function createPreviewHost(\n create: (generation: number) => Promise<PreviewApplication> | PreviewApplication,\n) {\n let state: PreviewState = { generation: 0, status: \"starting\" }\n let application: PreviewApplication | undefined\n let closed = false\n const clients = new Set<ReturnType<typeof attachPreviewHost>>()\n let work: Promise<void> = Promise.resolve()\n const reset = () => {\n if (closed) return Promise.reject(new Error(\"Preview host disposed\"))\n work = work\n .catch(() => undefined)\n .then(async () => {\n if (closed) return\n state = { generation: state.generation + 1, status: \"starting\" }\n try {\n const previous = application\n application = undefined\n await previous?.dispose()\n const next = await create(state.generation)\n if (closed) {\n await next.dispose()\n return\n }\n application = next\n state = { generation: state.generation, status: \"ready\" }\n } catch (error) {\n state = { generation: state.generation, status: \"error\", error: String(error) }\n throw error\n }\n })\n return work\n }\n const ready = reset()\n const fetch: FetchHandler = async (request) => {\n await work\n if (closed || !application) throw new Error(\"Preview host unavailable\")\n return application.fetch(request)\n }\n return {\n ready,\n fetch,\n reset,\n state: () => ({ ...state }),\n connect(port: PreviewPort) {\n if (closed) throw new Error(\"Preview host disposed\")\n const client = attachPreviewHost(port, fetch, { onDisconnect: () => clients.delete(client) })\n clients.add(client)\n return () => {\n client.dispose()\n clients.delete(client)\n }\n },\n async dispose() {\n if (closed) return\n closed = true\n for (const client of clients) client.dispose()\n clients.clear()\n await work.catch(() => undefined)\n await application?.dispose()\n application = undefined\n state = { generation: state.generation, status: \"disposed\" }\n },\n }\n}\n"],
5
- "mappings": ";;;;;AAWO,SAAS,kBACd,QACA;AACA,MAAI,QAAsB,EAAE,YAAY,GAAG,QAAQ,WAAW;AAC9D,MAAI;AACJ,MAAI,SAAS;AACb,QAAM,UAAU,oBAAI,IAA0C;AAC9D,MAAI,OAAsB,QAAQ,QAAQ;AAC1C,QAAM,QAAQ,MAAM;AAClB,QAAI,OAAQ,QAAO,QAAQ,OAAO,IAAI,MAAM,uBAAuB,CAAC;AACpE,WAAO,KACJ,MAAM,MAAM,MAAS,EACrB,KAAK,YAAY;AAChB,UAAI,OAAQ;AACZ,cAAQ,EAAE,YAAY,MAAM,aAAa,GAAG,QAAQ,WAAW;AAC/D,UAAI;AACF,cAAM,WAAW;AACjB,sBAAc;AACd,cAAM,UAAU,QAAQ;AACxB,cAAM,OAAO,MAAM,OAAO,MAAM,UAAU;AAC1C,YAAI,QAAQ;AACV,gBAAM,KAAK,QAAQ;AACnB;AAAA,QACF;AACA,sBAAc;AACd,gBAAQ,EAAE,YAAY,MAAM,YAAY,QAAQ,QAAQ;AAAA,MAC1D,SAAS,OAAO;AACd,gBAAQ,EAAE,YAAY,MAAM,YAAY,QAAQ,SAAS,OAAO,OAAO,KAAK,EAAE;AAC9E,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AACH,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,MAAM;AACpB,QAAM,QAAsB,OAAO,YAAY;AAC7C,UAAM;AACN,QAAI,UAAU,CAAC,YAAa,OAAM,IAAI,MAAM,0BAA0B;AACtE,WAAO,YAAY,MAAM,OAAO;AAAA,EAClC;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,OAAO,EAAE,GAAG,MAAM;AAAA,IACzB,QAAQ,MAAmB;AACzB,UAAI,OAAQ,OAAM,IAAI,MAAM,uBAAuB;AACnD,YAAM,SAAS,kBAAkB,MAAM,OAAO,EAAE,cAAc,MAAM,QAAQ,OAAO,MAAM,EAAE,CAAC;AAC5F,cAAQ,IAAI,MAAM;AAClB,aAAO,MAAM;AACX,eAAO,QAAQ;AACf,gBAAQ,OAAO,MAAM;AAAA,MACvB;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,UAAI,OAAQ;AACZ,eAAS;AACT,iBAAW,UAAU,QAAS,QAAO,QAAQ;AAC7C,cAAQ,MAAM;AACd,YAAM,KAAK,MAAM,MAAM,MAAS;AAChC,YAAM,aAAa,QAAQ;AAC3B,oBAAc;AACd,cAAQ,EAAE,YAAY,MAAM,YAAY,QAAQ,WAAW;AAAA,IAC7D;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { createPreviewHost as createHost } from \"@crvouga/mockingbird-preview\"\nimport { attachPreviewHost, type PreviewPort } from \"./bridge.js\"\nimport type { FetchHandler } from \"./types.js\"\n\nexport type PreviewApplication = { fetch: FetchHandler; dispose(): void | Promise<void> }\nexport type PreviewState = {\n generation: number\n status: \"starting\" | \"ready\" | \"error\" | \"disposed\"\n error?: string\n}\n\n/** Preserve the original generation numbering and promise-shaped readiness on the shared host. */\nexport function createPreviewHost(\n create: (generation: number) => Promise<PreviewApplication> | PreviewApplication,\n) {\n let failure: unknown\n const host = createHost({\n artifact: \"runtime-preview-compatibility\",\n boot: async ({ generation }) => {\n failure = undefined\n try {\n return await create(generation + 1)\n } catch (error) {\n failure = error\n throw error\n }\n },\n })\n const checked = async (work: Promise<void>) => {\n await work\n if (host.status().state === \"failed\") throw failure ?? new Error(\"Preview host unavailable\")\n }\n const ready = checked(host.ready())\n const clients = new Set<ReturnType<typeof attachPreviewHost>>()\n const fetch: FetchHandler = async (request) => {\n await checked(host.ready())\n if (host.status().state === \"disposed\") throw new Error(\"Preview host unavailable\")\n return host.fetch(request)\n }\n return {\n ready,\n fetch,\n reset: () => checked(host.reset()),\n state(): PreviewState {\n const current = host.status()\n return {\n generation: current.generation + 1,\n status: current.state === \"failed\" ? \"error\" : current.state,\n ...(current.state === \"failed\"\n ? { error: String(failure ?? \"Preview host unavailable\") }\n : {}),\n }\n },\n connect(port: PreviewPort) {\n if (host.status().state === \"disposed\") throw new Error(\"Preview host disposed\")\n const client = attachPreviewHost(port, fetch, { onDisconnect: () => clients.delete(client) })\n clients.add(client)\n return () => {\n client.dispose()\n clients.delete(client)\n }\n },\n async dispose() {\n for (const client of clients) client.dispose()\n clients.clear()\n await host.dispose()\n },\n }\n}\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,qBAAqB,kBAAkB;AAYzC,SAAS,kBACd,QACA;AACA,MAAI;AACJ,QAAM,OAAO,WAAW;AAAA,IACtB,UAAU;AAAA,IACV,MAAM,OAAO,EAAE,WAAW,MAAM;AAC9B,gBAAU;AACV,UAAI;AACF,eAAO,MAAM,OAAO,aAAa,CAAC;AAAA,MACpC,SAAS,OAAO;AACd,kBAAU;AACV,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF,CAAC;AACD,QAAM,UAAU,OAAO,SAAwB;AAC7C,UAAM;AACN,QAAI,KAAK,OAAO,EAAE,UAAU,SAAU,OAAM,WAAW,IAAI,MAAM,0BAA0B;AAAA,EAC7F;AACA,QAAM,QAAQ,QAAQ,KAAK,MAAM,CAAC;AAClC,QAAM,UAAU,oBAAI,IAA0C;AAC9D,QAAM,QAAsB,OAAO,YAAY;AAC7C,UAAM,QAAQ,KAAK,MAAM,CAAC;AAC1B,QAAI,KAAK,OAAO,EAAE,UAAU,WAAY,OAAM,IAAI,MAAM,0BAA0B;AAClF,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO,MAAM,QAAQ,KAAK,MAAM,CAAC;AAAA,IACjC,QAAsB;AACpB,YAAM,UAAU,KAAK,OAAO;AAC5B,aAAO;AAAA,QACL,YAAY,QAAQ,aAAa;AAAA,QACjC,QAAQ,QAAQ,UAAU,WAAW,UAAU,QAAQ;AAAA,QACvD,GAAI,QAAQ,UAAU,WAClB,EAAE,OAAO,OAAO,WAAW,0BAA0B,EAAE,IACvD,CAAC;AAAA,MACP;AAAA,IACF;AAAA,IACA,QAAQ,MAAmB;AACzB,UAAI,KAAK,OAAO,EAAE,UAAU,WAAY,OAAM,IAAI,MAAM,uBAAuB;AAC/E,YAAM,SAAS,kBAAkB,MAAM,OAAO,EAAE,cAAc,MAAM,QAAQ,OAAO,MAAM,EAAE,CAAC;AAC5F,cAAQ,IAAI,MAAM;AAClB,aAAO,MAAM;AACX,eAAO,QAAQ;AACf,gBAAQ,OAAO,MAAM;AAAA,MACvB;AAAA,IACF;AAAA,IACA,MAAM,UAAU;AACd,iBAAW,UAAU,QAAS,QAAO,QAAQ;AAC7C,cAAQ,MAAM;AACd,YAAM,KAAK,QAAQ;AAAA,IACrB;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -7,8 +7,8 @@ import {
7
7
  createMetrics,
8
8
  maskCredential,
9
9
  resolveAdminPrefix
10
- } from "../chunk-LL6NKAJO.js";
11
- import "../chunk-2Y25NPCV.js";
10
+ } from "../chunk-M4HUKBLC.js";
11
+ import "../chunk-U36J5GCB.js";
12
12
 
13
13
  // ../service/core/dist/engine-admin.js
14
14
  var SQL_ADMIN_EXTENSION = {
package/dist/service.d.ts CHANGED
@@ -172,6 +172,7 @@ type UpstreamOptions = {
172
172
  mode?: "emulated" | "forward";
173
173
  rewriteAuth?: (request: Request) => Request | Promise<Request>;
174
174
  };
175
+ declare const upstreamRequest: (request: Request, baseUrl: string) => Request;
175
176
 
176
177
  /**
177
178
  * Seeded pseudo-random numbers, so anything a mock invents — ids, jitter, which
@@ -1517,9 +1518,12 @@ declare const snapshotNamespace: (sqlite: SqliteClient, namespace: string) => Na
1517
1518
  */
1518
1519
  declare const restoreNamespace: (sqlite: SqliteClient, namespace: string, snapshot: NamespaceSnapshot) => void;
1519
1520
  /**
1520
- * Execute asynchronous service work atomically using the canonical Timeline rollback primitive.
1521
- * This is the prescribed escape hatch when the SQLite adapter cannot hold a transaction across
1522
- * `await`; service code should not coordinate raw namespace snapshots itself.
1521
+ * Execute asynchronous service work atomically: on a throw, every record and collection
1522
+ * sequence `run` wrote in `namespace` goes back to how it was. Only the rows the work touched
1523
+ * are saved and restored, so the cost follows the write, not the size of the namespace. Every
1524
+ * namespace write goes through {@link Collection}, which records into the open journal. This is
1525
+ * the prescribed escape hatch when the SQLite adapter cannot hold a transaction across `await`;
1526
+ * service code should not coordinate raw namespace snapshots itself.
1523
1527
  */
1524
1528
  declare const withNamespaceRollback: <T>(sqlite: SqliteClient, namespace: string, run: () => Promise<T>) => Promise<T>;
1525
1529
 
@@ -1551,6 +1555,8 @@ declare class Collection<T> {
1551
1555
  namespace: string,
1552
1556
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
1553
1557
  collectionName: string);
1558
+ /** Note the record's current row in every open rollback journal that has not seen it yet. */
1559
+ private journalRecord;
1554
1560
  private bumpCollectionSeq;
1555
1561
  nextSequence(): number;
1556
1562
  get(id: string): T | undefined;
@@ -2332,6 +2338,7 @@ type RuntimeOptions<T extends ServiceInstance> = {
2332
2338
  onForwardResponse?: (instance: T, request: Request, response: Response) => Promise<void>;
2333
2339
  /** Reject unsupported forwarding surfaces before any network request. */
2334
2340
  canForward?: (request: Request) => boolean;
2341
+ upstreamRequest?: (request: Request, baseUrl: string) => Request;
2335
2342
  /** Service name, e.g. `"junction"`. Also the default namespace's storage key. */
2336
2343
  name: string;
2337
2344
  /** Build the instance backing one namespace. Called once per namespace, on first use. */
@@ -2675,5 +2682,5 @@ declare const UNRELEASED_VERSION = "0.0.0-development";
2675
2682
  /** The published version of the service package this code is bundled into. */
2676
2683
  declare const PACKAGE_VERSION: string;
2677
2684
 
2678
- export { ADMIN_CONTROL_PAGES, ADMIN_DOCS_URL, ADMIN_KEY_HEADER, ADMIN_PREFIX, ADMIN_ROUTE_REFERENCE, AT_HEADER, AwsError, AwsProtocolAPI, BRANCH_HEADER, CHECKPOINT_HEADER, CONTROL_HEADERS, CONTROL_HEADER_REFERENCE, Collection, ControlError, DEFAULT_JOURNAL_SIZE, DEFAULT_NAMESPACE, DroppedConnectionError, FAULT_HEADER, HEALTH_PATH, HttpError, IdSequence, IdempotencyStore, MOCKINGBIRD_HEADER, NAMESPACE_HEADER, OperationRegistryError, OutboxStore, PACKAGE_VERSION, SNAPSHOT_FORMAT, SNAPSHOT_HEADER, STANDARD_ADMIN_ROUTES, STANDARD_FAULT_PRESETS, STATE_FIELD_KINDS, UNRELEASED_VERSION, annotateResponse, anyCredential, assertAdminPrefixAvailable, assertAdminUi, assertSnapshotDocument, awsList, awsMd5, awsPage, awsParseXml, awsRecord, awsRequired, awsXml, awsXmlEscape, basicAuth, bearerToken, bodyIssues, bootSqlite, codePointLength, coerce, controlHeaders, createClock, createControlPlane, createCredentialRegistry, createFaultRegistry, createJournal, createLatencyRegistry, createMetrics, createNamespaceControls, createRng, createRuntime, createService, createWebhookHub, decodeAwsQuery, defineMock, defineOperations, deriveClock, extractCodes, extractLinks, faultEffect, faultEffects, forwardRequestContext, fromBase64, hmac, idBaseOf, inspectState, isAdminPath, issuesByField, jsonRes, jsonRes as jsonResponse, markMutationAccepted, maskCredential, matchNamespacePath, normalizeBootControls, normalizeControls, normalizeFault, normalizeIdBase, opaqueToken, outboxAdminRoutes, ownedTransport, parseControlHeaders, parseDuration, parseFaultHeader, parseForm, parseInstant, parseSince, putObject, recordedIssues, requestBaseUrl, requestFingerprint, resolveAdminPrefix, responseNotes, restoreClock, restoreNamespace, seedFrom, setIdBase, sha, sigV4AccessKeyId, signSvix, signTimestamped, signTwilio, signV4, signers, snapshotNamespace, sortIssues, stableStringify, svixSecretBytes, timingSafeEqual, toBase64, toHex, unsupportedMediaType, verifyOperations, webhookAdminRoutes, withNamespaceRollback };
2685
+ export { ADMIN_CONTROL_PAGES, ADMIN_DOCS_URL, ADMIN_KEY_HEADER, ADMIN_PREFIX, ADMIN_ROUTE_REFERENCE, AT_HEADER, AwsError, AwsProtocolAPI, BRANCH_HEADER, CHECKPOINT_HEADER, CONTROL_HEADERS, CONTROL_HEADER_REFERENCE, Collection, ControlError, DEFAULT_JOURNAL_SIZE, DEFAULT_NAMESPACE, DroppedConnectionError, FAULT_HEADER, HEALTH_PATH, HttpError, IdSequence, IdempotencyStore, MOCKINGBIRD_HEADER, NAMESPACE_HEADER, OperationRegistryError, OutboxStore, PACKAGE_VERSION, SNAPSHOT_FORMAT, SNAPSHOT_HEADER, STANDARD_ADMIN_ROUTES, STANDARD_FAULT_PRESETS, STATE_FIELD_KINDS, UNRELEASED_VERSION, annotateResponse, anyCredential, assertAdminPrefixAvailable, assertAdminUi, assertSnapshotDocument, awsList, awsMd5, awsPage, awsParseXml, awsRecord, awsRequired, awsXml, awsXmlEscape, basicAuth, bearerToken, bodyIssues, bootSqlite, codePointLength, coerce, controlHeaders, createClock, createControlPlane, createCredentialRegistry, createFaultRegistry, createJournal, createLatencyRegistry, createMetrics, createNamespaceControls, createRng, createRuntime, createService, createWebhookHub, decodeAwsQuery, defineMock, defineOperations, deriveClock, extractCodes, extractLinks, faultEffect, faultEffects, forwardRequestContext, fromBase64, hmac, idBaseOf, inspectState, isAdminPath, issuesByField, jsonRes, jsonRes as jsonResponse, markMutationAccepted, maskCredential, matchNamespacePath, normalizeBootControls, normalizeControls, normalizeFault, normalizeIdBase, opaqueToken, outboxAdminRoutes, ownedTransport, parseControlHeaders, parseDuration, parseFaultHeader, parseForm, parseInstant, parseSince, putObject, recordedIssues, requestBaseUrl, requestFingerprint, resolveAdminPrefix, responseNotes, restoreClock, restoreNamespace, seedFrom, setIdBase, sha, sigV4AccessKeyId, signSvix, signTimestamped, signTwilio, signV4, signers, snapshotNamespace, sortIssues, stableStringify, svixSecretBytes, timingSafeEqual, toBase64, toHex, unsupportedMediaType, upstreamRequest, verifyOperations, webhookAdminRoutes, withNamespaceRollback };
2679
2686
  export type { APIOptions, AdminBrand, AdminExtension, AdminPanel, AdminRequest, AdminRoute, AdminRoutes, AdminUi, AwsInput, AwsOperation, AwsProtocolOptions, BasicCredentials, BodyIssue, ByteEncoding, Clock, ClockControls, ClockState, ControlClock, ControlContext, ControlHeaderInput, ControlHeaderName, ControlPlane, ControlSettings, ControlState, CredentialRegistry, DerivedClock, Duration, FaultCandidate, FaultHit, FaultInput, FaultListing, FaultPreset, FaultPresetList, FaultRegistry, FaultRule, FaultSnapshot, FieldResult, FormIssue, HmacAlgorithm, IdBase, IdempotencyErrors, IdempotencyStoreOptions, InstanceContext, Instant, Journal, JournalEntry, JournalQuery, LatencyControls, LatencyRegistry, LatencyRule, LatencyRuleInput, LatencyState, ListRecordsOptions, Metrics, MetricsReport, MockCheckpoint, MockControlState, MockControls, MockCreateOptions, MockInstanceSurface, MockSnapshotInfo, MockSurface, MountedAPI, NamespaceControls, NamespaceControls$1 as NamespaceControlsInput, NamespaceSnapshot, OperationContext, OperationHandler, OperationHandlers, OutboundPolicy, OutboxItem, OutboxQuery, OwnedTransport, ParsedForm, PublishInput, RejectedRequest, RequestBodyValue, RequestControls, RequestLog, ResponseNotes, Rng, RuntimeIO, RuntimeOptions, S3Target, Service, ServiceCheckpoint, ServiceInstance, ServiceOptions, ServiceRuntime, ServiceTimelineState, SignInput, SnapshotDocument, SnapshotInfo, SnapshotStore, StandardAdminRoute, StateCollectionView, StateDeclaration, StateField, StateFieldKind, StateMeta, StatePage, StateRecord, StateView, Stored, UnsupportedMediaType, UpstreamOptions, UpstreamState, WebhookAttempt, WebhookDelivery, WebhookEndpoint, WebhookFault, WebhookHub, WebhookHubOptions, WebhookMessage, WebhookSigner };
package/dist/service.js CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  verifyOperations,
66
66
  webhookAdminRoutes,
67
67
  withNamespaceRollback
68
- } from "./chunk-OISPHKE2.js";
68
+ } from "./chunk-KD6FHYQP.js";
69
69
  import "./chunk-2KDYLZXC.js";
70
70
  import {
71
71
  ADMIN_CONTROL_PAGES,
@@ -125,11 +125,12 @@ import {
125
125
  svixSecretBytes,
126
126
  timingSafeEqual,
127
127
  toBase64,
128
- toHex
129
- } from "./chunk-LL6NKAJO.js";
128
+ toHex,
129
+ upstreamRequest
130
+ } from "./chunk-M4HUKBLC.js";
130
131
  import {
131
132
  requestBaseUrl
132
- } from "./chunk-2Y25NPCV.js";
133
+ } from "./chunk-U36J5GCB.js";
133
134
  import "./chunk-EQLY2YOA.js";
134
135
  import "./chunk-HU6IOAFC.js";
135
136
  import "./chunk-4SAK6MQT.js";
@@ -257,6 +258,7 @@ export {
257
258
  toBase64,
258
259
  toHex,
259
260
  unsupportedMediaType,
261
+ upstreamRequest,
260
262
  verifyOperations,
261
263
  webhookAdminRoutes,
262
264
  withNamespaceRollback
package/dist/ui.d.ts CHANGED
@@ -1,37 +1 @@
1
- /**
2
- * Cross-browser baseline for every HTML surface this repo serves.
3
- *
4
- * `CSS_RESET` is the document sheet. `scopeReset(root)` is the same sheet
5
- * limited to a widget (`:where` so later component rules still win) and with
6
- * viewport heights rewritten to the widget's own box.
7
- *
8
- * `reset.css` is this string as a stylesheet. The package test fails when the
9
- * two drift.
10
- */
11
- declare const CSS_RESET = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n\n* {\n scrollbar-width: thin;\n scrollbar-color: color-mix(in srgb, CanvasText 35%, Canvas) Canvas;\n}\n\n*::-webkit-scrollbar {\n width: 12px;\n height: 12px;\n}\n\n*::-webkit-scrollbar-track,\n*::-webkit-scrollbar-corner {\n background: Canvas;\n}\n\n*::-webkit-scrollbar-thumb {\n background: color-mix(in srgb, CanvasText 35%, Canvas);\n border: 3px solid Canvas;\n border-radius: 999px;\n}\n\nhtml {\n hanging-punctuation: first allow-end last;\n -webkit-text-size-adjust: none;\n text-size-adjust: none;\n tab-size: 4;\n font-family:\n ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI Variable\", \"Segoe UI\",\n \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\";\n font-size: 16px;\n line-height: 1.5;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n -webkit-tap-highlight-color: transparent;\n scroll-behavior: smooth;\n background: Canvas;\n color: CanvasText;\n}\n\nbody {\n min-height: 100svh;\n line-height: 1.5;\n background: Canvas;\n color: CanvasText;\n}\n\nh1 {\n font-size: 2em;\n}\n\nh2 {\n font-size: 1.5em;\n}\n\nh3 {\n font-size: 1.17em;\n}\n\nh4 {\n font-size: 1em;\n}\n\nh5 {\n font-size: 0.83em;\n}\n\nh6 {\n font-size: 0.67em;\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-weight: 700;\n line-height: 1.2;\n text-wrap: balance;\n overflow-wrap: break-word;\n}\n\np,\nli,\nfigcaption,\ndd,\ndt,\nblockquote {\n overflow-wrap: break-word;\n}\n\np,\nli,\nfigcaption,\nblockquote {\n text-wrap: pretty;\n}\n\nul,\nol,\nmenu {\n list-style: none;\n}\n\na {\n color: inherit;\n text-decoration: underline;\n text-decoration-thickness: 1px;\n text-underline-offset: 0.15em;\n text-decoration-skip-ink: auto;\n}\n\nb,\nstrong {\n font-weight: 700;\n}\n\nsmall {\n font-size: 0.875em;\n}\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, \"SF Mono\", SFMono-Regular, Menlo, Consolas, monospace;\n font-size: 1em;\n}\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\nabbr[title] {\n text-decoration: underline dotted;\n text-underline-offset: 0.15em;\n}\n\nmark {\n background: Mark;\n color: MarkText;\n}\n\nhr {\n height: 0;\n border: 0;\n border-top: 1px solid color-mix(in srgb, CanvasText 20%, transparent);\n color: inherit;\n}\n\nimg,\npicture,\nvideo,\ncanvas {\n display: block;\n max-width: 100%;\n}\n\nimg,\nvideo {\n height: auto;\n}\n\nsvg {\n overflow: hidden;\n}\n\niframe {\n border: 0;\n max-width: 100%;\n}\n\ntable {\n border-collapse: collapse;\n border-spacing: 0;\n}\n\nfieldset {\n border: 0;\n min-inline-size: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nbutton,\ninput,\nselect,\ntextarea,\noptgroup {\n font: inherit;\n letter-spacing: inherit;\n color: inherit;\n margin: 0;\n vertical-align: middle;\n}\n\nbutton,\ninput[type=\"button\"],\ninput[type=\"submit\"],\ninput[type=\"reset\"] {\n appearance: none;\n background: none;\n border: 0;\n padding: 0;\n cursor: pointer;\n text-align: center;\n}\n\ninput,\ntextarea,\nselect {\n background-color: Canvas;\n border: 1px solid color-mix(in srgb, CanvasText 28%, transparent);\n border-radius: 0;\n padding: 0.5em 0.65em;\n}\n\ninput[type=\"checkbox\"],\ninput[type=\"radio\"],\ninput[type=\"range\"],\ninput[type=\"file\"],\ninput[type=\"color\"],\ninput[type=\"button\"],\ninput[type=\"submit\"],\ninput[type=\"reset\"],\ninput[type=\"image\"],\ninput[type=\"hidden\"] {\n background: none;\n border: 0;\n padding: 0;\n border-radius: 0;\n}\n\ninput[type=\"checkbox\"],\ninput[type=\"radio\"] {\n accent-color: CanvasText;\n}\n\ninput[type=\"search\"] {\n appearance: none;\n background-color: Canvas;\n border: 1px solid color-mix(in srgb, CanvasText 28%, transparent);\n}\n\ninput[type=\"search\"]::-webkit-search-decoration,\ninput[type=\"search\"]::-webkit-search-cancel-button,\ninput[type=\"search\"]::-webkit-search-results-button,\ninput[type=\"search\"]::-webkit-search-results-decoration {\n -webkit-appearance: none;\n display: none;\n}\n\ninput[type=\"number\"] {\n appearance: textfield;\n background-color: Canvas;\n border: 1px solid color-mix(in srgb, CanvasText 28%, transparent);\n}\n\ninput[type=\"number\"]::-webkit-inner-spin-button,\ninput[type=\"number\"]::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ntextarea {\n resize: vertical;\n}\n\n::placeholder {\n opacity: 1;\n color: color-mix(in srgb, CanvasText 45%, transparent);\n}\n\n:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n}\n\n:focus:not(:focus-visible) {\n outline: none;\n}\n\n:disabled,\n[disabled] {\n cursor: default;\n opacity: 0.6;\n}\n\nlabel,\nsummary,\nselect,\n[role=\"button\"] {\n cursor: pointer;\n}\n\nsummary {\n display: list-item;\n}\n\ndetails {\n display: block;\n}\n\ndialog {\n margin: auto;\n padding: 1rem;\n border: 1px solid color-mix(in srgb, CanvasText 20%, transparent);\n background: Canvas;\n color: CanvasText;\n max-width: calc(100vw - 2rem);\n max-height: calc(100svh - 2rem);\n}\n\ndialog:not([open]) {\n display: none;\n}\n\n::backdrop {\n background: color-mix(in srgb, CanvasText 40%, transparent);\n}\n\n[hidden] {\n display: none !important;\n}\n\n::selection {\n background: Highlight;\n color: HighlightText;\n}\n\n@media (prefers-reduced-motion: reduce) {\n *,\n *::before,\n *::after {\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n transition-duration: 0.01ms !important;\n scroll-behavior: auto !important;\n }\n}\n\n@media (pointer: coarse) {\n input,\n select,\n textarea {\n font-size: max(16px, 1em);\n }\n}";
12
- /** Scope the reset to `root` without raising specificity above a single element. */
13
- declare function scopeReset(root: string): string;
14
-
15
- /** Product code supplies lazy surfaces; the shell knows nothing about their services. */
16
- type SystemSurface = {
17
- id: string;
18
- label: string;
19
- mount(host: HTMLElement, signal: AbortSignal): Promise<() => void> | (() => void);
20
- };
21
- type SystemHarness = {
22
- show(id: string): Promise<void>;
23
- active(): string;
24
- destroy(): void;
25
- };
26
- /**
27
- * One visible surface, with mounted surfaces retained while hidden. Resolving mount means ready;
28
- * rejecting means failed. Abort and late disposal make teardown safe during asynchronous loading.
29
- * The reserved System surface is always reachable. URL state is opt-in for embedded hosts.
30
- */
31
- declare function mountSystemHarness(host: HTMLElement, surfaces: readonly SystemSurface[], options?: {
32
- initial?: string;
33
- syncUrl?: boolean;
34
- }): SystemHarness;
35
-
36
- export { CSS_RESET, mountSystemHarness, scopeReset };
37
- export type { SystemHarness, SystemSurface };
1
+ export * from '@crvouga/mockingbird-ui';