@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.
Files changed (44) hide show
  1. package/dist/aerogel-core.cjs.js +1 -1
  2. package/dist/aerogel-core.cjs.js.map +1 -1
  3. package/dist/aerogel-core.d.ts +145 -39
  4. package/dist/aerogel-core.esm.js +1 -1
  5. package/dist/aerogel-core.esm.js.map +1 -1
  6. package/package.json +12 -6
  7. package/src/bootstrap/bootstrap.test.ts +1 -0
  8. package/src/bootstrap/index.ts +6 -0
  9. package/src/components/AGAppLayout.vue +6 -2
  10. package/src/components/AGAppSnackbars.vue +1 -1
  11. package/src/components/headless/forms/AGHeadlessInput.ts +25 -0
  12. package/src/components/headless/forms/AGHeadlessInput.vue +4 -1
  13. package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
  14. package/src/components/headless/forms/AGHeadlessSelect.ts +2 -1
  15. package/src/components/headless/forms/AGHeadlessSelect.vue +1 -2
  16. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +4 -1
  17. package/src/components/headless/modals/AGHeadlessModal.ts +9 -0
  18. package/src/components/headless/modals/index.ts +4 -6
  19. package/src/components/index.ts +1 -1
  20. package/src/components/lib/AGStartupCrash.vue +31 -0
  21. package/src/components/lib/index.ts +4 -0
  22. package/src/components/modals/AGAlertModal.vue +1 -1
  23. package/src/components/modals/AGConfirmModal.ts +10 -0
  24. package/src/components/modals/AGConfirmModal.vue +3 -3
  25. package/src/components/modals/AGErrorReportModal.vue +1 -1
  26. package/src/components/modals/AGErrorReportModalTitle.vue +1 -1
  27. package/src/components/modals/AGLoadingModal.ts +9 -0
  28. package/src/components/modals/AGLoadingModal.vue +1 -1
  29. package/src/components/modals/AGModal.ts +2 -2
  30. package/src/components/modals/index.ts +2 -0
  31. package/src/components/snackbars/AGSnackbar.vue +1 -1
  32. package/src/errors/index.ts +8 -12
  33. package/src/services/App.state.ts +3 -3
  34. package/src/services/App.ts +10 -1
  35. package/src/services/Service.ts +8 -4
  36. package/src/ui/UI.ts +26 -4
  37. package/tsconfig.json +1 -1
  38. package/.eslintrc.js +0 -3
  39. package/dist/virtual.d.ts +0 -11
  40. package/src/components/basic/index.ts +0 -5
  41. package/src/types/virtual.d.ts +0 -11
  42. /package/src/components/{basic → lib}/AGErrorMessage.vue +0 -0
  43. /package/src/components/{basic → lib}/AGLink.vue +0 -0
  44. /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.9487bb13082b9d479112445804d906125ded5cbc",
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 && cp src/types/virtual.d.ts dist",
13
- "histoire:dev": "histoire dev",
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.4.0-next.2549ce58d5c94a6009ecdd37d6fe2fcd76b6038e",
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
  }
