zova-core 5.0.110 → 5.0.113

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 (133) hide show
  1. package/dist/bean/beanBaseSimple.d.ts.map +1 -1
  2. package/dist/bean/beanBaseSimple.js +10 -2
  3. package/dist/bean/beanBaseSimple.js.map +1 -1
  4. package/dist/core/resource.d.ts +6 -6
  5. package/dist/core/resource.d.ts.map +1 -1
  6. package/dist/core/resource.js +2 -6
  7. package/dist/core/resource.js.map +1 -1
  8. package/dist/decorator/class/use.js +8 -5
  9. package/dist/decorator/class/use.js.map +1 -1
  10. package/package.json +4 -3
  11. package/src/bean/beanBase.ts +53 -0
  12. package/src/bean/beanBaseSimple.ts +38 -0
  13. package/src/bean/beanContainer.ts +963 -0
  14. package/src/bean/beanControllerBase.ts +58 -0
  15. package/src/bean/beanControllerLike.ts +29 -0
  16. package/src/bean/beanControllerPageBase.ts +18 -0
  17. package/src/bean/beanRenderBase.ts +7 -0
  18. package/src/bean/beanRenderLike.ts +33 -0
  19. package/src/bean/beanSimple.ts +11 -0
  20. package/src/bean/beanStyleBase.ts +3 -0
  21. package/src/bean/index.ts +13 -0
  22. package/src/bean/resource/component/index.ts +1 -0
  23. package/src/bean/resource/component/type.ts +5 -0
  24. package/src/bean/resource/config/index.ts +1 -0
  25. package/src/bean/resource/config/type.ts +32 -0
  26. package/src/bean/resource/constant/index.ts +1 -0
  27. package/src/bean/resource/constant/type.ts +1 -0
  28. package/src/bean/resource/error/beanScopeError.ts +21 -0
  29. package/src/bean/resource/error/errorClass.ts +57 -0
  30. package/src/bean/resource/error/errorGlobal.ts +7 -0
  31. package/src/bean/resource/error/errorInternal.ts +66 -0
  32. package/src/bean/resource/error/errorObject.ts +4 -0
  33. package/src/bean/resource/error/index.ts +6 -0
  34. package/src/bean/resource/error/type.ts +10 -0
  35. package/src/bean/resource/icon/icon.ts +161 -0
  36. package/src/bean/resource/icon/iconGroup.ts +10 -0
  37. package/src/bean/resource/icon/index.ts +4 -0
  38. package/src/bean/resource/icon/types.ts +21 -0
  39. package/src/bean/resource/icon/useZovaIcon.ts +20 -0
  40. package/src/bean/resource/icon/utils.ts +20 -0
  41. package/src/bean/resource/icon/zovaIcon.ts +52 -0
  42. package/src/bean/resource/index.ts +8 -0
  43. package/src/bean/resource/locale/beanScopeLocale.ts +22 -0
  44. package/src/bean/resource/locale/index.ts +2 -0
  45. package/src/bean/resource/locale/type.ts +21 -0
  46. package/src/bean/resource/page/index.ts +1 -0
  47. package/src/bean/resource/page/type.ts +12 -0
  48. package/src/bean/resource/service/beanScopeService.ts +24 -0
  49. package/src/bean/resource/service/index.ts +2 -0
  50. package/src/bean/resource/service/type.ts +8 -0
  51. package/src/bean/scope/beanScopeBase.ts +74 -0
  52. package/src/bean/scope/index.ts +4 -0
  53. package/src/bean/scope/type.ts +23 -0
  54. package/src/bean/type.ts +31 -0
  55. package/src/composables/index.ts +4 -0
  56. package/src/composables/onControllerMounted.ts +12 -0
  57. package/src/composables/useApp.ts +7 -0
  58. package/src/composables/useContext.ts +7 -0
  59. package/src/composables/useController.ts +125 -0
  60. package/src/core/app/application.ts +76 -0
  61. package/src/core/app/config.ts +68 -0
  62. package/src/core/app/constant.ts +11 -0
  63. package/src/core/app/index.ts +6 -0
  64. package/src/core/app/locale.ts +12 -0
  65. package/src/core/app/meta.ts +44 -0
  66. package/src/core/app/util.ts +31 -0
  67. package/src/core/component/component.ts +44 -0
  68. package/src/core/component/cookie.ts +16 -0
  69. package/src/core/component/error.ts +18 -0
  70. package/src/core/component/event.ts +87 -0
  71. package/src/core/component/index.ts +3 -0
  72. package/src/core/component/locale.ts +97 -0
  73. package/src/core/component/module.ts +281 -0
  74. package/src/core/context/component.ts +34 -0
  75. package/src/core/context/context.ts +38 -0
  76. package/src/core/context/index.ts +4 -0
  77. package/src/core/context/meta.ts +26 -0
  78. package/src/core/context/state.ts +28 -0
  79. package/src/core/context/util.ts +20 -0
  80. package/src/core/index.ts +5 -0
  81. package/src/core/metadata.ts +54 -0
  82. package/src/core/resource.ts +186 -0
  83. package/src/decorator/class/bean.ts +19 -0
  84. package/src/decorator/class/index.ts +12 -0
  85. package/src/decorator/class/local.ts +18 -0
  86. package/src/decorator/class/model.ts +18 -0
  87. package/src/decorator/class/scope.ts +18 -0
  88. package/src/decorator/class/store.ts +18 -0
  89. package/src/decorator/class/style.ts +18 -0
  90. package/src/decorator/class/theme.ts +18 -0
  91. package/src/decorator/class/tool.ts +18 -0
  92. package/src/decorator/class/use.ts +37 -0
  93. package/src/decorator/class/useComposable.ts +16 -0
  94. package/src/decorator/class/useScope.ts +21 -0
  95. package/src/decorator/class/virtual.ts +20 -0
  96. package/src/decorator/index.ts +7 -0
  97. package/src/decorator/interface/beanOptions.ts +80 -0
  98. package/src/decorator/interface/useOptions.ts +37 -0
  99. package/src/decorator/type/constructable.ts +1 -0
  100. package/src/decorator/type/containerScope.ts +1 -0
  101. package/src/decorator/type/functionable.ts +1 -0
  102. package/src/decorator/type/injectionScope.ts +1 -0
  103. package/src/index.ts +9 -0
  104. package/src/plugins/bean.ts +16 -0
  105. package/src/plugins/index.ts +2 -0
  106. package/src/plugins/zova.ts +28 -0
  107. package/src/types/index.ts +2 -0
  108. package/src/types/interface/component.ts +36 -0
  109. package/src/types/interface/event.ts +28 -0
  110. package/src/types/interface/index.ts +6 -0
  111. package/src/types/interface/inject.ts +2 -0
  112. package/src/types/interface/module.ts +38 -0
  113. package/src/types/interface/monkey.ts +38 -0
  114. package/src/types/interface/pluginZova.ts +17 -0
  115. package/src/types/utils/cast.ts +8 -0
  116. package/src/types/utils/env.ts +35 -0
  117. package/src/types/utils/index.ts +3 -0
  118. package/src/types/utils/powerPartial.ts +3 -0
  119. package/src/utils/index.ts +1 -0
  120. package/src/utils/isClass.ts +17 -0
  121. package/src/utils/stateLock.ts +47 -0
  122. package/src/utils/uuid.ts +84 -0
  123. package/src/vue/composable.ts +10 -0
  124. package/src/vue/computed.ts +7 -0
  125. package/src/vue/customRef.ts +5 -0
  126. package/src/vue/index.ts +4 -0
  127. package/src/vue/ref.ts +12 -0
  128. package/src/zod/index.ts +2 -0
  129. package/src/zod/zz.ts +77 -0
  130. package/dist/decorator/class/data.d.ts +0 -3
  131. package/dist/decorator/class/data.d.ts.map +0 -1
  132. package/dist/decorator/class/data.js +0 -18
  133. package/dist/decorator/class/data.js.map +0 -1
