@crvouga/mockingbird-runtime 0.3.2 → 0.4.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @crvouga/mockingbird-runtime
2
2
 
3
- > Local emulators. Real API contracts. Part of [Mockingbird](https://github.com/crvouga-organization/mockingbird).
3
+ > Local emulators. Real API contracts. Part of [Mockingbird](https://github.com/crvouga/mockingbird).
4
4
 
5
5
  The runtime every Mockingbird emulator service is built on: the router, the `/__admin` API and
6
6
  page, snapshots, faults, the clock, and the HTTP and OpenAPI helpers. Each
@@ -2,7 +2,7 @@ import {
2
2
  normalizeIdBase,
3
3
  ownedTransport,
4
4
  signV4
5
- } from "./chunk-KD6FHYQP.js";
5
+ } from "./chunk-HGJXAIZJ.js";
6
6
  import "./chunk-2KDYLZXC.js";
7
7
  import {
8
8
  createClock,
@@ -13,7 +13,7 @@ import {
13
13
  resolveAdminPrefix,
14
14
  restoreClock,
15
15
  upstreamRequest
16
- } from "./chunk-M4HUKBLC.js";
16
+ } from "./chunk-NW5GDYLU.js";
17
17
  import {
18
18
  assertArchiveCompatibility,
19
19
  assertCompatibilityTags,
@@ -2186,7 +2186,7 @@ data: ${JSON.stringify(data)}
2186
2186
  async handle(request, path, namespace, body, admin) {
2187
2187
  const route = path.slice("/fleet".length), method = request.method;
2188
2188
  if (path === "/ui")
2189
- return new Response(fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
2189
+ return new Response(await fleetConsole(this.ctx.config.adminPrefix ?? "/__admin", this.ctx.dashboard?.()), { headers: { "content-type": "text/html; charset=utf-8" } });
2190
2190
  if (route === "" && method === "GET")
2191
2191
  return Response.json({
2192
2192
  ...this.capability(),
@@ -3172,8 +3172,13 @@ data: ${JSON.stringify(data)}
3172
3172
  clearInterval(this.expiryTimer);
3173
3173
  }
3174
3174
  };
3175
- var escapeAttribute = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
3176
- var fleetConsole = (prefix, dashboard) => `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Mockingbird Fleet</title><style>body{font:16px system-ui;max-width:1000px;margin:3rem auto;padding:1rem;background:#10151b;color:#e0e9f2}input,select,button{padding:.7rem;margin:.3rem;background:#233142;color:inherit;border:1px solid #60768b;border-radius:5px}pre{white-space:pre-wrap;overflow-wrap:anywhere}a{color:#9fdbff}</style><h1>Mockingbird Fleet</h1>${dashboard ? `<p id="dashboard">Every emulator's admin UI and the notifications UI are on the <a href="${escapeAttribute(dashboard)}">dashboard</a>.</p>` : ""}<label>Admin key <input id="key" type="password" autocomplete="off"></label><label>Namespace <input id="ns" value="default"></label><button id="refresh">Refresh</button><section id="children"></section><label>Action <select id="action"><option value="snapshots">Capture checkpoint</option><option value="reset">Reset namespace</option></select></label><button id="run">Run</button><h2>Lifecycle and operations</h2><pre id="result"></pre><script type="module">const base=${JSON.stringify(`${prefix}/fleet`)};const key=document.querySelector('#key'),ns=document.querySelector('#ns'),result=document.querySelector('#result');async function api(path,method='GET',body){const r=await fetch(base+path,{method,headers:{'content-type':'application/json','x-mockingbird-admin-key':key.value},...(body?{body:JSON.stringify(body)}:{})});const data=await r.json();result.textContent=JSON.stringify(data,null,2);return data}document.querySelector('#refresh').onclick=async()=>{const data=await api('');const host=document.querySelector('#children');host.replaceChildren();for(const [name,child]of Object.entries(data.manifest?.services??{})){const link=document.createElement('a');link.href=child.adminUrl;link.textContent=name+' ('+child.protocol+') ';host.append(link)}await api('/operations?namespace='+encodeURIComponent(ns.value))};document.querySelector('#run').onclick=()=>api('/namespaces/'+encodeURIComponent(ns.value)+'/'+document.querySelector('#action').value,'POST',{});</script></html>`;
3175
+ var fleetConsole = async (prefix, dashboard) => {
3176
+ const [{ fleetConsolePage }, { BUNDLE }] = await Promise.all([
3177
+ import("./server-32IZ5ZMR.js"),
3178
+ import("./client.bundle-6XOKJ6BJ.js")
3179
+ ]);
3180
+ return fleetConsolePage({ base: `${prefix}/fleet`, ...dashboard ? { dashboard } : {} }, { source: BUNDLE });
3181
+ };
3177
3182
 
3178
3183
  // ../adapters/node/dist/fleet-preflight.js
3179
3184
  import { readFile as readFile3, realpath } from "node:fs/promises";
@@ -3646,7 +3651,7 @@ async function preflightFleet(config, options) {
3646
3651
  break;
3647
3652
  }
3648
3653
  }
3649
- targets.set(name, { ...target, packageVersion: packageVersion ?? "0.3.2" });
3654
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "0.4.0" });
3650
3655
  } catch (error) {
3651
3656
  throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3652
3657
  }