@valbuild/tanstack 0.146.4 → 0.147.0
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/CHANGELOG.md +48 -0
- package/client/dist/valbuild-tanstack-client.cjs.dev.js +6 -6
- package/client/dist/valbuild-tanstack-client.cjs.prod.js +6 -6
- package/client/dist/valbuild-tanstack-client.esm.js +4 -4
- package/demo/dist/valbuild-tanstack-demo.cjs.d.ts +2 -0
- package/demo/dist/valbuild-tanstack-demo.cjs.dev.js +105 -0
- package/demo/dist/valbuild-tanstack-demo.cjs.js +7 -0
- package/demo/dist/valbuild-tanstack-demo.cjs.prod.js +105 -0
- package/demo/dist/valbuild-tanstack-demo.esm.js +101 -0
- package/demo/package.json +4 -0
- package/dist/{ValOverlayContext-3f080cce.cjs.dev.js → ValOverlayContext-510328ec.cjs.dev.js} +17 -17
- package/dist/{ValOverlayContext-59a0b19f.esm.js → ValOverlayContext-6278320b.esm.js} +1 -1
- package/dist/{ValOverlayContext-3e2c48a6.cjs.prod.js → ValOverlayContext-d3acd157.cjs.prod.js} +17 -17
- package/dist/{version-4da65f4f.esm.js → asyncToGenerator-500f022f.esm.js} +1 -149
- package/dist/{version-2cbea560.cjs.prod.js → asyncToGenerator-8e5c36c8.cjs.prod.js} +0 -151
- package/dist/{version-1f65da50.cjs.dev.js → asyncToGenerator-c3823d62.cjs.dev.js} +0 -151
- package/dist/declarations/src/ValApp.d.ts +15 -1
- package/dist/declarations/src/ValProvider.d.ts +1 -0
- package/dist/declarations/src/demo/index.d.ts +7 -0
- package/dist/declarations/src/demo/initValDemoServer.d.ts +27 -0
- package/dist/demoServiceWorker-382e1b63.cjs.dev.js +60 -0
- package/dist/demoServiceWorker-56fd96cf.esm.js +55 -0
- package/dist/demoServiceWorker-994710f7.cjs.prod.js +60 -0
- package/dist/{routeFromVal-385ee69c.cjs.dev.js → routeFromVal-0ea4586f.cjs.dev.js} +17 -24
- package/dist/{routeFromVal-ffa948ef.cjs.prod.js → routeFromVal-97a52f43.cjs.prod.js} +17 -24
- package/dist/{routeFromVal-ae54a17e.esm.js → routeFromVal-9f1f8725.esm.js} +7 -13
- package/dist/{createForOfIteratorHelper-93a62170.esm.js → typeof-66e2d869.esm.js} +11 -1
- package/dist/{createForOfIteratorHelper-9afd7d2d.cjs.prod.js → typeof-8998e126.cjs.prod.js} +11 -0
- package/dist/{createForOfIteratorHelper-4497beef.cjs.dev.js → typeof-dd0246a1.cjs.dev.js} +11 -0
- package/dist/valbuild-tanstack.cjs.dev.js +371 -42
- package/dist/valbuild-tanstack.cjs.prod.js +371 -42
- package/dist/valbuild-tanstack.esm.js +337 -8
- package/dist/version-1ae7092b.esm.js +174 -0
- package/dist/version-83d7f4b7.cjs.prod.js +179 -0
- package/dist/version-a820698f.cjs.dev.js +179 -0
- package/package.json +16 -10
- package/server/dist/valbuild-tanstack-server.cjs.dev.js +60 -75
- package/server/dist/valbuild-tanstack-server.cjs.prod.js +60 -75
- package/server/dist/valbuild-tanstack-server.esm.js +4 -19
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where the demo's service worker is served, under the API route.
|
|
5
|
+
*
|
|
6
|
+
* `Service-Worker-Allowed: /` on the response is what lets a script at this
|
|
7
|
+
* path control the whole origin: the Studio at `/val` AND the site's pages in
|
|
8
|
+
* its canvas, whose `<img>` and `<video>` ask for the files this relays.
|
|
9
|
+
*/
|
|
10
|
+
var DEMO_SERVICE_WORKER_PATH = "/demo-sw.js";
|
|
11
|
+
|
|
12
|
+
/** The message the worker sends a Studio tab, and what the tab answers. */
|
|
13
|
+
var DEMO_RELAY_MESSAGE = "val-demo-request";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* What a page sends the worker to be taken under its control now.
|
|
17
|
+
*
|
|
18
|
+
* `clients.claim()` runs when the worker activates, which is once. A page
|
|
19
|
+
* loaded after that with a hard reload (Shift+Reload) is deliberately NOT
|
|
20
|
+
* controlled by an active worker, and nothing would claim it -- so the page
|
|
21
|
+
* asks.
|
|
22
|
+
*/
|
|
23
|
+
var DEMO_CLAIM_MESSAGE = "val-demo-claim";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The demo's service worker, as the source it is served as.
|
|
27
|
+
*
|
|
28
|
+
* In a demo, Val's server runs in the Studio's tab (`@valbuild/server/browser`)
|
|
29
|
+
* and the Studio's client talks to it directly. Two kinds of request cannot go
|
|
30
|
+
* that way, because the browser makes them itself rather than the client:
|
|
31
|
+
*
|
|
32
|
+
* - an upload, which is an `XMLHttpRequest` to `/api/val/upload/...`
|
|
33
|
+
* (`createValSystem`, for its progress events);
|
|
34
|
+
* - an unpublished file, which is an `<img>` or `<video>` pointing at
|
|
35
|
+
* `/api/val/files/...?patch_id=...` -- in the Studio and in the site's pages
|
|
36
|
+
* in the canvas.
|
|
37
|
+
*
|
|
38
|
+
* This worker catches exactly those two prefixes and hands each request to a
|
|
39
|
+
* Studio tab over `postMessage`, where the same in-tab server answers it. So
|
|
40
|
+
* nothing leaves the browser, and the routes that answer are the real ones --
|
|
41
|
+
* the upload, the `Range` request a video seeks with, the draft HLS playlist
|
|
42
|
+
* rewrite.
|
|
43
|
+
*
|
|
44
|
+
* WHICH tab: a demo's edits are in one tab's memory, and two demo tabs are two
|
|
45
|
+
* demos. A request from a Studio page goes to that page. A request from
|
|
46
|
+
* anywhere else -- the site in a canvas frame -- goes to each Studio tab in
|
|
47
|
+
* turn, and the first that does not answer 404 has it: patch ids are unique,
|
|
48
|
+
* so only the tab that made a file can serve it.
|
|
49
|
+
*
|
|
50
|
+
* Plain source rather than compiled code, because it is served as a file of
|
|
51
|
+
* its own and must not depend on anything a bundler would have provided. Kept
|
|
52
|
+
* small for the same reason; `demoServiceWorker.test.ts` parses it and drives
|
|
53
|
+
* its fetch handler.
|
|
54
|
+
*/
|
|
55
|
+
var DEMO_SERVICE_WORKER_SOURCE = "\n\"use strict\";\nconst RELAYED = [\"/api/val/upload/\", \"/api/val/files/\"];\nconst TIMEOUT_MS = 60000;\n\nself.addEventListener(\"install\", () => self.skipWaiting());\nself.addEventListener(\"activate\", (event) => {\n event.waitUntil(self.clients.claim());\n});\n\nself.addEventListener(\"message\", (event) => {\n if (event.data && event.data.type === \"".concat(DEMO_CLAIM_MESSAGE, "\") {\n event.waitUntil(self.clients.claim());\n }\n});\n\nself.addEventListener(\"fetch\", (event) => {\n const url = new URL(event.request.url);\n if (url.origin !== self.location.origin) return;\n if (!RELAYED.some((prefix) => url.pathname.startsWith(prefix))) return;\n event.respondWith(relay(event.request, event.clientId));\n});\n\nfunction isStudio(client) {\n const path = new URL(client.url).pathname;\n return path === \"/val\" || path.startsWith(\"/val/\");\n}\n\nasync function studiosFor(clientId) {\n const own = clientId ? await self.clients.get(clientId) : undefined;\n if (own && isStudio(own)) return [own];\n const all = await self.clients.matchAll({ type: \"window\" });\n return all.filter(isStudio);\n}\n\nfunction ask(client, message, transfer) {\n return new Promise((resolve) => {\n const channel = new MessageChannel();\n const timer = setTimeout(() => {\n channel.port1.close();\n resolve(null);\n }, TIMEOUT_MS);\n channel.port1.onmessage = (event) => {\n clearTimeout(timer);\n channel.port1.close();\n resolve(event.data);\n };\n client.postMessage(message, [channel.port2, ...transfer]);\n });\n}\n\nfunction unavailable(status, message) {\n return new Response(JSON.stringify({ message }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n\nasync function relay(request, clientId) {\n const studios = await studiosFor(clientId);\n if (studios.length === 0) {\n return unavailable(\n 503,\n \"The demo's files live in the Studio's tab, and it is not open.\",\n );\n }\n const hasBody = request.method !== \"GET\" && request.method !== \"HEAD\";\n const body = hasBody ? await request.arrayBuffer() : null;\n let last = null;\n for (const studio of studios) {\n // A body can be transferred once, and transferring it detaches it, so\n // every tab is given a copy and the original is never sent.\n const copy = body ? body.slice(0) : null;\n const answer = await ask(\n studio,\n {\n type: \"").concat(DEMO_RELAY_MESSAGE, "\",\n url: request.url,\n method: request.method,\n headers: [...request.headers],\n body: copy,\n },\n copy ? [copy] : [],\n );\n if (answer === null) continue;\n last = answer;\n if (answer.status !== 404) break;\n }\n if (last === null) {\n return unavailable(504, \"The Studio's tab did not answer in time.\");\n }\n return new Response(last.body, { status: last.status, headers: last.headers });\n}\n");
|
|
56
|
+
|
|
57
|
+
exports.DEMO_CLAIM_MESSAGE = DEMO_CLAIM_MESSAGE;
|
|
58
|
+
exports.DEMO_RELAY_MESSAGE = DEMO_RELAY_MESSAGE;
|
|
59
|
+
exports.DEMO_SERVICE_WORKER_PATH = DEMO_SERVICE_WORKER_PATH;
|
|
60
|
+
exports.DEMO_SERVICE_WORKER_SOURCE = DEMO_SERVICE_WORKER_SOURCE;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the demo's service worker is served, under the API route.
|
|
3
|
+
*
|
|
4
|
+
* `Service-Worker-Allowed: /` on the response is what lets a script at this
|
|
5
|
+
* path control the whole origin: the Studio at `/val` AND the site's pages in
|
|
6
|
+
* its canvas, whose `<img>` and `<video>` ask for the files this relays.
|
|
7
|
+
*/
|
|
8
|
+
var DEMO_SERVICE_WORKER_PATH = "/demo-sw.js";
|
|
9
|
+
|
|
10
|
+
/** The message the worker sends a Studio tab, and what the tab answers. */
|
|
11
|
+
var DEMO_RELAY_MESSAGE = "val-demo-request";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* What a page sends the worker to be taken under its control now.
|
|
15
|
+
*
|
|
16
|
+
* `clients.claim()` runs when the worker activates, which is once. A page
|
|
17
|
+
* loaded after that with a hard reload (Shift+Reload) is deliberately NOT
|
|
18
|
+
* controlled by an active worker, and nothing would claim it -- so the page
|
|
19
|
+
* asks.
|
|
20
|
+
*/
|
|
21
|
+
var DEMO_CLAIM_MESSAGE = "val-demo-claim";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The demo's service worker, as the source it is served as.
|
|
25
|
+
*
|
|
26
|
+
* In a demo, Val's server runs in the Studio's tab (`@valbuild/server/browser`)
|
|
27
|
+
* and the Studio's client talks to it directly. Two kinds of request cannot go
|
|
28
|
+
* that way, because the browser makes them itself rather than the client:
|
|
29
|
+
*
|
|
30
|
+
* - an upload, which is an `XMLHttpRequest` to `/api/val/upload/...`
|
|
31
|
+
* (`createValSystem`, for its progress events);
|
|
32
|
+
* - an unpublished file, which is an `<img>` or `<video>` pointing at
|
|
33
|
+
* `/api/val/files/...?patch_id=...` -- in the Studio and in the site's pages
|
|
34
|
+
* in the canvas.
|
|
35
|
+
*
|
|
36
|
+
* This worker catches exactly those two prefixes and hands each request to a
|
|
37
|
+
* Studio tab over `postMessage`, where the same in-tab server answers it. So
|
|
38
|
+
* nothing leaves the browser, and the routes that answer are the real ones --
|
|
39
|
+
* the upload, the `Range` request a video seeks with, the draft HLS playlist
|
|
40
|
+
* rewrite.
|
|
41
|
+
*
|
|
42
|
+
* WHICH tab: a demo's edits are in one tab's memory, and two demo tabs are two
|
|
43
|
+
* demos. A request from a Studio page goes to that page. A request from
|
|
44
|
+
* anywhere else -- the site in a canvas frame -- goes to each Studio tab in
|
|
45
|
+
* turn, and the first that does not answer 404 has it: patch ids are unique,
|
|
46
|
+
* so only the tab that made a file can serve it.
|
|
47
|
+
*
|
|
48
|
+
* Plain source rather than compiled code, because it is served as a file of
|
|
49
|
+
* its own and must not depend on anything a bundler would have provided. Kept
|
|
50
|
+
* small for the same reason; `demoServiceWorker.test.ts` parses it and drives
|
|
51
|
+
* its fetch handler.
|
|
52
|
+
*/
|
|
53
|
+
var DEMO_SERVICE_WORKER_SOURCE = "\n\"use strict\";\nconst RELAYED = [\"/api/val/upload/\", \"/api/val/files/\"];\nconst TIMEOUT_MS = 60000;\n\nself.addEventListener(\"install\", () => self.skipWaiting());\nself.addEventListener(\"activate\", (event) => {\n event.waitUntil(self.clients.claim());\n});\n\nself.addEventListener(\"message\", (event) => {\n if (event.data && event.data.type === \"".concat(DEMO_CLAIM_MESSAGE, "\") {\n event.waitUntil(self.clients.claim());\n }\n});\n\nself.addEventListener(\"fetch\", (event) => {\n const url = new URL(event.request.url);\n if (url.origin !== self.location.origin) return;\n if (!RELAYED.some((prefix) => url.pathname.startsWith(prefix))) return;\n event.respondWith(relay(event.request, event.clientId));\n});\n\nfunction isStudio(client) {\n const path = new URL(client.url).pathname;\n return path === \"/val\" || path.startsWith(\"/val/\");\n}\n\nasync function studiosFor(clientId) {\n const own = clientId ? await self.clients.get(clientId) : undefined;\n if (own && isStudio(own)) return [own];\n const all = await self.clients.matchAll({ type: \"window\" });\n return all.filter(isStudio);\n}\n\nfunction ask(client, message, transfer) {\n return new Promise((resolve) => {\n const channel = new MessageChannel();\n const timer = setTimeout(() => {\n channel.port1.close();\n resolve(null);\n }, TIMEOUT_MS);\n channel.port1.onmessage = (event) => {\n clearTimeout(timer);\n channel.port1.close();\n resolve(event.data);\n };\n client.postMessage(message, [channel.port2, ...transfer]);\n });\n}\n\nfunction unavailable(status, message) {\n return new Response(JSON.stringify({ message }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n\nasync function relay(request, clientId) {\n const studios = await studiosFor(clientId);\n if (studios.length === 0) {\n return unavailable(\n 503,\n \"The demo's files live in the Studio's tab, and it is not open.\",\n );\n }\n const hasBody = request.method !== \"GET\" && request.method !== \"HEAD\";\n const body = hasBody ? await request.arrayBuffer() : null;\n let last = null;\n for (const studio of studios) {\n // A body can be transferred once, and transferring it detaches it, so\n // every tab is given a copy and the original is never sent.\n const copy = body ? body.slice(0) : null;\n const answer = await ask(\n studio,\n {\n type: \"").concat(DEMO_RELAY_MESSAGE, "\",\n url: request.url,\n method: request.method,\n headers: [...request.headers],\n body: copy,\n },\n copy ? [copy] : [],\n );\n if (answer === null) continue;\n last = answer;\n if (answer.status !== 404) break;\n }\n if (last === null) {\n return unavailable(504, \"The Studio's tab did not answer in time.\");\n }\n return new Response(last.body, { status: last.status, headers: last.headers });\n}\n");
|
|
54
|
+
|
|
55
|
+
export { DEMO_CLAIM_MESSAGE as D, DEMO_SERVICE_WORKER_PATH as a, DEMO_RELAY_MESSAGE as b, DEMO_SERVICE_WORKER_SOURCE as c };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where the demo's service worker is served, under the API route.
|
|
5
|
+
*
|
|
6
|
+
* `Service-Worker-Allowed: /` on the response is what lets a script at this
|
|
7
|
+
* path control the whole origin: the Studio at `/val` AND the site's pages in
|
|
8
|
+
* its canvas, whose `<img>` and `<video>` ask for the files this relays.
|
|
9
|
+
*/
|
|
10
|
+
var DEMO_SERVICE_WORKER_PATH = "/demo-sw.js";
|
|
11
|
+
|
|
12
|
+
/** The message the worker sends a Studio tab, and what the tab answers. */
|
|
13
|
+
var DEMO_RELAY_MESSAGE = "val-demo-request";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* What a page sends the worker to be taken under its control now.
|
|
17
|
+
*
|
|
18
|
+
* `clients.claim()` runs when the worker activates, which is once. A page
|
|
19
|
+
* loaded after that with a hard reload (Shift+Reload) is deliberately NOT
|
|
20
|
+
* controlled by an active worker, and nothing would claim it -- so the page
|
|
21
|
+
* asks.
|
|
22
|
+
*/
|
|
23
|
+
var DEMO_CLAIM_MESSAGE = "val-demo-claim";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The demo's service worker, as the source it is served as.
|
|
27
|
+
*
|
|
28
|
+
* In a demo, Val's server runs in the Studio's tab (`@valbuild/server/browser`)
|
|
29
|
+
* and the Studio's client talks to it directly. Two kinds of request cannot go
|
|
30
|
+
* that way, because the browser makes them itself rather than the client:
|
|
31
|
+
*
|
|
32
|
+
* - an upload, which is an `XMLHttpRequest` to `/api/val/upload/...`
|
|
33
|
+
* (`createValSystem`, for its progress events);
|
|
34
|
+
* - an unpublished file, which is an `<img>` or `<video>` pointing at
|
|
35
|
+
* `/api/val/files/...?patch_id=...` -- in the Studio and in the site's pages
|
|
36
|
+
* in the canvas.
|
|
37
|
+
*
|
|
38
|
+
* This worker catches exactly those two prefixes and hands each request to a
|
|
39
|
+
* Studio tab over `postMessage`, where the same in-tab server answers it. So
|
|
40
|
+
* nothing leaves the browser, and the routes that answer are the real ones --
|
|
41
|
+
* the upload, the `Range` request a video seeks with, the draft HLS playlist
|
|
42
|
+
* rewrite.
|
|
43
|
+
*
|
|
44
|
+
* WHICH tab: a demo's edits are in one tab's memory, and two demo tabs are two
|
|
45
|
+
* demos. A request from a Studio page goes to that page. A request from
|
|
46
|
+
* anywhere else -- the site in a canvas frame -- goes to each Studio tab in
|
|
47
|
+
* turn, and the first that does not answer 404 has it: patch ids are unique,
|
|
48
|
+
* so only the tab that made a file can serve it.
|
|
49
|
+
*
|
|
50
|
+
* Plain source rather than compiled code, because it is served as a file of
|
|
51
|
+
* its own and must not depend on anything a bundler would have provided. Kept
|
|
52
|
+
* small for the same reason; `demoServiceWorker.test.ts` parses it and drives
|
|
53
|
+
* its fetch handler.
|
|
54
|
+
*/
|
|
55
|
+
var DEMO_SERVICE_WORKER_SOURCE = "\n\"use strict\";\nconst RELAYED = [\"/api/val/upload/\", \"/api/val/files/\"];\nconst TIMEOUT_MS = 60000;\n\nself.addEventListener(\"install\", () => self.skipWaiting());\nself.addEventListener(\"activate\", (event) => {\n event.waitUntil(self.clients.claim());\n});\n\nself.addEventListener(\"message\", (event) => {\n if (event.data && event.data.type === \"".concat(DEMO_CLAIM_MESSAGE, "\") {\n event.waitUntil(self.clients.claim());\n }\n});\n\nself.addEventListener(\"fetch\", (event) => {\n const url = new URL(event.request.url);\n if (url.origin !== self.location.origin) return;\n if (!RELAYED.some((prefix) => url.pathname.startsWith(prefix))) return;\n event.respondWith(relay(event.request, event.clientId));\n});\n\nfunction isStudio(client) {\n const path = new URL(client.url).pathname;\n return path === \"/val\" || path.startsWith(\"/val/\");\n}\n\nasync function studiosFor(clientId) {\n const own = clientId ? await self.clients.get(clientId) : undefined;\n if (own && isStudio(own)) return [own];\n const all = await self.clients.matchAll({ type: \"window\" });\n return all.filter(isStudio);\n}\n\nfunction ask(client, message, transfer) {\n return new Promise((resolve) => {\n const channel = new MessageChannel();\n const timer = setTimeout(() => {\n channel.port1.close();\n resolve(null);\n }, TIMEOUT_MS);\n channel.port1.onmessage = (event) => {\n clearTimeout(timer);\n channel.port1.close();\n resolve(event.data);\n };\n client.postMessage(message, [channel.port2, ...transfer]);\n });\n}\n\nfunction unavailable(status, message) {\n return new Response(JSON.stringify({ message }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n\nasync function relay(request, clientId) {\n const studios = await studiosFor(clientId);\n if (studios.length === 0) {\n return unavailable(\n 503,\n \"The demo's files live in the Studio's tab, and it is not open.\",\n );\n }\n const hasBody = request.method !== \"GET\" && request.method !== \"HEAD\";\n const body = hasBody ? await request.arrayBuffer() : null;\n let last = null;\n for (const studio of studios) {\n // A body can be transferred once, and transferring it detaches it, so\n // every tab is given a copy and the original is never sent.\n const copy = body ? body.slice(0) : null;\n const answer = await ask(\n studio,\n {\n type: \"").concat(DEMO_RELAY_MESSAGE, "\",\n url: request.url,\n method: request.method,\n headers: [...request.headers],\n body: copy,\n },\n copy ? [copy] : [],\n );\n if (answer === null) continue;\n last = answer;\n if (answer.status !== 404) break;\n }\n if (last === null) {\n return unavailable(504, \"The Studio's tab did not answer in time.\");\n }\n return new Response(last.body, { status: last.status, headers: last.headers });\n}\n");
|
|
56
|
+
|
|
57
|
+
exports.DEMO_CLAIM_MESSAGE = DEMO_CLAIM_MESSAGE;
|
|
58
|
+
exports.DEMO_RELAY_MESSAGE = DEMO_RELAY_MESSAGE;
|
|
59
|
+
exports.DEMO_SERVICE_WORKER_PATH = DEMO_SERVICE_WORKER_PATH;
|
|
60
|
+
exports.DEMO_SERVICE_WORKER_SOURCE = DEMO_SERVICE_WORKER_SOURCE;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require('./typeof-dd0246a1.cjs.dev.js');
|
|
4
4
|
var core = require('@valbuild/core');
|
|
5
5
|
var client = require('@valbuild/shared/client');
|
|
6
6
|
|
|
7
|
-
function _typeof(o) {
|
|
8
|
-
"@babel/helpers - typeof";
|
|
9
|
-
|
|
10
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
11
|
-
return typeof o;
|
|
12
|
-
} : function (o) {
|
|
13
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
14
|
-
}, _typeof(o);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
7
|
/**
|
|
18
8
|
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
19
9
|
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
@@ -56,7 +46,7 @@ selector, sourcesOf) {
|
|
|
56
46
|
}
|
|
57
47
|
var sources = sourcesOf(modulePath);
|
|
58
48
|
var isRecord = function isRecord(value) {
|
|
59
|
-
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
49
|
+
return _typeof._typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
60
50
|
};
|
|
61
51
|
var chosen = sources.find(function (source) {
|
|
62
52
|
return source !== undefined;
|
|
@@ -68,7 +58,7 @@ selector, sourcesOf) {
|
|
|
68
58
|
var record = {};
|
|
69
59
|
var load = [];
|
|
70
60
|
var _loop = function _loop() {
|
|
71
|
-
var _Object$entries$_i =
|
|
61
|
+
var _Object$entries$_i = _typeof._slicedToArray(_Object$entries[_i], 2),
|
|
72
62
|
key = _Object$entries$_i[0],
|
|
73
63
|
entry = _Object$entries$_i[1];
|
|
74
64
|
if (!core.Internal.isJson(entry)) {
|
|
@@ -105,9 +95,9 @@ selector, sourcesOf) {
|
|
|
105
95
|
* An entry the bundle has no import for keeps its marker.
|
|
106
96
|
*/
|
|
107
97
|
function fillJsonValuesRecord(record, loaded) {
|
|
108
|
-
var filled =
|
|
98
|
+
var filled = _typeof._objectSpread2({}, record);
|
|
109
99
|
for (var _i2 = 0, _Object$entries2 = Object.entries(loaded); _i2 < _Object$entries2.length; _i2++) {
|
|
110
|
-
var _Object$entries2$_i =
|
|
100
|
+
var _Object$entries2$_i = _typeof._slicedToArray(_Object$entries2[_i2], 2),
|
|
111
101
|
key = _Object$entries2$_i[0],
|
|
112
102
|
content = _Object$entries2$_i[1];
|
|
113
103
|
if (content !== undefined) {
|
|
@@ -126,7 +116,7 @@ function bundledJsonEntryImport(
|
|
|
126
116
|
module, key) {
|
|
127
117
|
var _Internal$getJsonImpo;
|
|
128
118
|
var source = module && core.Internal.getSource(module);
|
|
129
|
-
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
119
|
+
var marker = _typeof._typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
130
120
|
if (!core.Internal.isJson(marker)) {
|
|
131
121
|
return undefined;
|
|
132
122
|
}
|
|
@@ -178,8 +168,8 @@ val) {
|
|
|
178
168
|
if (val === null) {
|
|
179
169
|
return null;
|
|
180
170
|
}
|
|
181
|
-
if (_typeof(val) !== "object") {
|
|
182
|
-
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: expected type object, found ").concat(_typeof(val), " instead)."));
|
|
171
|
+
if (_typeof._typeof(val) !== "object") {
|
|
172
|
+
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: expected type object, found ").concat(_typeof._typeof(val), " instead)."));
|
|
183
173
|
return null;
|
|
184
174
|
}
|
|
185
175
|
if (Array.isArray(val)) {
|
|
@@ -198,12 +188,12 @@ val) {
|
|
|
198
188
|
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: router is not the TanStack Router or External URL Page Router)."));
|
|
199
189
|
return null;
|
|
200
190
|
}
|
|
201
|
-
if (_typeof(resolvedParams) !== "object") {
|
|
191
|
+
if (_typeof._typeof(resolvedParams) !== "object") {
|
|
202
192
|
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: params is not an object)."));
|
|
203
193
|
return null;
|
|
204
194
|
}
|
|
205
195
|
var _Internal$splitModule = core.Internal.splitModuleFilePathAndModulePath(path),
|
|
206
|
-
_Internal$splitModule2 =
|
|
196
|
+
_Internal$splitModule2 = _typeof._slicedToArray(_Internal$splitModule, 1),
|
|
207
197
|
moduleFilePath = _Internal$splitModule2[0];
|
|
208
198
|
/*
|
|
209
199
|
* A route module is named after the route file it sits beside.
|
|
@@ -223,7 +213,7 @@ val) {
|
|
|
223
213
|
var parsedPattern = client.parseRoutePattern(pattern);
|
|
224
214
|
var missingPatterns = [];
|
|
225
215
|
var fullPathParts = [];
|
|
226
|
-
var missingParamKeys = _typeof(resolvedParams) === "object" && resolvedParams !== null && !Array.isArray(resolvedParams) ?
|
|
216
|
+
var missingParamKeys = _typeof._typeof(resolvedParams) === "object" && resolvedParams !== null && !Array.isArray(resolvedParams) ? _typeof._objectSpread2({}, resolvedParams) : {};
|
|
227
217
|
/*
|
|
228
218
|
* TanStack names a splat twice, and only one of the names is Val's.
|
|
229
219
|
*
|
|
@@ -237,7 +227,7 @@ val) {
|
|
|
237
227
|
if ("*" in missingParamKeys && "_splat" in missingParamKeys) {
|
|
238
228
|
delete missingParamKeys["*"];
|
|
239
229
|
}
|
|
240
|
-
var _iterator =
|
|
230
|
+
var _iterator = _typeof._createForOfIteratorHelper(parsedPattern !== null && parsedPattern !== void 0 ? parsedPattern : []),
|
|
241
231
|
_step;
|
|
242
232
|
try {
|
|
243
233
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -247,7 +237,11 @@ val) {
|
|
|
247
237
|
} else if (part.type === "array-param" || part.type === "string-param") {
|
|
248
238
|
var key = part.paramName;
|
|
249
239
|
var value = resolvedParams === null || resolvedParams === void 0 ? void 0 : resolvedParams[key];
|
|
250
|
-
if (
|
|
240
|
+
if (part.type === "string-param" && part.optional && (value === undefined || value === null)) {
|
|
241
|
+
// An optional segment the URL left out (`{-$locale}`): it contributes
|
|
242
|
+
// nothing to the key, so `/about` is the key for `{ locale: undefined }`.
|
|
243
|
+
delete missingParamKeys[key];
|
|
244
|
+
} else if (typeof value !== "string" && !Array.isArray(value)) {
|
|
251
245
|
missingPatterns.push(part);
|
|
252
246
|
} else if (Array.isArray(value)) {
|
|
253
247
|
if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
|
|
@@ -321,7 +315,6 @@ val) {
|
|
|
321
315
|
return actualRoute;
|
|
322
316
|
}
|
|
323
317
|
|
|
324
|
-
exports._typeof = _typeof;
|
|
325
318
|
exports.bundledJsonEntryImport = bundledJsonEntryImport;
|
|
326
319
|
exports.fillJsonValuesRecord = fillJsonValuesRecord;
|
|
327
320
|
exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require('./typeof-8998e126.cjs.prod.js');
|
|
4
4
|
var core = require('@valbuild/core');
|
|
5
5
|
var client = require('@valbuild/shared/client');
|
|
6
6
|
|
|
7
|
-
function _typeof(o) {
|
|
8
|
-
"@babel/helpers - typeof";
|
|
9
|
-
|
|
10
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
11
|
-
return typeof o;
|
|
12
|
-
} : function (o) {
|
|
13
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
14
|
-
}, _typeof(o);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
7
|
/**
|
|
18
8
|
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
19
9
|
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
@@ -56,7 +46,7 @@ selector, sourcesOf) {
|
|
|
56
46
|
}
|
|
57
47
|
var sources = sourcesOf(modulePath);
|
|
58
48
|
var isRecord = function isRecord(value) {
|
|
59
|
-
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
49
|
+
return _typeof._typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
60
50
|
};
|
|
61
51
|
var chosen = sources.find(function (source) {
|
|
62
52
|
return source !== undefined;
|
|
@@ -68,7 +58,7 @@ selector, sourcesOf) {
|
|
|
68
58
|
var record = {};
|
|
69
59
|
var load = [];
|
|
70
60
|
var _loop = function _loop() {
|
|
71
|
-
var _Object$entries$_i =
|
|
61
|
+
var _Object$entries$_i = _typeof._slicedToArray(_Object$entries[_i], 2),
|
|
72
62
|
key = _Object$entries$_i[0],
|
|
73
63
|
entry = _Object$entries$_i[1];
|
|
74
64
|
if (!core.Internal.isJson(entry)) {
|
|
@@ -105,9 +95,9 @@ selector, sourcesOf) {
|
|
|
105
95
|
* An entry the bundle has no import for keeps its marker.
|
|
106
96
|
*/
|
|
107
97
|
function fillJsonValuesRecord(record, loaded) {
|
|
108
|
-
var filled =
|
|
98
|
+
var filled = _typeof._objectSpread2({}, record);
|
|
109
99
|
for (var _i2 = 0, _Object$entries2 = Object.entries(loaded); _i2 < _Object$entries2.length; _i2++) {
|
|
110
|
-
var _Object$entries2$_i =
|
|
100
|
+
var _Object$entries2$_i = _typeof._slicedToArray(_Object$entries2[_i2], 2),
|
|
111
101
|
key = _Object$entries2$_i[0],
|
|
112
102
|
content = _Object$entries2$_i[1];
|
|
113
103
|
if (content !== undefined) {
|
|
@@ -126,7 +116,7 @@ function bundledJsonEntryImport(
|
|
|
126
116
|
module, key) {
|
|
127
117
|
var _Internal$getJsonImpo;
|
|
128
118
|
var source = module && core.Internal.getSource(module);
|
|
129
|
-
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
119
|
+
var marker = _typeof._typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
130
120
|
if (!core.Internal.isJson(marker)) {
|
|
131
121
|
return undefined;
|
|
132
122
|
}
|
|
@@ -178,8 +168,8 @@ val) {
|
|
|
178
168
|
if (val === null) {
|
|
179
169
|
return null;
|
|
180
170
|
}
|
|
181
|
-
if (_typeof(val) !== "object") {
|
|
182
|
-
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: expected type object, found ").concat(_typeof(val), " instead)."));
|
|
171
|
+
if (_typeof._typeof(val) !== "object") {
|
|
172
|
+
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: expected type object, found ").concat(_typeof._typeof(val), " instead)."));
|
|
183
173
|
return null;
|
|
184
174
|
}
|
|
185
175
|
if (Array.isArray(val)) {
|
|
@@ -198,12 +188,12 @@ val) {
|
|
|
198
188
|
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: router is not the TanStack Router or External URL Page Router)."));
|
|
199
189
|
return null;
|
|
200
190
|
}
|
|
201
|
-
if (_typeof(resolvedParams) !== "object") {
|
|
191
|
+
if (_typeof._typeof(resolvedParams) !== "object") {
|
|
202
192
|
console.error("Val: ".concat(methodName, " must be used with a Val Module that is a s.record().router(...) (details: params is not an object)."));
|
|
203
193
|
return null;
|
|
204
194
|
}
|
|
205
195
|
var _Internal$splitModule = core.Internal.splitModuleFilePathAndModulePath(path),
|
|
206
|
-
_Internal$splitModule2 =
|
|
196
|
+
_Internal$splitModule2 = _typeof._slicedToArray(_Internal$splitModule, 1),
|
|
207
197
|
moduleFilePath = _Internal$splitModule2[0];
|
|
208
198
|
/*
|
|
209
199
|
* A route module is named after the route file it sits beside.
|
|
@@ -223,7 +213,7 @@ val) {
|
|
|
223
213
|
var parsedPattern = client.parseRoutePattern(pattern);
|
|
224
214
|
var missingPatterns = [];
|
|
225
215
|
var fullPathParts = [];
|
|
226
|
-
var missingParamKeys = _typeof(resolvedParams) === "object" && resolvedParams !== null && !Array.isArray(resolvedParams) ?
|
|
216
|
+
var missingParamKeys = _typeof._typeof(resolvedParams) === "object" && resolvedParams !== null && !Array.isArray(resolvedParams) ? _typeof._objectSpread2({}, resolvedParams) : {};
|
|
227
217
|
/*
|
|
228
218
|
* TanStack names a splat twice, and only one of the names is Val's.
|
|
229
219
|
*
|
|
@@ -237,7 +227,7 @@ val) {
|
|
|
237
227
|
if ("*" in missingParamKeys && "_splat" in missingParamKeys) {
|
|
238
228
|
delete missingParamKeys["*"];
|
|
239
229
|
}
|
|
240
|
-
var _iterator =
|
|
230
|
+
var _iterator = _typeof._createForOfIteratorHelper(parsedPattern !== null && parsedPattern !== void 0 ? parsedPattern : []),
|
|
241
231
|
_step;
|
|
242
232
|
try {
|
|
243
233
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
@@ -247,7 +237,11 @@ val) {
|
|
|
247
237
|
} else if (part.type === "array-param" || part.type === "string-param") {
|
|
248
238
|
var key = part.paramName;
|
|
249
239
|
var value = resolvedParams === null || resolvedParams === void 0 ? void 0 : resolvedParams[key];
|
|
250
|
-
if (
|
|
240
|
+
if (part.type === "string-param" && part.optional && (value === undefined || value === null)) {
|
|
241
|
+
// An optional segment the URL left out (`{-$locale}`): it contributes
|
|
242
|
+
// nothing to the key, so `/about` is the key for `{ locale: undefined }`.
|
|
243
|
+
delete missingParamKeys[key];
|
|
244
|
+
} else if (typeof value !== "string" && !Array.isArray(value)) {
|
|
251
245
|
missingPatterns.push(part);
|
|
252
246
|
} else if (Array.isArray(value)) {
|
|
253
247
|
if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
|
|
@@ -321,7 +315,6 @@ val) {
|
|
|
321
315
|
return actualRoute;
|
|
322
316
|
}
|
|
323
317
|
|
|
324
|
-
exports._typeof = _typeof;
|
|
325
318
|
exports.bundledJsonEntryImport = bundledJsonEntryImport;
|
|
326
319
|
exports.fillJsonValuesRecord = fillJsonValuesRecord;
|
|
327
320
|
exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper } from './
|
|
1
|
+
import { _ as _objectSpread2, a as _slicedToArray, c as _typeof, b as _createForOfIteratorHelper } from './typeof-66e2d869.esm.js';
|
|
2
2
|
import { RecordSchema, Internal } from '@valbuild/core';
|
|
3
3
|
import { getTanStackRouterSourceFolder, getPatternFromModuleFilePath, parseRoutePattern } from '@valbuild/shared/client';
|
|
4
4
|
|
|
5
|
-
function _typeof(o) {
|
|
6
|
-
"@babel/helpers - typeof";
|
|
7
|
-
|
|
8
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
9
|
-
return typeof o;
|
|
10
|
-
} : function (o) {
|
|
11
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
12
|
-
}, _typeof(o);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
5
|
/**
|
|
16
6
|
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
17
7
|
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
@@ -245,7 +235,11 @@ val) {
|
|
|
245
235
|
} else if (part.type === "array-param" || part.type === "string-param") {
|
|
246
236
|
var key = part.paramName;
|
|
247
237
|
var value = resolvedParams === null || resolvedParams === void 0 ? void 0 : resolvedParams[key];
|
|
248
|
-
if (
|
|
238
|
+
if (part.type === "string-param" && part.optional && (value === undefined || value === null)) {
|
|
239
|
+
// An optional segment the URL left out (`{-$locale}`): it contributes
|
|
240
|
+
// nothing to the key, so `/about` is the key for `{ locale: undefined }`.
|
|
241
|
+
delete missingParamKeys[key];
|
|
242
|
+
} else if (typeof value !== "string" && !Array.isArray(value)) {
|
|
249
243
|
missingPatterns.push(part);
|
|
250
244
|
} else if (Array.isArray(value)) {
|
|
251
245
|
if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
|
|
@@ -319,4 +313,4 @@ val) {
|
|
|
319
313
|
return actualRoute;
|
|
320
314
|
}
|
|
321
315
|
|
|
322
|
-
export {
|
|
316
|
+
export { getValRouteUrlFromVal as a, bundledJsonEntryImport as b, initValRouteFromVal as c, fillJsonValuesRecord as f, getJsonEntryStegaRoot as g, isJsonValuesRecordSchema as i, jsonValuesRecordToFill as j };
|
|
@@ -148,4 +148,14 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
function _typeof(o) {
|
|
152
|
+
"@babel/helpers - typeof";
|
|
153
|
+
|
|
154
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
155
|
+
return typeof o;
|
|
156
|
+
} : function (o) {
|
|
157
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
158
|
+
}, _typeof(o);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { _objectSpread2 as _, _slicedToArray as a, _createForOfIteratorHelper as b, _typeof as c, _arrayLikeToArray as d, _unsupportedIterableToArray as e, _toPropertyKey as f, _defineProperty as g };
|
|
@@ -150,10 +150,21 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function _typeof(o) {
|
|
154
|
+
"@babel/helpers - typeof";
|
|
155
|
+
|
|
156
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
157
|
+
return typeof o;
|
|
158
|
+
} : function (o) {
|
|
159
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
160
|
+
}, _typeof(o);
|
|
161
|
+
}
|
|
162
|
+
|
|
153
163
|
exports._arrayLikeToArray = _arrayLikeToArray;
|
|
154
164
|
exports._createForOfIteratorHelper = _createForOfIteratorHelper;
|
|
155
165
|
exports._defineProperty = _defineProperty;
|
|
156
166
|
exports._objectSpread2 = _objectSpread2;
|
|
157
167
|
exports._slicedToArray = _slicedToArray;
|
|
158
168
|
exports._toPropertyKey = _toPropertyKey;
|
|
169
|
+
exports._typeof = _typeof;
|
|
159
170
|
exports._unsupportedIterableToArray = _unsupportedIterableToArray;
|
|
@@ -150,10 +150,21 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function _typeof(o) {
|
|
154
|
+
"@babel/helpers - typeof";
|
|
155
|
+
|
|
156
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
157
|
+
return typeof o;
|
|
158
|
+
} : function (o) {
|
|
159
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
160
|
+
}, _typeof(o);
|
|
161
|
+
}
|
|
162
|
+
|
|
153
163
|
exports._arrayLikeToArray = _arrayLikeToArray;
|
|
154
164
|
exports._createForOfIteratorHelper = _createForOfIteratorHelper;
|
|
155
165
|
exports._defineProperty = _defineProperty;
|
|
156
166
|
exports._objectSpread2 = _objectSpread2;
|
|
157
167
|
exports._slicedToArray = _slicedToArray;
|
|
158
168
|
exports._toPropertyKey = _toPropertyKey;
|
|
169
|
+
exports._typeof = _typeof;
|
|
159
170
|
exports._unsupportedIterableToArray = _unsupportedIterableToArray;
|