@tileflow/core 0.1.0-alpha.23 → 0.1.0-alpha.25

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.
@@ -0,0 +1,117 @@
1
+ # Native resource URLs
2
+
3
+ `@tileflow/core/native` provides synchronous URL helpers for clients that do not have a browser
4
+ origin. It has no renderer dependency and does not access browser globals when imported.
5
+
6
+ These helpers resolve URLs; they do not load manifests, validate MapLibre styles, create maps, or
7
+ authorize Hosted requests. A successful resolution is not a claim that a style or feature works on
8
+ a particular native renderer. Install `@tileflow/core@alpha` as described in the
9
+ [package README](../README.md); the examples use only this package's public exports.
10
+
11
+ ## Resolve the manifest explicitly
12
+
13
+ A native client must provide the complete manifest URL. There is no implicit
14
+ `/tileflow/manifest.json`, Metro host, device address, or current application route.
15
+
16
+ <!-- docs:check -->
17
+
18
+ ```ts
19
+ import {resolveTileflowNativeManifestUrl} from '@tileflow/core/native';
20
+
21
+ const manifestUrl = resolveTileflowNativeManifestUrl(
22
+ 'https://maps.example.com/tileflow/native/manifest.json',
23
+ );
24
+ ```
25
+
26
+ The result is the validated, absolute HTTPS manifest URL; no network request is made.
27
+ The default policy requires HTTPS. Both input and resolved URLs are limited to 2,048 UTF-16 code
28
+ units. Empty values, leading or trailing whitespace, control characters, backslashes, fragments,
29
+ malformed percent escapes, embedded credentials, and protocol-relative URLs are rejected.
30
+ Local file URLs and custom renderer protocols are outside this helper's HTTP(S) contract.
31
+
32
+ ## Resolve resources from their owning document
33
+
34
+ Pass the URL of the document that declares the resource. A style URL is relative to its manifest;
35
+ a tile URL in TileJSON is relative to that TileJSON; a font URL in a style is relative to the style.
36
+ The helper uses normal URL path resolution and never guesses a deployment prefix.
37
+
38
+ <!-- docs:check -->
39
+
40
+ ```ts
41
+ import {resolveTileflowNativeResourceUrl} from '@tileflow/core/native';
42
+
43
+ const styleUrl = resolveTileflowNativeResourceUrl('styles/main/light.json', {
44
+ documentUrl: 'https://maps.example.com/tileflow/native/manifest.json',
45
+ });
46
+
47
+ const tileUrl = resolveTileflowNativeResourceUrl('./{z}/{x}/{y}.pbf', {
48
+ documentUrl: 'https://tiles.example.com/streets/tiles.json',
49
+ template: 'tile',
50
+ });
51
+ ```
52
+
53
+ `styleUrl` resolves to the `styles/main/light.json` path beneath the manifest's directory. `tileUrl`
54
+ resolves to the `streets/{z}/{x}/{y}.pbf` template on the tile server; no tile coordinates are chosen.
55
+
56
+ Use the actual document URL after any redirects that the application has approved. The declaring
57
+ URL is validated even when the resource is already absolute. External HTTPS resources retain their
58
+ own origin. The helper never adds delivery credentials or copies a parent's query parameters to a
59
+ child resource.
60
+
61
+ `template: 'tile'` preserves `{z}`, `{x}`, `{y}`, `{ratio}`, `{quadkey}`, `{bbox-epsg-3857}`, and
62
+ `{prefix}`. `template: 'glyphs'` preserves `{fontstack}` and `{range}`. These placeholders are allowed
63
+ only in the resource path or query, not the authority. They are not expanded or checked against a
64
+ renderer version. Unknown, mismatched, and incomplete placeholders are rejected. Without a template
65
+ option, literal braces are rejected; existing percent-encoded braces in paths and queries remain
66
+ encoded literal data. Manifest and declaring-document URLs cannot contain literal placeholders.
67
+ Hostname normalization must not introduce placeholders, including from percent escapes or Unicode
68
+ characters that normalize to braces.
69
+
70
+ ## Opt into one development origin
71
+
72
+ A debug integration can explicitly permit one HTTP origin:
73
+
74
+ <!-- docs:check -->
75
+
76
+ ```ts
77
+ import {resolveTileflowNativeManifestUrl} from '@tileflow/core/native';
78
+
79
+ const manifestUrl = resolveTileflowNativeManifestUrl(
80
+ 'http://192.168.1.5:8080/tileflow/manifest.json',
81
+ {developmentOrigin: 'http://192.168.1.5:8080'},
82
+ );
83
+ ```
84
+
85
+ Supply the same option when resolving that document's resources. Scheme, hostname, and port must
86
+ match the selected origin after URL normalization. An exception for `localhost` does not permit
87
+ `127.0.0.1`, another port, or another device. HTTPS remains allowed. The option must name an HTTP
88
+ origin without a path, query, fragment, wildcard, or credentials; an optional trailing slash is
89
+ accepted. Wildcards and placeholders are rejected before and after hostname normalization.
90
+
91
+ Keep this option in debug-only application configuration. The helper cannot determine whether the
92
+ application is a debug build, does not change iOS or Android transport settings, and does not expose
93
+ a development server. The application still owns any narrowly scoped debug transport exception.
94
+
95
+ ## Handle errors without logging the rejected URL
96
+
97
+ Failures throw `TileflowNativeUrlError`, a `TypeError` with a stable `code` and `field`.
98
+
99
+ - `NATIVE_URL_INVALID`: malformed, unsafe, unsupported-scheme, or oversized URL.
100
+ - `NATIVE_URL_ABSOLUTE_REQUIRED`: a document URL is missing its explicit HTTP(S) origin.
101
+ - `NATIVE_URL_HTTPS_REQUIRED`: HTTP does not match the selected development origin.
102
+ - `NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID`: the development exception is not one valid HTTP origin.
103
+ - `NATIVE_URL_TEMPLATE_INVALID`: a template is unsupported, misplaced, or incomplete.
104
+
105
+ `field` is `manifestUrl`, `documentUrl`, `resourceUrl`, or `developmentOrigin`. Error messages do not
106
+ include the submitted URL or attach the original parser error. The application should preserve
107
+ that boundary when reporting failures: resource URLs may contain sensitive query parameters.
108
+
109
+ For JavaScript callers, missing or non-object resource options report `NATIVE_URL_INVALID` with
110
+ `field: 'documentUrl'`, just like an options object without its required `documentUrl`. Non-object
111
+ manifest options report `NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID` with `field: 'developmentOrigin'`.
112
+ Omitting manifest options or passing `undefined` remains valid and uses the default HTTPS policy.
113
+ Neither function accepts `null` as an options object.
114
+
115
+ This is URL policy, not an authorization or server-side request-forgery defense. Callers still own
116
+ resource-origin authorization, redirect handling, response size limits, cancellation, and any
117
+ network request. Do not attach a credential merely because this helper accepted a URL.
@@ -0,0 +1,86 @@
1
+ # Public API and browser subpath
2
+
3
+ Start with the [@tileflow/core guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for installation and a complete first example.
4
+
5
+ Config, data, modules, compilation, validation, runtime resolution, and capture-scene APIs remain
6
+ available from the package root. Capture scenes, manifests, and browser-runtime surfaces also have
7
+ explicit `@tileflow/core/capture`, `@tileflow/core/manifest`, and `@tileflow/core/runtime`
8
+ subpaths. Node build integrations import the small deterministic map-identity contract from
9
+ `@tileflow/core/build`: `collectTileflowMapBuildLineage`, `createTileflowMapBuildManifest`,
10
+ `hashTileflowMapRevision`, `hashTileflowAssetSet`, and `hashTileflowAssetSetIdentities`. The latter
11
+ reproduces the same asset-set v1 hash from exact per-file identities after another system has
12
+ independently confirmed the immutable bytes; package or bundle hashes are not substitutes. The
13
+ previous aggregate-wrapper and recipe-selector APIs, `renderer`, top-level `tiles`/`tileset`, module
14
+ arrays, and top-level raw `layers` are not part of this API. Raw MapLibre layers are accepted only
15
+ inside a named `maplibreOverlay()` bound to a named Team source.
16
+
17
+ Advanced cartography remains in the same public language: `withRenderStack()`, `renderPass()`, and
18
+ `refineRenderTarget()` address owner-local semantic targets without exposing physical layer IDs,
19
+ sources, source layers, raw filters, or before/after anchors. Typed `field()` references and
20
+ `expr.*` builders stay semantic until the compiler's single lowering boundary. There is no recipe
21
+ subpath or alternate compiler integration API.
22
+
23
+ `mapRevisionSha256` hashes only resolved cartography: the effective design after `extends`, the
24
+ semantic language, compiler-owned effective contributions, and exact source icon/font identities.
25
+ Leaf `id`, `name`, editorial `mapVersion`, default `view`, capture `scenes`, and `delivery` policy do
26
+ not change that content identity. They remain explicit on the map, manifest, Style, capture receipt,
27
+ or Hosted deployment fingerprint that owns them. Compiler ABI, package versions, generated assets,
28
+ and the concrete release selected by World `current` likewise have separate identities.
29
+
30
+ Runtime manifest version 1 has one shape for local and Hosted delivery. Every map entry owns
31
+ `defaultTheme`, optional `systemThemes`, and a `themes` record whose leaves contain
32
+ `colorScheme`, `styleUrl`, and optional font/deployment identity. Hosted-only identity is additive
33
+ metadata on the same map entry; there is no delivery discriminator or parallel `styles` alias.
34
+ `parseTileflowRuntimeManifest()` accepts only this canonical shape. The strict bounded schema uses
35
+ the same portable map and theme IDs as authoring, rejects `system` as a published name, duplicate
36
+ font identities, unsafe owner-relative URLs, prototype-bearing input, unknown fields, and JSON
37
+ larger than 1 MiB.
38
+
39
+ ```json
40
+ {
41
+ "version": 1,
42
+ "maps": {
43
+ "madrid": {
44
+ "defaultTheme": "light",
45
+ "systemThemes": {"light": "light", "dark": "dark"},
46
+ "themes": {
47
+ "light": {"colorScheme": "light", "styleUrl": "/styles/madrid/light.json"},
48
+ "dark": {"colorScheme": "dark", "styleUrl": "/styles/madrid/dark.json"}
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ Runtime fetches share a successful result for 30 seconds, never cache failures, use
56
+ `cache: 'no-store'`, enforce a 10-second timeout (configurable up to 60 seconds), compose an
57
+ external abort signal, and can be invalidated with `clearTileflowManifestCache()`.
58
+
59
+ Named map `view` values travel in the manifest. `resolveTileflowRuntimeTheme()` turns an omitted,
60
+ explicit, or browser `system` request into one concrete published entry; unknown names fail closed.
61
+ `resolveTileflowRuntimeView()` defines the shared
62
+ precedence as explicit runtime values, then the manifest view, then the single exported
63
+ `defaultTileflowRuntimeView` (`[0, 20]`, zoom 2, bearing/pitch 0). Browser delivery is one
64
+ discriminated `TileflowRuntimeSource`: `kind: 'tileflow'` resolves a named map only through its
65
+ published manifest, while `kind: 'maplibre'` accepts a direct style object or URL. The runtime
66
+ subpath does not import the config compiler, invent a localhost style URL, or change image mode by
67
+ environment.
68
+
69
+ Framework adapters import the browser-only lifecycle kernel explicitly:
70
+
71
+ ```ts
72
+ import {
73
+ attachTileflowFairUseNotice,
74
+ attachTileflowMapLifecycle,
75
+ createTileflowSessionStarter,
76
+ createTileflowTransformRequest,
77
+ registerTileflowWorldRequestBridge,
78
+ } from '@tileflow/core/browser';
79
+ ```
80
+
81
+ The browser entry is not re-exported from the root. It is SSR-safe to import, has no MapLibre
82
+ runtime dependency, and reads no browser global during module evaluation. See the
83
+ [framework browser runtime contract](https://github.com/tileflow/tileflow-sdk/blob/main/docs/contracts/framework-browser-runtime.md) and the
84
+ [cartographic authoring contract](https://github.com/tileflow/tileflow-sdk/blob/main/docs/contracts/cartographic-authoring.md). Exact field
85
+ resolution and asset rules live in the
86
+ [map inheritance contract](https://github.com/tileflow/tileflow-sdk/blob/main/docs/contracts/map-inheritance.md).
@@ -0,0 +1,22 @@
1
+ # Shared visual primitives
2
+
3
+ Start with the [@tileflow/core guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for installation and a complete first example.
4
+
5
+ The same small visual language is reused across every geographic domain. This keeps an agent from
6
+ having to learn different spellings for the same MapLibre behavior:
7
+
8
+ - `BackgroundStyle`: color, opacity, pattern, visibility, and zoom range.
9
+ - `FillStyle`: color, opacity, pattern, antialiasing, visibility, and zoom range.
10
+ - `LineStyle`: color, width, opacity, dash, blur, gap, offset, pattern, caps, joins, and zoom range.
11
+ - `LineHatchStyle`: repeated diagonal detail with color, opacity, spacing, size, angle, and zoom
12
+ range for a road structure.
13
+ - `TextStyle`: field, exact font face, exact fallback faces, size, color, halo, spacing metrics, transform,
14
+ collision policy, rotation, fixed/variable anchoring, line constraints, and zoom range.
15
+ - `IconStyle`: image, size, color, halo, rotation/alignment, collision policy, and zoom range.
16
+ - `CircleStyle`: radius, fill/stroke appearance, blur, opacity, pitch behavior, and zoom range.
17
+ - `ExtrusionStyle`: color, height, base, opacity, pattern, vertical gradient, and zoom range.
18
+
19
+ Compounds express common cartographic structures: `AreaStyle` has `fill` and `outline`,
20
+ `LineStackStyle` has `shadow`, `casing`, and `fill`, and `SymbolStyle` combines placement with
21
+ optional `text`, `icon`, and `marker`. Geographic selection remains owned by semantic modules;
22
+ ordinary visual styles intentionally do not accept raw source filters.
@@ -0,0 +1,83 @@
1
+ # Themes and module styles
2
+
3
+ Start with the [@tileflow/core guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for installation and a complete first example.
4
+
5
+ A map declares complete named appearances in `themes`, chooses one deterministic
6
+ `defaultTheme`, and may map the browser's light/dark preference through `systemThemes`. `system` is
7
+ never a compiled theme name: it is a runtime request that resolves immediately to one concrete
8
+ name. Disk builds write `styles/<map>/<theme>.json` beneath their output root. Public and
9
+ content-addressed Style URLs belong to the runtime manifest and may include a deployment prefix;
10
+ capture scenes and receipts store the concrete name rather than `system`.
11
+
12
+ Themes are flat, JSON-safe documents with `colorScheme`, identity, typography, lighting, and four
13
+ typed token catalogs: `color`, `font`, `image`, and `number`. Every theme on one map must expose the
14
+ same token keys, so changing a theme can never change map structure or silently lose a semantic
15
+ role. `defineTheme(base, definition)` is an authoring convenience that returns a fully materialized
16
+ document; it does not leave an inheritance edge in the resolved config.
17
+
18
+ The key in the `themes` record is its concrete runtime selector and output-path segment. The
19
+ theme's own `id` and `version` are its editorial identity and build provenance, so they need not
20
+ equal that key. Concrete keys may be names such as `day` and `night`; every `systemThemes.light` or
21
+ `systemThemes.dark` value must name an existing theme whose `colorScheme` matches that branch.
22
+
23
+ ```ts
24
+ import {color, defineMap, defineTheme, fixed, roads, token} from '@tileflow/core';
25
+ import {streets, streetsThemes} from '@tileflow/maps';
26
+
27
+ const dark = defineTheme(streetsThemes.dark, {
28
+ id: 'company-dark',
29
+ version: 1,
30
+ colorScheme: 'dark',
31
+ tokens: {
32
+ color: {
33
+ 'surface.land': '#101722',
34
+ 'labels.primary': color.mix('#eef3fb', token.color('surface.background'), {amount: 0.08}),
35
+ },
36
+ },
37
+ });
38
+
39
+ export default defineMap({
40
+ id: 'company',
41
+ version: 1,
42
+ extends: streets,
43
+ themes: {light: streetsThemes.light, dark},
44
+ defaultTheme: 'light',
45
+ systemThemes: {light: 'light', dark: 'dark'},
46
+ modules: {
47
+ roads: roads({
48
+ classes: {
49
+ primary: {
50
+ surface: {
51
+ fill: {
52
+ color: fixed('#ff2d78', {reason: 'Regulatory primary-road ink is invariant'}),
53
+ },
54
+ },
55
+ },
56
+ secondary: {
57
+ surface: {
58
+ fill: {
59
+ color: token.color('roads.secondary'),
60
+ },
61
+ },
62
+ },
63
+ },
64
+ }),
65
+ },
66
+ });
67
+ ```
68
+
69
+ Semantic modules own structure and behavior; visual fields accept typed token references.
70
+ Use a visual literal only inside a theme. If a module value intentionally must not vary, wrap it in
71
+ `fixed(value, {reason})`. `tileflow inspect --json` reports stable `THEME_IMPLICIT_FIXED`
72
+ diagnostics: implicit color, font, and image literals block Style compilation, while direct visual
73
+ number literals are warnings so an agent can document their invariance deliberately. Structural
74
+ numbers such as zoom bounds and ranks are not visual-theme diagnostics. `color.alpha()` and
75
+ deterministic OKLCH `color.mix()` keep derived palette logic inspectable. Unknown refs, cycles,
76
+ cross-category refs, token-schema drift, and unresolved visual nodes fail before Style JSON is
77
+ emitted.
78
+
79
+ There is no physical-layer override for the Tileflow basemap or separate official-map authoring
80
+ surface. Basemap behavior belongs to a typed control or owner-local render stack. Every
81
+ official and application map therefore follows the same schema, inheritance rules, diagnostics,
82
+ and lowering path. `createStyle()` validates the final planned Style JSON with the MapLibre style
83
+ spec and never returns an invalid style.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tileflow/core",
3
- "version": "0.1.0-alpha.23",
3
+ "version": "0.1.0-alpha.25",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Typed Tileflow config and MapLibre style compiler.",
6
6
  "type": "module",
@@ -25,11 +25,9 @@
25
25
  "types": "./dist/index.d.ts",
26
26
  "files": [
27
27
  "dist",
28
+ "docs",
28
29
  "LICENSE",
29
- "NOTICE",
30
- "THIRD_PARTY_NOTICES.md",
31
- "GENERATED_OUTPUT_LICENSE.md",
32
- "TRADEMARKS.md"
30
+ "THIRD_PARTY_NOTICES.md"
33
31
  ],
34
32
  "exports": {
35
33
  ".": {
@@ -58,6 +56,11 @@
58
56
  "import": "./dist/manifest.js",
59
57
  "default": "./dist/manifest.js"
60
58
  },
59
+ "./native": {
60
+ "types": "./dist/native.d.ts",
61
+ "import": "./dist/native.js",
62
+ "default": "./dist/native.js"
63
+ },
61
64
  "./runtime": {
62
65
  "types": "./dist/runtime.d.ts",
63
66
  "import": "./dist/runtime.js",
@@ -77,7 +80,7 @@
77
80
  "pmtiles": "4.4.0"
78
81
  },
79
82
  "scripts": {
80
- "build": "tsup src/index.ts src/build.ts src/capture.ts src/manifest.ts src/runtime.ts --format esm --dts --clean --no-splitting && tsup src/browser.ts --format esm --dts --no-splitting --platform browser && cp ../../docs/modules-api-reference.json dist/config-reference.json",
83
+ "build": "tsup src/index.ts src/build.ts src/capture.ts src/manifest.ts src/runtime.ts --format esm --dts --clean --no-splitting && tsup src/browser.ts src/native.ts --format esm --dts --no-splitting --platform browser && cp ../../docs/modules-api-reference.json dist/config-reference.json",
81
84
  "reference:check": "tsx scripts/generate-config-reference.ts --check",
82
85
  "reference:generate": "tsx scripts/generate-config-reference.ts --write",
83
86
  "verify": "pnpm run build && tsx --test test/*.test.ts",
@@ -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.