vite-devtools-svelte 0.1.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/dist/analyzers/assets.d.ts +3 -0
- package/dist/analyzers/components.d.ts +2 -0
- package/dist/analyzers/project.d.ts +2 -0
- package/dist/analyzers/routes.d.ts +2 -0
- package/dist/client/assets/client-jp6K3SZs.js +4 -0
- package/dist/client/assets/index-BjOa4UgY.js +6 -0
- package/dist/client/assets/index-D-ChuYqP.css +1 -0
- package/dist/client/index.html +46 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +855 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin.d.ts +9 -0
- package/dist/runtime.d.ts +17 -0
- package/dist/types.d.ts +176 -0
- package/package.json +62 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,855 @@
|
|
|
1
|
+
import e from "node:path";
|
|
2
|
+
import t from "node:fs";
|
|
3
|
+
import n from "node:net";
|
|
4
|
+
import r from "node:crypto";
|
|
5
|
+
import { fileURLToPath as i } from "node:url";
|
|
6
|
+
import { execFile as a } from "node:child_process";
|
|
7
|
+
import o from "fs";
|
|
8
|
+
import s from "path";
|
|
9
|
+
//#region src/analyzers/routes.ts
|
|
10
|
+
function c(e) {
|
|
11
|
+
if (!o.existsSync(e)) return [];
|
|
12
|
+
let t = [];
|
|
13
|
+
return l(e, e, t), t.sort((e, t) => e.path.localeCompare(t.path));
|
|
14
|
+
}
|
|
15
|
+
function l(e, t, n) {
|
|
16
|
+
let r = o.readdirSync(e, { withFileTypes: !0 }), i = [], a = !1;
|
|
17
|
+
for (let o of r) {
|
|
18
|
+
if (o.isDirectory()) {
|
|
19
|
+
l(s.join(e, o.name), t, n);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
let r = u(o.name, s.join(e, o.name));
|
|
23
|
+
r && (i.push(r), a = !0);
|
|
24
|
+
}
|
|
25
|
+
if (a) {
|
|
26
|
+
let r = s.relative(t, e), a = d(r), o = f(r);
|
|
27
|
+
n.push({
|
|
28
|
+
id: r || "/",
|
|
29
|
+
path: a,
|
|
30
|
+
pattern: a,
|
|
31
|
+
segments: a.split("/").filter(Boolean),
|
|
32
|
+
hasPage: i.some((e) => e.type === "page"),
|
|
33
|
+
hasLayout: i.some((e) => e.type === "layout"),
|
|
34
|
+
hasServerPage: i.some((e) => e.type === "page-load-server"),
|
|
35
|
+
hasServerLayout: i.some((e) => e.type === "layout-load-server"),
|
|
36
|
+
hasEndpoint: i.some((e) => e.type === "endpoint"),
|
|
37
|
+
hasPageLoad: i.some((e) => e.type === "page-load"),
|
|
38
|
+
hasLayoutLoad: i.some((e) => e.type === "layout-load"),
|
|
39
|
+
params: o,
|
|
40
|
+
files: i
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function u(e, t) {
|
|
45
|
+
let n = {
|
|
46
|
+
"+page.svelte": "page",
|
|
47
|
+
"+layout.svelte": "layout",
|
|
48
|
+
"+page.server.ts": "page-load-server",
|
|
49
|
+
"+page.server.js": "page-load-server",
|
|
50
|
+
"+layout.server.ts": "layout-load-server",
|
|
51
|
+
"+layout.server.js": "layout-load-server",
|
|
52
|
+
"+page.ts": "page-load",
|
|
53
|
+
"+page.js": "page-load",
|
|
54
|
+
"+layout.ts": "layout-load",
|
|
55
|
+
"+layout.js": "layout-load",
|
|
56
|
+
"+server.ts": "endpoint",
|
|
57
|
+
"+server.js": "endpoint",
|
|
58
|
+
"+error.svelte": "error"
|
|
59
|
+
}[e];
|
|
60
|
+
return n ? {
|
|
61
|
+
type: n,
|
|
62
|
+
path: t
|
|
63
|
+
} : null;
|
|
64
|
+
}
|
|
65
|
+
function d(e) {
|
|
66
|
+
return e ? "/" + e.split(s.sep).map((e) => {
|
|
67
|
+
if (e.startsWith("(") && e.endsWith(")")) return null;
|
|
68
|
+
if (e.startsWith("[") && e.endsWith("]")) {
|
|
69
|
+
let t = e.slice(1, -1);
|
|
70
|
+
return t.startsWith("...") ? `*${t.slice(3)}` : t.startsWith("[") && t.endsWith("]") ? `:${t.slice(1, -1)}?` : `:${t}`;
|
|
71
|
+
}
|
|
72
|
+
return e;
|
|
73
|
+
}).filter(Boolean).join("/") : "/";
|
|
74
|
+
}
|
|
75
|
+
function f(e) {
|
|
76
|
+
if (!e) return [];
|
|
77
|
+
let t = [], n = e.split(s.sep);
|
|
78
|
+
for (let e of n) {
|
|
79
|
+
if (!e.startsWith("[") || !e.endsWith("]")) continue;
|
|
80
|
+
let n = e.slice(1, -1);
|
|
81
|
+
if (n.startsWith("...")) t.push({
|
|
82
|
+
name: n.slice(3),
|
|
83
|
+
optional: !1,
|
|
84
|
+
rest: !0
|
|
85
|
+
});
|
|
86
|
+
else if (n.startsWith("[") && n.endsWith("]")) t.push({
|
|
87
|
+
name: n.slice(1, -1),
|
|
88
|
+
optional: !0,
|
|
89
|
+
rest: !1
|
|
90
|
+
});
|
|
91
|
+
else {
|
|
92
|
+
let e = n.split("=");
|
|
93
|
+
t.push({
|
|
94
|
+
name: e[0],
|
|
95
|
+
optional: !1,
|
|
96
|
+
rest: !1,
|
|
97
|
+
matcher: e[1]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return t;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/analyzers/assets.ts
|
|
105
|
+
var p = {
|
|
106
|
+
".png": "image/png",
|
|
107
|
+
".jpg": "image/jpeg",
|
|
108
|
+
".jpeg": "image/jpeg",
|
|
109
|
+
".gif": "image/gif",
|
|
110
|
+
".svg": "image/svg+xml",
|
|
111
|
+
".webp": "image/webp",
|
|
112
|
+
".avif": "image/avif",
|
|
113
|
+
".ico": "image/x-icon",
|
|
114
|
+
".woff": "font/woff",
|
|
115
|
+
".woff2": "font/woff2",
|
|
116
|
+
".ttf": "font/ttf",
|
|
117
|
+
".eot": "application/vnd.ms-fontobject",
|
|
118
|
+
".otf": "font/otf",
|
|
119
|
+
".mp4": "video/mp4",
|
|
120
|
+
".webm": "video/webm",
|
|
121
|
+
".mp3": "audio/mpeg",
|
|
122
|
+
".wav": "audio/wav",
|
|
123
|
+
".ogg": "audio/ogg",
|
|
124
|
+
".json": "application/json",
|
|
125
|
+
".xml": "application/xml",
|
|
126
|
+
".pdf": "application/pdf",
|
|
127
|
+
".txt": "text/plain",
|
|
128
|
+
".css": "text/css",
|
|
129
|
+
".js": "text/javascript",
|
|
130
|
+
".html": "text/html"
|
|
131
|
+
};
|
|
132
|
+
function m(e) {
|
|
133
|
+
if (!o.existsSync(e)) return [];
|
|
134
|
+
let t = [];
|
|
135
|
+
return h(e, e, t), t.sort((e, t) => e.relativePath.localeCompare(t.relativePath));
|
|
136
|
+
}
|
|
137
|
+
function h(e, t, n) {
|
|
138
|
+
let r = o.readdirSync(e, { withFileTypes: !0 });
|
|
139
|
+
for (let i of r) {
|
|
140
|
+
let r = s.join(e, i.name);
|
|
141
|
+
if (i.isDirectory()) {
|
|
142
|
+
h(r, t, n);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (i.name.startsWith(".")) continue;
|
|
146
|
+
let a = o.statSync(r), c = s.extname(i.name).toLowerCase();
|
|
147
|
+
n.push({
|
|
148
|
+
name: i.name,
|
|
149
|
+
path: r,
|
|
150
|
+
relativePath: s.relative(t, r),
|
|
151
|
+
size: a.size,
|
|
152
|
+
type: p[c] || "application/octet-stream",
|
|
153
|
+
mtime: a.mtimeMs
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/analyzers/project.ts
|
|
159
|
+
var g = 5e3, _ = null, v = null, y = 0;
|
|
160
|
+
function b(e) {
|
|
161
|
+
let t = Date.now();
|
|
162
|
+
if (_ && v === e && t - y < g) return _;
|
|
163
|
+
let n = x(e);
|
|
164
|
+
return _ = n, v = e, y = t, n;
|
|
165
|
+
}
|
|
166
|
+
function x(e) {
|
|
167
|
+
let t = s.join(e, "package.json"), n = o.existsSync(t) ? JSON.parse(o.readFileSync(t, "utf-8")) : {}, r = n.dependencies || {}, i = n.devDependencies || {};
|
|
168
|
+
return {
|
|
169
|
+
name: n.name || s.basename(e),
|
|
170
|
+
version: n.version || "0.0.0",
|
|
171
|
+
svelteVersion: S(e, "svelte") || r.svelte || i.svelte || "unknown",
|
|
172
|
+
sveltekitVersion: S(e, "@sveltejs/kit") || r["@sveltejs/kit"] || i["@sveltejs/kit"] || "unknown",
|
|
173
|
+
viteVersion: S(e, "vite") || r.vite || i.vite || "unknown",
|
|
174
|
+
dependencies: r,
|
|
175
|
+
devDependencies: i,
|
|
176
|
+
routesDir: C(e),
|
|
177
|
+
staticDir: w(e)
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function S(e, t) {
|
|
181
|
+
try {
|
|
182
|
+
let n = s.join(e, "node_modules", t, "package.json");
|
|
183
|
+
if (o.existsSync(n)) return JSON.parse(o.readFileSync(n, "utf-8")).version;
|
|
184
|
+
} catch {}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
function C(e) {
|
|
188
|
+
let t = [s.join(e, "src", "routes"), s.join(e, "src", "pages")];
|
|
189
|
+
for (let e of t) if (o.existsSync(e)) return e;
|
|
190
|
+
return s.join(e, "src", "routes");
|
|
191
|
+
}
|
|
192
|
+
function w(e) {
|
|
193
|
+
let t = [s.join(e, "static"), s.join(e, "public")];
|
|
194
|
+
for (let e of t) if (o.existsSync(e)) return e;
|
|
195
|
+
return s.join(e, "static");
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/analyzers/components.ts
|
|
199
|
+
function T(e) {
|
|
200
|
+
let t = s.join(e, "src");
|
|
201
|
+
if (!o.existsSync(t)) return [];
|
|
202
|
+
let n = [];
|
|
203
|
+
return E(t, n), n.map((t) => {
|
|
204
|
+
let n = D(o.readFileSync(t, "utf-8"), t), r = A(t);
|
|
205
|
+
return {
|
|
206
|
+
file: s.relative(e, t),
|
|
207
|
+
name: r,
|
|
208
|
+
imports: n.map((t) => s.relative(e, t))
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function E(e, t) {
|
|
213
|
+
let n = o.readdirSync(e, { withFileTypes: !0 });
|
|
214
|
+
for (let r of n) {
|
|
215
|
+
let n = s.join(e, r.name);
|
|
216
|
+
if (r.isDirectory()) {
|
|
217
|
+
if (r.name === "node_modules" || r.name === ".svelte-kit") continue;
|
|
218
|
+
E(n, t);
|
|
219
|
+
} else r.name.endsWith(".svelte") && t.push(n);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function D(e, t) {
|
|
223
|
+
let n = [], r = s.dirname(t), i = /import\s+[\w{}\s,*]+\s+from\s+['"]([^'"]+\.svelte)['"]/g, a;
|
|
224
|
+
for (; (a = i.exec(e)) !== null;) {
|
|
225
|
+
let e = a[1], i = O(e, r, t);
|
|
226
|
+
i && n.push(i);
|
|
227
|
+
}
|
|
228
|
+
return n;
|
|
229
|
+
}
|
|
230
|
+
function O(e, t, n) {
|
|
231
|
+
if (e.startsWith("$lib/")) {
|
|
232
|
+
let t = k(n);
|
|
233
|
+
if (t) {
|
|
234
|
+
let n = s.join(t, "src", "lib", e.slice(5));
|
|
235
|
+
if (o.existsSync(n)) return n;
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
if (e.startsWith(".")) {
|
|
240
|
+
let n = s.resolve(t, e);
|
|
241
|
+
if (o.existsSync(n)) return n;
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
function k(e) {
|
|
246
|
+
let t = s.dirname(e);
|
|
247
|
+
for (; t !== s.dirname(t);) {
|
|
248
|
+
if (o.existsSync(s.join(t, "package.json"))) return t;
|
|
249
|
+
t = s.dirname(t);
|
|
250
|
+
}
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
function A(e) {
|
|
254
|
+
return s.basename(e, ".svelte");
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/runtime.ts
|
|
258
|
+
var j = "virtual:svelte-devtools-runtime", M = "\0" + j, N = "\0svelte-devtools:wrapped-client", P = "\nimport * as __svelte_original from 'svelte/internal/client';\nexport * from 'svelte/internal/client';\n\nfunction __dt() {\n return typeof window !== 'undefined' ? window.__SVELTE_DEVTOOLS__ : null;\n}\n\n// Component ID stack (parallel to runtime._stack but local to wrapper)\nconst __idStack = [];\nfunction __currentId() {\n return __idStack.length > 0 ? __idStack[__idStack.length - 1] : null;\n}\n\n// Tracks the most recently created signal for type determination in tag()\nconst __pendingSignal = { ref: null, type: null };\n\n// --- Component Lifecycle ---\n//\n// Observer must not break the observed: every devtools side-effect below is\n// wrapped in try/catch so a bug or an out-of-shape runtime cannot tear down\n// the user's app. The original Svelte function is always called, and its\n// return value always returned, regardless of devtools failures.\n\nexport function push() {\n const result = __svelte_original.push.apply(null, arguments);\n try {\n const dt = __dt();\n if (dt) {\n const file = dt._pendingFile || 'Unknown';\n dt._pendingFile = null;\n const id = dt.register(file);\n __idStack.push(id);\n dt.startInit(id);\n try {\n __svelte_original.user_effect(() => {\n return () => { try { dt.unmount(id); } catch {} };\n });\n } catch {}\n }\n } catch {}\n return result;\n}\n\nexport function pop() {\n // Capture devtools errors but ALWAYS forward to the original pop so the\n // Svelte component stack stays balanced.\n try {\n const dt = __dt();\n if (dt && __idStack.length > 0) {\n const id = __idStack.pop();\n try { dt.endInit(id); } catch {}\n try { dt.registered(id); } catch {}\n }\n } catch {}\n return __svelte_original.pop.apply(null, arguments);\n}\n\n// --- Signal Creation (type markers) ---\n\nexport function state() {\n const signal = __svelte_original.state.apply(null, arguments);\n try {\n __pendingSignal.ref = signal;\n __pendingSignal.type = 'state';\n } catch {}\n return signal;\n}\n\nexport function derived() {\n const signal = __svelte_original.derived.apply(null, arguments);\n try {\n __pendingSignal.ref = signal;\n __pendingSignal.type = 'derived';\n } catch {}\n return signal;\n}\n\nexport function proxy() {\n const p = __svelte_original.proxy.apply(null, arguments);\n try {\n __pendingSignal.ref = p;\n __pendingSignal.type = 'proxy';\n } catch {}\n return p;\n}\n\n// --- Signal Tagging (Svelte dev mode) ---\n\nexport function tag(signal, name) {\n const result = __svelte_original.tag.apply(null, arguments);\n try {\n const dt = __dt();\n const cid = __currentId();\n if (dt && cid !== null) {\n const type = (__pendingSignal.ref === signal) ? __pendingSignal.type : 'state';\n if (type === 'derived') {\n dt.trackDerived(signal, name, cid);\n } else {\n dt.trackState(signal, name, cid);\n }\n }\n __pendingSignal.ref = null;\n __pendingSignal.type = null;\n } catch {}\n return result;\n}\n\nexport function tag_proxy(proxy, name) {\n const result = __svelte_original.tag_proxy.apply(null, arguments);\n try {\n const dt = __dt();\n const cid = __currentId();\n if (dt && cid !== null) {\n dt.trackProxy(proxy, name, cid);\n }\n __pendingSignal.ref = null;\n __pendingSignal.type = null;\n } catch {}\n return result;\n}\n\n// --- Effect Tracking ---\n\nexport function user_effect() {\n const result = __svelte_original.user_effect.apply(null, arguments);\n try {\n const dt = __dt();\n const cid = __currentId();\n if (dt && cid !== null) {\n dt._effectCounter = (dt._effectCounter || 0) + 1;\n // Track the effect OBJECT (not the callback). The Svelte runtime\n // populates result.deps with the signals this effect depends on,\n // which is what getReactiveGraph() reads to build edges.\n dt.trackEffect(result, 'effect_' + dt._effectCounter, cid);\n }\n } catch {}\n return result;\n}\n\nexport function user_pre_effect() {\n const result = __svelte_original.user_pre_effect.apply(null, arguments);\n try {\n const dt = __dt();\n const cid = __currentId();\n if (dt && cid !== null) {\n dt._effectCounter = (dt._effectCounter || 0) + 1;\n dt.trackEffect(result, 'effect_pre_' + dt._effectCounter, cid);\n }\n } catch {}\n return result;\n}\n", F = "\nif (typeof window !== 'undefined' && !window.__SVELTE_DEVTOOLS__) {\n const __SVELTE_DT = {\n _nextId: 0,\n _instances: new Map(),\n _stack: [],\n _pendingFile: null,\n _effectCounter: 0,\n _debounceTimer: null,\n _listeners: new Set(),\n\n // Phase 2: Profiling data\n _profiles: new Map(),\n _initStartTimes: new Map(),\n _profileDebounceTimer: null,\n\n // Phase 2: Reactive graph data\n _reactiveNodes: new Map(),\n _reactiveProxies: new Map(),\n\n // Phase 3: State timeline\n _stateTimeline: [],\n _stateSnapshots: new Map(),\n _timelineDebounceTimer: null,\n\n register(file) {\n const id = this._nextId++;\n const parentId = this._stack.length > 0 ? this._stack[this._stack.length - 1] : null;\n const name = file.split('/').pop()?.replace('.svelte', '') || 'Unknown';\n this._instances.set(id, { id, file, name, parentId, mounted: true, children: [] });\n if (parentId !== null) {\n const parent = this._instances.get(parentId);\n if (parent) parent.children.push(id);\n }\n this._stack.push(id);\n this._scheduleUpdate();\n return id;\n },\n\n registered(id) {\n const idx = this._stack.indexOf(id);\n if (idx !== -1) this._stack.splice(idx, 1);\n },\n\n mount(id) {\n const instance = this._instances.get(id);\n if (instance && !instance.mounted) {\n instance.mounted = true;\n this._scheduleUpdate();\n }\n },\n\n unmount(id) {\n const instance = this._instances.get(id);\n if (instance) {\n if (instance.parentId !== null) {\n const parent = this._instances.get(instance.parentId);\n if (parent) {\n parent.children = parent.children.filter(cid => cid !== id);\n }\n }\n this._removeChildren(id);\n this._cleanupReactiveNodes(id);\n this._instances.delete(id);\n }\n this._scheduleUpdate();\n },\n\n _cleanupReactiveNodes(componentId) {\n for (const [nodeId, entry] of this._reactiveNodes) {\n if (entry.meta.componentId === componentId) {\n this._reactiveNodes.delete(nodeId);\n }\n }\n },\n\n _removeChildren(parentId) {\n const parent = this._instances.get(parentId);\n if (!parent) return;\n for (const childId of [...parent.children]) {\n this._removeChildren(childId);\n this._cleanupReactiveNodes(childId);\n this._instances.delete(childId);\n }\n },\n\n _scheduleUpdate() {\n if (this._debounceTimer) clearTimeout(this._debounceTimer);\n this._debounceTimer = setTimeout(() => {\n this._sendUpdate();\n }, 100);\n },\n\n _sendUpdate() {\n const components = [];\n for (const [, instance] of this._instances) {\n if (instance.mounted) {\n components.push({\n id: instance.id,\n file: instance.file,\n name: instance.name,\n parentId: instance.parentId,\n mounted: instance.mounted,\n });\n }\n }\n if (import.meta.hot) {\n import.meta.hot.send('svelte-devtools:components', { components });\n }\n },\n\n getTree() {\n const components = [];\n for (const [, instance] of this._instances) {\n if (instance.mounted) {\n components.push({\n id: instance.id,\n file: instance.file,\n name: instance.name,\n parentId: instance.parentId,\n mounted: instance.mounted,\n });\n }\n }\n return components;\n },\n\n // --- Phase 2: Render Profiling ---\n\n startInit(id) {\n this._initStartTimes.set(id, performance.now());\n },\n\n endInit(id) {\n const start = this._initStartTimes.get(id);\n if (start === undefined) return;\n const initTime = performance.now() - start;\n this._initStartTimes.delete(id);\n const instance = this._instances.get(id);\n if (!instance) return;\n this._profiles.set(id, {\n componentId: id,\n file: instance.file,\n name: instance.name,\n initTime,\n renderCount: 0,\n totalRenderTime: 0,\n lastRenderTime: 0,\n lastRenderAt: Date.now(),\n });\n this._scheduleProfileUpdate();\n },\n\n recordRender(id) {\n const profile = this._profiles.get(id);\n if (!profile) {\n const instance = this._instances.get(id);\n if (!instance) return;\n this._profiles.set(id, {\n componentId: id,\n file: instance.file,\n name: instance.name,\n initTime: 0,\n renderCount: 1,\n totalRenderTime: 0,\n lastRenderTime: 0,\n lastRenderAt: Date.now(),\n });\n } else {\n profile.renderCount++;\n profile.lastRenderAt = Date.now();\n }\n this._scheduleProfileUpdate();\n },\n\n recordRenderTime(id, duration) {\n const profile = this._profiles.get(id);\n if (profile) {\n profile.totalRenderTime += duration;\n profile.lastRenderTime = duration;\n }\n },\n\n _scheduleProfileUpdate() {\n if (this._profileDebounceTimer) clearTimeout(this._profileDebounceTimer);\n this._profileDebounceTimer = setTimeout(() => {\n this._sendProfileUpdate();\n }, 500);\n },\n\n _sendProfileUpdate() {\n const profiles = Array.from(this._profiles.values());\n if (import.meta.hot) {\n import.meta.hot.send('svelte-devtools:profiles', { profiles });\n }\n },\n\n getProfiles() {\n return Array.from(this._profiles.values());\n },\n\n resetProfiles() {\n this._profiles.clear();\n this._scheduleProfileUpdate();\n },\n\n // --- Phase 2: Reactive Graph Tracking ---\n\n trackState(signal, name, componentId) {\n const instance = this._instances.get(componentId);\n const nodeId = componentId + ':' + name;\n this._reactiveNodes.set(nodeId, {\n signal: new WeakRef(signal),\n meta: { id: nodeId, type: 'state', name, componentId, componentFile: instance ? instance.file : '' }\n });\n },\n\n trackProxy(proxy, name, componentId) {\n const instance = this._instances.get(componentId);\n const nodeId = componentId + ':' + name;\n this._reactiveProxies.set(nodeId, new WeakRef(proxy));\n this._reactiveNodes.set(nodeId, {\n signal: new WeakRef({ v: '(proxy)', _isProxy: true }),\n meta: { id: nodeId, type: 'state', name, componentId, componentFile: instance ? instance.file : '' }\n });\n },\n\n trackDerived(signal, name, componentId) {\n const instance = this._instances.get(componentId);\n const nodeId = componentId + ':' + name;\n this._reactiveNodes.set(nodeId, {\n signal: new WeakRef(signal),\n meta: { id: nodeId, type: 'derived', name, componentId, componentFile: instance ? instance.file : '' }\n });\n },\n\n trackEffect(effect, name, componentId) {\n const instance = this._instances.get(componentId);\n const nodeId = componentId + ':' + name;\n this._reactiveNodes.set(nodeId, {\n signal: new WeakRef(effect || { v: undefined, _isEffect: true }),\n meta: { id: nodeId, type: 'effect', name, componentId, componentFile: instance ? instance.file : '' }\n });\n return effect;\n },\n\n getReactiveGraph() {\n const nodes = [];\n const edges = [];\n const signalToId = new Map();\n\n for (const [nodeId, entry] of this._reactiveNodes) {\n const signal = entry.signal.deref();\n if (!signal || !this._instances.has(entry.meta.componentId)) {\n this._reactiveNodes.delete(nodeId);\n continue;\n }\n signalToId.set(signal, nodeId);\n const node = { ...entry.meta };\n if (signal._isProxy) {\n const proxyRef = this._reactiveProxies.get(nodeId);\n const proxy = proxyRef?.deref();\n if (proxy) {\n try {\n node.value = Array.isArray(proxy) ? '[' + proxy.length + ']' : '{' + Object.keys(proxy).length + '}';\n } catch { node.value = '(proxy)'; }\n }\n } else if (node.type !== 'effect' && signal.v !== undefined && typeof signal.v !== 'symbol') {\n try {\n const v = signal.v;\n if (typeof v === 'number' || typeof v === 'string' || typeof v === 'boolean' || v === null) {\n node.value = v;\n } else {\n node.value = '(object)';\n }\n } catch { /* ignore */ }\n }\n nodes.push(node);\n }\n\n // Map proxy internal signals to their proxy node ID\n for (const [nodeId, ref] of this._reactiveProxies) {\n const proxy = ref.deref();\n if (!proxy) { this._reactiveProxies.delete(nodeId); continue; }\n const meta = this._reactiveNodes.get(nodeId)?.meta;\n if (!meta || !this._instances.has(meta.componentId)) { this._reactiveProxies.delete(nodeId); continue; }\n }\n\n // Build edges from deps\n const edgeSet = new Set();\n for (const [nodeId, entry] of this._reactiveNodes) {\n const signal = entry.signal.deref();\n if (!signal) continue;\n if (!signal.deps) continue;\n\n const visited = new Set();\n const queue = [...signal.deps];\n while (queue.length > 0) {\n const dep = queue.shift();\n if (!dep || visited.has(dep)) continue;\n visited.add(dep);\n const depId = signalToId.get(dep);\n if (depId) {\n const key = depId + '>' + nodeId;\n if (depId !== nodeId && !edgeSet.has(key)) {\n edgeSet.add(key);\n edges.push({ from: depId, to: nodeId });\n }\n } else if (dep.deps) {\n for (const d of dep.deps) queue.push(d);\n }\n }\n }\n\n return { nodes, edges };\n },\n\n sendReactiveGraph() {\n const graph = this.getReactiveGraph();\n if (import.meta.hot) {\n import.meta.hot.send('svelte-devtools:reactive-graph', graph);\n }\n },\n\n // --- Phase 3: State Timeline ---\n\n _pollStateValues() {\n for (const [nodeId, entry] of this._reactiveNodes) {\n if (entry.meta.type !== 'state') continue;\n if (!this._instances.has(entry.meta.componentId)) {\n this._reactiveNodes.delete(nodeId);\n continue;\n }\n const signal = entry.signal.deref();\n if (!signal || signal.v === undefined) continue;\n try {\n const currentVal = signal.v;\n const prev = this._stateSnapshots.get(nodeId);\n if (prev !== undefined && currentVal === prev) continue;\n const isPrimitive = currentVal === null || typeof currentVal !== 'object';\n let newSnapshot;\n if (isPrimitive) {\n if (prev !== undefined && prev === currentVal) continue;\n newSnapshot = currentVal;\n } else {\n const currStr = JSON.stringify(currentVal);\n const prevStr = this._stateSnapshotStrs?.get(nodeId);\n if (prevStr === currStr) continue;\n newSnapshot = JSON.parse(currStr);\n if (!this._stateSnapshotStrs) this._stateSnapshotStrs = new Map();\n this._stateSnapshotStrs.set(nodeId, currStr);\n }\n if (this._stateTimeline.length >= 500) this._stateTimeline.splice(0, this._stateTimeline.length - 499);\n this._stateTimeline.push({\n id: nodeId,\n name: entry.meta.name,\n componentFile: entry.meta.componentFile,\n oldValue: prev !== undefined ? prev : null,\n newValue: newSnapshot,\n timestamp: Date.now(),\n });\n this._stateSnapshots.set(nodeId, newSnapshot);\n this._scheduleTimelineUpdate();\n } catch { /* ignore non-serializable */ }\n }\n },\n\n _scheduleTimelineUpdate() {\n if (this._timelineDebounceTimer) clearTimeout(this._timelineDebounceTimer);\n this._timelineDebounceTimer = setTimeout(() => {\n if (import.meta.hot) {\n import.meta.hot.send('svelte-devtools:state-timeline', { changes: this._stateTimeline });\n }\n }, 300);\n },\n\n getStateTimeline() {\n return this._stateTimeline;\n },\n\n clearStateTimeline() {\n this._stateTimeline = [];\n this._scheduleTimelineUpdate();\n },\n\n // --- FPS Monitoring ---\n // Uses requestAnimationFrame to measure frame rate with minimal overhead.\n // Only stores timestamps - no allocations per frame beyond a single array push.\n _fpsFrameTimes: [],\n\n _fpsLoop() {\n this._fpsFrameTimes.push(performance.now());\n requestAnimationFrame(() => this._fpsLoop());\n },\n\n _sampleFps() {\n const now = performance.now();\n // Remove frame timestamps older than 1 second\n const cutoff = now - 1000;\n let i = 0;\n while (i < this._fpsFrameTimes.length && this._fpsFrameTimes[i] < cutoff) i++;\n if (i > 0) this._fpsFrameTimes.splice(0, i);\n const fps = this._fpsFrameTimes.length;\n if (import.meta.hot) {\n import.meta.hot.send('svelte-devtools:fps', { timestamp: Date.now(), fps });\n }\n }\n };\n\n window.__SVELTE_DEVTOOLS__ = __SVELTE_DT;\n\n // Poll state values for timeline\n setInterval(() => { __SVELTE_DT._pollStateValues(); }, 200);\n\n // FPS monitoring\n requestAnimationFrame(() => __SVELTE_DT._fpsLoop());\n setInterval(() => __SVELTE_DT._sampleFps(), 500);\n\n // Phase 3: Capture runtime errors\n window.addEventListener('error', (event) => {\n if (import.meta.hot) {\n import.meta.hot.send('svelte-devtools:runtime-error', {\n message: event.message,\n file: event.filename,\n line: event.lineno,\n column: event.colno,\n stack: event.error?.stack || '',\n timestamp: Date.now(),\n });\n }\n });\n window.addEventListener('unhandledrejection', (event) => {\n if (import.meta.hot) {\n const reason = event.reason;\n import.meta.hot.send('svelte-devtools:runtime-error', {\n message: reason?.message || String(reason),\n stack: reason?.stack || '',\n timestamp: Date.now(),\n });\n }\n });\n\n // Listen for reactive graph requests from server\n if (import.meta.hot) {\n import.meta.hot.on('svelte-devtools:request-reactive-graph', () => {\n __SVELTE_DT.sendReactiveGraph();\n });\n import.meta.hot.on('svelte-devtools:request-state-timeline', () => {\n import.meta.hot.send('svelte-devtools:state-timeline', { changes: __SVELTE_DT._stateTimeline });\n });\n import.meta.hot.on('svelte-devtools:clear-state-timeline', () => {\n __SVELTE_DT.clearStateTimeline();\n });\n }\n}\n", I = e.dirname(i(import.meta.url));
|
|
259
|
+
function L(e) {
|
|
260
|
+
let t;
|
|
261
|
+
try {
|
|
262
|
+
t = new URL(e);
|
|
263
|
+
} catch {
|
|
264
|
+
throw Error(`Invalid URL: ${e}`);
|
|
265
|
+
}
|
|
266
|
+
if (t.protocol !== "http:" && t.protocol !== "https:") throw Error(`Blocked URL scheme: ${t.protocol}`);
|
|
267
|
+
let r = t.hostname;
|
|
268
|
+
if (r === "::1" || r === "[::1]") throw Error("Blocked: loopback address");
|
|
269
|
+
if (n.isIP(r)) {
|
|
270
|
+
if (R(r)) throw Error(`Blocked: private IP address ${r}`);
|
|
271
|
+
} else {
|
|
272
|
+
let e = r.toLowerCase();
|
|
273
|
+
if (e === "localhost" || e.endsWith(".local") || e.endsWith(".internal")) throw Error(`Blocked: internal hostname ${r}`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function R(e) {
|
|
277
|
+
let t = e.split(".").map(Number);
|
|
278
|
+
return !!(t.length === 4 && (t[0] === 127 || t[0] === 10 || t[0] === 172 && t[1] >= 16 && t[1] <= 31 || t[0] === 192 && t[1] === 168 || t[0] === 169 && t[1] === 254 || t.every((e) => e === 0)));
|
|
279
|
+
}
|
|
280
|
+
function z(n = {}) {
|
|
281
|
+
let { componentTracking: i = !0 } = n, o, s, l, u = r.randomUUID();
|
|
282
|
+
function d(n) {
|
|
283
|
+
if (typeof n != "string" || n.length === 0) throw Error("Invalid file path");
|
|
284
|
+
let r = t.realpathSync(l), i = e.isAbsolute(n) ? n : e.resolve(l, n), a;
|
|
285
|
+
try {
|
|
286
|
+
a = t.realpathSync(i);
|
|
287
|
+
} catch {
|
|
288
|
+
throw Error("File not found");
|
|
289
|
+
}
|
|
290
|
+
if (a !== r && !a.startsWith(r + e.sep)) throw Error("Forbidden: path outside project root");
|
|
291
|
+
return a;
|
|
292
|
+
}
|
|
293
|
+
let f = [], h = [], g = [], _ = {
|
|
294
|
+
nodes: [],
|
|
295
|
+
edges: []
|
|
296
|
+
}, v = [], y = [], x = [], S = [], C = [], w = [], E = null;
|
|
297
|
+
function D() {
|
|
298
|
+
return E || (E = {
|
|
299
|
+
"svelte-devtools:get-project": async () => b(l),
|
|
300
|
+
"svelte-devtools:get-routes": async () => c(b(l).routesDir),
|
|
301
|
+
"svelte-devtools:get-assets": async () => m(b(l).staticDir),
|
|
302
|
+
"svelte-devtools:get-component-relations": async () => T(l),
|
|
303
|
+
"svelte-devtools:get-live-components": async () => f,
|
|
304
|
+
"svelte-devtools:open-in-editor": async (e, t) => {
|
|
305
|
+
let n = d(String(e));
|
|
306
|
+
t && Number(t) > 0 ? a("code", ["--goto", `${n}:${Number(t)}`]) : a("code", [n]);
|
|
307
|
+
},
|
|
308
|
+
"svelte-devtools:open-reactive-in-editor": async (e, n, r) => {
|
|
309
|
+
let i = d(String(e)), o = 0;
|
|
310
|
+
try {
|
|
311
|
+
let e = t.readFileSync(i, "utf-8").split("\n");
|
|
312
|
+
if (String(r) === "effect") {
|
|
313
|
+
for (let t = 0; t < e.length; t++) if (e[t].includes("$effect(") || e[t].includes("$effect.pre(")) {
|
|
314
|
+
o = t + 1;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
let t = String(n).replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), r = RegExp(`(?:let|const|var)\\s+${t}\\b`);
|
|
319
|
+
for (let t = 0; t < e.length; t++) if (r.test(e[t])) {
|
|
320
|
+
o = t + 1;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} catch {}
|
|
325
|
+
o > 0 ? a("code", ["--goto", `${i}:${o}`]) : a("code", [i]);
|
|
326
|
+
},
|
|
327
|
+
"svelte-devtools:get-render-profiles": async () => h,
|
|
328
|
+
"svelte-devtools:get-reactive-graph": async () => s ? (s.hot.send("svelte-devtools:request-reactive-graph", {}), new Promise((e) => {
|
|
329
|
+
let t = !1, n = (n) => {
|
|
330
|
+
t || (t = !0, clearTimeout(r), e(n));
|
|
331
|
+
}, r = setTimeout(() => {
|
|
332
|
+
t = !0;
|
|
333
|
+
let r = v.indexOf(n);
|
|
334
|
+
r !== -1 && v.splice(r, 1), e(_);
|
|
335
|
+
}, 1e3);
|
|
336
|
+
v.push(n);
|
|
337
|
+
})) : _,
|
|
338
|
+
"svelte-devtools:get-load-profiles": async () => g,
|
|
339
|
+
"svelte-devtools:clear-load-profiles": async () => {
|
|
340
|
+
g = [];
|
|
341
|
+
},
|
|
342
|
+
"svelte-devtools:get-state-timeline": async () => s ? (s.hot.send("svelte-devtools:request-state-timeline", {}), new Promise((e) => {
|
|
343
|
+
let t = !1, n = (n) => {
|
|
344
|
+
t || (t = !0, clearTimeout(r), e(n));
|
|
345
|
+
}, r = setTimeout(() => {
|
|
346
|
+
t = !0;
|
|
347
|
+
let r = x.indexOf(n);
|
|
348
|
+
r !== -1 && x.splice(r, 1), e(y);
|
|
349
|
+
}, 1e3);
|
|
350
|
+
x.push(n);
|
|
351
|
+
})) : y,
|
|
352
|
+
"svelte-devtools:clear-state-timeline": async () => {
|
|
353
|
+
y = [], s?.hot.send("svelte-devtools:clear-state-timeline", {});
|
|
354
|
+
},
|
|
355
|
+
"svelte-devtools:get-api-endpoints": async () => {
|
|
356
|
+
let e = c(b(l).routesDir), n = [];
|
|
357
|
+
for (let r of e) {
|
|
358
|
+
let e = r.files.find((e) => e.type === "endpoint");
|
|
359
|
+
if (e) {
|
|
360
|
+
let i = "";
|
|
361
|
+
try {
|
|
362
|
+
i = t.readFileSync(e.path, "utf-8");
|
|
363
|
+
} catch {}
|
|
364
|
+
let a = [];
|
|
365
|
+
for (let e of [
|
|
366
|
+
"GET",
|
|
367
|
+
"POST",
|
|
368
|
+
"PUT",
|
|
369
|
+
"PATCH",
|
|
370
|
+
"DELETE"
|
|
371
|
+
]) (i.includes(`export const ${e}`) || i.includes(`export async function ${e}`) || i.includes(`export function ${e}`)) && a.push(e);
|
|
372
|
+
a.length === 0 && a.push("GET"), n.push({
|
|
373
|
+
route: r.id,
|
|
374
|
+
path: r.path,
|
|
375
|
+
methods: a,
|
|
376
|
+
file: e.path
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return n;
|
|
381
|
+
},
|
|
382
|
+
"svelte-devtools:send-api-request": async (e, t, n, r) => {
|
|
383
|
+
let i = performance.now();
|
|
384
|
+
try {
|
|
385
|
+
L(String(e));
|
|
386
|
+
let a = n ? JSON.parse(String(n)) : {}, o = {
|
|
387
|
+
method: String(t),
|
|
388
|
+
headers: a
|
|
389
|
+
};
|
|
390
|
+
r && String(t) !== "GET" && String(t) !== "HEAD" && (o.body = String(r));
|
|
391
|
+
let s = await fetch(String(e), o), c = await s.text(), l = {};
|
|
392
|
+
return s.headers.forEach((e, t) => {
|
|
393
|
+
l[t] = e;
|
|
394
|
+
}), {
|
|
395
|
+
status: s.status,
|
|
396
|
+
statusText: s.statusText,
|
|
397
|
+
headers: l,
|
|
398
|
+
body: c,
|
|
399
|
+
duration: Math.round((performance.now() - i) * 100) / 100
|
|
400
|
+
};
|
|
401
|
+
} catch (e) {
|
|
402
|
+
return {
|
|
403
|
+
status: 0,
|
|
404
|
+
statusText: String(e),
|
|
405
|
+
headers: {},
|
|
406
|
+
body: "",
|
|
407
|
+
duration: Math.round((performance.now() - i) * 100) / 100
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
"svelte-devtools:get-compiler-warnings": async () => S,
|
|
412
|
+
"svelte-devtools:get-runtime-errors": async () => C,
|
|
413
|
+
"svelte-devtools:clear-errors": async () => {
|
|
414
|
+
S = [], C = [];
|
|
415
|
+
},
|
|
416
|
+
"svelte-devtools:get-svelte-files": async () => T(l).map((e) => ({
|
|
417
|
+
file: e.file,
|
|
418
|
+
name: e.name
|
|
419
|
+
})),
|
|
420
|
+
"svelte-devtools:inspect-file": async (e) => {
|
|
421
|
+
let n = String(e), r;
|
|
422
|
+
try {
|
|
423
|
+
r = d(n);
|
|
424
|
+
} catch {
|
|
425
|
+
return {
|
|
426
|
+
source: "",
|
|
427
|
+
compiled: "",
|
|
428
|
+
file: n
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
let i = "";
|
|
432
|
+
try {
|
|
433
|
+
i = t.readFileSync(r, "utf-8");
|
|
434
|
+
} catch {
|
|
435
|
+
return {
|
|
436
|
+
source: "",
|
|
437
|
+
compiled: "",
|
|
438
|
+
file: n
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
let a = "", o, c;
|
|
442
|
+
if (s) try {
|
|
443
|
+
let e = await s.transformRequest(r);
|
|
444
|
+
if (a = e?.code || "", e?.map) {
|
|
445
|
+
let t = typeof e.map == "string" ? JSON.parse(e.map) : e.map;
|
|
446
|
+
o = t.mappings, c = t.sources;
|
|
447
|
+
}
|
|
448
|
+
} catch {
|
|
449
|
+
a = "// Transform failed";
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
source: i,
|
|
453
|
+
compiled: a,
|
|
454
|
+
file: n,
|
|
455
|
+
mappings: o,
|
|
456
|
+
sources: c
|
|
457
|
+
};
|
|
458
|
+
},
|
|
459
|
+
"svelte-devtools:get-module-graph": async () => k(),
|
|
460
|
+
"svelte-devtools:get-og-preview": async (e) => A(String(e)),
|
|
461
|
+
"svelte-devtools:get-build-analysis": async () => R(),
|
|
462
|
+
"svelte-devtools:get-fps": async () => w,
|
|
463
|
+
"svelte-devtools:clear-fps": async () => {
|
|
464
|
+
w = [];
|
|
465
|
+
}
|
|
466
|
+
}, E);
|
|
467
|
+
}
|
|
468
|
+
let O = {
|
|
469
|
+
name: "vite-devtools-svelte",
|
|
470
|
+
enforce: "pre",
|
|
471
|
+
api: { getDevtoolsToken: () => u },
|
|
472
|
+
configResolved(e) {
|
|
473
|
+
o = e, l = o.root;
|
|
474
|
+
},
|
|
475
|
+
configureServer(n) {
|
|
476
|
+
s = n;
|
|
477
|
+
let r = 5e3, i = 5e3, a = 5e3, c = 2e4;
|
|
478
|
+
s.hot.on("svelte-devtools:components", (e) => {
|
|
479
|
+
let t = Array.isArray(e?.components) ? e.components : [];
|
|
480
|
+
f = t.length > r ? t.slice(-r) : t;
|
|
481
|
+
}), s.hot.on("svelte-devtools:profiles", (e) => {
|
|
482
|
+
let t = Array.isArray(e?.profiles) ? e.profiles : [];
|
|
483
|
+
h = t.length > i ? t.slice(-i) : t;
|
|
484
|
+
}), s.hot.on("svelte-devtools:state-timeline", (e) => {
|
|
485
|
+
let t = Array.isArray(e?.changes) ? e.changes : [];
|
|
486
|
+
y = t.length > 500 ? t.slice(-500) : t;
|
|
487
|
+
let n = x;
|
|
488
|
+
x = [];
|
|
489
|
+
for (let e of n) e(y);
|
|
490
|
+
}), s.hot.on("svelte-devtools:fps", (e) => {
|
|
491
|
+
w.push(e), w.length > 1200 && (w = w.slice(-1200));
|
|
492
|
+
}), s.hot.on("svelte-devtools:runtime-error", (e) => {
|
|
493
|
+
C.push(e), C.length > 200 && (C = C.slice(-200));
|
|
494
|
+
}), s.hot.on("svelte-devtools:reactive-graph", (e) => {
|
|
495
|
+
let t = Array.isArray(e?.nodes) ? e.nodes : [], n = Array.isArray(e?.edges) ? e.edges : [];
|
|
496
|
+
_ = {
|
|
497
|
+
nodes: t.length > a ? t.slice(0, a) : t,
|
|
498
|
+
edges: n.length > c ? n.slice(0, c) : n
|
|
499
|
+
};
|
|
500
|
+
let r = v;
|
|
501
|
+
v = [];
|
|
502
|
+
for (let e of r) e(_);
|
|
503
|
+
});
|
|
504
|
+
let d = () => {
|
|
505
|
+
let e = /* @__PURE__ */ new Set(), t = s?.config?.server ?? o?.server, n = t?.port ?? 5173, r = t?.https ? "https" : "http";
|
|
506
|
+
for (let t of [
|
|
507
|
+
"localhost",
|
|
508
|
+
"127.0.0.1",
|
|
509
|
+
"[::1]"
|
|
510
|
+
]) e.add(`${r}://${t}`), e.add(`${r}://${t}:${n}`);
|
|
511
|
+
return e;
|
|
512
|
+
}, m = (e) => {
|
|
513
|
+
let t = d(), n = e.headers.origin, r = e.headers.referer, i = (() => {
|
|
514
|
+
if (typeof n == "string" && n) return n;
|
|
515
|
+
if (typeof r == "string" && r) try {
|
|
516
|
+
return new URL(r).origin;
|
|
517
|
+
} catch {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
return null;
|
|
521
|
+
})();
|
|
522
|
+
if (i !== null && !t.has(i)) return !1;
|
|
523
|
+
let a = e.headers["x-svelte-devtools-token"];
|
|
524
|
+
return (Array.isArray(a) ? a[0] : a) === u;
|
|
525
|
+
}, g = e.resolve(I, "client");
|
|
526
|
+
s.middlewares.use("/.svelte-devtools", (n, r, i) => {
|
|
527
|
+
let a = (n.url || "/").split("?")[0], o = a === "/" || a === "" || a === "/index.html", s = o ? e.join(g, "index.html") : e.join(g, a);
|
|
528
|
+
try {
|
|
529
|
+
if (t.statSync(s).isFile()) {
|
|
530
|
+
let n = e.extname(s).toLowerCase();
|
|
531
|
+
if (r.setHeader("Content-Type", p[n] || "application/octet-stream"), o) {
|
|
532
|
+
let e = t.readFileSync(s, "utf-8"), n = `<meta name="svelte-devtools-token" content="${u}">`, i = e.includes("</head>") ? e.replace("</head>", ` ${n}\n</head>`) : `${n}\n${e}`;
|
|
533
|
+
r.end(i);
|
|
534
|
+
} else t.createReadStream(s).pipe(r);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
} catch {}
|
|
538
|
+
i();
|
|
539
|
+
}), s.middlewares.use("/__svelte-devtools/rpc", (e, t) => {
|
|
540
|
+
if (e.method !== "POST") {
|
|
541
|
+
t.statusCode = 405, t.end("Method not allowed");
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
if (!m(e)) {
|
|
545
|
+
t.statusCode = 403, t.end("Forbidden");
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
let n = e.headers["content-type"], r = Array.isArray(n) ? n[0] : n;
|
|
549
|
+
if (!r || !r.includes("application/json")) {
|
|
550
|
+
t.statusCode = 415, t.end("Unsupported Media Type");
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
let i = "", a = !1;
|
|
554
|
+
e.on("data", (e) => {
|
|
555
|
+
a || (i += e.toString(), i.length > 1e6 && (a = !0, t.statusCode = 413, t.end("Payload Too Large")));
|
|
556
|
+
}), e.on("end", async () => {
|
|
557
|
+
if (!a) try {
|
|
558
|
+
let { method: e, args: n } = JSON.parse(i), r = D()[e];
|
|
559
|
+
if (!r) throw Error(`Unknown RPC method: ${e}`);
|
|
560
|
+
let a = await r(...n);
|
|
561
|
+
t.setHeader("Content-Type", "application/json"), t.end(JSON.stringify(a));
|
|
562
|
+
} catch (e) {
|
|
563
|
+
t.statusCode = 500, t.end(JSON.stringify({ error: String(e) }));
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
}), s.middlewares.use("/__svelte-devtools/asset", (n, r) => {
|
|
567
|
+
if (!m(n)) {
|
|
568
|
+
r.statusCode = 403, r.end("Forbidden");
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
let i = n.url || "", a = i.indexOf("?"), o = a >= 0 ? i.slice(a) : "", s = new URLSearchParams(o).get("path");
|
|
572
|
+
if (!s) {
|
|
573
|
+
r.statusCode = 400, r.end("Missing path parameter");
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
let c = b(l), u = t.realpathSync(c.staticDir), d = e.resolve(s), f;
|
|
577
|
+
try {
|
|
578
|
+
f = t.realpathSync(d);
|
|
579
|
+
} catch {
|
|
580
|
+
r.statusCode = 404, r.end("Not found");
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
if (!f.startsWith(u + e.sep) && f !== u) {
|
|
584
|
+
r.statusCode = 403, r.end("Forbidden");
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
try {
|
|
588
|
+
if (!t.statSync(f).isFile()) throw Error("Not a file");
|
|
589
|
+
let n = e.extname(f).toLowerCase();
|
|
590
|
+
r.setHeader("Content-Type", p[n] || "application/octet-stream"), t.createReadStream(f).pipe(r);
|
|
591
|
+
} catch {
|
|
592
|
+
r.statusCode = 404, r.end("Not found");
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
},
|
|
596
|
+
resolveId(e, t) {
|
|
597
|
+
if (o?.command === "serve") {
|
|
598
|
+
if (e === "virtual:svelte-devtools-runtime") return M;
|
|
599
|
+
if (i && e === "svelte/internal/client" && t && !t.includes("node_modules") && !t.startsWith("\0")) return N;
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
load(e) {
|
|
603
|
+
if (o?.command === "serve") {
|
|
604
|
+
if (e === "\0virtual:svelte-devtools-runtime") return F;
|
|
605
|
+
if (e === "\0svelte-devtools:wrapped-client") return P;
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
transformIndexHtml() {
|
|
609
|
+
return o.command === "serve" ? [{
|
|
610
|
+
tag: "script",
|
|
611
|
+
attrs: { type: "module" },
|
|
612
|
+
children: `import '${j}'`,
|
|
613
|
+
injectTo: "head-prepend"
|
|
614
|
+
}] : [];
|
|
615
|
+
},
|
|
616
|
+
devtools: { setup(t) {
|
|
617
|
+
let n = e.resolve(I, "client");
|
|
618
|
+
t.views.hostStatic("/.svelte-devtools/", n), t.docks.register({
|
|
619
|
+
id: "svelte-devtools",
|
|
620
|
+
title: "Svelte",
|
|
621
|
+
icon: "simple-icons:svelte",
|
|
622
|
+
type: "iframe",
|
|
623
|
+
url: "/.svelte-devtools/",
|
|
624
|
+
category: "framework"
|
|
625
|
+
});
|
|
626
|
+
let r = D();
|
|
627
|
+
for (let [e, n] of Object.entries(r)) t.rpc.register({
|
|
628
|
+
name: e,
|
|
629
|
+
handler: n
|
|
630
|
+
});
|
|
631
|
+
} }
|
|
632
|
+
};
|
|
633
|
+
function k() {
|
|
634
|
+
if (!s) return {
|
|
635
|
+
modules: [],
|
|
636
|
+
cycles: []
|
|
637
|
+
};
|
|
638
|
+
let n = [], r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = [];
|
|
639
|
+
try {
|
|
640
|
+
for (let e of Object.values(s.environments || {})) if (e && "moduleGraph" in e) {
|
|
641
|
+
let t = e.moduleGraph;
|
|
642
|
+
if (t?.idToModuleMap) for (let e of t.idToModuleMap.values()) a.push(e);
|
|
643
|
+
}
|
|
644
|
+
} catch {}
|
|
645
|
+
if (a.length === 0) try {
|
|
646
|
+
let e = s.moduleGraph;
|
|
647
|
+
if (e?.idToModuleMap) for (let t of e.idToModuleMap.values()) a.push(t);
|
|
648
|
+
} catch {}
|
|
649
|
+
for (let o of a) {
|
|
650
|
+
if (!o.file || o.file.includes("node_modules")) continue;
|
|
651
|
+
let a = e.relative(l, o.file);
|
|
652
|
+
if (a.startsWith("..") || r.has(o.file)) continue;
|
|
653
|
+
let s = e.extname(o.file).toLowerCase(), c = s === ".svelte" ? "svelte" : s === ".ts" || s === ".js" ? s === ".ts" ? "ts" : "js" : s === ".css" ? "css" : "other", u;
|
|
654
|
+
try {
|
|
655
|
+
u = t.statSync(o.file).size;
|
|
656
|
+
} catch {}
|
|
657
|
+
let d = {
|
|
658
|
+
id: a,
|
|
659
|
+
file: o.file,
|
|
660
|
+
type: c,
|
|
661
|
+
importedBy: [],
|
|
662
|
+
imports: [],
|
|
663
|
+
size: u
|
|
664
|
+
};
|
|
665
|
+
r.set(o.file, d), i.set(a, d), n.push(d);
|
|
666
|
+
}
|
|
667
|
+
for (let e of a) {
|
|
668
|
+
if (!e.file || !r.has(e.file)) continue;
|
|
669
|
+
let t = r.get(e.file), n = new Set(t.imports);
|
|
670
|
+
for (let i of e.importedModules) if (i.file && r.has(i.file)) {
|
|
671
|
+
let e = r.get(i.file), a = e.id;
|
|
672
|
+
n.has(a) || (n.add(a), t.imports.push(a)), e.importedBy.includes(t.id) || e.importedBy.push(t.id);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
let o = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = [];
|
|
676
|
+
function f(e) {
|
|
677
|
+
if (u.has(e)) {
|
|
678
|
+
let t = d.indexOf(e);
|
|
679
|
+
if (t >= 0 && d.length - t > 0) {
|
|
680
|
+
let n = d.slice(t).concat(e);
|
|
681
|
+
n.length > 2 && o.push(n);
|
|
682
|
+
}
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
if (c.has(e)) return;
|
|
686
|
+
c.add(e), u.add(e), d.push(e);
|
|
687
|
+
let t = i.get(e);
|
|
688
|
+
if (t) for (let e of t.imports) f(e);
|
|
689
|
+
d.pop(), u.delete(e);
|
|
690
|
+
}
|
|
691
|
+
for (let e of n) f(e.id);
|
|
692
|
+
let p = new Set(o.flat());
|
|
693
|
+
for (let e of n) p.has(e.id) && (e.isCyclic = !0);
|
|
694
|
+
return {
|
|
695
|
+
modules: n,
|
|
696
|
+
cycles: o
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
async function A(e) {
|
|
700
|
+
let t = {
|
|
701
|
+
url: e,
|
|
702
|
+
title: "",
|
|
703
|
+
description: "",
|
|
704
|
+
image: "",
|
|
705
|
+
tags: [],
|
|
706
|
+
issues: []
|
|
707
|
+
};
|
|
708
|
+
try {
|
|
709
|
+
L(e);
|
|
710
|
+
let n = await (await fetch(e)).text(), r = /<meta\s+([^>]*?)\/?>/gi, i = /(?:property|name)=["']([^"']+)["']/, a = /content=["']([^"']+)["']/, o;
|
|
711
|
+
for (; (o = r.exec(n)) !== null;) {
|
|
712
|
+
let e = o[1], n = e.match(i), r = e.match(a);
|
|
713
|
+
if (n && r) {
|
|
714
|
+
let e = n[1], i = r[1];
|
|
715
|
+
t.tags.push({
|
|
716
|
+
property: e,
|
|
717
|
+
content: i
|
|
718
|
+
}), e === "og:title" ? t.title = i : e === "og:description" ? t.description = i : e === "og:image" && (t.image = i);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (!t.title) {
|
|
722
|
+
let e = n.match(/<title>([^<]+)<\/title>/i);
|
|
723
|
+
e && (t.title = e[1]);
|
|
724
|
+
}
|
|
725
|
+
if (!t.description) {
|
|
726
|
+
let e = t.tags.find((e) => e.property === "description");
|
|
727
|
+
e && (t.description = e.content);
|
|
728
|
+
}
|
|
729
|
+
t.title || t.issues.push("Missing og:title or <title>"), t.description || t.issues.push("Missing og:description or meta description"), t.image || t.issues.push("Missing og:image"), t.tags.some((e) => e.property === "og:url") || t.issues.push("Missing og:url"), t.tags.some((e) => e.property === "og:type") || t.issues.push("Missing og:type");
|
|
730
|
+
} catch (e) {
|
|
731
|
+
t.issues.push(`Failed to fetch: ${String(e)}`);
|
|
732
|
+
}
|
|
733
|
+
return t;
|
|
734
|
+
}
|
|
735
|
+
function R() {
|
|
736
|
+
let n = e.resolve(l, ".svelte-kit/output"), r = e.resolve(l, "build/client"), i = [];
|
|
737
|
+
for (let a of [
|
|
738
|
+
n,
|
|
739
|
+
r,
|
|
740
|
+
e.resolve(l, "build")
|
|
741
|
+
]) try {
|
|
742
|
+
let n = (r) => {
|
|
743
|
+
for (let a of t.readdirSync(r, { withFileTypes: !0 })) {
|
|
744
|
+
let o = e.join(r, a.name);
|
|
745
|
+
if (a.isDirectory()) {
|
|
746
|
+
n(o);
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
let s = e.extname(a.name).toLowerCase();
|
|
750
|
+
if ([
|
|
751
|
+
".js",
|
|
752
|
+
".css",
|
|
753
|
+
".html"
|
|
754
|
+
].includes(s)) {
|
|
755
|
+
let n = t.statSync(o);
|
|
756
|
+
i.push({
|
|
757
|
+
name: a.name,
|
|
758
|
+
file: e.relative(l, o),
|
|
759
|
+
size: n.size,
|
|
760
|
+
modules: [],
|
|
761
|
+
isEntry: a.name.includes("index") || a.name.includes("start")
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
n(a);
|
|
767
|
+
} catch {}
|
|
768
|
+
return i.sort((e, t) => t.size - e.size), {
|
|
769
|
+
chunks: i,
|
|
770
|
+
totalSize: i.reduce((e, t) => e + t.size, 0),
|
|
771
|
+
timestamp: Date.now()
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
return [
|
|
775
|
+
O,
|
|
776
|
+
{
|
|
777
|
+
name: "vite-devtools-svelte:tracking",
|
|
778
|
+
enforce: "post",
|
|
779
|
+
transform(e, t) {
|
|
780
|
+
if (!i || !t.endsWith(".svelte") || t.includes("node_modules") || o?.command !== "serve" || !e.includes("$.push(")) return null;
|
|
781
|
+
let n = JSON.stringify(t);
|
|
782
|
+
return {
|
|
783
|
+
code: `import '${j}';\n` + e.replace(/(\$\.push\([^)]+\);?)/, `if (typeof window !== 'undefined' && window.__SVELTE_DEVTOOLS__) { window.__SVELTE_DEVTOOLS__._pendingFile = ${n}; }\n$1`),
|
|
784
|
+
map: null
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
name: "vite-devtools-svelte:load-profile",
|
|
790
|
+
enforce: "post",
|
|
791
|
+
transform(e, t) {
|
|
792
|
+
if (o?.command !== "serve") return null;
|
|
793
|
+
let n = /\+page\.server\.[tj]s$/.test(t) || /\+layout\.server\.[tj]s$/.test(t), r = /\+(page|layout)\.[tj]s$/.test(t) && !t.includes(".server.");
|
|
794
|
+
if (!n && !r || t.includes("node_modules") || !e.includes("export") || !e.includes("load")) return null;
|
|
795
|
+
let i = n ? "server" : "universal", a = t.match(/routes(.*)\/\+/), s = a && a[1] || "/", c = JSON.stringify(s), l = JSON.stringify(t), u = JSON.stringify(i), d = e.replace(/export\s+const\s+load\s*=\s*/, "const __original_load = ");
|
|
796
|
+
if (d === e && (d = e.replace(/export\s+(async\s+)?function\s+load\s*\(/, "const __original_load = $1function __load_impl(")), d === e) return null;
|
|
797
|
+
let f = `
|
|
798
|
+
export const load = async (event) => {
|
|
799
|
+
const __start = performance.now();
|
|
800
|
+
const __result = await __original_load(event);
|
|
801
|
+
const __duration = performance.now() - __start;
|
|
802
|
+
const __dataSize = JSON.stringify(__result || {}).length;
|
|
803
|
+
if (typeof globalThis.__svelte_devtools_record_load === 'function') {
|
|
804
|
+
globalThis.__svelte_devtools_record_load(${c}, ${l}, ${u}, __duration, __dataSize);
|
|
805
|
+
}
|
|
806
|
+
return __result;
|
|
807
|
+
};
|
|
808
|
+
`;
|
|
809
|
+
return {
|
|
810
|
+
code: d + f,
|
|
811
|
+
map: null
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
name: "vite-devtools-svelte:load-profile-server",
|
|
817
|
+
configureServer() {
|
|
818
|
+
globalThis.__svelte_devtools_record_load = (e, t, n, r, i) => {
|
|
819
|
+
g.push({
|
|
820
|
+
route: e,
|
|
821
|
+
file: t,
|
|
822
|
+
type: n,
|
|
823
|
+
duration: Math.round(r * 100) / 100,
|
|
824
|
+
dataSize: i,
|
|
825
|
+
timestamp: Date.now()
|
|
826
|
+
}), g.length > 200 && (g = g.slice(-200));
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
name: "vite-devtools-svelte:warning-capture",
|
|
832
|
+
enforce: "post",
|
|
833
|
+
configResolved(e) {
|
|
834
|
+
let t = e.logger.warn;
|
|
835
|
+
e.logger.warn = (e, n) => {
|
|
836
|
+
if (e.includes(".svelte") && o?.command === "serve") {
|
|
837
|
+
let t = e.match(/(?:^|\s)((?:\/|\.\/|\w:)[^\s:]+\.svelte)(?::(\d+):(\d+))?/), n = e.match(/\(([a-z0-9_-]+)\)/);
|
|
838
|
+
S.push({
|
|
839
|
+
code: n?.[1] || "unknown",
|
|
840
|
+
message: e.replace(/\x1b\[[0-9;]*m/g, "").trim(),
|
|
841
|
+
file: t?.[1] || "",
|
|
842
|
+
line: t?.[2] ? parseInt(t[2]) : void 0,
|
|
843
|
+
column: t?.[3] ? parseInt(t[3]) : void 0
|
|
844
|
+
}), S.length > 500 && (S = S.slice(-500));
|
|
845
|
+
}
|
|
846
|
+
t(e, n);
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
];
|
|
851
|
+
}
|
|
852
|
+
//#endregion
|
|
853
|
+
export { z as svelteDevtools };
|
|
854
|
+
|
|
855
|
+
//# sourceMappingURL=index.mjs.map
|