@aerogel/core 0.0.0-next.7f6ed5a1f91688a86bf5ede2adc465e4fd6cfdea → 0.0.0-next.b58141fee5d2fe7d25debdbca6b1d2bf1c13e48e
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 +711 -79
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/dist/virtual.d.ts +11 -0
- package/noeldemartin.config.js +4 -1
- package/package.json +7 -9
- package/src/bootstrap/bootstrap.test.ts +0 -56
- package/src/bootstrap/index.ts +9 -25
- package/src/bootstrap/options.ts +5 -1
- package/src/components/AGAppModals.vue +15 -0
- package/src/components/AGAppOverlays.vue +5 -7
- package/src/components/AGAppSnackbars.vue +13 -0
- package/src/components/basic/AGErrorMessage.vue +16 -0
- package/src/components/basic/AGLink.vue +9 -0
- package/src/components/basic/AGMarkdown.vue +21 -5
- package/src/components/basic/index.ts +3 -1
- package/src/components/constants.ts +8 -0
- package/src/components/forms/AGButton.vue +36 -3
- package/src/components/forms/AGCheckbox.vue +35 -0
- package/src/components/forms/AGInput.vue +8 -4
- package/src/components/forms/index.ts +2 -1
- package/src/components/headless/forms/AGHeadlessButton.vue +7 -7
- package/src/components/headless/forms/AGHeadlessInput.ts +2 -2
- package/src/components/headless/forms/AGHeadlessInput.vue +5 -5
- package/src/components/headless/forms/AGHeadlessInputError.vue +9 -5
- package/src/components/headless/forms/AGHeadlessInputInput.vue +20 -4
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +16 -0
- package/src/components/headless/forms/index.ts +6 -4
- package/src/components/headless/index.ts +1 -0
- package/src/components/headless/modals/AGHeadlessModal.vue +5 -1
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +10 -2
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
- package/src/components/headless/snackbars/index.ts +25 -0
- package/src/components/index.ts +4 -1
- package/src/components/modals/AGAlertModal.vue +12 -2
- package/src/components/modals/AGConfirmModal.vue +30 -0
- package/src/components/modals/AGErrorReportModal.ts +20 -0
- package/src/components/modals/AGErrorReportModal.vue +62 -0
- package/src/components/modals/AGErrorReportModalButtons.vue +109 -0
- package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
- package/src/components/modals/AGLoadingModal.vue +19 -0
- package/src/components/modals/AGModal.ts +4 -0
- package/src/components/modals/AGModal.vue +23 -4
- package/src/components/modals/AGModalTitle.vue +9 -0
- package/src/components/modals/index.ts +20 -2
- package/src/components/snackbars/AGSnackbar.vue +42 -0
- package/src/components/snackbars/index.ts +3 -0
- package/src/directives/index.ts +19 -4
- package/src/errors/Errors.state.ts +31 -0
- package/src/errors/Errors.ts +183 -0
- package/src/errors/index.ts +59 -0
- package/src/forms/Form.test.ts +21 -0
- package/src/forms/Form.ts +38 -16
- package/src/forms/utils.ts +17 -0
- package/src/lang/Lang.ts +47 -8
- package/src/lang/index.ts +17 -76
- package/src/lang/utils.ts +4 -0
- package/src/main.ts +2 -0
- package/src/plugins/Plugin.ts +7 -0
- package/src/plugins/index.ts +7 -0
- package/src/services/App.state.ts +16 -0
- package/src/services/App.ts +15 -0
- package/src/services/Service.ts +157 -29
- package/src/services/index.ts +32 -7
- package/src/services/store.ts +27 -0
- package/src/types/virtual.d.ts +11 -0
- package/src/types/vite.d.ts +0 -2
- package/src/ui/UI.state.ts +12 -6
- package/src/ui/UI.ts +72 -10
- package/src/ui/index.ts +24 -14
- package/src/utils/composition/forms.ts +11 -0
- package/src/utils/composition/hooks.ts +9 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/markdown.ts +11 -2
- package/src/utils/vue.ts +2 -0
- package/tsconfig.json +2 -10
- package/vite.config.ts +3 -6
- package/src/bootstrap/hooks.ts +0 -19
- package/src/lang/helpers.ts +0 -5
- package/src/models/index.ts +0 -18
- package/src/routing/index.ts +0 -33
- package/src/testing/stubs/lang/en.yaml +0 -1
- package/src/testing/stubs/models/User.ts +0 -3
package/src/services/index.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
1
|
+
import type { App as VueApp } from 'vue';
|
|
2
2
|
|
|
3
|
+
import { definePlugin } from '@/plugins';
|
|
4
|
+
|
|
5
|
+
import App from './App';
|
|
3
6
|
import Events from './Events';
|
|
4
7
|
import Service from './Service';
|
|
5
|
-
import {
|
|
8
|
+
import { getPiniaStore } from './store';
|
|
6
9
|
|
|
10
|
+
export * from './App';
|
|
7
11
|
export * from './Events';
|
|
8
12
|
export * from './Service';
|
|
9
13
|
|
|
10
|
-
export { Events, Service };
|
|
14
|
+
export { App, Events, Service };
|
|
11
15
|
|
|
12
16
|
const defaultServices = {
|
|
17
|
+
$app: App,
|
|
13
18
|
$events: Events,
|
|
14
19
|
};
|
|
15
20
|
|
|
@@ -17,18 +22,38 @@ export type DefaultServices = typeof defaultServices;
|
|
|
17
22
|
|
|
18
23
|
export interface Services extends DefaultServices {}
|
|
19
24
|
|
|
20
|
-
export async function bootServices(app:
|
|
25
|
+
export async function bootServices(app: VueApp, services: Record<string, Service>): Promise<void> {
|
|
21
26
|
await Promise.all(
|
|
22
27
|
Object.entries(services).map(async ([name, service]) => {
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
await service
|
|
29
|
+
.launch()
|
|
30
|
+
.catch((error) => app.config.errorHandler?.(error, null, `Failed launching ${name}.`));
|
|
25
31
|
}),
|
|
26
32
|
);
|
|
27
33
|
|
|
28
34
|
Object.assign(app.config.globalProperties, services);
|
|
35
|
+
|
|
36
|
+
App.development && Object.assign(window, services);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
export default
|
|
39
|
+
export default definePlugin({
|
|
40
|
+
async install(app, options) {
|
|
41
|
+
const services = {
|
|
42
|
+
...defaultServices,
|
|
43
|
+
...options.services,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
app.use(getPiniaStore());
|
|
47
|
+
|
|
48
|
+
await bootServices(app, services);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
declare module '@/bootstrap/options' {
|
|
53
|
+
interface AerogelOptions {
|
|
54
|
+
services?: Record<string, Service>;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
32
57
|
|
|
33
58
|
declare module '@vue/runtime-core' {
|
|
34
59
|
interface ComponentCustomProperties extends Services {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createPinia, defineStore, setActivePinia } from 'pinia';
|
|
2
|
+
import type { DefineStoreOptions, Pinia, StateTree, Store, _GettersTree } from 'pinia';
|
|
3
|
+
|
|
4
|
+
let _store: Pinia | null = null;
|
|
5
|
+
|
|
6
|
+
function initializePiniaStore(): Pinia {
|
|
7
|
+
if (!_store) {
|
|
8
|
+
_store = createPinia();
|
|
9
|
+
|
|
10
|
+
setActivePinia(_store);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return _store;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getPiniaStore(): Pinia {
|
|
17
|
+
return _store ?? initializePiniaStore();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function defineServiceStore<Id extends string, S extends StateTree = {}, G extends _GettersTree<S> = {}, A = {}>(
|
|
21
|
+
name: Id,
|
|
22
|
+
options: Omit<DefineStoreOptions<Id, S, G, A>, 'id'>,
|
|
23
|
+
): Store<Id, S, G, A> {
|
|
24
|
+
initializePiniaStore();
|
|
25
|
+
|
|
26
|
+
return defineStore(name, options)();
|
|
27
|
+
}
|
package/src/types/vite.d.ts
CHANGED
package/src/ui/UI.state.ts
CHANGED
|
@@ -2,10 +2,6 @@ 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
|
-
|
|
9
5
|
export interface Modal<T = unknown> {
|
|
10
6
|
id: string;
|
|
11
7
|
properties: Record<string, unknown>;
|
|
@@ -21,6 +17,16 @@ export interface ModalComponent<
|
|
|
21
17
|
Result = unknown
|
|
22
18
|
> {}
|
|
23
19
|
|
|
24
|
-
export
|
|
25
|
-
|
|
20
|
+
export interface Snackbar {
|
|
21
|
+
id: string;
|
|
22
|
+
component: Component;
|
|
23
|
+
properties: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default defineServiceState({
|
|
27
|
+
name: 'ui',
|
|
28
|
+
initialState: {
|
|
29
|
+
modals: [] as Modal[],
|
|
30
|
+
snackbars: [] as Snackbar[],
|
|
31
|
+
},
|
|
26
32
|
});
|
package/src/ui/UI.ts
CHANGED
|
@@ -4,9 +4,10 @@ import type { Component } from 'vue';
|
|
|
4
4
|
import type { ObjectValues } from '@noeldemartin/utils';
|
|
5
5
|
|
|
6
6
|
import Events from '@/services/Events';
|
|
7
|
+
import type { SnackbarAction, SnackbarColor } from '@/components/headless/snackbars';
|
|
7
8
|
|
|
8
9
|
import Service from './UI.state';
|
|
9
|
-
import type { Modal, ModalComponent } from './UI.state';
|
|
10
|
+
import type { Modal, ModalComponent, Snackbar } from './UI.state';
|
|
10
11
|
|
|
11
12
|
interface ModalCallbacks<T = unknown> {
|
|
12
13
|
willClose(result: T | undefined): void;
|
|
@@ -20,17 +21,81 @@ type ModalResult<TComponent> = TComponent extends ModalComponent<Record<string,
|
|
|
20
21
|
|
|
21
22
|
export const UIComponents = {
|
|
22
23
|
AlertModal: 'alert-modal',
|
|
24
|
+
ConfirmModal: 'confirm-modal',
|
|
25
|
+
ErrorReportModal: 'error-report-modal',
|
|
26
|
+
LoadingModal: 'loading-modal',
|
|
27
|
+
Snackbar: 'snackbar',
|
|
23
28
|
} as const;
|
|
24
29
|
|
|
25
30
|
export type UIComponent = ObjectValues<typeof UIComponents>;
|
|
26
31
|
|
|
32
|
+
export interface ShowSnackbarOptions {
|
|
33
|
+
component?: Component;
|
|
34
|
+
color?: SnackbarColor;
|
|
35
|
+
actions?: SnackbarAction[];
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
export class UIService extends Service {
|
|
28
39
|
|
|
29
40
|
private modalCallbacks: Record<string, Partial<ModalCallbacks>> = {};
|
|
30
41
|
private components: Partial<Record<UIComponent, Component>> = {};
|
|
31
42
|
|
|
32
|
-
public
|
|
33
|
-
this.
|
|
43
|
+
public requireComponent(name: UIComponent): Component {
|
|
44
|
+
return this.components[name] ?? fail(`UI Component '${name}' is not defined!`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public alert(message: string): void;
|
|
48
|
+
public alert(title: string, message: string): void;
|
|
49
|
+
public alert(messageOrTitle: string, message?: string): void {
|
|
50
|
+
const options = typeof message === 'string' ? { title: messageOrTitle, message } : { message: messageOrTitle };
|
|
51
|
+
|
|
52
|
+
this.openModal(this.requireComponent(UIComponents.AlertModal), options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async confirm(message: string): Promise<boolean>;
|
|
56
|
+
public async confirm(title: string, message: string): Promise<boolean>;
|
|
57
|
+
public async confirm(messageOrTitle: string, message?: string): Promise<boolean> {
|
|
58
|
+
const options = typeof message === 'string' ? { title: messageOrTitle, message } : { message: messageOrTitle };
|
|
59
|
+
const modal = await this.openModal<ModalComponent<{ message: string }, boolean>>(
|
|
60
|
+
this.requireComponent(UIComponents.ConfirmModal),
|
|
61
|
+
options,
|
|
62
|
+
);
|
|
63
|
+
const result = await modal.beforeClose;
|
|
64
|
+
|
|
65
|
+
return result ?? false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async loading<T>(operation: Promise<T>): Promise<T>;
|
|
69
|
+
public async loading<T>(message: string, operation: Promise<T>): Promise<T>;
|
|
70
|
+
public async loading<T>(messageOrOperation: string | Promise<T>, operation?: Promise<T>): Promise<T> {
|
|
71
|
+
operation = typeof messageOrOperation === 'string' ? (operation as Promise<T>) : messageOrOperation;
|
|
72
|
+
|
|
73
|
+
const message = typeof messageOrOperation === 'string' ? messageOrOperation : undefined;
|
|
74
|
+
const modal = await this.openModal(this.requireComponent(UIComponents.LoadingModal), { message });
|
|
75
|
+
const result = await operation;
|
|
76
|
+
|
|
77
|
+
await this.closeModal(modal.id);
|
|
78
|
+
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public showSnackbar(message: string, options: ShowSnackbarOptions = {}): void {
|
|
83
|
+
const snackbar: Snackbar = {
|
|
84
|
+
id: uuid(),
|
|
85
|
+
properties: { message, ...options },
|
|
86
|
+
component: options.component ?? markRaw(this.requireComponent(UIComponents.Snackbar)),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
this.setState('snackbars', this.snackbars.concat(snackbar));
|
|
90
|
+
|
|
91
|
+
setTimeout(() => this.hideSnackbar(snackbar.id), 5000);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public hideSnackbar(id: string): void {
|
|
95
|
+
this.setState(
|
|
96
|
+
'snackbars',
|
|
97
|
+
this.snackbars.filter((snackbar) => snackbar.id !== id),
|
|
98
|
+
);
|
|
34
99
|
}
|
|
35
100
|
|
|
36
101
|
public registerComponent(name: UIComponent, component: Component): void {
|
|
@@ -72,15 +137,9 @@ export class UIService extends Service {
|
|
|
72
137
|
}
|
|
73
138
|
|
|
74
139
|
protected async boot(): Promise<void> {
|
|
75
|
-
await super.boot();
|
|
76
|
-
|
|
77
140
|
this.watchModalEvents();
|
|
78
141
|
}
|
|
79
142
|
|
|
80
|
-
private requireComponent(name: UIComponent): Component {
|
|
81
|
-
return this.components[name] ?? fail(`UI Component '${name}' is not defined!`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
143
|
private watchModalEvents(): void {
|
|
85
144
|
Events.on('modal-will-close', ({ modal, result }) => {
|
|
86
145
|
this.modalCallbacks[modal.id]?.willClose?.(result);
|
|
@@ -91,7 +150,10 @@ export class UIService extends Service {
|
|
|
91
150
|
});
|
|
92
151
|
|
|
93
152
|
Events.on('modal-closed', async ({ modal, result }) => {
|
|
94
|
-
this.setState(
|
|
153
|
+
this.setState(
|
|
154
|
+
'modals',
|
|
155
|
+
this.modals.filter((m) => m.id !== modal.id),
|
|
156
|
+
);
|
|
95
157
|
|
|
96
158
|
this.modalCallbacks[modal.id]?.closed?.(result);
|
|
97
159
|
|
package/src/ui/index.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { Component } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { bootServices } from '@/services';
|
|
4
|
-
import {
|
|
4
|
+
import { definePlugin } from '@/plugins';
|
|
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 AGErrorReportModal from '../components/modals/AGErrorReportModal.vue';
|
|
10
|
+
import AGLoadingModal from '../components/modals/AGLoadingModal.vue';
|
|
11
|
+
import AGSnackbar from '../components/snackbars/AGSnackbar.vue';
|
|
8
12
|
import type { UIComponent } from './UI';
|
|
9
13
|
|
|
10
14
|
export { UI, UIComponents, UIComponent };
|
|
@@ -13,25 +17,31 @@ const services = { $ui: UI };
|
|
|
13
17
|
|
|
14
18
|
export type UIServices = typeof services;
|
|
15
19
|
|
|
16
|
-
export default
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export default definePlugin({
|
|
21
|
+
async install(app, options) {
|
|
22
|
+
const defaultComponents = {
|
|
23
|
+
[UIComponents.AlertModal]: AGAlertModal,
|
|
24
|
+
[UIComponents.ConfirmModal]: AGConfirmModal,
|
|
25
|
+
[UIComponents.ErrorReportModal]: AGErrorReportModal,
|
|
26
|
+
[UIComponents.LoadingModal]: AGLoadingModal,
|
|
27
|
+
[UIComponents.Snackbar]: AGSnackbar,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
Object.entries({
|
|
31
|
+
...defaultComponents,
|
|
32
|
+
...options.components,
|
|
33
|
+
}).forEach(([name, component]) => UI.registerComponent(name as UIComponent, component));
|
|
34
|
+
|
|
35
|
+
await bootServices(app, services);
|
|
36
|
+
},
|
|
27
37
|
});
|
|
28
38
|
|
|
29
39
|
declare module '@/bootstrap/options' {
|
|
30
|
-
interface
|
|
40
|
+
interface AerogelOptions {
|
|
31
41
|
components?: Partial<Record<UIComponent, Component>>;
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
44
|
|
|
35
45
|
declare module '@/services' {
|
|
36
|
-
interface Services extends UIServices {}
|
|
46
|
+
export interface Services extends UIServices {}
|
|
37
47
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { objectWithout } from '@noeldemartin/utils';
|
|
2
|
+
import { computed, useAttrs } from 'vue';
|
|
3
|
+
import type { ComputedRef } from 'vue';
|
|
4
|
+
|
|
5
|
+
export function useInputAttrs(): [ComputedRef<{}>, ComputedRef<unknown>] {
|
|
6
|
+
const attrs = useAttrs();
|
|
7
|
+
const className = computed(() => attrs.class);
|
|
8
|
+
const inputAttrs = computed(() => objectWithout(attrs, 'class'));
|
|
9
|
+
|
|
10
|
+
return [inputAttrs, className];
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { noop } from '@noeldemartin/utils';
|
|
2
|
+
import { onMounted, onUnmounted } from 'vue';
|
|
3
|
+
|
|
4
|
+
export function onCleanMounted(operation: () => Function): void {
|
|
5
|
+
let cleanUp: Function = noop;
|
|
6
|
+
|
|
7
|
+
onMounted(() => (cleanUp = operation()));
|
|
8
|
+
onUnmounted(() => cleanUp());
|
|
9
|
+
}
|
package/src/utils/index.ts
CHANGED
package/src/utils/markdown.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { tap } from '@noeldemartin/utils';
|
|
1
2
|
import DOMPurify from 'dompurify';
|
|
2
|
-
import { marked } from 'marked';
|
|
3
|
+
import { Renderer, marked } from 'marked';
|
|
4
|
+
|
|
5
|
+
function makeRenderer(): Renderer {
|
|
6
|
+
return tap(new Renderer(), (renderer) => {
|
|
7
|
+
renderer.link = function(href, title, text) {
|
|
8
|
+
return Renderer.prototype.link.apply(this, [href, title, text]).replace('<a', '<a target="_blank"');
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
3
12
|
|
|
4
13
|
export function renderMarkdown(markdown: string): string {
|
|
5
|
-
return safeHtml(marked(markdown, { mangle: false, headerIds: false }));
|
|
14
|
+
return safeHtml(marked(markdown, { mangle: false, headerIds: false, renderer: makeRenderer() }));
|
|
6
15
|
}
|
|
7
16
|
|
|
8
17
|
export function safeHtml(html: string): string {
|
package/src/utils/vue.ts
CHANGED
|
@@ -10,6 +10,8 @@ type BaseProp<T> = {
|
|
|
10
10
|
type RequiredProp<T> = BaseProp<T> & { required: true };
|
|
11
11
|
type OptionalProp<T> = BaseProp<T> & { default: T | (() => T) | null };
|
|
12
12
|
|
|
13
|
+
export type ComponentProps = Record<string, unknown>;
|
|
14
|
+
|
|
13
15
|
export function arrayProp<T>(defaultValue?: () => T[]): OptionalProp<T[]> {
|
|
14
16
|
return {
|
|
15
17
|
type: Array as PropType<T[]>,
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"
|
|
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
|
+
"types": ["unplugin-icons/types/vue3"],
|
|
13
5
|
"baseUrl": ".",
|
|
14
6
|
"paths": {
|
|
15
7
|
"@/*": ["./src/*"]
|
package/vite.config.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import Aerogel from '@aerogel/vite';
|
|
2
|
+
import Icons from 'unplugin-icons/vite';
|
|
3
3
|
import { defineConfig } from 'vitest/config';
|
|
4
4
|
import { resolve } from 'path';
|
|
5
5
|
|
|
6
|
-
const isTesting = process.env.NODE_ENV === 'test';
|
|
7
|
-
|
|
8
6
|
export default defineConfig({
|
|
9
7
|
test: { clearMocks: true },
|
|
10
|
-
plugins: [
|
|
8
|
+
plugins: [Aerogel(), Icons()],
|
|
11
9
|
resolve: {
|
|
12
10
|
alias: {
|
|
13
11
|
'@': resolve(__dirname, './src'),
|
|
14
12
|
},
|
|
15
13
|
},
|
|
16
|
-
define: isTesting ? { __AG_BASE_PATH: 'undefined' } : undefined,
|
|
17
14
|
});
|
package/src/bootstrap/hooks.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
2
|
-
|
|
3
|
-
import type { BootstrapOptions } from '@/bootstrap/options';
|
|
4
|
-
|
|
5
|
-
const mountedHooks: Function[] = [];
|
|
6
|
-
|
|
7
|
-
export type BootstrapHook = (app: App, options: BootstrapOptions) => Promise<void>;
|
|
8
|
-
|
|
9
|
-
export function onAppMounted(hook: Function): void {
|
|
10
|
-
mountedHooks.push(hook);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function runAppMountedHooks(): void {
|
|
14
|
-
mountedHooks.forEach((hook) => hook());
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function defineBootstrapHook<T extends BootstrapHook>(hook: T): T {
|
|
18
|
-
return hook;
|
|
19
|
-
}
|
package/src/lang/helpers.ts
DELETED
package/src/models/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IndexedDBEngine, bootModelsFromViteGlob, setEngine } from 'soukai';
|
|
2
|
-
|
|
3
|
-
import { defineBootstrapHook } from '@/bootstrap/hooks';
|
|
4
|
-
|
|
5
|
-
export default defineBootstrapHook(async (_, options) => {
|
|
6
|
-
if (!options.models) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
setEngine(new IndexedDBEngine());
|
|
11
|
-
bootModelsFromViteGlob(options.models);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
declare module '@/bootstrap/options' {
|
|
15
|
-
interface BootstrapOptions {
|
|
16
|
-
models?: Record<string, Record<string, unknown>>;
|
|
17
|
-
}
|
|
18
|
-
}
|
package/src/routing/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createRouter, createWebHistory } from 'vue-router';
|
|
2
|
-
import type { Plugin } from 'vue';
|
|
3
|
-
|
|
4
|
-
import { defineBootstrapHook } from '@/bootstrap/hooks';
|
|
5
|
-
|
|
6
|
-
function createAppRouter(options: { routes: RouteRecordRaw[]; basePath?: string }): Plugin {
|
|
7
|
-
return createRouter({
|
|
8
|
-
history: createWebHistory(options.basePath),
|
|
9
|
-
routes: options.routes,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default defineBootstrapHook(async (app, options) => {
|
|
14
|
-
if (!options.routes) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const plugin = createAppRouter({
|
|
19
|
-
routes: options.routes,
|
|
20
|
-
basePath: options.basePath ?? __AG_BASE_PATH,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
app.use(plugin);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
declare module '@/bootstrap/options' {
|
|
27
|
-
interface BootstrapOptions {
|
|
28
|
-
routes?: RouteRecordRaw[];
|
|
29
|
-
basePath?: string;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
import type { RouteRecordRaw } from 'vue-router';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
foo: Bar
|