@nuxt/devtools-nightly 0.0.0 → 2.0.0-beta.0-28940159.3b2c84c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +129 -0
  3. package/cli.mjs +2 -0
  4. package/dist/chunks/analyze-build.mjs +58 -0
  5. package/dist/chunks/module-main.mjs +2044 -0
  6. package/dist/chunks/plugin-metrics.mjs +68 -0
  7. package/dist/chunks/timeline.mjs +73 -0
  8. package/dist/chunks/vite-inspect.mjs +57 -0
  9. package/dist/chunks/vscode.mjs +195 -0
  10. package/dist/chunks/vue-devtools.mjs +30 -0
  11. package/dist/chunks/vue-inspector.mjs +15 -0
  12. package/dist/client/200.html +20 -0
  13. package/dist/client/404.html +20 -0
  14. package/dist/client/_nuxt/__blank-f4f9nu4d.js +1 -0
  15. package/dist/client/_nuxt/analyze-build-d4ocz87m.js +1 -0
  16. package/dist/client/_nuxt/assets-accfst8t.js +16 -0
  17. package/dist/client/_nuxt/assets.css-hmxl533k.css +1 -0
  18. package/dist/client/_nuxt/builds/latest.json +1 -0
  19. package/dist/client/_nuxt/builds/meta/078b774d-b96e-484e-b4d5-b349c23c7fd7.json +1 -0
  20. package/dist/client/_nuxt/c5gs2ah3.js +17 -0
  21. package/dist/client/_nuxt/client-ihvctios.js +1 -0
  22. package/dist/client/_nuxt/code-diff.vue-dfkrd13w.js +8 -0
  23. package/dist/client/_nuxt/code-snippets.vue-lcfqth8k.js +1 -0
  24. package/dist/client/_nuxt/components-oghrvkye.js +1 -0
  25. package/dist/client/_nuxt/components-tree-knr0y8qe.js +1 -0
  26. package/dist/client/_nuxt/composable-item.vue-lu13s905.js +1 -0
  27. package/dist/client/_nuxt/constants-b32h69zq.js +1 -0
  28. package/dist/client/_nuxt/custom-_name_-fup3n0cu.js +1 -0
  29. package/dist/client/_nuxt/default-i1yqd2to.js +1 -0
  30. package/dist/client/_nuxt/duration-display.vue-e5ntxkcx.js +1 -0
  31. package/dist/client/_nuxt/entry.css-kxi58hys.css +1 -0
  32. package/dist/client/_nuxt/error-404-ci0xzyd6.js +1 -0
  33. package/dist/client/_nuxt/error-404.css-b3x40x40.css +1 -0
  34. package/dist/client/_nuxt/error-500-ny17oe9i.js +1 -0
  35. package/dist/client/_nuxt/error-500.css-hilpkhd4.css +1 -0
  36. package/dist/client/_nuxt/error-nhdqe6i6.js +9 -0
  37. package/dist/client/_nuxt/filepath-item.vue-mcgdbj53.js +1 -0
  38. package/dist/client/_nuxt/full-nb67w4v9.js +1 -0
  39. package/dist/client/_nuxt/help-fab.css-ms50khsu.css +1 -0
  40. package/dist/client/_nuxt/help-fab.vue-opvnmtcj.js +1 -0
  41. package/dist/client/_nuxt/hooks-kfudy7r2.js +1 -0
  42. package/dist/client/_nuxt/imports-eo3khgic.js +1 -0
  43. package/dist/client/_nuxt/index-m4vf8cbo.js +2 -0
  44. package/dist/client/_nuxt/index-ow49s53n.js +1 -0
  45. package/dist/client/_nuxt/launch-page.vue-iesvi41s.js +1 -0
  46. package/dist/client/_nuxt/modules-bjoacevh.js +1 -0
  47. package/dist/client/_nuxt/nbadge-hknag3xt.js +1 -0
  48. package/dist/client/_nuxt/ncheckbox.vue-ms3v2bv8.js +1 -0
  49. package/dist/client/_nuxt/ncode-block.css-c9cb29at.css +1 -0
  50. package/dist/client/_nuxt/ncode-block.vue-ls06c06q.js +2 -0
  51. package/dist/client/_nuxt/ndrawer.vue-pawnvrjc.js +1 -0
  52. package/dist/client/_nuxt/ndropdown.vue-dbst6ukt.js +1 -0
  53. package/dist/client/_nuxt/nicon-title.vue-ipq3avx6.js +1 -0
  54. package/dist/client/_nuxt/nlink.vue-e8l6ggyt.js +1 -0
  55. package/dist/client/_nuxt/nmarkdown.vue-lp7ya0j6.js +1 -0
  56. package/dist/client/_nuxt/nnavbar.vue-lykocirm.js +1 -0
  57. package/dist/client/_nuxt/none-dgqlebv3.js +1 -0
  58. package/dist/client/_nuxt/nsection-block-o11p8ted.js +1 -0
  59. package/dist/client/_nuxt/nsection-block.css-e7kbjm7k.css +1 -0
  60. package/dist/client/_nuxt/nselect-tabs.vue-otuk7xnz.js +1 -0
  61. package/dist/client/_nuxt/nselect.vue-bjzfjabo.js +1 -0
  62. package/dist/client/_nuxt/open-graph-bfgokib7.js +3 -0
  63. package/dist/client/_nuxt/open-graph.css-e21qzmvj.css +1 -0
  64. package/dist/client/_nuxt/overview-klilnch0.js +1 -0
  65. package/dist/client/_nuxt/pages-jvi3fi1o.js +1 -0
  66. package/dist/client/_nuxt/payload-nznxtz0n.js +1 -0
  67. package/dist/client/_nuxt/pinia-dvjxs68v.js +1 -0
  68. package/dist/client/_nuxt/plugins-1i3hudxm.js +1 -0
  69. package/dist/client/_nuxt/runtime-configs-zuvf8944.js +1 -0
  70. package/dist/client/_nuxt/server-route-inputs.vue-mus15xmu.js +1 -0
  71. package/dist/client/_nuxt/server-routes-g18npbq7.js +9 -0
  72. package/dist/client/_nuxt/server-tasks-mvftg09y.js +1 -0
  73. package/dist/client/_nuxt/settings-hux8x7fu.js +1 -0
  74. package/dist/client/_nuxt/stacktrace-list.vue-k97c53ud.js +1 -0
  75. package/dist/client/_nuxt/state-components-hjf5pd61.js +1 -0
  76. package/dist/client/_nuxt/state-editor.vue-h67wwxtf.js +1 -0
  77. package/dist/client/_nuxt/state-modules-c2e21x4m.js +1 -0
  78. package/dist/client/_nuxt/storage-fh94um93.js +1 -0
  79. package/dist/client/_nuxt/terminals-l9qfrdfc.js +1 -0
  80. package/dist/client/_nuxt/terminals.css-mejv43xm.css +1 -0
  81. package/dist/client/_nuxt/timeline-cb92pqd1.js +31 -0
  82. package/dist/client/_nuxt/timeline.css-lhkpu01p.css +1 -0
  83. package/dist/client/_nuxt/unocss-runtime-jzfgcoxk.js +1 -0
  84. package/dist/client/_nuxt/vendor/json-editor-vue-c3wisb33.js +3818 -0
  85. package/dist/client/_nuxt/vendor/json-editor-vue.css-mqq5uooj.css +1 -0
  86. package/dist/client/_nuxt/vendor/markdown-it-fvu08dbs.js +16 -0
  87. package/dist/client/_nuxt/vendor/shiki-bnvxb5wv.js +147 -0
  88. package/dist/client/_nuxt/vendor/unocss-3uirpnla.js +2 -0
  89. package/dist/client/_nuxt/vendor/unocss.css-mhvipxpl.css +1 -0
  90. package/dist/client/_nuxt/vendor/vis-dlwijd5n.js +98 -0
  91. package/dist/client/_nuxt/vendor/xterm-dbpzgj7s.js +9 -0
  92. package/dist/client/_nuxt/vendor/xterm.css-egmhki83.css +32 -0
  93. package/dist/client/_nuxt/virtual-files-idfl2dwx.js +1 -0
  94. package/dist/client/_nuxt/virtual-files.css-gqpg2wnb.css +1 -0
  95. package/dist/client/_nuxt/vue-virtual-scroller.esm-md1d6mcg.js +2 -0
  96. package/dist/client/index.html +20 -0
  97. package/dist/client/nuxt.svg +3 -0
  98. package/dist/dirs.d.mts +7 -0
  99. package/dist/dirs.d.ts +7 -0
  100. package/dist/dirs.mjs +28 -0
  101. package/dist/module.cjs +5 -0
  102. package/dist/module.d.mts +9 -0
  103. package/dist/module.d.ts +9 -0
  104. package/dist/module.json +9 -0
  105. package/dist/module.mjs +6 -0
  106. package/dist/runtime/auth/index.html +76 -0
  107. package/dist/runtime/function-metrics-helpers.d.ts +3 -0
  108. package/dist/runtime/function-metrics-helpers.js +69 -0
  109. package/dist/runtime/nitro/inline.d.ts +3 -0
  110. package/dist/runtime/nitro/inline.js +6 -0
  111. package/dist/runtime/plugins/devtools.client.d.ts +2 -0
  112. package/dist/runtime/plugins/devtools.client.js +56 -0
  113. package/dist/runtime/plugins/devtools.server.d.ts +2 -0
  114. package/dist/runtime/plugins/devtools.server.js +7 -0
  115. package/dist/runtime/plugins/view/FrameBox.vue +167 -0
  116. package/dist/runtime/plugins/view/Main.vue +422 -0
  117. package/dist/runtime/plugins/view/client.d.ts +12 -0
  118. package/dist/runtime/plugins/view/client.js +332 -0
  119. package/dist/runtime/plugins/view/state.d.ts +5 -0
  120. package/dist/runtime/plugins/view/state.js +17 -0
  121. package/dist/runtime/plugins/view/utils.d.ts +31 -0
  122. package/dist/runtime/plugins/view/utils.js +156 -0
  123. package/dist/runtime/settings.d.ts +4 -0
  124. package/dist/runtime/settings.js +2 -0
  125. package/dist/runtime/shared/hooks.d.ts +2 -0
  126. package/dist/runtime/shared/hooks.js +33 -0
  127. package/dist/runtime/use-nuxt-devtools.d.ts +8 -0
  128. package/dist/runtime/use-nuxt-devtools.js +23 -0
  129. package/dist/runtime/vue-devtools/overlay.d.ts +1 -0
  130. package/dist/runtime/vue-devtools/overlay.js +8 -0
  131. package/dist/shared/devtools-nightly.2a48a9e5.d.mts +62 -0
  132. package/dist/shared/devtools-nightly.2a48a9e5.d.ts +62 -0
  133. package/dist/shared/devtools-nightly.5ac54dae.mjs +121 -0
  134. package/dist/types.d.mts +42 -0
  135. package/dist/types.d.ts +42 -0
  136. package/dist/types.mjs +1 -0
  137. package/package.json +123 -2
  138. package/types.d.ts +1 -0
