ivue 0.0.32 → 0.1.0

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 (157) hide show
  1. package/.babelrc.json +14 -0
  2. package/.eslintrc.cjs +24 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/compiler.xml +7 -0
  5. package/.idea/infinite-vue.iml +10 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +11 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/php.xml +20 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.vscode/extensions.json +3 -0
  11. package/LICENSE +19 -0
  12. package/README.md +31 -0
  13. package/demo/App.vue +72 -0
  14. package/demo/components/IVueTest.vue +298 -0
  15. package/demo/components/PreComponent.vue +13 -0
  16. package/demo/components/SubComponent2.vue +45 -0
  17. package/demo/components/TraitsComponent.vue +120 -0
  18. package/demo/components/useIVueTest.vue +136 -0
  19. package/demo/main.ts +21 -0
  20. package/demo/router/index.ts +14 -0
  21. package/demo/tests/IVueTests.ts +255 -0
  22. package/demo/tests/Mouse.ts +79 -0
  23. package/demo/tests/ParentIVueTests.ts +36 -0
  24. package/demo/tests/TApp.ts +15 -0
  25. package/demo/tests/TAuth.ts +23 -0
  26. package/demo/tests/TField.ts +84 -0
  27. package/demo/tests/TMessage.ts +52 -0
  28. package/demo/tests/TRouter.ts +18 -0
  29. package/demo/tests/TUser.ts +19 -0
  30. package/demo/tests/Test.ts +86 -0
  31. package/demo/tests/useField.ts +82 -0
  32. package/demo/tests/useIVueTests.ts +57 -0
  33. package/demo/vite.config.ts +13 -0
  34. package/dist/favicon.ico +0 -0
  35. package/dist/index.es.js +518 -0
  36. package/dist/index.umd.js +1 -0
  37. package/dist/src/behavior.d.ts +72 -0
  38. package/dist/src/config.d.ts +6 -0
  39. package/dist/src/index.d.ts +21 -0
  40. package/dist/src/ivue.d.ts +35 -0
  41. package/dist/src/kernel.d.ts +182 -0
  42. package/dist/src/traits/UseCapsule.d.ts +9 -0
  43. package/dist/src/traits/UseEmit.d.ts +3 -0
  44. package/dist/src/traits/UseInstance.d.ts +6 -0
  45. package/dist/src/traits/UseMounting.d.ts +11 -0
  46. package/dist/src/traits/UseRefs.d.ts +8 -0
  47. package/dist/src/traits/UseRoute.d.ts +3 -0
  48. package/dist/src/traits/UseRouter.d.ts +3 -0
  49. package/dist/src/traits/UseRouting.d.ts +6 -0
  50. package/dist/src/traits/UseTick.d.ts +4 -0
  51. package/dist/src/traits/UseVue.d.ts +13 -0
  52. package/dist/src/types/core.d.ts +46 -0
  53. package/dist/src/utils/dispose-garbage.d.ts +12 -0
  54. package/dist/src/utils/extend.d.ts +12 -0
  55. package/dist/src/utils/getters.d.ts +21 -0
  56. package/dist/src/utils/index.d.ts +7 -0
  57. package/dist/src/utils/is.d.ts +14 -0
  58. package/dist/src/utils/pre.d.ts +9 -0
  59. package/dist/src/utils/raw.d.ts +12 -0
  60. package/dist/src/utils/safe-class-name.d.ts +7 -0
  61. package/dist/src/utils/traits.d.ts +41 -0
  62. package/env.d.ts +1 -0
  63. package/index.html +13 -0
  64. package/package-lock.json +14305 -0
  65. package/package.json +89 -10
  66. package/public/favicon.ico +0 -0
  67. package/src/App/App.ts +27 -0
  68. package/src/App/Auth/Auth.ts +105 -0
  69. package/src/App/Auth/Auth.vue +98 -0
  70. package/src/App/Auth/Logout.vue +14 -0
  71. package/src/App/Auth/User.ts +6 -0
  72. package/src/App/BlackBox.ts +75 -0
  73. package/src/App/Config.ts +6 -0
  74. package/src/App/Generators/generators.ts +47 -0
  75. package/src/App/Home/Home.vue +16 -0
  76. package/src/App/Services/Http/FakeHttp.ts +8 -0
  77. package/src/App/Services/Http/Http.ts +51 -0
  78. package/src/App/Services/Message/Message.ts +49 -0
  79. package/src/App/Services/Message/Message.vue +15 -0
  80. package/src/App/Services/Navigation/Navigation.ts +83 -0
  81. package/src/App/Services/Navigation/Navigation.vue +59 -0
  82. package/src/App/Services/Routing/FakeRouter.ts +7 -0
  83. package/src/App/Services/Routing/NotFoundRoute.vue +13 -0
  84. package/src/App/Services/Routing/Router.ts +262 -0
  85. package/src/App/Services/Routing/Routes.ts +49 -0
  86. package/src/App/Stubs/SingleBookResultStub.ts +13 -0
  87. package/src/App/Traits/UseApp.ts +6 -0
  88. package/src/App/Traits/UseBlackline.ts +0 -0
  89. package/src/App/Traits/UseQuasar.ts +8 -0
  90. package/src/behavior.ts +269 -0
  91. package/src/config.ts +15 -0
  92. package/src/dev/dev-utils.ts +78 -0
  93. package/src/index.ts +83 -0
  94. package/src/ivue.ts +296 -0
  95. package/src/kernel.ts +810 -0
  96. package/src/tests/auth.spec.ts +48 -0
  97. package/src/traits/UseCapsule.ts +28 -0
  98. package/src/traits/UseEmit.ts +3 -0
  99. package/src/traits/UseInstance.ts +17 -0
  100. package/src/traits/UseMounting.ts +23 -0
  101. package/src/traits/UseRefs.ts +17 -0
  102. package/src/traits/UseRoute.ts +6 -0
  103. package/src/traits/UseRouter.ts +5 -0
  104. package/src/traits/UseRouting.ts +7 -0
  105. package/src/traits/UseTick.ts +5 -0
  106. package/src/traits/UseVue.ts +38 -0
  107. package/src/types/core.ts +64 -0
  108. package/src/utils/dispose-garbage.ts +34 -0
  109. package/src/utils/extend.ts +85 -0
  110. package/src/utils/getters.ts +62 -0
  111. package/src/utils/index.ts +16 -0
  112. package/src/utils/is.ts +22 -0
  113. package/src/utils/pre.ts +29 -0
  114. package/src/utils/raw.ts +19 -0
  115. package/src/utils/safe-class-name.ts +15 -0
  116. package/src/utils/traits.ts +121 -0
  117. package/tsconfig.app.json +47 -0
  118. package/tsconfig.json +14 -0
  119. package/tsconfig.node.json +14 -0
  120. package/tsconfig.vitest.json +9 -0
  121. package/vite.config.ts +55 -0
  122. package/vitest.config.ts +18 -0
  123. package/dist/index.js +0 -218
  124. package/docs/index.html +0 -195
  125. package/docs/index.json +0 -3
  126. package/docs/input.html +0 -41
  127. package/docs/items.html +0 -42
  128. package/gulpfile.js +0 -5
  129. package/src/components/checkbox.js +0 -47
  130. package/src/components/data.js +0 -6
  131. package/src/components/file.js +0 -40
  132. package/src/components/form.js +0 -7
  133. package/src/components/index.js +0 -15
  134. package/src/components/input.js +0 -80
  135. package/src/components/items.js +0 -65
  136. package/src/components/modal.js +0 -42
  137. package/src/components/paginate-old.js +0 -88
  138. package/src/components/paginate.js +0 -35
  139. package/src/components/select-search.js +0 -152
  140. package/src/components/select.js +0 -62
  141. package/src/components/submit.js +0 -10
  142. package/src/components/textarea.js +0 -72
  143. package/src/components/upload.js +0 -49
  144. package/src/directives/href.js +0 -10
  145. package/src/directives/index.js +0 -1
  146. package/src/filters/date.js +0 -3
  147. package/src/filters/datetime.js +0 -3
  148. package/src/filters/index.js +0 -4
  149. package/src/filters/json.js +0 -3
  150. package/src/filters/money.js +0 -3
  151. package/src/index.js +0 -4
  152. package/src/mixins/data.js +0 -13
  153. package/src/mixins/form.js +0 -85
  154. package/src/mixins/resource.js +0 -31
  155. package/src/services/client.js +0 -32
  156. package/src/services/flash.js +0 -17
  157. package/src/services/index.js +0 -2
