@vizejs/musea-nuxt 0.32.0 → 0.34.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/index.d.mts +392 -0
- package/dist/{index.js → index.mjs} +20 -24
- package/package.json +27 -26
- package/dist/index.d.ts +0 -210
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { Ref, ref } from "vue";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* NuxtMusea plugin options.
|
|
8
|
+
*/
|
|
9
|
+
interface NuxtMuseaOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Mock route data.
|
|
12
|
+
*/
|
|
13
|
+
route?: {
|
|
14
|
+
path?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
params?: Record<string, string>;
|
|
17
|
+
query?: Record<string, string>;
|
|
18
|
+
hash?: string;
|
|
19
|
+
fullPath?: string;
|
|
20
|
+
meta?: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Mock runtime config.
|
|
24
|
+
*/
|
|
25
|
+
runtimeConfig?: {
|
|
26
|
+
public?: Record<string, unknown>;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Mock useFetch / useAsyncData default responses.
|
|
31
|
+
* Key is the URL/key pattern, value is the mock response data.
|
|
32
|
+
*/
|
|
33
|
+
fetchMocks?: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Mock useState initial values.
|
|
36
|
+
* Key is the state key, value is the initial state.
|
|
37
|
+
*/
|
|
38
|
+
stateMocks?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/mocks/composables.d.ts
|
|
42
|
+
/**
|
|
43
|
+
* Mock useRoute - returns a reactive route object.
|
|
44
|
+
*/
|
|
45
|
+
declare function useRoute(): {
|
|
46
|
+
path: string;
|
|
47
|
+
name: string;
|
|
48
|
+
params: Record<string, string>;
|
|
49
|
+
query: Record<string, string>;
|
|
50
|
+
hash: string;
|
|
51
|
+
fullPath: string;
|
|
52
|
+
meta: Record<string, unknown>;
|
|
53
|
+
matched: never[];
|
|
54
|
+
redirectedFrom: undefined;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Mock useRouter - returns a router-like object with no-op navigation.
|
|
58
|
+
*/
|
|
59
|
+
declare function useRouter(): {
|
|
60
|
+
push: (_to: unknown) => Promise<void>;
|
|
61
|
+
replace: (_to: unknown) => Promise<void>;
|
|
62
|
+
back: () => void;
|
|
63
|
+
forward: () => void;
|
|
64
|
+
go: (_delta: number) => void;
|
|
65
|
+
resolve: (to: unknown) => {
|
|
66
|
+
href: string;
|
|
67
|
+
route: {
|
|
68
|
+
path: string;
|
|
69
|
+
name: string;
|
|
70
|
+
params: Record<string, string>;
|
|
71
|
+
query: Record<string, string>;
|
|
72
|
+
hash: string;
|
|
73
|
+
fullPath: string;
|
|
74
|
+
meta: Record<string, unknown>;
|
|
75
|
+
matched: never[];
|
|
76
|
+
redirectedFrom: undefined;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
currentRoute: vue.ComputedRef<{
|
|
80
|
+
path: string;
|
|
81
|
+
name: string;
|
|
82
|
+
params: Record<string, string>;
|
|
83
|
+
query: Record<string, string>;
|
|
84
|
+
hash: string;
|
|
85
|
+
fullPath: string;
|
|
86
|
+
meta: Record<string, unknown>;
|
|
87
|
+
matched: never[];
|
|
88
|
+
redirectedFrom: undefined;
|
|
89
|
+
}>;
|
|
90
|
+
addRoute: () => () => void;
|
|
91
|
+
removeRoute: () => void;
|
|
92
|
+
hasRoute: () => boolean;
|
|
93
|
+
getRoutes: () => never[];
|
|
94
|
+
beforeEach: () => () => void;
|
|
95
|
+
afterEach: () => () => void;
|
|
96
|
+
onError: () => () => void;
|
|
97
|
+
isReady: () => Promise<void>;
|
|
98
|
+
options: {};
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/mocks/data.d.ts
|
|
102
|
+
interface AsyncDataResult<T> {
|
|
103
|
+
data: ReturnType<typeof ref<T | null>>;
|
|
104
|
+
pending: ReturnType<typeof ref<boolean>>;
|
|
105
|
+
error: ReturnType<typeof ref<Error | null>>;
|
|
106
|
+
refresh: () => Promise<void>;
|
|
107
|
+
execute: () => Promise<void>;
|
|
108
|
+
status: ReturnType<typeof ref<string>>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Mock useFetch - returns reactive data based on mock config.
|
|
112
|
+
*/
|
|
113
|
+
declare function useFetch<T = unknown>(url: string | (() => string), _opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
114
|
+
/**
|
|
115
|
+
* Mock useAsyncData - similar to useFetch but with key-based lookup.
|
|
116
|
+
*/
|
|
117
|
+
declare function useAsyncData<T = unknown>(key: string, _handler?: () => Promise<T>, _opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Mock useLazyFetch - lazy variant of useFetch.
|
|
120
|
+
*/
|
|
121
|
+
declare function useLazyFetch<T = unknown>(url: string | (() => string), opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Mock useLazyAsyncData - lazy variant of useAsyncData.
|
|
124
|
+
*/
|
|
125
|
+
declare function useLazyAsyncData<T = unknown>(key: string, handler?: () => Promise<T>, opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/mocks/navigation.d.ts
|
|
128
|
+
/**
|
|
129
|
+
* Mock Nuxt navigation utilities.
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Mock navigateTo - no-op in gallery context.
|
|
133
|
+
*/
|
|
134
|
+
declare function navigateTo(_to: string | Record<string, unknown>, _opts?: {
|
|
135
|
+
replace?: boolean;
|
|
136
|
+
redirectCode?: number;
|
|
137
|
+
external?: boolean;
|
|
138
|
+
}): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Mock abortNavigation - no-op in gallery context.
|
|
141
|
+
*/
|
|
142
|
+
declare function abortNavigation(_err?: string | Error): void;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/mocks/head.d.ts
|
|
145
|
+
/**
|
|
146
|
+
* Mock Nuxt head management composables.
|
|
147
|
+
* All are no-ops in the gallery context.
|
|
148
|
+
*/
|
|
149
|
+
/**
|
|
150
|
+
* Mock useHead - no-op.
|
|
151
|
+
*/
|
|
152
|
+
declare function useHead(_input: Record<string, unknown>): void;
|
|
153
|
+
/**
|
|
154
|
+
* Mock useSeoMeta - no-op.
|
|
155
|
+
*/
|
|
156
|
+
declare function useSeoMeta(_input: Record<string, unknown>): void;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/mocks/runtime.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* Mock useNuxtApp - returns a minimal Nuxt app-like object.
|
|
161
|
+
*/
|
|
162
|
+
declare function useNuxtApp(): {
|
|
163
|
+
$config: {
|
|
164
|
+
public: Record<string, unknown>;
|
|
165
|
+
};
|
|
166
|
+
provide: (_name: string, _value: unknown) => void;
|
|
167
|
+
hook: (_name: string, _fn: (...args: unknown[]) => void) => void;
|
|
168
|
+
callHook: (_name: string, ..._args: unknown[]) => Promise<void>;
|
|
169
|
+
vueApp: null;
|
|
170
|
+
payload: {
|
|
171
|
+
data: {};
|
|
172
|
+
state: {};
|
|
173
|
+
};
|
|
174
|
+
isHydrating: boolean;
|
|
175
|
+
runWithContext: <T>(fn: () => T) => T;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Mock useRuntimeConfig - returns the configured runtime config.
|
|
179
|
+
*/
|
|
180
|
+
declare function useRuntimeConfig(): {
|
|
181
|
+
public: Record<string, unknown>;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Mock useState - returns a ref initialized from mock config or init function.
|
|
185
|
+
*/
|
|
186
|
+
declare function useState<T = unknown>(key: string, init?: () => T): Ref<T | undefined>;
|
|
187
|
+
/**
|
|
188
|
+
* Mock useCookie - returns a ref-like cookie mock.
|
|
189
|
+
*/
|
|
190
|
+
declare function useCookie<T = unknown>(_name: string, _opts?: Record<string, unknown>): Ref<T | undefined>;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/mocks/components.d.ts
|
|
193
|
+
/**
|
|
194
|
+
* Mock Nuxt built-in components.
|
|
195
|
+
*/
|
|
196
|
+
/**
|
|
197
|
+
* Mock NuxtLink - renders as <RouterLink> or <a>.
|
|
198
|
+
*/
|
|
199
|
+
declare const NuxtLink: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
200
|
+
to: {
|
|
201
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
202
|
+
default: string;
|
|
203
|
+
};
|
|
204
|
+
href: {
|
|
205
|
+
type: StringConstructor;
|
|
206
|
+
default: undefined;
|
|
207
|
+
};
|
|
208
|
+
target: {
|
|
209
|
+
type: StringConstructor;
|
|
210
|
+
default: undefined;
|
|
211
|
+
};
|
|
212
|
+
rel: {
|
|
213
|
+
type: StringConstructor;
|
|
214
|
+
default: undefined;
|
|
215
|
+
};
|
|
216
|
+
external: {
|
|
217
|
+
type: BooleanConstructor;
|
|
218
|
+
default: boolean;
|
|
219
|
+
};
|
|
220
|
+
replace: {
|
|
221
|
+
type: BooleanConstructor;
|
|
222
|
+
default: boolean;
|
|
223
|
+
};
|
|
224
|
+
prefetch: {
|
|
225
|
+
type: BooleanConstructor;
|
|
226
|
+
default: boolean;
|
|
227
|
+
};
|
|
228
|
+
noPrefetch: {
|
|
229
|
+
type: BooleanConstructor;
|
|
230
|
+
default: boolean;
|
|
231
|
+
};
|
|
232
|
+
activeClass: {
|
|
233
|
+
type: StringConstructor;
|
|
234
|
+
default: string;
|
|
235
|
+
};
|
|
236
|
+
exactActiveClass: {
|
|
237
|
+
type: StringConstructor;
|
|
238
|
+
default: string;
|
|
239
|
+
};
|
|
240
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
241
|
+
[key: string]: any;
|
|
242
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
243
|
+
to: {
|
|
244
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
245
|
+
default: string;
|
|
246
|
+
};
|
|
247
|
+
href: {
|
|
248
|
+
type: StringConstructor;
|
|
249
|
+
default: undefined;
|
|
250
|
+
};
|
|
251
|
+
target: {
|
|
252
|
+
type: StringConstructor;
|
|
253
|
+
default: undefined;
|
|
254
|
+
};
|
|
255
|
+
rel: {
|
|
256
|
+
type: StringConstructor;
|
|
257
|
+
default: undefined;
|
|
258
|
+
};
|
|
259
|
+
external: {
|
|
260
|
+
type: BooleanConstructor;
|
|
261
|
+
default: boolean;
|
|
262
|
+
};
|
|
263
|
+
replace: {
|
|
264
|
+
type: BooleanConstructor;
|
|
265
|
+
default: boolean;
|
|
266
|
+
};
|
|
267
|
+
prefetch: {
|
|
268
|
+
type: BooleanConstructor;
|
|
269
|
+
default: boolean;
|
|
270
|
+
};
|
|
271
|
+
noPrefetch: {
|
|
272
|
+
type: BooleanConstructor;
|
|
273
|
+
default: boolean;
|
|
274
|
+
};
|
|
275
|
+
activeClass: {
|
|
276
|
+
type: StringConstructor;
|
|
277
|
+
default: string;
|
|
278
|
+
};
|
|
279
|
+
exactActiveClass: {
|
|
280
|
+
type: StringConstructor;
|
|
281
|
+
default: string;
|
|
282
|
+
};
|
|
283
|
+
}>> & Readonly<{}>, {
|
|
284
|
+
to: string | Record<string, any>;
|
|
285
|
+
href: string;
|
|
286
|
+
target: string;
|
|
287
|
+
rel: string;
|
|
288
|
+
external: boolean;
|
|
289
|
+
replace: boolean;
|
|
290
|
+
prefetch: boolean;
|
|
291
|
+
noPrefetch: boolean;
|
|
292
|
+
activeClass: string;
|
|
293
|
+
exactActiveClass: string;
|
|
294
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
295
|
+
/**
|
|
296
|
+
* Mock NuxtPage - renders <RouterView> or slot content.
|
|
297
|
+
*/
|
|
298
|
+
declare const NuxtPage: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
299
|
+
name: {
|
|
300
|
+
type: StringConstructor;
|
|
301
|
+
default: string;
|
|
302
|
+
};
|
|
303
|
+
transition: {
|
|
304
|
+
type: (ObjectConstructor | BooleanConstructor)[];
|
|
305
|
+
default: undefined;
|
|
306
|
+
};
|
|
307
|
+
keepalive: {
|
|
308
|
+
type: (ObjectConstructor | BooleanConstructor)[];
|
|
309
|
+
default: undefined;
|
|
310
|
+
};
|
|
311
|
+
pageKey: {
|
|
312
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
313
|
+
default: undefined;
|
|
314
|
+
};
|
|
315
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
316
|
+
[key: string]: any;
|
|
317
|
+
}> | vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
318
|
+
[key: string]: any;
|
|
319
|
+
}>[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
320
|
+
name: {
|
|
321
|
+
type: StringConstructor;
|
|
322
|
+
default: string;
|
|
323
|
+
};
|
|
324
|
+
transition: {
|
|
325
|
+
type: (ObjectConstructor | BooleanConstructor)[];
|
|
326
|
+
default: undefined;
|
|
327
|
+
};
|
|
328
|
+
keepalive: {
|
|
329
|
+
type: (ObjectConstructor | BooleanConstructor)[];
|
|
330
|
+
default: undefined;
|
|
331
|
+
};
|
|
332
|
+
pageKey: {
|
|
333
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
334
|
+
default: undefined;
|
|
335
|
+
};
|
|
336
|
+
}>> & Readonly<{}>, {
|
|
337
|
+
name: string;
|
|
338
|
+
transition: boolean | Record<string, any>;
|
|
339
|
+
keepalive: boolean | Record<string, any>;
|
|
340
|
+
pageKey: string | Function;
|
|
341
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
342
|
+
/**
|
|
343
|
+
* Mock ClientOnly - renders default slot on client side (always in browser context).
|
|
344
|
+
*/
|
|
345
|
+
declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
346
|
+
[key: string]: any;
|
|
347
|
+
}>[] | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
348
|
+
/**
|
|
349
|
+
* Mock NuxtLayout - renders slot content with optional layout wrapper.
|
|
350
|
+
*/
|
|
351
|
+
declare const NuxtLayout: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
352
|
+
name: {
|
|
353
|
+
type: StringConstructor;
|
|
354
|
+
default: string;
|
|
355
|
+
};
|
|
356
|
+
fallback: {
|
|
357
|
+
type: StringConstructor;
|
|
358
|
+
default: undefined;
|
|
359
|
+
};
|
|
360
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
361
|
+
[key: string]: any;
|
|
362
|
+
}>[] | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
363
|
+
name: {
|
|
364
|
+
type: StringConstructor;
|
|
365
|
+
default: string;
|
|
366
|
+
};
|
|
367
|
+
fallback: {
|
|
368
|
+
type: StringConstructor;
|
|
369
|
+
default: undefined;
|
|
370
|
+
};
|
|
371
|
+
}>> & Readonly<{}>, {
|
|
372
|
+
name: string;
|
|
373
|
+
fallback: string;
|
|
374
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
375
|
+
/**
|
|
376
|
+
* Mock NuxtLoadingIndicator - renders nothing.
|
|
377
|
+
*/
|
|
378
|
+
declare const NuxtLoadingIndicator: vue.DefineComponent<{}, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
379
|
+
/**
|
|
380
|
+
* Mock NuxtErrorBoundary - renders default slot.
|
|
381
|
+
*/
|
|
382
|
+
declare const NuxtErrorBoundary: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
383
|
+
[key: string]: any;
|
|
384
|
+
}>[] | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/index.d.ts
|
|
387
|
+
/**
|
|
388
|
+
* Create Nuxt mock Vite plugin for Musea.
|
|
389
|
+
*/
|
|
390
|
+
declare function nuxtMusea(options?: NuxtMuseaOptions): Plugin;
|
|
391
|
+
//#endregion
|
|
392
|
+
export { ClientOnly, NuxtErrorBoundary, NuxtLayout, NuxtLink, NuxtLoadingIndicator, type NuxtMuseaOptions, NuxtPage, abortNavigation, navigateTo, nuxtMusea, useAsyncData, useCookie, useFetch, useHead, useLazyAsyncData, useLazyFetch, useNuxtApp, useRoute, useRouter, useRuntimeConfig, useSeoMeta, useState };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { createRequire } from "module";
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { computed, defineComponent, h, reactive, ref } from "vue";
|
|
5
|
-
|
|
6
|
-
//#region rolldown:runtime
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
7
6
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
8
|
-
|
|
9
7
|
//#endregion
|
|
10
8
|
//#region src/plugin.ts
|
|
11
9
|
const VIRTUAL_IMPORTS_ID = "\0musea-nuxt:imports";
|
|
@@ -70,7 +68,6 @@ _setStateMocks(_config.stateMocks ?? {});
|
|
|
70
68
|
`;
|
|
71
69
|
}
|
|
72
70
|
function generateComponentsModule(srcDir) {
|
|
73
|
-
const componentsPath = path.join(srcDir, "mocks", "components.js").replace(/\\/g, "/");
|
|
74
71
|
return `
|
|
75
72
|
// Auto-generated by @vizejs/musea-nuxt
|
|
76
73
|
export {
|
|
@@ -80,12 +77,14 @@ export {
|
|
|
80
77
|
NuxtLayout,
|
|
81
78
|
NuxtLoadingIndicator,
|
|
82
79
|
NuxtErrorBoundary,
|
|
83
|
-
} from '${
|
|
80
|
+
} from '${path.join(srcDir, "mocks", "components.js").replace(/\\/g, "/")}';
|
|
84
81
|
`;
|
|
85
82
|
}
|
|
86
|
-
|
|
87
83
|
//#endregion
|
|
88
84
|
//#region src/mocks/composables.ts
|
|
85
|
+
/**
|
|
86
|
+
* Mock Nuxt routing composables.
|
|
87
|
+
*/
|
|
89
88
|
let _routeConfig = {};
|
|
90
89
|
/**
|
|
91
90
|
* Mock useRoute - returns a reactive route object.
|
|
@@ -129,22 +128,21 @@ function useRouter() {
|
|
|
129
128
|
options: {}
|
|
130
129
|
};
|
|
131
130
|
}
|
|
132
|
-
|
|
133
131
|
//#endregion
|
|
134
132
|
//#region src/mocks/data.ts
|
|
133
|
+
/**
|
|
134
|
+
* Mock Nuxt data-fetching composables.
|
|
135
|
+
*/
|
|
135
136
|
let _fetchMocks = {};
|
|
136
137
|
function findMockData(key) {
|
|
137
138
|
if (key in _fetchMocks) return _fetchMocks[key];
|
|
138
139
|
for (const [pattern, data] of Object.entries(_fetchMocks)) if (key.includes(pattern)) return data;
|
|
139
|
-
return void 0;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Mock useFetch - returns reactive data based on mock config.
|
|
143
143
|
*/
|
|
144
144
|
function useFetch(url, _opts) {
|
|
145
|
-
const
|
|
146
|
-
const mockData = findMockData(key);
|
|
147
|
-
const data = ref(mockData ?? null);
|
|
145
|
+
const data = ref(findMockData(typeof url === "function" ? url() : url) ?? null);
|
|
148
146
|
const pending = ref(false);
|
|
149
147
|
const error = ref(null);
|
|
150
148
|
const status = ref("success");
|
|
@@ -163,8 +161,7 @@ function useFetch(url, _opts) {
|
|
|
163
161
|
* Mock useAsyncData - similar to useFetch but with key-based lookup.
|
|
164
162
|
*/
|
|
165
163
|
function useAsyncData(key, _handler, _opts) {
|
|
166
|
-
const
|
|
167
|
-
const data = ref(mockData ?? null);
|
|
164
|
+
const data = ref(findMockData(key) ?? null);
|
|
168
165
|
const pending = ref(false);
|
|
169
166
|
const error = ref(null);
|
|
170
167
|
const status = ref("success");
|
|
@@ -197,7 +194,6 @@ function useLazyAsyncData(key, handler, opts) {
|
|
|
197
194
|
lazy: true
|
|
198
195
|
});
|
|
199
196
|
}
|
|
200
|
-
|
|
201
197
|
//#endregion
|
|
202
198
|
//#region src/mocks/navigation.ts
|
|
203
199
|
/**
|
|
@@ -213,7 +209,6 @@ function navigateTo(_to, _opts) {
|
|
|
213
209
|
* Mock abortNavigation - no-op in gallery context.
|
|
214
210
|
*/
|
|
215
211
|
function abortNavigation(_err) {}
|
|
216
|
-
|
|
217
212
|
//#endregion
|
|
218
213
|
//#region src/mocks/head.ts
|
|
219
214
|
/**
|
|
@@ -228,9 +223,11 @@ function useHead(_input) {}
|
|
|
228
223
|
* Mock useSeoMeta - no-op.
|
|
229
224
|
*/
|
|
230
225
|
function useSeoMeta(_input) {}
|
|
231
|
-
|
|
232
226
|
//#endregion
|
|
233
227
|
//#region src/mocks/runtime.ts
|
|
228
|
+
/**
|
|
229
|
+
* Mock Nuxt runtime composables.
|
|
230
|
+
*/
|
|
234
231
|
let _runtimeConfig = {};
|
|
235
232
|
let _stateMocks = {};
|
|
236
233
|
/**
|
|
@@ -273,14 +270,15 @@ function useState(key, init) {
|
|
|
273
270
|
/**
|
|
274
271
|
* Mock useCookie - returns a ref-like cookie mock.
|
|
275
272
|
*/
|
|
276
|
-
function useCookie(
|
|
277
|
-
|
|
278
|
-
return value;
|
|
273
|
+
function useCookie(_name, _opts) {
|
|
274
|
+
return ref(void 0);
|
|
279
275
|
}
|
|
280
|
-
|
|
281
276
|
//#endregion
|
|
282
277
|
//#region src/mocks/components.ts
|
|
283
278
|
/**
|
|
279
|
+
* Mock Nuxt built-in components.
|
|
280
|
+
*/
|
|
281
|
+
/**
|
|
284
282
|
* Mock NuxtLink - renders as <RouterLink> or <a>.
|
|
285
283
|
*/
|
|
286
284
|
const NuxtLink = defineComponent({
|
|
@@ -430,7 +428,6 @@ const NuxtErrorBoundary = defineComponent({
|
|
|
430
428
|
return () => slots.default?.() ?? null;
|
|
431
429
|
}
|
|
432
430
|
});
|
|
433
|
-
|
|
434
431
|
//#endregion
|
|
435
432
|
//#region src/index.ts
|
|
436
433
|
/**
|
|
@@ -439,6 +436,5 @@ const NuxtErrorBoundary = defineComponent({
|
|
|
439
436
|
function nuxtMusea(options = {}) {
|
|
440
437
|
return createNuxtMuseaPlugin(options);
|
|
441
438
|
}
|
|
442
|
-
|
|
443
439
|
//#endregion
|
|
444
|
-
export { ClientOnly, NuxtErrorBoundary, NuxtLayout, NuxtLink, NuxtLoadingIndicator, NuxtPage, abortNavigation, navigateTo, nuxtMusea, useAsyncData, useCookie, useFetch, useHead, useLazyAsyncData, useLazyFetch, useNuxtApp, useRoute, useRouter, useRuntimeConfig, useSeoMeta, useState };
|
|
440
|
+
export { ClientOnly, NuxtErrorBoundary, NuxtLayout, NuxtLink, NuxtLoadingIndicator, NuxtPage, abortNavigation, navigateTo, nuxtMusea, useAsyncData, useCookie, useFetch, useHead, useLazyAsyncData, useLazyFetch, useNuxtApp, useRoute, useRouter, useRuntimeConfig, useSeoMeta, useState };
|
package/package.json
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/musea-nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "Nuxt mock layer for Musea - enables Nuxt component isolation in galleries",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"component-gallery",
|
|
7
|
+
"mock",
|
|
8
|
+
"musea",
|
|
9
|
+
"nuxt",
|
|
10
|
+
"vite-plugin"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "ubugeeei",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/ubugeeei/vize.git",
|
|
17
|
+
"directory": "npm/musea-nuxt"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
5
22
|
"type": "module",
|
|
6
23
|
"main": "./dist/index.js",
|
|
7
24
|
"types": "./dist/index.d.ts",
|
|
@@ -11,28 +28,14 @@
|
|
|
11
28
|
"types": "./dist/index.d.ts"
|
|
12
29
|
}
|
|
13
30
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
],
|
|
17
|
-
"keywords": [
|
|
18
|
-
"nuxt",
|
|
19
|
-
"musea",
|
|
20
|
-
"vite-plugin",
|
|
21
|
-
"component-gallery",
|
|
22
|
-
"mock"
|
|
23
|
-
],
|
|
24
|
-
"author": "ubugeeei",
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "https://github.com/ubugeeei/vize.git",
|
|
29
|
-
"directory": "npm/musea-nuxt"
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
30
33
|
},
|
|
31
34
|
"dependencies": {},
|
|
32
35
|
"devDependencies": {
|
|
33
|
-
"tsdown": "^0.9.0",
|
|
34
36
|
"typescript": "^5.7.0",
|
|
35
|
-
"vite": "
|
|
37
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
38
|
+
"vite-plus": "latest",
|
|
36
39
|
"vue": "^3.5.0",
|
|
37
40
|
"vue-router": "^4.5.0"
|
|
38
41
|
},
|
|
@@ -41,13 +44,11 @@
|
|
|
41
44
|
"vue": "^3.5.0",
|
|
42
45
|
"vue-router": "^4.5.0"
|
|
43
46
|
},
|
|
44
|
-
"publishConfig": {
|
|
45
|
-
"access": "public"
|
|
46
|
-
},
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "
|
|
49
|
-
"dev": "
|
|
50
|
-
"
|
|
51
|
-
"
|
|
48
|
+
"build": "vp pack",
|
|
49
|
+
"dev": "vp pack --watch",
|
|
50
|
+
"check": "vp check src vite.config.ts",
|
|
51
|
+
"check:fix": "vp check --fix src vite.config.ts",
|
|
52
|
+
"fmt": "vp fmt --write src vite.config.ts"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { ref } from "vue";
|
|
2
|
-
import { Plugin } from "vite";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* NuxtMusea plugin options.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* NuxtMusea plugin options.
|
|
10
|
-
*/
|
|
11
|
-
interface NuxtMuseaOptions {
|
|
12
|
-
/**
|
|
13
|
-
* Mock route data.
|
|
14
|
-
*/
|
|
15
|
-
route?: {
|
|
16
|
-
path?: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
params?: Record<string, string>;
|
|
19
|
-
query?: Record<string, string>;
|
|
20
|
-
hash?: string;
|
|
21
|
-
fullPath?: string;
|
|
22
|
-
meta?: Record<string, unknown>;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Mock runtime config.
|
|
26
|
-
*/
|
|
27
|
-
runtimeConfig?: {
|
|
28
|
-
public?: Record<string, unknown>;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Mock useFetch / useAsyncData default responses.
|
|
33
|
-
* Key is the URL/key pattern, value is the mock response data.
|
|
34
|
-
*/
|
|
35
|
-
fetchMocks?: Record<string, unknown>;
|
|
36
|
-
/**
|
|
37
|
-
* Mock useState initial values.
|
|
38
|
-
* Key is the state key, value is the initial state.
|
|
39
|
-
*/
|
|
40
|
-
stateMocks?: Record<string, unknown>;
|
|
41
|
-
} //#endregion
|
|
42
|
-
//#region src/mocks/composables.d.ts
|
|
43
|
-
/**
|
|
44
|
-
* Mock useRoute - returns a reactive route object.
|
|
45
|
-
*/
|
|
46
|
-
declare function useRoute(): any;
|
|
47
|
-
/**
|
|
48
|
-
* Mock useRouter - returns a router-like object with no-op navigation.
|
|
49
|
-
*/
|
|
50
|
-
declare function useRouter(): {
|
|
51
|
-
push: (_to: unknown) => Promise<void>;
|
|
52
|
-
replace: (_to: unknown) => Promise<void>;
|
|
53
|
-
back: () => void;
|
|
54
|
-
forward: () => void;
|
|
55
|
-
go: (_delta: number) => void;
|
|
56
|
-
resolve: (to: unknown) => {
|
|
57
|
-
href: string;
|
|
58
|
-
route: any;
|
|
59
|
-
};
|
|
60
|
-
currentRoute: any;
|
|
61
|
-
addRoute: () => () => void;
|
|
62
|
-
removeRoute: () => void;
|
|
63
|
-
hasRoute: () => boolean;
|
|
64
|
-
getRoutes: () => never[];
|
|
65
|
-
beforeEach: () => () => void;
|
|
66
|
-
afterEach: () => () => void;
|
|
67
|
-
onError: () => () => void;
|
|
68
|
-
isReady: () => Promise<void>;
|
|
69
|
-
options: {};
|
|
70
|
-
};
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/mocks/data.d.ts
|
|
73
|
-
interface AsyncDataResult<T> {
|
|
74
|
-
data: ReturnType<typeof ref<T | null>>;
|
|
75
|
-
pending: ReturnType<typeof ref<boolean>>;
|
|
76
|
-
error: ReturnType<typeof ref<Error | null>>;
|
|
77
|
-
refresh: () => Promise<void>;
|
|
78
|
-
execute: () => Promise<void>;
|
|
79
|
-
status: ReturnType<typeof ref<string>>;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Mock useFetch - returns reactive data based on mock config.
|
|
83
|
-
*/
|
|
84
|
-
declare function useFetch<T = unknown>(url: string | (() => string), _opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
85
|
-
/**
|
|
86
|
-
* Mock useAsyncData - similar to useFetch but with key-based lookup.
|
|
87
|
-
*/
|
|
88
|
-
declare function useAsyncData<T = unknown>(key: string, _handler?: () => Promise<T>, _opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
89
|
-
/**
|
|
90
|
-
* Mock useLazyFetch - lazy variant of useFetch.
|
|
91
|
-
*/
|
|
92
|
-
declare function useLazyFetch<T = unknown>(url: string | (() => string), opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
93
|
-
/**
|
|
94
|
-
* Mock useLazyAsyncData - lazy variant of useAsyncData.
|
|
95
|
-
*/
|
|
96
|
-
declare function useLazyAsyncData<T = unknown>(key: string, handler?: () => Promise<T>, opts?: Record<string, unknown>): AsyncDataResult<T>;
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/mocks/navigation.d.ts
|
|
100
|
-
/**
|
|
101
|
-
* Mock Nuxt navigation utilities.
|
|
102
|
-
*/
|
|
103
|
-
/**
|
|
104
|
-
* Mock navigateTo - no-op in gallery context.
|
|
105
|
-
*/
|
|
106
|
-
declare function navigateTo(_to: string | Record<string, unknown>, _opts?: {
|
|
107
|
-
replace?: boolean;
|
|
108
|
-
redirectCode?: number;
|
|
109
|
-
external?: boolean;
|
|
110
|
-
}): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Mock abortNavigation - no-op in gallery context.
|
|
113
|
-
*/
|
|
114
|
-
declare function abortNavigation(_err?: string | Error): void;
|
|
115
|
-
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/mocks/head.d.ts
|
|
118
|
-
/**
|
|
119
|
-
* Mock defineNuxtRouteMiddleware - returns the middleware function as-is.
|
|
120
|
-
*/
|
|
121
|
-
/**
|
|
122
|
-
* Mock Nuxt head management composables.
|
|
123
|
-
* All are no-ops in the gallery context.
|
|
124
|
-
*/
|
|
125
|
-
/**
|
|
126
|
-
* Mock useHead - no-op.
|
|
127
|
-
*/
|
|
128
|
-
declare function useHead(_input: Record<string, unknown>): void;
|
|
129
|
-
/**
|
|
130
|
-
* Mock useSeoMeta - no-op.
|
|
131
|
-
*/
|
|
132
|
-
declare function useSeoMeta(_input: Record<string, unknown>): void;
|
|
133
|
-
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/mocks/runtime.d.ts
|
|
136
|
-
/**
|
|
137
|
-
* Mock useHeadSafe - no-op.
|
|
138
|
-
*/
|
|
139
|
-
/**
|
|
140
|
-
* Mock useNuxtApp - returns a minimal Nuxt app-like object.
|
|
141
|
-
*/
|
|
142
|
-
declare function useNuxtApp(): {
|
|
143
|
-
$config: any;
|
|
144
|
-
provide: (_name: string, _value: unknown) => void;
|
|
145
|
-
hook: (_name: string, _fn: (...args: unknown[]) => void) => void;
|
|
146
|
-
callHook: (_name: string, ..._args: unknown[]) => Promise<void>;
|
|
147
|
-
vueApp: null;
|
|
148
|
-
payload: any;
|
|
149
|
-
isHydrating: boolean;
|
|
150
|
-
runWithContext: <T>(fn: () => T) => T;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Mock useRuntimeConfig - returns the configured runtime config.
|
|
154
|
-
*/
|
|
155
|
-
declare function useRuntimeConfig(): any;
|
|
156
|
-
/**
|
|
157
|
-
* Mock useState - returns a ref initialized from mock config or init function.
|
|
158
|
-
*/
|
|
159
|
-
declare function useState<T = unknown>(key: string, init?: () => T): any;
|
|
160
|
-
/**
|
|
161
|
-
* Mock useRequestHeaders - returns empty headers in gallery context.
|
|
162
|
-
*/
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Mock useCookie - returns a ref-like cookie mock.
|
|
166
|
-
*/
|
|
167
|
-
declare function useCookie<T = unknown>(name: string, _opts?: Record<string, unknown>): any;
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/mocks/components.d.ts
|
|
171
|
-
/**
|
|
172
|
-
* Mock clearNuxtState - no-op.
|
|
173
|
-
*/
|
|
174
|
-
/**
|
|
175
|
-
* Mock Nuxt built-in components.
|
|
176
|
-
*/
|
|
177
|
-
/**
|
|
178
|
-
* Mock NuxtLink - renders as <RouterLink> or <a>.
|
|
179
|
-
*/
|
|
180
|
-
declare const NuxtLink: any;
|
|
181
|
-
/**
|
|
182
|
-
* Mock NuxtPage - renders <RouterView> or slot content.
|
|
183
|
-
*/
|
|
184
|
-
declare const NuxtPage: any;
|
|
185
|
-
/**
|
|
186
|
-
* Mock ClientOnly - renders default slot on client side (always in browser context).
|
|
187
|
-
*/
|
|
188
|
-
declare const ClientOnly: any;
|
|
189
|
-
/**
|
|
190
|
-
* Mock NuxtLayout - renders slot content with optional layout wrapper.
|
|
191
|
-
*/
|
|
192
|
-
declare const NuxtLayout: any;
|
|
193
|
-
/**
|
|
194
|
-
* Mock NuxtLoadingIndicator - renders nothing.
|
|
195
|
-
*/
|
|
196
|
-
declare const NuxtLoadingIndicator: any;
|
|
197
|
-
/**
|
|
198
|
-
* Mock NuxtErrorBoundary - renders default slot.
|
|
199
|
-
*/
|
|
200
|
-
declare const NuxtErrorBoundary: any;
|
|
201
|
-
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/index.d.ts
|
|
204
|
-
/**
|
|
205
|
-
* Create Nuxt mock Vite plugin for Musea.
|
|
206
|
-
*/
|
|
207
|
-
declare function nuxtMusea(options?: NuxtMuseaOptions): Plugin;
|
|
208
|
-
|
|
209
|
-
//#endregion
|
|
210
|
-
export { ClientOnly, NuxtErrorBoundary, NuxtLayout, NuxtLink, NuxtLoadingIndicator, NuxtMuseaOptions, NuxtPage, abortNavigation, navigateTo, nuxtMusea, useAsyncData, useCookie, useFetch, useHead, useLazyAsyncData, useLazyFetch, useNuxtApp, useRoute, useRouter, useRuntimeConfig, useSeoMeta, useState };
|