@tileflow/dev 0.1.0-alpha.4 → 0.1.0-alpha.41

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 (45) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +264 -5
  3. package/THIRD_PARTY_NOTICES.md +309 -0
  4. package/dist/artifacts.d.ts +269 -0
  5. package/dist/artifacts.js +98 -0
  6. package/dist/chunk-AQUGMUZW.js +324 -0
  7. package/dist/chunk-C4VPHZ3F.js +4062 -0
  8. package/dist/chunk-D4OE4ITL.js +13 -0
  9. package/dist/chunk-FOMTSCOP.js +671 -0
  10. package/dist/chunk-GXLY73PD.js +3199 -0
  11. package/dist/chunk-KDFTE4Q5.js +156 -0
  12. package/dist/chunk-ONYQNLNA.js +1108 -0
  13. package/dist/chunk-RTU7TD4M.js +172 -0
  14. package/dist/chunk-XHJBCVBB.js +241 -0
  15. package/dist/config.d.ts +33 -0
  16. package/dist/config.js +27 -0
  17. package/dist/fonts.d.ts +47 -0
  18. package/dist/fonts.js +16 -0
  19. package/dist/icons-BIHpw5Zy.d.ts +417 -0
  20. package/dist/icons.d.ts +3 -0
  21. package/dist/icons.js +41 -0
  22. package/dist/inspect.d.ts +149 -0
  23. package/dist/inspect.js +805 -0
  24. package/dist/inspector-browser.js +16955 -0
  25. package/dist/inspector-observer.js +95 -0
  26. package/dist/preview-assets-ATLLYY72.js +103 -0
  27. package/dist/preview.d.ts +31 -0
  28. package/dist/preview.js +1974 -0
  29. package/dist/server.d.ts +89 -0
  30. package/dist/server.js +3662 -0
  31. package/dist/tilesets.d.ts +89 -0
  32. package/dist/tilesets.js +6 -0
  33. package/dist/validation.d.ts +65 -0
  34. package/dist/validation.js +24 -0
  35. package/package.json +77 -13
  36. package/ui-fonts/hubot-sans-OFL.txt +93 -0
  37. package/ui-fonts/hubot-sans.woff2 +0 -0
  38. package/ui-fonts/inter-OFL.txt +92 -0
  39. package/ui-fonts/inter.woff2 +0 -0
  40. package/ui-fonts/jetbrains-mono-OFL.txt +93 -0
  41. package/ui-fonts/jetbrains-mono.woff2 +0 -0
  42. package/ui-fonts/mona-sans-OFL.txt +93 -0
  43. package/ui-fonts/mona-sans.woff2 +0 -0
  44. package/dist/index.d.ts +0 -54
  45. package/dist/index.js +0 -314
