@tileflow/capture 0.1.0-alpha.20 → 0.1.0-alpha.22
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 +6 -6
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/index.js +104 -6
- package/package.json +14 -16
- package/GENERATED_OUTPUT_LICENSE.md +0 -21
- package/NOTICE +0 -9
- package/TRADEMARKS.md +0 -10
package/README.md
CHANGED
|
@@ -16,12 +16,12 @@ const result = await captureTileflowScenes({
|
|
|
16
16
|
const [{png, receipt, sha256, networkDependent}] = result.captures;
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Standalone scenes compile through `@tileflow/dev`,
|
|
20
|
-
|
|
21
|
-
for `load`, `idle`, and two animation
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
that normal happy path by default.
|
|
19
|
+
Standalone scenes compile through `@tileflow/dev`, fulfill the installed MapLibre main module,
|
|
20
|
+
shared module, worker module, and CSS closure in a pinned Playwright Chromium headless shell,
|
|
21
|
+
fulfill generated local icon assets in memory, and wait for `load`, `idle`, and two animation
|
|
22
|
+
frames. They never open a visible window or an HTTP listener. One call with multiple scenes uses
|
|
23
|
+
one Browser and a fresh isolated context per scene. Capture installs the exact pinned shell
|
|
24
|
+
automatically when `allowBrowserInstall` is true; the CLI enables that normal happy path by default.
|
|
25
25
|
|
|
26
26
|
For a warm integration, retain and close a session:
|
|
27
27
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -18,7 +18,7 @@ the platform-specific headless shell into its versioned per-user browser cache;
|
|
|
18
18
|
distribution carries Chromium's license and credits. Chromium source and license information are
|
|
19
19
|
available at https://www.chromium.org/chromium-projects/.
|
|
20
20
|
|
|
21
|
-
## MapLibre GL JS
|
|
21
|
+
## MapLibre GL JS 6.9.0
|
|
22
22
|
|
|
23
23
|
Copyright (c) 2023 MapLibre contributors. Licensed under BSD-3-Clause. The installed `maplibre-gl`
|
|
24
24
|
package includes `LICENSE.txt`, including notices for code derived from Mapbox GL JS and other
|
package/dist/index.js
CHANGED
|
@@ -320,8 +320,12 @@ import { getTileflowStyleFontFaces } from "@tileflow/core/runtime";
|
|
|
320
320
|
import { assertValidTileflowStyle, TileflowStyleValidationError } from "@tileflow/dev/validation";
|
|
321
321
|
var tileflowSyntheticAssetOrigin = "https://tileflow.local.invalid";
|
|
322
322
|
var require3 = createRequire2(import.meta.url);
|
|
323
|
-
var
|
|
324
|
-
|
|
323
|
+
var mapLibreRuntimePaths = Object.freeze({
|
|
324
|
+
css: require3.resolve("maplibre-gl/dist/maplibre-gl.css"),
|
|
325
|
+
main: require3.resolve("maplibre-gl/dist/maplibre-gl.mjs"),
|
|
326
|
+
shared: require3.resolve("maplibre-gl/dist/maplibre-gl-shared.mjs"),
|
|
327
|
+
worker: require3.resolve("maplibre-gl/dist/maplibre-gl-worker.mjs")
|
|
328
|
+
});
|
|
325
329
|
var tileflowCorePackagePath = require3.resolve("@tileflow/core/package.json");
|
|
326
330
|
var tileflowBrowserModule = `${readFileSync2(
|
|
327
331
|
join2(dirname2(tileflowCorePackagePath), "dist", "browser.js"),
|
|
@@ -351,6 +355,9 @@ async function captureStandaloneTileflowScene(input) {
|
|
|
351
355
|
throw error;
|
|
352
356
|
}
|
|
353
357
|
const timeoutMs = input.timeoutMs ?? 3e4;
|
|
358
|
+
const mapLibreRuntimeUrls = createMapLibreRuntimeUrls(
|
|
359
|
+
resolveMapLibreRuntimeDocumentOrigin(input.style)
|
|
360
|
+
);
|
|
354
361
|
let termination;
|
|
355
362
|
let context;
|
|
356
363
|
let phase = "browser-start";
|
|
@@ -407,6 +414,13 @@ async function captureStandaloneTileflowScene(input) {
|
|
|
407
414
|
};
|
|
408
415
|
await context.route("**/*", async (route) => {
|
|
409
416
|
const url = new URL(route.request().url());
|
|
417
|
+
if (url.origin === mapLibreRuntimeUrls.origin) {
|
|
418
|
+
const runtime = getMapLibreRuntimeResponse(url.pathname, input.scene.viewport);
|
|
419
|
+
if (runtime) {
|
|
420
|
+
await route.fulfill(runtime);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
410
424
|
if (url.origin === tileflowSyntheticAssetOrigin) {
|
|
411
425
|
const fileName = decodeURIComponent(url.pathname.slice(1));
|
|
412
426
|
const localTileset = url.search === "" ? localTilesets.get(fileName) : void 0;
|
|
@@ -415,7 +429,10 @@ async function captureStandaloneTileflowScene(input) {
|
|
|
415
429
|
route.request().headers()["range"],
|
|
416
430
|
localTileset
|
|
417
431
|
);
|
|
418
|
-
await route.fulfill(
|
|
432
|
+
await route.fulfill({
|
|
433
|
+
...response,
|
|
434
|
+
headers: { "Access-Control-Allow-Origin": "*", ...response.headers }
|
|
435
|
+
});
|
|
419
436
|
return;
|
|
420
437
|
}
|
|
421
438
|
const asset = url.search === "" ? assets.get(fileName) : void 0;
|
|
@@ -428,6 +445,7 @@ async function captureStandaloneTileflowScene(input) {
|
|
|
428
445
|
await route.fulfill({
|
|
429
446
|
body: typeof source === "string" ? source : Buffer.from(source),
|
|
430
447
|
contentType: asset.contentType,
|
|
448
|
+
headers: { "Access-Control-Allow-Origin": "*" },
|
|
431
449
|
status: 200
|
|
432
450
|
});
|
|
433
451
|
return;
|
|
@@ -457,9 +475,17 @@ async function captureStandaloneTileflowScene(input) {
|
|
|
457
475
|
});
|
|
458
476
|
page.on("requestfailed", (request) => recordResourceFailure(request.url()));
|
|
459
477
|
page.setDefaultTimeout(timeoutMs);
|
|
460
|
-
await page.
|
|
461
|
-
await page.addStyleTag({
|
|
462
|
-
await page.addScriptTag({
|
|
478
|
+
await page.goto(mapLibreRuntimeUrls.document, { waitUntil: "domcontentloaded" });
|
|
479
|
+
await page.addStyleTag({ url: mapLibreRuntimeUrls.css });
|
|
480
|
+
await page.addScriptTag({
|
|
481
|
+
content: `import * as maplibregl from ${JSON.stringify(mapLibreRuntimeUrls.main)};
|
|
482
|
+
maplibregl.setWorkerUrl(${JSON.stringify(mapLibreRuntimeUrls.worker)});
|
|
483
|
+
globalThis.maplibregl = maplibregl;`,
|
|
484
|
+
type: "module"
|
|
485
|
+
});
|
|
486
|
+
await page.waitForFunction(
|
|
487
|
+
() => Boolean(globalThis.maplibregl)
|
|
488
|
+
);
|
|
463
489
|
await page.addScriptTag({ content: tileflowBrowserModule, type: "module" });
|
|
464
490
|
await page.addScriptTag({ content: renderMapInPageScript });
|
|
465
491
|
phase = "map-load";
|
|
@@ -559,6 +585,78 @@ async function captureStandaloneTileflowScene(input) {
|
|
|
559
585
|
await context?.close().catch(() => void 0);
|
|
560
586
|
}
|
|
561
587
|
}
|
|
588
|
+
function createMapLibreRuntimeUrls(origin) {
|
|
589
|
+
return Object.freeze({
|
|
590
|
+
css: `${origin}/__runtime/maplibre-gl.css`,
|
|
591
|
+
document: `${origin}/__runtime/document.html`,
|
|
592
|
+
main: `${origin}/__runtime/maplibre-gl.mjs`,
|
|
593
|
+
origin,
|
|
594
|
+
shared: `${origin}/__runtime/maplibre-gl-shared.mjs`,
|
|
595
|
+
worker: `${origin}/__runtime/maplibre-gl-worker.mjs`
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
function resolveMapLibreRuntimeDocumentOrigin(style) {
|
|
599
|
+
const origins = /* @__PURE__ */ new Set();
|
|
600
|
+
const loopbackOrigins = /* @__PURE__ */ new Set();
|
|
601
|
+
const addOrigin = (value) => {
|
|
602
|
+
if (typeof value !== "string") return;
|
|
603
|
+
try {
|
|
604
|
+
const url = new URL(value);
|
|
605
|
+
if ((url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "") {
|
|
606
|
+
origins.add(url.origin);
|
|
607
|
+
if (isLoopbackUrl(url)) loopbackOrigins.add(url.origin);
|
|
608
|
+
}
|
|
609
|
+
} catch {
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
addOrigin(style.glyphs);
|
|
613
|
+
if (Array.isArray(style.sprite)) {
|
|
614
|
+
for (const sprite of style.sprite) {
|
|
615
|
+
if (sprite && typeof sprite === "object") {
|
|
616
|
+
addOrigin(sprite.url);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
} else {
|
|
620
|
+
addOrigin(style.sprite);
|
|
621
|
+
}
|
|
622
|
+
const fontFaces = style.metadata?.["tileflow:fontFaces"];
|
|
623
|
+
if (Array.isArray(fontFaces)) {
|
|
624
|
+
for (const fontFace of fontFaces) {
|
|
625
|
+
if (fontFace && typeof fontFace === "object") {
|
|
626
|
+
addOrigin(fontFace.source);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
for (const source of Object.values(style.sources)) {
|
|
631
|
+
const candidate = source;
|
|
632
|
+
addOrigin(candidate.data);
|
|
633
|
+
addOrigin(candidate.url);
|
|
634
|
+
if (Array.isArray(candidate.tiles)) {
|
|
635
|
+
for (const tile of candidate.tiles) addOrigin(tile);
|
|
636
|
+
}
|
|
637
|
+
if (Array.isArray(candidate.urls)) {
|
|
638
|
+
for (const url of candidate.urls) addOrigin(url);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const preferredOrigins = loopbackOrigins.size > 0 ? loopbackOrigins : origins;
|
|
642
|
+
return [...preferredOrigins].sort(compareCodeUnits)[0] ?? tileflowSyntheticAssetOrigin;
|
|
643
|
+
}
|
|
644
|
+
function getMapLibreRuntimeResponse(pathname, viewport) {
|
|
645
|
+
if (pathname === "/__runtime/document.html") {
|
|
646
|
+
return {
|
|
647
|
+
body: renderHtml(viewport),
|
|
648
|
+
contentType: "text/html; charset=utf-8",
|
|
649
|
+
status: 200
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
const asset = pathname === "/__runtime/maplibre-gl.mjs" ? mapLibreRuntimePaths.main : pathname === "/__runtime/maplibre-gl-shared.mjs" ? mapLibreRuntimePaths.shared : pathname === "/__runtime/maplibre-gl-worker.mjs" ? mapLibreRuntimePaths.worker : pathname === "/__runtime/maplibre-gl.css" ? mapLibreRuntimePaths.css : void 0;
|
|
653
|
+
if (!asset) return void 0;
|
|
654
|
+
return {
|
|
655
|
+
body: readFileSync2(asset, "utf8"),
|
|
656
|
+
contentType: pathname === "/__runtime/maplibre-gl.css" ? "text/css; charset=utf-8" : "text/javascript; charset=utf-8",
|
|
657
|
+
status: 200
|
|
658
|
+
};
|
|
659
|
+
}
|
|
562
660
|
async function localTilesetCaptureResponse(rangeHeader, file) {
|
|
563
661
|
const match = rangeHeader?.match(/^bytes=(\d+)-(\d*)$/u);
|
|
564
662
|
if (!match) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tileflow/capture",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.22",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Deterministic local visual capture and comparison for Tileflow maps.",
|
|
6
6
|
"engines": {
|
|
@@ -29,10 +29,7 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
31
|
"THIRD_PARTY_NOTICES.md",
|
|
32
|
-
"LICENSE"
|
|
33
|
-
"NOTICE",
|
|
34
|
-
"GENERATED_OUTPUT_LICENSE.md",
|
|
35
|
-
"TRADEMARKS.md"
|
|
32
|
+
"LICENSE"
|
|
36
33
|
],
|
|
37
34
|
"exports": {
|
|
38
35
|
".": {
|
|
@@ -50,9 +47,9 @@
|
|
|
50
47
|
"access": "public"
|
|
51
48
|
},
|
|
52
49
|
"dependencies": {
|
|
53
|
-
"@tileflow/core": ">=0.1.0-alpha.
|
|
54
|
-
"@tileflow/dev": ">=0.1.0-alpha.
|
|
55
|
-
"maplibre-gl": "
|
|
50
|
+
"@tileflow/core": ">=0.1.0-alpha.24 <0.1.0-beta.0",
|
|
51
|
+
"@tileflow/dev": ">=0.1.0-alpha.23 <0.1.0-beta.0",
|
|
52
|
+
"maplibre-gl": "6.9.0",
|
|
56
53
|
"pixelmatch": "7.2.0",
|
|
57
54
|
"playwright": "1.62.1",
|
|
58
55
|
"pngjs": "7.0.0"
|
|
@@ -62,20 +59,21 @@
|
|
|
62
59
|
"@types/node": "^25.9.2",
|
|
63
60
|
"@types/pngjs": "6.0.5",
|
|
64
61
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
65
|
-
"
|
|
62
|
+
"maplibre-gl-min": "npm:maplibre-gl@6.4.1",
|
|
63
|
+
"next": "16.3.3",
|
|
66
64
|
"react": "^19.2.7",
|
|
67
65
|
"react-dom": "^19.2.7",
|
|
68
66
|
"svelte": "^5.56.4",
|
|
69
67
|
"vite": "^8.0.16",
|
|
70
68
|
"vue": "^3.5.39",
|
|
71
69
|
"webpack": "5.108.3",
|
|
72
|
-
"@tileflow/maps": "0.1.0-alpha.
|
|
73
|
-
"@tileflow/
|
|
74
|
-
"@tileflow/
|
|
75
|
-
"@tileflow/next": "0.1.0-alpha.
|
|
76
|
-
"@tileflow/
|
|
77
|
-
"@tileflow/webpack": "0.1.0-alpha.
|
|
78
|
-
"@tileflow/
|
|
70
|
+
"@tileflow/maps": "0.1.0-alpha.3",
|
|
71
|
+
"@tileflow/react": "0.1.0-alpha.24",
|
|
72
|
+
"@tileflow/vite": "0.1.0-alpha.21",
|
|
73
|
+
"@tileflow/next": "0.1.0-alpha.21",
|
|
74
|
+
"@tileflow/svelte": "0.1.0-alpha.23",
|
|
75
|
+
"@tileflow/webpack": "0.1.0-alpha.21",
|
|
76
|
+
"@tileflow/vue": "0.1.0-alpha.23"
|
|
79
77
|
},
|
|
80
78
|
"scripts": {
|
|
81
79
|
"build": "tsup src/index.ts src/receipt.ts --format esm --dts --clean --platform node",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Tileflow generated-output grant
|
|
2
|
-
|
|
3
|
-
In addition to the rights granted by the Apache License, Version 2.0, Tileflow.dev contributors
|
|
4
|
-
grant recipients a perpetual, worldwide, non-exclusive, no-charge, royalty-free right to use,
|
|
5
|
-
reproduce, modify, display, perform, distribute, sublicense, and commercialize the Tileflow-owned
|
|
6
|
-
parts of output generated by this SDK.
|
|
7
|
-
|
|
8
|
-
Covered output includes compiled map styles, manifests, receipts, sprites, glyph artifacts, static
|
|
9
|
-
render descriptions, and other build artifacts produced from Tileflow maps or application maps.
|
|
10
|
-
Original Tileflow map definitions, icons, and patterns distributed by `@tileflow/maps` may likewise
|
|
11
|
-
be used, modified, embedded, deployed, and redistributed as part of personal or commercial maps and
|
|
12
|
-
applications.
|
|
13
|
-
|
|
14
|
-
This grant does not relicense third-party software, fonts, icons, map data, datasets, imagery, or
|
|
15
|
-
other input material. Their licenses, attribution requirements, notices, and use restrictions
|
|
16
|
-
continue to apply to the relevant source and generated output. You are responsible for having the
|
|
17
|
-
rights necessary to process and distribute your own inputs.
|
|
18
|
-
|
|
19
|
-
This grant does not provide access to Tileflow hosted services or grant rights in Tileflow names,
|
|
20
|
-
logos, or marks. The SDK and generated output are provided without warranties or conditions beyond
|
|
21
|
-
those required by applicable law.
|
package/NOTICE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
Tileflow SDK
|
|
2
|
-
Copyright 2026 Tileflow.dev contributors
|
|
3
|
-
|
|
4
|
-
This product includes software and original map artwork developed by Tileflow.dev contributors.
|
|
5
|
-
|
|
6
|
-
Third-party materials distributed with a package remain subject to their own license and notice
|
|
7
|
-
files. See THIRD_PARTY_NOTICES.md and asset-adjacent license files where present.
|
|
8
|
-
|
|
9
|
-
The Tileflow names and marks are not licensed under the Apache License 2.0. See TRADEMARKS.md.
|
package/TRADEMARKS.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Tileflow trademarks
|
|
2
|
-
|
|
3
|
-
The Apache License, Version 2.0, and the Tileflow generated-output grant do not grant permission to
|
|
4
|
-
use the Tileflow name, `tileflow.dev`, logos, service marks, product names, or other Tileflow brand
|
|
5
|
-
features except for reasonable and customary use that truthfully describes the origin of the SDK or
|
|
6
|
-
compatibility with Tileflow, and for reproducing required notices.
|
|
7
|
-
|
|
8
|
-
You may not use Tileflow brand features in a way that suggests sponsorship, endorsement, or an
|
|
9
|
-
official Tileflow product when none exists. Third-party names and marks remain the property of their
|
|
10
|
-
respective owners.
|