@tileflow/core 0.1.0-alpha.2 → 0.1.0-alpha.21
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/GENERATED_OUTPUT_LICENSE.md +21 -0
- package/LICENSE +201 -0
- package/NOTICE +9 -0
- package/README.md +1139 -20
- package/THIRD_PARTY_NOTICES.md +185 -0
- package/TRADEMARKS.md +10 -0
- package/dist/browser.d.ts +180 -0
- package/dist/browser.js +3461 -0
- package/dist/build.d.ts +195 -0
- package/dist/build.js +12254 -0
- package/dist/capture-scene-BK_0J2oR.d.ts +161 -0
- package/dist/capture.d.ts +9 -0
- package/dist/capture.js +206 -0
- package/dist/domains-CPSrdTik.d.ts +4 -0
- package/dist/index.d.ts +291 -165
- package/dist/index.js +13416 -3465
- package/dist/manifest.d.ts +3 -0
- package/dist/manifest.js +229 -0
- package/dist/recipe.d.ts +66 -0
- package/dist/recipe.js +577 -0
- package/dist/requirements-BV77ZVhR.d.ts +491 -0
- package/dist/runtime-C4MtSzkB.d.ts +223 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +1117 -0
- package/dist/types-DlUGI6LC.d.ts +525 -0
- package/dist/visual-semantics-DTC-8Hsb.d.ts +479 -0
- package/package.json +51 -7
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import 'zod';
|
|
2
|
+
export { d as TileflowRuntimeColorScheme, e as TileflowRuntimeManifest, n as TileflowRuntimeManifestMapEntry, o as TileflowRuntimeManifestTheme, s as TileflowRuntimeSystemThemes, K as parseTileflowRuntimeManifest, S as safeParseTileflowRuntimeManifest, W as tileflowRuntimeManifestLimits, X as tileflowRuntimeManifestSchema, Y as tileflowRuntimeManifestVersion } from './runtime-C4MtSzkB.js';
|
|
3
|
+
import './types-DlUGI6LC.js';
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// src/manifest.ts
|
|
2
|
+
import { z as z2 } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/portable-identity.ts
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
// src/portable-identity-rules.ts
|
|
8
|
+
var tileflowPortableIdMaximumLength = 64;
|
|
9
|
+
var tileflowPortableIdPattern = /^[a-z][a-z0-9-]{0,63}$/u;
|
|
10
|
+
function isTileflowPortableId(value) {
|
|
11
|
+
return typeof value === "string" && value.length <= tileflowPortableIdMaximumLength && tileflowPortableIdPattern.test(value) && !["constructor", "prototype"].includes(value) && !/^(?:AUX|CON|NUL|PRN|COM[1-9]|LPT[1-9])$/i.test(value);
|
|
12
|
+
}
|
|
13
|
+
function isTileflowThemeName(value) {
|
|
14
|
+
return isTileflowPortableId(value) && value !== "system";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/portable-identity.ts
|
|
18
|
+
var tileflowPortableIdSchema = z.string().min(1).max(tileflowPortableIdMaximumLength).regex(tileflowPortableIdPattern, {
|
|
19
|
+
message: "Expected lowercase kebab-case beginning with a letter"
|
|
20
|
+
}).refine(
|
|
21
|
+
(name) => !["constructor", "prototype"].includes(name) && !/^(?:AUX|CON|NUL|PRN|COM[1-9]|LPT[1-9])$/i.test(name),
|
|
22
|
+
"Expected a portable identifier that is not a reserved filename or prototype key"
|
|
23
|
+
);
|
|
24
|
+
var tileflowThemeNameSchema = tileflowPortableIdSchema.refine(
|
|
25
|
+
isTileflowThemeName,
|
|
26
|
+
"Expected a concrete theme name; system is browser-only"
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// src/manifest.ts
|
|
30
|
+
var tileflowRuntimeManifestVersion = 1;
|
|
31
|
+
var tileflowRuntimeManifestLimits = Object.freeze({ maximumBytes: 1024 * 1024 });
|
|
32
|
+
var safeTextSchema = z2.string().min(1).max(2048).refine((value) => value === value.trim(), "Expected text without surrounding whitespace").refine((value) => !/[\p{Cc}\\]/u.test(value), "Expected safe text");
|
|
33
|
+
var publicResourceUrlSchema = safeTextSchema.refine(isPublicResourceUrl, {
|
|
34
|
+
message: "Expected an HTTP(S), root-relative, or path-relative public URL"
|
|
35
|
+
});
|
|
36
|
+
var apiOriginSchema = safeTextSchema.refine(isApiOrigin, {
|
|
37
|
+
message: "Expected an absolute HTTP(S) origin without path, credentials, query, or fragment"
|
|
38
|
+
});
|
|
39
|
+
var viewSchema = z2.object({
|
|
40
|
+
bearing: z2.number().finite().min(-180).max(180).optional(),
|
|
41
|
+
center: z2.tuple([z2.number().finite().min(-180).max(180), z2.number().finite().min(-90).max(90)]).optional(),
|
|
42
|
+
pitch: z2.number().finite().min(0).max(85).optional(),
|
|
43
|
+
zoom: z2.number().finite().min(0).max(24).optional()
|
|
44
|
+
}).strict();
|
|
45
|
+
var fontFaceSchema = z2.object({
|
|
46
|
+
family: safeTextSchema.max(100),
|
|
47
|
+
source: publicResourceUrlSchema,
|
|
48
|
+
style: z2.enum(["italic", "normal", "oblique"]).optional(),
|
|
49
|
+
weight: z2.enum(["100", "200", "300", "400", "500", "600", "700", "800", "900"]).optional()
|
|
50
|
+
}).strict();
|
|
51
|
+
var fontFacesSchema = z2.array(fontFaceSchema).max(16).superRefine(validateUniqueFontFaces);
|
|
52
|
+
var manifestThemeSchema = z2.object({
|
|
53
|
+
colorScheme: z2.enum(["dark", "light"]),
|
|
54
|
+
fontFaces: fontFacesSchema.optional(),
|
|
55
|
+
revision: safeTextSchema.max(128).optional(),
|
|
56
|
+
styleId: safeTextSchema.max(128).optional(),
|
|
57
|
+
styleUrl: publicResourceUrlSchema
|
|
58
|
+
}).strict();
|
|
59
|
+
var manifestMapSchema = z2.object({
|
|
60
|
+
apiUrl: apiOriginSchema.optional(),
|
|
61
|
+
defaultTheme: tileflowThemeNameSchema,
|
|
62
|
+
environment: safeTextSchema.max(128).optional(),
|
|
63
|
+
mapId: safeTextSchema.max(128).optional(),
|
|
64
|
+
systemThemes: z2.object({ dark: tileflowThemeNameSchema, light: tileflowThemeNameSchema }).strict().optional(),
|
|
65
|
+
themes: z2.record(tileflowThemeNameSchema, manifestThemeSchema),
|
|
66
|
+
usageMode: z2.literal("session").optional(),
|
|
67
|
+
view: viewSchema.optional(),
|
|
68
|
+
worldGeneration: z2.literal("v1").optional()
|
|
69
|
+
}).strict().superRefine((entry, context) => {
|
|
70
|
+
const names = Object.keys(entry.themes);
|
|
71
|
+
if (names.length === 0) {
|
|
72
|
+
context.addIssue({ code: "custom", message: "Expected at least one theme", path: ["themes"] });
|
|
73
|
+
}
|
|
74
|
+
if (names.length > 64) {
|
|
75
|
+
context.addIssue({ code: "too_big", maximum: 64, origin: "object", path: ["themes"] });
|
|
76
|
+
}
|
|
77
|
+
if (!Object.hasOwn(entry.themes, entry.defaultTheme)) {
|
|
78
|
+
context.addIssue({
|
|
79
|
+
code: "custom",
|
|
80
|
+
message: "defaultTheme must name a declared theme",
|
|
81
|
+
path: ["defaultTheme"]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (entry.systemThemes) {
|
|
85
|
+
for (const colorScheme of ["light", "dark"]) {
|
|
86
|
+
const name = entry.systemThemes[colorScheme];
|
|
87
|
+
const theme = entry.themes[name];
|
|
88
|
+
if (!theme) {
|
|
89
|
+
context.addIssue({
|
|
90
|
+
code: "custom",
|
|
91
|
+
message: `systemThemes.${colorScheme} must name a declared theme`,
|
|
92
|
+
path: ["systemThemes", colorScheme]
|
|
93
|
+
});
|
|
94
|
+
} else if (theme.colorScheme !== colorScheme) {
|
|
95
|
+
context.addIssue({
|
|
96
|
+
code: "custom",
|
|
97
|
+
message: `systemThemes.${colorScheme} must reference a ${colorScheme} theme`,
|
|
98
|
+
path: ["systemThemes", colorScheme]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (entry.usageMode === void 0 !== (entry.worldGeneration === void 0)) {
|
|
104
|
+
context.addIssue({
|
|
105
|
+
code: "custom",
|
|
106
|
+
message: "usageMode and worldGeneration must be declared together"
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
var canonicalManifestSchema = z2.object({
|
|
111
|
+
apiUrl: apiOriginSchema.optional(),
|
|
112
|
+
maps: z2.record(tileflowPortableIdSchema, manifestMapSchema),
|
|
113
|
+
version: z2.literal(tileflowRuntimeManifestVersion)
|
|
114
|
+
}).strict().superRefine((manifest, context) => {
|
|
115
|
+
const mapCount = Object.keys(manifest.maps).length;
|
|
116
|
+
if (mapCount === 0) {
|
|
117
|
+
context.addIssue({ code: "custom", message: "Expected at least one map", path: ["maps"] });
|
|
118
|
+
}
|
|
119
|
+
if (mapCount > 1e3) {
|
|
120
|
+
context.addIssue({ code: "too_big", maximum: 1e3, origin: "object", path: ["maps"] });
|
|
121
|
+
}
|
|
122
|
+
if (new TextEncoder().encode(JSON.stringify(manifest)).byteLength > tileflowRuntimeManifestLimits.maximumBytes) {
|
|
123
|
+
context.addIssue({
|
|
124
|
+
code: "too_big",
|
|
125
|
+
maximum: tileflowRuntimeManifestLimits.maximumBytes,
|
|
126
|
+
origin: "string",
|
|
127
|
+
message: "Manifest JSON exceeds the 1 MiB limit"
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
var safeManifestInputSchema = z2.unknown().superRefine((input, context) => {
|
|
132
|
+
const unsafe = findUnsafeManifestStructure(input);
|
|
133
|
+
if (unsafe) {
|
|
134
|
+
context.addIssue({
|
|
135
|
+
code: "custom",
|
|
136
|
+
message: unsafe.reason === "prototype" ? "Expected plain manifest objects" : "Expected no prototype-mutating keys",
|
|
137
|
+
path: unsafe.path
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
var tileflowRuntimeManifestSchema = safeManifestInputSchema.pipe(canonicalManifestSchema);
|
|
142
|
+
function parseTileflowRuntimeManifest(input) {
|
|
143
|
+
return tileflowRuntimeManifestSchema.parse(input);
|
|
144
|
+
}
|
|
145
|
+
function safeParseTileflowRuntimeManifest(input) {
|
|
146
|
+
return tileflowRuntimeManifestSchema.safeParse(input);
|
|
147
|
+
}
|
|
148
|
+
function validateUniqueFontFaces(fontFaces, context) {
|
|
149
|
+
const seen = /* @__PURE__ */ new Map();
|
|
150
|
+
for (const [index, fontFace] of fontFaces.entries()) {
|
|
151
|
+
const identity = `${fontFace.family}\0${fontFace.style ?? "normal"}\0${fontFace.weight ?? "400"}`;
|
|
152
|
+
const first = seen.get(identity);
|
|
153
|
+
if (first !== void 0) {
|
|
154
|
+
context.addIssue({
|
|
155
|
+
code: "custom",
|
|
156
|
+
message: `Duplicate font face identity; first declared at index ${first}`,
|
|
157
|
+
path: [index]
|
|
158
|
+
});
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
seen.set(identity, index);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function isPublicResourceUrl(value) {
|
|
165
|
+
if (value.startsWith("//")) return false;
|
|
166
|
+
if (!value.startsWith("/") && !value.startsWith("./") && !value.startsWith("../") && !isAbsolutePublicUrl(value)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return isSafeResolvedPublicUrl(value);
|
|
170
|
+
}
|
|
171
|
+
function isAbsolutePublicUrl(value) {
|
|
172
|
+
try {
|
|
173
|
+
const url = new URL(value);
|
|
174
|
+
return (url.protocol === "http:" || url.protocol === "https:") && !url.username && !url.password && !url.hash && !hasEncodedPathSeparator(value);
|
|
175
|
+
} catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function isSafeResolvedPublicUrl(value) {
|
|
180
|
+
try {
|
|
181
|
+
const url = new URL(value, "https://manifest.invalid/owner/manifest.json");
|
|
182
|
+
return (url.protocol === "http:" || url.protocol === "https:") && !url.username && !url.password && !url.hash && !hasEncodedPathSeparator(value);
|
|
183
|
+
} catch {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function hasEncodedPathSeparator(value) {
|
|
188
|
+
return /%(?:2f|5c)/iu.test(value);
|
|
189
|
+
}
|
|
190
|
+
function isApiOrigin(value) {
|
|
191
|
+
try {
|
|
192
|
+
const url = new URL(value);
|
|
193
|
+
return isAbsolutePublicUrl(value) && url.pathname === "/" && !url.search && value.replace(/\/$/u, "") === url.origin;
|
|
194
|
+
} catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function findUnsafeManifestStructure(input) {
|
|
199
|
+
if (!input || typeof input !== "object") return void 0;
|
|
200
|
+
const pending = [{ path: [], value: input }];
|
|
201
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
202
|
+
while (pending.length > 0) {
|
|
203
|
+
const current = pending.pop();
|
|
204
|
+
if (visited.has(current.value)) continue;
|
|
205
|
+
visited.add(current.value);
|
|
206
|
+
if (!Array.isArray(current.value)) {
|
|
207
|
+
const prototype = Object.getPrototypeOf(current.value);
|
|
208
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
209
|
+
return { path: current.path, reason: "prototype" };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
for (const key of Object.keys(current.value)) {
|
|
213
|
+
const path = [...current.path, Array.isArray(current.value) ? Number(key) : key];
|
|
214
|
+
if (key === "__proto__") return { path, reason: "key" };
|
|
215
|
+
const descriptor = Object.getOwnPropertyDescriptor(current.value, key);
|
|
216
|
+
if (descriptor && "value" in descriptor && descriptor.value && typeof descriptor.value === "object") {
|
|
217
|
+
pending.push({ path, value: descriptor.value });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
parseTileflowRuntimeManifest,
|
|
225
|
+
safeParseTileflowRuntimeManifest,
|
|
226
|
+
tileflowRuntimeManifestLimits,
|
|
227
|
+
tileflowRuntimeManifestSchema,
|
|
228
|
+
tileflowRuntimeManifestVersion
|
|
229
|
+
};
|
package/dist/recipe.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { T as TileflowStreetsModuleName, O as OpenMapTilesFieldBindings, a as OpenMapTilesLayerBindings } from './visual-semantics-DTC-8Hsb.js';
|
|
2
|
+
export { b as TileflowVisualValueCategory, c as classifyTileflowVisualProperty } from './visual-semantics-DTC-8Hsb.js';
|
|
3
|
+
import { T as TileflowLayerDomain } from './domains-CPSrdTik.js';
|
|
4
|
+
export { t as toMapLibreStyleValue } from './types-DlUGI6LC.js';
|
|
5
|
+
|
|
6
|
+
type TileflowSemanticFieldReference = {
|
|
7
|
+
readonly kind: 'tileflow-semantic-field';
|
|
8
|
+
readonly name: keyof OpenMapTilesFieldBindings;
|
|
9
|
+
};
|
|
10
|
+
type TileflowSemanticLayerReference = {
|
|
11
|
+
readonly kind: 'tileflow-semantic-layer';
|
|
12
|
+
readonly name: keyof OpenMapTilesLayerBindings;
|
|
13
|
+
};
|
|
14
|
+
type TileflowModuleLayerPlacement = {
|
|
15
|
+
after: string;
|
|
16
|
+
} | {
|
|
17
|
+
before: string;
|
|
18
|
+
};
|
|
19
|
+
type TileflowModuleEffect = {
|
|
20
|
+
kind: 'patch';
|
|
21
|
+
owner: TileflowStreetsModuleName;
|
|
22
|
+
patch: Record<string, unknown>;
|
|
23
|
+
requires?: readonly TileflowLayerDomain[];
|
|
24
|
+
target: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'add';
|
|
27
|
+
layer: Record<string, unknown> & {
|
|
28
|
+
id: string;
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
owner: TileflowStreetsModuleName;
|
|
32
|
+
placement: TileflowModuleLayerPlacement;
|
|
33
|
+
requires?: readonly TileflowLayerDomain[];
|
|
34
|
+
target: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: 'remove';
|
|
37
|
+
owner: TileflowStreetsModuleName;
|
|
38
|
+
requires?: readonly TileflowLayerDomain[];
|
|
39
|
+
target: string;
|
|
40
|
+
};
|
|
41
|
+
/** Compiler-private authoring field reference. Official maps never capture physical data fields. */
|
|
42
|
+
declare function semanticField(name: keyof OpenMapTilesFieldBindings): TileflowSemanticFieldReference;
|
|
43
|
+
/** Compiler-private authoring layer reference. Official maps never capture physical source layers. */
|
|
44
|
+
declare function semanticLayer(name: keyof OpenMapTilesLayerBindings): TileflowSemanticLayerReference;
|
|
45
|
+
declare function patchModuleLayer(owner: TileflowStreetsModuleName, target: string, patch: Record<string, unknown>, options?: {
|
|
46
|
+
requires?: readonly TileflowLayerDomain[];
|
|
47
|
+
}): TileflowModuleEffect;
|
|
48
|
+
declare function addModuleLayer(owner: TileflowStreetsModuleName, target: string, layer: Record<string, unknown> & {
|
|
49
|
+
id: string;
|
|
50
|
+
type: string;
|
|
51
|
+
}, placement: TileflowModuleLayerPlacement, options?: {
|
|
52
|
+
requires?: readonly TileflowLayerDomain[];
|
|
53
|
+
}): TileflowModuleEffect;
|
|
54
|
+
declare function removeModuleLayer(owner: TileflowStreetsModuleName, target: string, options?: {
|
|
55
|
+
requires?: readonly TileflowLayerDomain[];
|
|
56
|
+
}): TileflowModuleEffect;
|
|
57
|
+
/**
|
|
58
|
+
* Attach compiler-private effects without adding a public string key to a map definition.
|
|
59
|
+
* The empty return type deliberately keeps the symbol out of public authoring inference.
|
|
60
|
+
*/
|
|
61
|
+
declare function internalModuleEffects(effects: readonly TileflowModuleEffect[]): {};
|
|
62
|
+
declare function getResolvedModuleEffects(input: object): readonly TileflowModuleEffect[];
|
|
63
|
+
|
|
64
|
+
declare function isMapLibreExpressionOperator(value: unknown): value is string;
|
|
65
|
+
|
|
66
|
+
export { type TileflowModuleEffect, type TileflowModuleLayerPlacement, addModuleLayer, internalModuleEffects as defineModuleEffects, getResolvedModuleEffects, isMapLibreExpressionOperator, patchModuleLayer, removeModuleLayer, semanticField, semanticLayer };
|