@jskit-ai/assistant-voice 0.1.1 → 0.1.2

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 (47) hide show
  1. package/examples/conversation/package.json +8 -8
  2. package/package.json +1 -1
  3. package/examples/conversation/dist/assets/error-DOwCrGXH.js +0 -1
  4. package/examples/conversation/dist/assets/index-Bq1DwQwF.js +0 -90
  5. package/examples/conversation/dist/assets/index-Bw7_l3Cu.css +0 -1
  6. package/examples/conversation/dist/assets/placement-CUwf_TAl.js +0 -1
  7. package/examples/conversation/dist/assets/placementTopology-CUwf_TAl.js +0 -1
  8. package/examples/conversation/dist/index.html +0 -3
  9. package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js +0 -824
  10. package/examples/conversation/node_modules/.vite/deps/@jskit-ai_kernel_client_moduleBootstrap.js.map +0 -1
  11. package/examples/conversation/node_modules/.vite/deps/@mdi_js.js +0 -7450
  12. package/examples/conversation/node_modules/.vite/deps/@mdi_js.js.map +0 -1
  13. package/examples/conversation/node_modules/.vite/deps/@tanstack_vue-query.js +0 -3965
  14. package/examples/conversation/node_modules/.vite/deps/@tanstack_vue-query.js.map +0 -1
  15. package/examples/conversation/node_modules/.vite/deps/VTooltip-Nwckus73.js +0 -2311
  16. package/examples/conversation/node_modules/.vite/deps/VTooltip-Nwckus73.js.map +0 -1
  17. package/examples/conversation/node_modules/.vite/deps/_metadata.json +0 -110
  18. package/examples/conversation/node_modules/.vite/deps/defineComponent-Bx_4rnHZ.js +0 -710
  19. package/examples/conversation/node_modules/.vite/deps/defineComponent-Bx_4rnHZ.js.map +0 -1
  20. package/examples/conversation/node_modules/.vite/deps/dist-CUIjXXPV.js +0 -3878
  21. package/examples/conversation/node_modules/.vite/deps/dist-CUIjXXPV.js.map +0 -1
  22. package/examples/conversation/node_modules/.vite/deps/hotkey-parsing-B5h5TiMG.js +0 -1214
  23. package/examples/conversation/node_modules/.vite/deps/hotkey-parsing-B5h5TiMG.js.map +0 -1
  24. package/examples/conversation/node_modules/.vite/deps/icons-DPtxVIU0.js +0 -98
  25. package/examples/conversation/node_modules/.vite/deps/icons-DPtxVIU0.js.map +0 -1
  26. package/examples/conversation/node_modules/.vite/deps/json-rest-schema.js +0 -2071
  27. package/examples/conversation/node_modules/.vite/deps/json-rest-schema.js.map +0 -1
  28. package/examples/conversation/node_modules/.vite/deps/package.json +0 -3
  29. package/examples/conversation/node_modules/.vite/deps/pinia.js +0 -1453
  30. package/examples/conversation/node_modules/.vite/deps/pinia.js.map +0 -1
  31. package/examples/conversation/node_modules/.vite/deps/socket__io-client.js +0 -3899
  32. package/examples/conversation/node_modules/.vite/deps/socket__io-client.js.map +0 -1
  33. package/examples/conversation/node_modules/.vite/deps/theme-BSn2V8xv.js +0 -1301
  34. package/examples/conversation/node_modules/.vite/deps/theme-BSn2V8xv.js.map +0 -1
  35. package/examples/conversation/node_modules/.vite/deps/vue-router.js +0 -2989
  36. package/examples/conversation/node_modules/.vite/deps/vue-router.js.map +0 -1
  37. package/examples/conversation/node_modules/.vite/deps/vue.js +0 -2
  38. package/examples/conversation/node_modules/.vite/deps/vue.runtime.esm-bundler-DWdvffrK.js +0 -8890
  39. package/examples/conversation/node_modules/.vite/deps/vue.runtime.esm-bundler-DWdvffrK.js.map +0 -1
  40. package/examples/conversation/node_modules/.vite/deps/vuetify.js +0 -413
  41. package/examples/conversation/node_modules/.vite/deps/vuetify.js.map +0 -1
  42. package/examples/conversation/node_modules/.vite/deps/vuetify_components.js +0 -25370
  43. package/examples/conversation/node_modules/.vite/deps/vuetify_components.js.map +0 -1
  44. package/examples/conversation/node_modules/.vite/deps/vuetify_directives.js +0 -132
  45. package/examples/conversation/node_modules/.vite/deps/vuetify_directives.js.map +0 -1
  46. package/examples/conversation/node_modules/.vite/deps/vuetify_iconsets_mdi-svg.js +0 -70
  47. package/examples/conversation/node_modules/.vite/deps/vuetify_iconsets_mdi-svg.js.map +0 -1
