@tileflow/capture 0.1.0-alpha.27 → 0.1.0-alpha.28

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 (2) hide show
  1. package/dist/index.js +39 -0
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -317,6 +317,11 @@ import { open } from "fs/promises";
317
317
  import { createRequire as createRequire2 } from "module";
318
318
  import { dirname as dirname2, join as join2 } from "path";
319
319
  import { getTileflowStyleFontFaces } from "@tileflow/core/runtime";
320
+ import {
321
+ createTileflowLineBackgroundGlyphResponder,
322
+ parseTileflowLineBackgroundGlyphPath,
323
+ tileflowLineBackgroundGlyphRoute
324
+ } from "@tileflow/dev/artifacts";
320
325
  import { assertValidTileflowStyle, TileflowStyleValidationError } from "@tileflow/dev/validation";
321
326
 
322
327
  // src/assets.ts
@@ -409,6 +414,7 @@ async function captureStandaloneTileflowScene(input) {
409
414
  );
410
415
  const fontFaces = getTileflowStyleFontFaces(input.style);
411
416
  const remoteOrigins = /* @__PURE__ */ new Set();
417
+ let lineBackgroundGlyphs;
412
418
  let syntheticAssetFailure;
413
419
  const resourceFailures = [];
414
420
  let pageFailed = false;
@@ -439,6 +445,35 @@ async function captureStandaloneTileflowScene(input) {
439
445
  return;
440
446
  }
441
447
  }
448
+ if (url.origin === tileflowSyntheticAssetOrigin && url.pathname.startsWith(`/${tileflowLineBackgroundGlyphRoute}/`)) {
449
+ const glyphRequest = parseTileflowLineBackgroundGlyphPath(url.pathname);
450
+ const upstream = glyphRequest ? input.lineBackgroundGlyphs?.[glyphRequest.mapName] : void 0;
451
+ if (!glyphRequest || !upstream || url.search !== "") {
452
+ syntheticAssetFailure = url.pathname.slice(1) || "unknown";
453
+ await route.abort("blockedbyclient");
454
+ return;
455
+ }
456
+ const provider = new URL(
457
+ upstream.replace("{fontstack}", "stack").replace("{range}", "0-255")
458
+ );
459
+ if (!isLoopbackUrl(provider)) remoteOrigins.add(provider.origin);
460
+ lineBackgroundGlyphs ??= createTileflowLineBackgroundGlyphResponder({
461
+ cwd: input.glyphCacheDirectory ?? process.cwd()
462
+ });
463
+ const response = await lineBackgroundGlyphs(
464
+ upstream,
465
+ glyphRequest.fontStack,
466
+ glyphRequest.range
467
+ );
468
+ if (response.status !== 200) recordResourceFailure(url.toString(), response.status);
469
+ await route.fulfill({
470
+ body: Buffer.from(await response.arrayBuffer()),
471
+ contentType: response.headers.get("content-type") ?? "application/x-protobuf",
472
+ headers: { "Access-Control-Allow-Origin": "*" },
473
+ status: response.status
474
+ });
475
+ return;
476
+ }
442
477
  if (url.origin === tileflowSyntheticAssetOrigin) {
443
478
  const fileName = decodeURIComponent(url.pathname.slice(1));
444
479
  const localTileset = url.search === "" ? localTilesets.get(fileName) : void 0;
@@ -1873,6 +1908,10 @@ var TileflowCaptureSessionImpl = class {
1873
1908
  assets: [...artifacts.assets, ...prepared.assets ?? []],
1874
1909
  browser,
1875
1910
  ...artifacts.localTilesets ? { localTilesets: artifacts.localTilesets } : {},
1911
+ ...artifacts.lineBackgroundGlyphs ? {
1912
+ glyphCacheDirectory: resolve(this.#options.cwd ?? process.cwd()),
1913
+ lineBackgroundGlyphs: artifacts.lineBackgroundGlyphs
1914
+ } : {},
1876
1915
  scene,
1877
1916
  signal,
1878
1917
  style,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/capture",
3
- "version": "0.1.0-alpha.27",
3
+ "version": "0.1.0-alpha.28",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Deterministic local visual capture and comparison for Tileflow maps.",
6
6
  "engines": {
@@ -48,8 +48,8 @@
48
48
  "access": "public"
49
49
  },
50
50
  "dependencies": {
51
- "@tileflow/core": ">=0.1.0-alpha.29 <0.1.0-beta.0",
52
- "@tileflow/dev": ">=0.1.0-alpha.27 <0.1.0-beta.0",
51
+ "@tileflow/core": ">=0.1.0-alpha.30 <0.1.0-beta.0",
52
+ "@tileflow/dev": ">=0.1.0-alpha.28 <0.1.0-beta.0",
53
53
  "maplibre-gl": "6.9.0",
54
54
  "pixelmatch": "7.2.0",
55
55
  "playwright": "1.62.1",
@@ -68,13 +68,13 @@
68
68
  "vite": "^8.0.16",
69
69
  "vue": "^3.5.39",
70
70
  "webpack": "5.108.3",
71
- "@tileflow/maps": "0.1.0-alpha.6",
72
- "@tileflow/next": "0.1.0-alpha.24",
73
- "@tileflow/react": "0.1.0-alpha.27",
71
+ "@tileflow/maps": "0.1.0-alpha.7",
72
+ "@tileflow/react": "0.1.0-alpha.28",
74
73
  "@tileflow/vite": "0.1.0-alpha.24",
75
- "@tileflow/svelte": "0.1.0-alpha.26",
76
- "@tileflow/vue": "0.1.0-alpha.26",
77
- "@tileflow/webpack": "0.1.0-alpha.24"
74
+ "@tileflow/vue": "0.1.0-alpha.27",
75
+ "@tileflow/webpack": "0.1.0-alpha.24",
76
+ "@tileflow/next": "0.1.0-alpha.24",
77
+ "@tileflow/svelte": "0.1.0-alpha.27"
78
78
  },
79
79
  "scripts": {
80
80
  "build": "tsup src/index.ts src/receipt.ts --format esm --dts --clean --platform node",