@aerogel/core 0.0.0-next.59bf5f7cc06e728d0cf6c00de28f1da48d7d6b8e → 0.0.0-next.7f6ed5a1f91688a86bf5ede2adc465e4fd6cfdea

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 (61) hide show
  1. package/dist/aerogel-core.cjs.js +1 -1
  2. package/dist/aerogel-core.d.ts +68 -414
  3. package/dist/aerogel-core.esm.js +1 -1
  4. package/package.json +8 -6
  5. package/src/bootstrap/bootstrap.test.ts +56 -0
  6. package/src/bootstrap/hooks.ts +19 -0
  7. package/src/bootstrap/index.ts +25 -9
  8. package/src/bootstrap/options.ts +1 -5
  9. package/src/components/basic/AGMarkdown.vue +5 -20
  10. package/src/components/forms/AGButton.vue +3 -26
  11. package/src/components/forms/AGInput.vue +4 -8
  12. package/src/components/forms/index.ts +1 -2
  13. package/src/components/headless/forms/AGHeadlessInput.ts +2 -2
  14. package/src/components/headless/forms/AGHeadlessInput.vue +5 -5
  15. package/src/components/headless/forms/AGHeadlessInputError.vue +5 -9
  16. package/src/components/headless/forms/AGHeadlessInputInput.vue +4 -20
  17. package/src/components/headless/forms/index.ts +4 -6
  18. package/src/components/headless/modals/AGHeadlessModal.vue +1 -5
  19. package/src/components/headless/modals/AGHeadlessModalPanel.vue +2 -10
  20. package/src/components/index.ts +1 -2
  21. package/src/components/modals/AGAlertModal.vue +2 -13
  22. package/src/components/modals/AGModal.ts +0 -4
  23. package/src/components/modals/AGModal.vue +2 -20
  24. package/src/components/modals/index.ts +1 -4
  25. package/src/directives/index.ts +3 -5
  26. package/src/forms/Form.test.ts +0 -21
  27. package/src/forms/Form.ts +16 -38
  28. package/src/forms/utils.ts +0 -17
  29. package/src/lang/Lang.ts +8 -47
  30. package/src/lang/helpers.ts +5 -0
  31. package/src/lang/index.ts +76 -17
  32. package/src/main.ts +0 -4
  33. package/src/models/index.ts +18 -0
  34. package/src/routing/index.ts +33 -0
  35. package/src/services/Service.ts +28 -151
  36. package/src/services/index.ts +7 -29
  37. package/src/testing/stubs/lang/en.yaml +1 -0
  38. package/src/testing/stubs/models/User.ts +3 -0
  39. package/src/types/vite.d.ts +2 -0
  40. package/src/ui/UI.state.ts +6 -3
  41. package/src/ui/UI.ts +2 -35
  42. package/src/ui/index.ts +13 -19
  43. package/src/utils/index.ts +0 -3
  44. package/tsconfig.json +10 -1
  45. package/vite.config.ts +6 -2
  46. package/src/components/forms/AGCheckbox.vue +0 -35
  47. package/src/components/headless/forms/AGHeadlessInputLabel.vue +0 -16
  48. package/src/components/modals/AGConfirmModal.vue +0 -30
  49. package/src/components/modals/AGLoadingModal.vue +0 -19
  50. package/src/errors/Errors.state.ts +0 -31
  51. package/src/errors/Errors.ts +0 -132
  52. package/src/errors/index.ts +0 -21
  53. package/src/globals.ts +0 -6
  54. package/src/lang/utils.ts +0 -4
  55. package/src/plugins/Plugin.ts +0 -7
  56. package/src/plugins/index.ts +0 -7
  57. package/src/services/App.state.ts +0 -13
  58. package/src/services/App.ts +0 -17
  59. package/src/services/store.ts +0 -27
  60. package/src/utils/composition/forms.ts +0 -11
  61. package/src/utils/composition/hooks.ts +0 -9
