@roki-h5/create-roki-app 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/index.js +15 -1
  2. package/package.json +1 -1
  3. package/templates/h5/config/env/.env.development +7 -0
  4. package/templates/h5/config/env/.env.development.local +2 -0
  5. package/templates/h5/config/env/.env.production +9 -0
  6. package/templates/h5/config/env/.env.test +9 -0
  7. package/templates/h5/config/env.ts +10 -0
  8. package/templates/h5/index.html +1 -1
  9. package/templates/h5/node_modules/.bin/autoprefixer +17 -0
  10. package/templates/h5/node_modules/.bin/browserslist +17 -0
  11. package/templates/h5/node_modules/.bin/tsc +17 -0
  12. package/templates/h5/node_modules/.bin/tsserver +17 -0
  13. package/templates/h5/node_modules/.bin/vite +17 -0
  14. package/templates/h5/node_modules/.bin/vue-tsc +17 -0
  15. package/templates/h5/node_modules/.vite/deps/_metadata.json +43 -0
  16. package/templates/h5/node_modules/.vite/deps/axios.js +3370 -0
  17. package/templates/h5/node_modules/.vite/deps/axios.js.map +7 -0
  18. package/templates/h5/node_modules/.vite/deps/chunk-CVVHEZGK.js +162 -0
  19. package/templates/h5/node_modules/.vite/deps/chunk-CVVHEZGK.js.map +7 -0
  20. package/templates/h5/node_modules/.vite/deps/chunk-HFUUWO4F.js +13072 -0
  21. package/templates/h5/node_modules/.vite/deps/chunk-HFUUWO4F.js.map +7 -0
  22. package/templates/h5/node_modules/.vite/deps/chunk-PZ5AY32C.js +9 -0
  23. package/templates/h5/node_modules/.vite/deps/chunk-PZ5AY32C.js.map +7 -0
  24. package/templates/h5/node_modules/.vite/deps/package.json +3 -0
  25. package/templates/h5/node_modules/.vite/deps/pinia.js +1561 -0
  26. package/templates/h5/node_modules/.vite/deps/pinia.js.map +7 -0
  27. package/templates/h5/node_modules/.vite/deps/vue-router.js +2241 -0
  28. package/templates/h5/node_modules/.vite/deps/vue-router.js.map +7 -0
  29. package/templates/h5/node_modules/.vite/deps/vue.js +347 -0
  30. package/templates/h5/node_modules/.vite/deps/vue.js.map +7 -0
  31. package/templates/h5/node_modules/.vue-global-types/vue_3.5_0_0_0.d.ts +118 -0
  32. package/templates/h5/package.json +9 -6
  33. package/templates/h5/scripts/version.js +38 -0
  34. package/templates/h5/src/App.vue +29 -0
  35. package/templates/h5/src/api/index.ts +4 -0
  36. package/templates/h5/src/api/nativeApi.ts +72 -0
  37. package/templates/h5/src/api/request.ts +2 -1
  38. package/templates/h5/src/api/welcome.ts +24 -0
  39. package/templates/h5/src/assets/images/home/img-device.png +0 -0
  40. package/templates/h5/src/assets/images/home/logo-free.png +0 -0
  41. package/templates/h5/src/assets/images/logo.png +0 -0
  42. package/templates/h5/src/components/WelcomeInfo.vue +90 -0
  43. package/templates/h5/src/router/index.ts +1 -1
  44. package/templates/h5/src/stores/index.ts +96 -1
  45. package/templates/h5/src/utils/appInfo.ts +86 -0
  46. package/templates/h5/src/utils/browser.ts +26 -0
  47. package/templates/h5/src/utils/buildInfo.ts +3 -0
  48. package/templates/h5/src/utils/greeting.ts +38 -0
  49. package/templates/h5/src/views/home/index.vue +12 -11
  50. package/templates/h5/src/vite-env.d.ts +26 -0
  51. package/templates/h5/tsconfig.json +3 -2
  52. package/templates/h5/vite.config.ts +56 -11
  53. package/templates/h5/.env.development +0 -1