@@ -11,6 +11,7 @@ import { bootstrapApplication } from './index';
11
11
  describe('Aerogel', () => {
12
12
 
13
13
  beforeEach(() => {
14
+ vi.stubGlobal('document', { getElementById: () => null });
14
15
  vi.mock('vue', async () => {
15
16
  const vue = (await vi.importActual('vue')) as Object;
16
17
 
@@ -21,3 +21,9 @@ export async function bootstrapApplication(rootComponent: Component, options: Ae
21
21
 
22
22
  Events.emit('application-mounted');
23
23
  }
24
+
25
+ declare module '@/services/Events' {
26
+ export interface EventsPayload {
27
+ 'application-mounted': void;
28
+ }
29
+ }
@@ -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-center space-y-4 sm:items-end">
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
- options: requiredArrayProp<IAGSelectOptionValue>(),
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, stringProp } from '@/utils/vue';
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="select.label" v-slot="{ open, disabled }: ComponentProps">
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
- import AGHeadlessModal from './AGHeadlessModal.vue';
2
- import AGHeadlessModalPanel from './AGHeadlessModalPanel.vue';
3
- import AGHeadlessModalTitle from './AGHeadlessModalTitle.vue';
4
- import type { IAGHeadlessModal } from './AGHeadlessModal';
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';
@@ -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,4 @@
1
+ export { default as AGErrorMessage } from './AGErrorMessage.vue';
2
+ export { default as AGLink } from './AGLink.vue';
3
+ export { default as AGMarkdown } from './AGMarkdown.vue';
4
+ export { default as AGStartupCrash } from './AGStartupCrash.vue';
@@ -16,7 +16,7 @@ import { requiredStringProp, stringProp } from '@/utils/vue';
16
16
 
17
17
  import AGModal from './AGModal.vue';
18
18
 
19
- import AGMarkdown from '../basic/AGMarkdown.vue';
19
+ import AGMarkdown from '../lib/AGMarkdown.vue';
20
20
 
21
21
  defineProps({
22
22
  title: stringProp(),
@@ -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 }: IAGModalSlotProps" :cancellable="false">
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 { IAGModalSlotProps } from './AGModal';
21
+ import type { IAGModalDefaultSlotProps } from './AGModal';
22
22
 
23
23
  import AGButton from '../forms/AGButton.vue';
24
- import AGMarkdown from '../basic/AGMarkdown.vue';
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 '../basic/AGMarkdown.vue';
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 '../basic/AGMarkdown.vue';
11
+ import AGMarkdown from '../lib/AGMarkdown.vue';
12
12
 
13
13
  const props = defineProps({
14
14
  report: requiredObjectProp<ErrorReport>(),
@@ -0,0 +1,9 @@
1
+ import { stringProp } from '@/utils';
2
+
3
+ export const loadingModalProps = {
4
+ message: stringProp(),
5
+ };
6
+
7
+ export function useLoadingModalProps(): typeof loadingModalProps {
8
+ return loadingModalProps;
9
+ }
@@ -12,7 +12,7 @@ import { translateWithDefault } from '@/lang/utils';
12
12
 
13
13
  import AGModal from './AGModal.vue';
14
14
 
15
- import AGMarkdown from '../basic/AGMarkdown.vue';
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 IAGModalSlotProps {
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 '../basic/AGMarkdown.vue';
25
+ import AGMarkdown from '../lib/AGMarkdown.vue';
26
26
 
27
27
  const props = defineProps(useSnackbarProps());
28
28
  const styleClasses = computed(() => {
@@ -1,4 +1,4 @@
1
- import { tap } from '@noeldemartin/utils';
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): ErrorHandler {
29
- return tap(
30
- (error) => baseHandler(error) || frameworkHandler(error),
31
- (errorHandler) => {
32
- globalThis.onerror = (message, _, __, ___, error) => errorHandler(error ?? message);
33
- globalThis.onunhandledrejection = (event) => errorHandler(event.reason);
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
- const errorHandler = setUpErrorHandler(options.handleError);
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 Build from 'virtual:aerogel';
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: Build.environment,
11
- sourceUrl: Build.sourceUrl,
10
+ environment: Aerogel.environment,
11
+ sourceUrl: Aerogel.sourceUrl,
12
12
  isMounted: false,
13
13
  },
14
14
  computed: {
@@ -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
  }
@@ -162,7 +162,11 @@ export default class Service<
162
162
  return;
163
163
  }
164
164
 
165
- const storage = Storage.require<ServiceStorage>(this._name);
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.restorePersistedState();
198
+ this.initializePersistedState();
195
199
  }
196
200
 
197
201
  protected async boot(): Promise<void> {
198
- // Override.
202
+ // Placeholder for overrides, don't place any functionality here.
199
203
  }
200
204
 
201
- protected restorePersistedState(): void {
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
- await this.closeModal(modal.id);
76
+ try {
77
+ const [result] = await Promise.all([operation, after({ seconds: 1 })]);
78
78
 
79
- return result;
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "types": ["unplugin-icons/types/vue3"],
4
+ "types": ["unplugin-icons/types/vue3", "@aerogel/vite/dist/virtual"],
5
5
  "baseUrl": ".",
6
6
  "paths": {
7
7
  "@/*": ["./src/*"]
package/.eslintrc.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['@noeldemartin/eslint-config-vue'],
3
- };
package/dist/virtual.d.ts DELETED
@@ -1,11 +0,0 @@
1
- declare module 'virtual:aerogel' {
2
- interface AerogelBuild {
3
- environment: 'production' | 'development' | 'testing';
4
- basePath?: string;
5
- sourceUrl?: string;
6
- }
7
-
8
- const build: AerogelBuild;
9
-
10
- export default build;
11
- }
@@ -1,5 +0,0 @@
1
- import AGErrorMessage from './AGErrorMessage.vue';
2
- import AGLink from './AGLink.vue';
3
- import AGMarkdown from './AGMarkdown.vue';
4
-
5
- export { AGErrorMessage, AGLink, AGMarkdown };
@@ -1,11 +0,0 @@
1
- declare module 'virtual:aerogel' {
2
- interface AerogelBuild {
3
- environment: 'production' | 'development' | 'testing';
4
- basePath?: string;
5
- sourceUrl?: string;
6
- }
7
-
8
- const build: AerogelBuild;
9
-
10
- export default build;
11
- }
File without changes