@aerogel/core 0.0.0-next.97312fd206b83ac5ae520da32b1bb3f12fb55969 → 0.0.0-next.9a02fcd3bcf698211dd7a71d4c48257c96dd7832

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.
@@ -1,16 +1,19 @@
1
+ import { tap } from '@noeldemartin/utils';
1
2
  import { createPinia, defineStore, setActivePinia } from 'pinia';
2
3
  import type { DefineStoreOptions, Pinia, StateTree, Store, _GettersTree } from 'pinia';
3
4
 
4
5
  let _store: Pinia | null = null;
5
6
 
6
7
  function initializePiniaStore(): Pinia {
7
- if (!_store) {
8
- _store = createPinia();
8
+ return _store ?? resetPiniaStore();
9
+ }
9
10
 
10
- setActivePinia(_store);
11
- }
11
+ export function resetPiniaStore(): Pinia {
12
+ return tap(createPinia(), (store) => {
13
+ _store = store;
12
14
 
13
- return _store;
15
+ setActivePinia(store);
16
+ });
14
17
  }
15
18
 
16
19
  export function getPiniaStore(): Pinia {
@@ -0,0 +1,25 @@
1
+ import type { GetClosureArgs } from '@noeldemartin/utils';
2
+
3
+ import Events from '@/services/Events';
4
+ import { definePlugin } from '@/plugins';
5
+
6
+ export interface AerogelTestingRuntime {
7
+ on: (typeof Events)['on'];
8
+ }
9
+
10
+ export default definePlugin({
11
+ async install() {
12
+ if (import.meta.env.MODE !== 'testing') {
13
+ return;
14
+ }
15
+
16
+ globalThis.testingRuntime = {
17
+ on: ((...args: GetClosureArgs<(typeof Events)['on']>) => Events.on(...args)) as (typeof Events)['on'],
18
+ };
19
+ },
20
+ });
21
+
22
+ declare global {
23
+ // eslint-disable-next-line no-var
24
+ var testingRuntime: AerogelTestingRuntime | undefined;
25
+ }
package/src/ui/UI.ts CHANGED
@@ -167,7 +167,7 @@ export class UIService extends Service {
167
167
  const snackbar: Snackbar = {
168
168
  id: uuid(),
169
169
  properties: { message, ...options },
170
- component: options.component ?? markRaw(this.requireComponent(UIComponents.Snackbar)),
170
+ component: markRaw(options.component ?? this.requireComponent(UIComponents.Snackbar)),
171
171
  };
172
172
 
173
173
  this.setState('snackbars', this.snackbars.concat(snackbar));
@@ -270,14 +270,16 @@ export class UIService extends Service {
270
270
 
271
271
  }
272
272
 
273
- export default facade(new UIService());
273
+ export default facade(UIService);
274
274
 
275
275
  declare module '@/services/Events' {
276
276
  export interface EventsPayload {
277
- 'modal-will-close': { modal: Modal; result?: unknown };
278
- 'modal-closed': { modal: Modal; result?: unknown };
279
277
  'close-modal': { id: string; result?: unknown };
280
278
  'hide-modal': { id: string };
279
+ 'hide-overlays-backdrop': void;
280
+ 'modal-closed': { modal: Modal; result?: unknown };
281
+ 'modal-will-close': { modal: Modal; result?: unknown };
281
282
  'show-modal': { id: string };
283
+ 'show-overlays-backdrop': void;
282
284
  }
283
285
  }