@@ -0,0 +1,1561 @@
1
+ import {
2
+ setupDevtoolsPlugin
3
+ } from "./chunk-CVVHEZGK.js";
4
+ import {
5
+ computed,
6
+ effectScope,
7
+ getCurrentInstance,
8
+ getCurrentScope,
9
+ hasInjectionContext,
10
+ inject,
11
+ isReactive,
12
+ isRef,
13
+ markRaw,
14
+ nextTick,
15
+ onScopeDispose,
16
+ reactive,
17
+ ref,
18
+ toRaw,
19
+ toRef,
20
+ toRefs,
21
+ unref,
22
+ watch
23
+ } from "./chunk-HFUUWO4F.js";
24
+ import "./chunk-PZ5AY32C.js";
25
+
26
+ // ../../../../node_modules/.pnpm/vue-demi@0.14.10_vue@3.5.38_typescript@5.9.3_/node_modules/vue-demi/lib/index.mjs
27
+ var isVue2 = false;
28
+ function set(target, key, val) {
29
+ if (Array.isArray(target)) {
30
+ target.length = Math.max(target.length, key);
31
+ target.splice(key, 1, val);
32
+ return val;
33
+ }
34
+ target[key] = val;
35
+ return val;
36
+ }
37
+ function del(target, key) {
38
+ if (Array.isArray(target)) {
39
+ target.splice(key, 1);
40
+ return;
41
+ }
42
+ delete target[key];
43
+ }
44
+
45
+ // ../../../../node_modules/.pnpm/pinia@2.3.1_typescript@5.9.3_vue@3.5.38_typescript@5.9.3_/node_modules/pinia/dist/pinia.mjs
46
+ var activePinia;
47
+ var setActivePinia = (pinia) => activePinia = pinia;
48
+ var getActivePinia = () => hasInjectionContext() && inject(piniaSymbol) || activePinia;
49
+ var piniaSymbol = true ? Symbol("pinia") : (
50
+ /* istanbul ignore next */
51
+ Symbol()
52
+ );
53
+ function isPlainObject(o) {
54
+ return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
55
+ }
56
+ var MutationType;
57
+ (function(MutationType2) {
58
+ MutationType2["direct"] = "direct";
59
+ MutationType2["patchObject"] = "patch object";
60
+ MutationType2["patchFunction"] = "patch function";
61
+ })(MutationType || (MutationType = {}));
62
+ var IS_CLIENT = typeof window !== "undefined";
63
+ var _global = (() => typeof window === "object" && window.window === window ? window : typeof self === "object" && self.self === self ? self : typeof global === "object" && global.global === global ? global : typeof globalThis === "object" ? globalThis : { HTMLElement: null })();
64
+ function bom(blob, { autoBom = false } = {}) {
65
+ if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
66
+ return new Blob([String.fromCharCode(65279), blob], { type: blob.type });
67
+ }
68
+ return blob;
69
+ }
70
+ function download(url, name, opts) {
71
+ const xhr = new XMLHttpRequest();
72
+ xhr.open("GET", url);
73
+ xhr.responseType = "blob";
74
+ xhr.onload = function() {
75
+ saveAs(xhr.response, name, opts);
76
+ };
77
+ xhr.onerror = function() {
78
+ console.error("could not download file");
79
+ };
80
+ xhr.send();
81
+ }
82
+ function corsEnabled(url) {
83
+ const xhr = new XMLHttpRequest();
84
+ xhr.open("HEAD", url, false);
85
+ try {
86
+ xhr.send();
87
+ } catch (e) {
88
+ }
89
+ return xhr.status >= 200 && xhr.status <= 299;
90
+ }
91
+ function click(node) {
92
+ try {
93
+ node.dispatchEvent(new MouseEvent("click"));
94
+ } catch (e) {
95
+ const evt = document.createEvent("MouseEvents");
96
+ evt.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
97
+ node.dispatchEvent(evt);
98
+ }
99
+ }
100
+ var _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
101
+ var isMacOSWebView = (() => /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent))();
102
+ var saveAs = !IS_CLIENT ? () => {
103
+ } : (
104
+ // Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
105
+ typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : (
106
+ // Use msSaveOrOpenBlob as a second approach
107
+ "msSaveOrOpenBlob" in _navigator ? msSaveAs : (
108
+ // Fallback to using FileReader and a popup
109
+ fileSaverSaveAs
110
+ )
111
+ )
112
+ );
113
+ function downloadSaveAs(blob, name = "download", opts) {
114
+ const a = document.createElement("a");
115
+ a.download = name;
116
+ a.rel = "noopener";
117
+ if (typeof blob === "string") {
118
+ a.href = blob;
119
+ if (a.origin !== location.origin) {
120
+ if (corsEnabled(a.href)) {
121
+ download(blob, name, opts);
122
+ } else {
123
+ a.target = "_blank";
124
+ click(a);
125
+ }
126
+ } else {
127
+ click(a);
128
+ }
129
+ } else {
130
+ a.href = URL.createObjectURL(blob);
131
+ setTimeout(function() {
132
+ URL.revokeObjectURL(a.href);
133
+ }, 4e4);
134
+ setTimeout(function() {
135
+ click(a);
136
+ }, 0);
137
+ }
138
+ }
139
+ function msSaveAs(blob, name = "download", opts) {
140
+ if (typeof blob === "string") {
141
+ if (corsEnabled(blob)) {
142
+ download(blob, name, opts);
143
+ } else {
144
+ const a = document.createElement("a");
145
+ a.href = blob;
146
+ a.target = "_blank";
147
+ setTimeout(function() {
148
+ click(a);
149
+ });
150
+ }
151
+ } else {
152
+ navigator.msSaveOrOpenBlob(bom(blob, opts), name);
153
+ }
154
+ }
155
+ function fileSaverSaveAs(blob, name, opts, popup) {
156
+ popup = popup || open("", "_blank");
157
+ if (popup) {
158
+ popup.document.title = popup.document.body.innerText = "downloading...";
159
+ }
160
+ if (typeof blob === "string")
161
+ return download(blob, name, opts);
162
+ const force = blob.type === "application/octet-stream";
163
+ const isSafari = /constructor/i.test(String(_global.HTMLElement)) || "safari" in _global;
164
+ const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
165
+ if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
166
+ const reader = new FileReader();
167
+ reader.onloadend = function() {
168
+ let url = reader.result;
169
+ if (typeof url !== "string") {
170
+ popup = null;
171
+ throw new Error("Wrong reader.result type");
172
+ }
173
+ url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
174
+ if (popup) {
175
+ popup.location.href = url;
176
+ } else {
177
+ location.assign(url);
178
+ }
179
+ popup = null;
180
+ };
181
+ reader.readAsDataURL(blob);
182
+ } else {
183
+ const url = URL.createObjectURL(blob);
184
+ if (popup)
185
+ popup.location.assign(url);
186
+ else
187
+ location.href = url;
188
+ popup = null;
189
+ setTimeout(function() {
190
+ URL.revokeObjectURL(url);
191
+ }, 4e4);
192
+ }
193
+ }
194
+ function toastMessage(message, type) {
195
+ const piniaMessage = "🍍 " + message;
196
+ if (typeof __VUE_DEVTOOLS_TOAST__ === "function") {
197
+ __VUE_DEVTOOLS_TOAST__(piniaMessage, type);
198
+ } else if (type === "error") {
199
+ console.error(piniaMessage);
200
+ } else if (type === "warn") {
201
+ console.warn(piniaMessage);
202
+ } else {
203
+ console.log(piniaMessage);
204
+ }
205
+ }
206
+ function isPinia(o) {
207
+ return "_a" in o && "install" in o;
208
+ }
209
+ function checkClipboardAccess() {
210
+ if (!("clipboard" in navigator)) {
211
+ toastMessage(`Your browser doesn't support the Clipboard API`, "error");
212
+ return true;
213
+ }
214
+ }
215
+ function checkNotFocusedError(error) {
216
+ if (error instanceof Error && error.message.toLowerCase().includes("document is not focused")) {
217
+ toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', "warn");
218
+ return true;
219
+ }
220
+ return false;
221
+ }
222
+ async function actionGlobalCopyState(pinia) {
223
+ if (checkClipboardAccess())
224
+ return;
225
+ try {
226
+ await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
227
+ toastMessage("Global state copied to clipboard.");
228
+ } catch (error) {
229
+ if (checkNotFocusedError(error))
230
+ return;
231
+ toastMessage(`Failed to serialize the state. Check the console for more details.`, "error");
232
+ console.error(error);
233
+ }
234
+ }
235
+ async function actionGlobalPasteState(pinia) {
236
+ if (checkClipboardAccess())
237
+ return;
238
+ try {
239
+ loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText()));
240
+ toastMessage("Global state pasted from clipboard.");
241
+ } catch (error) {
242
+ if (checkNotFocusedError(error))
243
+ return;
244
+ toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, "error");
245
+ console.error(error);
246
+ }
247
+ }
248
+ async function actionGlobalSaveState(pinia) {
249
+ try {
250
+ saveAs(new Blob([JSON.stringify(pinia.state.value)], {
251
+ type: "text/plain;charset=utf-8"
252
+ }), "pinia-state.json");
253
+ } catch (error) {
254
+ toastMessage(`Failed to export the state as JSON. Check the console for more details.`, "error");
255
+ console.error(error);
256
+ }
257
+ }
258
+ var fileInput;
259
+ function getFileOpener() {
260
+ if (!fileInput) {
261
+ fileInput = document.createElement("input");
262
+ fileInput.type = "file";
263
+ fileInput.accept = ".json";
264
+ }
265
+ function openFile() {
266
+ return new Promise((resolve, reject) => {
267
+ fileInput.onchange = async () => {
268
+ const files = fileInput.files;
269
+ if (!files)
270
+ return resolve(null);
271
+ const file = files.item(0);
272
+ if (!file)
273
+ return resolve(null);
274
+ return resolve({ text: await file.text(), file });
275
+ };
276
+ fileInput.oncancel = () => resolve(null);
277
+ fileInput.onerror = reject;
278
+ fileInput.click();
279
+ });
280
+ }
281
+ return openFile;
282
+ }
283
+ async function actionGlobalOpenStateFile(pinia) {
284
+ try {
285
+ const open2 = getFileOpener();
286
+ const result = await open2();
287
+ if (!result)
288
+ return;
289
+ const { text, file } = result;
290
+ loadStoresState(pinia, JSON.parse(text));
291
+ toastMessage(`Global state imported from "${file.name}".`);
292
+ } catch (error) {
293
+ toastMessage(`Failed to import the state from JSON. Check the console for more details.`, "error");
294
+ console.error(error);
295
+ }
296
+ }
297
+ function loadStoresState(pinia, state) {
298
+ for (const key in state) {
299
+ const storeState = pinia.state.value[key];
300
+ if (storeState) {
301
+ Object.assign(storeState, state[key]);
302
+ } else {
303
+ pinia.state.value[key] = state[key];
304
+ }
305
+ }
306
+ }
307
+ function formatDisplay(display) {
308
+ return {
309
+ _custom: {
310
+ display
311
+ }
312
+ };
313
+ }
314
+ var PINIA_ROOT_LABEL = "🍍 Pinia (root)";
315
+ var PINIA_ROOT_ID = "_root";
316
+ function formatStoreForInspectorTree(store) {
317
+ return isPinia(store) ? {
318
+ id: PINIA_ROOT_ID,
319
+ label: PINIA_ROOT_LABEL
320
+ } : {
321
+ id: store.$id,
322
+ label: store.$id
323
+ };
324
+ }
325
+ function formatStoreForInspectorState(store) {
326
+ if (isPinia(store)) {
327
+ const storeNames = Array.from(store._s.keys());
328
+ const storeMap = store._s;
329
+ const state2 = {
330
+ state: storeNames.map((storeId) => ({
331
+ editable: true,
332
+ key: storeId,
333
+ value: store.state.value[storeId]
334
+ })),
335
+ getters: storeNames.filter((id) => storeMap.get(id)._getters).map((id) => {
336
+ const store2 = storeMap.get(id);
337
+ return {
338
+ editable: false,
339
+ key: id,
340
+ value: store2._getters.reduce((getters, key) => {
341
+ getters[key] = store2[key];
342
+ return getters;
343
+ }, {})
344
+ };
345
+ })
346
+ };
347
+ return state2;
348
+ }
349
+ const state = {
350
+ state: Object.keys(store.$state).map((key) => ({
351
+ editable: true,
352
+ key,
353
+ value: store.$state[key]
354
+ }))
355
+ };
356
+ if (store._getters && store._getters.length) {
357
+ state.getters = store._getters.map((getterName) => ({
358
+ editable: false,
359
+ key: getterName,
360
+ value: store[getterName]
361
+ }));
362
+ }
363
+ if (store._customProperties.size) {
364
+ state.customProperties = Array.from(store._customProperties).map((key) => ({
365
+ editable: true,
366
+ key,
367
+ value: store[key]
368
+ }));
369
+ }
370
+ return state;
371
+ }
372
+ function formatEventData(events) {
373
+ if (!events)
374
+ return {};
375
+ if (Array.isArray(events)) {
376
+ return events.reduce((data, event) => {
377
+ data.keys.push(event.key);
378
+ data.operations.push(event.type);
379
+ data.oldValue[event.key] = event.oldValue;
380
+ data.newValue[event.key] = event.newValue;
381
+ return data;
382
+ }, {
383
+ oldValue: {},
384
+ keys: [],
385
+ operations: [],
386
+ newValue: {}
387
+ });
388
+ } else {
389
+ return {
390
+ operation: formatDisplay(events.type),
391
+ key: formatDisplay(events.key),
392
+ oldValue: events.oldValue,
393
+ newValue: events.newValue
394
+ };
395
+ }
396
+ }
397
+ function formatMutationType(type) {
398
+ switch (type) {
399
+ case MutationType.direct:
400
+ return "mutation";
401
+ case MutationType.patchFunction:
402
+ return "$patch";
403
+ case MutationType.patchObject:
404
+ return "$patch";
405
+ default:
406
+ return "unknown";
407
+ }
408
+ }
409
+ var isTimelineActive = true;
410
+ var componentStateTypes = [];
411
+ var MUTATIONS_LAYER_ID = "pinia:mutations";
412
+ var INSPECTOR_ID = "pinia";
413
+ var { assign: assign$1 } = Object;
414
+ var getStoreType = (id) => "🍍 " + id;
415
+ function registerPiniaDevtools(app, pinia) {
416
+ setupDevtoolsPlugin({
417
+ id: "dev.esm.pinia",
418
+ label: "Pinia 🍍",
419
+ logo: "https://pinia.vuejs.org/logo.svg",
420
+ packageName: "pinia",
421
+ homepage: "https://pinia.vuejs.org",
422
+ componentStateTypes,
423
+ app
424
+ }, (api) => {
425
+ if (typeof api.now !== "function") {
426
+ toastMessage("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
427
+ }
428
+ api.addTimelineLayer({
429
+ id: MUTATIONS_LAYER_ID,
430
+ label: `Pinia 🍍`,
431
+ color: 15064968
432
+ });
433
+ api.addInspector({
434
+ id: INSPECTOR_ID,
435
+ label: "Pinia 🍍",
436
+ icon: "storage",
437
+ treeFilterPlaceholder: "Search stores",
438
+ actions: [
439
+ {
440
+ icon: "content_copy",
441
+ action: () => {
442
+ actionGlobalCopyState(pinia);
443
+ },
444
+ tooltip: "Serialize and copy the state"
445
+ },
446
+ {
447
+ icon: "content_paste",
448
+ action: async () => {
449
+ await actionGlobalPasteState(pinia);
450
+ api.sendInspectorTree(INSPECTOR_ID);
451
+ api.sendInspectorState(INSPECTOR_ID);
452
+ },
453
+ tooltip: "Replace the state with the content of your clipboard"
454
+ },
455
+ {
456
+ icon: "save",
457
+ action: () => {
458
+ actionGlobalSaveState(pinia);
459
+ },
460
+ tooltip: "Save the state as a JSON file"
461
+ },
462
+ {
463
+ icon: "folder_open",
464
+ action: async () => {
465
+ await actionGlobalOpenStateFile(pinia);
466
+ api.sendInspectorTree(INSPECTOR_ID);
467
+ api.sendInspectorState(INSPECTOR_ID);
468
+ },
469
+ tooltip: "Import the state from a JSON file"
470
+ }
471
+ ],
472
+ nodeActions: [
473
+ {
474
+ icon: "restore",
475
+ tooltip: 'Reset the state (with "$reset")',
476
+ action: (nodeId) => {
477
+ const store = pinia._s.get(nodeId);
478
+ if (!store) {
479
+ toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, "warn");
480
+ } else if (typeof store.$reset !== "function") {
481
+ toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, "warn");
482
+ } else {
483
+ store.$reset();
484
+ toastMessage(`Store "${nodeId}" reset.`);
485
+ }
486
+ }
487
+ }
488
+ ]
489
+ });
490
+ api.on.inspectComponent((payload, ctx) => {
491
+ const proxy = payload.componentInstance && payload.componentInstance.proxy;
492
+ if (proxy && proxy._pStores) {
493
+ const piniaStores = payload.componentInstance.proxy._pStores;
494
+ Object.values(piniaStores).forEach((store) => {
495
+ payload.instanceData.state.push({
496
+ type: getStoreType(store.$id),
497
+ key: "state",
498
+ editable: true,
499
+ value: store._isOptionsAPI ? {
500
+ _custom: {
501
+ value: toRaw(store.$state),
502
+ actions: [
503
+ {
504
+ icon: "restore",
505
+ tooltip: "Reset the state of this store",
506
+ action: () => store.$reset()
507
+ }
508
+ ]
509
+ }
510
+ } : (
511
+ // NOTE: workaround to unwrap transferred refs
512
+ Object.keys(store.$state).reduce((state, key) => {
513
+ state[key] = store.$state[key];
514
+ return state;
515
+ }, {})
516
+ )
517
+ });
518
+ if (store._getters && store._getters.length) {
519
+ payload.instanceData.state.push({
520
+ type: getStoreType(store.$id),
521
+ key: "getters",
522
+ editable: false,
523
+ value: store._getters.reduce((getters, key) => {
524
+ try {
525
+ getters[key] = store[key];
526
+ } catch (error) {
527
+ getters[key] = error;
528
+ }
529
+ return getters;
530
+ }, {})
531
+ });
532
+ }
533
+ });
534
+ }
535
+ });
536
+ api.on.getInspectorTree((payload) => {
537
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
538
+ let stores = [pinia];
539
+ stores = stores.concat(Array.from(pinia._s.values()));
540
+ payload.rootNodes = (payload.filter ? stores.filter((store) => "$id" in store ? store.$id.toLowerCase().includes(payload.filter.toLowerCase()) : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) : stores).map(formatStoreForInspectorTree);
541
+ }
542
+ });
543
+ globalThis.$pinia = pinia;
544
+ api.on.getInspectorState((payload) => {
545
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
546
+ const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
547
+ if (!inspectedStore) {
548
+ return;
549
+ }
550
+ if (inspectedStore) {
551
+ if (payload.nodeId !== PINIA_ROOT_ID)
552
+ globalThis.$store = toRaw(inspectedStore);
553
+ payload.state = formatStoreForInspectorState(inspectedStore);
554
+ }
555
+ }
556
+ });
557
+ api.on.editInspectorState((payload, ctx) => {
558
+ if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
559
+ const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
560
+ if (!inspectedStore) {
561
+ return toastMessage(`store "${payload.nodeId}" not found`, "error");
562
+ }
563
+ const { path } = payload;
564
+ if (!isPinia(inspectedStore)) {
565
+ if (path.length !== 1 || !inspectedStore._customProperties.has(path[0]) || path[0] in inspectedStore.$state) {
566
+ path.unshift("$state");
567
+ }
568
+ } else {
569
+ path.unshift("state");
570
+ }
571
+ isTimelineActive = false;
572
+ payload.set(inspectedStore, path, payload.state.value);
573
+ isTimelineActive = true;
574
+ }
575
+ });
576
+ api.on.editComponentState((payload) => {
577
+ if (payload.type.startsWith("🍍")) {
578
+ const storeId = payload.type.replace(/^🍍\s*/, "");
579
+ const store = pinia._s.get(storeId);
580
+ if (!store) {
581
+ return toastMessage(`store "${storeId}" not found`, "error");
582
+ }
583
+ const { path } = payload;
584
+ if (path[0] !== "state") {
585
+ return toastMessage(`Invalid path for store "${storeId}":
586
+ ${path}
587
+ Only state can be modified.`);
588
+ }
589
+ path[0] = "$state";
590
+ isTimelineActive = false;
591
+ payload.set(store, path, payload.state.value);
592
+ isTimelineActive = true;
593
+ }
594
+ });
595
+ });
596
+ }
597
+ function addStoreToDevtools(app, store) {
598
+ if (!componentStateTypes.includes(getStoreType(store.$id))) {
599
+ componentStateTypes.push(getStoreType(store.$id));
600
+ }
601
+ setupDevtoolsPlugin({
602
+ id: "dev.esm.pinia",
603
+ label: "Pinia 🍍",
604
+ logo: "https://pinia.vuejs.org/logo.svg",
605
+ packageName: "pinia",
606
+ homepage: "https://pinia.vuejs.org",
607
+ componentStateTypes,
608
+ app,
609
+ settings: {
610
+ logStoreChanges: {
611
+ label: "Notify about new/deleted stores",
612
+ type: "boolean",
613
+ defaultValue: true
614
+ }
615
+ // useEmojis: {
616
+ // label: 'Use emojis in messages ⚡️',
617
+ // type: 'boolean',
618
+ // defaultValue: true,
619
+ // },
620
+ }
621
+ }, (api) => {
622
+ const now = typeof api.now === "function" ? api.now.bind(api) : Date.now;
623
+ store.$onAction(({ after, onError, name, args }) => {
624
+ const groupId = runningActionId++;
625
+ api.addTimelineEvent({
626
+ layerId: MUTATIONS_LAYER_ID,
627
+ event: {
628
+ time: now(),
629
+ title: "🛫 " + name,
630
+ subtitle: "start",
631
+ data: {
632
+ store: formatDisplay(store.$id),
633
+ action: formatDisplay(name),
634
+ args
635
+ },
636
+ groupId
637
+ }
638
+ });
639
+ after((result) => {
640
+ activeAction = void 0;
641
+ api.addTimelineEvent({
642
+ layerId: MUTATIONS_LAYER_ID,
643
+ event: {
644
+ time: now(),
645
+ title: "🛬 " + name,
646
+ subtitle: "end",
647
+ data: {
648
+ store: formatDisplay(store.$id),
649
+ action: formatDisplay(name),
650
+ args,
651
+ result
652
+ },
653
+ groupId
654
+ }
655
+ });
656
+ });
657
+ onError((error) => {
658
+ activeAction = void 0;
659
+ api.addTimelineEvent({
660
+ layerId: MUTATIONS_LAYER_ID,
661
+ event: {
662
+ time: now(),
663
+ logType: "error",
664
+ title: "💥 " + name,
665
+ subtitle: "end",
666
+ data: {
667
+ store: formatDisplay(store.$id),
668
+ action: formatDisplay(name),
669
+ args,
670
+ error
671
+ },
672
+ groupId
673
+ }
674
+ });
675
+ });
676
+ }, true);
677
+ store._customProperties.forEach((name) => {
678
+ watch(() => unref(store[name]), (newValue, oldValue) => {
679
+ api.notifyComponentUpdate();
680
+ api.sendInspectorState(INSPECTOR_ID);
681
+ if (isTimelineActive) {
682
+ api.addTimelineEvent({
683
+ layerId: MUTATIONS_LAYER_ID,
684
+ event: {
685
+ time: now(),
686
+ title: "Change",
687
+ subtitle: name,
688
+ data: {
689
+ newValue,
690
+ oldValue
691
+ },
692
+ groupId: activeAction
693
+ }
694
+ });
695
+ }
696
+ }, { deep: true });
697
+ });
698
+ store.$subscribe(({ events, type }, state) => {
699
+ api.notifyComponentUpdate();
700
+ api.sendInspectorState(INSPECTOR_ID);
701
+ if (!isTimelineActive)
702
+ return;
703
+ const eventData = {
704
+ time: now(),
705
+ title: formatMutationType(type),
706
+ data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)),
707
+ groupId: activeAction
708
+ };
709
+ if (type === MutationType.patchFunction) {
710
+ eventData.subtitle = "⤵️";
711
+ } else if (type === MutationType.patchObject) {
712
+ eventData.subtitle = "🧩";
713
+ } else if (events && !Array.isArray(events)) {
714
+ eventData.subtitle = events.type;
715
+ }
716
+ if (events) {
717
+ eventData.data["rawEvent(s)"] = {
718
+ _custom: {
719
+ display: "DebuggerEvent",
720
+ type: "object",
721
+ tooltip: "raw DebuggerEvent[]",
722
+ value: events
723
+ }
724
+ };
725
+ }
726
+ api.addTimelineEvent({
727
+ layerId: MUTATIONS_LAYER_ID,
728
+ event: eventData
729
+ });
730
+ }, { detached: true, flush: "sync" });
731
+ const hotUpdate = store._hotUpdate;
732
+ store._hotUpdate = markRaw((newStore) => {
733
+ hotUpdate(newStore);
734
+ api.addTimelineEvent({
735
+ layerId: MUTATIONS_LAYER_ID,
736
+ event: {
737
+ time: now(),
738
+ title: "🔥 " + store.$id,
739
+ subtitle: "HMR update",
740
+ data: {
741
+ store: formatDisplay(store.$id),
742
+ info: formatDisplay(`HMR update`)
743
+ }
744
+ }
745
+ });
746
+ api.notifyComponentUpdate();
747
+ api.sendInspectorTree(INSPECTOR_ID);
748
+ api.sendInspectorState(INSPECTOR_ID);
749
+ });
750
+ const { $dispose } = store;
751
+ store.$dispose = () => {
752
+ $dispose();
753
+ api.notifyComponentUpdate();
754
+ api.sendInspectorTree(INSPECTOR_ID);
755
+ api.sendInspectorState(INSPECTOR_ID);
756
+ api.getSettings().logStoreChanges && toastMessage(`Disposed "${store.$id}" store 🗑`);
757
+ };
758
+ api.notifyComponentUpdate();
759
+ api.sendInspectorTree(INSPECTOR_ID);
760
+ api.sendInspectorState(INSPECTOR_ID);
761
+ api.getSettings().logStoreChanges && toastMessage(`"${store.$id}" store installed 🆕`);
762
+ });
763
+ }
764
+ var runningActionId = 0;
765
+ var activeAction;
766
+ function patchActionForGrouping(store, actionNames, wrapWithProxy) {
767
+ const actions = actionNames.reduce((storeActions, actionName) => {
768
+ storeActions[actionName] = toRaw(store)[actionName];
769
+ return storeActions;
770
+ }, {});
771
+ for (const actionName in actions) {
772
+ store[actionName] = function() {
773
+ const _actionId = runningActionId;
774
+ const trackedStore = wrapWithProxy ? new Proxy(store, {
775
+ get(...args) {
776
+ activeAction = _actionId;
777
+ return Reflect.get(...args);
778
+ },
779
+ set(...args) {
780
+ activeAction = _actionId;
781
+ return Reflect.set(...args);
782
+ }
783
+ }) : store;
784
+ activeAction = _actionId;
785
+ const retValue = actions[actionName].apply(trackedStore, arguments);
786
+ activeAction = void 0;
787
+ return retValue;
788
+ };
789
+ }
790
+ }
791
+ function devtoolsPlugin({ app, store, options }) {
792
+ if (store.$id.startsWith("__hot:")) {
793
+ return;
794
+ }
795
+ store._isOptionsAPI = !!options.state;
796
+ if (!store._p._testing) {
797
+ patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI);
798
+ const originalHotUpdate = store._hotUpdate;
799
+ toRaw(store)._hotUpdate = function(newStore) {
800
+ originalHotUpdate.apply(this, arguments);
801
+ patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI);
802
+ };
803
+ }
804
+ addStoreToDevtools(
805
+ app,
806
+ // FIXME: is there a way to allow the assignment from Store<Id, S, G, A> to StoreGeneric?
807
+ store
808
+ );
809
+ }
810
+ function createPinia() {
811
+ const scope = effectScope(true);
812
+ const state = scope.run(() => ref({}));
813
+ let _p = [];
814
+ let toBeInstalled = [];
815
+ const pinia = markRaw({
816
+ install(app) {
817
+ setActivePinia(pinia);
818
+ if (!isVue2) {
819
+ pinia._a = app;
820
+ app.provide(piniaSymbol, pinia);
821
+ app.config.globalProperties.$pinia = pinia;
822
+ if (IS_CLIENT) {
823
+ registerPiniaDevtools(app, pinia);
824
+ }
825
+ toBeInstalled.forEach((plugin) => _p.push(plugin));
826
+ toBeInstalled = [];
827
+ }
828
+ },
829
+ use(plugin) {
830
+ if (!this._a && !isVue2) {
831
+ toBeInstalled.push(plugin);
832
+ } else {
833
+ _p.push(plugin);
834
+ }
835
+ return this;
836
+ },
837
+ _p,
838
+ // it's actually undefined here
839
+ // @ts-expect-error
840
+ _a: null,
841
+ _e: scope,
842
+ _s: /* @__PURE__ */ new Map(),
843
+ state
844
+ });
845
+ if (IS_CLIENT && typeof Proxy !== "undefined") {
846
+ pinia.use(devtoolsPlugin);
847
+ }
848
+ return pinia;
849
+ }
850
+ function disposePinia(pinia) {
851
+ pinia._e.stop();
852
+ pinia._s.clear();
853
+ pinia._p.splice(0);
854
+ pinia.state.value = {};
855
+ pinia._a = null;
856
+ }
857
+ var isUseStore = (fn) => {
858
+ return typeof fn === "function" && typeof fn.$id === "string";
859
+ };
860
+ function patchObject(newState, oldState) {
861
+ for (const key in oldState) {
862
+ const subPatch = oldState[key];
863
+ if (!(key in newState)) {
864
+ continue;
865
+ }
866
+ const targetValue = newState[key];
867
+ if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) {
868
+ newState[key] = patchObject(targetValue, subPatch);
869
+ } else {
870
+ if (isVue2) {
871
+ set(newState, key, subPatch);
872
+ } else {
873
+ newState[key] = subPatch;
874
+ }
875
+ }
876
+ }
877
+ return newState;
878
+ }
879
+ function acceptHMRUpdate(initialUseStore, hot) {
880
+ if (false) {
881
+ return () => {
882
+ };
883
+ }
884
+ return (newModule) => {
885
+ const pinia = hot.data.pinia || initialUseStore._pinia;
886
+ if (!pinia) {
887
+ return;
888
+ }
889
+ hot.data.pinia = pinia;
890
+ for (const exportName in newModule) {
891
+ const useStore = newModule[exportName];
892
+ if (isUseStore(useStore) && pinia._s.has(useStore.$id)) {
893
+ const id = useStore.$id;
894
+ if (id !== initialUseStore.$id) {
895
+ console.warn(`The id of the store changed from "${initialUseStore.$id}" to "${id}". Reloading.`);
896
+ return hot.invalidate();
897
+ }
898
+ const existingStore = pinia._s.get(id);
899
+ if (!existingStore) {
900
+ console.log(`[Pinia]: skipping hmr because store doesn't exist yet`);
901
+ return;
902
+ }
903
+ useStore(pinia, existingStore);
904
+ }
905
+ }
906
+ };
907
+ }
908
+ var noop = () => {
909
+ };
910
+ function addSubscription(subscriptions, callback, detached, onCleanup = noop) {
911
+ subscriptions.push(callback);
912
+ const removeSubscription = () => {
913
+ const idx = subscriptions.indexOf(callback);
914
+ if (idx > -1) {
915
+ subscriptions.splice(idx, 1);
916
+ onCleanup();
917
+ }
918
+ };
919
+ if (!detached && getCurrentScope()) {
920
+ onScopeDispose(removeSubscription);
921
+ }
922
+ return removeSubscription;
923
+ }
924
+ function triggerSubscriptions(subscriptions, ...args) {
925
+ subscriptions.slice().forEach((callback) => {
926
+ callback(...args);
927
+ });
928
+ }
929
+ var fallbackRunWithContext = (fn) => fn();
930
+ var ACTION_MARKER = Symbol();
931
+ var ACTION_NAME = Symbol();
932
+ function mergeReactiveObjects(target, patchToApply) {
933
+ if (target instanceof Map && patchToApply instanceof Map) {
934
+ patchToApply.forEach((value, key) => target.set(key, value));
935
+ } else if (target instanceof Set && patchToApply instanceof Set) {
936
+ patchToApply.forEach(target.add, target);
937
+ }
938
+ for (const key in patchToApply) {
939
+ if (!patchToApply.hasOwnProperty(key))
940
+ continue;
941
+ const subPatch = patchToApply[key];
942
+ const targetValue = target[key];
943
+ if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) {
944
+ target[key] = mergeReactiveObjects(targetValue, subPatch);
945
+ } else {
946
+ target[key] = subPatch;
947
+ }
948
+ }
949
+ return target;
950
+ }
951
+ var skipHydrateSymbol = true ? Symbol("pinia:skipHydration") : (
952
+ /* istanbul ignore next */
953
+ Symbol()
954
+ );
955
+ function skipHydrate(obj) {
956
+ return Object.defineProperty(obj, skipHydrateSymbol, {});
957
+ }
958
+ function shouldHydrate(obj) {
959
+ return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
960
+ }
961
+ var { assign } = Object;
962
+ function isComputed(o) {
963
+ return !!(isRef(o) && o.effect);
964
+ }
965
+ function createOptionsStore(id, options, pinia, hot) {
966
+ const { state, actions, getters } = options;
967
+ const initialState = pinia.state.value[id];
968
+ let store;
969
+ function setup() {
970
+ if (!initialState && !hot) {
971
+ if (isVue2) {
972
+ set(pinia.state.value, id, state ? state() : {});
973
+ } else {
974
+ pinia.state.value[id] = state ? state() : {};
975
+ }
976
+ }
977
+ const localState = hot ? (
978
+ // use ref() to unwrap refs inside state TODO: check if this is still necessary
979
+ toRefs(ref(state ? state() : {}).value)
980
+ ) : toRefs(pinia.state.value[id]);
981
+ return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
982
+ if (name in localState) {
983
+ console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`);
984
+ }
985
+ computedGetters[name] = markRaw(computed(() => {
986
+ setActivePinia(pinia);
987
+ const store2 = pinia._s.get(id);
988
+ if (isVue2 && !store2._r)
989
+ return;
990
+ return getters[name].call(store2, store2);
991
+ }));
992
+ return computedGetters;
993
+ }, {}));
994
+ }
995
+ store = createSetupStore(id, setup, options, pinia, hot, true);
996
+ return store;
997
+ }
998
+ function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
999
+ let scope;
1000
+ const optionsForPlugin = assign({ actions: {} }, options);
1001
+ if (!pinia._e.active) {
1002
+ throw new Error("Pinia destroyed");
1003
+ }
1004
+ const $subscribeOptions = { deep: true };
1005
+ if (!isVue2) {
1006
+ $subscribeOptions.onTrigger = (event) => {
1007
+ if (isListening) {
1008
+ debuggerEvents = event;
1009
+ } else if (isListening == false && !store._hotUpdating) {
1010
+ if (Array.isArray(debuggerEvents)) {
1011
+ debuggerEvents.push(event);
1012
+ } else {
1013
+ console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.");
1014
+ }
1015
+ }
1016
+ };
1017
+ }
1018
+ let isListening;
1019
+ let isSyncListening;
1020
+ let subscriptions = [];
1021
+ let actionSubscriptions = [];
1022
+ let debuggerEvents;
1023
+ const initialState = pinia.state.value[$id];
1024
+ if (!isOptionsStore && !initialState && !hot) {
1025
+ if (isVue2) {
1026
+ set(pinia.state.value, $id, {});
1027
+ } else {
1028
+ pinia.state.value[$id] = {};
1029
+ }
1030
+ }
1031
+ const hotState = ref({});
1032
+ let activeListener;
1033
+ function $patch(partialStateOrMutator) {
1034
+ let subscriptionMutation;
1035
+ isListening = isSyncListening = false;
1036
+ if (true) {
1037
+ debuggerEvents = [];
1038
+ }
1039
+ if (typeof partialStateOrMutator === "function") {
1040
+ partialStateOrMutator(pinia.state.value[$id]);
1041
+ subscriptionMutation = {
1042
+ type: MutationType.patchFunction,
1043
+ storeId: $id,
1044
+ events: debuggerEvents
1045
+ };
1046
+ } else {
1047
+ mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
1048
+ subscriptionMutation = {
1049
+ type: MutationType.patchObject,
1050
+ payload: partialStateOrMutator,
1051
+ storeId: $id,
1052
+ events: debuggerEvents
1053
+ };
1054
+ }
1055
+ const myListenerId = activeListener = Symbol();
1056
+ nextTick().then(() => {
1057
+ if (activeListener === myListenerId) {
1058
+ isListening = true;
1059
+ }
1060
+ });
1061
+ isSyncListening = true;
1062
+ triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
1063
+ }
1064
+ const $reset = isOptionsStore ? function $reset2() {
1065
+ const { state } = options;
1066
+ const newState = state ? state() : {};
1067
+ this.$patch(($state) => {
1068
+ assign($state, newState);
1069
+ });
1070
+ } : (
1071
+ /* istanbul ignore next */
1072
+ true ? () => {
1073
+ throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
1074
+ } : noop
1075
+ );
1076
+ function $dispose() {
1077
+ scope.stop();
1078
+ subscriptions = [];
1079
+ actionSubscriptions = [];
1080
+ pinia._s.delete($id);
1081
+ }
1082
+ const action = (fn, name = "") => {
1083
+ if (ACTION_MARKER in fn) {
1084
+ fn[ACTION_NAME] = name;
1085
+ return fn;
1086
+ }
1087
+ const wrappedAction = function() {
1088
+ setActivePinia(pinia);
1089
+ const args = Array.from(arguments);
1090
+ const afterCallbackList = [];
1091
+ const onErrorCallbackList = [];
1092
+ function after(callback) {
1093
+ afterCallbackList.push(callback);
1094
+ }
1095
+ function onError(callback) {
1096
+ onErrorCallbackList.push(callback);
1097
+ }
1098
+ triggerSubscriptions(actionSubscriptions, {
1099
+ args,
1100
+ name: wrappedAction[ACTION_NAME],
1101
+ store,
1102
+ after,
1103
+ onError
1104
+ });
1105
+ let ret;
1106
+ try {
1107
+ ret = fn.apply(this && this.$id === $id ? this : store, args);
1108
+ } catch (error) {
1109
+ triggerSubscriptions(onErrorCallbackList, error);
1110
+ throw error;
1111
+ }
1112
+ if (ret instanceof Promise) {
1113
+ return ret.then((value) => {
1114
+ triggerSubscriptions(afterCallbackList, value);
1115
+ return value;
1116
+ }).catch((error) => {
1117
+ triggerSubscriptions(onErrorCallbackList, error);
1118
+ return Promise.reject(error);
1119
+ });
1120
+ }
1121
+ triggerSubscriptions(afterCallbackList, ret);
1122
+ return ret;
1123
+ };
1124
+ wrappedAction[ACTION_MARKER] = true;
1125
+ wrappedAction[ACTION_NAME] = name;
1126
+ return wrappedAction;
1127
+ };
1128
+ const _hmrPayload = markRaw({
1129
+ actions: {},
1130
+ getters: {},
1131
+ state: [],
1132
+ hotState
1133
+ });
1134
+ const partialStore = {
1135
+ _p: pinia,
1136
+ // _s: scope,
1137
+ $id,
1138
+ $onAction: addSubscription.bind(null, actionSubscriptions),
1139
+ $patch,
1140
+ $reset,
1141
+ $subscribe(callback, options2 = {}) {
1142
+ const removeSubscription = addSubscription(subscriptions, callback, options2.detached, () => stopWatcher());
1143
+ const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
1144
+ if (options2.flush === "sync" ? isSyncListening : isListening) {
1145
+ callback({
1146
+ storeId: $id,
1147
+ type: MutationType.direct,
1148
+ events: debuggerEvents
1149
+ }, state);
1150
+ }
1151
+ }, assign({}, $subscribeOptions, options2)));
1152
+ return removeSubscription;
1153
+ },
1154
+ $dispose
1155
+ };
1156
+ if (isVue2) {
1157
+ partialStore._r = false;
1158
+ }
1159
+ const store = reactive(true ? assign(
1160
+ {
1161
+ _hmrPayload,
1162
+ _customProperties: markRaw(/* @__PURE__ */ new Set())
1163
+ // devtools custom properties
1164
+ },
1165
+ partialStore
1166
+ // must be added later
1167
+ // setupStore
1168
+ ) : partialStore);
1169
+ pinia._s.set($id, store);
1170
+ const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext;
1171
+ const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(() => setup({ action }))));
1172
+ for (const key in setupStore) {
1173
+ const prop = setupStore[key];
1174
+ if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
1175
+ if (hot) {
1176
+ set(hotState.value, key, toRef(setupStore, key));
1177
+ } else if (!isOptionsStore) {
1178
+ if (initialState && shouldHydrate(prop)) {
1179
+ if (isRef(prop)) {
1180
+ prop.value = initialState[key];
1181
+ } else {
1182
+ mergeReactiveObjects(prop, initialState[key]);
1183
+ }
1184
+ }
1185
+ if (isVue2) {
1186
+ set(pinia.state.value[$id], key, prop);
1187
+ } else {
1188
+ pinia.state.value[$id][key] = prop;
1189
+ }
1190
+ }
1191
+ if (true) {
1192
+ _hmrPayload.state.push(key);
1193
+ }
1194
+ } else if (typeof prop === "function") {
1195
+ const actionValue = hot ? prop : action(prop, key);
1196
+ if (isVue2) {
1197
+ set(setupStore, key, actionValue);
1198
+ } else {
1199
+ setupStore[key] = actionValue;
1200
+ }
1201
+ if (true) {
1202
+ _hmrPayload.actions[key] = prop;
1203
+ }
1204
+ optionsForPlugin.actions[key] = prop;
1205
+ } else if (true) {
1206
+ if (isComputed(prop)) {
1207
+ _hmrPayload.getters[key] = isOptionsStore ? (
1208
+ // @ts-expect-error
1209
+ options.getters[key]
1210
+ ) : prop;
1211
+ if (IS_CLIENT) {
1212
+ const getters = setupStore._getters || // @ts-expect-error: same
1213
+ (setupStore._getters = markRaw([]));
1214
+ getters.push(key);
1215
+ }
1216
+ }
1217
+ }
1218
+ }
1219
+ if (isVue2) {
1220
+ Object.keys(setupStore).forEach((key) => {
1221
+ set(store, key, setupStore[key]);
1222
+ });
1223
+ } else {
1224
+ assign(store, setupStore);
1225
+ assign(toRaw(store), setupStore);
1226
+ }
1227
+ Object.defineProperty(store, "$state", {
1228
+ get: () => hot ? hotState.value : pinia.state.value[$id],
1229
+ set: (state) => {
1230
+ if (hot) {
1231
+ throw new Error("cannot set hotState");
1232
+ }
1233
+ $patch(($state) => {
1234
+ assign($state, state);
1235
+ });
1236
+ }
1237
+ });
1238
+ if (true) {
1239
+ store._hotUpdate = markRaw((newStore) => {
1240
+ store._hotUpdating = true;
1241
+ newStore._hmrPayload.state.forEach((stateKey) => {
1242
+ if (stateKey in store.$state) {
1243
+ const newStateTarget = newStore.$state[stateKey];
1244
+ const oldStateSource = store.$state[stateKey];
1245
+ if (typeof newStateTarget === "object" && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) {
1246
+ patchObject(newStateTarget, oldStateSource);
1247
+ } else {
1248
+ newStore.$state[stateKey] = oldStateSource;
1249
+ }
1250
+ }
1251
+ set(store, stateKey, toRef(newStore.$state, stateKey));
1252
+ });
1253
+ Object.keys(store.$state).forEach((stateKey) => {
1254
+ if (!(stateKey in newStore.$state)) {
1255
+ del(store, stateKey);
1256
+ }
1257
+ });
1258
+ isListening = false;
1259
+ isSyncListening = false;
1260
+ pinia.state.value[$id] = toRef(newStore._hmrPayload, "hotState");
1261
+ isSyncListening = true;
1262
+ nextTick().then(() => {
1263
+ isListening = true;
1264
+ });
1265
+ for (const actionName in newStore._hmrPayload.actions) {
1266
+ const actionFn = newStore[actionName];
1267
+ set(store, actionName, action(actionFn, actionName));
1268
+ }
1269
+ for (const getterName in newStore._hmrPayload.getters) {
1270
+ const getter = newStore._hmrPayload.getters[getterName];
1271
+ const getterValue = isOptionsStore ? (
1272
+ // special handling of options api
1273
+ computed(() => {
1274
+ setActivePinia(pinia);
1275
+ return getter.call(store, store);
1276
+ })
1277
+ ) : getter;
1278
+ set(store, getterName, getterValue);
1279
+ }
1280
+ Object.keys(store._hmrPayload.getters).forEach((key) => {
1281
+ if (!(key in newStore._hmrPayload.getters)) {
1282
+ del(store, key);
1283
+ }
1284
+ });
1285
+ Object.keys(store._hmrPayload.actions).forEach((key) => {
1286
+ if (!(key in newStore._hmrPayload.actions)) {
1287
+ del(store, key);
1288
+ }
1289
+ });
1290
+ store._hmrPayload = newStore._hmrPayload;
1291
+ store._getters = newStore._getters;
1292
+ store._hotUpdating = false;
1293
+ });
1294
+ }
1295
+ if (IS_CLIENT) {
1296
+ const nonEnumerable = {
1297
+ writable: true,
1298
+ configurable: true,
1299
+ // avoid warning on devtools trying to display this property
1300
+ enumerable: false
1301
+ };
1302
+ ["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((p) => {
1303
+ Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable));
1304
+ });
1305
+ }
1306
+ if (isVue2) {
1307
+ store._r = true;
1308
+ }
1309
+ pinia._p.forEach((extender) => {
1310
+ if (IS_CLIENT) {
1311
+ const extensions = scope.run(() => extender({
1312
+ store,
1313
+ app: pinia._a,
1314
+ pinia,
1315
+ options: optionsForPlugin
1316
+ }));
1317
+ Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
1318
+ assign(store, extensions);
1319
+ } else {
1320
+ assign(store, scope.run(() => extender({
1321
+ store,
1322
+ app: pinia._a,
1323
+ pinia,
1324
+ options: optionsForPlugin
1325
+ })));
1326
+ }
1327
+ });
1328
+ if (store.$state && typeof store.$state === "object" && typeof store.$state.constructor === "function" && !store.$state.constructor.toString().includes("[native code]")) {
1329
+ console.warn(`[🍍]: The "state" must be a plain object. It cannot be
1330
+ state: () => new MyClass()
1331
+ Found in store "${store.$id}".`);
1332
+ }
1333
+ if (initialState && isOptionsStore && options.hydrate) {
1334
+ options.hydrate(store.$state, initialState);
1335
+ }
1336
+ isListening = true;
1337
+ isSyncListening = true;
1338
+ return store;
1339
+ }
1340
+ function defineStore(idOrOptions, setup, setupOptions) {
1341
+ let id;
1342
+ let options;
1343
+ const isSetupStore = typeof setup === "function";
1344
+ if (typeof idOrOptions === "string") {
1345
+ id = idOrOptions;
1346
+ options = isSetupStore ? setupOptions : setup;
1347
+ } else {
1348
+ options = idOrOptions;
1349
+ id = idOrOptions.id;
1350
+ if (typeof id !== "string") {
1351
+ throw new Error(`[🍍]: "defineStore()" must be passed a store id as its first argument.`);
1352
+ }
1353
+ }
1354
+ function useStore(pinia, hot) {
1355
+ const hasContext = hasInjectionContext();
1356
+ pinia = // in test mode, ignore the argument provided as we can always retrieve a
1357
+ // pinia instance with getActivePinia()
1358
+ (false ? null : pinia) || (hasContext ? inject(piniaSymbol, null) : null);
1359
+ if (pinia)
1360
+ setActivePinia(pinia);
1361
+ if (!activePinia) {
1362
+ throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
1363
+ See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
1364
+ This will fail in production.`);
1365
+ }
1366
+ pinia = activePinia;
1367
+ if (!pinia._s.has(id)) {
1368
+ if (isSetupStore) {
1369
+ createSetupStore(id, setup, options, pinia);
1370
+ } else {
1371
+ createOptionsStore(id, options, pinia);
1372
+ }
1373
+ if (true) {
1374
+ useStore._pinia = pinia;
1375
+ }
1376
+ }
1377
+ const store = pinia._s.get(id);
1378
+ if (hot) {
1379
+ const hotId = "__hot:" + id;
1380
+ const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
1381
+ hot._hotUpdate(newStore);
1382
+ delete pinia.state.value[hotId];
1383
+ pinia._s.delete(hotId);
1384
+ }
1385
+ if (IS_CLIENT) {
1386
+ const currentInstance = getCurrentInstance();
1387
+ if (currentInstance && currentInstance.proxy && // avoid adding stores that are just built for hot module replacement
1388
+ !hot) {
1389
+ const vm = currentInstance.proxy;
1390
+ const cache = "_pStores" in vm ? vm._pStores : vm._pStores = {};
1391
+ cache[id] = store;
1392
+ }
1393
+ }
1394
+ return store;
1395
+ }
1396
+ useStore.$id = id;
1397
+ return useStore;
1398
+ }
1399
+ var mapStoreSuffix = "Store";
1400
+ function setMapStoreSuffix(suffix) {
1401
+ mapStoreSuffix = suffix;
1402
+ }
1403
+ function mapStores(...stores) {
1404
+ if (Array.isArray(stores[0])) {
1405
+ console.warn(`[🍍]: Directly pass all stores to "mapStores()" without putting them in an array:
1406
+ Replace
1407
+ mapStores([useAuthStore, useCartStore])
1408
+ with
1409
+ mapStores(useAuthStore, useCartStore)
1410
+ This will fail in production if not fixed.`);
1411
+ stores = stores[0];
1412
+ }
1413
+ return stores.reduce((reduced, useStore) => {
1414
+ reduced[useStore.$id + mapStoreSuffix] = function() {
1415
+ return useStore(this.$pinia);
1416
+ };
1417
+ return reduced;
1418
+ }, {});
1419
+ }
1420
+ function mapState(useStore, keysOrMapper) {
1421
+ return Array.isArray(keysOrMapper) ? keysOrMapper.reduce((reduced, key) => {
1422
+ reduced[key] = function() {
1423
+ return useStore(this.$pinia)[key];
1424
+ };
1425
+ return reduced;
1426
+ }, {}) : Object.keys(keysOrMapper).reduce((reduced, key) => {
1427
+ reduced[key] = function() {
1428
+ const store = useStore(this.$pinia);
1429
+ const storeKey = keysOrMapper[key];
1430
+ return typeof storeKey === "function" ? storeKey.call(this, store) : (
1431
+ // @ts-expect-error: FIXME: should work?
1432
+ store[storeKey]
1433
+ );
1434
+ };
1435
+ return reduced;
1436
+ }, {});
1437
+ }
1438
+ var mapGetters = mapState;
1439
+ function mapActions(useStore, keysOrMapper) {
1440
+ return Array.isArray(keysOrMapper) ? keysOrMapper.reduce((reduced, key) => {
1441
+ reduced[key] = function(...args) {
1442
+ return useStore(this.$pinia)[key](...args);
1443
+ };
1444
+ return reduced;
1445
+ }, {}) : Object.keys(keysOrMapper).reduce((reduced, key) => {
1446
+ reduced[key] = function(...args) {
1447
+ return useStore(this.$pinia)[keysOrMapper[key]](...args);
1448
+ };
1449
+ return reduced;
1450
+ }, {});
1451
+ }
1452
+ function mapWritableState(useStore, keysOrMapper) {
1453
+ return Array.isArray(keysOrMapper) ? keysOrMapper.reduce((reduced, key) => {
1454
+ reduced[key] = {
1455
+ get() {
1456
+ return useStore(this.$pinia)[key];
1457
+ },
1458
+ set(value) {
1459
+ return useStore(this.$pinia)[key] = value;
1460
+ }
1461
+ };
1462
+ return reduced;
1463
+ }, {}) : Object.keys(keysOrMapper).reduce((reduced, key) => {
1464
+ reduced[key] = {
1465
+ get() {
1466
+ return useStore(this.$pinia)[keysOrMapper[key]];
1467
+ },
1468
+ set(value) {
1469
+ return useStore(this.$pinia)[keysOrMapper[key]] = value;
1470
+ }
1471
+ };
1472
+ return reduced;
1473
+ }, {});
1474
+ }
1475
+ function storeToRefs(store) {
1476
+ if (isVue2) {
1477
+ return toRefs(store);
1478
+ } else {
1479
+ const rawStore = toRaw(store);
1480
+ const refs = {};
1481
+ for (const key in rawStore) {
1482
+ const value = rawStore[key];
1483
+ if (value.effect) {
1484
+ refs[key] = // ...
1485
+ computed({
1486
+ get: () => store[key],
1487
+ set(value2) {
1488
+ store[key] = value2;
1489
+ }
1490
+ });
1491
+ } else if (isRef(value) || isReactive(value)) {
1492
+ refs[key] = // ---
1493
+ toRef(store, key);
1494
+ }
1495
+ }
1496
+ return refs;
1497
+ }
1498
+ }
1499
+ var PiniaVuePlugin = function(_Vue) {
1500
+ _Vue.mixin({
1501
+ beforeCreate() {
1502
+ const options = this.$options;
1503
+ if (options.pinia) {
1504
+ const pinia = options.pinia;
1505
+ if (!this._provided) {
1506
+ const provideCache = {};
1507
+ Object.defineProperty(this, "_provided", {
1508
+ get: () => provideCache,
1509
+ set: (v) => Object.assign(provideCache, v)
1510
+ });
1511
+ }
1512
+ this._provided[piniaSymbol] = pinia;
1513
+ if (!this.$pinia) {
1514
+ this.$pinia = pinia;
1515
+ }
1516
+ pinia._a = this;
1517
+ if (IS_CLIENT) {
1518
+ setActivePinia(pinia);
1519
+ }
1520
+ if (IS_CLIENT) {
1521
+ registerPiniaDevtools(pinia._a, pinia);
1522
+ }
1523
+ } else if (!this.$pinia && options.parent && options.parent.$pinia) {
1524
+ this.$pinia = options.parent.$pinia;
1525
+ }
1526
+ },
1527
+ destroyed() {
1528
+ delete this._pStores;
1529
+ }
1530
+ });
1531
+ };
1532
+ export {
1533
+ MutationType,
1534
+ PiniaVuePlugin,
1535
+ acceptHMRUpdate,
1536
+ createPinia,
1537
+ defineStore,
1538
+ disposePinia,
1539
+ getActivePinia,
1540
+ mapActions,
1541
+ mapGetters,
1542
+ mapState,
1543
+ mapStores,
1544
+ mapWritableState,
1545
+ setActivePinia,
1546
+ setMapStoreSuffix,
1547
+ shouldHydrate,
1548
+ skipHydrate,
1549
+ storeToRefs
1550
+ };
1551
+ /*! Bundled license information:
1552
+
1553
+ pinia/dist/pinia.mjs:
1554
+ (*!
1555
+ * pinia v2.3.1
1556
+ * (c) 2025 Eduardo San Martin Morote
1557
+ * @license MIT
1558
+ *)
1559
+ (*! #__NO_SIDE_EFFECTS__ *)
1560
+ */
1561
+ //# sourceMappingURL=pinia.js.map