@@ -0,0 +1,93 @@
1
+ Copyright (c) 2023, GitHub https://github.com/github/mona-sans
2
+ with Reserved Font Name "Mona Sans"
3
+
4
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
5
+ This license is copied below, and is also available with a FAQ at:
6
+ http://scripts.sil.org/OFL
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting — in part or in whole — any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file
package/dist/index.d.ts DELETED
@@ -1,54 +0,0 @@
1
- import { TileflowManifest, MapLibreStyle, ValidationMessage, TileflowProjectConfig, TileflowStyleOptions } from '@tileflow/core';
2
-
3
- declare const defaultTileflowApiUrl = "https://api.tileflow.dev";
4
- declare const defaultTileflowConfigPath = "tileflow.config.ts";
5
- declare const defaultTileflowManifestPath = "public/tileflow/manifest.json";
6
- declare const defaultTileflowTileset = "world";
7
- type LoadTileflowConfigOptions = {
8
- cwd?: string;
9
- fresh?: boolean;
10
- };
11
- type TileflowManifestOptions = {
12
- styleBaseUrl?: string;
13
- tileBaseUrl?: string;
14
- };
15
- type TileflowDevRequestHandlerOptions = {
16
- basePath?: string;
17
- config?: string;
18
- cwd?: string;
19
- onError?: (error: unknown) => void;
20
- styleBaseUrl?: string;
21
- tileBaseUrl?: string;
22
- };
23
- type TileflowBuildArtifactsOptions = {
24
- config?: string;
25
- cwd?: string;
26
- styleBaseUrl?: string;
27
- tileBaseUrl?: string;
28
- };
29
- type TileflowBuildArtifacts = {
30
- manifest: TileflowManifest;
31
- styles: Record<string, MapLibreStyle>;
32
- };
33
- type WriteTileflowBuildArtifactsOptions = TileflowBuildArtifactsOptions & {
34
- outDir: string;
35
- };
36
- declare class TileflowValidationError extends Error {
37
- readonly messages: ValidationMessage[];
38
- constructor(messages: ValidationMessage[]);
39
- }
40
- declare function loadTileflowConfig(configPath?: string, options?: LoadTileflowConfigOptions): Promise<TileflowProjectConfig>;
41
- declare function loadValidTileflowConfig(configPath?: string, options?: LoadTileflowConfigOptions): Promise<TileflowProjectConfig>;
42
- declare function assertValidTileflowConfig(project: TileflowProjectConfig): void;
43
- declare function asTileflowProjectConfig(input: unknown): TileflowProjectConfig;
44
- declare function getTileflowMapNames(project: TileflowProjectConfig): string[];
45
- declare function getFirstTileflowMapName(project: TileflowProjectConfig): string;
46
- declare function getTileflowStyleMapName(path: string): string;
47
- declare function createTileflowManifest(project: TileflowProjectConfig, options?: TileflowManifestOptions): TileflowManifest;
48
- declare function createTileflowStyle(project: TileflowProjectConfig, mapName: string, options?: TileflowStyleOptions): MapLibreStyle;
49
- declare function createTileflowBuildArtifacts(options?: TileflowBuildArtifactsOptions): Promise<TileflowBuildArtifacts>;
50
- declare function writeTileflowBuildArtifacts(options: WriteTileflowBuildArtifactsOptions): Promise<TileflowBuildArtifacts>;
51
- declare function createTileflowDevRequestHandler(options?: TileflowDevRequestHandlerOptions): (request: Request) => Promise<Response>;
52
- declare function normalizeTileflowBasePath(value?: string): string;
53
-
54
- export { type LoadTileflowConfigOptions, type TileflowBuildArtifacts, type TileflowBuildArtifactsOptions, type TileflowDevRequestHandlerOptions, type TileflowManifestOptions, TileflowValidationError, type WriteTileflowBuildArtifactsOptions, asTileflowProjectConfig, assertValidTileflowConfig, createTileflowBuildArtifacts, createTileflowDevRequestHandler, createTileflowManifest, createTileflowStyle, defaultTileflowApiUrl, defaultTileflowConfigPath, defaultTileflowManifestPath, defaultTileflowTileset, getFirstTileflowMapName, getTileflowMapNames, getTileflowStyleMapName, loadTileflowConfig, loadValidTileflowConfig, normalizeTileflowBasePath, writeTileflowBuildArtifacts };
package/dist/index.js DELETED
@@ -1,314 +0,0 @@
1
- // src/index.ts
2
- import {
3
- createManifest,
4
- createStyleFromProject,
5
- validateConfig
6
- } from "@tileflow/core";
7
- import { existsSync } from "fs";
8
- import { mkdir, writeFile } from "fs/promises";
9
- import { resolve } from "path";
10
- import { createJiti } from "jiti";
11
- var defaultTileflowApiUrl = "https://api.tileflow.dev";
12
- var defaultTileflowConfigPath = "tileflow.config.ts";
13
- var defaultTileflowManifestPath = "public/tileflow/manifest.json";
14
- var defaultTileflowTileset = "world";
15
- var TileflowValidationError = class extends Error {
16
- messages;
17
- constructor(messages) {
18
- super("Invalid Tileflow config");
19
- this.name = "TileflowValidationError";
20
- this.messages = messages;
21
- }
22
- };
23
- async function loadTileflowConfig(configPath = defaultTileflowConfigPath, options = {}) {
24
- const cwd = options.cwd ?? process.cwd();
25
- const resolvedPath = resolve(cwd, configPath);
26
- if (!existsSync(resolvedPath)) {
27
- throw new Error(`Config not found: ${configPath}`);
28
- }
29
- const jiti = createJiti(import.meta.url, {
30
- fsCache: false,
31
- moduleCache: !options.fresh
32
- });
33
- const imported = await jiti.import(resolvedPath, { default: true });
34
- return asTileflowProjectConfig(imported);
35
- }
36
- async function loadValidTileflowConfig(configPath = defaultTileflowConfigPath, options = {}) {
37
- const project = await loadTileflowConfig(configPath, options);
38
- assertValidTileflowConfig(project);
39
- return project;
40
- }
41
- function assertValidTileflowConfig(project) {
42
- const result = validateConfig(project);
43
- if (!result.valid) {
44
- throw new TileflowValidationError(result.messages);
45
- }
46
- }
47
- function asTileflowProjectConfig(input) {
48
- if (input && typeof input === "object" && "maps" in input && typeof input.maps === "object") {
49
- return input;
50
- }
51
- return {
52
- tilesets: {
53
- [defaultTileflowTileset]: {
54
- id: defaultTileflowTileset,
55
- name: "World"
56
- }
57
- },
58
- maps: {
59
- main: input
60
- }
61
- };
62
- }
63
- function getTileflowMapNames(project) {
64
- return Object.keys(project.maps);
65
- }
66
- function getFirstTileflowMapName(project) {
67
- const [mapName] = getTileflowMapNames(project);
68
- if (!mapName) {
69
- throw new Error("Tileflow config must define at least one map.");
70
- }
71
- return mapName;
72
- }
73
- function getTileflowStyleMapName(path) {
74
- const fileName = path.split("/").pop() ?? "";
75
- return fileName.replace(/\.json$/, "");
76
- }
77
- function createTileflowManifest(project, options = {}) {
78
- return createManifest(project, options);
79
- }
80
- function createTileflowStyle(project, mapName, options = {}) {
81
- return createStyleFromProject(project, mapName, options);
82
- }
83
- async function createTileflowBuildArtifacts(options = {}) {
84
- const project = await loadValidTileflowConfig(
85
- options.config ?? defaultTileflowConfigPath,
86
- {
87
- cwd: options.cwd,
88
- fresh: true
89
- }
90
- );
91
- const styleOptions = { tileBaseUrl: options.tileBaseUrl };
92
- const styles = Object.fromEntries(
93
- getTileflowMapNames(project).map((mapName) => [
94
- mapName,
95
- createStyleFromProject(project, mapName, styleOptions)
96
- ])
97
- );
98
- return {
99
- manifest: createManifest(project, {
100
- styleBaseUrl: options.styleBaseUrl,
101
- tileBaseUrl: options.tileBaseUrl
102
- }),
103
- styles
104
- };
105
- }
106
- async function writeTileflowBuildArtifacts(options) {
107
- const cwd = options.cwd ?? process.cwd();
108
- const outDir = resolve(cwd, options.outDir);
109
- const stylesDir = resolve(outDir, "styles");
110
- const artifacts = await createTileflowBuildArtifacts(options);
111
- await mkdir(stylesDir, { recursive: true });
112
- for (const [mapName, style] of Object.entries(artifacts.styles)) {
113
- await writeFile(
114
- resolve(stylesDir, `${mapName}.json`),
115
- `${JSON.stringify(style, null, 2)}
116
- `,
117
- "utf8"
118
- );
119
- }
120
- await writeFile(
121
- resolve(outDir, "manifest.json"),
122
- `${JSON.stringify(artifacts.manifest, null, 2)}
123
- `,
124
- "utf8"
125
- );
126
- return artifacts;
127
- }
128
- function createTileflowDevRequestHandler(options = {}) {
129
- const basePath = normalizeTileflowBasePath(options.basePath);
130
- const configPath = options.config ?? defaultTileflowConfigPath;
131
- const cwd = options.cwd ?? process.cwd();
132
- const tileBaseUrl = options.tileBaseUrl ?? defaultTileflowApiUrl;
133
- return async function handleTileflowDevRequest(request) {
134
- if (request.method !== "GET" && request.method !== "HEAD") {
135
- return jsonResponse({ error: "Method not allowed" }, 405);
136
- }
137
- const url = new URL(request.url);
138
- const path = stripTileflowBasePath(url.pathname, basePath);
139
- if (path === null) {
140
- return jsonResponse({ error: "Not found" }, 404);
141
- }
142
- try {
143
- if (path === "/" || path === "") {
144
- const project = await loadValidTileflowConfig(configPath, {
145
- cwd,
146
- fresh: true
147
- });
148
- return htmlResponse(
149
- previewHtml(getFirstTileflowMapName(project), basePath)
150
- );
151
- }
152
- if (path === "/manifest.json") {
153
- const project = await loadValidTileflowConfig(configPath, {
154
- cwd,
155
- fresh: true
156
- });
157
- const styleBaseUrl = options.styleBaseUrl ?? `${url.origin}${basePath}`;
158
- return jsonResponse(
159
- createManifest(project, {
160
- styleBaseUrl,
161
- tileBaseUrl
162
- })
163
- );
164
- }
165
- if (path === "/style.json") {
166
- const project = await loadValidTileflowConfig(configPath, {
167
- cwd,
168
- fresh: true
169
- });
170
- return jsonResponse(
171
- createStyleFromProject(project, getFirstTileflowMapName(project), {
172
- tileBaseUrl
173
- })
174
- );
175
- }
176
- if (path.startsWith("/styles/")) {
177
- const project = await loadValidTileflowConfig(configPath, {
178
- cwd,
179
- fresh: true
180
- });
181
- const mapName = getTileflowStyleMapName(path);
182
- if (!project.maps[mapName]) {
183
- return jsonResponse({ error: `Unknown map: ${mapName}` }, 404);
184
- }
185
- return jsonResponse(
186
- createStyleFromProject(project, mapName, {
187
- tileBaseUrl
188
- })
189
- );
190
- }
191
- return jsonResponse({ error: "Not found" }, 404);
192
- } catch (error) {
193
- options.onError?.(error);
194
- return tileflowErrorResponse(error);
195
- }
196
- };
197
- }
198
- function normalizeTileflowBasePath(value = "") {
199
- const trimmed = value.trim().replace(/^\/+|\/+$/g, "");
200
- return trimmed ? `/${trimmed}` : "";
201
- }
202
- function stripTileflowBasePath(pathname, basePath) {
203
- if (!basePath) {
204
- return pathname;
205
- }
206
- if (pathname === basePath) {
207
- return "/";
208
- }
209
- if (pathname.startsWith(`${basePath}/`)) {
210
- return pathname.slice(basePath.length);
211
- }
212
- return null;
213
- }
214
- function tileflowErrorResponse(error) {
215
- if (error instanceof TileflowValidationError) {
216
- return jsonResponse(
217
- {
218
- error: error.message,
219
- messages: error.messages
220
- },
221
- 400
222
- );
223
- }
224
- const message = error instanceof Error ? error.message : "Unknown error";
225
- return jsonResponse({ error: message }, 500);
226
- }
227
- function jsonResponse(body, status = 200) {
228
- return new Response(`${JSON.stringify(body, null, 2)}
229
- `, {
230
- headers: {
231
- "Access-Control-Allow-Origin": "*",
232
- "Cache-Control": "no-store",
233
- "Content-Type": "application/json; charset=utf-8"
234
- },
235
- status
236
- });
237
- }
238
- function htmlResponse(body, status = 200) {
239
- return new Response(body, {
240
- headers: {
241
- "Access-Control-Allow-Origin": "*",
242
- "Cache-Control": "no-store",
243
- "Content-Type": "text/html; charset=utf-8"
244
- },
245
- status
246
- });
247
- }
248
- function previewHtml(mapName, basePath) {
249
- const styleUrl = `${basePath}/styles/${mapName}.json`;
250
- return `<!doctype html>
251
- <html lang="en">
252
- <head>
253
- <meta charset="utf-8" />
254
- <meta name="viewport" content="width=device-width, initial-scale=1" />
255
- <title>Tileflow Preview</title>
256
- <link rel="preconnect" href="https://fonts.googleapis.com" />
257
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
258
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet" />
259
- <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css" />
260
- <style>
261
- html, body, #map { height: 100%; margin: 0; }
262
- body { font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
263
- .badge {
264
- position: fixed;
265
- left: 16px;
266
- top: 16px;
267
- z-index: 1;
268
- border-radius: 8px;
269
- background: rgba(246, 247, 243, 0.92);
270
- border: 1px solid rgba(60, 64, 67, 0.12);
271
- color: #3C4043;
272
- padding: 10px 12px;
273
- box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
274
- }
275
- </style>
276
- </head>
277
- <body>
278
- <div class="badge">Tileflow preview</div>
279
- <div id="map"></div>
280
- <script type="module">
281
- import maplibregl from "https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.js";
282
-
283
- const map = new maplibregl.Map({
284
- container: "map",
285
- style: "${styleUrl}",
286
- center: [-3.7038, 40.4168],
287
- zoom: 12
288
- });
289
-
290
- map.addControl(new maplibregl.NavigationControl(), "top-right");
291
- </script>
292
- </body>
293
- </html>`;
294
- }
295
- export {
296
- TileflowValidationError,
297
- asTileflowProjectConfig,
298
- assertValidTileflowConfig,
299
- createTileflowBuildArtifacts,
300
- createTileflowDevRequestHandler,
301
- createTileflowManifest,
302
- createTileflowStyle,
303
- defaultTileflowApiUrl,
304
- defaultTileflowConfigPath,
305
- defaultTileflowManifestPath,
306
- defaultTileflowTileset,
307
- getFirstTileflowMapName,
308
- getTileflowMapNames,
309
- getTileflowStyleMapName,
310
- loadTileflowConfig,
311
- loadValidTileflowConfig,
312
- normalizeTileflowBasePath,
313
- writeTileflowBuildArtifacts
314
- };