@aerogel/core 0.0.0-next.59bf5f7cc06e728d0cf6c00de28f1da48d7d6b8e → 0.0.0-next.7f6ed5a1f91688a86bf5ede2adc465e4fd6cfdea

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 (61) hide show
  1. package/dist/aerogel-core.cjs.js +1 -1
  2. package/dist/aerogel-core.d.ts +68 -414
  3. package/dist/aerogel-core.esm.js +1 -1
  4. package/package.json +8 -6
  5. package/src/bootstrap/bootstrap.test.ts +56 -0
  6. package/src/bootstrap/hooks.ts +19 -0
  7. package/src/bootstrap/index.ts +25 -9
  8. package/src/bootstrap/options.ts +1 -5
  9. package/src/components/basic/AGMarkdown.vue +5 -20
  10. package/src/components/forms/AGButton.vue +3 -26
  11. package/src/components/forms/AGInput.vue +4 -8
  12. package/src/components/forms/index.ts +1 -2
  13. package/src/components/headless/forms/AGHeadlessInput.ts +2 -2
  14. package/src/components/headless/forms/AGHeadlessInput.vue +5 -5
  15. package/src/components/headless/forms/AGHeadlessInputError.vue +5 -9
  16. package/src/components/headless/forms/AGHeadlessInputInput.vue +4 -20
  17. package/src/components/headless/forms/index.ts +4 -6
  18. package/src/components/headless/modals/AGHeadlessModal.vue +1 -5
  19. package/src/components/headless/modals/AGHeadlessModalPanel.vue +2 -10
  20. package/src/components/index.ts +1 -2
  21. package/src/components/modals/AGAlertModal.vue +2 -13
  22. package/src/components/modals/AGModal.ts +0 -4
  23. package/src/components/modals/AGModal.vue +2 -20
  24. package/src/components/modals/index.ts +1 -4
  25. package/src/directives/index.ts +3 -5
  26. package/src/forms/Form.test.ts +0 -21
  27. package/src/forms/Form.ts +16 -38
  28. package/src/forms/utils.ts +0 -17
  29. package/src/lang/Lang.ts +8 -47
  30. package/src/lang/helpers.ts +5 -0
  31. package/src/lang/index.ts +76 -17
  32. package/src/main.ts +0 -4
  33. package/src/models/index.ts +18 -0
  34. package/src/routing/index.ts +33 -0
  35. package/src/services/Service.ts +28 -151
  36. package/src/services/index.ts +7 -29
  37. package/src/testing/stubs/lang/en.yaml +1 -0
  38. package/src/testing/stubs/models/User.ts +3 -0
  39. package/src/types/vite.d.ts +2 -0
  40. package/src/ui/UI.state.ts +6 -3
  41. package/src/ui/UI.ts +2 -35
  42. package/src/ui/index.ts +13 -19
  43. package/src/utils/index.ts +0 -3
  44. package/tsconfig.json +10 -1
  45. package/vite.config.ts +6 -2
  46. package/src/components/forms/AGCheckbox.vue +0 -35
  47. package/src/components/headless/forms/AGHeadlessInputLabel.vue +0 -16
  48. package/src/components/modals/AGConfirmModal.vue +0 -30
  49. package/src/components/modals/AGLoadingModal.vue +0 -19
  50. package/src/errors/Errors.state.ts +0 -31
  51. package/src/errors/Errors.ts +0 -132
  52. package/src/errors/index.ts +0 -21
  53. package/src/globals.ts +0 -6
  54. package/src/lang/utils.ts +0 -4
  55. package/src/plugins/Plugin.ts +0 -7
  56. package/src/plugins/index.ts +0 -7
  57. package/src/services/App.state.ts +0 -13
  58. package/src/services/App.ts +0 -17
  59. package/src/services/store.ts +0 -27
  60. package/src/utils/composition/forms.ts +0 -11
  61. package/src/utils/composition/hooks.ts +0 -9
@@ -1,96 +1,47 @@
1
- import { MagicObject, PromisedValue, Storage, isEmpty, objectDeepClone, objectOnly } from '@noeldemartin/utils';
1
+ import { MagicObject, PromisedValue } from '@noeldemartin/utils';
2
+ import { reactive } from 'vue';
2
3
  import type { Constructor } from '@noeldemartin/utils';
3
- import type { Store } from 'pinia';
4
4
 
5
5
  import ServiceBootError from '@/errors/ServiceBootError';