@@ -0,0 +1,35 @@
1
+ import { type EffectScope } from 'vue';
2
+ import type { IVue, IVueToRefsObj, AnyClass, InferredArgs, Getters, Computeds } from "./types/core";
3
+ /**
4
+ * Create ivue instance from class constructor.
5
+ *
6
+ * @param className
7
+ * @param args
8
+ * @returns @see IVue<T>
9
+ */
10
+ export declare function ivue<T extends AnyClass>(className: T, ...args: InferredArgs<T>): IVue<T>;
11
+ /**
12
+ * Create ivue instance from an object.
13
+ *
14
+ * @param obj
15
+ * @returns
16
+ */
17
+ export declare function iobj<T extends object>(obj: T): T & IVueToRefsObj<T>;
18
+ /**
19
+ * Pure VueJS Reactive Observable Class-based Architecture System.
20
+ *
21
+ * @param vue
22
+ * @param getters
23
+ * @param args Arguments are available when used via ivue(obj, ...args)
24
+ */
25
+ export declare function ivueTransform(vue: any, getters: Getters, computeds: Computeds, scope: EffectScope, ...args: undefined[]): any;
26
+ /**
27
+ * Convert reactive to refs.
28
+ *
29
+ * @param vue @see IVue
30
+ * @param getters @see Getters
31
+ * @param computeds @see Computeds
32
+ * @param scope @see EffectScope
33
+ * @returns
34
+ */
35
+ export declare function ivueToRefs<T extends AnyClass>(vue: IVue<T>, getters: Getters, computeds: Computeds, scope: EffectScope): (...props: string[]) => IVue<T>;
@@ -0,0 +1,182 @@
1
+ import { type EffectScope } from 'vue';
2
+ import type { MappingScope, MappingType, IVue, AnyClass, InferredArgs } from './types/core';
3
+ /**
4
+ * Kernel Mapping.
5
+ */
6
+ export declare class Mapping {
7
+ from: any;
8
+ /**
9
+ * Construct mapping, by default set 'to'
10
+ * to equal 'from' binding, to
11
+ * support auto-binding.
12
+ *
13
+ * @param from mapping pointer
14
+ */
15
+ constructor(from: any);
16
+ /**
17
+ * Resolves mapping to this value.
18
+ */
19
+ to: any;
20
+ /**
21
+ * Scope: singleton | transient
22
+ */
23
+ scope: MappingScope;
24
+ /**
25
+ * Mapping type: generic | ivue | ...
26
+ */
27
+ type: MappingType;
28
+ /**
29
+ * Mapping initializer method.
30
+ */
31
+ onInit: typeof onInit;
32
+ }
33
+ /**
34
+ * Kernel - ivue IOC Container.
35
+ *
36
+ * [IOC] Inversion of Control.
37
+ * Enables memory and object instance state management.
38
+ *
39
+ * Allows creation and storage of singletons and trasients.
40
+ * Allows for interceptable class architecture.
41
+ *
42
+ * Converts clases to ivue reactive instances automatically.
43
+ *
44
+ * Smart garbage disposal mechanism allows to keep
45
+ * the App memory low making it more effiecient.
46
+ */
47
+ export declare class Kernel {
48
+ /**
49
+ * Transiet mappings storage.
50
+ */
51
+ transients: WeakMap<object, any>;
52
+ /**
53
+ * Singleton mappings storage.
54
+ */
55
+ singletons: WeakMap<object, any>;
56
+ /**
57
+ * Singleton instances storage.
58
+ */
59
+ instances: WeakMap<object, any>;
60
+ /**
61
+ * Subscribers
62
+ */
63
+ subscribers: WeakMap<AnyClass, number>;
64
+ /**
65
+ * Vue EffectScopes for garbage collection.
66
+ */
67
+ effectScopes: WeakMap<AnyClass, EffectScope>;
68
+ /**
69
+ * Current mapping being set.
70
+ */
71
+ current: Mapping;
72
+ /**
73
+ * Set mapping to bind from this value.
74
+ *
75
+ * @param from mapping pointer
76
+ * @returns this
77
+ */
78
+ bind(from: any): this;
79
+ /**
80
+ * Set mapping to resolve the binding to the value of to param.
81
+ *
82
+ * @param to resolve mapping to this value
83
+ * @returns this
84
+ */
85
+ to(to: any): this;
86
+ /**
87
+ * Set binding to singleton scope.
88
+ *
89
+ * @returns this
90
+ */
91
+ singleton(): this;
92
+ /**
93
+ * Set binding to transient scope.
94
+ *
95
+ * @returns this
96
+ */
97
+ transient(): this;
98
+ /**
99
+ * Set mapping type.
100
+ *
101
+ * @param value type of mapping
102
+ * @returns this
103
+ */
104
+ type(value: any): this;
105
+ /**
106
+ * Set preset ivue initializer callback.
107
+ *
108
+ * @returns this
109
+ */
110
+ ivue(): this;
111
+ /**
112
+ * Set mapping initializer callback method.
113
+ *
114
+ * @param callback Initializer callback method
115
+ * @returns this
116
+ */
117
+ onInit(callback: any): this;
118
+ /**
119
+ * Get a singleton instance declared in the container.
120
+ *
121
+ * @param className
122
+ * @param args
123
+ */
124
+ get<T extends AnyClass>(className: T, ...args: InferredArgs<T>): InstanceType<T>;
125
+ /**
126
+ * Make a transient instance based on container definition.
127
+ *
128
+ * @param className
129
+ * @param args
130
+ */
131
+ make<T extends AnyClass>(className: T, ...args: InferredArgs<T>): InstanceType<T>;
132
+ /**
133
+ * Initialize ivue singleton instance.
134
+ *
135
+ * @param className Class constructor
136
+ * @param args Class constructor arguments
137
+ * @returns @see IVue
138
+ */
139
+ use<T extends AnyClass>(className: T, ...args: InferredArgs<T>): IVue<T>;
140
+ /**
141
+ * Initialize ivue transient instance.
142
+ *
143
+ * @param className Class constructor
144
+ * @param args Class constructor arguments
145
+ * @returns @see IVue
146
+ */
147
+ init<T extends AnyClass>(className: T, ...args: InferredArgs<T>): IVue<T>;
148
+ }
149
+ /**
150
+ * Any class initializer callback for Kernel Mapping.
151
+ *
152
+ * @param mapping @see Mapping
153
+ * @param args
154
+ * @returns
155
+ */
156
+ export declare function onInit<T extends AnyClass>(mapping: Mapping, ...args: InferredArgs<T>): any;
157
+ /**
158
+ * Activation method to use with Inversify IOC library.
159
+ *
160
+ * @param ctx
161
+ * @param obj
162
+ * @param args
163
+ */
164
+ export declare function ivueInversify(ctx: any, obj: any, ...args: any): any;
165
+ /**
166
+ * Kernel API exported procedural shortcuts.
167
+ */
168
+ /**
169
+ * Kernel instance kernel & .bind method
170
+ */
171
+ export declare const kernel: Kernel;
172
+ export declare const bind: any;
173
+ /**
174
+ * Kernel container getters for plain JavaScript classes.
175
+ */
176
+ export declare const get: any;
177
+ export declare const make: any;
178
+ /**
179
+ * Kernel container getters for ivue reactive JavaScript classes.
180
+ */
181
+ export declare const use: any;
182
+ export declare const init: any;
@@ -0,0 +1,9 @@
1
+ import type { AnyClass } from '../types/core';
2
+ export declare class UseCapsule {
3
+ $: InstanceType<this['capsule']>;
4
+ capsule: AnyClass | any;
5
+ useCapsule(args?: any): void;
6
+ initCapsule(args?: any): void;
7
+ getCapsule(args?: any): void;
8
+ makeCapsule(args?: any): void;
9
+ }
@@ -0,0 +1,3 @@
1
+ export declare class UseEmit {
2
+ $emit: Function;
3
+ }
@@ -0,0 +1,6 @@
1
+ import type { Class } from '../types/core';
2
+ export declare function useInstance(mainClass: Class, self: UseInstance | any): void;
3
+ export declare class UseInstance {
4
+ get $instance(): import("vue").ComponentInternalInstance;
5
+ constructor(mainClass: Class);
6
+ }
@@ -0,0 +1,11 @@
1
+ import { type Class } from '../types/core';
2
+ import { onMounted, onUnmounted, onBeforeMount, onBeforeUnmount } from 'vue';
3
+ export declare function useMounting(mainClass: Class, obj: UseMounting | any): void;
4
+ /** Make a class useMounting to a Vue component */
5
+ export declare class UseMounting {
6
+ constructor(mainClass: Class);
7
+ beforeMount?: ReturnType<typeof onBeforeMount>;
8
+ mounted?: ReturnType<typeof onMounted>;
9
+ beforeUnmount?: ReturnType<typeof onBeforeUnmount>;
10
+ unmounted?: ReturnType<typeof onUnmounted>;
11
+ }
@@ -0,0 +1,8 @@
1
+ import type { Class } from '../types/core';
2
+ export declare function useRefs(mainClass: Class, obj: any): void;
3
+ export declare class UseRefs {
4
+ get $refs(): {
5
+ [x: string]: unknown;
6
+ };
7
+ constructor(mainClass: Class);
8
+ }
@@ -0,0 +1,3 @@
1
+ export declare class UseRoute {
2
+ get route(): any;
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare class UseRouter {
2
+ get router(): any;
3
+ }
@@ -0,0 +1,6 @@
1
+ import { UseRouter } from './UseRouter';
2
+ import { UseRoute } from './UseRoute';
3
+ export declare class UseRouting {
4
+ }
5
+ export interface UseRouting extends UseRouter, UseRoute {
6
+ }
@@ -0,0 +1,4 @@
1
+ import { nextTick } from 'vue';
2
+ export declare class UseTick {
3
+ $nextTick: typeof nextTick;
4
+ }
@@ -0,0 +1,13 @@
1
+ import type { Class } from '../types/core';
2
+ import { UseMounting } from './UseMounting';
3
+ import { UseRouting } from './UseRouting';
4
+ import { UseRefs } from './UseRefs';
5
+ import { UseEmit } from './UseEmit';
6
+ import { UseTick } from './UseTick';
7
+ import { UseInstance } from './UseInstance';
8
+ export declare function useVue(mainClass: Class, obj: UseVue | any): void;
9
+ export declare class UseVue {
10
+ constructor(mainClass: Class);
11
+ }
12
+ export interface UseVue extends UseRouting, UseMounting, UseEmit, UseTick, UseRefs, UseInstance {
13
+ }
@@ -0,0 +1,46 @@
1
+ import type { Mapping } from '../kernel';
2
+ import type { ComputedRef } from 'vue';
3
+ export type AnyClass = abstract new (...args: any) => any;
4
+ export type Class = {
5
+ behavior?: any;
6
+ new (...args: any[]): any;
7
+ [x: string | symbol]: any;
8
+ };
9
+ export type IVue<T extends AnyClass> = InstanceType<T> & IVueToRefs<T>;
10
+ /**
11
+ * @see ivueTransform
12
+ */
13
+ export interface IVueToRefs<T extends AnyClass> {
14
+ toRefs: (...args: any) => InstanceType<T>;
15
+ }
16
+ export interface IVueToRefsObj<T extends object> {
17
+ toRefs: (...args: any) => T;
18
+ }
19
+ export type MappingScope = 'singleton' | 'transient';
20
+ export type MappingType = 'generic' | 'ivue' | any;
21
+ export type InferredArgs<T> = T extends {
22
+ new (...args: infer P): any;
23
+ } ? P : never[];
24
+ export type Getters = Map<string | symbol | number, PropertyDescriptor>;
25
+ export interface Intercept {
26
+ return: any;
27
+ mapping: Mapping;
28
+ name?: string;
29
+ self: any;
30
+ args: any;
31
+ }
32
+ export type InterceptOptions = {
33
+ top: boolean;
34
+ scoped: boolean;
35
+ };
36
+ export type InterceptFn = (intercept: Intercept, self: Object, prop: string) => void | true;
37
+ export type InterceptsMap = {
38
+ before: Map<Function | Class, InterceptFn[]>;
39
+ after: Map<Function | Class, InterceptFn[]>;
40
+ };
41
+ export type InterceptAttachTo = Function | [Class, Function];
42
+ export type InterceptsFns = InterceptFn[] | undefined | any;
43
+ export type Null<T> = T | null;
44
+ export type AnyObj = Record<string | number | symbol, any>;
45
+ export type Params<T extends (...args: any) => any> = Parameters<T>;
46
+ export type Computeds = Record<string | symbol | number, ComputedRef>;
@@ -0,0 +1,12 @@
1
+ import type { AnyClass, IVue } from "..";
2
+ /**
3
+ * Advanced garbage disposal for complete memory control.
4
+ * Disposes an internal object that is under the vue reactive proxy.
5
+ * To expose the raw property, toRaw(vue) method is used
6
+ * to retrieve the original object.
7
+ *
8
+ * @param vue ivue instance
9
+ * @param getters @see Getters
10
+ * @param name string
11
+ */
12
+ export declare const disposeGarbage: <T extends AnyClass>(vue: any) => void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Advanced deep merge of two or more objects.
3
+ * Merges sources into target iterating from left to right.
4
+ * Supports circular references and promises.
5
+ * Merges and modifies the target object.
6
+ * Only simple objects can extend the target, yet the
7
+ * target can be anything, even a class object.
8
+ *
9
+ * @param target object
10
+ * @param sources array
11
+ */
12
+ export declare function extend(target: any, ...sources: any[]): any;
@@ -0,0 +1,21 @@
1
+ import type { Getters } from '../types/core';
2
+ /**
3
+ * Store all getters for each class prototype processed by getPrototypeGetters.
4
+ * @see getPrototypeGetters
5
+ */
6
+ export declare const gettersMap: Map<any, any>;
7
+ /**
8
+ * Get getters of a class prototype as a map.
9
+ *
10
+ * @param proto
11
+ * @return Getters
12
+ */
13
+ export declare function getPrototypeGetters(proto: object | null): any;
14
+ /**
15
+ * Get getters of a class instance and the total number of them.
16
+ * @param instance Object instance
17
+ * @returns Getter descriptors
18
+ */
19
+ export declare function getInstanceGetters(instance: {
20
+ [x: string]: any;
21
+ }): Getters;
@@ -0,0 +1,7 @@
1
+ import { raw, unraw } from './raw';
2
+ import { extend } from './extend';
3
+ import { Traits } from './traits';
4
+ import { getPrototypeGetters, getInstanceGetters } from './getters';
5
+ import { safeClassName } from './safe-class-name';
6
+ import { pre } from './pre';
7
+ export { raw, unraw, extend, Traits, getPrototypeGetters, getInstanceGetters, safeClassName, pre };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Determine if the value is a true Object.
3
+ *
4
+ * @param v any value
5
+ * @returns boolean
6
+ */
7
+ export declare function isObject(v: any): boolean;
8
+ /**
9
+ * Determine if the value is a Promise.
10
+ *
11
+ * @param v any value
12
+ * @returns boolean
13
+ */
14
+ export declare function isPromise(v: any): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Pretty print an object that can contain circular references.
3
+ *
4
+ * @param v object to print
5
+ * @param spaces number of spaces for tabs
6
+ * @returns pretty string
7
+ * @source https://stackoverflow.com/a/48254637
8
+ */
9
+ export declare function pre(v: any, spaces?: number): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Convert object back to Vue reactive.
3
+ *
4
+ * @param obj
5
+ */
6
+ export declare function unraw(obj: any): void;
7
+ /**
8
+ * Alias for Vue markRaw() function.
9
+ *
10
+ * @param obj
11
+ */
12
+ export declare function raw(obj: any): any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Convert class name, symbol to string.
3
+ *
4
+ * @param className
5
+ * @returns
6
+ */
7
+ export declare function safeClassName(className: any): string;
@@ -0,0 +1,41 @@
1
+ import type { Class } from '../types/core';
2
+ /**
3
+ * Traits architecture that supports methods, properties, getters and setters.
4
+ *
5
+ * Traits override each other, while traits can set new props onto
6
+ * the main prototype, they cannot override the main prototypes'
7
+ * props if the main prototype had them already initially.
8
+ *
9
+ * Traits override each other, left most traits having higher priority, matching
10
+ * TypeScript's interface `interface Class extends Trait1, Trait2, Trait3 {}`
11
+ * architecture, enabling us to have full TypeScript & IDE support:
12
+ *
13
+ * Example:
14
+ * ```ts
15
+ * class MainClass {}
16
+ *
17
+ * class Trait1 {
18
+ * get prop () { return 3 }
19
+ * }
20
+ *
21
+ * class Trait2 {
22
+ * get prop () { return 2 }
23
+ * }
24
+ *
25
+ * class Trait3 {
26
+ * get prop () { return 3 }
27
+ * }
28
+ *
29
+ * Traits(MainClass, [Trait1, Trait2, Trait3])
30
+ * export interface MainClass extends Trait1, Trait2, Trait3 {}
31
+ * ```
32
+ *
33
+ * Trait1 props will override Traits2 & Traits3 properties,
34
+ * but will not override MainClass properties if set.
35
+ *
36
+ * Inspired by TypeScript docs: https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern
37
+ *
38
+ * @param main
39
+ * @param traits
40
+ */
41
+ export declare function Traits(main: Class, traits: Class[]): void;
package/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <link rel="icon" href="/favicon.ico">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Vite App</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="./demo/main.ts"></script>
12
+ </body>
13
+ </html>