@aerogel/core 0.0.0-next.9487bb13082b9d479112445804d906125ded5cbc → 0.0.0-next.a56c0f4966eb71571173f8502f3f36d357ceebc7

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/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.a56c0f4966eb71571173f8502f3f36d357ceebc7",
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,13 @@
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",
12
+ "build:types": "noeldemartin-build-types",
13
13
  "histoire:dev": "histoire dev",
14
14
  "histoire:prod": "histoire build",
15
15
  "lint": "noeldemartin-lint src",
16
16
  "publish-next": "noeldemartin-publish-next",
17
- "test": "vitest --run"
17
+ "test": "vitest --run",
18
+ "test:ci": "vitest --run --reporter verbose"
18
19
  },
19
20
  "engines": {
20
21
  "node": ">=18.x"
@@ -35,7 +36,7 @@
35
36
  },
36
37
  "dependencies": {
37
38
  "@headlessui/vue": "^1.7.14",
38
- "@noeldemartin/utils": "0.4.0-next.2549ce58d5c94a6009ecdd37d6fe2fcd76b6038e",
39
+ "@noeldemartin/utils": "0.5.0-next.dce7f1ca99862fde01601bb39d71d0eaaed3abe5",
39
40
  "dompurify": "^3.0.3",
40
41
  "marked": "^5.0.4",
41
42
  "pinia": "^2.1.6",
@@ -46,5 +47,10 @@
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"
@@ -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(),
@@ -21,7 +21,7 @@ import AGModal from './AGModal.vue';
21
21
  import type { IAGModalSlotProps } 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>(),
@@ -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...'));
@@ -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
  }
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
File without changes