@@ -1,1453 +0,0 @@
1
- import { $n as toRefs, Bn as markRaw, In as isReactive, Kn as ref, Ln as isReadonly, Mn as effectScope, Nn as getCurrentScope, Ot as nextTick, Qn as toRef, Rn as isRef, U as computed, Vn as onScopeDispose, Wn as reactive, Zn as toRaw, gn as watch, ht as hasInjectionContext, nr as unref, ut as getCurrentInstance, xt as inject } from "./vue.runtime.esm-bundler-DWdvffrK.js";
2
- import { n as createConsoleReporter, r as defineDiagnostics, t as setupDevToolsPlugin } from "./dist-CUIjXXPV.js";
3
- //#region ../../../../node_modules/pinia/dist/pinia.js
4
- /*!
5
- * pinia v4.0.3
6
- * (c) 2026 Eduardo San Martin Morote
7
- * @license MIT
8
- */
9
- var IS_CLIENT = typeof window !== "undefined";
10
- /**
11
- * Catalog of user-facing Pinia diagnostics. Each handle builds a diagnostic
12
- * and runs the reporters. All call sites are dev-only (`__DEV__` guarded or
13
- * HMR), so production builds drop the calls and tree-shake this catalog.
14
- */
15
- var diagnostics = /*#__PURE__*/ defineDiagnostics({
16
- reporters: [/*#__PURE__*/ createConsoleReporter()],
17
- codes: {
18
- PINIA_R1001: {
19
- why: "Directly pass all stores to \"mapStores()\" without putting them in an array. This will fail in production.",
20
- fix: "Replace mapStores([useAuthStore, useCartStore]) with mapStores(useAuthStore, useCartStore).",
21
- docs: "https://pinia.vuejs.org/cookbook/options-api.html#Giving-access-to-the-whole-store"
22
- },
23
- PINIA_R1002: {
24
- why: (p) => `A getter cannot have the same name as another state property. Found "${p.name}" in store "${p.id}".`,
25
- fix: "Rename either the getter or the state property.",
26
- docs: "https://pinia.vuejs.org/core-concepts/getters.html#Accessing-other-getters"
27
- },
28
- PINIA_R1003: {
29
- why: (p) => `The "state" must be a plain object. Found in store "${p.id}".`,
30
- fix: "Return a plain object, e.g. avoid state: () => new MyClass().",
31
- docs: "https://pinia.vuejs.org/core-concepts/state.html#State"
32
- },
33
- PINIA_R1004: {
34
- why: "Pinia instance not found in context. This falls back to the global activePinia, which exposes you to cross-request pollution on the server.",
35
- fix: "\"useStore()\" is a composable and follows the same rules: call it at the top of setup() (or another composable), or pass the pinia instance explicitly when used outside of a component.",
36
- docs: "https://pinia.vuejs.org/ssr/#Using-the-store-outside-of-setup-"
37
- },
38
- PINIA_R1005: {
39
- why: (p) => `The store id changed from "${p.from}" to "${p.to}", forcing a reload.`,
40
- docs: "https://pinia.vuejs.org/cookbook/hot-module-replacement.html#HMR-Hot-Module-Replacement-"
41
- },
42
- PINIA_R1006: {
43
- why: (p) => `Property "${p.key}" of store "${p.id}" is not reactive (not a ref, reactive object, or shallowRef), so storeToRefs() ignores it.`,
44
- fix: "If it should be reactive state, wrap it with ref(), reactive(), or shallowRef(). If it is an intentional non-reactive property, wrap it with markRaw() so storeToRefs() skips it explicitly.",
45
- docs: "https://pinia.vuejs.org/core-concepts/plugins.html#Adding-new-external-properties"
46
- },
47
- PINIA_R1007: {
48
- why: (p) => `The same callback was passed to "$subscribe()" of store "${p.id}" more than once. Subscriptions are deduplicated, so the duplicate is ignored.`,
49
- fix: "Subscribe each callback only once. If you need to resubscribe, call the returned function to remove the previous subscription first, or create a new function.",
50
- docs: "https://pinia.vuejs.org/core-concepts/state.html#Subscribing-to-the-state"
51
- }
52
- }
53
- });
54
- /**
55
- * setActivePinia must be called to handle SSR at the top of functions like
56
- * `fetch`, `setup`, `serverPrefetch` and others
57
- */
58
- var activePinia;
59
- /**
60
- * Sets or unsets the active pinia. Used in SSR and internally when calling
61
- * actions and getters
62
- *
63
- * @param pinia - Pinia instance
64
- */
65
- var setActivePinia = (pinia) => activePinia = pinia;
66
- /**
67
- * Get the currently active pinia if there is any.
68
- */
69
- var getActivePinia = () => {
70
- const pinia = hasInjectionContext() && inject(piniaSymbol);
71
- if (!pinia && !IS_CLIENT) diagnostics.PINIA_R1004({}, { method: "error" });
72
- return pinia || activePinia;
73
- };
74
- /**
75
- * Symbol used to provide/inject the pinia instance in the app. Used internally
76
- * and exposed for testing purposes and edge cases like storybook. Could break
77
- * in a minor, **USE AT YOUR OWN RISK**.
78
- *
79
- * For context, see:
80
- * - https://github.com/vuejs/pinia/issues/870
81
- * - https://github.com/vuejs/pinia/pull/2973
82
- *
83
- * @internal
84
- */
85
- var piniaSymbol = Symbol("pinia");
86
- function isPlainObject(o) {
87
- return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
88
- }
89
- /**
90
- * Possible types for SubscriptionCallback
91
- */
92
- var MutationType = /* @__PURE__ */ function(MutationType) {
93
- /**
94
- * Direct mutation of the state:
95
- *
96
- * - `store.name = 'new name'`
97
- * - `store.$state.name = 'new name'`
98
- * - `store.list.push('new item')`
99
- */
100
- MutationType["direct"] = "direct";
101
- /**
102
- * Mutated the state with `$patch` and an object
103
- *
104
- * - `store.$patch({ name: 'newName' })`
105
- */
106
- MutationType["patchObject"] = "patch object";
107
- /**
108
- * Mutated the state with `$patch` and a function
109
- *
110
- * - `store.$patch(state => state.name = 'newName')`
111
- */
112
- MutationType["patchFunction"] = "patch function";
113
- return MutationType;
114
- }({});
115
- var _global = /*#__PURE__*/ (() => 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 })();
116
- function bom(blob, { autoBom = false } = {}) {
117
- if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) return new Blob([String.fromCharCode(65279), blob], { type: blob.type });
118
- return blob;
119
- }
120
- function download(url, name, opts) {
121
- const xhr = new XMLHttpRequest();
122
- xhr.open("GET", url);
123
- xhr.responseType = "blob";
124
- xhr.onload = function() {
125
- saveAs(xhr.response, name, opts);
126
- };
127
- xhr.onerror = function() {
128
- console.error("could not download file");
129
- };
130
- xhr.send();
131
- }
132
- function corsEnabled(url) {
133
- const xhr = new XMLHttpRequest();
134
- xhr.open("HEAD", url, false);
135
- try {
136
- xhr.send();
137
- } catch (e) {}
138
- return xhr.status >= 200 && xhr.status <= 299;
139
- }
140
- function click(node) {
141
- try {
142
- node.dispatchEvent(new MouseEvent("click"));
143
- } catch (e) {
144
- const evt = new MouseEvent("click", {
145
- bubbles: true,
146
- cancelable: true,
147
- view: window,
148
- detail: 0,
149
- screenX: 80,
150
- screenY: 20,
151
- clientX: 80,
152
- clientY: 20,
153
- ctrlKey: false,
154
- altKey: false,
155
- shiftKey: false,
156
- metaKey: false,
157
- button: 0,
158
- relatedTarget: null
159
- });
160
- node.dispatchEvent(evt);
161
- }
162
- }
163
- var _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
164
- var isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent))();
165
- var saveAs = !IS_CLIENT ? () => {} : typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : "msSaveOrOpenBlob" in _navigator ? msSaveAs : fileSaverSaveAs;
166
- function downloadSaveAs(blob, name = "download", opts) {
167
- const a = document.createElement("a");
168
- a.download = name;
169
- a.rel = "noopener";
170
- if (typeof blob === "string") {
171
- a.href = blob;
172
- if (a.origin !== location.origin) if (corsEnabled(a.href)) download(blob, name, opts);
173
- else {
174
- a.target = "_blank";
175
- click(a);
176
- }
177
- else click(a);
178
- } else {
179
- a.href = URL.createObjectURL(blob);
180
- setTimeout(function() {
181
- URL.revokeObjectURL(a.href);
182
- }, 4e4);
183
- setTimeout(function() {
184
- click(a);
185
- }, 0);
186
- }
187
- }
188
- function msSaveAs(blob, name = "download", opts) {
189
- if (typeof blob === "string") if (corsEnabled(blob)) download(blob, name, opts);
190
- else {
191
- const a = document.createElement("a");
192
- a.href = blob;
193
- a.target = "_blank";
194
- setTimeout(function() {
195
- click(a);
196
- });
197
- }
198
- else navigator.msSaveOrOpenBlob(bom(blob, opts), name);
199
- }
200
- function fileSaverSaveAs(blob, name, opts, popup) {
201
- popup = popup || open("", "_blank");
202
- if (popup) popup.document.title = popup.document.body.innerText = "downloading...";
203
- if (typeof blob === "string") return download(blob, name, opts);
204
- const force = blob.type === "application/octet-stream";
205
- const isSafari = /constructor/i.test(String(_global.HTMLElement)) || "safari" in _global;
206
- const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
207
- if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
208
- const reader = new FileReader();
209
- reader.onloadend = function() {
210
- let url = reader.result;
211
- if (typeof url !== "string") {
212
- popup = null;
213
- throw new Error("Wrong reader.result type");
214
- }
215
- url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
216
- if (popup) popup.location.href = url;
217
- else location.assign(url);
218
- popup = null;
219
- };
220
- reader.readAsDataURL(blob);
221
- } else {
222
- const url = URL.createObjectURL(blob);
223
- if (popup) popup.location.assign(url);
224
- else location.href = url;
225
- popup = null;
226
- setTimeout(function() {
227
- URL.revokeObjectURL(url);
228
- }, 4e4);
229
- }
230
- }
231
- /**
232
- * Shows a toast or console.log
233
- *
234
- * @param message - message to log
235
- * @param type - different color of the tooltip
236
- */
237
- function toastMessage(message, type) {
238
- const piniaMessage = "🍍 " + message;
239
- if (type === "error") console.error(piniaMessage);
240
- else if (type === "warn") console.warn(piniaMessage);
241
- else console.debug(piniaMessage);
242
- }
243
- function isPinia(o) {
244
- return "_a" in o && "install" in o;
245
- }
246
- /**
247
- * Detects if a store getter is a writable computed (has a setter) so it can be
248
- * edited from devtools.
249
- */
250
- function isWritableComputed(store, key) {
251
- const rawProp = toRaw(store)[key];
252
- return isRef(rawProp) && !isReadonly(rawProp);
253
- }
254
- /**
255
- * This file contain devtools actions, they are not Pinia actions.
256
- */
257
- function checkClipboardAccess() {
258
- if (!("clipboard" in navigator)) {
259
- toastMessage(`Your browser doesn't support the Clipboard API`, "error");
260
- return true;
261
- }
262
- }
263
- function checkNotFocusedError(error) {
264
- if (error instanceof Error && error.message.toLowerCase().includes("document is not focused")) {
265
- toastMessage("You need to activate the \"Emulate a focused page\" setting in the \"Rendering\" panel of devtools.", "warn");
266
- return true;
267
- }
268
- return false;
269
- }
270
- async function actionGlobalCopyState(pinia) {
271
- if (checkClipboardAccess()) return;
272
- try {
273
- await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
274
- toastMessage("Global state copied to clipboard.");
275
- } catch (error) {
276
- if (checkNotFocusedError(error)) return;
277
- toastMessage(`Failed to serialize the state. Check the console for more details.`, "error");
278
- console.error(error);
279
- }
280
- }
281
- async function actionGlobalPasteState(pinia) {
282
- if (checkClipboardAccess()) return;
283
- try {
284
- loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText()));
285
- toastMessage("Global state pasted from clipboard.");
286
- } catch (error) {
287
- if (checkNotFocusedError(error)) return;
288
- toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, "error");
289
- console.error(error);
290
- }
291
- }
292
- async function actionGlobalSaveState(pinia) {
293
- try {
294
- saveAs(new Blob([JSON.stringify(pinia.state.value)], { type: "text/plain;charset=utf-8" }), "pinia-state.json");
295
- } catch (error) {
296
- toastMessage(`Failed to export the state as JSON. Check the console for more details.`, "error");
297
- console.error(error);
298
- }
299
- }
300
- var fileInput;
301
- function getFileOpener() {
302
- if (!fileInput) {
303
- fileInput = document.createElement("input");
304
- fileInput.type = "file";
305
- fileInput.accept = ".json";
306
- }
307
- function openFile() {
308
- return new Promise((resolve, reject) => {
309
- fileInput.onchange = async () => {
310
- const files = fileInput.files;
311
- if (!files) return resolve(null);
312
- const file = files.item(0);
313
- if (!file) return resolve(null);
314
- return resolve({
315
- text: await file.text(),
316
- file
317
- });
318
- };
319
- fileInput.oncancel = () => resolve(null);
320
- fileInput.onerror = reject;
321
- fileInput.click();
322
- });
323
- }
324
- return openFile;
325
- }
326
- async function actionGlobalOpenStateFile(pinia) {
327
- try {
328
- const result = await getFileOpener()();
329
- if (!result) return;
330
- const { text, file } = result;
331
- loadStoresState(pinia, JSON.parse(text));
332
- toastMessage(`Global state imported from "${file.name}".`);
333
- } catch (error) {
334
- toastMessage(`Failed to import the state from JSON. Check the console for more details.`, "error");
335
- console.error(error);
336
- }
337
- }
338
- function loadStoresState(pinia, state) {
339
- for (const key in state) {
340
- const storeState = pinia.state.value[key];
341
- if (storeState) Object.assign(storeState, state[key]);
342
- else pinia.state.value[key] = state[key];
343
- }
344
- }
345
- function formatDisplay(display) {
346
- return { _custom: { display } };
347
- }
348
- var PINIA_ROOT_LABEL = "🍍 Pinia (root)";
349
- var PINIA_ROOT_ID = "_root";
350
- function formatStoreForInspectorTree(store) {
351
- return isPinia(store) ? {
352
- id: PINIA_ROOT_ID,
353
- label: PINIA_ROOT_LABEL
354
- } : {
355
- id: store.$id,
356
- label: store.$id
357
- };
358
- }
359
- function formatStoreForInspectorState(store) {
360
- if (isPinia(store)) {
361
- const storeNames = Array.from(store._s.keys());
362
- const storeMap = store._s;
363
- return {
364
- state: storeNames.map((storeId) => ({
365
- editable: true,
366
- key: storeId,
367
- value: store.state.value[storeId]
368
- })),
369
- getters: storeNames.filter((id) => storeMap.get(id)._getters).map((id) => {
370
- const store = storeMap.get(id);
371
- return {
372
- editable: false,
373
- key: id,
374
- value: store._getters.reduce((getters, key) => {
375
- getters[key] = store[key];
376
- return getters;
377
- }, {})
378
- };
379
- })
380
- };
381
- }
382
- const state = { state: Object.keys(store.$state).map((key) => ({
383
- editable: true,
384
- key,
385
- value: store.$state[key]
386
- })) };
387
- if (store._getters && store._getters.length) state.getters = store._getters.map((getterName) => ({
388
- editable: isWritableComputed(store, getterName),
389
- key: getterName,
390
- value: store[getterName]
391
- }));
392
- if (store._customProperties.size) state.customProperties = Array.from(store._customProperties).map((key) => ({
393
- editable: true,
394
- key,
395
- value: store[key]
396
- }));
397
- return state;
398
- }
399
- function formatEventData(events) {
400
- if (!events) return {};
401
- if (Array.isArray(events)) return events.reduce((data, event) => {
402
- data.keys.push(event.key);
403
- data.operations.push(event.type);
404
- data.oldValue[event.key] = event.oldValue;
405
- data.newValue[event.key] = event.newValue;
406
- return data;
407
- }, {
408
- oldValue: {},
409
- keys: [],
410
- operations: [],
411
- newValue: {}
412
- });
413
- else return {
414
- operation: formatDisplay(events.type),
415
- key: formatDisplay(events.key),
416
- oldValue: events.oldValue,
417
- newValue: events.newValue
418
- };
419
- }
420
- function formatMutationType(type) {
421
- switch (type) {
422
- case "direct": return "mutation";
423
- case "patch function": return "$patch";
424
- case "patch object": return "$patch";
425
- default: return "unknown";
426
- }
427
- }
428
- var isTimelineActive = true;
429
- var componentStateTypes = [];
430
- var MUTATIONS_LAYER_ID = "pinia:mutations";
431
- var INSPECTOR_ID = "pinia";
432
- var { assign: assign$1 } = Object;
433
- /**
434
- * Gets the displayed name of a store in devtools
435
- *
436
- * @param id - id of the store
437
- * @returns a formatted string
438
- */
439
- var getStoreType = (id) => "🍍 " + id;
440
- /**
441
- * Add the pinia plugin without any store. Allows displaying a Pinia plugin tab
442
- * as soon as it is added to the application.
443
- *
444
- * @param app - Vue application
445
- * @param pinia - pinia instance
446
- */
447
- function registerPiniaDevtools(app, pinia) {
448
- setupDevToolsPlugin({
449
- id: "dev.esm.pinia",
450
- label: "Pinia 🍍",
451
- logo: "https://pinia.vuejs.org/logo.svg",
452
- packageName: "pinia",
453
- homepage: "https://pinia.vuejs.org",
454
- componentStateTypes,
455
- app
456
- }, (api) => {
457
- if (typeof api.now !== "function") 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.");
458
- api.addTimelineLayer({
459
- id: MUTATIONS_LAYER_ID,
460
- label: `Pinia 🍍`,
461
- color: 15064968
462
- });
463
- api.addInspector({
464
- id: INSPECTOR_ID,
465
- label: "Pinia 🍍",
466
- icon: "storage",
467
- treeFilterPlaceholder: "Search stores",
468
- actions: [
469
- {
470
- icon: "content_copy",
471
- action: () => {
472
- actionGlobalCopyState(pinia);
473
- },
474
- tooltip: "Serialize and copy the state"
475
- },
476
- {
477
- icon: "content_paste",
478
- action: async () => {
479
- await actionGlobalPasteState(pinia);
480
- api.sendInspectorTree(INSPECTOR_ID);
481
- api.sendInspectorState(INSPECTOR_ID);
482
- },
483
- tooltip: "Replace the state with the content of your clipboard"
484
- },
485
- {
486
- icon: "save",
487
- action: () => {
488
- actionGlobalSaveState(pinia);
489
- },
490
- tooltip: "Save the state as a JSON file"
491
- },
492
- {
493
- icon: "folder_open",
494
- action: async () => {
495
- await actionGlobalOpenStateFile(pinia);
496
- api.sendInspectorTree(INSPECTOR_ID);
497
- api.sendInspectorState(INSPECTOR_ID);
498
- },
499
- tooltip: "Import the state from a JSON file"
500
- }
501
- ],
502
- nodeActions: [{
503
- icon: "restore",
504
- tooltip: "Reset the state (with \"$reset\")",
505
- action: (nodeId) => {
506
- const store = pinia._s.get(nodeId);
507
- if (!store) toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, "warn");
508
- else if (typeof store.$reset !== "function") toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, "warn");
509
- else {
510
- store.$reset();
511
- toastMessage(`Store "${nodeId}" reset.`);
512
- }
513
- }
514
- }]
515
- });
516
- api.on.inspectComponent((payload) => {
517
- const proxy = payload.componentInstance && payload.componentInstance.proxy;
518
- if (proxy && proxy._pStores) {
519
- const piniaStores = payload.componentInstance.proxy._pStores;
520
- Object.values(piniaStores).forEach((store) => {
521
- payload.instanceData.state.push({
522
- type: getStoreType(store.$id),
523
- key: "state",
524
- editable: true,
525
- value: store._isOptionsAPI ? { _custom: {
526
- value: toRaw(store.$state),
527
- actions: [{
528
- icon: "restore",
529
- tooltip: "Reset the state of this store",
530
- action: () => store.$reset()
531
- }]
532
- } } : Object.keys(store.$state).reduce((state, key) => {
533
- state[key] = store.$state[key];
534
- return state;
535
- }, {})
536
- });
537
- if (store._getters && store._getters.length) payload.instanceData.state.push({
538
- type: getStoreType(store.$id),
539
- key: "getters",
540
- editable: false,
541
- value: store._getters.reduce((getters, key) => {
542
- try {
543
- getters[key] = store[key];
544
- } catch (error) {
545
- getters[key] = error;
546
- }
547
- return getters;
548
- }, {})
549
- });
550
- });
551
- }
552
- });
553
- api.on.getInspectorTree((payload) => {
554
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
555
- let stores = [pinia];
556
- stores = stores.concat(Array.from(pinia._s.values()));
557
- 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);
558
- }
559
- });
560
- globalThis.$pinia = pinia;
561
- api.on.getInspectorState((payload) => {
562
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
563
- const inspectedStore = payload.nodeId === "_root" ? pinia : pinia._s.get(payload.nodeId);
564
- if (!inspectedStore) return;
565
- if (inspectedStore) {
566
- if (payload.nodeId !== "_root") globalThis.$store = toRaw(inspectedStore);
567
- payload.state = formatStoreForInspectorState(inspectedStore);
568
- }
569
- }
570
- });
571
- api.on.editInspectorState((payload) => {
572
- if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
573
- const inspectedStore = payload.nodeId === "_root" ? pinia : pinia._s.get(payload.nodeId);
574
- if (!inspectedStore) return toastMessage(`store "${payload.nodeId}" not found`, "error");
575
- const { path } = payload;
576
- if (!isPinia(inspectedStore)) {
577
- if (path.length !== 1 || !inspectedStore._customProperties.has(path[0]) && !isWritableComputed(inspectedStore, path[0]) || path[0] in inspectedStore.$state) path.unshift("$state");
578
- } else path.unshift("state");
579
- isTimelineActive = false;
580
- payload.set(inspectedStore, path, payload.state.value);
581
- isTimelineActive = true;
582
- }
583
- });
584
- api.on.editComponentState((payload) => {
585
- if (payload.type.startsWith("🍍")) {
586
- const storeId = payload.type.replace(/^🍍\s*/, "");
587
- const store = pinia._s.get(storeId);
588
- if (!store) return toastMessage(`store "${storeId}" not found`, "error");
589
- const { path } = payload;
590
- if (path[0] !== "state") return toastMessage(`Invalid path for store "${storeId}":\n${path}\nOnly state can be modified.`);
591
- path[0] = "$state";
592
- isTimelineActive = false;
593
- payload.set(store, path, payload.state.value);
594
- isTimelineActive = true;
595
- }
596
- });
597
- });
598
- }
599
- function addStoreToDevtools(app, store) {
600
- if (!componentStateTypes.includes(getStoreType(store.$id))) componentStateTypes.push(getStoreType(store.$id));
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: { logStoreChanges: {
610
- label: "Notify about new/deleted stores",
611
- type: "boolean",
612
- defaultValue: true
613
- } }
614
- }, (api) => {
615
- const now = typeof api.now === "function" ? api.now.bind(api) : Date.now;
616
- store.$onAction(({ after, onError, name, args }) => {
617
- const groupId = runningActionId++;
618
- api.addTimelineEvent({
619
- layerId: MUTATIONS_LAYER_ID,
620
- event: {
621
- time: now(),
622
- title: "🛫 " + name,
623
- subtitle: "start",
624
- data: {
625
- store: formatDisplay(store.$id),
626
- action: formatDisplay(name),
627
- args
628
- },
629
- groupId
630
- }
631
- });
632
- after((result) => {
633
- activeAction = void 0;
634
- api.addTimelineEvent({
635
- layerId: MUTATIONS_LAYER_ID,
636
- event: {
637
- time: now(),
638
- title: "🛬 " + name,
639
- subtitle: "end",
640
- data: {
641
- store: formatDisplay(store.$id),
642
- action: formatDisplay(name),
643
- args,
644
- result
645
- },
646
- groupId
647
- }
648
- });
649
- });
650
- onError((error) => {
651
- activeAction = void 0;
652
- api.addTimelineEvent({
653
- layerId: MUTATIONS_LAYER_ID,
654
- event: {
655
- time: now(),
656
- logType: "error",
657
- title: "💥 " + name,
658
- subtitle: "end",
659
- data: {
660
- store: formatDisplay(store.$id),
661
- action: formatDisplay(name),
662
- args,
663
- error
664
- },
665
- groupId
666
- }
667
- });
668
- });
669
- }, true);
670
- store._customProperties.forEach((name) => {
671
- watch(() => unref(store[name]), (newValue, oldValue) => {
672
- api.notifyComponentUpdate();
673
- api.sendInspectorState(INSPECTOR_ID);
674
- if (isTimelineActive) api.addTimelineEvent({
675
- layerId: MUTATIONS_LAYER_ID,
676
- event: {
677
- time: now(),
678
- title: "Change",
679
- subtitle: name,
680
- data: {
681
- newValue,
682
- oldValue
683
- },
684
- groupId: activeAction
685
- }
686
- });
687
- }, { deep: true });
688
- });
689
- store.$subscribe(({ events, type }, state) => {
690
- api.notifyComponentUpdate();
691
- api.sendInspectorState(INSPECTOR_ID);
692
- if (!isTimelineActive) return;
693
- const eventData = {
694
- time: now(),
695
- title: formatMutationType(type),
696
- data: assign$1({ store: formatDisplay(store.$id) }, formatEventData(events)),
697
- groupId: activeAction
698
- };
699
- if (type === "patch function") eventData.subtitle = "⤵️";
700
- else if (type === "patch object") eventData.subtitle = "🧩";
701
- else if (events && !Array.isArray(events)) eventData.subtitle = events.type;
702
- if (events) eventData.data["rawEvent(s)"] = { _custom: {
703
- display: "DebuggerEvent",
704
- type: "object",
705
- tooltip: "raw DebuggerEvent[]",
706
- value: events
707
- } };
708
- api.addTimelineEvent({
709
- layerId: MUTATIONS_LAYER_ID,
710
- event: eventData
711
- });
712
- }, {
713
- detached: true,
714
- flush: "sync"
715
- });
716
- const hotUpdate = store._hotUpdate;
717
- store._hotUpdate = markRaw((newStore) => {
718
- hotUpdate(newStore);
719
- api.addTimelineEvent({
720
- layerId: MUTATIONS_LAYER_ID,
721
- event: {
722
- time: now(),
723
- title: "🔥 " + store.$id,
724
- subtitle: "HMR update",
725
- data: {
726
- store: formatDisplay(store.$id),
727
- info: formatDisplay(`HMR update`)
728
- }
729
- }
730
- });
731
- api.notifyComponentUpdate();
732
- api.sendInspectorTree(INSPECTOR_ID);
733
- api.sendInspectorState(INSPECTOR_ID);
734
- });
735
- const { $dispose } = store;
736
- store.$dispose = () => {
737
- $dispose();
738
- api.notifyComponentUpdate();
739
- api.sendInspectorTree(INSPECTOR_ID);
740
- api.sendInspectorState(INSPECTOR_ID);
741
- api.getSettings().logStoreChanges && toastMessage(`Disposed "${store.$id}" store 🗑`);
742
- };
743
- api.notifyComponentUpdate();
744
- api.sendInspectorTree(INSPECTOR_ID);
745
- api.sendInspectorState(INSPECTOR_ID);
746
- api.getSettings().logStoreChanges && toastMessage(`"${store.$id}" store installed 🆕`);
747
- });
748
- }
749
- var runningActionId = 0;
750
- var activeAction;
751
- /**
752
- * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the
753
- * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state
754
- * mutation to the action.
755
- *
756
- * @param store - store to patch
757
- * @param actionNames - list of actionst to patch
758
- */
759
- function patchActionForGrouping(store, actionNames, wrapWithProxy) {
760
- const actions = actionNames.reduce((storeActions, actionName) => {
761
- storeActions[actionName] = toRaw(store)[actionName];
762
- return storeActions;
763
- }, {});
764
- for (const actionName in actions) store[actionName] = function() {
765
- const _actionId = runningActionId;
766
- const trackedStore = wrapWithProxy ? new Proxy(store, {
767
- get(...args) {
768
- activeAction = _actionId;
769
- return Reflect.get(...args);
770
- },
771
- set(...args) {
772
- activeAction = _actionId;
773
- return Reflect.set(...args);
774
- }
775
- }) : store;
776
- activeAction = _actionId;
777
- const retValue = actions[actionName].apply(trackedStore, arguments);
778
- activeAction = void 0;
779
- return retValue;
780
- };
781
- }
782
- /**
783
- * pinia.use(devtoolsPlugin)
784
- */
785
- function devtoolsPlugin({ app, store, options }) {
786
- if (store.$id.startsWith("__hot:")) return;
787
- store._isOptionsAPI = !!options.state;
788
- if (!store._p._testing) {
789
- patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI);
790
- const originalHotUpdate = store._hotUpdate;
791
- toRaw(store)._hotUpdate = function(newStore) {
792
- originalHotUpdate.apply(this, arguments);
793
- patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI);
794
- };
795
- }
796
- addStoreToDevtools(app, store);
797
- }
798
- /**
799
- * Creates a Pinia instance to be used by the application
800
- */
801
- function createPinia() {
802
- const scope = effectScope(true);
803
- const state = scope.run(() => ref({}));
804
- let _p = [];
805
- let toBeInstalled = [];
806
- const pinia = markRaw({
807
- install(app) {
808
- setActivePinia(pinia);
809
- pinia._a = app;
810
- app.provide(piniaSymbol, pinia);
811
- app.config.globalProperties.$pinia = pinia;
812
- /* istanbul ignore else */
813
- if (IS_CLIENT) registerPiniaDevtools(app, pinia);
814
- toBeInstalled.forEach((plugin) => _p.push(plugin));
815
- toBeInstalled = [];
816
- },
817
- use(plugin) {
818
- if (!this._a) toBeInstalled.push(plugin);
819
- else _p.push(plugin);
820
- return this;
821
- },
822
- _p,
823
- _a: null,
824
- _e: scope,
825
- _s: /* @__PURE__ */ new Map(),
826
- state
827
- });
828
- if (IS_CLIENT && typeof Proxy !== "undefined") pinia.use(devtoolsPlugin);
829
- return pinia;
830
- }
831
- /**
832
- * Dispose a Pinia instance by stopping its effectScope and removing the state, plugins and stores. This is mostly
833
- * useful in tests, with both a testing pinia or a regular pinia and in applications that use multiple pinia instances.
834
- * Once disposed, the pinia instance cannot be used anymore.
835
- *
836
- * @param pinia - pinia instance
837
- */
838
- function disposePinia(pinia) {
839
- pinia._e.stop();
840
- pinia._s.clear();
841
- pinia._p.splice(0);
842
- pinia.state.value = {};
843
- pinia._a = null;
844
- }
845
- /**
846
- * Checks if a function is a `StoreDefinition`.
847
- *
848
- * @param fn - object to test
849
- * @returns true if `fn` is a StoreDefinition
850
- */
851
- var isUseStore = (fn) => {
852
- return typeof fn === "function" && typeof fn.$id === "string";
853
- };
854
- /**
855
- * Mutates in place `newState` with `oldState` to _hot update_ it. It will
856
- * remove any key not existing in `newState` and recursively merge plain
857
- * objects.
858
- *
859
- * @param newState - new state object to be patched
860
- * @param oldState - old state that should be used to patch newState
861
- * @returns - newState
862
- */
863
- function patchObject(newState, oldState) {
864
- for (const key in oldState) {
865
- const subPatch = oldState[key];
866
- if (!(key in newState)) continue;
867
- const targetValue = newState[key];
868
- if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) newState[key] = patchObject(targetValue, subPatch);
869
- else newState[key] = subPatch;
870
- }
871
- return newState;
872
- }
873
- /**
874
- * Creates an _accept_ function to pass to `import.meta.hot` in Vite applications.
875
- *
876
- * @example
877
- * ```js
878
- * const useUser = defineStore(...)
879
- * if (import.meta.hot) {
880
- * import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot))
881
- * }
882
- * ```
883
- *
884
- * @param initialUseStore - return of the defineStore to hot update
885
- * @param hot - `import.meta.hot`
886
- */
887
- function acceptHMRUpdate(initialUseStore, hot) {
888
- return (newModule) => {
889
- const pinia = hot.data.pinia || initialUseStore._pinia;
890
- if (!pinia) return;
891
- hot.data.pinia = pinia;
892
- for (const exportName in newModule) {
893
- const useStore = newModule[exportName];
894
- if (isUseStore(useStore) && pinia._s.has(useStore.$id)) {
895
- const id = useStore.$id;
896
- if (id !== initialUseStore.$id) {
897
- diagnostics.PINIA_R1005({
898
- from: initialUseStore.$id,
899
- to: id
900
- });
901
- return hot.invalidate();
902
- }
903
- const existingStore = pinia._s.get(id);
904
- if (!existingStore) {
905
- console.log(`[Pinia]: skipping hmr because store doesn't exist yet`);
906
- return;
907
- }
908
- useStore(pinia, existingStore);
909
- }
910
- }
911
- };
912
- }
913
- var noop = () => {};
914
- function addSubscription(subscriptions, callback, detached, onCleanup = noop) {
915
- subscriptions.add(callback);
916
- const removeSubscription = () => {
917
- subscriptions.delete(callback) && onCleanup();
918
- };
919
- if (!detached && getCurrentScope()) onScopeDispose(removeSubscription);
920
- return removeSubscription;
921
- }
922
- function triggerSubscriptions(subscriptions, ...args) {
923
- subscriptions.forEach((callback) => {
924
- callback(...args);
925
- });
926
- }
927
- var fallbackRunWithContext = (fn) => fn();
928
- /**
929
- * Marks a function as an action for `$onAction`
930
- * @internal
931
- */
932
- var ACTION_MARKER = Symbol();
933
- /**
934
- * Action name symbol. Allows to add a name to an action after defining it
935
- * @internal
936
- */
937
- var ACTION_NAME = Symbol();
938
- function mergeReactiveObjects(target, patchToApply) {
939
- if (target instanceof Map && patchToApply instanceof Map) patchToApply.forEach((value, key) => target.set(key, value));
940
- else if (target instanceof Set && patchToApply instanceof Set) patchToApply.forEach(target.add, target);
941
- for (const key in patchToApply) {
942
- if (!Object.hasOwn(patchToApply, key)) continue;
943
- const subPatch = patchToApply[key];
944
- const targetValue = target[key];
945
- if (isPlainObject(targetValue) && isPlainObject(subPatch) && Object.hasOwn(target, key) && !isRef(subPatch) && !isReactive(subPatch)) target[key] = mergeReactiveObjects(targetValue, subPatch);
946
- else target[key] = subPatch;
947
- }
948
- return target;
949
- }
950
- var skipHydrateSymbol = Symbol("pinia:skipHydration");
951
- /**
952
- * Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
953
- * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store.
954
- *
955
- * @param obj - target object
956
- * @returns obj
957
- */
958
- function skipHydrate(obj) {
959
- return Object.defineProperty(obj, skipHydrateSymbol, {});
960
- }
961
- /**
962
- * Returns whether a value should be hydrated
963
- *
964
- * @param obj - target variable
965
- * @returns true if `obj` should be hydrated
966
- */
967
- function shouldHydrate(obj) {
968
- return !obj || typeof obj !== "object" || !Object.hasOwn(obj, skipHydrateSymbol);
969
- }
970
- var { assign } = Object;
971
- function isComputed(o) {
972
- return !!(isRef(o) && o.effect);
973
- }
974
- function createOptionsStore(id, options, pinia, hot) {
975
- const { state, actions, getters } = options;
976
- const initialState = pinia.state.value[id];
977
- let store;
978
- function setup() {
979
- if (!initialState && !hot)
980
- /* istanbul ignore if */
981
- pinia.state.value[id] = state ? state() : {};
982
- const localState = hot ? toRefs(ref(state ? state() : {}).value) : toRefs(pinia.state.value[id]);
983
- return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
984
- if (name in localState) diagnostics.PINIA_R1002({
985
- name,
986
- id
987
- });
988
- computedGetters[name] = markRaw(computed(() => {
989
- setActivePinia(pinia);
990
- const store = pinia._s.get(id);
991
- return getters[name].call(store, store);
992
- }));
993
- return computedGetters;
994
- }, {}));
995
- }
996
- store = createSetupStore(id, setup, options, pinia, hot, true);
997
- return store;
998
- }
999
- function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
1000
- let scope;
1001
- const optionsForPlugin = assign({ actions: {} }, options);
1002
- /* istanbul ignore if */
1003
- if (!pinia._e.active) throw new Error("Pinia destroyed");
1004
- const $subscribeOptions = { deep: true };
1005
- $subscribeOptions.onTrigger = (event) => {
1006
- /* istanbul ignore else */
1007
- if (isListening) debuggerEvents = event;
1008
- else if (isListening === false && !store._hotUpdating)
1009
- /* istanbul ignore else */
1010
- if (Array.isArray(debuggerEvents)) debuggerEvents.push(event);
1011
- else console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.");
1012
- };
1013
- let isListening;
1014
- let isSyncListening;
1015
- let subscriptions = /* @__PURE__ */ new Set();
1016
- let actionSubscriptions = /* @__PURE__ */ new Set();
1017
- let debuggerEvents;
1018
- const initialState = pinia.state.value[$id];
1019
- if (!isOptionsStore && !initialState && !hot)
1020
- /* istanbul ignore if */
1021
- pinia.state.value[$id] = {};
1022
- const hotState = /*#__PURE__*/ ref({});
1023
- let activeListener;
1024
- function $patch(partialStateOrMutator) {
1025
- let subscriptionMutation;
1026
- isListening = isSyncListening = false;
1027
- debuggerEvents = [];
1028
- if (typeof partialStateOrMutator === "function") {
1029
- partialStateOrMutator(pinia.state.value[$id]);
1030
- subscriptionMutation = {
1031
- type: "patch function",
1032
- storeId: $id,
1033
- events: debuggerEvents
1034
- };
1035
- } else {
1036
- mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
1037
- subscriptionMutation = {
1038
- type: "patch object",
1039
- payload: partialStateOrMutator,
1040
- storeId: $id,
1041
- events: debuggerEvents
1042
- };
1043
- }
1044
- const myListenerId = activeListener = Symbol();
1045
- nextTick().then(() => {
1046
- if (activeListener === myListenerId) isListening = true;
1047
- });
1048
- isSyncListening = true;
1049
- triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
1050
- }
1051
- const $reset = isOptionsStore ? function $reset() {
1052
- const { state } = options;
1053
- const newState = state ? state() : {};
1054
- this.$patch(($state) => {
1055
- assign($state, newState);
1056
- });
1057
- } : () => {
1058
- throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
1059
- };
1060
- function $dispose() {
1061
- scope.stop();
1062
- subscriptions.clear();
1063
- actionSubscriptions.clear();
1064
- pinia._s.delete($id);
1065
- }
1066
- /**
1067
- * Helper that wraps function so it can be tracked with $onAction
1068
- * @param fn - action to wrap
1069
- * @param name - name of the action
1070
- */
1071
- const action = (fn, name = "") => {
1072
- if (ACTION_MARKER in fn) {
1073
- fn[ACTION_NAME] = name;
1074
- return fn;
1075
- }
1076
- const wrappedAction = function() {
1077
- setActivePinia(pinia);
1078
- const args = Array.from(arguments);
1079
- const afterCallbackSet = /* @__PURE__ */ new Set();
1080
- const onErrorCallbackSet = /* @__PURE__ */ new Set();
1081
- function after(callback) {
1082
- afterCallbackSet.add(callback);
1083
- }
1084
- function onError(callback) {
1085
- onErrorCallbackSet.add(callback);
1086
- }
1087
- triggerSubscriptions(actionSubscriptions, {
1088
- args,
1089
- name: wrappedAction[ACTION_NAME],
1090
- store,
1091
- after,
1092
- onError
1093
- });
1094
- let ret;
1095
- try {
1096
- ret = fn.apply(this && this.$id === $id ? this : store, args);
1097
- } catch (error) {
1098
- triggerSubscriptions(onErrorCallbackSet, error);
1099
- throw error;
1100
- }
1101
- if (ret instanceof Promise) return ret.then((value) => {
1102
- triggerSubscriptions(afterCallbackSet, value);
1103
- return value;
1104
- }).catch((error) => {
1105
- triggerSubscriptions(onErrorCallbackSet, error);
1106
- return Promise.reject(error);
1107
- });
1108
- triggerSubscriptions(afterCallbackSet, ret);
1109
- return ret;
1110
- };
1111
- wrappedAction[ACTION_MARKER] = true;
1112
- wrappedAction[ACTION_NAME] = name;
1113
- return wrappedAction;
1114
- };
1115
- const _hmrPayload = /*#__PURE__*/ markRaw({
1116
- actions: {},
1117
- getters: {},
1118
- state: [],
1119
- hotState
1120
- });
1121
- const partialStore = {
1122
- _p: pinia,
1123
- $id,
1124
- $onAction: addSubscription.bind(null, actionSubscriptions),
1125
- $patch,
1126
- $reset,
1127
- $subscribe(callback, options = {}) {
1128
- if (subscriptions.has(callback)) {
1129
- diagnostics.PINIA_R1007({ id: $id });
1130
- return noop;
1131
- }
1132
- const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher());
1133
- const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
1134
- if (options.flush === "sync" ? isSyncListening : isListening) callback({
1135
- storeId: $id,
1136
- type: "direct",
1137
- events: debuggerEvents
1138
- }, state);
1139
- }, assign({}, $subscribeOptions, options)));
1140
- return removeSubscription;
1141
- },
1142
- $dispose
1143
- };
1144
- const store = reactive(assign({
1145
- _hmrPayload,
1146
- _customProperties: markRaw(/* @__PURE__ */ new Set())
1147
- }, partialStore));
1148
- pinia._s.set($id, store);
1149
- const setupStore = (pinia._a && pinia._a.runWithContext || fallbackRunWithContext)(() => pinia._e.run(() => (scope = effectScope()).run(() => setup({ action }))));
1150
- for (const key in setupStore) {
1151
- const prop = setupStore[key];
1152
- if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
1153
- if (hot) hotState.value[key] = toRef(setupStore, key);
1154
- else if (!isOptionsStore) {
1155
- if (initialState && shouldHydrate(prop)) if (isRef(prop)) prop.value = initialState[key];
1156
- else {
1157
- if (prop instanceof Set || prop instanceof Map) prop.clear();
1158
- mergeReactiveObjects(prop, initialState[key]);
1159
- }
1160
- pinia.state.value[$id][key] = prop;
1161
- }
1162
- _hmrPayload.state.push(key);
1163
- } else if (typeof prop === "function") {
1164
- setupStore[key] = hot ? prop : action(prop, key);
1165
- _hmrPayload.actions[key] = prop;
1166
- optionsForPlugin.actions[key] = prop;
1167
- } else if (isComputed(prop)) {
1168
- _hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
1169
- if (IS_CLIENT) (setupStore._getters || (setupStore._getters = markRaw([]))).push(key);
1170
- }
1171
- }
1172
- /* istanbul ignore if */
1173
- assign(store, setupStore);
1174
- assign(toRaw(store), setupStore);
1175
- Object.defineProperty(store, "$state", {
1176
- get: () => hot ? hotState.value : pinia.state.value[$id],
1177
- set: (state) => {
1178
- /* istanbul ignore if */
1179
- if (hot) throw new Error("cannot set hotState");
1180
- $patch(($state) => {
1181
- assign($state, state);
1182
- });
1183
- }
1184
- });
1185
- store._hotUpdate = markRaw((newStore) => {
1186
- store._hotUpdating = true;
1187
- newStore._hmrPayload.state.forEach((stateKey) => {
1188
- if (stateKey in store.$state) {
1189
- const newStateTarget = newStore.$state[stateKey];
1190
- const oldStateSource = store.$state[stateKey];
1191
- if (isOptionsStore && typeof newStateTarget === "object" && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) patchObject(newStateTarget, oldStateSource);
1192
- else newStore.$state[stateKey] = oldStateSource;
1193
- }
1194
- store[stateKey] = toRef(newStore.$state, stateKey);
1195
- });
1196
- Object.keys(store.$state).forEach((stateKey) => {
1197
- if (!(stateKey in newStore.$state)) delete store[stateKey];
1198
- });
1199
- isListening = false;
1200
- isSyncListening = false;
1201
- pinia.state.value[$id] = toRef(newStore._hmrPayload, "hotState");
1202
- isSyncListening = true;
1203
- nextTick().then(() => {
1204
- isListening = true;
1205
- });
1206
- for (const actionName in newStore._hmrPayload.actions) {
1207
- const actionFn = newStore[actionName];
1208
- store[actionName] = action(actionFn, actionName);
1209
- }
1210
- for (const getterName in newStore._hmrPayload.getters) {
1211
- const getter = newStore._hmrPayload.getters[getterName];
1212
- const getterValue = isOptionsStore ? computed(() => {
1213
- setActivePinia(pinia);
1214
- return getter.call(store, store);
1215
- }) : getter;
1216
- store[getterName] = getterValue;
1217
- }
1218
- Object.keys(store._hmrPayload.getters).forEach((key) => {
1219
- if (!(key in newStore._hmrPayload.getters)) delete store[key];
1220
- });
1221
- Object.keys(store._hmrPayload.actions).forEach((key) => {
1222
- if (!(key in newStore._hmrPayload.actions)) delete store[key];
1223
- });
1224
- store._hmrPayload = newStore._hmrPayload;
1225
- store._getters = newStore._getters;
1226
- store._hotUpdating = false;
1227
- });
1228
- if (IS_CLIENT) {
1229
- const nonEnumerable = {
1230
- writable: true,
1231
- configurable: true,
1232
- enumerable: false
1233
- };
1234
- [
1235
- "_p",
1236
- "_hmrPayload",
1237
- "_getters",
1238
- "_customProperties"
1239
- ].forEach((p) => {
1240
- Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable));
1241
- });
1242
- }
1243
- pinia._p.forEach((extender) => {
1244
- const extensions = scope.run(() => extender({
1245
- store,
1246
- app: pinia._a,
1247
- pinia,
1248
- options: optionsForPlugin
1249
- }));
1250
- /* istanbul ignore else */
1251
- if (IS_CLIENT) Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
1252
- for (const key in extensions) {
1253
- const value = extensions[key];
1254
- if (typeof value === "object" && !isRef(value) && !isReactive(value) && !value?.__v_skip) diagnostics.PINIA_R1006({
1255
- key,
1256
- id: $id
1257
- });
1258
- }
1259
- assign(store, extensions);
1260
- });
1261
- if (store.$state && typeof store.$state === "object" && typeof store.$state.constructor === "function" && !store.$state.constructor.toString().includes("[native code]")) diagnostics.PINIA_R1003({ id: store.$id });
1262
- if (initialState && isOptionsStore && options.hydrate) options.hydrate(store.$state, initialState);
1263
- isListening = true;
1264
- isSyncListening = true;
1265
- return store;
1266
- }
1267
- /*! #__NO_SIDE_EFFECTS__ */
1268
- function defineStore(id, setup, setupOptions) {
1269
- let options;
1270
- const isSetupStore = typeof setup === "function";
1271
- options = isSetupStore ? setupOptions : setup;
1272
- function useStore(pinia, hot) {
1273
- const hasContext = hasInjectionContext();
1274
- pinia = pinia || (hasContext ? inject(piniaSymbol, null) : null);
1275
- if (pinia) setActivePinia(pinia);
1276
- if (!activePinia) throw new Error("[🍍]: \"getActivePinia()\" was called but there was no active Pinia. Are you trying to use a store before calling \"app.use(pinia)\"?\nSee https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\nThis will fail in production.");
1277
- pinia = activePinia;
1278
- if (!pinia._s.has(id)) {
1279
- if (isSetupStore) createSetupStore(id, setup, options, pinia);
1280
- else createOptionsStore(id, options, pinia);
1281
- useStore._pinia = pinia;
1282
- }
1283
- const store = pinia._s.get(id);
1284
- if (hot) {
1285
- const hotId = "__hot:" + id;
1286
- const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
1287
- hot._hotUpdate(newStore);
1288
- delete pinia.state.value[hotId];
1289
- pinia._s.delete(hotId);
1290
- }
1291
- if (IS_CLIENT) {
1292
- const currentInstance = getCurrentInstance();
1293
- if (currentInstance && currentInstance.proxy && !hot) {
1294
- const vm = currentInstance.proxy;
1295
- const cache = "_pStores" in vm ? vm._pStores : vm._pStores = {};
1296
- cache[id] = store;
1297
- }
1298
- }
1299
- return store;
1300
- }
1301
- useStore.$id = id;
1302
- return useStore;
1303
- }
1304
- var mapStoreSuffix = "Store";
1305
- /**
1306
- * Changes the suffix added by `mapStores()`. Can be set to an empty string.
1307
- * Defaults to `"Store"`. Make sure to extend the MapStoresCustomization
1308
- * interface if you are using TypeScript.
1309
- *
1310
- * @param suffix - new suffix
1311
- */
1312
- function setMapStoreSuffix(suffix) {
1313
- mapStoreSuffix = suffix;
1314
- }
1315
- /**
1316
- * Allows using stores without the composition API (`setup()`) by generating an
1317
- * object to be spread in the `computed` field of a component. It accepts a list
1318
- * of store definitions.
1319
- *
1320
- * @example
1321
- * ```js
1322
- * export default {
1323
- * computed: {
1324
- * // other computed properties
1325
- * ...mapStores(useUserStore, useCartStore)
1326
- * },
1327
- *
1328
- * created() {
1329
- * this.userStore // store with id "user"
1330
- * this.cartStore // store with id "cart"
1331
- * }
1332
- * }
1333
- * ```
1334
- *
1335
- * @param stores - list of stores to map to an object
1336
- */
1337
- function mapStores(...stores) {
1338
- if (Array.isArray(stores[0])) {
1339
- diagnostics.PINIA_R1001();
1340
- stores = stores[0];
1341
- }
1342
- return stores.reduce((reduced, useStore) => {
1343
- reduced[useStore.$id + mapStoreSuffix] = function() {
1344
- return useStore(this.$pinia);
1345
- };
1346
- return reduced;
1347
- }, {});
1348
- }
1349
- /**
1350
- * Allows using state and getters from one store without using the composition
1351
- * API (`setup()`) by generating an object to be spread in the `computed` field
1352
- * of a component.
1353
- *
1354
- * @param useStore - store to map from
1355
- * @param keysOrMapper - array or object
1356
- */
1357
- function mapState(useStore, keysOrMapper) {
1358
- return Array.isArray(keysOrMapper) ? keysOrMapper.reduce((reduced, key) => {
1359
- reduced[key] = function() {
1360
- return useStore(this.$pinia)[key];
1361
- };
1362
- return reduced;
1363
- }, {}) : Object.keys(keysOrMapper).reduce((reduced, key) => {
1364
- reduced[key] = function() {
1365
- const store = useStore(this.$pinia);
1366
- const storeKey = keysOrMapper[key];
1367
- return typeof storeKey === "function" ? storeKey.call(this, store) : store[storeKey];
1368
- };
1369
- return reduced;
1370
- }, {});
1371
- }
1372
- /**
1373
- * Alias for `mapState()`. You should use `mapState()` instead.
1374
- * @deprecated use `mapState()` instead.
1375
- */
1376
- var mapGetters = mapState;
1377
- /**
1378
- * Allows directly using actions from your store without using the composition
1379
- * API (`setup()`) by generating an object to be spread in the `methods` field
1380
- * of a component.
1381
- *
1382
- * @param useStore - store to map from
1383
- * @param keysOrMapper - array or object
1384
- */
1385
- function mapActions(useStore, keysOrMapper) {
1386
- return Array.isArray(keysOrMapper) ? keysOrMapper.reduce((reduced, key) => {
1387
- reduced[key] = function(...args) {
1388
- return useStore(this.$pinia)[key](...args);
1389
- };
1390
- return reduced;
1391
- }, {}) : Object.keys(keysOrMapper).reduce((reduced, key) => {
1392
- reduced[key] = function(...args) {
1393
- return useStore(this.$pinia)[keysOrMapper[key]](...args);
1394
- };
1395
- return reduced;
1396
- }, {});
1397
- }
1398
- /**
1399
- * Allows using state and getters from one store without using the composition
1400
- * API (`setup()`) by generating an object to be spread in the `computed` field
1401
- * of a component.
1402
- *
1403
- * @param useStore - store to map from
1404
- * @param keysOrMapper - array or object
1405
- */
1406
- function mapWritableState(useStore, keysOrMapper) {
1407
- return Array.isArray(keysOrMapper) ? keysOrMapper.reduce((reduced, key) => {
1408
- reduced[key] = {
1409
- get() {
1410
- return useStore(this.$pinia)[key];
1411
- },
1412
- set(value) {
1413
- return useStore(this.$pinia)[key] = value;
1414
- }
1415
- };
1416
- return reduced;
1417
- }, {}) : Object.keys(keysOrMapper).reduce((reduced, key) => {
1418
- reduced[key] = {
1419
- get() {
1420
- return useStore(this.$pinia)[keysOrMapper[key]];
1421
- },
1422
- set(value) {
1423
- return useStore(this.$pinia)[keysOrMapper[key]] = value;
1424
- }
1425
- };
1426
- return reduced;
1427
- }, {});
1428
- }
1429
- /**
1430
- * Creates an object of references with all the state, getters, and plugin-added
1431
- * state properties of the store. Similar to `toRefs()` but specifically
1432
- * designed for Pinia stores so methods and non reactive properties are
1433
- * completely ignored.
1434
- *
1435
- * @param store - store to extract the refs from
1436
- */
1437
- function storeToRefs(store) {
1438
- const rawStore = toRaw(store);
1439
- const refs = {};
1440
- for (const key in rawStore) {
1441
- const value = rawStore[key];
1442
- if (value?.effect) refs[key] = computed({
1443
- get: () => store[key],
1444
- set(value) {
1445
- store[key] = value;
1446
- }
1447
- });
1448
- else if (isRef(value) || isReactive(value)) refs[key] = toRef(store, key);
1449
- }
1450
- return refs;
1451
- }
1452
- //#endregion
1453
- export { MutationType, acceptHMRUpdate, createPinia, defineStore, disposePinia, getActivePinia, mapActions, mapGetters, mapState, mapStores, mapWritableState, piniaSymbol, setActivePinia, setMapStoreSuffix, shouldHydrate, skipHydrate, storeToRefs };