@platforma-sdk/ui-vue 1.3.5

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 (91) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +56 -0
  3. package/.prettierrc +6 -0
  4. package/CHANGELOG.md +9 -0
  5. package/README.md +5 -0
  6. package/dist/lib.js +50299 -0
  7. package/dist/lib.umd.cjs +248 -0
  8. package/dist/src/components/BlockLayout.vue.d.ts +5 -0
  9. package/dist/src/components/BlockLayout.vue.d.ts.map +1 -0
  10. package/dist/src/components/LoaderPage.vue.d.ts +3 -0
  11. package/dist/src/components/LoaderPage.vue.d.ts.map +1 -0
  12. package/dist/src/components/NotFound.vue.d.ts +3 -0
  13. package/dist/src/components/NotFound.vue.d.ts.map +1 -0
  14. package/dist/src/components/PlAgDataTable/OverlayLoading.vue.d.ts +11 -0
  15. package/dist/src/components/PlAgDataTable/OverlayLoading.vue.d.ts.map +1 -0
  16. package/dist/src/components/PlAgDataTable/OverlayNoRows.vue.d.ts +3 -0
  17. package/dist/src/components/PlAgDataTable/OverlayNoRows.vue.d.ts.map +1 -0
  18. package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts +16 -0
  19. package/dist/src/components/PlAgDataTable/PlAgDataTable.vue.d.ts.map +1 -0
  20. package/dist/src/components/PlAgDataTable/index.d.ts +3 -0
  21. package/dist/src/components/PlAgDataTable/index.d.ts.map +1 -0
  22. package/dist/src/components/PlAgDataTable/sources/file-source.d.ts +7 -0
  23. package/dist/src/components/PlAgDataTable/sources/file-source.d.ts.map +1 -0
  24. package/dist/src/components/PlAgDataTable/sources/table-source.d.ts +15 -0
  25. package/dist/src/components/PlAgDataTable/sources/table-source.d.ts.map +1 -0
  26. package/dist/src/components/PlAgDataTable/types.d.ts +35 -0
  27. package/dist/src/components/PlAgDataTable/types.d.ts.map +1 -0
  28. package/dist/src/components/ValueOrErrorsComponent.vue.d.ts +27 -0
  29. package/dist/src/components/ValueOrErrorsComponent.vue.d.ts.map +1 -0
  30. package/dist/src/composition/useWatchResult.d.ts +7 -0
  31. package/dist/src/composition/useWatchResult.d.ts.map +1 -0
  32. package/dist/src/computedResult.d.ts +35 -0
  33. package/dist/src/computedResult.d.ts.map +1 -0
  34. package/dist/src/createApp.d.ts +27 -0
  35. package/dist/src/createApp.d.ts.map +1 -0
  36. package/dist/src/createModel.d.ts +3 -0
  37. package/dist/src/createModel.d.ts.map +1 -0
  38. package/dist/src/defineApp.d.ts +14 -0
  39. package/dist/src/defineApp.d.ts.map +1 -0
  40. package/dist/src/defineStore.d.ts +2 -0
  41. package/dist/src/defineStore.d.ts.map +1 -0
  42. package/dist/src/lib.d.ts +16 -0
  43. package/dist/src/lib.d.ts.map +1 -0
  44. package/dist/src/types.d.ts +73 -0
  45. package/dist/src/types.d.ts.map +1 -0
  46. package/dist/src/types.static-test.d.ts +7 -0
  47. package/dist/src/types.static-test.d.ts.map +1 -0
  48. package/dist/src/urls.d.ts +4 -0
  49. package/dist/src/urls.d.ts.map +1 -0
  50. package/dist/src/utils.d.ts +20 -0
  51. package/dist/src/utils.d.ts.map +1 -0
  52. package/dist/style.css +1 -0
  53. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  54. package/index.html +13 -0
  55. package/package.json +64 -0
  56. package/src/assets/base.scss +9 -0
  57. package/src/assets/block.scss +71 -0
  58. package/src/assets/file-dialog.scss +181 -0
  59. package/src/assets/icons/empty-cat.svg +21 -0
  60. package/src/assets/icons/no-data-cat.svg +40 -0
  61. package/src/assets/ui.scss +9 -0
  62. package/src/components/BlockLayout.vue +40 -0
  63. package/src/components/LoaderPage.vue +7 -0
  64. package/src/components/NotFound.vue +21 -0
  65. package/src/components/PlAgDataTable/OverlayLoading.vue +47 -0
  66. package/src/components/PlAgDataTable/OverlayNoRows.vue +29 -0
  67. package/src/components/PlAgDataTable/PlAgDataTable.vue +293 -0
  68. package/src/components/PlAgDataTable/ag-theme.css +403 -0
  69. package/src/components/PlAgDataTable/assets/cat-in-bag.png +0 -0
  70. package/src/components/PlAgDataTable/assets/sad-cat.png +0 -0
  71. package/src/components/PlAgDataTable/index.ts +3 -0
  72. package/src/components/PlAgDataTable/sources/file-source.ts +25 -0
  73. package/src/components/PlAgDataTable/sources/table-source.ts +235 -0
  74. package/src/components/PlAgDataTable/types.ts +38 -0
  75. package/src/components/ValueOrErrorsComponent.vue +28 -0
  76. package/src/composition/useWatchResult.ts +42 -0
  77. package/src/computedResult.ts +47 -0
  78. package/src/createApp.ts +213 -0
  79. package/src/createModel.ts +108 -0
  80. package/src/defineApp.ts +78 -0
  81. package/src/defineStore.ts +32 -0
  82. package/src/lib.ts +26 -0
  83. package/src/types.static-test.ts +80 -0
  84. package/src/types.ts +106 -0
  85. package/src/urls.ts +14 -0
  86. package/src/utils.ts +75 -0
  87. package/src/vite-env.d.ts +8 -0
  88. package/tsconfig.json +11 -0
  89. package/tsconfig.lib.json +27 -0
  90. package/tsconfig.node.json +13 -0
  91. package/vite.config.ts +26 -0
