@aerogel/core 0.0.0-next.ea2e864c719d0a4d01b04729a9b681c0e9c85ea7 → 0.0.0-next.eb6fcafb87cdccbc72933f616799ca3124d1eca8
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/aerogel-core.d.ts +209 -71
- package/dist/aerogel-core.js +1255 -1007
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +1 -1
- package/src/components/contracts/AlertModal.ts +1 -1
- package/src/components/contracts/DropdownMenu.ts +2 -2
- package/src/components/contracts/Select.ts +2 -2
- package/src/components/headless/HeadlessInputInput.vue +14 -3
- package/src/components/ui/Input.vue +2 -2
- package/src/components/ui/Setting.vue +31 -0
- package/src/components/ui/StartupCrash.vue +51 -6
- package/src/components/ui/TextArea.vue +56 -0
- package/src/components/ui/index.ts +2 -0
- package/src/errors/Errors.state.ts +1 -0
- package/src/errors/Errors.ts +27 -6
- package/src/errors/settings/Debug.vue +8 -33
- package/src/forms/FormController.test.ts +3 -0
- package/src/forms/FormController.ts +25 -16
- package/src/forms/utils.ts +25 -0
- package/src/forms/validation.ts +31 -0
- package/src/index.css +3 -0
- package/src/services/Service.ts +11 -6
- package/src/testing/index.ts +4 -0
- package/src/ui/UI.ts +20 -4
- package/src/utils/app.ts +7 -0
- package/src/utils/index.ts +1 -0
package/src/services/Service.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { Constructor, Nullable } from '@noeldemartin/utils';
|
|
|
12
12
|
import type { Store } from 'pinia';
|
|
13
13
|
|
|
14
14
|
import ServiceBootError from '@aerogel/core/errors/ServiceBootError';
|
|
15
|
+
import { appNamespace } from '@aerogel/core/utils/app';
|
|
15
16
|
import { defineServiceStore } from '@aerogel/core/services/store';
|
|
16
17
|
import type { Unref } from '@aerogel/core/utils/vue';
|
|
17
18
|
|
|
@@ -164,7 +165,7 @@ export default class Service<
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
public hasPersistedState(): boolean {
|
|
167
|
-
return Storage.has(this.
|
|
168
|
+
return Storage.has(this.storageKey);
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
public hasState<P extends keyof State>(property: P): boolean {
|
|
@@ -231,6 +232,10 @@ export default class Service<
|
|
|
231
232
|
this.setState({ [property]: value } as Partial<State>);
|
|
232
233
|
}
|
|
233
234
|
|
|
235
|
+
protected get storageKey(): string {
|
|
236
|
+
return `${appNamespace()}:${this._name}`;
|
|
237
|
+
}
|
|
238
|
+
|
|
234
239
|
protected onStateUpdated(update: Partial<State>, old: Partial<State>): void {
|
|
235
240
|
const persisted = objectOnly(update, this.static('persist'));
|
|
236
241
|
|
|
@@ -250,13 +255,13 @@ export default class Service<
|
|
|
250
255
|
}
|
|
251
256
|
|
|
252
257
|
protected onPersistentStateUpdated(persisted: Partial<State>): void {
|
|
253
|
-
const storage = Storage.get<ServiceStorage>(this.
|
|
258
|
+
const storage = Storage.get<ServiceStorage>(this.storageKey);
|
|
254
259
|
|
|
255
260
|
if (!storage) {
|
|
256
261
|
return;
|
|
257
262
|
}
|
|
258
263
|
|
|
259
|
-
Storage.set(this.
|
|
264
|
+
Storage.set(this.storageKey, {
|
|
260
265
|
...storage,
|
|
261
266
|
...this.serializePersistedState(objectDeepClone(persisted) as Partial<State>),
|
|
262
267
|
});
|
|
@@ -303,14 +308,14 @@ export default class Service<
|
|
|
303
308
|
return;
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
if (Storage.has(this.
|
|
307
|
-
const persisted = Storage.require<ServiceStorage>(this.
|
|
311
|
+
if (Storage.has(this.storageKey)) {
|
|
312
|
+
const persisted = Storage.require<ServiceStorage>(this.storageKey);
|
|
308
313
|
this.setState(this.deserializePersistedState(persisted));
|
|
309
314
|
|
|
310
315
|
return;
|
|
311
316
|
}
|
|
312
317
|
|
|
313
|
-
Storage.set(this.
|
|
318
|
+
Storage.set(this.storageKey, objectOnly(this.getState(), this.static('persist')));
|
|
314
319
|
}
|
|
315
320
|
|
|
316
321
|
protected requireStore(): Store<string, State, ComputedState, {}> {
|
package/src/testing/index.ts
CHANGED
|
@@ -2,10 +2,13 @@ import { isTesting } from '@noeldemartin/utils';
|
|
|
2
2
|
import type { GetClosureArgs } from '@noeldemartin/utils';
|
|
3
3
|
|
|
4
4
|
import Events from '@aerogel/core/services/Events';
|
|
5
|
+
import { App } from '@aerogel/core/services';
|
|
5
6
|
import { definePlugin } from '@aerogel/core/plugins';
|
|
7
|
+
import type { Services } from '@aerogel/core/services';
|
|
6
8
|
|
|
7
9
|
export interface AerogelTestingRuntime {
|
|
8
10
|
on: (typeof Events)['on'];
|
|
11
|
+
service<T extends keyof Services>(name: T): Services[T] | null;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export default definePlugin({
|
|
@@ -16,6 +19,7 @@ export default definePlugin({
|
|
|
16
19
|
|
|
17
20
|
globalThis.testingRuntime = {
|
|
18
21
|
on: ((...args: GetClosureArgs<(typeof Events)['on']>) => Events.on(...args)) as (typeof Events)['on'],
|
|
22
|
+
service: (name) => App.service(name),
|
|
19
23
|
};
|
|
20
24
|
},
|
|
21
25
|
});
|
package/src/ui/UI.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { after, facade, fail, isDevelopment, required, uuid } from '@noeldemartin/utils';
|
|
2
|
-
import { markRaw, nextTick } from 'vue';
|
|
2
|
+
import { markRaw, nextTick, unref } from 'vue';
|
|
3
3
|
import type { ComponentExposed, ComponentProps } from 'vue-component-type-helpers';
|
|
4
4
|
import type { Component } from 'vue';
|
|
5
5
|
import type { ClosureArgs } from '@noeldemartin/utils';
|
|
@@ -64,6 +64,7 @@ export type LoadingOptions = AcceptRefs<{
|
|
|
64
64
|
title?: string;
|
|
65
65
|
message?: string;
|
|
66
66
|
progress?: number;
|
|
67
|
+
delay?: number;
|
|
67
68
|
}>;
|
|
68
69
|
|
|
69
70
|
export interface ConfirmOptionsWithCheckboxes<T extends ConfirmModalCheckboxes = ConfirmModalCheckboxes>
|
|
@@ -218,7 +219,11 @@ export class UIService extends Service {
|
|
|
218
219
|
operation?: Promise<T> | (() => T),
|
|
219
220
|
): Promise<T> {
|
|
220
221
|
const processOperation = (o: Promise<T> | (() => T)) => (typeof o === 'function' ? Promise.resolve(o()) : o);
|
|
221
|
-
const processArgs = (): {
|
|
222
|
+
const processArgs = (): {
|
|
223
|
+
operationPromise: Promise<T>;
|
|
224
|
+
props?: AcceptRefs<LoadingModalProps>;
|
|
225
|
+
delay?: number;
|
|
226
|
+
} => {
|
|
222
227
|
if (typeof operationOrMessageOrOptions === 'string') {
|
|
223
228
|
return {
|
|
224
229
|
props: { message: operationOrMessageOrOptions },
|
|
@@ -230,13 +235,24 @@ export class UIService extends Service {
|
|
|
230
235
|
return { operationPromise: processOperation(operationOrMessageOrOptions) };
|
|
231
236
|
}
|
|
232
237
|
|
|
238
|
+
const { delay, ...props } = operationOrMessageOrOptions;
|
|
239
|
+
|
|
233
240
|
return {
|
|
234
|
-
props
|
|
241
|
+
props,
|
|
242
|
+
delay: unref(delay),
|
|
235
243
|
operationPromise: processOperation(operation as Promise<T> | (() => T)),
|
|
236
244
|
};
|
|
237
245
|
};
|
|
238
246
|
|
|
239
|
-
|
|
247
|
+
let delayed = false;
|
|
248
|
+
const { operationPromise, props, delay } = processArgs();
|
|
249
|
+
|
|
250
|
+
delay && (await Promise.race([after({ ms: delay }).then(() => (delayed = true)), operationPromise]));
|
|
251
|
+
|
|
252
|
+
if (delay && !delayed) {
|
|
253
|
+
return operationPromise;
|
|
254
|
+
}
|
|
255
|
+
|
|
240
256
|
const modal = await this.modal(this.requireComponent('loading-modal'), props);
|
|
241
257
|
|
|
242
258
|
try {
|
package/src/utils/app.ts
ADDED
package/src/utils/index.ts
CHANGED