@k-4u/resource-mapper-core 0.0.1
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/.aws-icons-last-updated +1 -0
- package/.svelte-kit/ambient.d.ts +263 -0
- package/.svelte-kit/generated/client/app.js +31 -0
- package/.svelte-kit/generated/client/matchers.js +1 -0
- package/.svelte-kit/generated/client/nodes/0.js +1 -0
- package/.svelte-kit/generated/client/nodes/1.js +1 -0
- package/.svelte-kit/generated/client/nodes/2.js +3 -0
- package/.svelte-kit/generated/client/nodes/3.js +3 -0
- package/.svelte-kit/generated/client-optimized/app.js +31 -0
- package/.svelte-kit/generated/client-optimized/matchers.js +1 -0
- package/.svelte-kit/generated/client-optimized/nodes/0.js +1 -0
- package/.svelte-kit/generated/client-optimized/nodes/1.js +1 -0
- package/.svelte-kit/generated/client-optimized/nodes/2.js +3 -0
- package/.svelte-kit/generated/client-optimized/nodes/3.js +3 -0
- package/.svelte-kit/generated/root.js +3 -0
- package/.svelte-kit/generated/root.svelte +68 -0
- package/.svelte-kit/generated/server/internal.js +53 -0
- package/.svelte-kit/non-ambient.d.ts +43 -0
- package/.svelte-kit/output/client/.vite/manifest.json +175 -0
- package/.svelte-kit/output/client/_app/immutable/assets/0.Czt_67iE.css +1 -0
- package/.svelte-kit/output/client/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css +1 -0
- package/.svelte-kit/output/client/_app/immutable/assets/helpers.ysDrpaDf.css +1 -0
- package/.svelte-kit/output/client/_app/immutable/assets/libavoid.DQJapW5w.wasm +0 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/BlLuv0eP.js +46 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/CSBHmwYv.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/CTCi5ueQ.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/CfOzjaik.js +2 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/D4PdvFNs.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/DXgP-QUS.js +2 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/DlbDC5An.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/chunks/wRWe7aK9.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/entry/app.ConrMuHl.js +2 -0
- package/.svelte-kit/output/client/_app/immutable/entry/start.Bm6FyGme.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/nodes/0.d3cL-ETU.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/nodes/1.D6z9rPGv.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/nodes/2.CLD-8chl.js +1 -0
- package/.svelte-kit/output/client/_app/immutable/nodes/3.DXYeBoel.js +1 -0
- package/.svelte-kit/output/client/_app/version.json +1 -0
- package/.svelte-kit/output/client/libavoid.wasm +0 -0
- package/.svelte-kit/output/client/static/robots.txt +3 -0
- package/.svelte-kit/output/prerendered/dependencies/_app/env.js +1 -0
- package/.svelte-kit/output/server/.vite/manifest.json +224 -0
- package/.svelte-kit/output/server/_app/immutable/assets/LoadingOverlay.DBbe6V8W.css +1 -0
- package/.svelte-kit/output/server/_app/immutable/assets/_layout.Czt_67iE.css +1 -0
- package/.svelte-kit/output/server/_app/immutable/assets/_page.D9P41uDZ.css +1 -0
- package/.svelte-kit/output/server/chunks/ErrorDisplay.js +59 -0
- package/.svelte-kit/output/server/chunks/LoadingOverlay.js +12 -0
- package/.svelte-kit/output/server/chunks/LoadingOverlay.svelte_svelte_type_style_lang.js +1671 -0
- package/.svelte-kit/output/server/chunks/connections.js +33 -0
- package/.svelte-kit/output/server/chunks/diagram.js +7 -0
- package/.svelte-kit/output/server/chunks/environment.js +34 -0
- package/.svelte-kit/output/server/chunks/equality.js +57 -0
- package/.svelte-kit/output/server/chunks/exports.js +174 -0
- package/.svelte-kit/output/server/chunks/false.js +4 -0
- package/.svelte-kit/output/server/chunks/index.js +59 -0
- package/.svelte-kit/output/server/chunks/index2.js +2939 -0
- package/.svelte-kit/output/server/chunks/index3.js +20 -0
- package/.svelte-kit/output/server/chunks/internal.js +1017 -0
- package/.svelte-kit/output/server/chunks/shared.js +770 -0
- package/.svelte-kit/output/server/chunks/utils.js +43 -0
- package/.svelte-kit/output/server/entries/pages/_error.svelte.js +64 -0
- package/.svelte-kit/output/server/entries/pages/_layout.svelte.js +65 -0
- package/.svelte-kit/output/server/entries/pages/_page.svelte.js +3991 -0
- package/.svelte-kit/output/server/entries/pages/_page.ts.js +30 -0
- package/.svelte-kit/output/server/entries/pages/group/_groupId_/_page.svelte.js +67 -0
- package/.svelte-kit/output/server/entries/pages/group/_groupId_/_page.ts.js +47 -0
- package/.svelte-kit/output/server/index.js +3747 -0
- package/.svelte-kit/output/server/internal.js +13 -0
- package/.svelte-kit/output/server/manifest-full.js +47 -0
- package/.svelte-kit/output/server/manifest.js +47 -0
- package/.svelte-kit/output/server/nodes/0.js +8 -0
- package/.svelte-kit/output/server/nodes/1.js +8 -0
- package/.svelte-kit/output/server/nodes/2.js +10 -0
- package/.svelte-kit/output/server/nodes/3.js +10 -0
- package/.svelte-kit/output/server/remote-entry.js +557 -0
- package/.svelte-kit/tsconfig.json +61 -0
- package/.svelte-kit/types/route_meta_data.json +8 -0
- package/.svelte-kit/types/src/routes/$types.d.ts +26 -0
- package/.svelte-kit/types/src/routes/group/[groupId]/$types.d.ts +21 -0
- package/.svelte-kit/types/src/routes/group/[groupId]/proxy+page.ts +49 -0
- package/.svelte-kit/types/src/routes/proxy+page.ts +33 -0
- package/build/_app/env.js +1 -0
- package/build/_app/env.js.br +1 -0
- package/build/_app/env.js.gz +0 -0
- package/build/_app/immutable/assets/0.Czt_67iE.css +1 -0
- package/build/_app/immutable/assets/0.Czt_67iE.css.br +0 -0
- package/build/_app/immutable/assets/0.Czt_67iE.css.gz +0 -0
- package/build/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css +1 -0
- package/build/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css.br +0 -0
- package/build/_app/immutable/assets/TeamContactCard.Dxj5nUCr.css.gz +0 -0
- package/build/_app/immutable/assets/helpers.ysDrpaDf.css +1 -0
- package/build/_app/immutable/assets/helpers.ysDrpaDf.css.br +0 -0
- package/build/_app/immutable/assets/helpers.ysDrpaDf.css.gz +0 -0
- package/build/_app/immutable/assets/libavoid.DQJapW5w.wasm +0 -0
- package/build/_app/immutable/assets/libavoid.DQJapW5w.wasm.br +0 -0
- package/build/_app/immutable/assets/libavoid.DQJapW5w.wasm.gz +0 -0
- package/build/_app/immutable/chunks/BlLuv0eP.js +46 -0
- package/build/_app/immutable/chunks/BlLuv0eP.js.br +0 -0
- package/build/_app/immutable/chunks/BlLuv0eP.js.gz +0 -0
- package/build/_app/immutable/chunks/CSBHmwYv.js +1 -0
- package/build/_app/immutable/chunks/CSBHmwYv.js.br +0 -0
- package/build/_app/immutable/chunks/CSBHmwYv.js.gz +0 -0
- package/build/_app/immutable/chunks/CTCi5ueQ.js +1 -0
- package/build/_app/immutable/chunks/CTCi5ueQ.js.br +0 -0
- package/build/_app/immutable/chunks/CTCi5ueQ.js.gz +0 -0
- package/build/_app/immutable/chunks/CfOzjaik.js +2 -0
- package/build/_app/immutable/chunks/CfOzjaik.js.br +0 -0
- package/build/_app/immutable/chunks/CfOzjaik.js.gz +0 -0
- package/build/_app/immutable/chunks/D4PdvFNs.js +1 -0
- package/build/_app/immutable/chunks/D4PdvFNs.js.br +0 -0
- package/build/_app/immutable/chunks/D4PdvFNs.js.gz +0 -0
- package/build/_app/immutable/chunks/DXgP-QUS.js +2 -0
- package/build/_app/immutable/chunks/DXgP-QUS.js.br +0 -0
- package/build/_app/immutable/chunks/DXgP-QUS.js.gz +0 -0
- package/build/_app/immutable/chunks/DlbDC5An.js +1 -0
- package/build/_app/immutable/chunks/DlbDC5An.js.br +0 -0
- package/build/_app/immutable/chunks/DlbDC5An.js.gz +0 -0
- package/build/_app/immutable/chunks/wRWe7aK9.js +1 -0
- package/build/_app/immutable/chunks/wRWe7aK9.js.br +0 -0
- package/build/_app/immutable/chunks/wRWe7aK9.js.gz +0 -0
- package/build/_app/immutable/entry/app.ConrMuHl.js +2 -0
- package/build/_app/immutable/entry/app.ConrMuHl.js.br +0 -0
- package/build/_app/immutable/entry/app.ConrMuHl.js.gz +0 -0
- package/build/_app/immutable/entry/start.Bm6FyGme.js +1 -0
- package/build/_app/immutable/entry/start.Bm6FyGme.js.br +2 -0
- package/build/_app/immutable/entry/start.Bm6FyGme.js.gz +0 -0
- package/build/_app/immutable/nodes/0.d3cL-ETU.js +1 -0
- package/build/_app/immutable/nodes/0.d3cL-ETU.js.br +0 -0
- package/build/_app/immutable/nodes/0.d3cL-ETU.js.gz +0 -0
- package/build/_app/immutable/nodes/1.D6z9rPGv.js +1 -0
- package/build/_app/immutable/nodes/1.D6z9rPGv.js.br +0 -0
- package/build/_app/immutable/nodes/1.D6z9rPGv.js.gz +0 -0
- package/build/_app/immutable/nodes/2.CLD-8chl.js +1 -0
- package/build/_app/immutable/nodes/2.CLD-8chl.js.br +0 -0
- package/build/_app/immutable/nodes/2.CLD-8chl.js.gz +0 -0
- package/build/_app/immutable/nodes/3.DXYeBoel.js +1 -0
- package/build/_app/immutable/nodes/3.DXYeBoel.js.br +0 -0
- package/build/_app/immutable/nodes/3.DXYeBoel.js.gz +0 -0
- package/build/_app/version.json +1 -0
- package/build/_app/version.json.br +0 -0
- package/build/_app/version.json.gz +0 -0
- package/build/index.html +34 -0
- package/build/index.html.br +0 -0
- package/build/index.html.gz +0 -0
- package/build/libavoid.wasm +0 -0
- package/build/libavoid.wasm.br +0 -0
- package/build/libavoid.wasm.gz +0 -0
- package/build/static/robots.txt +3 -0
- package/coverage/coverage-final.json +6 -0
- package/coverage/coverage-summary.json +7 -0
- package/coverage/junit.xml +57 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/stores/index.html +116 -0
- package/coverage/lcov-report/stores/routingStore.ts.html +781 -0
- package/coverage/lcov-report/utils/flow/helpers.ts.html +127 -0
- package/coverage/lcov-report/utils/flow/index.html +161 -0
- package/coverage/lcov-report/utils/flow/layout.ts.html +805 -0
- package/coverage/lcov-report/utils/flow/serviceIds.ts.html +97 -0
- package/coverage/lcov-report/utils/flow/servicesGraph.ts.html +859 -0
- package/coverage/lcov.info +646 -0
- package/coverage/test-results.json +1 -0
- package/data/services/api/api-gateway.yaml +18 -0
- package/data/services/api/group-info.yaml +7 -0
- package/data/services/api/lambda-orders.yaml +21 -0
- package/data/services/api/lambda-products.yaml +15 -0
- package/data/services/api/lambda-users.yaml +15 -0
- package/data/services/compute/alb.yaml +15 -0
- package/data/services/compute/ecs-inventory.yaml +16 -0
- package/data/services/compute/ecs-notification.yaml +15 -0
- package/data/services/compute/group-info.yaml +7 -0
- package/data/services/data/dynamodb-notifications.yaml +12 -0
- package/data/services/data/dynamodb-orders.yaml +9 -0
- package/data/services/data/dynamodb-products.yaml +9 -0
- package/data/services/data/dynamodb-users.yaml +9 -0
- package/data/services/data/group-info.yaml +7 -0
- package/data/services/data/rds-postgres.yaml +9 -0
- package/data/services/data/redis.yaml +10 -0
- package/data/services/frontend/cloudfront.yaml +12 -0
- package/data/services/frontend/group-info.yaml +7 -0
- package/data/services/frontend/route53.yaml +15 -0
- package/data/services/frontend/s3-website.yaml +9 -0
- package/data/teams/cloud-shepherds.yaml +15 -0
- package/data/teams/data-wizards.yaml +15 -0
- package/data/teams/interface-architects.yaml +19 -0
- package/e2e/demo.test.ts +54 -0
- package/e2e/header-toolbar.simple.spec.ts +0 -0
- package/e2e/header-toolbar.spec.ts +53 -0
- package/e2e/layout.spec.ts +30 -0
- package/package.json +69 -0
- package/playwright.config.ts +10 -0
- package/plugins/mapper-data-plugin.ts +32 -0
- package/project.json +23 -0
- package/src/app.css +125 -0
- package/src/app.d.ts +31 -0
- package/src/app.html +11 -0
- package/src/lib/assets/favicon.svg +19 -0
- package/src/lib/components/EmptyState.svelte +37 -0
- package/src/lib/components/ErrorDisplay.svelte +82 -0
- package/src/lib/components/FlowCanvas.svelte +223 -0
- package/src/lib/components/GenericSidebarCard.svelte +44 -0
- package/src/lib/components/GroupDetailSidebar.svelte +31 -0
- package/src/lib/components/Header.svelte +57 -0
- package/src/lib/components/Legend.svelte +25 -0
- package/src/lib/components/LoadingOverlay.svelte +42 -0
- package/src/lib/components/LoadingSpinner.svelte +10 -0
- package/src/lib/components/ServiceDetailSidebar.svelte +90 -0
- package/src/lib/components/TeamContactCard.svelte +166 -0
- package/src/lib/components/flow/ExternalNode.svelte +45 -0
- package/src/lib/components/flow/MainGroupNode.svelte +24 -0
- package/src/lib/components/flow/ServiceGroupNode.svelte +17 -0
- package/src/lib/components/flow/ServiceNode.svelte +40 -0
- package/src/lib/components/flow/SnakeEdge.svelte +206 -0
- package/src/lib/components/flow/index.ts +6 -0
- package/src/lib/components/index.ts +12 -0
- package/src/lib/data/connections.ts +26 -0
- package/src/lib/data/groups.ts +11 -0
- package/src/lib/data/services.ts +12 -0
- package/src/lib/data/teams.ts +11 -0
- package/src/lib/index.ts +1 -0
- package/src/lib/state/theme.svelte.ts +21 -0
- package/src/lib/stores/diagram.ts +6 -0
- package/src/lib/stores/routingStore.test.ts +133 -0
- package/src/lib/stores/routingStore.ts +232 -0
- package/src/lib/utils/awsIcons.ts +117 -0
- package/src/lib/utils/flow/groupOverviewGraph.ts +73 -0
- package/src/lib/utils/flow/helpers.ts +14 -0
- package/src/lib/utils/flow/layout.test.ts +271 -0
- package/src/lib/utils/flow/layout.ts +240 -0
- package/src/lib/utils/flow/serviceIds.ts +5 -0
- package/src/lib/utils/flow/servicesGraph.test.ts +119 -0
- package/src/lib/utils/flow/servicesGraph.ts +258 -0
- package/src/routes/+error.svelte +36 -0
- package/src/routes/+layout.svelte +27 -0
- package/src/routes/+page.svelte +81 -0
- package/src/routes/+page.ts +31 -0
- package/src/routes/group/[groupId]/+page.svelte +102 -0
- package/src/routes/group/[groupId]/+page.ts +48 -0
- package/src/routes/layout.css +0 -0
- package/static/static/robots.txt +3 -0
- package/svelte.config.js +28 -0
- package/tailwind.config.js +12 -0
- package/tsconfig.json +22 -0
- package/vite.config.ts +81 -0
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
import { json, text } from "@sveltejs/kit";
|
|
2
|
+
import { SvelteKitError, HttpError } from "@sveltejs/kit/internal";
|
|
3
|
+
import { with_request_store } from "@sveltejs/kit/internal/server";
|
|
4
|
+
import * as devalue from "devalue";
|
|
5
|
+
import { t as text_decoder, b as base64_encode, c as base64_decode } from "./utils.js";
|
|
6
|
+
const SVELTE_KIT_ASSETS = "/_svelte_kit_assets";
|
|
7
|
+
const ENDPOINT_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"];
|
|
8
|
+
const PAGE_METHODS = ["GET", "POST", "HEAD"];
|
|
9
|
+
function set_nested_value(object, path_string, value) {
|
|
10
|
+
if (path_string.startsWith("n:")) {
|
|
11
|
+
path_string = path_string.slice(2);
|
|
12
|
+
value = value === "" ? void 0 : parseFloat(value);
|
|
13
|
+
} else if (path_string.startsWith("b:")) {
|
|
14
|
+
path_string = path_string.slice(2);
|
|
15
|
+
value = value === "on";
|
|
16
|
+
}
|
|
17
|
+
deep_set(object, split_path(path_string), value);
|
|
18
|
+
}
|
|
19
|
+
function convert_formdata(data) {
|
|
20
|
+
const result = {};
|
|
21
|
+
for (let key of data.keys()) {
|
|
22
|
+
const is_array = key.endsWith("[]");
|
|
23
|
+
let values = data.getAll(key);
|
|
24
|
+
if (is_array) key = key.slice(0, -2);
|
|
25
|
+
if (values.length > 1 && !is_array) {
|
|
26
|
+
throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`);
|
|
27
|
+
}
|
|
28
|
+
values = values.filter(
|
|
29
|
+
(entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0
|
|
30
|
+
);
|
|
31
|
+
if (key.startsWith("n:")) {
|
|
32
|
+
key = key.slice(2);
|
|
33
|
+
values = values.map((v) => v === "" ? void 0 : parseFloat(
|
|
34
|
+
/** @type {string} */
|
|
35
|
+
v
|
|
36
|
+
));
|
|
37
|
+
} else if (key.startsWith("b:")) {
|
|
38
|
+
key = key.slice(2);
|
|
39
|
+
values = values.map((v) => v === "on");
|
|
40
|
+
}
|
|
41
|
+
set_nested_value(result, key, is_array ? values : values[0]);
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
const BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
|
|
46
|
+
const BINARY_FORM_VERSION = 0;
|
|
47
|
+
const HEADER_BYTES = 1 + 4 + 2;
|
|
48
|
+
async function deserialize_binary_form(request) {
|
|
49
|
+
if (request.headers.get("content-type") !== BINARY_FORM_CONTENT_TYPE) {
|
|
50
|
+
const form_data = await request.formData();
|
|
51
|
+
return { data: convert_formdata(form_data), meta: {}, form_data };
|
|
52
|
+
}
|
|
53
|
+
if (!request.body) {
|
|
54
|
+
throw deserialize_error("no body");
|
|
55
|
+
}
|
|
56
|
+
const content_length = parseInt(request.headers.get("content-length") ?? "");
|
|
57
|
+
if (Number.isNaN(content_length)) {
|
|
58
|
+
throw deserialize_error("invalid Content-Length header");
|
|
59
|
+
}
|
|
60
|
+
const reader = request.body.getReader();
|
|
61
|
+
const chunks = [];
|
|
62
|
+
function get_chunk(index) {
|
|
63
|
+
if (index in chunks) return chunks[index];
|
|
64
|
+
let i = chunks.length;
|
|
65
|
+
while (i <= index) {
|
|
66
|
+
chunks[i] = reader.read().then((chunk) => chunk.value);
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
return chunks[index];
|
|
70
|
+
}
|
|
71
|
+
async function get_buffer(offset, length) {
|
|
72
|
+
let start_chunk;
|
|
73
|
+
let chunk_start = 0;
|
|
74
|
+
let chunk_index;
|
|
75
|
+
for (chunk_index = 0; ; chunk_index++) {
|
|
76
|
+
const chunk = await get_chunk(chunk_index);
|
|
77
|
+
if (!chunk) return null;
|
|
78
|
+
const chunk_end = chunk_start + chunk.byteLength;
|
|
79
|
+
if (offset >= chunk_start && offset < chunk_end) {
|
|
80
|
+
start_chunk = chunk;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
chunk_start = chunk_end;
|
|
84
|
+
}
|
|
85
|
+
if (offset + length <= chunk_start + start_chunk.byteLength) {
|
|
86
|
+
return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start);
|
|
87
|
+
}
|
|
88
|
+
const chunks2 = [start_chunk.subarray(offset - chunk_start)];
|
|
89
|
+
let cursor = start_chunk.byteLength - offset + chunk_start;
|
|
90
|
+
while (cursor < length) {
|
|
91
|
+
chunk_index++;
|
|
92
|
+
let chunk = await get_chunk(chunk_index);
|
|
93
|
+
if (!chunk) return null;
|
|
94
|
+
if (chunk.byteLength > length - cursor) {
|
|
95
|
+
chunk = chunk.subarray(0, length - cursor);
|
|
96
|
+
}
|
|
97
|
+
chunks2.push(chunk);
|
|
98
|
+
cursor += chunk.byteLength;
|
|
99
|
+
}
|
|
100
|
+
const buffer = new Uint8Array(length);
|
|
101
|
+
cursor = 0;
|
|
102
|
+
for (const chunk of chunks2) {
|
|
103
|
+
buffer.set(chunk, cursor);
|
|
104
|
+
cursor += chunk.byteLength;
|
|
105
|
+
}
|
|
106
|
+
return buffer;
|
|
107
|
+
}
|
|
108
|
+
const header = await get_buffer(0, HEADER_BYTES);
|
|
109
|
+
if (!header) throw deserialize_error("too short");
|
|
110
|
+
if (header[0] !== BINARY_FORM_VERSION) {
|
|
111
|
+
throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
|
|
112
|
+
}
|
|
113
|
+
const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
|
|
114
|
+
const data_length = header_view.getUint32(1, true);
|
|
115
|
+
if (HEADER_BYTES + data_length > content_length) {
|
|
116
|
+
throw deserialize_error("data overflow");
|
|
117
|
+
}
|
|
118
|
+
const file_offsets_length = header_view.getUint16(5, true);
|
|
119
|
+
if (HEADER_BYTES + data_length + file_offsets_length > content_length) {
|
|
120
|
+
throw deserialize_error("file offset table overflow");
|
|
121
|
+
}
|
|
122
|
+
const data_buffer = await get_buffer(HEADER_BYTES, data_length);
|
|
123
|
+
if (!data_buffer) throw deserialize_error("data too short");
|
|
124
|
+
let file_offsets;
|
|
125
|
+
let files_start_offset;
|
|
126
|
+
if (file_offsets_length > 0) {
|
|
127
|
+
const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
|
|
128
|
+
if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
|
|
129
|
+
file_offsets = /** @type {Array<number>} */
|
|
130
|
+
JSON.parse(text_decoder.decode(file_offsets_buffer));
|
|
131
|
+
files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
|
|
132
|
+
}
|
|
133
|
+
const [data, meta] = devalue.parse(text_decoder.decode(data_buffer), {
|
|
134
|
+
File: ([name, type, size, last_modified, index]) => {
|
|
135
|
+
if (files_start_offset + file_offsets[index] + size > content_length) {
|
|
136
|
+
throw deserialize_error("file data overflow");
|
|
137
|
+
}
|
|
138
|
+
return new Proxy(
|
|
139
|
+
new LazyFile(
|
|
140
|
+
name,
|
|
141
|
+
type,
|
|
142
|
+
size,
|
|
143
|
+
last_modified,
|
|
144
|
+
get_chunk,
|
|
145
|
+
files_start_offset + file_offsets[index]
|
|
146
|
+
),
|
|
147
|
+
{
|
|
148
|
+
getPrototypeOf() {
|
|
149
|
+
return File.prototype;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
void (async () => {
|
|
156
|
+
let has_more = true;
|
|
157
|
+
while (has_more) {
|
|
158
|
+
const chunk = await get_chunk(chunks.length);
|
|
159
|
+
has_more = !!chunk;
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
return { data, meta, form_data: null };
|
|
163
|
+
}
|
|
164
|
+
function deserialize_error(message) {
|
|
165
|
+
return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
|
|
166
|
+
}
|
|
167
|
+
class LazyFile {
|
|
168
|
+
/** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
|
|
169
|
+
#get_chunk;
|
|
170
|
+
/** @type {number} */
|
|
171
|
+
#offset;
|
|
172
|
+
/**
|
|
173
|
+
* @param {string} name
|
|
174
|
+
* @param {string} type
|
|
175
|
+
* @param {number} size
|
|
176
|
+
* @param {number} last_modified
|
|
177
|
+
* @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
|
|
178
|
+
* @param {number} offset
|
|
179
|
+
*/
|
|
180
|
+
constructor(name, type, size, last_modified, get_chunk, offset) {
|
|
181
|
+
this.name = name;
|
|
182
|
+
this.type = type;
|
|
183
|
+
this.size = size;
|
|
184
|
+
this.lastModified = last_modified;
|
|
185
|
+
this.webkitRelativePath = "";
|
|
186
|
+
this.#get_chunk = get_chunk;
|
|
187
|
+
this.#offset = offset;
|
|
188
|
+
this.arrayBuffer = this.arrayBuffer.bind(this);
|
|
189
|
+
this.bytes = this.bytes.bind(this);
|
|
190
|
+
this.slice = this.slice.bind(this);
|
|
191
|
+
this.stream = this.stream.bind(this);
|
|
192
|
+
this.text = this.text.bind(this);
|
|
193
|
+
}
|
|
194
|
+
/** @type {ArrayBuffer | undefined} */
|
|
195
|
+
#buffer;
|
|
196
|
+
async arrayBuffer() {
|
|
197
|
+
this.#buffer ??= await new Response(this.stream()).arrayBuffer();
|
|
198
|
+
return this.#buffer;
|
|
199
|
+
}
|
|
200
|
+
async bytes() {
|
|
201
|
+
return new Uint8Array(await this.arrayBuffer());
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @param {number=} start
|
|
205
|
+
* @param {number=} end
|
|
206
|
+
* @param {string=} contentType
|
|
207
|
+
*/
|
|
208
|
+
slice(start = 0, end = this.size, contentType = this.type) {
|
|
209
|
+
if (start < 0) {
|
|
210
|
+
start = Math.max(this.size + start, 0);
|
|
211
|
+
} else {
|
|
212
|
+
start = Math.min(start, this.size);
|
|
213
|
+
}
|
|
214
|
+
if (end < 0) {
|
|
215
|
+
end = Math.max(this.size + end, 0);
|
|
216
|
+
} else {
|
|
217
|
+
end = Math.min(end, this.size);
|
|
218
|
+
}
|
|
219
|
+
const size = Math.max(end - start, 0);
|
|
220
|
+
const file = new LazyFile(
|
|
221
|
+
this.name,
|
|
222
|
+
contentType,
|
|
223
|
+
size,
|
|
224
|
+
this.lastModified,
|
|
225
|
+
this.#get_chunk,
|
|
226
|
+
this.#offset + start
|
|
227
|
+
);
|
|
228
|
+
return file;
|
|
229
|
+
}
|
|
230
|
+
stream() {
|
|
231
|
+
let cursor = 0;
|
|
232
|
+
let chunk_index = 0;
|
|
233
|
+
return new ReadableStream({
|
|
234
|
+
start: async (controller) => {
|
|
235
|
+
let chunk_start = 0;
|
|
236
|
+
let start_chunk = null;
|
|
237
|
+
for (chunk_index = 0; ; chunk_index++) {
|
|
238
|
+
const chunk = await this.#get_chunk(chunk_index);
|
|
239
|
+
if (!chunk) return null;
|
|
240
|
+
const chunk_end = chunk_start + chunk.byteLength;
|
|
241
|
+
if (this.#offset >= chunk_start && this.#offset < chunk_end) {
|
|
242
|
+
start_chunk = chunk;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
chunk_start = chunk_end;
|
|
246
|
+
}
|
|
247
|
+
if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) {
|
|
248
|
+
controller.enqueue(
|
|
249
|
+
start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start)
|
|
250
|
+
);
|
|
251
|
+
controller.close();
|
|
252
|
+
} else {
|
|
253
|
+
controller.enqueue(start_chunk.subarray(this.#offset - chunk_start));
|
|
254
|
+
cursor = start_chunk.byteLength - this.#offset + chunk_start;
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
pull: async (controller) => {
|
|
258
|
+
chunk_index++;
|
|
259
|
+
let chunk = await this.#get_chunk(chunk_index);
|
|
260
|
+
if (!chunk) {
|
|
261
|
+
controller.error("incomplete file data");
|
|
262
|
+
controller.close();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (chunk.byteLength > this.size - cursor) {
|
|
266
|
+
chunk = chunk.subarray(0, this.size - cursor);
|
|
267
|
+
}
|
|
268
|
+
controller.enqueue(chunk);
|
|
269
|
+
cursor += chunk.byteLength;
|
|
270
|
+
if (cursor >= this.size) {
|
|
271
|
+
controller.close();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
async text() {
|
|
277
|
+
return text_decoder.decode(await this.arrayBuffer());
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
|
|
281
|
+
function split_path(path) {
|
|
282
|
+
if (!path_regex.test(path)) {
|
|
283
|
+
throw new Error(`Invalid path ${path}`);
|
|
284
|
+
}
|
|
285
|
+
return path.split(/\.|\[|\]/).filter(Boolean);
|
|
286
|
+
}
|
|
287
|
+
function check_prototype_pollution(key) {
|
|
288
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
289
|
+
throw new Error(
|
|
290
|
+
`Invalid key "${key}"`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function deep_set(object, keys, value) {
|
|
295
|
+
let current = object;
|
|
296
|
+
for (let i = 0; i < keys.length - 1; i += 1) {
|
|
297
|
+
const key = keys[i];
|
|
298
|
+
check_prototype_pollution(key);
|
|
299
|
+
const is_array = /^\d+$/.test(keys[i + 1]);
|
|
300
|
+
const exists = Object.hasOwn(current, key);
|
|
301
|
+
const inner = current[key];
|
|
302
|
+
if (exists && is_array !== Array.isArray(inner)) {
|
|
303
|
+
throw new Error(`Invalid array key ${keys[i + 1]}`);
|
|
304
|
+
}
|
|
305
|
+
if (!exists) {
|
|
306
|
+
current[key] = is_array ? [] : {};
|
|
307
|
+
}
|
|
308
|
+
current = current[key];
|
|
309
|
+
}
|
|
310
|
+
const final_key = keys[keys.length - 1];
|
|
311
|
+
check_prototype_pollution(final_key);
|
|
312
|
+
current[final_key] = value;
|
|
313
|
+
}
|
|
314
|
+
function normalize_issue(issue, server = false) {
|
|
315
|
+
const normalized = { name: "", path: [], message: issue.message, server };
|
|
316
|
+
if (issue.path !== void 0) {
|
|
317
|
+
let name = "";
|
|
318
|
+
for (const segment of issue.path) {
|
|
319
|
+
const key = (
|
|
320
|
+
/** @type {string | number} */
|
|
321
|
+
typeof segment === "object" ? segment.key : segment
|
|
322
|
+
);
|
|
323
|
+
normalized.path.push(key);
|
|
324
|
+
if (typeof key === "number") {
|
|
325
|
+
name += `[${key}]`;
|
|
326
|
+
} else if (typeof key === "string") {
|
|
327
|
+
name += name === "" ? key : "." + key;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
normalized.name = name;
|
|
331
|
+
}
|
|
332
|
+
return normalized;
|
|
333
|
+
}
|
|
334
|
+
function flatten_issues(issues) {
|
|
335
|
+
const result = {};
|
|
336
|
+
for (const issue of issues) {
|
|
337
|
+
(result.$ ??= []).push(issue);
|
|
338
|
+
let name = "";
|
|
339
|
+
if (issue.path !== void 0) {
|
|
340
|
+
for (const key of issue.path) {
|
|
341
|
+
if (typeof key === "number") {
|
|
342
|
+
name += `[${key}]`;
|
|
343
|
+
} else if (typeof key === "string") {
|
|
344
|
+
name += name === "" ? key : "." + key;
|
|
345
|
+
}
|
|
346
|
+
(result[name] ??= []).push(issue);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
352
|
+
function deep_get(object, path) {
|
|
353
|
+
let current = object;
|
|
354
|
+
for (const key of path) {
|
|
355
|
+
if (current == null || typeof current !== "object") {
|
|
356
|
+
return current;
|
|
357
|
+
}
|
|
358
|
+
current = current[key];
|
|
359
|
+
}
|
|
360
|
+
return current;
|
|
361
|
+
}
|
|
362
|
+
function create_field_proxy(target, get_input, set_input, get_issues, path = []) {
|
|
363
|
+
const get_value = () => {
|
|
364
|
+
return deep_get(get_input(), path);
|
|
365
|
+
};
|
|
366
|
+
return new Proxy(target, {
|
|
367
|
+
get(target2, prop) {
|
|
368
|
+
if (typeof prop === "symbol") return target2[prop];
|
|
369
|
+
if (/^\d+$/.test(prop)) {
|
|
370
|
+
return create_field_proxy({}, get_input, set_input, get_issues, [
|
|
371
|
+
...path,
|
|
372
|
+
parseInt(prop, 10)
|
|
373
|
+
]);
|
|
374
|
+
}
|
|
375
|
+
const key = build_path_string(path);
|
|
376
|
+
if (prop === "set") {
|
|
377
|
+
const set_func = function(newValue) {
|
|
378
|
+
set_input(path, newValue);
|
|
379
|
+
return newValue;
|
|
380
|
+
};
|
|
381
|
+
return create_field_proxy(set_func, get_input, set_input, get_issues, [...path, prop]);
|
|
382
|
+
}
|
|
383
|
+
if (prop === "value") {
|
|
384
|
+
return create_field_proxy(get_value, get_input, set_input, get_issues, [...path, prop]);
|
|
385
|
+
}
|
|
386
|
+
if (prop === "issues" || prop === "allIssues") {
|
|
387
|
+
const issues_func = () => {
|
|
388
|
+
const all_issues = get_issues()[key === "" ? "$" : key];
|
|
389
|
+
if (prop === "allIssues") {
|
|
390
|
+
return all_issues?.map((issue) => ({
|
|
391
|
+
path: issue.path,
|
|
392
|
+
message: issue.message
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
return all_issues?.filter((issue) => issue.name === key)?.map((issue) => ({
|
|
396
|
+
path: issue.path,
|
|
397
|
+
message: issue.message
|
|
398
|
+
}));
|
|
399
|
+
};
|
|
400
|
+
return create_field_proxy(issues_func, get_input, set_input, get_issues, [...path, prop]);
|
|
401
|
+
}
|
|
402
|
+
if (prop === "as") {
|
|
403
|
+
const as_func = (type, input_value) => {
|
|
404
|
+
const is_array = type === "file multiple" || type === "select multiple" || type === "checkbox" && typeof input_value === "string";
|
|
405
|
+
const prefix = type === "number" || type === "range" ? "n:" : type === "checkbox" && !is_array ? "b:" : "";
|
|
406
|
+
const base_props = {
|
|
407
|
+
name: prefix + key + (is_array ? "[]" : ""),
|
|
408
|
+
get "aria-invalid"() {
|
|
409
|
+
const issues = get_issues();
|
|
410
|
+
return key in issues ? "true" : void 0;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
if (type !== "text" && type !== "select" && type !== "select multiple") {
|
|
414
|
+
base_props.type = type === "file multiple" ? "file" : type;
|
|
415
|
+
}
|
|
416
|
+
if (type === "submit" || type === "hidden") {
|
|
417
|
+
return Object.defineProperties(base_props, {
|
|
418
|
+
value: { value: input_value, enumerable: true }
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
if (type === "select" || type === "select multiple") {
|
|
422
|
+
return Object.defineProperties(base_props, {
|
|
423
|
+
multiple: { value: is_array, enumerable: true },
|
|
424
|
+
value: {
|
|
425
|
+
enumerable: true,
|
|
426
|
+
get() {
|
|
427
|
+
return get_value();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
if (type === "checkbox" || type === "radio") {
|
|
433
|
+
return Object.defineProperties(base_props, {
|
|
434
|
+
value: { value: input_value ?? "on", enumerable: true },
|
|
435
|
+
checked: {
|
|
436
|
+
enumerable: true,
|
|
437
|
+
get() {
|
|
438
|
+
const value = get_value();
|
|
439
|
+
if (type === "radio") {
|
|
440
|
+
return value === input_value;
|
|
441
|
+
}
|
|
442
|
+
if (is_array) {
|
|
443
|
+
return (value ?? []).includes(input_value);
|
|
444
|
+
}
|
|
445
|
+
return value;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
if (type === "file" || type === "file multiple") {
|
|
451
|
+
return Object.defineProperties(base_props, {
|
|
452
|
+
multiple: { value: is_array, enumerable: true },
|
|
453
|
+
files: {
|
|
454
|
+
enumerable: true,
|
|
455
|
+
get() {
|
|
456
|
+
const value = get_value();
|
|
457
|
+
if (value instanceof File) {
|
|
458
|
+
if (typeof DataTransfer !== "undefined") {
|
|
459
|
+
const fileList = new DataTransfer();
|
|
460
|
+
fileList.items.add(value);
|
|
461
|
+
return fileList.files;
|
|
462
|
+
}
|
|
463
|
+
return { 0: value, length: 1 };
|
|
464
|
+
}
|
|
465
|
+
if (Array.isArray(value) && value.every((f) => f instanceof File)) {
|
|
466
|
+
if (typeof DataTransfer !== "undefined") {
|
|
467
|
+
const fileList = new DataTransfer();
|
|
468
|
+
value.forEach((file) => fileList.items.add(file));
|
|
469
|
+
return fileList.files;
|
|
470
|
+
}
|
|
471
|
+
const fileListLike = { length: value.length };
|
|
472
|
+
value.forEach((file, index) => {
|
|
473
|
+
fileListLike[index] = file;
|
|
474
|
+
});
|
|
475
|
+
return fileListLike;
|
|
476
|
+
}
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
return Object.defineProperties(base_props, {
|
|
483
|
+
value: {
|
|
484
|
+
enumerable: true,
|
|
485
|
+
get() {
|
|
486
|
+
const value = get_value();
|
|
487
|
+
return value != null ? String(value) : "";
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
return create_field_proxy(as_func, get_input, set_input, get_issues, [...path, "as"]);
|
|
493
|
+
}
|
|
494
|
+
return create_field_proxy({}, get_input, set_input, get_issues, [...path, prop]);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
function build_path_string(path) {
|
|
499
|
+
let result = "";
|
|
500
|
+
for (const segment of path) {
|
|
501
|
+
if (typeof segment === "number") {
|
|
502
|
+
result += `[${segment}]`;
|
|
503
|
+
} else {
|
|
504
|
+
result += result === "" ? segment : "." + segment;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return result;
|
|
508
|
+
}
|
|
509
|
+
function negotiate(accept, types) {
|
|
510
|
+
const parts = [];
|
|
511
|
+
accept.split(",").forEach((str, i) => {
|
|
512
|
+
const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
|
|
513
|
+
if (match) {
|
|
514
|
+
const [, type, subtype, q = "1"] = match;
|
|
515
|
+
parts.push({ type, subtype, q: +q, i });
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
parts.sort((a, b) => {
|
|
519
|
+
if (a.q !== b.q) {
|
|
520
|
+
return b.q - a.q;
|
|
521
|
+
}
|
|
522
|
+
if (a.subtype === "*" !== (b.subtype === "*")) {
|
|
523
|
+
return a.subtype === "*" ? 1 : -1;
|
|
524
|
+
}
|
|
525
|
+
if (a.type === "*" !== (b.type === "*")) {
|
|
526
|
+
return a.type === "*" ? 1 : -1;
|
|
527
|
+
}
|
|
528
|
+
return a.i - b.i;
|
|
529
|
+
});
|
|
530
|
+
let accepted;
|
|
531
|
+
let min_priority = Infinity;
|
|
532
|
+
for (const mimetype of types) {
|
|
533
|
+
const [type, subtype] = mimetype.split("/");
|
|
534
|
+
const priority = parts.findIndex(
|
|
535
|
+
(part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*")
|
|
536
|
+
);
|
|
537
|
+
if (priority !== -1 && priority < min_priority) {
|
|
538
|
+
accepted = mimetype;
|
|
539
|
+
min_priority = priority;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return accepted;
|
|
543
|
+
}
|
|
544
|
+
function is_content_type(request, ...types) {
|
|
545
|
+
const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
|
|
546
|
+
return types.includes(type.toLowerCase());
|
|
547
|
+
}
|
|
548
|
+
function is_form_content_type(request) {
|
|
549
|
+
return is_content_type(
|
|
550
|
+
request,
|
|
551
|
+
"application/x-www-form-urlencoded",
|
|
552
|
+
"multipart/form-data",
|
|
553
|
+
"text/plain",
|
|
554
|
+
BINARY_FORM_CONTENT_TYPE
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
function coalesce_to_error(err) {
|
|
558
|
+
return err instanceof Error || err && /** @type {any} */
|
|
559
|
+
err.name && /** @type {any} */
|
|
560
|
+
err.message ? (
|
|
561
|
+
/** @type {Error} */
|
|
562
|
+
err
|
|
563
|
+
) : new Error(JSON.stringify(err));
|
|
564
|
+
}
|
|
565
|
+
function normalize_error(error) {
|
|
566
|
+
return (
|
|
567
|
+
/** @type {import('../exports/internal/index.js').Redirect | HttpError | SvelteKitError | Error} */
|
|
568
|
+
error
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
function get_status(error) {
|
|
572
|
+
return error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
|
|
573
|
+
}
|
|
574
|
+
function get_message(error) {
|
|
575
|
+
return error instanceof SvelteKitError ? error.text : "Internal Error";
|
|
576
|
+
}
|
|
577
|
+
const escape_html_attr_dict = {
|
|
578
|
+
"&": "&",
|
|
579
|
+
'"': """
|
|
580
|
+
// Svelte also escapes < because the escape function could be called inside a `noscript` there
|
|
581
|
+
// https://github.com/sveltejs/svelte/security/advisories/GHSA-8266-84wp-wv5c
|
|
582
|
+
// However, that doesn't apply in SvelteKit
|
|
583
|
+
};
|
|
584
|
+
const escape_html_dict = {
|
|
585
|
+
"&": "&",
|
|
586
|
+
"<": "<"
|
|
587
|
+
};
|
|
588
|
+
const surrogates = (
|
|
589
|
+
// high surrogate without paired low surrogate
|
|
590
|
+
"[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]"
|
|
591
|
+
);
|
|
592
|
+
const escape_html_attr_regex = new RegExp(
|
|
593
|
+
`[${Object.keys(escape_html_attr_dict).join("")}]|` + surrogates,
|
|
594
|
+
"g"
|
|
595
|
+
);
|
|
596
|
+
const escape_html_regex = new RegExp(
|
|
597
|
+
`[${Object.keys(escape_html_dict).join("")}]|` + surrogates,
|
|
598
|
+
"g"
|
|
599
|
+
);
|
|
600
|
+
function escape_html(str, is_attr) {
|
|
601
|
+
const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
|
|
602
|
+
const escaped_str = str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
|
|
603
|
+
if (match.length === 2) {
|
|
604
|
+
return match;
|
|
605
|
+
}
|
|
606
|
+
return dict[match] ?? `&#${match.charCodeAt(0)};`;
|
|
607
|
+
});
|
|
608
|
+
return escaped_str;
|
|
609
|
+
}
|
|
610
|
+
function method_not_allowed(mod, method) {
|
|
611
|
+
return text(`${method} method not allowed`, {
|
|
612
|
+
status: 405,
|
|
613
|
+
headers: {
|
|
614
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405
|
|
615
|
+
// "The server must generate an Allow header field in a 405 status code response"
|
|
616
|
+
allow: allowed_methods(mod).join(", ")
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
function allowed_methods(mod) {
|
|
621
|
+
const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
|
|
622
|
+
if ("GET" in mod && !("HEAD" in mod)) {
|
|
623
|
+
allowed.push("HEAD");
|
|
624
|
+
}
|
|
625
|
+
return allowed;
|
|
626
|
+
}
|
|
627
|
+
function get_global_name(options) {
|
|
628
|
+
return `__sveltekit_${options.version_hash}`;
|
|
629
|
+
}
|
|
630
|
+
function static_error_page(options, status, message) {
|
|
631
|
+
let page = options.templates.error({ status, message: escape_html(message) });
|
|
632
|
+
return text(page, {
|
|
633
|
+
headers: { "content-type": "text/html; charset=utf-8" },
|
|
634
|
+
status
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
async function handle_fatal_error(event, state, options, error) {
|
|
638
|
+
error = error instanceof HttpError ? error : coalesce_to_error(error);
|
|
639
|
+
const status = get_status(error);
|
|
640
|
+
const body = await handle_error_and_jsonify(event, state, options, error);
|
|
641
|
+
const type = negotiate(event.request.headers.get("accept") || "text/html", [
|
|
642
|
+
"application/json",
|
|
643
|
+
"text/html"
|
|
644
|
+
]);
|
|
645
|
+
if (event.isDataRequest || type === "application/json") {
|
|
646
|
+
return json(body, {
|
|
647
|
+
status
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
return static_error_page(options, status, body.message);
|
|
651
|
+
}
|
|
652
|
+
async function handle_error_and_jsonify(event, state, options, error) {
|
|
653
|
+
if (error instanceof HttpError) {
|
|
654
|
+
return { message: "Unknown Error", ...error.body };
|
|
655
|
+
}
|
|
656
|
+
const status = get_status(error);
|
|
657
|
+
const message = get_message(error);
|
|
658
|
+
return await with_request_store(
|
|
659
|
+
{ event, state },
|
|
660
|
+
() => options.hooks.handleError({ error, event, status, message })
|
|
661
|
+
) ?? { message };
|
|
662
|
+
}
|
|
663
|
+
function redirect_response(status, location) {
|
|
664
|
+
const response = new Response(void 0, {
|
|
665
|
+
status,
|
|
666
|
+
headers: { location }
|
|
667
|
+
});
|
|
668
|
+
return response;
|
|
669
|
+
}
|
|
670
|
+
function clarify_devalue_error(event, error) {
|
|
671
|
+
if (error.path) {
|
|
672
|
+
return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`;
|
|
673
|
+
}
|
|
674
|
+
if (error.path === "") {
|
|
675
|
+
return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
|
|
676
|
+
}
|
|
677
|
+
return error.message;
|
|
678
|
+
}
|
|
679
|
+
function serialize_uses(node) {
|
|
680
|
+
const uses = {};
|
|
681
|
+
if (node.uses && node.uses.dependencies.size > 0) {
|
|
682
|
+
uses.dependencies = Array.from(node.uses.dependencies);
|
|
683
|
+
}
|
|
684
|
+
if (node.uses && node.uses.search_params.size > 0) {
|
|
685
|
+
uses.search_params = Array.from(node.uses.search_params);
|
|
686
|
+
}
|
|
687
|
+
if (node.uses && node.uses.params.size > 0) {
|
|
688
|
+
uses.params = Array.from(node.uses.params);
|
|
689
|
+
}
|
|
690
|
+
if (node.uses?.parent) uses.parent = 1;
|
|
691
|
+
if (node.uses?.route) uses.route = 1;
|
|
692
|
+
if (node.uses?.url) uses.url = 1;
|
|
693
|
+
return uses;
|
|
694
|
+
}
|
|
695
|
+
function has_prerendered_path(manifest, pathname) {
|
|
696
|
+
return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
|
|
697
|
+
}
|
|
698
|
+
function format_server_error(status, error, event) {
|
|
699
|
+
const formatted_text = `
|
|
700
|
+
\x1B[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1B[0m`;
|
|
701
|
+
if (status === 404) {
|
|
702
|
+
return formatted_text;
|
|
703
|
+
}
|
|
704
|
+
return `${formatted_text}
|
|
705
|
+
${error.stack}`;
|
|
706
|
+
}
|
|
707
|
+
function get_node_type(node_id) {
|
|
708
|
+
const parts = node_id?.split("/");
|
|
709
|
+
const filename = parts?.at(-1);
|
|
710
|
+
if (!filename) return "unknown";
|
|
711
|
+
const dot_parts = filename.split(".");
|
|
712
|
+
return dot_parts.slice(0, -1).join(".");
|
|
713
|
+
}
|
|
714
|
+
const INVALIDATED_PARAM = "x-sveltekit-invalidated";
|
|
715
|
+
const TRAILING_SLASH_PARAM = "x-sveltekit-trailing-slash";
|
|
716
|
+
function stringify(data, transport) {
|
|
717
|
+
const encoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.encode]));
|
|
718
|
+
return devalue.stringify(data, encoders);
|
|
719
|
+
}
|
|
720
|
+
function stringify_remote_arg(value, transport) {
|
|
721
|
+
if (value === void 0) return "";
|
|
722
|
+
const json_string = stringify(value, transport);
|
|
723
|
+
const bytes = new TextEncoder().encode(json_string);
|
|
724
|
+
return base64_encode(bytes).replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
|
|
725
|
+
}
|
|
726
|
+
function parse_remote_arg(string, transport) {
|
|
727
|
+
if (!string) return void 0;
|
|
728
|
+
const json_string = text_decoder.decode(
|
|
729
|
+
// no need to add back `=` characters, atob can handle it
|
|
730
|
+
base64_decode(string.replaceAll("-", "+").replaceAll("_", "/"))
|
|
731
|
+
);
|
|
732
|
+
const decoders = Object.fromEntries(Object.entries(transport).map(([k, v]) => [k, v.decode]));
|
|
733
|
+
return devalue.parse(json_string, decoders);
|
|
734
|
+
}
|
|
735
|
+
function create_remote_key(id, payload) {
|
|
736
|
+
return id + "/" + payload;
|
|
737
|
+
}
|
|
738
|
+
export {
|
|
739
|
+
ENDPOINT_METHODS as E,
|
|
740
|
+
INVALIDATED_PARAM as I,
|
|
741
|
+
PAGE_METHODS as P,
|
|
742
|
+
SVELTE_KIT_ASSETS as S,
|
|
743
|
+
TRAILING_SLASH_PARAM as T,
|
|
744
|
+
normalize_error as a,
|
|
745
|
+
get_global_name as b,
|
|
746
|
+
clarify_devalue_error as c,
|
|
747
|
+
get_node_type as d,
|
|
748
|
+
escape_html as e,
|
|
749
|
+
create_remote_key as f,
|
|
750
|
+
get_status as g,
|
|
751
|
+
handle_error_and_jsonify as h,
|
|
752
|
+
is_form_content_type as i,
|
|
753
|
+
static_error_page as j,
|
|
754
|
+
stringify as k,
|
|
755
|
+
deserialize_binary_form as l,
|
|
756
|
+
method_not_allowed as m,
|
|
757
|
+
negotiate as n,
|
|
758
|
+
has_prerendered_path as o,
|
|
759
|
+
parse_remote_arg as p,
|
|
760
|
+
handle_fatal_error as q,
|
|
761
|
+
redirect_response as r,
|
|
762
|
+
serialize_uses as s,
|
|
763
|
+
format_server_error as t,
|
|
764
|
+
stringify_remote_arg as u,
|
|
765
|
+
flatten_issues as v,
|
|
766
|
+
create_field_proxy as w,
|
|
767
|
+
normalize_issue as x,
|
|
768
|
+
set_nested_value as y,
|
|
769
|
+
deep_set as z
|
|
770
|
+
};
|