@@ -0,0 +1,108 @@
1
+ import { reactive, computed, ref, watch, unref } from 'vue';
2
+ import type { ZodError } from 'zod';
3
+ import type { ModelOptions, Model } from './types';
4
+ import { deepEqual, deepClone } from '@milaboratories/helpers';
5
+
6
+ const identity = <T, V = T>(v: T): V => v as unknown as V;
7
+
8
+ const ensureError = (cause: unknown) => {
9
+ if (cause instanceof Error) {
10
+ return cause;
11
+ }
12
+
13
+ return Error(String(cause));
14
+ };
15
+
16
+ const isZodError = (err: Error): err is ZodError => {
17
+ return err.name === 'ZodError';
18
+ };
19
+
20
+ const formatZodError = (err: ZodError) => {
21
+ const { formErrors, fieldErrors } = err.flatten();
22
+ const _fieldErrors = Object.entries(fieldErrors).map(([field, errors]) => {
23
+ return field + ':' + errors?.join(',');
24
+ });
25
+ return formErrors.concat(_fieldErrors).join('; ');
26
+ };
27
+
28
+ export function createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<M> {
29
+ const validate = options.validate ?? identity;
30
+
31
+ const { autoSave } = options;
32
+
33
+ const error = ref<Error | undefined>();
34
+
35
+ const local = ref<M>();
36
+
37
+ watch(
38
+ () => options.get(),
39
+ (v) => {
40
+ local.value = deepClone(v);
41
+ },
42
+ { immediate: true },
43
+ );
44
+
45
+ const save = () => {
46
+ options.onSave(validate(deepClone(local.value)));
47
+ };
48
+
49
+ const revert = () => {
50
+ local.value = deepClone(options.get());
51
+ error.value = undefined;
52
+ };
53
+
54
+ const setValue = (v: M) => {
55
+ error.value = undefined;
56
+ try {
57
+ validate(v);
58
+ if (autoSave) {
59
+ save();
60
+ }
61
+ } catch (cause: unknown) {
62
+ const err = ensureError(cause);
63
+ if (isZodError(err)) {
64
+ error.value = Error(formatZodError(err)); // @todo temp
65
+ } else {
66
+ error.value = err as Error; // @todo ensureError
67
+ }
68
+ }
69
+ };
70
+
71
+ const model = computed<M>({
72
+ get: () => {
73
+ return local.value as M;
74
+ },
75
+ set(v) {
76
+ local.value = v;
77
+ setValue(v);
78
+ },
79
+ });
80
+
81
+ watch(
82
+ local,
83
+ (v) => {
84
+ if (!deepEqual(options.get(), v)) {
85
+ setValue(v as M);
86
+ }
87
+ },
88
+ { deep: true },
89
+ );
90
+
91
+ const valid = computed(() => !error.value);
92
+
93
+ const isChanged = computed(() => {
94
+ return !deepEqual(options.get(), unref(local));
95
+ });
96
+
97
+ const errorString = computed(() => (error.value ? error.value.message : ''));
98
+
99
+ return reactive({
100
+ model: model,
101
+ valid,
102
+ isChanged,
103
+ error,
104
+ errorString,
105
+ save,
106
+ revert,
107
+ });
108
+ }
@@ -0,0 +1,78 @@
1
+ import { notEmpty } from '@milaboratories/helpers';
2
+ import { type BlockOutputsBase, type Platforma } from '@platforma-sdk/model';
3
+ import type { Component, Reactive } from 'vue';
4
+ import { inject, markRaw, reactive } from 'vue';
5
+ import { createApp, type BaseApp } from './createApp';
6
+ import type { LocalState, Routes } from './types';
7
+
8
+ const pluginKey = Symbol('sdk-vue');
9
+
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ export function useSdkPlugin(): SdkPlugin {
12
+ return inject(pluginKey)!;
13
+ }
14
+
15
+ export function defineApp<
16
+ Args = unknown,
17
+ Outputs extends BlockOutputsBase = BlockOutputsBase,
18
+ UiState = unknown,
19
+ Href extends `/${string}` = `/${string}`,
20
+ Local extends LocalState<Href> = LocalState<Href>,
21
+ >(platforma: Platforma<Args, Outputs, UiState, Href>, extendApp: (app: BaseApp<Args, Outputs, UiState, Href>) => Local) {
22
+ let app: undefined | App<Args, Outputs, UiState, Href, Local> = undefined;
23
+
24
+ const loadApp = () => {
25
+ platforma
26
+ .loadBlockState()
27
+ .then((state) => {
28
+ plugin.loaded = true;
29
+ const baseApp = createApp<Args, Outputs, UiState, Href>(state, platforma);
30
+
31
+ const localState = extendApp(baseApp);
32
+
33
+ app = Object.assign(baseApp, {
34
+ ...localState,
35
+ routes: Object.fromEntries(
36
+ Object.entries(localState.routes as Routes<Href>).map(([href, component]) => {
37
+ return [href, markRaw(component as Component)];
38
+ }),
39
+ ),
40
+ } as unknown as App<Args, Outputs, UiState, Href, Local>);
41
+ })
42
+ .catch((err) => {
43
+ plugin.error = err;
44
+ });
45
+ };
46
+
47
+ const plugin = reactive({
48
+ loaded: false,
49
+ error: undefined as unknown,
50
+ // Href to get typed query parameters for a specific route
51
+ useApp<PageHref extends Href = Href>() {
52
+ return notEmpty(app, 'App is not loaded') as App<Args, Outputs, UiState, PageHref, Local>;
53
+ },
54
+ // @todo type portability issue with Vue
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ install(app: any) {
57
+ app.provide(pluginKey, this);
58
+ loadApp();
59
+ },
60
+ });
61
+
62
+ return plugin;
63
+ }
64
+
65
+ export type App<
66
+ Args = unknown,
67
+ Outputs extends BlockOutputsBase = BlockOutputsBase,
68
+ UiState = unknown,
69
+ Href extends `/${string}` = `/${string}`,
70
+ Local extends LocalState<Href> = LocalState<Href>,
71
+ > = BaseApp<Args, Outputs, UiState, Href> & Reactive<Local>;
72
+
73
+ export type SdkPlugin<
74
+ Args = unknown,
75
+ Outputs extends BlockOutputsBase = BlockOutputsBase,
76
+ UiState = unknown,
77
+ Href extends `/${string}` = `/${string}`,
78
+ > = ReturnType<typeof defineApp<Args, Outputs, UiState, Href>>;
@@ -0,0 +1,32 @@
1
+ import { reactive, onScopeDispose, getCurrentScope, effectScope } from 'vue';
2
+
3
+ const shelf = new Map<symbol, unknown>();
4
+
5
+ function initStore<S extends object>(key: symbol, cb: () => S) {
6
+ const scope = getCurrentScope() ?? effectScope();
7
+
8
+ const store = scope.run(() => {
9
+ onScopeDispose(() => {
10
+ shelf.delete(key);
11
+ });
12
+
13
+ return reactive(cb());
14
+ }) as S;
15
+
16
+ (store as Disposable)[Symbol.dispose] = () => {
17
+ scope.stop();
18
+ };
19
+
20
+ return store;
21
+ }
22
+
23
+ export function defineStore<S extends object>(cb: () => S) {
24
+ const key = Symbol();
25
+
26
+ return () => {
27
+ if (!shelf.has(key)) {
28
+ shelf.set(key, initStore(key, cb));
29
+ }
30
+ return shelf.get(key) as S & Disposable;
31
+ };
32
+ }
package/src/lib.ts ADDED
@@ -0,0 +1,26 @@
1
+ import './assets/ui.scss';
2
+ import BlockLayout from './components/BlockLayout.vue';
3
+ import PlAgDataTable from './components/PlAgDataTable/PlAgDataTable.vue';
4
+ import ValueOrErrorsComponent from './components/ValueOrErrorsComponent.vue';
5
+
6
+ export { BlockLayout, PlAgDataTable, ValueOrErrorsComponent };
7
+
8
+ export * from './components/PlAgDataTable/types';
9
+
10
+ export * from './defineApp';
11
+
12
+ export * from './createModel';
13
+
14
+ export * from './types';
15
+
16
+ export * from './defineStore';
17
+
18
+ export * from './utils';
19
+
20
+ export * from './computedResult';
21
+
22
+ export * from './composition/useWatchResult';
23
+
24
+ export * from '@milaboratories/uikit';
25
+
26
+ export type * from '@milaboratories/uikit';
@@ -0,0 +1,80 @@
1
+ import type { Expect, Equal } from '@milaboratories/helpers';
2
+ import { z } from 'zod';
3
+ import type { ModelOptions, Model } from './types';
4
+ import type { BlockOutputsBase, InferHrefType, InferOutputsType, Platforma } from '@platforma-sdk/model';
5
+ import type { BaseApp, createApp } from './createApp';
6
+ import type { App } from './defineApp';
7
+ import { computed, type Component } from 'vue';
8
+
9
+ declare function __createModel<M, V = unknown>(options: ModelOptions<M, V>): Model<M>;
10
+
11
+ declare const __args: {
12
+ seed: number;
13
+ };
14
+
15
+ const validate = z.coerce.number().int().parse;
16
+
17
+ type _number = ReturnType<typeof validate>;
18
+
19
+ const __model1 = __createModel({
20
+ get() {
21
+ return String(__args.seed);
22
+ },
23
+ validate,
24
+ autoSave: true,
25
+ onSave(seed) {
26
+ console.log('save', seed);
27
+ },
28
+ });
29
+
30
+ const __model2 = __createModel({
31
+ get() {
32
+ return __args.seed;
33
+ },
34
+ validate,
35
+ autoSave: true,
36
+ onSave(seed) {
37
+ console.log('save', seed);
38
+ },
39
+ });
40
+
41
+ type InferArgs<Pl extends Platforma> = Pl extends Platforma<infer Args> ? Args : never;
42
+ type InferUiState<Pl extends Platforma> = Pl extends Platforma<unknown, BlockOutputsBase, infer UiState> ? UiState : never;
43
+
44
+ export type TestApp<P extends Platforma> = ReturnType<typeof createApp<InferArgs<P>, InferOutputsType<P>, InferUiState<P>, InferHrefType<P>>>;
45
+
46
+ type _App1 = BaseApp<1, BlockOutputsBase, unknown, '/'>;
47
+ type _App2 = TestApp<Platforma<1, BlockOutputsBase, unknown, '/'>>;
48
+
49
+ const local = () => {
50
+ const counter = computed(() => 1);
51
+ const label = computed(() => 'aaaa');
52
+
53
+ const method = () => 100;
54
+
55
+ return {
56
+ counter,
57
+ label,
58
+ method,
59
+ routes: {
60
+ '/': undefined as unknown as Component,
61
+ },
62
+ };
63
+ };
64
+
65
+ type ExtApp = App<1, BlockOutputsBase, unknown, '/', ReturnType<typeof local>>;
66
+
67
+ declare const app: ExtApp;
68
+
69
+ app.counter;
70
+
71
+ type __cases = [
72
+ Expect<Equal<Model<string>, typeof __model1>>,
73
+ Expect<Equal<Model<number>, typeof __model2>>,
74
+ Expect<Equal<Model<string>, typeof __model1>>,
75
+ Expect<Equal<Model<number>, typeof __model2>>,
76
+ Expect<Equal<_App1, _App2>>,
77
+ Expect<Equal<ExtApp['counter'], number>>,
78
+ Expect<Equal<ExtApp['label'], string>>,
79
+ Expect<Equal<ExtApp['method'], () => number>>,
80
+ ];
package/src/types.ts ADDED
@@ -0,0 +1,106 @@
1
+ import type { Equal, Expect } from '@milaboratories/helpers';
2
+ import type { BlockOutputsBase, ValueOrErrors } from '@platforma-sdk/model';
3
+ import type { Component, ComputedGetter } from 'vue';
4
+
5
+ export type UnwrapValueOrErrors<R extends ValueOrErrors<unknown>> = Extract<R, { ok: true }>['value'];
6
+ export interface StateModelOptions<A, T = A> {
7
+ transform?: (v: A) => T;
8
+ validate?: (v: unknown) => A;
9
+ }
10
+
11
+ export interface ModelOptions<M, V = M> extends ReadableComputed<M> {
12
+ get(): M;
13
+ validate?(v: unknown): V;
14
+ onSave(v: V): void;
15
+ autoSave?: boolean;
16
+ // @todo debounce?: number
17
+ }
18
+
19
+ export type Model<T> = {
20
+ model: T;
21
+ valid: boolean;
22
+ isChanged: boolean;
23
+ error: Error | undefined;
24
+ errorString: string | undefined;
25
+ save: () => void;
26
+ revert: () => void;
27
+ };
28
+
29
+ interface ReadableComputed<T> {
30
+ get: ComputedGetter<T>;
31
+ }
32
+
33
+ export type StripLastSlash<S extends string> = S extends `${infer Stripped}/` ? Stripped : S;
34
+
35
+ export type ParsePathnamePart<S extends string> = S extends `${infer Path}?${string}` ? StripLastSlash<Path> : S;
36
+
37
+ export type ParseQueryPart<S extends string> = S extends `${string}?${infer Query}` ? Query : '';
38
+
39
+ export type QueryChunks<S extends string> = S extends `${infer Chunk}&${infer Rest}` ? Chunk | QueryChunks<Rest> : S;
40
+
41
+ export type SplitChunks<S extends string> = S extends `${infer Key}=${infer Value}` ? [Key, Value] : never;
42
+
43
+ export type ParseQuery<QueryString extends string> = { [T in SplitChunks<QueryChunks<ParseQueryPart<QueryString>>> as T[0]]: T[1] };
44
+
45
+ export type Routes<Href extends `/${string}` = `/${string}`> = {
46
+ [P in Href as ParsePathnamePart<P>]: Component;
47
+ };
48
+
49
+ export type RouteParams<Href extends `/${string}` = `/${string}`> = {
50
+ [P in Href as ParsePathnamePart<P>]: ParseQuery<P>;
51
+ };
52
+
53
+ export type LocalState<Href extends `/${string}` = `/${string}`> = {
54
+ routes: Routes<Href>;
55
+ };
56
+
57
+ // Results (ValueOrErrors)
58
+
59
+ export type UnwrapValueOrError<W> = W extends {
60
+ ok: true;
61
+ value: infer V;
62
+ }
63
+ ? V
64
+ : never;
65
+
66
+ export type UnwrapOutputs<Outputs extends BlockOutputsBase, K extends keyof Outputs = keyof Outputs> = {
67
+ [P in K]: UnwrapValueOrError<Outputs[P]>;
68
+ };
69
+
70
+ // Draft
71
+ export type ModelResult<T, E = unknown> =
72
+ | {
73
+ ok: true;
74
+ model: T;
75
+ }
76
+ | {
77
+ ok: false;
78
+ error: E;
79
+ };
80
+
81
+ export type OptionalResult<T> =
82
+ | {
83
+ errors?: undefined;
84
+ value?: T; // I make this optional (wip)
85
+ }
86
+ | {
87
+ value?: undefined;
88
+ errors: string[];
89
+ };
90
+
91
+ export type OutputValues<Outputs extends BlockOutputsBase> = {
92
+ [P in keyof Outputs]?: UnwrapValueOrError<Outputs[P]>;
93
+ };
94
+
95
+ export type OutputErrors<Outputs extends BlockOutputsBase> = {
96
+ [P in keyof Outputs]?: Error;
97
+ };
98
+
99
+ // declare global {
100
+ // const platforma: Platforma | undefined;
101
+ // interface Window {
102
+ // platforma: Platforma | undefined;
103
+ // }
104
+ // }
105
+
106
+ type _cases = [Expect<Equal<number, UnwrapValueOrError<ValueOrErrors<number>>>>];
package/src/urls.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { ParseQuery } from './types';
2
+
3
+ export const parsePathname = (href: `/${string}`) => {
4
+ try {
5
+ return new URL(href, 'http://dummy').pathname as `/${string}`;
6
+ } catch (err) {
7
+ console.error('Invalid href', href);
8
+ return undefined;
9
+ }
10
+ };
11
+
12
+ export const parseQuery = <Href extends `/${string}`>(href: Href) => {
13
+ return Object.fromEntries(new URL(href, 'http://dummy').searchParams) as ParseQuery<Href>;
14
+ };
package/src/utils.ts ADDED
@@ -0,0 +1,75 @@
1
+ import type { ValueOrErrors } from '@platforma-sdk/model';
2
+ import type { OptionalResult } from './types';
3
+
4
+ export class UnresolvedError extends Error {}
5
+
6
+ export class MultiError extends Error {
7
+ constructor(public readonly errors: string[]) {
8
+ super();
9
+ }
10
+
11
+ // @todo
12
+ toString() {
13
+ return this.errors.join(',');
14
+ }
15
+ }
16
+
17
+ export function wrapValueOrErrors<V>(value: V): ValueOrErrors<V> {
18
+ return {
19
+ ok: true,
20
+ value,
21
+ };
22
+ }
23
+
24
+ export function unwrapValueOrErrors<V>(valueOrErrors?: ValueOrErrors<V>): V {
25
+ if (!valueOrErrors) {
26
+ throw new UnresolvedError();
27
+ }
28
+
29
+ if (!valueOrErrors.ok) {
30
+ throw Error(valueOrErrors.errors.join(';'));
31
+ }
32
+
33
+ return valueOrErrors.value;
34
+ }
35
+
36
+ // Optional Result
37
+
38
+ export function wrapOptionalResult<V>(value: V): OptionalResult<V> {
39
+ return {
40
+ value,
41
+ errors: undefined,
42
+ };
43
+ }
44
+
45
+ export function unwrapOptionalResult<V>(result: OptionalResult<V>): V {
46
+ if (result.errors) {
47
+ throw new MultiError(result.errors);
48
+ }
49
+
50
+ if (!result.value) {
51
+ throw new UnresolvedError();
52
+ }
53
+
54
+ return result.value;
55
+ }
56
+
57
+ export function isDefined<T>(v: T | undefined): v is T {
58
+ return v !== undefined;
59
+ }
60
+
61
+ export function getFilePathBreadcrumbs(filePath: string) {
62
+ const chunks = filePath.split('/');
63
+
64
+ const stack: { index: number; path: string; name: string }[] = [];
65
+
66
+ for (let i = 0; i < chunks.length; i++) {
67
+ stack.push({
68
+ index: i,
69
+ name: i === 0 ? 'Root' : chunks[i],
70
+ path: chunks.slice(0, i + 1).join('/'),
71
+ });
72
+ }
73
+
74
+ return stack;
75
+ }
@@ -0,0 +1,8 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ // declare module '*.vue' {
4
+ // import type { DefineComponent } from 'vue';
5
+ // // eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
6
+ // const component: DefineComponent<{}, {}, any>;
7
+ // export default component;
8
+ // }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.lib.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.node.json"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "target": "ES2021",
5
+ "useDefineForClassFields": true,
6
+ "module": "ESNext",
7
+ "lib": ["ES2021", "DOM", "DOM.Iterable"],
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "Bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "resolveJsonModule": true,
14
+ "isolatedModules": true,
15
+ "moduleDetection": "force",
16
+ "emitDeclarationOnly": true,
17
+ "declarationMap": true,
18
+
19
+ /* Linting */
20
+ "strict": true,
21
+ "noUnusedLocals": false,
22
+ "noUnusedParameters": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "outDir": "dist"
25
+ },
26
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
27
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": false,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "allowSyntheticDefaultImports": true,
8
+ "strict": true,
9
+ "noEmit": true,
10
+ "types": ["node"]
11
+ },
12
+ "include": ["vite.config.ts"]
13
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { defineConfig } from 'vite';
2
+ import vue from '@vitejs/plugin-vue';
3
+ import { resolve } from 'path';
4
+
5
+ // https://vitejs.dev/config/
6
+ export default defineConfig({
7
+ plugins: [vue()],
8
+ build: {
9
+ emptyOutDir: false,
10
+ lib: {
11
+ // Could also be a dictionary or array of multiple entry points
12
+ entry: [resolve(__dirname, 'src/lib.ts')],
13
+ name: 'SdkVueLib',
14
+ // the proper extensions will be added
15
+ fileName: 'lib',
16
+ },
17
+ rollupOptions: {
18
+ external: ['vue'],
19
+ output: {
20
+ globals: {
21
+ vue: 'Vue',
22
+ },
23
+ },
24
+ },
25
+ },
26
+ });