@aerogel/core 0.0.0-next.9487bb13082b9d479112445804d906125ded5cbc → 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c
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.cjs.js +1 -1
- package/dist/aerogel-core.cjs.js.map +1 -1
- package/dist/aerogel-core.d.ts +145 -39
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/package.json +12 -6
- package/src/bootstrap/bootstrap.test.ts +1 -0
- package/src/bootstrap/index.ts +6 -0
- package/src/components/AGAppLayout.vue +6 -2
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInput.ts +25 -0
- package/src/components/headless/forms/AGHeadlessInput.vue +4 -1
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
- package/src/components/headless/forms/AGHeadlessSelect.ts +2 -1
- package/src/components/headless/forms/AGHeadlessSelect.vue +1 -2
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +4 -1
- package/src/components/headless/modals/AGHeadlessModal.ts +9 -0
- package/src/components/headless/modals/index.ts +4 -6
- package/src/components/index.ts +1 -1
- package/src/components/lib/AGStartupCrash.vue +31 -0
- package/src/components/lib/index.ts +4 -0
- package/src/components/modals/AGAlertModal.vue +1 -1
- package/src/components/modals/AGConfirmModal.ts +10 -0
- package/src/components/modals/AGConfirmModal.vue +3 -3
- package/src/components/modals/AGErrorReportModal.vue +1 -1
- package/src/components/modals/AGErrorReportModalTitle.vue +1 -1
- package/src/components/modals/AGLoadingModal.ts +9 -0
- package/src/components/modals/AGLoadingModal.vue +1 -1
- package/src/components/modals/AGModal.ts +2 -2
- package/src/components/modals/index.ts +2 -0
- package/src/components/snackbars/AGSnackbar.vue +1 -1
- package/src/errors/index.ts +8 -12
- package/src/services/App.state.ts +3 -3
- package/src/services/App.ts +10 -1
- package/src/services/Service.ts +8 -4
- package/src/ui/UI.ts +26 -4
- package/tsconfig.json +1 -1
- package/.eslintrc.js +0 -3
- package/dist/virtual.d.ts +0 -11
- package/src/components/basic/index.ts +0 -5
- package/src/types/virtual.d.ts +0 -11
- /package/src/components/{basic → lib}/AGErrorMessage.vue +0 -0
- /package/src/components/{basic → lib}/AGLink.vue +0 -0
- /package/src/components/{basic → lib}/AGMarkdown.vue +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerogel/core",
|
|
3
3
|
"description": "The Lightest Solid",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c",
|
|
5
5
|
"main": "dist/aerogel-core.cjs.js",
|
|
6
6
|
"module": "dist/aerogel-core.esm.js",
|
|
7
7
|
"types": "dist/aerogel-core.d.ts",
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "rm dist -rf && npm run build:js && npm run build:types",
|
|
11
11
|
"build:js": "noeldemartin-build-javascript",
|
|
12
|
-
"build:types": "noeldemartin-build-types
|
|
13
|
-
"histoire
|
|
14
|
-
"histoire:prod": "histoire build",
|
|
12
|
+
"build:types": "noeldemartin-build-types",
|
|
13
|
+
"histoire": "histoire dev",
|
|
15
14
|
"lint": "noeldemartin-lint src",
|
|
16
15
|
"publish-next": "noeldemartin-publish-next",
|
|
17
|
-
"test": "vitest --run"
|
|
16
|
+
"test": "vitest --run",
|
|
17
|
+
"test:ci": "vitest --run --reporter verbose"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=18.x"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@headlessui/vue": "^1.7.14",
|
|
38
|
-
"@noeldemartin/utils": "0.
|
|
38
|
+
"@noeldemartin/utils": "0.5.0-next.dce7f1ca99862fde01601bb39d71d0eaaed3abe5",
|
|
39
39
|
"dompurify": "^3.0.3",
|
|
40
40
|
"marked": "^5.0.4",
|
|
41
41
|
"pinia": "^2.1.6",
|
|
@@ -43,8 +43,14 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@aerogel/vite": "*",
|
|
46
|
+
"@histoire/plugin-vue": "^0.17.6",
|
|
46
47
|
"@types/dompurify": "^3.0.2",
|
|
47
48
|
"@types/marked": "^5.0.0",
|
|
48
49
|
"tailwindcss": "^3.3.5"
|
|
50
|
+
},
|
|
51
|
+
"eslintConfig": {
|
|
52
|
+
"extends": [
|
|
53
|
+
"@noeldemartin/eslint-config-vue"
|
|
54
|
+
]
|
|
49
55
|
}
|
|
50
56
|
}
|
package/src/bootstrap/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
|
|
3
|
-
<slot
|
|
2
|
+
<div class="flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
|
|
3
|
+
<slot v-if="$errors.hasStartupErrors" name="startup-crash">
|
|
4
|
+
<AGStartupCrash />
|
|
5
|
+
</slot>
|
|
6
|
+
<slot v-else />
|
|
4
7
|
|
|
5
8
|
<AGAppOverlays />
|
|
6
9
|
</div>
|
|
@@ -8,4 +11,5 @@
|
|
|
8
11
|
|
|
9
12
|
<script setup lang="ts">
|
|
10
13
|
import AGAppOverlays from './AGAppOverlays.vue';
|
|
14
|
+
import AGStartupCrash from './lib/AGStartupCrash.vue';
|
|
11
15
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div aria-live="assertive" class="z-60 pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:p-6">
|
|
3
|
-
<div class="flex w-full flex-col items-
|
|
3
|
+
<div class="flex w-full flex-col items-end space-y-4">
|
|
4
4
|
<component
|
|
5
5
|
:is="snackbar.component"
|
|
6
6
|
v-for="snackbar of $ui.snackbars"
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
2
2
|
|
|
3
|
+
import { stringProp } from '@/utils';
|
|
4
|
+
|
|
3
5
|
export interface IAGHeadlessInput {
|
|
4
6
|
id: string;
|
|
7
|
+
name: ComputedRef<string | null>;
|
|
8
|
+
label: ComputedRef<string | null>;
|
|
5
9
|
value: ComputedRef<string | number | boolean | null>;
|
|
6
10
|
errors: DeepReadonly<Ref<string[] | null>>;
|
|
7
11
|
update(value: string | number | boolean | null): void;
|
|
8
12
|
}
|
|
13
|
+
|
|
14
|
+
export const inputProps = {
|
|
15
|
+
name: stringProp(),
|
|
16
|
+
label: stringProp(),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function useInputProps(): typeof inputProps {
|
|
20
|
+
return inputProps;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function extractInputProps<T extends Record<keyof typeof inputProps, unknown>>(
|
|
24
|
+
componentProps: T,
|
|
25
|
+
): Pick<T, keyof typeof inputProps> {
|
|
26
|
+
return Object.keys(inputProps).reduce((extractedProps, selectProp) => {
|
|
27
|
+
const prop = selectProp as keyof typeof inputProps;
|
|
28
|
+
|
|
29
|
+
extractedProps[prop] = componentProps[prop];
|
|
30
|
+
|
|
31
|
+
return extractedProps;
|
|
32
|
+
}, {} as Pick<T, keyof typeof inputProps>);
|
|
33
|
+
}
|
|
@@ -12,13 +12,14 @@ import { uuid } from '@noeldemartin/utils';
|
|
|
12
12
|
import { mixedProp, stringProp } from '@/utils/vue';
|
|
13
13
|
import type Form from '@/forms/Form';
|
|
14
14
|
|
|
15
|
+
import { useInputProps } from './AGHeadlessInput';
|
|
15
16
|
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
16
17
|
|
|
17
18
|
const emit = defineEmits(['update:modelValue']);
|
|
18
19
|
const props = defineProps({
|
|
19
20
|
as: stringProp('div'),
|
|
20
|
-
name: stringProp(),
|
|
21
21
|
modelValue: mixedProp<string | number | boolean>([String, Number, Boolean]),
|
|
22
|
+
...useInputProps(),
|
|
22
23
|
});
|
|
23
24
|
const errors = computed(() => {
|
|
24
25
|
if (!form || !props.name) {
|
|
@@ -30,6 +31,8 @@ const errors = computed(() => {
|
|
|
30
31
|
const form = inject<Form | null>('form', null);
|
|
31
32
|
const api: IAGHeadlessInput = {
|
|
32
33
|
id: `input-${uuid()}`,
|
|
34
|
+
name: computed(() => props.name),
|
|
35
|
+
label: computed(() => props.label),
|
|
33
36
|
value: computed(() => {
|
|
34
37
|
if (form && props.name) {
|
|
35
38
|
return form.getFieldValue(props.name) as string | number | boolean | null;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<label :for="input.id">
|
|
3
|
-
<slot
|
|
2
|
+
<label v-if="show" :for="input.id">
|
|
3
|
+
<slot>
|
|
4
|
+
{{ input.label }}
|
|
5
|
+
</slot>
|
|
4
6
|
</label>
|
|
5
7
|
</template>
|
|
6
8
|
|
|
7
9
|
<script setup lang="ts">
|
|
10
|
+
import { computed, useSlots } from 'vue';
|
|
11
|
+
|
|
8
12
|
import { injectReactiveOrFail } from '@/utils/vue';
|
|
9
13
|
|
|
10
14
|
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
@@ -13,4 +17,6 @@ const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
|
13
17
|
'input',
|
|
14
18
|
'<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>',
|
|
15
19
|
);
|
|
20
|
+
const slots = useSlots();
|
|
21
|
+
const show = computed(() => !!(input.label || slots.default));
|
|
16
22
|
</script>
|
|
@@ -21,8 +21,9 @@ export interface IAGHeadlessSelect {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const selectProps = {
|
|
24
|
-
|
|
24
|
+
name: stringProp(),
|
|
25
25
|
label: stringProp(),
|
|
26
|
+
options: requiredArrayProp<IAGSelectOptionValue>(),
|
|
26
27
|
noSelectionText: stringProp(),
|
|
27
28
|
};
|
|
28
29
|
|
|
@@ -13,7 +13,7 @@ import { computed, inject, provide } from 'vue';
|
|
|
13
13
|
import { isObject, toString, uuid } from '@noeldemartin/utils';
|
|
14
14
|
import { Listbox } from '@headlessui/vue';
|
|
15
15
|
|
|
16
|
-
import { mixedProp
|
|
16
|
+
import { mixedProp } from '@/utils/vue';
|
|
17
17
|
import { translateWithDefault } from '@/lang/utils';
|
|
18
18
|
import type Form from '@/forms/Form';
|
|
19
19
|
import type { ComponentProps } from '@/utils/vue';
|
|
@@ -23,7 +23,6 @@ import type { IAGHeadlessSelect, IAGSelectOption, IAGSelectOptionValue } from '.
|
|
|
23
23
|
|
|
24
24
|
const emit = defineEmits(['update:modelValue']);
|
|
25
25
|
const props = defineProps({
|
|
26
|
-
name: stringProp(),
|
|
27
26
|
modelValue: mixedProp<IAGSelectOptionValue>(),
|
|
28
27
|
...useSelectProps(),
|
|
29
28
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<ListboxLabel v-if="
|
|
2
|
+
<ListboxLabel v-if="show" v-slot="{ open, disabled }: ComponentProps">
|
|
3
3
|
<slot :open="open" :disabled="disabled">
|
|
4
4
|
{{ select.label }}
|
|
5
5
|
</slot>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script setup lang="ts">
|
|
10
|
+
import { computed, useSlots } from 'vue';
|
|
10
11
|
import { ListboxLabel } from '@headlessui/vue';
|
|
11
12
|
|
|
12
13
|
import { injectReactiveOrFail } from '@/utils/vue';
|
|
@@ -18,4 +19,6 @@ const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
|
18
19
|
'select',
|
|
19
20
|
'<AGHeadlessSelectLabel> must be a child of a <AGHeadlessSelect>',
|
|
20
21
|
);
|
|
22
|
+
const slots = useSlots();
|
|
23
|
+
const show = computed(() => !!(select.label || slots.default));
|
|
21
24
|
</script>
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { IAGModal } from '@/components/modals/AGModal';
|
|
2
|
+
import { booleanProp } from '@/utils';
|
|
2
3
|
|
|
3
4
|
export interface IAGHeadlessModal extends IAGModal {}
|
|
4
5
|
|
|
5
6
|
export interface IAGHeadlessModalDefaultSlotProps {
|
|
6
7
|
close(result?: unknown): Promise<void>;
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
export const modalProps = {
|
|
11
|
+
cancellable: booleanProp(true),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function useModalProps(): typeof modalProps {
|
|
15
|
+
return modalProps;
|
|
16
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { AGHeadlessModal, AGHeadlessModalPanel, AGHeadlessModalTitle, IAGHeadlessModal };
|
|
1
|
+
export * from './AGHeadlessModal';
|
|
2
|
+
export { default as AGHeadlessModal } from './AGHeadlessModal.vue';
|
|
3
|
+
export { default as AGHeadlessModalPanel } from './AGHeadlessModalPanel.vue';
|
|
4
|
+
export { default as AGHeadlessModalTitle } from './AGHeadlessModalTitle.vue';
|
package/src/components/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ import AGAppOverlays from './AGAppOverlays.vue';
|
|
|
3
3
|
|
|
4
4
|
export { AGAppLayout, AGAppOverlays };
|
|
5
5
|
|
|
6
|
-
export * from './basic';
|
|
7
6
|
export * from './constants';
|
|
8
7
|
export * from './forms';
|
|
9
8
|
export * from './headless';
|
|
9
|
+
export * from './lib';
|
|
10
10
|
export * from './modals';
|
|
11
11
|
export * from './snackbars';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="grid flex-grow place-items-center">
|
|
3
|
+
<div class="flex flex-col items-center space-y-6 p-8">
|
|
4
|
+
<h1 class="mt-2 text-center text-4xl font-medium text-red-600">
|
|
5
|
+
{{ $td('startupCrash.title', 'Something went wrong!') }}
|
|
6
|
+
</h1>
|
|
7
|
+
<AGMarkdown
|
|
8
|
+
:text="
|
|
9
|
+
$td(
|
|
10
|
+
'startupCrash.message',
|
|
11
|
+
'Something failed trying to start the application.\n\nHere\'s some things you can do:'
|
|
12
|
+
)
|
|
13
|
+
"
|
|
14
|
+
class="mt-4 text-center"
|
|
15
|
+
/>
|
|
16
|
+
<div class="mt-4 flex flex-col space-y-4">
|
|
17
|
+
<AGButton color="danger" @click="$app.reload()">
|
|
18
|
+
{{ $td('startupCrash.reload', 'Try again') }}
|
|
19
|
+
</AGButton>
|
|
20
|
+
<AGButton color="danger" @click="$errors.inspect($errors.startupErrors)">
|
|
21
|
+
{{ $td('startupCrash.inspect', 'View error details') }}
|
|
22
|
+
</AGButton>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import AGMarkdown from './AGMarkdown.vue';
|
|
30
|
+
import AGButton from '../forms/AGButton.vue';
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { requiredStringProp, stringProp } from '@/utils';
|
|
2
|
+
|
|
3
|
+
export const confirmModalProps = {
|
|
4
|
+
title: stringProp(),
|
|
5
|
+
message: requiredStringProp(),
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function useConfirmModalProps(): typeof confirmModalProps {
|
|
9
|
+
return confirmModalProps;
|
|
10
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal v-slot="{ close }:
|
|
2
|
+
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false">
|
|
3
3
|
<AGMarkdown v-if="title" :text="title" as="h1" />
|
|
4
4
|
<AGMarkdown :text="message" />
|
|
5
5
|
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
19
19
|
|
|
20
20
|
import AGModal from './AGModal.vue';
|
|
21
|
-
import type {
|
|
21
|
+
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
22
22
|
|
|
23
23
|
import AGButton from '../forms/AGButton.vue';
|
|
24
|
-
import AGMarkdown from '../
|
|
24
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
25
25
|
|
|
26
26
|
defineProps({
|
|
27
27
|
title: stringProp(),
|
|
@@ -53,7 +53,7 @@ import { useErrorReportModalProps } from './AGErrorReportModal';
|
|
|
53
53
|
import AGButton from '../forms/AGButton.vue';
|
|
54
54
|
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
55
55
|
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
56
|
-
import AGMarkdown from '../
|
|
56
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
57
57
|
import AGModal from './AGModal.vue';
|
|
58
58
|
|
|
59
59
|
const props = defineProps(useErrorReportModalProps());
|
|
@@ -8,7 +8,7 @@ import { computed } from 'vue';
|
|
|
8
8
|
import { numberProp, requiredObjectProp } from '@/utils/vue';
|
|
9
9
|
import type { ErrorReport } from '@/errors';
|
|
10
10
|
|
|
11
|
-
import AGMarkdown from '../
|
|
11
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
12
|
|
|
13
13
|
const props = defineProps({
|
|
14
14
|
report: requiredObjectProp<ErrorReport>(),
|
|
@@ -12,7 +12,7 @@ import { translateWithDefault } from '@/lang/utils';
|
|
|
12
12
|
|
|
13
13
|
import AGModal from './AGModal.vue';
|
|
14
14
|
|
|
15
|
-
import AGMarkdown from '../
|
|
15
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
16
16
|
|
|
17
17
|
const props = defineProps({ message: stringProp() });
|
|
18
18
|
const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
|
|
@@ -2,9 +2,9 @@ import type { Ref } from 'vue';
|
|
|
2
2
|
|
|
3
3
|
export interface IAGModal {
|
|
4
4
|
cancellable: Ref<boolean>;
|
|
5
|
-
close(): Promise<void>;
|
|
5
|
+
close(result?: unknown): Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface IAGModalDefaultSlotProps {
|
|
9
9
|
close(result?: unknown): Promise<void>;
|
|
10
10
|
}
|
|
@@ -7,7 +7,9 @@ import AGModal from './AGModal.vue';
|
|
|
7
7
|
import AGModalTitle from './AGModalTitle.vue';
|
|
8
8
|
import AGModalContext from './AGModalContext.vue';
|
|
9
9
|
|
|
10
|
+
export * from './AGConfirmModal';
|
|
10
11
|
export * from './AGErrorReportModal';
|
|
12
|
+
export * from './AGLoadingModal';
|
|
11
13
|
export * from './AGModal';
|
|
12
14
|
export * from './AGModalContext';
|
|
13
15
|
|
|
@@ -22,7 +22,7 @@ import type { SnackbarAction } from '@/components/headless';
|
|
|
22
22
|
|
|
23
23
|
import AGButton from '../forms/AGButton.vue';
|
|
24
24
|
import AGHeadlessSnackbar from '../headless/snackbars/AGHeadlessSnackbar.vue';
|
|
25
|
-
import AGMarkdown from '../
|
|
25
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
26
26
|
|
|
27
27
|
const props = defineProps(useSnackbarProps());
|
|
28
28
|
const styleClasses = computed(() => {
|
package/src/errors/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { App } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { bootServices } from '@/services';
|
|
4
4
|
import { definePlugin } from '@/plugins';
|
|
@@ -25,14 +25,12 @@ const frameworkHandler: ErrorHandler = (error) => {
|
|
|
25
25
|
return true;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
function setUpErrorHandler(baseHandler: ErrorHandler = () => false):
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
);
|
|
28
|
+
function setUpErrorHandler(app: App, baseHandler: ErrorHandler = () => false): void {
|
|
29
|
+
const errorHandler: ErrorHandler = (error) => baseHandler(error) || frameworkHandler(error);
|
|
30
|
+
|
|
31
|
+
app.config.errorHandler = errorHandler;
|
|
32
|
+
globalThis.onerror = (event, _, __, ___, error) => errorHandler(error ?? event);
|
|
33
|
+
globalThis.onunhandledrejection = (event) => errorHandler(event.reason);
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
export type ErrorHandler = (error: ErrorSource) => boolean;
|
|
@@ -40,9 +38,7 @@ export type ErrorsServices = typeof services;
|
|
|
40
38
|
|
|
41
39
|
export default definePlugin({
|
|
42
40
|
async install(app, options) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
app.config.errorHandler = errorHandler;
|
|
41
|
+
setUpErrorHandler(app, options.handleError);
|
|
46
42
|
|
|
47
43
|
await bootServices(app, services);
|
|
48
44
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Aerogel from 'virtual:aerogel';
|
|
2
2
|
|
|
3
3
|
import { defineServiceState } from '@/services/Service';
|
|
4
4
|
import type { Plugin } from '@/plugins/Plugin';
|
|
@@ -7,8 +7,8 @@ export default defineServiceState({
|
|
|
7
7
|
name: 'app',
|
|
8
8
|
initialState: {
|
|
9
9
|
plugins: {} as Record<string, Plugin>,
|
|
10
|
-
environment:
|
|
11
|
-
sourceUrl:
|
|
10
|
+
environment: Aerogel.environment,
|
|
11
|
+
sourceUrl: Aerogel.sourceUrl,
|
|
12
12
|
isMounted: false,
|
|
13
13
|
},
|
|
14
14
|
computed: {
|
package/src/services/App.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { facade } from '@noeldemartin/utils';
|
|
1
|
+
import { facade, forever, updateLocationQueryParameters } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
3
|
import Events from '@/services/Events';
|
|
4
4
|
import type { Plugin } from '@/plugins';
|
|
@@ -7,6 +7,15 @@ import Service from './App.state';
|
|
|
7
7
|
|
|
8
8
|
export class AppService extends Service {
|
|
9
9
|
|
|
10
|
+
public async reload(queryParameters?: Record<string, string | undefined>): Promise<void> {
|
|
11
|
+
queryParameters && updateLocationQueryParameters(queryParameters);
|
|
12
|
+
|
|
13
|
+
location.reload();
|
|
14
|
+
|
|
15
|
+
// Stall until the reload happens
|
|
16
|
+
await forever();
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
public plugin<T extends Plugin = Plugin>(name: string): T | null {
|
|
11
20
|
return (this.plugins[name] as T) ?? null;
|
|
12
21
|
}
|
package/src/services/Service.ts
CHANGED
|
@@ -162,7 +162,11 @@ export default class Service<
|
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
const storage = Storage.
|
|
165
|
+
const storage = Storage.get<ServiceStorage>(this._name);
|
|
166
|
+
|
|
167
|
+
if (!storage) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
166
170
|
|
|
167
171
|
Storage.set(this._name, {
|
|
168
172
|
...storage,
|
|
@@ -191,14 +195,14 @@ export default class Service<
|
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
protected async frameworkBoot(): Promise<void> {
|
|
194
|
-
this.
|
|
198
|
+
this.initializePersistedState();
|
|
195
199
|
}
|
|
196
200
|
|
|
197
201
|
protected async boot(): Promise<void> {
|
|
198
|
-
//
|
|
202
|
+
// Placeholder for overrides, don't place any functionality here.
|
|
199
203
|
}
|
|
200
204
|
|
|
201
|
-
protected
|
|
205
|
+
protected initializePersistedState(): void {
|
|
202
206
|
// TODO fix this.static()
|
|
203
207
|
const persist = (this.constructor as unknown as { persist: string[] }).persist;
|
|
204
208
|
|
package/src/ui/UI.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { facade, fail, uuid } from '@noeldemartin/utils';
|
|
1
|
+
import { after, facade, fail, uuid } from '@noeldemartin/utils';
|
|
2
2
|
import { markRaw, nextTick } from 'vue';
|
|
3
3
|
import type { Component } from 'vue';
|
|
4
4
|
import type { ObjectValues } from '@noeldemartin/utils';
|
|
@@ -72,11 +72,14 @@ export class UIService extends Service {
|
|
|
72
72
|
|
|
73
73
|
const message = typeof messageOrOperation === 'string' ? messageOrOperation : undefined;
|
|
74
74
|
const modal = await this.openModal(this.requireComponent(UIComponents.LoadingModal), { message });
|
|
75
|
-
const result = await operation;
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
try {
|
|
77
|
+
const [result] = await Promise.all([operation, after({ seconds: 1 })]);
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
return result;
|
|
80
|
+
} finally {
|
|
81
|
+
await this.closeModal(modal.id);
|
|
82
|
+
}
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
public showSnackbar(message: string, options: ShowSnackbarOptions = {}): void {
|
|
@@ -138,6 +141,7 @@ export class UIService extends Service {
|
|
|
138
141
|
|
|
139
142
|
protected async boot(): Promise<void> {
|
|
140
143
|
this.watchModalEvents();
|
|
144
|
+
this.watchMountedEvent();
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
private watchModalEvents(): void {
|
|
@@ -165,6 +169,24 @@ export class UIService extends Service {
|
|
|
165
169
|
});
|
|
166
170
|
}
|
|
167
171
|
|
|
172
|
+
private watchMountedEvent(): void {
|
|
173
|
+
Events.once('application-mounted', async () => {
|
|
174
|
+
const splash = document.getElementById('splash');
|
|
175
|
+
|
|
176
|
+
if (!splash) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (window.getComputedStyle(splash).opacity !== '0') {
|
|
181
|
+
splash.style.opacity = '0';
|
|
182
|
+
|
|
183
|
+
await after({ ms: 600 });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
splash.remove();
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
168
190
|
}
|
|
169
191
|
|
|
170
192
|
export default facade(new UIService());
|
package/tsconfig.json
CHANGED
package/.eslintrc.js
DELETED
package/dist/virtual.d.ts
DELETED
package/src/types/virtual.d.ts
DELETED
|
File without changes
|
|
File without changes
|