@@ -1,132 +0,0 @@
1
- import { JSError, facade, isObject } from '@noeldemartin/utils';
2
-
3
- import App from '@/services/App';
4
- import ServiceBootError from '@/errors/ServiceBootError';
5
- import UI from '@/ui/UI';
6
- import { translate } from '@/lang/utils';
7
-
8
- import Service from './Errors.state';
9
- import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
10
-
11
- export class ErrorsService extends Service {
12
-
13
- public forceReporting: boolean = false;
14
- private enabled: boolean = true;
15
-
16
- public enable(): void {
17
- this.enabled = true;
18
- }
19
-
20
- public disable(): void {
21
- this.enabled = false;
22
- }
23
-
24
- public async inspect(error: ErrorSource | ErrorReport[]): Promise<void> {
25
- const reports = Array.isArray(error) ? error : [await this.createErrorReport(error)];
26
-
27
- // TODO open errors modal
28
- reports;
29
- }
30
-
31
- public async report(error: ErrorSource, message?: string): Promise<void> {
32
- if (App.isDevelopment || App.isTesting) {
33
- this.logError(error);
34
- }
35
-
36
- if (!this.enabled) {
37
- throw error;
38
- }
39
-
40
- if (!App.isMounted) {
41
- const startupError = await this.createStartupErrorReport(error);
42
-
43
- if (startupError) {
44
- this.setState({ startupErrors: this.startupErrors.concat(startupError) });
45
- }
46
-
47
- return;
48
- }
49
-
50
- const report = await this.createErrorReport(error);
51
- const log: ErrorReportLog = {
52
- report,
53
- seen: false,
54
- date: new Date(),
55
- };
56
-
57
- // TODO open error snackbar
58
- UI.alert(message ?? 'Something went wrong, but it\'s not your fault! (look at the console for details)');
59
-
60
- this.setState({ logs: [log].concat(this.logs) });
61
- }
62
-
63
- public see(report: ErrorReport): void {
64
- this.setState({
65
- logs: this.logs.map((log) => {
66
- if (log.report !== report) {
67
- return log;
68
- }
69
-
70
- return {
71
- ...log,
72
- seen: true,
73
- };
74
- }),
75
- });
76
- }
77
-
78
- public seeAll(): void {
79
- this.setState({
80
- logs: this.logs.map((log) => ({
81
- ...log,
82
- seen: true,
83
- })),
84
- });
85
- }
86
-
87
- private logError(error: unknown): void {
88
- // eslint-disable-next-line no-console
89
- console.error(error);
90
-
91
- if (isObject(error) && error.cause) {
92
- this.logError(error.cause);
93
- }
94
- }
95
-
96
- private async createErrorReport(error: ErrorSource): Promise<ErrorReport> {
97
- if (typeof error === 'string') {
98
- return { title: error };
99
- }
100
-
101
- if (error instanceof Error || error instanceof JSError) {
102
- return this.createErrorReportFromError(error);
103
- }
104
-
105
- return {
106
- title: translate('errors.unknown'),
107
- error,
108
- };
109
- }
110
-
111
- private async createStartupErrorReport(error: ErrorSource): Promise<ErrorReport | null> {
112
- if (error instanceof ServiceBootError) {
113
- // Ignore second-order boot errors in order to have a cleaner startup crash screen.
114
- return error.cause instanceof ServiceBootError ? null : this.createErrorReport(error.cause);
115
- }
116
-
117
- return this.createErrorReport(error);
118
- }
119
-
120
- private createErrorReportFromError(error: Error | JSError, defaults: Partial<ErrorReport> = {}): ErrorReport {
121
- return {
122
- title: error.name,
123
- description: error.message,
124
- details: error.stack,
125
- error,
126
- ...defaults,
127
- };
128
- }
129
-
130
- }
131
-
132
- export default facade(new ErrorsService());
@@ -1,21 +0,0 @@
1
- import { bootServices } from '@/services';
2
- import { definePlugin } from '@/plugins';
3
-
4
- import Errors from './Errors';
5
- import { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
6
-
7
- export { Errors, ErrorSource, ErrorReport, ErrorReportLog };
8
-
9
- const services = { $errors: Errors };
10
-
11
- export type ErrorsServices = typeof services;
12
-
13
- export default definePlugin({
14
- async install(app) {
15
- await bootServices(app, services);
16
- },
17
- });
18
-
19
- declare module '@/services' {
20
- interface Services extends ErrorsServices {}
21
- }
package/src/globals.ts DELETED
@@ -1,6 +0,0 @@
1
- export {};
2
-
3
- declare global {
4
- export const __AG_BASE_PATH: string | undefined;
5
- export const __AG_ENV: 'production' | 'development' | 'testing';
6
- }
package/src/lang/utils.ts DELETED
@@ -1,4 +0,0 @@
1
- import Lang from './Lang';
2
-
3
- export const translate = Lang.translate.bind(Lang);
4
- export const translateWithDefault = Lang.translateWithDefault.bind(Lang);
@@ -1,7 +0,0 @@
1
- import type { App } from 'vue';
2
-
3
- import type { AerogelOptions } from '@/bootstrap/options';
4
-
5
- export interface Plugin {
6
- install(app: App, options: AerogelOptions): void | Promise<void>;
7
- }
@@ -1,7 +0,0 @@
1
- import type { Plugin } from './Plugin';
2
-
3
- export * from './Plugin';
4
-
5
- export function definePlugin<T extends Plugin>(plugin: T): T {
6
- return plugin;
7
- }
@@ -1,13 +0,0 @@
1
- import { defineServiceState } from '@/services/Service';
2
-
3
- export default defineServiceState({
4
- name: 'app',
5
- initialState: {
6
- environment: __AG_ENV,
7
- isMounted: false,
8
- },
9
- computed: {
10
- isDevelopment: (state) => state.environment === 'development',
11
- isTesting: (state) => state.environment === 'testing',
12
- },
13
- });
@@ -1,17 +0,0 @@
1
- import { facade } from '@noeldemartin/utils';
2
-
3
- import Events from '@/services/Events';
4
-
5
- import Service from './App.state';
6
-
7
- export class AppService extends Service {
8
-
9
- protected async boot(): Promise<void> {
10
- await super.boot();
11
-
12
- Events.once('application-mounted', () => this.setState({ isMounted: true }));
13
- }
14
-
15
- }
16
-
17
- export default facade(new AppService());
@@ -1,27 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,9 +0,0 @@
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
- }