6
- import { defineServiceStore } from '@/services/store';
7
6
 
8
7
  export type ServiceState = Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any
9
- export type DefaultServiceState = any; // eslint-disable-line @typescript-eslint/no-explicit-any
8
+ export type DefaultServiceState = {};
10
9
  export type ServiceConstructor<T extends Service = Service> = Constructor<T> & typeof Service;
11
10
 
12
- export type ComputedStateDefinition<TState extends ServiceState, TComputedState extends ServiceState> = {
13
- [K in keyof TComputedState]: (state: TState) => TComputedState[K];
14
- } & ThisType<{
15
- readonly [K in keyof TComputedState]: TComputedState[K];
16
- }>;
17
-
18
- export function defineServiceState<
19
- State extends ServiceState = ServiceState,
20
- ComputedState extends ServiceState = {}
21
- >(options: {
22
- name: string;
11
+ export function defineServiceState<State extends ServiceState>(options: {
23
12
  initialState: State;
24
- persist?: (keyof State)[];
25
- computed?: ComputedStateDefinition<State, ComputedState>;
26
- serialize?: (state: Partial<State>) => Partial<State>;
27
- }): Constructor<State> & Constructor<ComputedState> & Constructor<Service<State, ComputedState, Partial<State>>> {
28
- return class extends Service<State, ComputedState> {
29
-
30
- public static persist = (options.persist as string[]) ?? [];
31
-
32
- protected usesStore(): boolean {
33
- return true;
34
- }
35
-
36
- protected getName(): string | null {
37
- return options.name ?? null;
38
- }
13
+ }): Constructor<State> & ServiceConstructor {
14
+ return class extends Service<State> {
39
15
 
40
16
  protected getInitialState(): State {
41
17
  return options.initialState;
42
18
  }
43
-
44
- protected getComputedStateDefinition(): ComputedStateDefinition<State, ComputedState> {
45
- return options.computed ?? ({} as ComputedStateDefinition<State, ComputedState>);
46
- }
47
-
48
- protected serializePersistedState(state: Partial<State>): Partial<State> {
49
- return options.serialize?.(state) ?? state;
50
- }
51
19
 
52
- } as unknown as Constructor<State> &
53
- Constructor<ComputedState> &
54
- Constructor<Service<State, ComputedState, Partial<State>>>;
20
+ } as unknown as Constructor<State> & ServiceConstructor;
55
21
  }
56
22
 
57
- export default class Service<
58
- State extends ServiceState = DefaultServiceState,
59
- ComputedState extends ServiceState = {},
60
- ServiceStorage extends Partial<State> = Partial<State>
61
- > extends MagicObject {
23
+ export default class Service<State extends ServiceState = DefaultServiceState> extends MagicObject {
62
24
 
63
- public static persist: string[] = [];
64
-
65
- protected _name: string;
25
+ protected _namespace: string;
66
26
  private _booted: PromisedValue<void>;
67
- private _computedStateKeys: Set<keyof State>;
68
- private _store?: Store | false;
27
+ private _state: State;
69
28
 
70
29
  constructor() {
71
30
  super();
72
31
 
73
- const getters = this.getComputedStateDefinition();
74
-
75
- this._name = this.getName() ?? new.target.name;
32
+ this._namespace = new.target.name;
76
33
  this._booted = new PromisedValue();
77
- this._computedStateKeys = new Set(Object.keys(getters));
78
- this._store =
79
- this.usesStore() &&
80
- defineServiceStore(this._name, {
81
- state: () => this.getInitialState(),
82
-
83
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
- getters: getters as any,
85
- });
34
+ this._state = reactive(this.getInitialState());
86
35
  }
87
36
 
88
37
  public get booted(): PromisedValue<void> {
89
38
  return this._booted;
90
39
  }
91
40
 
92
- public launch(): Promise<void> {
93
- const handleError = (error: unknown) => this._booted.reject(new ServiceBootError(this._name, error));
41
+ public launch(namespace?: string): Promise<void> {
42
+ const handleError = (error: unknown) => this._booted.reject(new ServiceBootError(this._namespace, error));
43
+
44
+ this._namespace = namespace ?? this._namespace;
94
45
 
95
46
  try {
96
47
  this.boot()
@@ -103,112 +54,38 @@ export default class Service<
103
54
  return this._booted;
104
55
  }
105
56
 
106
- public hasState<P extends keyof State>(property: P): boolean {
107
- if (!this._store) {
108
- return false;
109
- }
110
-
111
- return property in this._store.$state || this._computedStateKeys.has(property);
112
- }
113
-
114
- public getState(): State;
115
- public getState<P extends keyof State>(property: P): State[P];
116
- public getState<P extends keyof State>(property?: P): State | State[P] {
117
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
118
- const store = this._store as any;
119
-
120
- if (property) {
121
- return store ? store[property] : undefined;
122
- }
123
-
124
- return store ? store : {};
125
- }
126
-
127
- public setState<P extends keyof State>(property: P, value: State[P]): void;
128
- public setState(state: Partial<State>): void;
129
- public setState<P extends keyof State>(stateOrProperty: P | Partial<State>, value?: State[P]): void {
130
- if (!this._store) {
131
- return;
132
- }
133
-
134
- const state = (
135
- typeof stateOrProperty === 'string' ? { [stateOrProperty]: value } : stateOrProperty
136
- ) as Partial<State>;
137
-
138
- Object.assign(this._store.$state, state);
139
-
140
- this.onStateUpdated(state);
141
- }
142
-
143
57
  protected __get(property: string): unknown {
144
- if (this.hasState(property)) {
145
- return this.getState(property);
58
+ if (!this.hasState(property)) {
59
+ return super.__get(property);
146
60
  }
147
61
 
148
- return super.__get(property);
62
+ return this.getState(property);
149
63
  }
150
64
 
151
65
  protected __set(property: string, value: unknown): void {
152
66
  this.setState({ [property]: value } as Partial<State>);
153
67
  }
154
68
 
155
- protected onStateUpdated(state: Partial<State>): void {
156
- // TODO fix this.static()
157
- const persist = (this.constructor as unknown as { persist: string[] }).persist;
158
- const persisted = objectOnly(state, persist);
159
-
160
- if (isEmpty(persisted)) {
161
- return;
162
- }
163
-
164
- const storage = Storage.require<ServiceStorage>(this._name);
165
-
166
- Storage.set(this._name, {
167
- ...storage,
168
- ...this.serializePersistedState(objectDeepClone(persisted) as Partial<State>),
169
- });
69
+ protected hasState<P extends keyof State>(property: P): boolean {
70
+ return property in this._state;
170
71
  }
171
72
 
172
- protected usesStore(): boolean {
173
- return false;
73
+ protected getState(): State;
74
+ protected getState<P extends keyof State>(property: P): State[P];
75
+ protected getState<P extends keyof State>(property?: P): State | State[P] {
76
+ return property ? this._state[property] : this._state;
174
77
  }
175
78
 
176
- protected getName(): string | null {
177
- return null;
79
+ protected setState(state: Partial<State>): void {
80
+ Object.assign(this._state, state);
178
81
  }
179
82
 
180
83
  protected getInitialState(): State {
181
84
  return {} as State;
182
85
  }
183
86
 
184
- protected getComputedStateDefinition(): ComputedStateDefinition<State, ComputedState> {
185
- return {} as ComputedStateDefinition<State, ComputedState>;
186
- }
187
-
188
- protected serializePersistedState(state: Partial<State>): Partial<State> {
189
- return state;
190
- }
191
-
192
87
  protected async boot(): Promise<void> {
193
- this.restorePersistedState();
194
- }
195
-
196
- protected restorePersistedState(): void {
197
- // TODO fix this.static()
198
- const persist = (this.constructor as unknown as { persist: string[] }).persist;
199
-
200
- if (!this.usesStore() || isEmpty(persist)) {
201
- return;
202
- }
203
-
204
- if (Storage.has(this._name)) {
205
- const persisted = Storage.require<ServiceStorage>(this._name);
206
- this.setState(persisted);
207
-
208
- return;
209
- }
210
-
211
- Storage.set(this._name, objectOnly(this.getState(), persist));
88
+ //
212
89
  }
213
90
 
214
91
  }
@@ -1,20 +1,15 @@
1
- import type { App as VueApp } from 'vue';
1
+ import type { App } from 'vue';
2
2
 
3
- import { definePlugin } from '@/plugins';
4
-
5
- import App from './App';
6
3
  import Events from './Events';
7
4
  import Service from './Service';
8
- import { getPiniaStore } from './store';
5
+ import { defineBootstrapHook } from '@/bootstrap/hooks';
9
6
 
10
- export * from './App';
11
7
  export * from './Events';
12
8
  export * from './Service';
13
9
 
14
- export { App, Events, Service };
10
+ export { Events, Service };
15
11
 
16
12
  const defaultServices = {
17
- $app: App,
18
13
  $events: Events,
19
14
  };
20
15
 
@@ -22,35 +17,18 @@ export type DefaultServices = typeof defaultServices;
22
17
 
23
18
  export interface Services extends DefaultServices {}
24
19
 
25
- export async function bootServices(app: VueApp, services: Record<string, Service>): Promise<void> {
20
+ export async function bootServices(app: App, services: Record<string, Service>): Promise<void> {
26
21
  await Promise.all(
27
- Object.entries(services).map(async ([_, service]) => {
22
+ Object.entries(services).map(async ([name, service]) => {
28
23
  // eslint-disable-next-line no-console
29
- await service.launch().catch((error) => console.error(error));
24
+ await service.launch(name.slice(1)).catch((error) => console.error(error));
30
25
  }),
31
26
  );
32
27
 
33
28
  Object.assign(app.config.globalProperties, services);
34
29
  }
35
30
 
36
- export default definePlugin({
37
- async install(app, options) {
38
- const services = {
39
- ...defaultServices,
40
- ...options.services,
41
- };
42
-
43
- app.use(getPiniaStore());
44
-
45
- await bootServices(app, services);
46
- },
47
- });
48
-
49
- declare module '@/bootstrap/options' {
50
- interface AerogelOptions {
51
- services?: Record<string, Service>;
52
- }
53
- }
31
+ export default defineBootstrapHook((app) => bootServices(app, defaultServices));
54
32
 
55
33
  declare module '@vue/runtime-core' {
56
34
  interface ComponentCustomProperties extends Services {}
@@ -0,0 +1 @@
1
+ foo: Bar
@@ -0,0 +1,3 @@
1
+ import { Model } from 'soukai';
2
+
3
+ export default class User extends Model {}
@@ -1 +1,3 @@
1
1
  /// <reference types="vite/client" />
2
+
3
+ declare const __AG_BASE_PATH: string | undefined;
@@ -2,6 +2,10 @@ import type { Component } from 'vue';
2
2
 
3
3
  import { defineServiceState } from '@/services/Service';
4
4
 
5
+ export interface State {
6
+ modals: Modal[];
7
+ }
8
+
5
9
  export interface Modal<T = unknown> {
6
10
  id: string;
7
11
  properties: Record<string, unknown>;
@@ -17,7 +21,6 @@ export interface ModalComponent<
17
21
  Result = unknown
18
22
  > {}
19
23
 
20
- export default defineServiceState({
21
- name: 'ui',
22
- initialState: { modals: [] as Modal[] },
24
+ export default defineServiceState<State>({
25
+ initialState: { modals: [] },
23
26
  });
package/src/ui/UI.ts CHANGED
@@ -20,8 +20,6 @@ type ModalResult<TComponent> = TComponent extends ModalComponent<Record<string,
20
20
 
21
21
  export const UIComponents = {
22
22
  AlertModal: 'alert-modal',
23
- ConfirmModal: 'confirm-modal',
24
- LoadingModal: 'loading-modal',
25
23
  } as const;
26
24
 
27
25
  export type UIComponent = ObjectValues<typeof UIComponents>;
@@ -31,39 +29,8 @@ export class UIService extends Service {
31
29
  private modalCallbacks: Record<string, Partial<ModalCallbacks>> = {};
32
30
  private components: Partial<Record<UIComponent, Component>> = {};
33
31
 
34
- public alert(message: string): void;
35
- public alert(title: string, message: string): void;
36
- public alert(messageOrTitle: string, message?: string): void {
37
- const options = typeof message === 'string' ? { title: messageOrTitle, message } : { message: messageOrTitle };
38
-
39
- this.openModal(this.requireComponent(UIComponents.AlertModal), options);
40
- }
41
-
42
- public async confirm(message: string): Promise<boolean>;
43
- public async confirm(title: string, message: string): Promise<boolean>;
44
- public async confirm(messageOrTitle: string, message?: string): Promise<boolean> {
45
- const options = typeof message === 'string' ? { title: messageOrTitle, message } : { message: messageOrTitle };
46
- const modal = await this.openModal<ModalComponent<{ message: string }, boolean>>(
47
- this.requireComponent(UIComponents.ConfirmModal),
48
- options,
49
- );
50
- const result = await modal.beforeClose;
51
-
52
- return result ?? false;
53
- }
54
-
55
- public async loading<T>(operation: Promise<T>): Promise<T>;
56
- public async loading<T>(message: string, operation: Promise<T>): Promise<T>;
57
- public async loading<T>(messageOrOperation: string | Promise<T>, operation?: Promise<T>): Promise<T> {
58
- operation = typeof messageOrOperation === 'string' ? (operation as Promise<T>) : messageOrOperation;
59
-
60
- const message = typeof messageOrOperation === 'string' ? messageOrOperation : undefined;
61
- const modal = await this.openModal(this.requireComponent(UIComponents.LoadingModal), { message });
62
- const result = await operation;
63
-
64
- await this.closeModal(modal.id);
65
-
66
- return result;
32
+ public alert(message: string): void {
33
+ this.openModal(this.requireComponent(UIComponents.AlertModal), { message });
67
34
  }
68
35
 
69
36
  public registerComponent(name: UIComponent, component: Component): void {
package/src/ui/index.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import type { Component } from 'vue';
2
2
 
3
3
  import { bootServices } from '@/services';
4
- import { definePlugin } from '@/plugins';
4
+ import { defineBootstrapHook } from '@/bootstrap/hooks';
5
5
 
6
6
  import UI, { UIComponents } from './UI';
7
7
  import AGAlertModal from '../components/modals/AGAlertModal.vue';
8
- import AGConfirmModal from '../components/modals/AGConfirmModal.vue';
9
- import AGLoadingModal from '../components/modals/AGLoadingModal.vue';
10
8
  import type { UIComponent } from './UI';
11
9
 
12
10
  export { UI, UIComponents, UIComponent };
@@ -15,25 +13,21 @@ const services = { $ui: UI };
15
13
 
16
14
  export type UIServices = typeof services;
17
15
 
18
- export default definePlugin({
19
- async install(app, options) {
20
- const defaultComponents = {
21
- [UIComponents.AlertModal]: AGAlertModal,
22
- [UIComponents.ConfirmModal]: AGConfirmModal,
23
- [UIComponents.LoadingModal]: AGLoadingModal,
24
- };
25
-
26
- Object.entries({
27
- ...defaultComponents,
28
- ...options.components,
29
- }).forEach(([name, component]) => UI.registerComponent(name as UIComponent, component));
30
-
31
- await bootServices(app, services);
32
- },
16
+ export default defineBootstrapHook(async (app, options) => {
17
+ const defaultComponents = {
18
+ [UIComponents.AlertModal]: AGAlertModal,
19
+ };
20
+
21
+ Object.entries({
22
+ ...defaultComponents,
23
+ ...options.components,
24
+ }).forEach(([name, component]) => UI.registerComponent(name as UIComponent, component));
25
+
26
+ await bootServices(app, services);
33
27
  });
34
28
 
35
29
  declare module '@/bootstrap/options' {
36
- interface AerogelOptions {
30
+ interface BootstrapOptions {
37
31
  components?: Partial<Record<UIComponent, Component>>;
38
32
  }
39
33
  }
@@ -1,4 +1 @@
1
- export * from './composition/events';
2
- export * from './composition/forms';
3
- export * from './composition/hooks';
4
1
  export * from './vue';
package/tsconfig.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
- "extends": "../../tsconfig.json",
3
2
  "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "strict": true,
7
+ "types": [],
8
+ "jsx": "preserve",
9
+ "noUncheckedIndexedAccess": true,
10
+ "resolveJsonModule": true,
11
+ "esModuleInterop": true,
12
+ "lib": ["esnext", "dom"],
4
13
  "baseUrl": ".",
5
14
  "paths": {
6
15
  "@/*": ["./src/*"]
package/vite.config.ts CHANGED
@@ -1,13 +1,17 @@
1
- import Aerogel from '@aerogel/vite';
1
+ import I18n from '@intlify/unplugin-vue-i18n/vite';
2
+ import Vue from '@vitejs/plugin-vue';
2
3
  import { defineConfig } from 'vitest/config';
3
4
  import { resolve } from 'path';
4
5
 
6
+ const isTesting = process.env.NODE_ENV === 'test';
7
+
5
8
  export default defineConfig({
6
9
  test: { clearMocks: true },
7
- plugins: [Aerogel()],
10
+ plugins: [Vue(), I18n({ include: resolve(__dirname, './src/testing/stubs/lang/**/*.yaml') })],
8
11
  resolve: {
9
12
  alias: {
10
13
  '@': resolve(__dirname, './src'),
11
14
  },
12
15
  },
16
+ define: isTesting ? { __AG_BASE_PATH: 'undefined' } : undefined,
13
17
  });
@@ -1,35 +0,0 @@
1
- <template>
2
- <AGHeadlessInput ref="$input" :name="name" class="flex">
3
- <AGHeadlessInputInput
4
- v-bind="$attrs"
5
- type="checkbox"
6
- :class="{
7
- 'text-indigo-600 focus:ring-indigo-600': !$input?.errors,
8
- 'border-red-200 text-red-600 focus:ring-red-600': $input?.errors,
9
- }"
10
- />
11
-
12
- <div class="ml-2">
13
- <AGHeadlessInputLabel v-if="$slots.default">
14
- <slot />
15
- </AGHeadlessInputLabel>
16
- <AGHeadlessInputError class="text-sm text-red-600" />
17
- </div>
18
- </AGHeadlessInput>
19
- </template>
20
-
21
- <script setup lang="ts">
22
- import { componentRef, stringProp } from '@/utils/vue';
23
-
24
- import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
25
-
26
- import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
27
- import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
28
- import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
29
- import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
30
-
31
- defineProps({ name: stringProp() });
32
- defineOptions({ inheritAttrs: false });
33
-
34
- const $input = componentRef<IAGHeadlessInput>();
35
- </script>
@@ -1,16 +0,0 @@
1
- <template>
2
- <label :for="input.id">
3
- <slot />
4
- </label>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { injectReactiveOrFail } from '@/utils/vue';
9
-
10
- import type { IAGHeadlessInput } from './AGHeadlessInput';
11
-
12
- const input = injectReactiveOrFail<IAGHeadlessInput>(
13
- 'input',
14
- '<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>',
15
- );
16
- </script>
@@ -1,30 +0,0 @@
1
- <template>
2
- <AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false">
3
- <AGMarkdown v-if="title" :text="title" as="h1" />
4
- <AGMarkdown :text="message" />
5
-
6
- <div class="mt-2 flex flex-row-reverse gap-2">
7
- <AGButton @click="close(true)">
8
- {{ $td('ui.ok', 'OK') }}
9
- </AGButton>
10
- <AGButton secondary @click="close()">
11
- {{ $td('ui.cancel', 'Cancel') }}
12
- </AGButton>
13
- </div>
14
- </AGModal>
15
- </template>
16
-
17
- <script setup lang="ts">
18
- import { requiredStringProp, stringProp } from '@/utils/vue';
19
-
20
- import AGModal from './AGModal.vue';
21
- import type { IAGModalDefaultSlotProps } from './AGModal';
22
-
23
- import AGButton from '../forms/AGButton.vue';
24
- import AGMarkdown from '../basic/AGMarkdown.vue';
25
-
26
- defineProps({
27
- title: stringProp(),
28
- message: requiredStringProp(),
29
- });
30
- </script>
@@ -1,19 +0,0 @@
1
- <template>
2
- <AGModal :cancellable="false">
3
- <AGMarkdown :text="renderedMessage" />
4
- </AGModal>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from 'vue';
9
-
10
- import { stringProp } from '@/utils/vue';
11
- import { translateWithDefault } from '@/lang/utils';
12
-
13
- import AGModal from './AGModal.vue';
14
-
15
- import AGMarkdown from '../basic/AGMarkdown.vue';
16
-
17
- const props = defineProps({ message: stringProp() });
18
- const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
19
- </script>
@@ -1,31 +0,0 @@
1
- import type { JSError } from '@noeldemartin/utils';
2
-
3
- import { defineServiceState } from '@/services';
4
-
5
- export type ErrorSource = string | Error | JSError | unknown;
6
-
7
- export interface ErrorReport {
8
- title: string;
9
- description?: string;
10
- details?: string;
11
- error?: Error | JSError | unknown;
12
- }
13
-
14
- export interface ErrorReportLog {
15
- report: ErrorReport;
16
- seen: boolean;
17
- date: Date;
18
- }
19
-
20
- export default defineServiceState({
21
- name: 'errors',
22
- initialState: {
23
- logs: [] as ErrorReportLog[],
24
- startupErrors: [] as ErrorReport[],
25
- },
26
- computed: {
27
- hasErrors: ({ logs }) => logs.length > 0,
28
- hasNewErrors: ({ logs }) => logs.some((error) => !error.seen),
29
- hasStartupErrors: ({ startupErrors }) => startupErrors.length > 0,
30
- },
31
- });