@authup/client-web-kit 1.0.0-beta.14 → 1.0.0-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var vue = require('vue');
6
5
  var coreKit = require('@authup/core-kit');
6
+ var vue = require('vue');
7
7
  var coreHttpKit = require('@authup/core-http-kit');
8
+ var pinia = require('pinia');
8
9
  var kit = require('@authup/kit');
9
10
  var smob = require('smob');
10
11
  var listControls = require('@vuecs/list-controls');
@@ -17,644 +18,6 @@ var useVuelidate = require('@vuelidate/core');
17
18
  var pagination = require('@vuecs/pagination');
18
19
  var Cookie = require('universal-cookie');
19
20
 
20
- var isVue2 = false;
21
- function set(target, key, val) {
22
- if (Array.isArray(target)) {
23
- target.length = Math.max(target.length, key);
24
- target.splice(key, 1, val);
25
- return val;
26
- }
27
- target[key] = val;
28
- return val;
29
- }
30
- function del(target, key) {
31
- if (Array.isArray(target)) {
32
- target.splice(key, 1);
33
- return;
34
- }
35
- delete target[key];
36
- }
37
-
38
- /**
39
- * setActivePinia must be called to handle SSR at the top of functions like
40
- * `fetch`, `setup`, `serverPrefetch` and others
41
- */ let activePinia;
42
- /**
43
- * Sets or unsets the active pinia. Used in SSR and internally when calling
44
- * actions and getters
45
- *
46
- * @param pinia - Pinia instance
47
- */ // @ts-expect-error: cannot constrain the type of the return
48
- const setActivePinia = (pinia)=>activePinia = pinia;
49
- const piniaSymbol = process.env.NODE_ENV !== 'production' ? Symbol('pinia') : /* istanbul ignore next */ Symbol();
50
- function isPlainObject(// eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- o) {
52
- return o && typeof o === 'object' && Object.prototype.toString.call(o) === '[object Object]' && typeof o.toJSON !== 'function';
53
- }
54
- // type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
55
- // TODO: can we change these to numbers?
56
- /**
57
- * Possible types for SubscriptionCallback
58
- */ var MutationType;
59
- (function(MutationType) {
60
- /**
61
- * Direct mutation of the state:
62
- *
63
- * - `store.name = 'new name'`
64
- * - `store.$state.name = 'new name'`
65
- * - `store.list.push('new item')`
66
- */ MutationType["direct"] = "direct";
67
- /**
68
- * Mutated the state with `$patch` and an object
69
- *
70
- * - `store.$patch({ name: 'newName' })`
71
- */ MutationType["patchObject"] = "patch object";
72
- /**
73
- * Mutated the state with `$patch` and a function
74
- *
75
- * - `store.$patch(state => state.name = 'newName')`
76
- */ MutationType["patchFunction"] = "patch function";
77
- // maybe reset? for $state = {} and $reset
78
- })(MutationType || (MutationType = {}));
79
- const IS_CLIENT = typeof window !== 'undefined';
80
- /**
81
- * Should we add the devtools plugins.
82
- * - only if dev mode or forced through the prod devtools flag
83
- * - not in test
84
- * - only if window exists (could change in the future)
85
- */ const USE_DEVTOOLS = (process.env.NODE_ENV !== 'production' || typeof __VUE_PROD_DEVTOOLS__ !== 'undefined' && __VUE_PROD_DEVTOOLS__) && !(process.env.NODE_ENV === 'test') && IS_CLIENT;
86
- /**
87
- * Mutates in place `newState` with `oldState` to _hot update_ it. It will
88
- * remove any key not existing in `newState` and recursively merge plain
89
- * objects.
90
- *
91
- * @param newState - new state object to be patched
92
- * @param oldState - old state that should be used to patch newState
93
- * @returns - newState
94
- */ function patchObject(newState, oldState) {
95
- // no need to go through symbols because they cannot be serialized anyway
96
- for(const key in oldState){
97
- const subPatch = oldState[key];
98
- // skip the whole sub tree
99
- if (!(key in newState)) {
100
- continue;
101
- }
102
- const targetValue = newState[key];
103
- if (isPlainObject(targetValue) && isPlainObject(subPatch) && !vue.isRef(subPatch) && !vue.isReactive(subPatch)) {
104
- newState[key] = patchObject(targetValue, subPatch);
105
- } else {
106
- // objects are either a bit more complex (e.g. refs) or primitives, so we
107
- // just set the whole thing
108
- {
109
- newState[key] = subPatch;
110
- }
111
- }
112
- }
113
- return newState;
114
- }
115
- const noop$1 = ()=>{};
116
- function addSubscription(subscriptions, callback, detached, onCleanup = noop$1) {
117
- subscriptions.push(callback);
118
- const removeSubscription = ()=>{
119
- const idx = subscriptions.indexOf(callback);
120
- if (idx > -1) {
121
- subscriptions.splice(idx, 1);
122
- onCleanup();
123
- }
124
- };
125
- if (!detached && vue.getCurrentScope()) {
126
- vue.onScopeDispose(removeSubscription);
127
- }
128
- return removeSubscription;
129
- }
130
- function triggerSubscriptions(subscriptions, ...args) {
131
- subscriptions.slice().forEach((callback)=>{
132
- callback(...args);
133
- });
134
- }
135
- const fallbackRunWithContext = (fn)=>fn();
136
- function mergeReactiveObjects(target, patchToApply) {
137
- // Handle Map instances
138
- if (target instanceof Map && patchToApply instanceof Map) {
139
- patchToApply.forEach((value, key)=>target.set(key, value));
140
- }
141
- // Handle Set instances
142
- if (target instanceof Set && patchToApply instanceof Set) {
143
- patchToApply.forEach(target.add, target);
144
- }
145
- // no need to go through symbols because they cannot be serialized anyway
146
- for(const key in patchToApply){
147
- if (!patchToApply.hasOwnProperty(key)) continue;
148
- const subPatch = patchToApply[key];
149
- const targetValue = target[key];
150
- if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !vue.isRef(subPatch) && !vue.isReactive(subPatch)) {
151
- // NOTE: here I wanted to warn about inconsistent types but it's not possible because in setup stores one might
152
- // start the value of a property as a certain type e.g. a Map, and then for some reason, during SSR, change that
153
- // to `undefined`. When trying to hydrate, we want to override the Map with `undefined`.
154
- target[key] = mergeReactiveObjects(targetValue, subPatch);
155
- } else {
156
- // @ts-expect-error: subPatch is a valid value
157
- target[key] = subPatch;
158
- }
159
- }
160
- return target;
161
- }
162
- const skipHydrateSymbol = process.env.NODE_ENV !== 'production' ? Symbol('pinia:skipHydration') : /* istanbul ignore next */ Symbol();
163
- /**
164
- * Returns whether a value should be hydrated
165
- *
166
- * @param obj - target variable
167
- * @returns true if `obj` should be hydrated
168
- */ function shouldHydrate(obj) {
169
- return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
170
- }
171
- const { assign } = Object;
172
- function isComputed(o) {
173
- return !!(vue.isRef(o) && o.effect);
174
- }
175
- function createOptionsStore(id, options, pinia, hot) {
176
- const { state, actions, getters } = options;
177
- const initialState = pinia.state.value[id];
178
- let store;
179
- function setup() {
180
- if (!initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) {
181
- /* istanbul ignore if */ {
182
- pinia.state.value[id] = state ? state() : {};
183
- }
184
- }
185
- // avoid creating a state in pinia.state.value
186
- const localState = process.env.NODE_ENV !== 'production' && hot ? vue.toRefs(vue.ref(state ? state() : {}).value) : vue.toRefs(pinia.state.value[id]);
187
- return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name)=>{
188
- if (process.env.NODE_ENV !== 'production' && name in localState) {
189
- console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`);
190
- }
191
- computedGetters[name] = vue.markRaw(vue.computed(()=>{
192
- setActivePinia(pinia);
193
- // it was created just before
194
- const store = pinia._s.get(id);
195
- // @ts-expect-error
196
- // return getters![name].call(context, context)
197
- // TODO: avoid reading the getter while assigning with a global variable
198
- return getters[name].call(store, store);
199
- }));
200
- return computedGetters;
201
- }, {}));
202
- }
203
- store = createSetupStore(id, setup, options, pinia, hot, true);
204
- return store;
205
- }
206
- function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
207
- let scope;
208
- const optionsForPlugin = assign({
209
- actions: {}
210
- }, options);
211
- /* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && !pinia._e.active) {
212
- throw new Error('Pinia destroyed');
213
- }
214
- // watcher options for $subscribe
215
- const $subscribeOptions = {
216
- deep: true
217
- };
218
- /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production' && !isVue2) {
219
- $subscribeOptions.onTrigger = (event)=>{
220
- /* istanbul ignore else */ if (isListening) {
221
- debuggerEvents = event;
222
- // avoid triggering this while the store is being built and the state is being set in pinia
223
- } else if (isListening == false && !store._hotUpdating) {
224
- // let patch send all the events together later
225
- /* istanbul ignore else */ if (Array.isArray(debuggerEvents)) {
226
- debuggerEvents.push(event);
227
- } else {
228
- console.error('🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.');
229
- }
230
- }
231
- };
232
- }
233
- // internal state
234
- let isListening; // set to true at the end
235
- let isSyncListening; // set to true at the end
236
- let subscriptions = [];
237
- let actionSubscriptions = [];
238
- let debuggerEvents;
239
- const initialState = pinia.state.value[$id];
240
- // avoid setting the state for option stores if it is set
241
- // by the setup
242
- if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== 'production') || !hot)) {
243
- /* istanbul ignore if */ {
244
- pinia.state.value[$id] = {};
245
- }
246
- }
247
- const hotState = vue.ref({});
248
- // avoid triggering too many listeners
249
- // https://github.com/vuejs/pinia/issues/1129
250
- let activeListener;
251
- function $patch(partialStateOrMutator) {
252
- let subscriptionMutation;
253
- isListening = isSyncListening = false;
254
- // reset the debugger events since patches are sync
255
- /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
256
- debuggerEvents = [];
257
- }
258
- if (typeof partialStateOrMutator === 'function') {
259
- partialStateOrMutator(pinia.state.value[$id]);
260
- subscriptionMutation = {
261
- type: MutationType.patchFunction,
262
- storeId: $id,
263
- events: debuggerEvents
264
- };
265
- } else {
266
- mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
267
- subscriptionMutation = {
268
- type: MutationType.patchObject,
269
- payload: partialStateOrMutator,
270
- storeId: $id,
271
- events: debuggerEvents
272
- };
273
- }
274
- const myListenerId = activeListener = Symbol();
275
- vue.nextTick().then(()=>{
276
- if (activeListener === myListenerId) {
277
- isListening = true;
278
- }
279
- });
280
- isSyncListening = true;
281
- // because we paused the watcher, we need to manually call the subscriptions
282
- triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
283
- }
284
- const $reset = isOptionsStore ? function $reset() {
285
- const { state } = options;
286
- const newState = state ? state() : {};
287
- // we use a patch to group all changes into one single subscription
288
- this.$patch(($state)=>{
289
- assign($state, newState);
290
- });
291
- } : /* istanbul ignore next */ process.env.NODE_ENV !== 'production' ? ()=>{
292
- throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
293
- } : noop$1;
294
- function $dispose() {
295
- scope.stop();
296
- subscriptions = [];
297
- actionSubscriptions = [];
298
- pinia._s.delete($id);
299
- }
300
- /**
301
- * Wraps an action to handle subscriptions.
302
- *
303
- * @param name - name of the action
304
- * @param action - action to wrap
305
- * @returns a wrapped action to handle subscriptions
306
- */ function wrapAction(name, action) {
307
- return function() {
308
- setActivePinia(pinia);
309
- const args = Array.from(arguments);
310
- const afterCallbackList = [];
311
- const onErrorCallbackList = [];
312
- function after(callback) {
313
- afterCallbackList.push(callback);
314
- }
315
- function onError(callback) {
316
- onErrorCallbackList.push(callback);
317
- }
318
- // @ts-expect-error
319
- triggerSubscriptions(actionSubscriptions, {
320
- args,
321
- name,
322
- store,
323
- after,
324
- onError
325
- });
326
- let ret;
327
- try {
328
- ret = action.apply(this && this.$id === $id ? this : store, args);
329
- // handle sync errors
330
- } catch (error) {
331
- triggerSubscriptions(onErrorCallbackList, error);
332
- throw error;
333
- }
334
- if (ret instanceof Promise) {
335
- return ret.then((value)=>{
336
- triggerSubscriptions(afterCallbackList, value);
337
- return value;
338
- }).catch((error)=>{
339
- triggerSubscriptions(onErrorCallbackList, error);
340
- return Promise.reject(error);
341
- });
342
- }
343
- // trigger after callbacks
344
- triggerSubscriptions(afterCallbackList, ret);
345
- return ret;
346
- };
347
- }
348
- const _hmrPayload = /*#__PURE__*/ vue.markRaw({
349
- actions: {},
350
- getters: {},
351
- state: [],
352
- hotState
353
- });
354
- const partialStore = {
355
- _p: pinia,
356
- // _s: scope,
357
- $id,
358
- $onAction: addSubscription.bind(null, actionSubscriptions),
359
- $patch,
360
- $reset,
361
- $subscribe (callback, options = {}) {
362
- const removeSubscription = addSubscription(subscriptions, callback, options.detached, ()=>stopWatcher());
363
- const stopWatcher = scope.run(()=>vue.watch(()=>pinia.state.value[$id], (state)=>{
364
- if (options.flush === 'sync' ? isSyncListening : isListening) {
365
- callback({
366
- storeId: $id,
367
- type: MutationType.direct,
368
- events: debuggerEvents
369
- }, state);
370
- }
371
- }, assign({}, $subscribeOptions, options)));
372
- return removeSubscription;
373
- },
374
- $dispose
375
- };
376
- const store = vue.reactive(process.env.NODE_ENV !== 'production' || USE_DEVTOOLS ? assign({
377
- _hmrPayload,
378
- _customProperties: vue.markRaw(new Set())
379
- }, partialStore) : partialStore);
380
- // store the partial store now so the setup of stores can instantiate each other before they are finished without
381
- // creating infinite loops.
382
- pinia._s.set($id, store);
383
- const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext;
384
- // TODO: idea create skipSerialize that marks properties as non serializable and they are skipped
385
- const setupStore = runWithContext(()=>pinia._e.run(()=>(scope = vue.effectScope()).run(setup)));
386
- // overwrite existing actions to support $onAction
387
- for(const key in setupStore){
388
- const prop = setupStore[key];
389
- if (vue.isRef(prop) && !isComputed(prop) || vue.isReactive(prop)) {
390
- // mark it as a piece of state to be serialized
391
- if (process.env.NODE_ENV !== 'production' && hot) {
392
- set(hotState.value, key, vue.toRef(setupStore, key));
393
- // createOptionStore directly sets the state in pinia.state.value so we
394
- // can just skip that
395
- } else if (!isOptionsStore) {
396
- // in setup stores we must hydrate the state and sync pinia state tree with the refs the user just created
397
- if (initialState && shouldHydrate(prop)) {
398
- if (vue.isRef(prop)) {
399
- prop.value = initialState[key];
400
- } else {
401
- // probably a reactive object, lets recursively assign
402
- // @ts-expect-error: prop is unknown
403
- mergeReactiveObjects(prop, initialState[key]);
404
- }
405
- }
406
- // transfer the ref to the pinia state to keep everything in sync
407
- /* istanbul ignore if */ {
408
- pinia.state.value[$id][key] = prop;
409
- }
410
- }
411
- /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
412
- _hmrPayload.state.push(key);
413
- }
414
- // action
415
- } else if (typeof prop === 'function') {
416
- // @ts-expect-error: we are overriding the function we avoid wrapping if
417
- const actionValue = process.env.NODE_ENV !== 'production' && hot ? prop : wrapAction(key, prop);
418
- // this a hot module replacement store because the hotUpdate method needs
419
- // to do it with the right context
420
- /* istanbul ignore if */ {
421
- // @ts-expect-error
422
- setupStore[key] = actionValue;
423
- }
424
- /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
425
- _hmrPayload.actions[key] = prop;
426
- }
427
- // list actions so they can be used in plugins
428
- // @ts-expect-error
429
- optionsForPlugin.actions[key] = prop;
430
- } else if (process.env.NODE_ENV !== 'production') {
431
- // add getters for devtools
432
- if (isComputed(prop)) {
433
- _hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
434
- if (IS_CLIENT) {
435
- const getters = setupStore._getters || // @ts-expect-error: same
436
- (setupStore._getters = vue.markRaw([]));
437
- getters.push(key);
438
- }
439
- }
440
- }
441
- }
442
- // add the state, getters, and action properties
443
- /* istanbul ignore if */ {
444
- assign(store, setupStore);
445
- // allows retrieving reactive objects with `storeToRefs()`. Must be called after assigning to the reactive object.
446
- // Make `storeToRefs()` work with `reactive()` #799
447
- assign(vue.toRaw(store), setupStore);
448
- }
449
- // use this instead of a computed with setter to be able to create it anywhere
450
- // without linking the computed lifespan to wherever the store is first
451
- // created.
452
- Object.defineProperty(store, '$state', {
453
- get: ()=>process.env.NODE_ENV !== 'production' && hot ? hotState.value : pinia.state.value[$id],
454
- set: (state)=>{
455
- /* istanbul ignore if */ if (process.env.NODE_ENV !== 'production' && hot) {
456
- throw new Error('cannot set hotState');
457
- }
458
- $patch(($state)=>{
459
- assign($state, state);
460
- });
461
- }
462
- });
463
- // add the hotUpdate before plugins to allow them to override it
464
- /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
465
- store._hotUpdate = vue.markRaw((newStore)=>{
466
- store._hotUpdating = true;
467
- newStore._hmrPayload.state.forEach((stateKey)=>{
468
- if (stateKey in store.$state) {
469
- const newStateTarget = newStore.$state[stateKey];
470
- const oldStateSource = store.$state[stateKey];
471
- if (typeof newStateTarget === 'object' && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) {
472
- patchObject(newStateTarget, oldStateSource);
473
- } else {
474
- // transfer the ref
475
- newStore.$state[stateKey] = oldStateSource;
476
- }
477
- }
478
- // patch direct access properties to allow store.stateProperty to work as
479
- // store.$state.stateProperty
480
- set(store, stateKey, vue.toRef(newStore.$state, stateKey));
481
- });
482
- // remove deleted state properties
483
- Object.keys(store.$state).forEach((stateKey)=>{
484
- if (!(stateKey in newStore.$state)) {
485
- del(store, stateKey);
486
- }
487
- });
488
- // avoid devtools logging this as a mutation
489
- isListening = false;
490
- isSyncListening = false;
491
- pinia.state.value[$id] = vue.toRef(newStore._hmrPayload, 'hotState');
492
- isSyncListening = true;
493
- vue.nextTick().then(()=>{
494
- isListening = true;
495
- });
496
- for(const actionName in newStore._hmrPayload.actions){
497
- const action = newStore[actionName];
498
- set(store, actionName, wrapAction(actionName, action));
499
- }
500
- // TODO: does this work in both setup and option store?
501
- for(const getterName in newStore._hmrPayload.getters){
502
- const getter = newStore._hmrPayload.getters[getterName];
503
- const getterValue = isOptionsStore ? vue.computed(()=>{
504
- setActivePinia(pinia);
505
- return getter.call(store, store);
506
- }) : getter;
507
- set(store, getterName, getterValue);
508
- }
509
- // remove deleted getters
510
- Object.keys(store._hmrPayload.getters).forEach((key)=>{
511
- if (!(key in newStore._hmrPayload.getters)) {
512
- del(store, key);
513
- }
514
- });
515
- // remove old actions
516
- Object.keys(store._hmrPayload.actions).forEach((key)=>{
517
- if (!(key in newStore._hmrPayload.actions)) {
518
- del(store, key);
519
- }
520
- });
521
- // update the values used in devtools and to allow deleting new properties later on
522
- store._hmrPayload = newStore._hmrPayload;
523
- store._getters = newStore._getters;
524
- store._hotUpdating = false;
525
- });
526
- }
527
- if (USE_DEVTOOLS) {
528
- const nonEnumerable = {
529
- writable: true,
530
- configurable: true,
531
- // avoid warning on devtools trying to display this property
532
- enumerable: false
533
- };
534
- [
535
- '_p',
536
- '_hmrPayload',
537
- '_getters',
538
- '_customProperties'
539
- ].forEach((p)=>{
540
- Object.defineProperty(store, p, assign({
541
- value: store[p]
542
- }, nonEnumerable));
543
- });
544
- }
545
- // apply all plugins
546
- pinia._p.forEach((extender)=>{
547
- /* istanbul ignore else */ if (USE_DEVTOOLS) {
548
- const extensions = scope.run(()=>extender({
549
- store,
550
- app: pinia._a,
551
- pinia,
552
- options: optionsForPlugin
553
- }));
554
- Object.keys(extensions || {}).forEach((key)=>store._customProperties.add(key));
555
- assign(store, extensions);
556
- } else {
557
- assign(store, scope.run(()=>extender({
558
- store,
559
- app: pinia._a,
560
- pinia,
561
- options: optionsForPlugin
562
- })));
563
- }
564
- });
565
- if (process.env.NODE_ENV !== 'production' && store.$state && typeof store.$state === 'object' && typeof store.$state.constructor === 'function' && !store.$state.constructor.toString().includes('[native code]')) {
566
- console.warn(`[🍍]: The "state" must be a plain object. It cannot be\n` + `\tstate: () => new MyClass()\n` + `Found in store "${store.$id}".`);
567
- }
568
- // only apply hydrate to option stores with an initial state in pinia
569
- if (initialState && isOptionsStore && options.hydrate) {
570
- options.hydrate(store.$state, initialState);
571
- }
572
- isListening = true;
573
- isSyncListening = true;
574
- return store;
575
- }
576
- function defineStore(// TODO: add proper types from above
577
- idOrOptions, setup, setupOptions) {
578
- let id;
579
- let options;
580
- const isSetupStore = typeof setup === 'function';
581
- {
582
- id = idOrOptions;
583
- // the option store setup will contain the actual options in this case
584
- options = isSetupStore ? setupOptions : setup;
585
- }
586
- function useStore(pinia, hot) {
587
- const hasContext = vue.hasInjectionContext();
588
- pinia = // in test mode, ignore the argument provided as we can always retrieve a
589
- // pinia instance with getActivePinia()
590
- (process.env.NODE_ENV === 'test' && activePinia && activePinia._testing ? null : pinia) || (hasContext ? vue.inject(piniaSymbol, null) : null);
591
- if (pinia) setActivePinia(pinia);
592
- if (process.env.NODE_ENV !== 'production' && !activePinia) {
593
- throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?\n` + `See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\n` + `This will fail in production.`);
594
- }
595
- pinia = activePinia;
596
- if (!pinia._s.has(id)) {
597
- // creating the store registers it in `pinia._s`
598
- if (isSetupStore) {
599
- createSetupStore(id, setup, options, pinia);
600
- } else {
601
- createOptionsStore(id, options, pinia);
602
- }
603
- /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') {
604
- // @ts-expect-error: not the right inferred type
605
- useStore._pinia = pinia;
606
- }
607
- }
608
- const store = pinia._s.get(id);
609
- if (process.env.NODE_ENV !== 'production' && hot) {
610
- const hotId = '__hot:' + id;
611
- const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
612
- hot._hotUpdate(newStore);
613
- // cleanup the state properties and the store from the cache
614
- delete pinia.state.value[hotId];
615
- pinia._s.delete(hotId);
616
- }
617
- if (process.env.NODE_ENV !== 'production' && IS_CLIENT) {
618
- const currentInstance = vue.getCurrentInstance();
619
- // save stores in instances to access them devtools
620
- if (currentInstance && currentInstance.proxy && // avoid adding stores that are just built for hot module replacement
621
- !hot) {
622
- const vm = currentInstance.proxy;
623
- const cache = '_pStores' in vm ? vm._pStores : vm._pStores = {};
624
- cache[id] = store;
625
- }
626
- }
627
- // StoreGeneric cannot be casted towards Store
628
- return store;
629
- }
630
- useStore.$id = id;
631
- return useStore;
632
- }
633
- /**
634
- * Creates an object of references with all the state, getters, and plugin-added
635
- * state properties of the store. Similar to `toRefs()` but specifically
636
- * designed for Pinia stores so methods and non reactive properties are
637
- * completely ignored.
638
- *
639
- * @param store - store to extract the refs from
640
- */ function storeToRefs$1(store) {
641
- // See https://github.com/vuejs/pinia/issues/852
642
- // It's easier to just use toRefs() even if it includes more stuff
643
- {
644
- store = vue.toRaw(store);
645
- const refs = {};
646
- for(const key in store){
647
- const value = store[key];
648
- if (vue.isRef(value) || vue.isReactive(value)) {
649
- // @ts-expect-error: the key is state or getter
650
- refs[key] = // ---
651
- vue.toRef(store, key);
652
- }
653
- }
654
- return refs;
655
- }
656
- }
657
-
658
21
  function inject$1(key, instance) {
659
22
  if (instance && instance._context && instance._context.provides && instance._context.provides[key]) {
660
23
  return instance._context.provides[key];
@@ -989,7 +352,7 @@ function installStore(app, options = {}) {
989
352
  if (hasStore(app)) {
990
353
  return;
991
354
  }
992
- const storeCreator = defineStore(STORE_ID, ()=>createStore({
355
+ const storeCreator = pinia.defineStore(STORE_ID, ()=>createStore({
993
356
  baseURL: options.baseURL
994
357
  }));
995
358
  const store = storeCreator(options.pinia);
@@ -1124,7 +487,7 @@ function installHTTPClient(app, options = {}) {
1124
487
  });
1125
488
  const storeCreator = injectStore(app);
1126
489
  const store = storeCreator(options.pinia);
1127
- const { refreshToken } = storeToRefs$1(store);
490
+ const { refreshToken } = pinia.storeToRefs(store);
1128
491
  const tokenHook = new coreHttpKit.ClientResponseErrorTokenHook(client, {
1129
492
  baseURL: options.baseURL,
1130
493
  tokenCreator: ()=>{
@@ -2644,7 +2007,7 @@ function useAbilityCheck(name) {
2644
2007
 
2645
2008
  function useRealmResourceWritableCheck(realmId) {
2646
2009
  const store = useStore();
2647
- const { realm } = storeToRefs$1(store);
2010
+ const { realm } = pinia.storeToRefs(store);
2648
2011
  return vue.computed(()=>{
2649
2012
  const realmIdRaw = vue.unref(realmId);
2650
2013
  return coreKit.isRealmResourceWritable(realm.value, realmIdRaw);
@@ -7248,66 +6611,66 @@ const AEntityDelete = vue.defineComponent({
7248
6611
  });
7249
6612
 
7250
6613
  var components = /*#__PURE__*/Object.freeze({
7251
- __proto__: null,
7252
- AClient: AClient,
7253
- AClientForm: AClientForm,
7254
- AClientRedirectUris: AClientRedirectUris,
7255
- AClientRedirectUrisItem: AClientRedirectUrisItem,
7256
- AClientScope: AClientScope,
7257
- AClientScopeAssignment: AClientScopeAssignment,
7258
- AClientScopeAssignments: AClientScopeAssignments,
7259
- AClientScopes: AClientScopes,
7260
- AClients: AClients,
7261
- AEntityDelete: AEntityDelete,
7262
- AIdentityProvider: AIdentityProvider,
7263
- AIdentityProviderForm: AIdentityProviderForm,
7264
- AIdentityProviderIcon: AIdentityProviderIcon,
7265
- AIdentityProviderLdapForm: AIdentityProviderLdapForm,
7266
- AIdentityProviderOAuth2Form: AIdentityProviderOAuth2Form,
7267
- AIdentityProviderPreset: AIdentityProviderPreset,
7268
- AIdentityProviderProtocol: AIdentityProviderProtocol,
7269
- AIdentityProviderRoleAssignment: AIdentityProviderRoleAssignment,
7270
- AIdentityProviderRoleAssignments: AIdentityProviderRoleAssignments,
7271
- AIdentityProviders: AIdentityProviders,
7272
- APagination: APagination,
7273
- APermission: APermission,
7274
- APermissionForm: APermissionForm,
7275
- APermissionRobotAssignments: APermissionRobotAssignments,
7276
- APermissionRoleAssignments: APermissionRoleAssignments,
7277
- APermissionUserAssignments: APermissionUserAssignments,
7278
- APermissions: APermissions,
7279
- ARealm: ARealm,
7280
- ARealmForm: ARealmForm,
7281
- ARealms: ARealms,
7282
- ARobot: ARobot,
7283
- ARobotForm: ARobotForm,
7284
- ARobotPermissionAssignment: ARobotPermissionAssignment,
7285
- ARobotPermissionAssignments: ARobotPermissionAssignments,
7286
- ARobotRoleAssignment: ARobotRoleAssignment,
7287
- ARobotRoleAssignments: ARobotRoleAssignments,
7288
- ARobots: ARobots,
7289
- ARole: ARole,
7290
- ARoleForm: ARoleForm,
7291
- ARolePermissionAssignment: ARolePermissionAssignment,
7292
- ARolePermissionAssignments: ARolePermissionAssignments,
7293
- ARoleRobotAssignments: ARoleRobotAssignments,
7294
- ARoleUserAssignments: ARoleUserAssignments,
7295
- ARoles: ARoles,
7296
- AScope: AScope,
7297
- AScopeClientAssignments: AScopeClientAssignments,
7298
- AScopeForm: AScopeForm,
7299
- AScopes: AScopes,
7300
- ASearch: ASearch,
7301
- ATitle: ATitle,
7302
- AUser: AUser,
7303
- AUserForm: AUserForm,
7304
- AUserPasswordForm: AUserPasswordForm,
7305
- AUserPermissionAssignment: AUserPermissionAssignment,
7306
- AUserPermissionAssignments: AUserPermissionAssignments,
7307
- AUserRoleAssignment: AUserRoleAssignment,
7308
- AUserRoleAssignments: AUserRoleAssignments,
7309
- AUsers: AUsers,
7310
- LanguageSwitcherDropdown: LanguageSwitcherDropdown
6614
+ __proto__: null,
6615
+ AClient: AClient,
6616
+ AClientForm: AClientForm,
6617
+ AClientRedirectUris: AClientRedirectUris,
6618
+ AClientRedirectUrisItem: AClientRedirectUrisItem,
6619
+ AClientScope: AClientScope,
6620
+ AClientScopeAssignment: AClientScopeAssignment,
6621
+ AClientScopeAssignments: AClientScopeAssignments,
6622
+ AClientScopes: AClientScopes,
6623
+ AClients: AClients,
6624
+ AEntityDelete: AEntityDelete,
6625
+ AIdentityProvider: AIdentityProvider,
6626
+ AIdentityProviderForm: AIdentityProviderForm,
6627
+ AIdentityProviderIcon: AIdentityProviderIcon,
6628
+ AIdentityProviderLdapForm: AIdentityProviderLdapForm,
6629
+ AIdentityProviderOAuth2Form: AIdentityProviderOAuth2Form,
6630
+ AIdentityProviderPreset: AIdentityProviderPreset,
6631
+ AIdentityProviderProtocol: AIdentityProviderProtocol,
6632
+ AIdentityProviderRoleAssignment: AIdentityProviderRoleAssignment,
6633
+ AIdentityProviderRoleAssignments: AIdentityProviderRoleAssignments,
6634
+ AIdentityProviders: AIdentityProviders,
6635
+ APagination: APagination,
6636
+ APermission: APermission,
6637
+ APermissionForm: APermissionForm,
6638
+ APermissionRobotAssignments: APermissionRobotAssignments,
6639
+ APermissionRoleAssignments: APermissionRoleAssignments,
6640
+ APermissionUserAssignments: APermissionUserAssignments,
6641
+ APermissions: APermissions,
6642
+ ARealm: ARealm,
6643
+ ARealmForm: ARealmForm,
6644
+ ARealms: ARealms,
6645
+ ARobot: ARobot,
6646
+ ARobotForm: ARobotForm,
6647
+ ARobotPermissionAssignment: ARobotPermissionAssignment,
6648
+ ARobotPermissionAssignments: ARobotPermissionAssignments,
6649
+ ARobotRoleAssignment: ARobotRoleAssignment,
6650
+ ARobotRoleAssignments: ARobotRoleAssignments,
6651
+ ARobots: ARobots,
6652
+ ARole: ARole,
6653
+ ARoleForm: ARoleForm,
6654
+ ARolePermissionAssignment: ARolePermissionAssignment,
6655
+ ARolePermissionAssignments: ARolePermissionAssignments,
6656
+ ARoleRobotAssignments: ARoleRobotAssignments,
6657
+ ARoleUserAssignments: ARoleUserAssignments,
6658
+ ARoles: ARoles,
6659
+ AScope: AScope,
6660
+ AScopeClientAssignments: AScopeClientAssignments,
6661
+ AScopeForm: AScopeForm,
6662
+ AScopes: AScopes,
6663
+ ASearch: ASearch,
6664
+ ATitle: ATitle,
6665
+ AUser: AUser,
6666
+ AUserForm: AUserForm,
6667
+ AUserPasswordForm: AUserPasswordForm,
6668
+ AUserPermissionAssignment: AUserPermissionAssignment,
6669
+ AUserPermissionAssignments: AUserPermissionAssignments,
6670
+ AUserRoleAssignment: AUserRoleAssignment,
6671
+ AUserRoleAssignments: AUserRoleAssignments,
6672
+ AUsers: AUsers,
6673
+ LanguageSwitcherDropdown: LanguageSwitcherDropdown
7311
6674
  });
7312
6675
 
7313
6676
  function installComponents(input) {
@@ -7332,9 +6695,6 @@ function install(app1, options) {
7332
6695
  baseURL: options.realtimeURL || options.baseURL
7333
6696
  });
7334
6697
  }
7335
- if (options.pinia) {
7336
- setActivePinia(options.pinia);
7337
- }
7338
6698
  installStore(app1, {
7339
6699
  baseURL: options.baseURL,
7340
6700
  cookieSet: options.cookieSet,