@@ -0,0 +1,332 @@
1
+ import { useAppConfig, useRuntimeConfig } from "#imports";
2
+ import { setIframeServerContext } from "@vue/devtools-kit";
3
+ import { createHooks } from "hookable";
4
+ import { debounce } from "perfect-debounce";
5
+ import { computed, createApp, h, markRaw, ref, shallowReactive, shallowRef, watch } from "vue";
6
+ import { initTimelineMetrics } from "../../function-metrics-helpers.js";
7
+ import Main from "./Main.vue";
8
+ import { popupWindow, state } from "./state.js";
9
+ const clientRef = shallowRef();
10
+ export { clientRef as client };
11
+ export async function setupDevToolsClient({
12
+ nuxt,
13
+ clientHooks,
14
+ timeMetric,
15
+ router
16
+ }) {
17
+ const isInspecting = ref(false);
18
+ const colorMode = useClientColorMode();
19
+ const timeline = initTimelineMetrics();
20
+ const client = shallowReactive({
21
+ nuxt: markRaw(nuxt),
22
+ hooks: createHooks(),
23
+ inspector: getInspectorInstance(),
24
+ getIframe,
25
+ syncClient,
26
+ devtools: {
27
+ toggle() {
28
+ if (state.value.open)
29
+ client.devtools.close();
30
+ else
31
+ client.devtools.open();
32
+ },
33
+ close() {
34
+ if (!state.value.open)
35
+ return;
36
+ state.value.open = false;
37
+ if (popupWindow.value) {
38
+ try {
39
+ popupWindow.value.close();
40
+ } catch {
41
+ }
42
+ popupWindow.value = null;
43
+ }
44
+ },
45
+ open() {
46
+ if (state.value.open)
47
+ return;
48
+ state.value.open = true;
49
+ },
50
+ async navigate(path) {
51
+ if (!state.value.open)
52
+ await client.devtools.open();
53
+ await client.hooks.callHook("host:action:navigate", path);
54
+ },
55
+ async reload() {
56
+ await client.hooks.callHook("host:action:reload");
57
+ }
58
+ },
59
+ app: {
60
+ appConfig: useAppConfig(),
61
+ reload() {
62
+ location.reload();
63
+ },
64
+ navigate(path, hard = false) {
65
+ if (hard)
66
+ location.href = path;
67
+ else
68
+ router.push(path);
69
+ },
70
+ colorMode,
71
+ frameState: state,
72
+ $fetch: globalThis.$fetch
73
+ },
74
+ metrics: {
75
+ clientPlugins: () => window.__NUXT_DEVTOOLS_PLUGINS_METRIC__,
76
+ clientHooks: () => Object.values(clientHooks),
77
+ clientTimeline: () => timeline,
78
+ loading: () => timeMetric
79
+ },
80
+ revision: ref(0)
81
+ });
82
+ window.__NUXT_DEVTOOLS_HOST__ = client;
83
+ let iframe;
84
+ function syncClient() {
85
+ if (!client.inspector)
86
+ client.inspector = getInspectorInstance();
87
+ try {
88
+ iframe?.contentWindow?.__NUXT_DEVTOOLS_VIEW__?.setClient(client);
89
+ } catch {
90
+ }
91
+ return client;
92
+ }
93
+ function getIframe() {
94
+ if (!iframe) {
95
+ const runtimeConfig = useRuntimeConfig();
96
+ const CLIENT_BASE = "/__nuxt_devtools__/client";
97
+ const CLIENT_PATH = `${runtimeConfig.app.baseURL.replace(CLIENT_BASE, "/")}${CLIENT_BASE}`.replace(/\/+/g, "/");
98
+ const initialUrl = CLIENT_PATH + state.value.route;
99
+ iframe = document.createElement("iframe");
100
+ for (const [key, value] of Object.entries(runtimeConfig.app.devtools?.iframeProps || {}))
101
+ iframe.setAttribute(key, String(value));
102
+ iframe.id = "nuxt-devtools-iframe";
103
+ iframe.src = initialUrl;
104
+ iframe.onload = async () => {
105
+ try {
106
+ setIframeServerContext(iframe);
107
+ await waitForClientInjection();
108
+ client.syncClient();
109
+ } catch (e) {
110
+ console.error("Nuxt DevTools client injection failed");
111
+ console.error(e);
112
+ }
113
+ };
114
+ }
115
+ return iframe;
116
+ }
117
+ function waitForClientInjection(retry = 20, timeout = 300) {
118
+ let lastError;
119
+ const test = () => {
120
+ try {
121
+ return !!iframe?.contentWindow?.__NUXT_DEVTOOLS_VIEW__;
122
+ } catch (e) {
123
+ lastError = e;
124
+ }
125
+ return false;
126
+ };
127
+ if (test())
128
+ return;
129
+ return new Promise((resolve, reject) => {
130
+ const interval = setInterval(() => {
131
+ if (test()) {
132
+ clearInterval(interval);
133
+ resolve();
134
+ } else if (retry-- <= 0) {
135
+ clearInterval(interval);
136
+ reject(lastError);
137
+ }
138
+ }, timeout);
139
+ });
140
+ }
141
+ function enableComponentInspector() {
142
+ window.__VUE_INSPECTOR__?.enable();
143
+ isInspecting.value = true;
144
+ }
145
+ function disableComponentInspector() {
146
+ if (!window.__VUE_INSPECTOR__?.enabled)
147
+ return;
148
+ window.__VUE_INSPECTOR__?.disable();
149
+ client?.hooks.callHook("host:inspector:close");
150
+ isInspecting.value = false;
151
+ }
152
+ function getInspectorInstance() {
153
+ const componentInspector = window.__VUE_INSPECTOR__;
154
+ if (componentInspector) {
155
+ componentInspector.openInEditor = async (url) => {
156
+ disableComponentInspector();
157
+ await client.hooks.callHook("host:inspector:click", url);
158
+ };
159
+ componentInspector.onUpdated = () => {
160
+ client.hooks.callHook("host:inspector:update", {
161
+ ...componentInspector.linkParams,
162
+ ...componentInspector.position
163
+ });
164
+ };
165
+ }
166
+ return markRaw({
167
+ isEnabled: isInspecting,
168
+ enable: enableComponentInspector,
169
+ disable: disableComponentInspector,
170
+ toggle: () => {
171
+ if (!state.value.open)
172
+ client.devtools.open();
173
+ if (window.__VUE_INSPECTOR__?.enabled)
174
+ disableComponentInspector();
175
+ else
176
+ enableComponentInspector();
177
+ },
178
+ instance: componentInspector
179
+ });
180
+ }
181
+ setupRouteTracking(timeline, router);
182
+ setupReactivity(client, router, timeline);
183
+ clientRef.value = client;
184
+ const documentPictureInPicture = window.documentPictureInPicture;
185
+ if (documentPictureInPicture?.requestWindow) {
186
+ client.devtools.popup = async () => {
187
+ const iframe2 = getIframe();
188
+ if (!iframe2)
189
+ return;
190
+ const pip = popupWindow.value = await documentPictureInPicture.requestWindow({
191
+ width: Math.round(window.innerWidth * state.value.width / 100),
192
+ height: Math.round(window.innerHeight * state.value.height / 100)
193
+ });
194
+ const style = pip.document.createElement("style");
195
+ style.innerHTML = `
196
+ body {
197
+ margin: 0;
198
+ padding: 0;
199
+ }
200
+ iframe {
201
+ width: 100vw;
202
+ height: 100vh;
203
+ border: none;
204
+ outline: none;
205
+ }
206
+ `;
207
+ pip.__NUXT_DEVTOOLS_DISABLE__ = true;
208
+ pip.__NUXT_DEVTOOLS_IS_POPUP__ = true;
209
+ pip.__NUXT__ = window.parent?.__NUXT__ || window.__NUXT__;
210
+ pip.document.title = "Nuxt DevTools";
211
+ pip.document.head.appendChild(style);
212
+ pip.document.body.appendChild(iframe2);
213
+ pip.addEventListener("resize", () => {
214
+ state.value.width = Math.round(pip.innerWidth / window.innerWidth * 100);
215
+ state.value.height = Math.round(pip.innerHeight / window.innerHeight * 100);
216
+ });
217
+ pip.addEventListener("pagehide", () => {
218
+ popupWindow.value = null;
219
+ pip.close();
220
+ });
221
+ };
222
+ }
223
+ const holder = document.createElement("div");
224
+ holder.id = "nuxt-devtools-container";
225
+ holder.setAttribute("data-v-inspector-ignore", "true");
226
+ document.body.appendChild(holder);
227
+ window.addEventListener("keydown", (e) => {
228
+ if (e.code === "KeyD" && e.altKey && e.shiftKey)
229
+ client.devtools.toggle();
230
+ });
231
+ const app = createApp({
232
+ render: () => h(Main, { client }),
233
+ devtools: {
234
+ hide: true
235
+ }
236
+ });
237
+ app.mount(holder);
238
+ }
239
+ export function useClientColorMode() {
240
+ const explicitColor = ref();
241
+ const systemColor = ref();
242
+ const elements = [
243
+ document.documentElement,
244
+ document.body
245
+ ];
246
+ const ob = new MutationObserver(getExplicitColor);
247
+ elements.forEach((el) => {
248
+ ob.observe(el, {
249
+ attributes: true,
250
+ attributeFilter: ["class"]
251
+ });
252
+ });
253
+ const preferDarkQuery = window.matchMedia("(prefers-color-scheme: dark)");
254
+ const preferLightQuery = window.matchMedia("(prefers-color-scheme: light)");
255
+ preferDarkQuery.addEventListener("change", getSystemColor);
256
+ preferLightQuery.addEventListener("change", getSystemColor);
257
+ function getExplicitColor() {
258
+ let color;
259
+ for (const el of elements) {
260
+ if (el.classList.contains("dark")) {
261
+ color = "dark";
262
+ break;
263
+ }
264
+ if (el.classList.contains("light")) {
265
+ color = "light";
266
+ break;
267
+ }
268
+ }
269
+ explicitColor.value = color;
270
+ }
271
+ function getSystemColor() {
272
+ if (preferDarkQuery.matches)
273
+ systemColor.value = "dark";
274
+ else if (preferLightQuery.matches)
275
+ systemColor.value = "light";
276
+ else
277
+ systemColor.value = void 0;
278
+ }
279
+ getExplicitColor();
280
+ getSystemColor();
281
+ return computed(() => explicitColor.value || systemColor.value || "light");
282
+ }
283
+ function setupRouteTracking(timeline, router) {
284
+ if (timeline.options.enabled && router?.currentRoute?.value?.path) {
285
+ const start = timeline.events[0]?.start || Date.now();
286
+ timeline.events.unshift({
287
+ type: "route",
288
+ from: router.currentRoute.value.path,
289
+ to: router.currentRoute.value.path,
290
+ start,
291
+ end: start
292
+ });
293
+ }
294
+ let lastRouteEvent;
295
+ router?.afterEach(() => {
296
+ if (lastRouteEvent && !lastRouteEvent?.end)
297
+ lastRouteEvent.end = Date.now();
298
+ });
299
+ router?.beforeEach((to, from) => {
300
+ if (!timeline.options.enabled)
301
+ return;
302
+ lastRouteEvent = {
303
+ type: "route",
304
+ from: from.path,
305
+ to: to.path,
306
+ start: Date.now()
307
+ };
308
+ timeline.events.push(lastRouteEvent);
309
+ });
310
+ }
311
+ function setupReactivity(client, router, timeMetric) {
312
+ const refreshReactivity = debounce(() => {
313
+ client.hooks.callHook("host:update:reactivity");
314
+ }, 100, { trailing: true });
315
+ watch(() => [
316
+ client.nuxt.payload,
317
+ client.app.colorMode.value,
318
+ client.metrics.loading(),
319
+ timeMetric
320
+ ], () => {
321
+ refreshReactivity();
322
+ }, { deep: true });
323
+ router?.afterEach(() => {
324
+ refreshReactivity();
325
+ });
326
+ client.nuxt.hook("app:mounted", () => {
327
+ refreshReactivity();
328
+ });
329
+ client.hooks.hook("devtools:navigate", (path) => {
330
+ state.value.route = path;
331
+ });
332
+ }
@@ -0,0 +1,5 @@
1
+ export declare const PANEL_PADDING = 10;
2
+ export declare const PANEL_MIN = 20;
3
+ export declare const PANEL_MAX = 100;
4
+ export declare const popupWindow: import("vue").ShallowRef<Window | null, Window | null>;
5
+ export declare const state: import("vue").Ref<DevToolsFrameState, DevToolsFrameState>;
@@ -0,0 +1,17 @@
1
+ import { shallowRef } from "vue";
2
+ import { useObjectStorage } from "./utils.js";
3
+ export const PANEL_PADDING = 10;
4
+ export const PANEL_MIN = 20;
5
+ export const PANEL_MAX = 100;
6
+ export const popupWindow = shallowRef(null);
7
+ export const state = useObjectStorage("nuxt-devtools-frame-state", {
8
+ width: 80,
9
+ height: 60,
10
+ top: 0,
11
+ left: 50,
12
+ open: false,
13
+ route: "/",
14
+ position: "bottom",
15
+ closeOnOutsideClick: false,
16
+ minimizePanelInactive: 5e3
17
+ }, false);
@@ -0,0 +1,31 @@
1
+ import type { Ref } from 'vue';
2
+ export declare function useObjectStorage<T>(key: string, initial: T, listenToStorage?: boolean): Ref<T>;
3
+ export declare function useTransform<F, T>(data: Ref<F>, to: (data: F) => T, from: (data: T) => F): Ref<T>;
4
+ export declare function useEventListener(target: EventTarget, type: string, listener: any, options?: boolean | AddEventListenerOptions): void;
5
+ /**
6
+ * @see https://vueuse.org/useElementBounding
7
+ */
8
+ export declare function useElementBounding(target: Ref<HTMLElement | null | undefined>): {
9
+ height: Ref<number, number>;
10
+ bottom: Ref<number, number>;
11
+ left: Ref<number, number>;
12
+ right: Ref<number, number>;
13
+ top: Ref<number, number>;
14
+ width: Ref<number, number>;
15
+ x: Ref<number, number>;
16
+ y: Ref<number, number>;
17
+ update: () => void;
18
+ };
19
+ export declare function millisecondToHumanreadable(ms: number): [number, string];
20
+ /**
21
+ * Reactive `env(safe-area-inset-*)`
22
+ *
23
+ * @see https://vueuse.org/useScreenSafeArea
24
+ */
25
+ export declare function useScreenSafeArea(): {
26
+ top: Ref<number, number>;
27
+ right: Ref<number, number>;
28
+ bottom: Ref<number, number>;
29
+ left: Ref<number, number>;
30
+ update: () => void;
31
+ };
@@ -0,0 +1,156 @@
1
+ import { computed, getCurrentInstance, getCurrentScope, onMounted, onScopeDispose, ref, toValue, watch } from "vue";
2
+ export function useObjectStorage(key, initial, listenToStorage = true) {
3
+ const raw = localStorage.getItem(key);
4
+ const data = ref(raw ? JSON.parse(raw) : initial);
5
+ for (const key2 in initial) {
6
+ if (data.value[key2] === void 0)
7
+ data.value[key2] = initial[key2];
8
+ }
9
+ let updating = false;
10
+ let wrote = "";
11
+ watch(data, (value) => {
12
+ if (updating)
13
+ return;
14
+ wrote = JSON.stringify(value);
15
+ localStorage.setItem(key, wrote);
16
+ }, { deep: true, flush: "post" });
17
+ if (listenToStorage) {
18
+ useEventListener(window, "storage", (e) => {
19
+ if (e.key === key && e.newValue && e.newValue !== wrote) {
20
+ updating = true;
21
+ data.value = JSON.parse(e.newValue);
22
+ updating = false;
23
+ }
24
+ });
25
+ }
26
+ return data;
27
+ }
28
+ export function useTransform(data, to, from) {
29
+ return computed({
30
+ get() {
31
+ return to(data.value);
32
+ },
33
+ set(value) {
34
+ data.value = from(value);
35
+ }
36
+ });
37
+ }
38
+ export function useEventListener(target, type, listener, options) {
39
+ target.addEventListener(type, listener, options);
40
+ if (getCurrentScope())
41
+ onScopeDispose(() => target.removeEventListener(type, listener, options));
42
+ }
43
+ export function useElementBounding(target) {
44
+ const height = ref(0);
45
+ const bottom = ref(0);
46
+ const left = ref(0);
47
+ const right = ref(0);
48
+ const top = ref(0);
49
+ const width = ref(0);
50
+ const x = ref(0);
51
+ const y = ref(0);
52
+ function update() {
53
+ const el = toValue(target);
54
+ if (!el) {
55
+ height.value = 0;
56
+ bottom.value = 0;
57
+ left.value = 0;
58
+ right.value = 0;
59
+ top.value = 0;
60
+ width.value = 0;
61
+ x.value = 0;
62
+ y.value = 0;
63
+ return;
64
+ }
65
+ const rect = el.getBoundingClientRect();
66
+ height.value = rect.height;
67
+ bottom.value = rect.bottom;
68
+ left.value = rect.left;
69
+ right.value = rect.right;
70
+ top.value = rect.top;
71
+ width.value = rect.width;
72
+ x.value = rect.x;
73
+ y.value = rect.y;
74
+ }
75
+ watch(() => toValue(target), update);
76
+ useEventListener(window, "resize", update);
77
+ if (getCurrentInstance())
78
+ onMounted(() => update());
79
+ let observer;
80
+ const cleanup = () => {
81
+ if (observer) {
82
+ observer.disconnect();
83
+ observer = void 0;
84
+ }
85
+ };
86
+ const stopWatch = watch(
87
+ () => toValue(target),
88
+ (el) => {
89
+ cleanup();
90
+ if (window) {
91
+ observer = new ResizeObserver(update);
92
+ if (el)
93
+ observer.observe(el);
94
+ }
95
+ },
96
+ { immediate: true, flush: "post", deep: true }
97
+ );
98
+ if (getCurrentScope()) {
99
+ onScopeDispose(() => {
100
+ cleanup();
101
+ stopWatch();
102
+ });
103
+ }
104
+ return {
105
+ height,
106
+ bottom,
107
+ left,
108
+ right,
109
+ top,
110
+ width,
111
+ x,
112
+ y,
113
+ update
114
+ };
115
+ }
116
+ export function millisecondToHumanreadable(ms) {
117
+ if (ms < 1e3)
118
+ return [+ms.toFixed(0), "ms"];
119
+ if (ms < 1e3 * 60)
120
+ return [+(ms / 1e3).toFixed(1), "s"];
121
+ if (ms < 1e3 * 60 * 60)
122
+ return [+(ms / 1e3 / 60).toFixed(1), "min"];
123
+ return [+(ms / 1e3 / 60 / 60).toFixed(1), "hour"];
124
+ }
125
+ const topVarName = "--nuxt-devtools-safe-area-top";
126
+ const rightVarName = "--nuxt-devtools-safe-area-right";
127
+ const bottomVarName = "--nuxt-devtools-safe-area-bottom";
128
+ const leftVarName = "--nuxt-devtools-safe-area-left";
129
+ export function useScreenSafeArea() {
130
+ const top = ref(0);
131
+ const right = ref(0);
132
+ const bottom = ref(0);
133
+ const left = ref(0);
134
+ document.documentElement.style.setProperty(topVarName, "env(safe-area-inset-top, 0px)");
135
+ document.documentElement.style.setProperty(rightVarName, "env(safe-area-inset-right, 0px)");
136
+ document.documentElement.style.setProperty(bottomVarName, "env(safe-area-inset-bottom, 0px)");
137
+ document.documentElement.style.setProperty(leftVarName, "env(safe-area-inset-left, 0px)");
138
+ update();
139
+ useEventListener(window, "resize", update);
140
+ function getValue(position) {
141
+ return Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(position)) || 0;
142
+ }
143
+ function update() {
144
+ top.value = getValue(topVarName);
145
+ right.value = getValue(rightVarName);
146
+ bottom.value = getValue(bottomVarName);
147
+ left.value = getValue(leftVarName);
148
+ }
149
+ return {
150
+ top,
151
+ right,
152
+ bottom,
153
+ left,
154
+ update
155
+ };
156
+ }
@@ -0,0 +1,4 @@
1
+ import type { NuxtDevToolsOptions } from '@nuxt/devtools/types';
2
+ export declare const settings: {
3
+ ui: NuxtDevToolsOptions["ui"];
4
+ };
@@ -0,0 +1,2 @@
1
+ import _settings from "#build/devtools/settings";
2
+ export const settings = _settings;
@@ -0,0 +1,2 @@
1
+ import type { Hookable } from 'hookable';
2
+ export declare function setupHooksDebug<T extends Hookable<any>>(hooks: T): Record<string, HookInfo>;
@@ -0,0 +1,33 @@
1
+ export function setupHooksDebug(hooks) {
2
+ const serverHooks = {};
3
+ const now = typeof globalThis.performance === "undefined" ? () => Date.now() : () => performance.now();
4
+ hooks.beforeEach((event) => {
5
+ if (!serverHooks[event.name]) {
6
+ serverHooks[event.name] = {
7
+ name: event.name,
8
+ start: now(),
9
+ // @ts-expect-error private field
10
+ listeners: hooks._hooks[event.name]?.length || 0,
11
+ executions: []
12
+ };
13
+ } else {
14
+ const hook = serverHooks[event.name];
15
+ if (hook.duration != null)
16
+ hook.executions.push(hook.duration);
17
+ hook.start = now();
18
+ hook.end = void 0;
19
+ hook.duration = void 0;
20
+ }
21
+ });
22
+ hooks.afterEach((event) => {
23
+ const hook = serverHooks[event.name];
24
+ if (!hook)
25
+ return;
26
+ hook.end = now();
27
+ hook.duration = hook.end - hook.start;
28
+ const listeners = hooks._hooks[event.name]?.length;
29
+ if (listeners != null)
30
+ hook.listeners = listeners;
31
+ });
32
+ return serverHooks;
33
+ }
@@ -0,0 +1,8 @@
1
+ import type { NuxtDevtoolsHostClient } from '@nuxt/devtools/types';
2
+ import type { Ref } from 'vue';
3
+ /**
4
+ * Get Nuxt DevTools client for host app
5
+ *
6
+ * Returns undefined if not in development mode or the devtools is not enabled
7
+ */
8
+ export declare function useNuxtDevTools(): Ref<NuxtDevtoolsHostClient | undefined>;
@@ -0,0 +1,23 @@
1
+ import { shallowRef } from "vue";
2
+ export function useNuxtDevTools() {
3
+ const r = shallowRef();
4
+ if (!import.meta.dev)
5
+ return r;
6
+ if (import.meta.server)
7
+ return r;
8
+ if (window.__NUXT_DEVTOOLS_HOST__) {
9
+ r.value = window.__NUXT_DEVTOOLS_HOST__;
10
+ } else {
11
+ Object.defineProperty(window, "__NUXT_DEVTOOLS_HOST__", {
12
+ set(value) {
13
+ r.value = value;
14
+ },
15
+ get() {
16
+ return r.value;
17
+ },
18
+ enumerable: false,
19
+ configurable: true
20
+ });
21
+ }
22
+ return r;
23
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { functions } from '@vue/devtools-core'
2
+ import { createRpcServer, devtools } from '@vue/devtools-kit'
3
+
4
+ devtools.init()
5
+
6
+ createRpcServer(functions, {
7
+ preset: 'iframe',
8
+ })
@@ -0,0 +1,62 @@
1
+ import { VueInspectorClient } from 'vite-plugin-vue-inspector';
2
+ import { NuxtDevtoolsIframeClient, NuxtDevtoolsHostClient, NuxtDevtoolsGlobal, PluginMetric, TimelineMetrics, LoadingTimeMetric } from '@nuxt/devtools-kit/types';
3
+
4
+ declare global {
5
+ interface Window {
6
+ /**
7
+ * API for module integration
8
+ */
9
+ __NUXT_DEVTOOLS__?: NuxtDevtoolsIframeClient;
10
+ /**
11
+ * Nuxt DevTools client for host app
12
+ */
13
+ __NUXT_DEVTOOLS_HOST__?: NuxtDevtoolsHostClient;
14
+ /**
15
+ * Nuxt DevTools for receiving host client
16
+ *
17
+ * @internal
18
+ */
19
+ __NUXT_DEVTOOLS_VIEW__?: NuxtDevtoolsGlobal;
20
+ /**
21
+ * Metrics for plugin loading time
22
+ *
23
+ * @internal
24
+ */
25
+ __NUXT_DEVTOOLS_PLUGINS_METRIC__?: PluginMetric[];
26
+ /**
27
+ * Metrics for function calls
28
+ *
29
+ * @internal
30
+ */
31
+ __NUXT_DEVTOOLS_TIMELINE_METRICS__?: TimelineMetrics;
32
+ /**
33
+ * Metrics for page / route loading time
34
+ *
35
+ * @internal
36
+ */
37
+ __NUXT_DEVTOOLS_TIME_METRIC__?: LoadingTimeMetric;
38
+ /**
39
+ * Manually disable Nuxt DevTools embedding.
40
+ * Used for popup mode.
41
+ *
42
+ * @internal
43
+ */
44
+ __NUXT_DEVTOOLS_DISABLE__?: boolean;
45
+ /**
46
+ * Is popup mode
47
+ *
48
+ * @internal
49
+ */
50
+ __NUXT_DEVTOOLS_IS_POPUP__?: boolean;
51
+ /**
52
+ * Vue Inspector client
53
+ */
54
+ __VUE_INSPECTOR__?: VueInspectorClient;
55
+ /**
56
+ * Experimental API: Picture-in-Picture mode
57
+ *
58
+ * @see https://developer.chrome.com/docs/web-platform/document-picture-in-picture/
59
+ */
60
+ documentPictureInPicture?: any;
61
+ }
62
+ }