@@ -0,0 +1,80 @@
1
+ import { MetadataKey } from '../../core/metadata.js';
2
+ import { Constructable } from '../index.js';
3
+ import { ContainerScope } from '../index.js';
4
+
5
+ export type TypeDecoratorBeanOptionsSceneBase = 'local' | 'aop' | 'virtual' | 'scope' | TypeDecoratorBeanOptionsScene;
6
+ // containerScope: store(app) model(ctx)
7
+ export type TypeDecoratorBeanOptionsScene = 'bean' | 'store' | 'model' | 'style' | 'theme' | 'tool'; // | 'ui' | 'event';
8
+
9
+ export interface IDecoratorBeanOptionsBase<T = unknown> {
10
+ /**
11
+ * global: module.scene.name
12
+ * others: undefined: use beanClass
13
+ */
14
+ beanFullName: string;
15
+ beanUuid: string;
16
+ module: string;
17
+ scene?: TypeDecoratorBeanOptionsSceneBase;
18
+ name: string;
19
+ beanClass: Constructable<T>;
20
+ containerScope?: ContainerScope;
21
+ markReactive?: boolean;
22
+ aop?: boolean;
23
+ aopMatch?: string | RegExp | (string | RegExp)[];
24
+ virtual?: boolean;
25
+ moduleBelong?: string;
26
+ options?: unknown;
27
+ __aopChains__: MetadataKey[];
28
+ __aopChainsKey__: Record<string, [MetadataKey, string][]>;
29
+ }
30
+
31
+ export interface IDecoratorBeanOptions {
32
+ scene?: TypeDecoratorBeanOptionsScene;
33
+ name?: string;
34
+ containerScope?: ContainerScope;
35
+ markReactive?: boolean;
36
+ }
37
+
38
+ export type IDecoratorVirtualOptions = IDecoratorBeanOptions;
39
+
40
+ export interface IDecoratorLocalOptions {
41
+ containerScope?: ContainerScope;
42
+ markReactive?: boolean;
43
+ }
44
+
45
+ export interface IDecoratorAopOptions {
46
+ name?: string;
47
+ match: string | RegExp | (string | RegExp)[];
48
+ }
49
+
50
+ export interface IDecoratorScopeOptions {}
51
+
52
+ export interface IDecoratorStoreOptions {
53
+ scene?: TypeDecoratorBeanOptionsScene;
54
+ name?: string;
55
+ markReactive?: boolean;
56
+ }
57
+
58
+ export interface IDecoratorModelOptions {
59
+ scene?: TypeDecoratorBeanOptionsScene;
60
+ name?: string;
61
+ markReactive?: boolean;
62
+ }
63
+
64
+ export interface IDecoratorStyleOptions {
65
+ scene?: TypeDecoratorBeanOptionsScene;
66
+ name?: string;
67
+ markReactive?: boolean;
68
+ }
69
+
70
+ export interface IDecoratorThemeOptions {
71
+ scene?: TypeDecoratorBeanOptionsScene;
72
+ name?: string;
73
+ markReactive?: boolean;
74
+ }
75
+
76
+ export interface IDecoratorToolOptions {
77
+ scene?: TypeDecoratorBeanOptionsScene;
78
+ name?: string;
79
+ markReactive?: boolean;
80
+ }
@@ -0,0 +1,37 @@
1
+ import { IBeanRecord, IBeanScopeRecord } from '../../bean/type.js';
2
+ import { MetadataKey } from '../../core/metadata.js';
3
+ import { Constructable } from '../type/constructable.js';
4
+ import { InjectionScope } from '../type/injectionScope.js';
5
+ import { Functionable } from '../type/functionable.js';
6
+
7
+ export interface IDecoratorUseOptionsBase<T = unknown> {
8
+ prop: MetadataKey;
9
+ beanFullName?: string;
10
+ name?: string;
11
+ beanClass?: Constructable<T>;
12
+ beanComposable?: Functionable;
13
+ /** such as: moduleScope */
14
+ selector?: string;
15
+ injectionScope?: InjectionScope;
16
+ markReactive?: boolean;
17
+ }
18
+
19
+ export interface IDecoratorUseOptions {
20
+ beanFullName?: keyof IBeanRecord;
21
+ name?: string;
22
+ selector?: string;
23
+ injectionScope?: InjectionScope;
24
+ markReactive?: boolean;
25
+ }
26
+
27
+ export interface IDecoratorUseComposableOptions {
28
+ beanComposable?: Functionable;
29
+ name?: string;
30
+ selector?: string;
31
+ injectionScope?: InjectionScope;
32
+ markReactive?: boolean;
33
+ }
34
+
35
+ export interface IDecoratorUseScopeOptions {
36
+ module: keyof IBeanScopeRecord;
37
+ }
@@ -0,0 +1 @@
1
+ export type Constructable<T = unknown> = new (...args: any[]) => T;
@@ -0,0 +1 @@
1
+ export type ContainerScope = 'app' | 'ctx' | 'new';
@@ -0,0 +1 @@
1
+ export type Functionable<T = unknown> = (...args: any[]) => T;
@@ -0,0 +1 @@
1
+ export type InjectionScope = 'app' | 'ctx' | 'new' | 'host' | 'skipSelf';
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from './bean/index.js';
2
+ export * from './core/index.js';
3
+ export * from './decorator/index.js';
4
+ export * from './composables/index.js';
5
+ export * from './plugins/index.js';
6
+ export * from './types/index.js';
7
+ export * from './utils/index.js';
8
+ export * from './vue/index.js';
9
+ export * from './zod/index.js';
@@ -0,0 +1,16 @@
1
+ import { App } from 'vue';
2
+ import { ZovaContext } from '../core/index.js';
3
+
4
+ export const PluginBean = {
5
+ install(app: App) {
6
+ app.mixin({
7
+ created() {
8
+ // this._ is instance, not use self.$
9
+ const ctx: ZovaContext = this._.zova;
10
+ if (ctx) {
11
+ ctx.meta.component.activate();
12
+ }
13
+ },
14
+ });
15
+ },
16
+ };
@@ -0,0 +1,2 @@
1
+ export * from './bean.js';
2
+ export * from './zova.js';
@@ -0,0 +1,28 @@
1
+ import { App } from 'vue';
2
+ import { ZovaApplication, ZovaContext } from '../core/index.js';
3
+ import { PluginZovaOptions } from '../types/interface/pluginZova.js';
4
+ import { BeanContainerInstances } from '../bean/beanContainer.js';
5
+ import { Cast } from '../types/index.js';
6
+ import { BeanControllerIdentifier, BeanRenderIdentifier, BeanStyleIdentifier } from '../bean/type.js';
7
+
8
+ export const PluginZova = {
9
+ async install(vue: App, ctxRoot: ZovaContext, { modulesMeta, AppMonkey, locales, config }: PluginZovaOptions) {
10
+ // zova app
11
+ const app = new ZovaApplication(vue, ctxRoot);
12
+ await app.initialize({ modulesMeta, AppMonkey, locales, config });
13
+ return app;
14
+ },
15
+ async update(app: ZovaApplication, ctxRoot: ZovaContext) {
16
+ const bean = Cast(app.bean);
17
+ bean.ctx = ctxRoot;
18
+ for (const key in bean[BeanContainerInstances]) {
19
+ bean[BeanContainerInstances][key].ctx = ctxRoot;
20
+ }
21
+ delete bean[BeanContainerInstances][BeanControllerIdentifier];
22
+ delete bean[BeanContainerInstances][BeanRenderIdentifier];
23
+ delete bean[BeanContainerInstances][BeanStyleIdentifier];
24
+ Object.assign(bean[BeanContainerInstances], ctxRoot.bean[BeanContainerInstances]);
25
+ ctxRoot.bean = bean;
26
+ ctxRoot.app = app;
27
+ },
28
+ };
@@ -0,0 +1,2 @@
1
+ export * from './interface/index.js';
2
+ export * from './utils/index.js';
@@ -0,0 +1,36 @@
1
+ import 'vue';
2
+ import 'vue/jsx-runtime';
3
+ import '@vue/runtime-dom';
4
+
5
+ declare module 'vue' {
6
+ export interface ComponentCustomOptions {
7
+ meta?: {
8
+ global?: boolean;
9
+ };
10
+ }
11
+
12
+ export interface AllowedComponentProps {}
13
+ }
14
+
15
+ declare module 'vue/jsx-runtime' {
16
+ namespace JSX {
17
+ // need define class/style in IntrinsicAttributes
18
+ export interface IntrinsicAttributes {
19
+ class?: unknown;
20
+ style?: unknown;
21
+ onClick?: (e: MouseEvent) => void;
22
+ }
23
+ }
24
+ }
25
+
26
+ declare module '@vue/runtime-dom' {
27
+ export interface LabelHTMLAttributes {
28
+ htmlFor?: string;
29
+ }
30
+
31
+ export interface SVGAttributes {
32
+ strokeLinecap?: string;
33
+ strokeLinejoin?: string;
34
+ strokeWidth?: string;
35
+ }
36
+ }
@@ -0,0 +1,28 @@
1
+ export type TypeEventOff = () => void;
2
+
3
+ export type TypeEventHandlersMap<KS extends keyof IEventRecord> = {
4
+ [K in KS]: TypeEventHandlers<IEventRecord[K], IEventResultRecord[K]>;
5
+ };
6
+
7
+ export type TypeEventHandlers<D = unknown, R = unknown> = TypeEventHandlerWrapper<D, R>[];
8
+
9
+ export type TypeEventContext<D, R> = {
10
+ data: D;
11
+ result: R;
12
+ };
13
+
14
+ export type TypeEventHandlerWrapper<D, R> = {
15
+ fn: TypeEventHandler<D, R> | null;
16
+ };
17
+
18
+ export type TypeEventHandler<D, R> = {
19
+ (context: TypeEventContext<D, R>, next: TypeEventNext): Promise<void>;
20
+ };
21
+
22
+ export type TypeEventNext = () => Promise<void>;
23
+
24
+ export interface IEventRecord {}
25
+ export type TypeEventRecordKeys = keyof IEventRecord;
26
+
27
+ export interface IEventResultRecord {}
28
+ export type TypeEventResultRecordKeys = keyof IEventResultRecord;
@@ -0,0 +1,6 @@
1
+ export * from './component.js';
2
+ export * from './event.js';
3
+ export * from './inject.js';
4
+ export * from './module.js';
5
+ export * from './monkey.js';
6
+ export * from './pluginZova.js';
@@ -0,0 +1,2 @@
1
+ export interface IInjectRecord {}
2
+ export type TypeInjectRecordKeys = keyof IInjectRecord;
@@ -0,0 +1,38 @@
1
+ import { IModuleInfo } from '@cabloy/module-info';
2
+ import { ZovaApplication } from '../../core/app/application.js';
3
+ import { IModuleMain, IMonkeyModule, IMonkeyController, IMonkeySystem } from './monkey.js';
4
+ import { StateLock } from '../../utils/stateLock.js';
5
+ import { Component } from 'vue';
6
+
7
+ export type TypeModuleResourceIcons = Record<string, string>;
8
+ export type TypeModuleResourceLocales = Record<string, object>;
9
+ export type TypeModuleResourceLocaleModules = Record<string, TypeModuleResourceLocales>;
10
+ export type TypeModuleResourceErrors = Record<number, string>;
11
+ export type TypeModuleResourceErrorModules = Record<string, TypeModuleResourceErrors>;
12
+ export type TypeModuleResourceComponents = Record<string, Component>;
13
+ export type TypeModuleResourceServices = Record<string, (app: ZovaApplication) => object>;
14
+
15
+ export interface IModuleResource {
16
+ Main: new () => IModuleMain;
17
+ Monkey: new () => IMonkeyModule & IMonkeySystem & IMonkeyController;
18
+ locales: TypeModuleResourceLocales;
19
+ Errors: TypeModuleResourceErrors;
20
+ config: (app: ZovaApplication) => object | Promise<object>;
21
+ constants: unknown;
22
+ icons: TypeModuleResourceIcons;
23
+ components: TypeModuleResourceComponents;
24
+ services: TypeModuleResourceServices;
25
+ }
26
+
27
+ export const SymbolInstalled = Symbol('SymbolInstalled');
28
+
29
+ declare module '@cabloy/module-info' {
30
+ export interface IModule {
31
+ /** @internal */
32
+ [SymbolInstalled]: StateLock;
33
+ resource: IModuleResource; // IModuleResource | Promise<IModuleResource>;
34
+ info: IModuleInfo;
35
+ mainInstance: IModuleMain;
36
+ monkeyInstance: IMonkeyModule & IMonkeySystem & IMonkeyController;
37
+ }
38
+ }
@@ -0,0 +1,38 @@
1
+ import { IModule } from '@cabloy/module-info';
2
+ import { BeanBase } from '../../bean/beanBase.js';
3
+ import { BeanContainer } from '../../bean/beanContainer.js';
4
+ import { IControllerData } from '../../bean/type.js';
5
+
6
+ export type TypeMonkeyName = keyof IMonkeyModule | keyof IMonkeySystem | keyof IMonkeyController;
7
+
8
+ export interface IMonkeyApp {
9
+ moduleLoading(module: IModule): Promise<void>;
10
+ moduleLoaded(module: IModule): Promise<void>;
11
+ configLoaded(module: IModule, config: any): Promise<void>;
12
+ }
13
+
14
+ export interface IModuleMain {
15
+ moduleLoading(): Promise<void>;
16
+ moduleLoaded(): Promise<void>;
17
+ configLoaded(config: any): Promise<void>;
18
+ }
19
+
20
+ export interface IMonkeyModule {
21
+ moduleLoading(module: IModule): Promise<void>;
22
+ moduleLoaded(module: IModule): Promise<void>;
23
+ configLoaded(module: IModule, config: any): Promise<void>;
24
+ }
25
+
26
+ export interface IMonkeySystem {
27
+ appInitialize(bean: BeanContainer): Promise<void>;
28
+ appInitialized(bean: BeanContainer): Promise<void>;
29
+ beanInit(bean: BeanContainer, beanInstance: BeanBase): Promise<void>;
30
+ beanInited(bean: BeanContainer, beanInstance: BeanBase): Promise<void>;
31
+ beanDispose(bean: BeanContainer, beanInstance: BeanBase): void;
32
+ beanDisposed(bean: BeanContainer, beanInstance: BeanBase): void;
33
+ }
34
+
35
+ export interface IMonkeyController {
36
+ controllerDataPrepare(controllerData: IControllerData);
37
+ controllerDataInit(controllerData: IControllerData, controller: BeanBase);
38
+ }
@@ -0,0 +1,17 @@
1
+ import { IModule } from '@cabloy/module-info';
2
+ import { ZovaConfig } from '../../core/app/config.js';
3
+ import { IMonkeyApp, IMonkeySystem, IMonkeyController } from './monkey.js';
4
+ import { Constructable } from '../../decorator/index.js';
5
+ import { ZovaLocaleOptionalMap } from '../../core/app/locale.js';
6
+
7
+ export interface PluginZovaModulesMeta {
8
+ modules: Record<string, IModule>;
9
+ moduleNames: string[];
10
+ }
11
+
12
+ export interface PluginZovaOptions {
13
+ modulesMeta: PluginZovaModulesMeta;
14
+ AppMonkey: Constructable<IMonkeyApp & IMonkeySystem & IMonkeyController>;
15
+ locales: ZovaLocaleOptionalMap;
16
+ config: ZovaConfig;
17
+ }
@@ -0,0 +1,8 @@
1
+ export function Cast<T = any>(source: unknown) {
2
+ return source as T;
3
+ }
4
+
5
+ declare global {
6
+ function parseInt(num: number, radix?: number): number;
7
+ function parseInt(num: any, radix?: number): number;
8
+ }
@@ -0,0 +1,35 @@
1
+ export interface ZovaConfigMeta {
2
+ flavor: 'app' | 'web' | string;
3
+ mode: 'development' | 'production' | string;
4
+ appMode: 'spa' | 'ssr' | 'pwa' | 'cordova' | 'capacitor' | 'electron' | 'bex' | string | undefined;
5
+ }
6
+
7
+ export interface ZovaConfigEnv {
8
+ appServer: boolean;
9
+ appRouterMode: 'hash' | 'history' | 'abstract' | undefined;
10
+ appRouterBase: string | undefined;
11
+ appPublicPath: string | undefined;
12
+ appName: string | undefined;
13
+ appTitle: string | undefined;
14
+ appVersion: string | undefined;
15
+ }
16
+
17
+ declare global {
18
+ namespace NodeJS {
19
+ interface ProcessEnv {
20
+ NODE_ENV: 'development' | 'production';
21
+ META_FLAVOR: 'app' | 'web' | string;
22
+ META_MODE: 'development' | 'production';
23
+ META_APP_MODE: 'spa' | 'ssr' | 'pwa' | 'cordova' | 'capacitor' | 'electron' | 'bex' | string | undefined;
24
+ APP_SERVER: string | undefined;
25
+ APP_ROUTER_MODE: 'hash' | 'history' | 'abstract' | undefined;
26
+ APP_ROUTER_BASE: string | undefined;
27
+ APP_PUBLIC_PATH: string | undefined;
28
+ APP_NAME: string | undefined;
29
+ APP_TITLE: string | undefined;
30
+ APP_VERSION: string | undefined;
31
+ DEV_SERVER_HOST: string | undefined;
32
+ DEV_SERVER_PORT: string | undefined;
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,3 @@
1
+ export * from './cast.js';
2
+ export * from './env.js';
3
+ export * from './powerPartial.js';
@@ -0,0 +1,3 @@
1
+ export type PowerPartial<T> = {
2
+ [U in keyof T]?: T[U] extends object ? PowerPartial<T[U]> : T[U];
3
+ };
@@ -0,0 +1 @@
1
+ export * from './stateLock.js';
@@ -0,0 +1,17 @@
1
+ export function isClass(fn) {
2
+ // just check if is function
3
+ return typeof fn === 'function';
4
+ }
5
+
6
+ // function fnBody(fn) {
7
+ // return toString
8
+ // .call(fn)
9
+ // .replace(/^[^{]*{\s*/, '')
10
+ // .replace(/\s*}[^}]*$/, '');
11
+ // }
12
+
13
+ // export function isClass(fn) {
14
+ // return (
15
+ // typeof fn === 'function' && (/^class(?:\s|{)/.test(toString.call(fn)) || /^.*classCallCheck\(/.test(fnBody(fn))) // babel.js
16
+ // );
17
+ // }
@@ -0,0 +1,47 @@
1
+ import { reactive, watch } from 'vue';
2
+
3
+ // eslint-disable-next-line
4
+ let __counter = 0;
5
+
6
+ export class StateLock {
7
+ private _state: boolean;
8
+
9
+ static create() {
10
+ return reactive(new StateLock()) as StateLock;
11
+ }
12
+
13
+ protected constructor() {
14
+ this._state = false;
15
+ __counter++;
16
+ }
17
+
18
+ get state() {
19
+ return this._state;
20
+ }
21
+
22
+ set state(value) {
23
+ if (this._state !== value) {
24
+ this._state = value;
25
+ __counter--;
26
+ // console.log('-----lock counter: ', __counter);
27
+ }
28
+ }
29
+
30
+ touch() {
31
+ this.state = true;
32
+ }
33
+
34
+ async wait() {
35
+ return new Promise(resolve => {
36
+ // condition check should place in the promise inner
37
+ if (this.state) return resolve(null);
38
+ watch(
39
+ () => this.state,
40
+ () => {
41
+ resolve(null);
42
+ },
43
+ { once: true },
44
+ );
45
+ });
46
+ }
47
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Based on the work of https://github.com/jchook/uuid-random
3
+ */
4
+
5
+ let buf,
6
+ bufIdx = 0;
7
+ const hexBytes = new Array(256);
8
+
9
+ // Pre-calculate toString(16) for speed
10
+ for (let i = 0; i < 256; i++) {
11
+ hexBytes[i] = (i + 0x100).toString(16).substring(1);
12
+ }
13
+
14
+ // Use best available PRNG
15
+ const randomBytes = (() => {
16
+ // Node & Browser support
17
+ const lib: any =
18
+ typeof crypto !== 'undefined'
19
+ ? crypto
20
+ : typeof window !== 'undefined'
21
+ ? window.crypto || (<any>window).msCrypto
22
+ : void 0;
23
+
24
+ if (lib !== void 0) {
25
+ if (lib.randomBytes !== void 0) {
26
+ return lib.randomBytes;
27
+ }
28
+ if (lib.getRandomValues !== void 0) {
29
+ return n => {
30
+ const bytes = new Uint8Array(n);
31
+ lib.getRandomValues(bytes);
32
+ return bytes;
33
+ };
34
+ }
35
+ }
36
+
37
+ return n => {
38
+ const r: number[] = [];
39
+ for (let i = n; i > 0; i--) {
40
+ r.push(Math.floor(Math.random() * 256));
41
+ }
42
+ return r;
43
+ };
44
+ })();
45
+
46
+ // Buffer random numbers for speed
47
+ // Reduce memory usage by decreasing this number (min 16)
48
+ // or improve speed by increasing this number (try 16384)
49
+ const BUFFER_SIZE = 4096;
50
+
51
+ export function uuid() {
52
+ // Buffer some random bytes for speed
53
+ if (buf === void 0 || bufIdx + 16 > BUFFER_SIZE) {
54
+ bufIdx = 0;
55
+ buf = randomBytes(BUFFER_SIZE);
56
+ }
57
+
58
+ const b = Array.prototype.slice.call(buf, bufIdx, (bufIdx += 16));
59
+ b[6] = (b[6] & 0x0f) | 0x40;
60
+ b[8] = (b[8] & 0x3f) | 0x80;
61
+
62
+ return (
63
+ hexBytes[b[0]] +
64
+ hexBytes[b[1]] +
65
+ hexBytes[b[2]] +
66
+ hexBytes[b[3]] +
67
+ '-' +
68
+ hexBytes[b[4]] +
69
+ hexBytes[b[5]] +
70
+ '-' +
71
+ hexBytes[b[6]] +
72
+ hexBytes[b[7]] +
73
+ '-' +
74
+ hexBytes[b[8]] +
75
+ hexBytes[b[9]] +
76
+ '-' +
77
+ hexBytes[b[10]] +
78
+ hexBytes[b[11]] +
79
+ hexBytes[b[12]] +
80
+ hexBytes[b[13]] +
81
+ hexBytes[b[14]] +
82
+ hexBytes[b[15]]
83
+ );
84
+ }
@@ -0,0 +1,10 @@
1
+ import { UnwrapNestedRefs } from 'vue';
2
+ import { Functionable } from '../decorator/type/functionable.js';
3
+
4
+ export type ReturnTypeComposable<Composable extends Functionable> = Composable extends (...args: any[]) => infer R
5
+ ? UnwrapNestedRefs<R>
6
+ : any;
7
+
8
+ export function useComposable<T extends Functionable>(composable: T, ...args: Parameters<T>): ReturnTypeComposable<T> {
9
+ return composable(...args) as ReturnTypeComposable<T>;
10
+ }
@@ -0,0 +1,7 @@
1
+ import { computed, ComputedGetter, DebuggerOptions, WritableComputedOptions } from 'vue';
2
+
3
+ export function useComputed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): T;
4
+ export function useComputed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): T;
5
+ export function useComputed(options, debugOptions) {
6
+ return computed(options, debugOptions);
7
+ }
@@ -0,0 +1,5 @@
1
+ import { CustomRefFactory, customRef } from 'vue';
2
+
3
+ export function useCustomRef<T>(factory: CustomRefFactory<T>): T {
4
+ return customRef(factory) as T;
5
+ }
@@ -0,0 +1,4 @@
1
+ export * from './composable.js';
2
+ export * from './computed.js';
3
+ export * from './customRef.js';
4
+ export * from './ref.js';
package/src/vue/ref.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Ref, UnwrapRef, toRef } from 'vue';
2
+
3
+ export function useRef<T>(value: T): T extends () => infer R ? R : T extends Ref ? UnwrapRef<T> : UnwrapRef<T>;
4
+ export function useRef<T extends object, K extends keyof T>(object: T, key: K): T[K];
5
+ export function useRef<T extends object, K extends keyof T>(
6
+ object: T,
7
+ key: K,
8
+ defaultValue: T[K],
9
+ ): Exclude<T[K], undefined>;
10
+ export function useRef(object, key?, defaultValue?) {
11
+ return toRef(object, key, defaultValue);
12
+ }
@@ -0,0 +1,2 @@
1
+ export { z } from 'zod';
2
+ export * as zz from './zz.js';