@qwik.dev/devtools 0.0.1 → 0.0.3
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/lib/devtools.css.qwik.cjs +3 -0
- package/lib/devtools.css.qwik.mjs +4 -0
- package/lib/devtools.qwik.cjs +538 -0
- package/lib/devtools.qwik.mjs +538 -0
- package/lib/index.qwik.cjs +2 -0
- package/lib/index.qwik.mjs +2 -0
- package/lib/kit/client.qwik.cjs +18 -0
- package/lib/kit/client.qwik.mjs +18 -0
- package/lib/kit/context.qwik.cjs +16 -0
- package/lib/kit/context.qwik.mjs +17 -1
- package/lib/kit/globals.qwik.cjs +4 -0
- package/lib/kit/globals.qwik.mjs +4 -0
- package/lib/plugin/index.qwik.cjs +2 -2
- package/lib/plugin/index.qwik.mjs +2 -2
- package/lib/utils/location.qwik.cjs +9 -0
- package/lib/utils/location.qwik.mjs +9 -0
- package/lib-types/index.d.ts +1 -0
- package/lib-types/utils/location.d.ts +1 -0
- package/package.json +1 -7
- package/src/devtools.tsx +3 -10
- package/src/index.ts +1 -0
- package/src/plugin/index.ts +2 -2
- package/src/utils/location.ts +9 -0
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import { jsxs, jsx } from "@qwik.dev/core/jsx-runtime";
|
|
2
|
+
import { component$, useStyles$, useStore, useSignal, useVisibleTask$, noSerialize } from "@qwik.dev/core";
|
|
3
|
+
import { tryCreateHotContext } from "vite-hot-client";
|
|
4
|
+
import { HiBoltOutline, HiCubeOutline, HiPhotoOutline } from "@qwikest/icons/heroicons";
|
|
5
|
+
import { LuFolderTree } from "@qwikest/icons/lucide";
|
|
6
|
+
import { createClientRpc } from "./kit/client.qwik.mjs";
|
|
7
|
+
import "superjson";
|
|
8
|
+
import "birpc";
|
|
9
|
+
import { setViteClientContext, getViteClientRpc } from "./kit/context.qwik.mjs";
|
|
10
|
+
import { Type } from "dree";
|
|
11
|
+
import styles from "./devtools.css.qwik.mjs";
|
|
12
|
+
import { getCurrentLocation } from "./utils/location.qwik.mjs";
|
|
13
|
+
function getClientRpcFunctions() {
|
|
14
|
+
return {
|
|
15
|
+
healthCheck: () => true
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const QwikDevtools = component$(() => {
|
|
19
|
+
useStyles$(styles);
|
|
20
|
+
const state = useStore({
|
|
21
|
+
isOpen: false,
|
|
22
|
+
activeTab: "overview",
|
|
23
|
+
npmPackages: [],
|
|
24
|
+
assets: [],
|
|
25
|
+
routes: void 0
|
|
26
|
+
});
|
|
27
|
+
const panelRef = useSignal();
|
|
28
|
+
const location = getCurrentLocation();
|
|
29
|
+
useVisibleTask$(async ({ cleanup, track }) => {
|
|
30
|
+
const hot = await tryCreateHotContext(void 0, [
|
|
31
|
+
"/"
|
|
32
|
+
]);
|
|
33
|
+
if (!hot) {
|
|
34
|
+
throw new Error("Vite Hot Context not connected");
|
|
35
|
+
}
|
|
36
|
+
setViteClientContext(hot);
|
|
37
|
+
createClientRpc(getClientRpcFunctions());
|
|
38
|
+
track(() => {
|
|
39
|
+
if (state.isOpen) {
|
|
40
|
+
const rpc = getViteClientRpc();
|
|
41
|
+
rpc.getAssetsFromPublicDir().then((data) => {
|
|
42
|
+
state.assets = data;
|
|
43
|
+
});
|
|
44
|
+
rpc.getRoutes().then((data) => {
|
|
45
|
+
const children = data.children || [];
|
|
46
|
+
const directories = children.filter((child) => child.type === "directory");
|
|
47
|
+
const values = [
|
|
48
|
+
{
|
|
49
|
+
relativePath: "",
|
|
50
|
+
name: "index",
|
|
51
|
+
type: Type.DIRECTORY,
|
|
52
|
+
path: "",
|
|
53
|
+
isSymbolicLink: false,
|
|
54
|
+
children: void 0
|
|
55
|
+
},
|
|
56
|
+
...directories
|
|
57
|
+
];
|
|
58
|
+
state.routes = noSerialize(values);
|
|
59
|
+
});
|
|
60
|
+
rpc.getQwikPackages().then((data) => {
|
|
61
|
+
state.npmPackages = data;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const handleKeyPress = (e) => {
|
|
66
|
+
if (e.key === "`" && e.metaKey) {
|
|
67
|
+
state.isOpen = !state.isOpen;
|
|
68
|
+
}
|
|
69
|
+
if (e.key === "Escape" && state.isOpen) {
|
|
70
|
+
state.isOpen = false;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const handleClickOutside = (e) => {
|
|
74
|
+
if (state.isOpen && panelRef.value && !panelRef.value.contains(e.target)) {
|
|
75
|
+
state.isOpen = false;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
window.addEventListener("keydown", handleKeyPress);
|
|
79
|
+
window.addEventListener("mousedown", handleClickOutside);
|
|
80
|
+
cleanup(() => {
|
|
81
|
+
window.removeEventListener("keydown", handleKeyPress);
|
|
82
|
+
window.removeEventListener("mousedown", handleClickOutside);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
86
|
+
class: {
|
|
87
|
+
"devtools-container": true,
|
|
88
|
+
"devtools-open": state.isOpen
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ jsx("div", {
|
|
92
|
+
class: {
|
|
93
|
+
"devtools-toggle": true,
|
|
94
|
+
"is-open": state.isOpen
|
|
95
|
+
},
|
|
96
|
+
onClick$: () => state.isOpen = !state.isOpen,
|
|
97
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
98
|
+
width: 20,
|
|
99
|
+
height: 20,
|
|
100
|
+
src: "https://qwik.dev/logos/qwik-logo.svg",
|
|
101
|
+
alt: "Qwik Logo",
|
|
102
|
+
class: "toggle-icon"
|
|
103
|
+
})
|
|
104
|
+
}),
|
|
105
|
+
state.isOpen && /* @__PURE__ */ jsxs("div", {
|
|
106
|
+
ref: panelRef,
|
|
107
|
+
class: "devtools-panel",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("div", {
|
|
110
|
+
class: "devtools-tabs",
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ jsx("button", {
|
|
113
|
+
class: {
|
|
114
|
+
"tab-active": state.activeTab === "overview"
|
|
115
|
+
},
|
|
116
|
+
onClick$: () => state.activeTab = "overview",
|
|
117
|
+
title: "Overview",
|
|
118
|
+
children: /* @__PURE__ */ jsx(HiBoltOutline, {
|
|
119
|
+
width: 20,
|
|
120
|
+
height: 20
|
|
121
|
+
})
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ jsx("button", {
|
|
124
|
+
class: {
|
|
125
|
+
"tab-active": state.activeTab === "components"
|
|
126
|
+
},
|
|
127
|
+
onClick$: () => state.activeTab = "components",
|
|
128
|
+
title: "Components",
|
|
129
|
+
children: /* @__PURE__ */ jsx(HiCubeOutline, {
|
|
130
|
+
width: 20,
|
|
131
|
+
height: 20
|
|
132
|
+
})
|
|
133
|
+
}),
|
|
134
|
+
/* @__PURE__ */ jsx("button", {
|
|
135
|
+
class: {
|
|
136
|
+
"tab-active": state.activeTab === "routes"
|
|
137
|
+
},
|
|
138
|
+
onClick$: () => state.activeTab = "routes",
|
|
139
|
+
title: "Routes",
|
|
140
|
+
children: /* @__PURE__ */ jsx(LuFolderTree, {
|
|
141
|
+
width: 20,
|
|
142
|
+
height: 20
|
|
143
|
+
})
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsx("button", {
|
|
146
|
+
class: {
|
|
147
|
+
"tab-active": state.activeTab === "state"
|
|
148
|
+
},
|
|
149
|
+
onClick$: () => state.activeTab = "state",
|
|
150
|
+
title: "State",
|
|
151
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
152
|
+
width: "20",
|
|
153
|
+
height: "20",
|
|
154
|
+
viewBox: "0 0 24 24",
|
|
155
|
+
fill: "none",
|
|
156
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx("path", {
|
|
159
|
+
d: "M12 2a7 7 0 0 1 7 7c0 2.38-1.19 4.47-3 5.74V17a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1v-2.26C6.19 13.47 5 11.38 5 9a7 7 0 0 1 7-7zm0 2a5 5 0 0 0-5 5c0 2.05 1.23 3.81 3 4.58V16h4v-2.42c1.77-.77 3-2.53 3-4.58a5 5 0 0 0-5-5z",
|
|
160
|
+
fill: "currentColor"
|
|
161
|
+
}),
|
|
162
|
+
/* @__PURE__ */ jsx("path", {
|
|
163
|
+
d: "M8 20v1h8v-1H8z",
|
|
164
|
+
fill: "currentColor"
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
}),
|
|
169
|
+
/* @__PURE__ */ jsx("button", {
|
|
170
|
+
class: {
|
|
171
|
+
"tab-active": state.activeTab === "assets"
|
|
172
|
+
},
|
|
173
|
+
onClick$: () => state.activeTab = "assets",
|
|
174
|
+
title: "Assets",
|
|
175
|
+
children: /* @__PURE__ */ jsx(HiPhotoOutline, {
|
|
176
|
+
width: 20,
|
|
177
|
+
height: 20
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ jsxs("div", {
|
|
183
|
+
class: "devtools-content",
|
|
184
|
+
children: [
|
|
185
|
+
state.activeTab === "overview" && /* @__PURE__ */ jsxs("div", {
|
|
186
|
+
class: "tab-content overview",
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ jsxs("div", {
|
|
189
|
+
class: "header-section",
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ jsxs("div", {
|
|
192
|
+
class: "title-container",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsx("img", {
|
|
195
|
+
width: 32,
|
|
196
|
+
height: 32,
|
|
197
|
+
src: "https://qwik.dev/logos/qwik-logo.svg",
|
|
198
|
+
alt: "Qwik Logo",
|
|
199
|
+
class: "qwik-logo"
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ jsx("h1", {
|
|
202
|
+
children: "Qwik DevTools"
|
|
203
|
+
})
|
|
204
|
+
]
|
|
205
|
+
}),
|
|
206
|
+
/* @__PURE__ */ jsxs("div", {
|
|
207
|
+
class: "version",
|
|
208
|
+
children: [
|
|
209
|
+
"v",
|
|
210
|
+
state.npmPackages.find(([name]) => name.includes("core"))?.[1] || "0.0.0"
|
|
211
|
+
]
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ jsxs("div", {
|
|
216
|
+
class: "metrics-grid",
|
|
217
|
+
children: [
|
|
218
|
+
/* @__PURE__ */ jsxs("div", {
|
|
219
|
+
class: "metric-card",
|
|
220
|
+
children: [
|
|
221
|
+
/* @__PURE__ */ jsx("div", {
|
|
222
|
+
class: "metric-icon",
|
|
223
|
+
children: /* @__PURE__ */ jsx(LuFolderTree, {
|
|
224
|
+
class: "icon"
|
|
225
|
+
})
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsxs("div", {
|
|
228
|
+
class: "metric-content",
|
|
229
|
+
children: [
|
|
230
|
+
/* @__PURE__ */ jsx("div", {
|
|
231
|
+
class: "metric-value",
|
|
232
|
+
children: state.routes?.length
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsx("div", {
|
|
235
|
+
class: "metric-label",
|
|
236
|
+
children: "pages"
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
})
|
|
240
|
+
]
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ jsxs("div", {
|
|
243
|
+
class: "metric-card",
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsx("div", {
|
|
246
|
+
class: "metric-icon",
|
|
247
|
+
children: /* @__PURE__ */ jsx(HiCubeOutline, {
|
|
248
|
+
class: "icon"
|
|
249
|
+
})
|
|
250
|
+
}),
|
|
251
|
+
/* @__PURE__ */ jsxs("div", {
|
|
252
|
+
class: "metric-content",
|
|
253
|
+
children: [
|
|
254
|
+
/* @__PURE__ */ jsx("div", {
|
|
255
|
+
class: "metric-value",
|
|
256
|
+
children: state.assets.length
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ jsx("div", {
|
|
259
|
+
class: "metric-label",
|
|
260
|
+
children: "components"
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
]
|
|
265
|
+
}),
|
|
266
|
+
/* @__PURE__ */ jsxs("div", {
|
|
267
|
+
class: "metric-card",
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ jsx("div", {
|
|
270
|
+
class: "metric-icon",
|
|
271
|
+
children: /* @__PURE__ */ jsx(HiPhotoOutline, {
|
|
272
|
+
class: "icon"
|
|
273
|
+
})
|
|
274
|
+
}),
|
|
275
|
+
/* @__PURE__ */ jsxs("div", {
|
|
276
|
+
class: "metric-content",
|
|
277
|
+
children: [
|
|
278
|
+
/* @__PURE__ */ jsx("div", {
|
|
279
|
+
class: "metric-value",
|
|
280
|
+
children: state.assets.length || 0
|
|
281
|
+
}),
|
|
282
|
+
/* @__PURE__ */ jsx("div", {
|
|
283
|
+
class: "metric-label",
|
|
284
|
+
children: "assets"
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
})
|
|
288
|
+
]
|
|
289
|
+
})
|
|
290
|
+
]
|
|
291
|
+
}),
|
|
292
|
+
/* @__PURE__ */ jsxs("div", {
|
|
293
|
+
class: "packages-section",
|
|
294
|
+
children: [
|
|
295
|
+
/* @__PURE__ */ jsx("h3", {
|
|
296
|
+
children: "Installed Packages"
|
|
297
|
+
}),
|
|
298
|
+
/* @__PURE__ */ jsx("div", {
|
|
299
|
+
class: "packages-grid",
|
|
300
|
+
children: state.npmPackages.map(([name, version]) => /* @__PURE__ */ jsxs("div", {
|
|
301
|
+
class: "package-item",
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx("div", {
|
|
304
|
+
class: "package-name",
|
|
305
|
+
children: name
|
|
306
|
+
}),
|
|
307
|
+
/* @__PURE__ */ jsxs("div", {
|
|
308
|
+
class: "package-version",
|
|
309
|
+
children: [
|
|
310
|
+
"v",
|
|
311
|
+
version
|
|
312
|
+
]
|
|
313
|
+
})
|
|
314
|
+
]
|
|
315
|
+
}, name))
|
|
316
|
+
})
|
|
317
|
+
]
|
|
318
|
+
}),
|
|
319
|
+
/* @__PURE__ */ jsxs("div", {
|
|
320
|
+
class: "performance-section",
|
|
321
|
+
children: [
|
|
322
|
+
/* @__PURE__ */ jsx("h3", {
|
|
323
|
+
children: "Performance"
|
|
324
|
+
}),
|
|
325
|
+
/* @__PURE__ */ jsxs("div", {
|
|
326
|
+
class: "performance-metrics",
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ jsxs("div", {
|
|
329
|
+
class: "perf-item",
|
|
330
|
+
children: [
|
|
331
|
+
/* @__PURE__ */ jsx("span", {
|
|
332
|
+
children: "SSR to full load"
|
|
333
|
+
}),
|
|
334
|
+
/* @__PURE__ */ jsx("span", {
|
|
335
|
+
class: "perf-value",
|
|
336
|
+
children: "-"
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
}),
|
|
340
|
+
/* @__PURE__ */ jsxs("div", {
|
|
341
|
+
class: "perf-item",
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsx("span", {
|
|
344
|
+
children: "Page load"
|
|
345
|
+
}),
|
|
346
|
+
/* @__PURE__ */ jsx("span", {
|
|
347
|
+
class: "perf-value",
|
|
348
|
+
children: "-"
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
}),
|
|
352
|
+
/* @__PURE__ */ jsxs("div", {
|
|
353
|
+
class: "perf-item",
|
|
354
|
+
children: [
|
|
355
|
+
/* @__PURE__ */ jsx("span", {
|
|
356
|
+
children: "Navigation"
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ jsx("span", {
|
|
359
|
+
class: "perf-value",
|
|
360
|
+
children: "-"
|
|
361
|
+
})
|
|
362
|
+
]
|
|
363
|
+
})
|
|
364
|
+
]
|
|
365
|
+
})
|
|
366
|
+
]
|
|
367
|
+
})
|
|
368
|
+
]
|
|
369
|
+
}),
|
|
370
|
+
state.activeTab === "assets" && /* @__PURE__ */ jsxs("div", {
|
|
371
|
+
class: "tab-content assets",
|
|
372
|
+
children: [
|
|
373
|
+
/* @__PURE__ */ jsxs("div", {
|
|
374
|
+
class: "header-section",
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ jsx("h3", {
|
|
377
|
+
children: "Public Assets"
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ jsxs("div", {
|
|
380
|
+
class: "assets-stats",
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ jsxs("span", {
|
|
383
|
+
class: "stat-item",
|
|
384
|
+
children: [
|
|
385
|
+
"Total Size:",
|
|
386
|
+
" ",
|
|
387
|
+
(state.assets?.reduce((acc, asset) => acc + asset.size, 0) / 1024).toFixed(2),
|
|
388
|
+
" ",
|
|
389
|
+
"KB"
|
|
390
|
+
]
|
|
391
|
+
}),
|
|
392
|
+
/* @__PURE__ */ jsxs("span", {
|
|
393
|
+
class: "stat-item",
|
|
394
|
+
children: [
|
|
395
|
+
"Count: ",
|
|
396
|
+
state.assets?.length || 0
|
|
397
|
+
]
|
|
398
|
+
})
|
|
399
|
+
]
|
|
400
|
+
})
|
|
401
|
+
]
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ jsx("div", {
|
|
404
|
+
class: "assets-grid",
|
|
405
|
+
children: state.assets?.map((asset) => {
|
|
406
|
+
const isImage = asset.path.match(/\.(jpg|jpeg|png|gif|svg|webp)$/i);
|
|
407
|
+
const fileExt = asset.path.split(".").pop()?.toUpperCase();
|
|
408
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
409
|
+
class: "asset-card",
|
|
410
|
+
children: [
|
|
411
|
+
isImage ? /* @__PURE__ */ jsx("div", {
|
|
412
|
+
class: "asset-preview",
|
|
413
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
414
|
+
width: 176,
|
|
415
|
+
height: 176,
|
|
416
|
+
src: asset.publicPath,
|
|
417
|
+
alt: asset.path
|
|
418
|
+
})
|
|
419
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
420
|
+
class: "file-preview",
|
|
421
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
422
|
+
class: "file-ext",
|
|
423
|
+
children: fileExt
|
|
424
|
+
})
|
|
425
|
+
}),
|
|
426
|
+
/* @__PURE__ */ jsxs("div", {
|
|
427
|
+
class: "asset-info",
|
|
428
|
+
children: [
|
|
429
|
+
/* @__PURE__ */ jsx("div", {
|
|
430
|
+
class: "asset-path",
|
|
431
|
+
title: asset.path,
|
|
432
|
+
children: asset.path.split("/").pop()
|
|
433
|
+
}),
|
|
434
|
+
/* @__PURE__ */ jsxs("div", {
|
|
435
|
+
class: "asset-meta",
|
|
436
|
+
children: [
|
|
437
|
+
/* @__PURE__ */ jsxs("span", {
|
|
438
|
+
class: "asset-size",
|
|
439
|
+
children: [
|
|
440
|
+
(asset.size / 1024).toFixed(2),
|
|
441
|
+
" KB"
|
|
442
|
+
]
|
|
443
|
+
}),
|
|
444
|
+
/* @__PURE__ */ jsx("span", {
|
|
445
|
+
class: "asset-type",
|
|
446
|
+
children: fileExt
|
|
447
|
+
})
|
|
448
|
+
]
|
|
449
|
+
})
|
|
450
|
+
]
|
|
451
|
+
})
|
|
452
|
+
]
|
|
453
|
+
}, asset.filePath);
|
|
454
|
+
})
|
|
455
|
+
})
|
|
456
|
+
]
|
|
457
|
+
}),
|
|
458
|
+
state.activeTab === "components" && /* @__PURE__ */ jsx("div", {
|
|
459
|
+
class: "tab-content",
|
|
460
|
+
children: /* @__PURE__ */ jsx("h3", {
|
|
461
|
+
children: "Components"
|
|
462
|
+
})
|
|
463
|
+
}),
|
|
464
|
+
state.activeTab === "routes" && /* @__PURE__ */ jsxs("div", {
|
|
465
|
+
class: "tab-content",
|
|
466
|
+
children: [
|
|
467
|
+
/* @__PURE__ */ jsx("h3", {
|
|
468
|
+
children: "Application Routes"
|
|
469
|
+
}),
|
|
470
|
+
/* @__PURE__ */ jsxs("div", {
|
|
471
|
+
class: "routes-table",
|
|
472
|
+
children: [
|
|
473
|
+
/* @__PURE__ */ jsxs("div", {
|
|
474
|
+
class: "table-header",
|
|
475
|
+
children: [
|
|
476
|
+
/* @__PURE__ */ jsx("div", {
|
|
477
|
+
class: "col-route",
|
|
478
|
+
children: "Route Path"
|
|
479
|
+
}),
|
|
480
|
+
/* @__PURE__ */ jsx("div", {
|
|
481
|
+
class: "col-route",
|
|
482
|
+
children: "Name"
|
|
483
|
+
}),
|
|
484
|
+
/* @__PURE__ */ jsx("div", {
|
|
485
|
+
class: "col-route",
|
|
486
|
+
children: "Middleware"
|
|
487
|
+
}),
|
|
488
|
+
/* @__PURE__ */ jsx("div", {
|
|
489
|
+
class: "col-route",
|
|
490
|
+
children: "Layout"
|
|
491
|
+
})
|
|
492
|
+
]
|
|
493
|
+
}),
|
|
494
|
+
state.routes?.map((route, i) => {
|
|
495
|
+
const children = route.children || [];
|
|
496
|
+
const layout = route.relativePath !== "" && route.type === "directory" && children.find((child) => child.name.startsWith("layout"));
|
|
497
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
498
|
+
class: "table-row",
|
|
499
|
+
children: [
|
|
500
|
+
/* @__PURE__ */ jsx("div", {
|
|
501
|
+
class: "col-route",
|
|
502
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
503
|
+
class: location === `/${route.relativePath}` ? "active-route" : "",
|
|
504
|
+
children: route.relativePath === "" ? "/" : `/${route.relativePath}/`
|
|
505
|
+
})
|
|
506
|
+
}),
|
|
507
|
+
/* @__PURE__ */ jsx("div", {
|
|
508
|
+
class: "col-route",
|
|
509
|
+
children: route.name
|
|
510
|
+
}),
|
|
511
|
+
/* @__PURE__ */ jsx("div", {
|
|
512
|
+
class: "col-route",
|
|
513
|
+
children: "-"
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ jsx("div", {
|
|
516
|
+
class: "col-route",
|
|
517
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
518
|
+
class: layout && i > 0 ? "custom-layout" : "",
|
|
519
|
+
children: layout && i > 0 ? `${route.relativePath}/layout` : "default"
|
|
520
|
+
})
|
|
521
|
+
})
|
|
522
|
+
]
|
|
523
|
+
}, route.relativePath);
|
|
524
|
+
})
|
|
525
|
+
]
|
|
526
|
+
})
|
|
527
|
+
]
|
|
528
|
+
})
|
|
529
|
+
]
|
|
530
|
+
})
|
|
531
|
+
]
|
|
532
|
+
})
|
|
533
|
+
]
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
export {
|
|
537
|
+
QwikDevtools
|
|
538
|
+
};
|
package/lib/index.qwik.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const index = require("./plugin/index.qwik.cjs");
|
|
4
|
+
const devtools = require("./devtools.qwik.cjs");
|
|
4
5
|
exports.qwikDevtools = index.qwikDevtools;
|
|
6
|
+
exports.QwikDevtools = devtools.QwikDevtools;
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const SuperJSON = require("superjson");
|
|
4
|
+
const birpc = require("birpc");
|
|
5
|
+
const constants = require("./constants.qwik.cjs");
|
|
6
|
+
const context = require("./context.qwik.cjs");
|
|
7
|
+
function createClientRpc(functions) {
|
|
8
|
+
const client = context.getViteClientContext();
|
|
9
|
+
const rpc = birpc.createBirpc(functions, {
|
|
10
|
+
post: (data) => client.send(constants.DEVTOOLS_VITE_MESSAGING_EVENT, SuperJSON.stringify(data)),
|
|
11
|
+
on: (fn) => client.on(constants.DEVTOOLS_VITE_MESSAGING_EVENT, (data) => {
|
|
12
|
+
fn(SuperJSON.parse(data));
|
|
13
|
+
}),
|
|
14
|
+
timeout: 12e4
|
|
15
|
+
});
|
|
16
|
+
context.setViteClientRpc(rpc);
|
|
17
|
+
}
|
|
18
|
+
exports.createClientRpc = createClientRpc;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import SuperJSON from "superjson";
|
|
2
|
+
import { createBirpc } from "birpc";
|
|
3
|
+
import { DEVTOOLS_VITE_MESSAGING_EVENT } from "./constants.qwik.mjs";
|
|
4
|
+
import { setViteClientRpc, getViteClientContext } from "./context.qwik.mjs";
|
|
5
|
+
function createClientRpc(functions) {
|
|
6
|
+
const client = getViteClientContext();
|
|
7
|
+
const rpc = createBirpc(functions, {
|
|
8
|
+
post: (data) => client.send(DEVTOOLS_VITE_MESSAGING_EVENT, SuperJSON.stringify(data)),
|
|
9
|
+
on: (fn) => client.on(DEVTOOLS_VITE_MESSAGING_EVENT, (data) => {
|
|
10
|
+
fn(SuperJSON.parse(data));
|
|
11
|
+
}),
|
|
12
|
+
timeout: 12e4
|
|
13
|
+
});
|
|
14
|
+
setViteClientRpc(rpc);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
createClientRpc
|
|
18
|
+
};
|
package/lib/kit/context.qwik.cjs
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const shared = require("./shared.qwik.cjs");
|
|
4
4
|
const globals = require("./globals.qwik.cjs");
|
|
5
|
+
function getViteClientContext() {
|
|
6
|
+
return shared.target[globals.CLIENT_CTX];
|
|
7
|
+
}
|
|
8
|
+
function setViteClientContext(ctx) {
|
|
9
|
+
shared.target[globals.CLIENT_CTX] = ctx;
|
|
10
|
+
}
|
|
5
11
|
function getViteServerContext() {
|
|
6
12
|
return shared.target[globals.SERVER_CTX];
|
|
7
13
|
}
|
|
@@ -11,6 +17,16 @@ function setViteServerContext(ctx) {
|
|
|
11
17
|
function setViteServerRpc(rpc) {
|
|
12
18
|
shared.target[globals.SERVER_RPC] = rpc;
|
|
13
19
|
}
|
|
20
|
+
function getViteClientRpc() {
|
|
21
|
+
return shared.target[globals.CLIENT_RPC];
|
|
22
|
+
}
|
|
23
|
+
function setViteClientRpc(rpc) {
|
|
24
|
+
shared.target[globals.CLIENT_RPC] = rpc;
|
|
25
|
+
}
|
|
26
|
+
exports.getViteClientContext = getViteClientContext;
|
|
27
|
+
exports.getViteClientRpc = getViteClientRpc;
|
|
14
28
|
exports.getViteServerContext = getViteServerContext;
|
|
29
|
+
exports.setViteClientContext = setViteClientContext;
|
|
30
|
+
exports.setViteClientRpc = setViteClientRpc;
|
|
15
31
|
exports.setViteServerContext = setViteServerContext;
|
|
16
32
|
exports.setViteServerRpc = setViteServerRpc;
|
package/lib/kit/context.qwik.mjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { target } from "./shared.qwik.mjs";
|
|
2
|
-
import { SERVER_CTX, SERVER_RPC } from "./globals.qwik.mjs";
|
|
2
|
+
import { CLIENT_CTX, SERVER_CTX, CLIENT_RPC, SERVER_RPC } from "./globals.qwik.mjs";
|
|
3
|
+
function getViteClientContext() {
|
|
4
|
+
return target[CLIENT_CTX];
|
|
5
|
+
}
|
|
6
|
+
function setViteClientContext(ctx) {
|
|
7
|
+
target[CLIENT_CTX] = ctx;
|
|
8
|
+
}
|
|
3
9
|
function getViteServerContext() {
|
|
4
10
|
return target[SERVER_CTX];
|
|
5
11
|
}
|
|
@@ -9,8 +15,18 @@ function setViteServerContext(ctx) {
|
|
|
9
15
|
function setViteServerRpc(rpc) {
|
|
10
16
|
target[SERVER_RPC] = rpc;
|
|
11
17
|
}
|
|
18
|
+
function getViteClientRpc() {
|
|
19
|
+
return target[CLIENT_RPC];
|
|
20
|
+
}
|
|
21
|
+
function setViteClientRpc(rpc) {
|
|
22
|
+
target[CLIENT_RPC] = rpc;
|
|
23
|
+
}
|
|
12
24
|
export {
|
|
25
|
+
getViteClientContext,
|
|
26
|
+
getViteClientRpc,
|
|
13
27
|
getViteServerContext,
|
|
28
|
+
setViteClientContext,
|
|
29
|
+
setViteClientRpc,
|
|
14
30
|
setViteServerContext,
|
|
15
31
|
setViteServerRpc
|
|
16
32
|
};
|
package/lib/kit/globals.qwik.cjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const CLIENT_CTX = "__qwik_client_ctx__";
|
|
3
4
|
const SERVER_CTX = "__qwik_server_ctx__";
|
|
4
5
|
const SERVER_RPC = "__qwik_server_rpc__";
|
|
6
|
+
const CLIENT_RPC = "__qwik_client_rpc__";
|
|
7
|
+
exports.CLIENT_CTX = CLIENT_CTX;
|
|
8
|
+
exports.CLIENT_RPC = CLIENT_RPC;
|
|
5
9
|
exports.SERVER_CTX = SERVER_CTX;
|
|
6
10
|
exports.SERVER_RPC = SERVER_RPC;
|
package/lib/kit/globals.qwik.mjs
CHANGED