@crvouga/mockingbird-service-google-maps 2.1.0 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog — @crvouga/mockingbird-service-google-maps
2
2
 
3
+ ## 2.2.0 (2026-10-05)
4
+
5
+ ### Features
6
+
7
+ - add scripted local API mock ([4a76a11](https://github.com/crvouga/mockingbird/commit/4a76a114e2efad45934e0a93cf29576fd418e15c))
8
+
9
+ ### Fixes and improvements
10
+
11
+ - support embedded route parameters ([127cad9](https://github.com/crvouga/mockingbird/commit/127cad997ef106950c1b866070eea191ba54403f))
12
+
3
13
  ## 2.1.0 (2026-10-04)
4
14
 
5
15
  ### Features
@@ -12,10 +22,6 @@
12
22
  - fill the embedded viewport ([c1a35a4](https://github.com/crvouga/mockingbird/commit/c1a35a4789389ee9cd06c286d09bd47c4d06c71e))
13
23
  - make dialog cleanup immediate ([0c1a3c5](https://github.com/crvouga/mockingbird/commit/0c1a3c5b12584d50c19dcae595b951b8e5417b9c))
14
24
 
15
- ### Dependencies
16
-
17
- - `@crvouga/mockingbird-service-sqlite`
18
-
19
25
  ## 2.0.0 (2026-10-04)
20
26
 
21
27
  ### ⚠️ Breaking changes
@@ -3,7 +3,7 @@ import {
3
3
  createRuntime,
4
4
  parseDuration,
5
5
  resolveAdminPrefix
6
- } from "./chunk-53MIPHUJ.js";
6
+ } from "./chunk-WLKNPNFO.js";
7
7
 
8
8
  // ../../adapters/node/dist/cli.js
9
9
  import { readFile as readFile2 } from "node:fs/promises";
@@ -847,4 +847,4 @@ export {
847
847
  createServer2 as createServer,
848
848
  serveTarget
849
849
  };
850
- //# sourceMappingURL=chunk-WJ6YEIWV.js.map
850
+ //# sourceMappingURL=chunk-3ETSHEVA.js.map
@@ -820,7 +820,40 @@ var decodeBody = (contentType, bytes) => {
820
820
  return { kind: "bytes", value: bytes };
821
821
  };
822
822
  var readBody = async (message) => {
823
- const bytes = new Uint8Array(await message.arrayBuffer());
823
+ if (!(message instanceof Request) || !message.body) {
824
+ if (message instanceof Request)
825
+ message.signal.throwIfAborted();
826
+ return decodeBody(message.headers.get("content-type"), new Uint8Array(await message.arrayBuffer()));
827
+ }
828
+ message.signal.throwIfAborted();
829
+ const reader = message.body.getReader();
830
+ const cancel = () => {
831
+ void reader.cancel(message.signal.reason).catch(() => {
832
+ });
833
+ };
834
+ message.signal.addEventListener("abort", cancel, { once: true });
835
+ const chunks = [];
836
+ let size = 0;
837
+ try {
838
+ for (; ; ) {
839
+ message.signal.throwIfAborted();
840
+ const { done, value } = await reader.read();
841
+ message.signal.throwIfAborted();
842
+ if (done)
843
+ break;
844
+ chunks.push(value);
845
+ size += value.byteLength;
846
+ }
847
+ } finally {
848
+ message.signal.removeEventListener("abort", cancel);
849
+ reader.releaseLock();
850
+ }
851
+ const bytes = new Uint8Array(size);
852
+ let offset = 0;
853
+ for (const chunk of chunks) {
854
+ bytes.set(chunk, offset);
855
+ offset += chunk.byteLength;
856
+ }
824
857
  return decodeBody(message.headers.get("content-type"), bytes);
825
858
  };
826
859
 
@@ -1465,7 +1498,42 @@ var verifyOperations = (document2, handlers) => {
1465
1498
  }
1466
1499
  return problems;
1467
1500
  };
1468
- var honoPath = (template) => template.replace(/\{([^}]+)\}/g, ":$1");
1501
+ var escapePattern = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1502
+ var serviceRoute = (template) => {
1503
+ const names = [];
1504
+ let pattern = "", end = 0;
1505
+ for (const match of template.matchAll(/\{([^}]+)\}/g)) {
1506
+ pattern += `${escapePattern(template.slice(end, match.index))}([^/]+?)`;
1507
+ const name = match[1];
1508
+ if (!name)
1509
+ throw new Error(`Invalid OpenAPI route template: ${template}`);
1510
+ names.push(name);
1511
+ end = match.index + match[0].length;
1512
+ }
1513
+ pattern += escapePattern(template.slice(end));
1514
+ const matcher = new RegExp(`^${pattern}$`);
1515
+ const path = template.split("/").map((segment, index) => {
1516
+ if (!segment.includes("{"))
1517
+ return segment;
1518
+ const literal = /^\{([^}]+)\}$/.exec(segment);
1519
+ if (literal)
1520
+ return `:${literal[1]}`;
1521
+ let expression = "", offset = 0;
1522
+ for (const match of segment.matchAll(/\{[^}]+\}/g)) {
1523
+ expression += `${escapePattern(segment.slice(offset, match.index))}[^/]+?`;
1524
+ offset = match.index + match[0].length;
1525
+ }
1526
+ expression += escapePattern(segment.slice(offset));
1527
+ return `:mockingbirdSegment${index}{${expression}}`;
1528
+ }).join("/");
1529
+ return {
1530
+ path,
1531
+ params: (pathname) => {
1532
+ const values = matcher.exec(pathname);
1533
+ return Object.fromEntries(names.map((name, index) => [name, decodeURIComponent(values?.[index + 1] ?? "")]));
1534
+ }
1535
+ };
1536
+ };
1469
1537
  var routeOrder = (a, b) => {
1470
1538
  const sa = a.path.split("/");
1471
1539
  const sb = b.path.split("/");
@@ -1500,6 +1568,7 @@ var createService = (options) => {
1500
1568
  for (const operation of operations) {
1501
1569
  const metadata = operationMetadata(operation.operation);
1502
1570
  const handler = options.handlers[operation.operationId];
1571
+ const registeredRoute = serviceRoute(operation.path);
1503
1572
  const route = async (c) => {
1504
1573
  const request = c.req.raw;
1505
1574
  if (!metadata.supported || !handler) {
@@ -1509,7 +1578,7 @@ var createService = (options) => {
1509
1578
  const context = {
1510
1579
  request,
1511
1580
  url,
1512
- params: c.req.param(),
1581
+ params: registeredRoute.params(url.pathname),
1513
1582
  query: queryOf(url),
1514
1583
  body: await readBody(request),
1515
1584
  sqlite: options.sqlite,
@@ -1521,7 +1590,7 @@ var createService = (options) => {
1521
1590
  const short = await options.before?.(context);
1522
1591
  return withIssues(request, short ?? await handler(context));
1523
1592
  };
1524
- app.on(operation.method.toUpperCase(), honoPath(operation.path), route);
1593
+ app.on(operation.method.toUpperCase(), registeredRoute.path, route);
1525
1594
  }
1526
1595
  return {
1527
1596
  app,
@@ -1990,7 +2059,7 @@ var stateAdminRoutes = (routes) => {
1990
2059
  };
1991
2060
 
1992
2061
  // ../core/dist/version.js
1993
- var PACKAGE_VERSION = true ? "2.1.0" : UNRELEASED_VERSION;
2062
+ var PACKAGE_VERSION = true ? "2.2.0" : UNRELEASED_VERSION;
1994
2063
 
1995
2064
  // ../core/dist/signing.js
1996
2065
  var encoder = new TextEncoder();
@@ -4974,4 +5043,4 @@ export {
4974
5043
  keyCredential,
4975
5044
  GoogleMapsAPI
4976
5045
  };
4977
- //# sourceMappingURL=chunk-53MIPHUJ.js.map
5046
+ //# sourceMappingURL=chunk-WLKNPNFO.js.map