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.
- package/.babelrc.json +14 -0
- package/.eslintrc.cjs +24 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/compiler.xml +7 -0
- package/.idea/infinite-vue.iml +10 -0
- package/.idea/inspectionProfiles/Project_Default.xml +11 -0
- package/.idea/modules.xml +8 -0
- package/.idea/php.xml +20 -0
- package/.idea/vcs.xml +6 -0
- package/.vscode/extensions.json +3 -0
- package/LICENSE +19 -0
- package/README.md +31 -0
- package/demo/App.vue +72 -0
- package/demo/components/IVueTest.vue +298 -0
- package/demo/components/PreComponent.vue +13 -0
- package/demo/components/SubComponent2.vue +45 -0
- package/demo/components/TraitsComponent.vue +120 -0
- package/demo/components/useIVueTest.vue +136 -0
- package/demo/main.ts +21 -0
- package/demo/router/index.ts +14 -0
- package/demo/tests/IVueTests.ts +255 -0
- package/demo/tests/Mouse.ts +79 -0
- package/demo/tests/ParentIVueTests.ts +36 -0
- package/demo/tests/TApp.ts +15 -0
- package/demo/tests/TAuth.ts +23 -0
- package/demo/tests/TField.ts +84 -0
- package/demo/tests/TMessage.ts +52 -0
- package/demo/tests/TRouter.ts +18 -0
- package/demo/tests/TUser.ts +19 -0
- package/demo/tests/Test.ts +86 -0
- package/demo/tests/useField.ts +82 -0
- package/demo/tests/useIVueTests.ts +57 -0
- package/demo/vite.config.ts +13 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.es.js +518 -0
- package/dist/index.umd.js +1 -0
- package/dist/src/behavior.d.ts +72 -0
- package/dist/src/config.d.ts +6 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/ivue.d.ts +35 -0
- package/dist/src/kernel.d.ts +182 -0
- package/dist/src/traits/UseCapsule.d.ts +9 -0
- package/dist/src/traits/UseEmit.d.ts +3 -0
- package/dist/src/traits/UseInstance.d.ts +6 -0
- package/dist/src/traits/UseMounting.d.ts +11 -0
- package/dist/src/traits/UseRefs.d.ts +8 -0
- package/dist/src/traits/UseRoute.d.ts +3 -0
- package/dist/src/traits/UseRouter.d.ts +3 -0
- package/dist/src/traits/UseRouting.d.ts +6 -0
- package/dist/src/traits/UseTick.d.ts +4 -0
- package/dist/src/traits/UseVue.d.ts +13 -0
- package/dist/src/types/core.d.ts +46 -0
- package/dist/src/utils/dispose-garbage.d.ts +12 -0
- package/dist/src/utils/extend.d.ts +12 -0
- package/dist/src/utils/getters.d.ts +21 -0
- package/dist/src/utils/index.d.ts +7 -0
- package/dist/src/utils/is.d.ts +14 -0
- package/dist/src/utils/pre.d.ts +9 -0
- package/dist/src/utils/raw.d.ts +12 -0
- package/dist/src/utils/safe-class-name.d.ts +7 -0
- package/dist/src/utils/traits.d.ts +41 -0
- package/env.d.ts +1 -0
- package/index.html +13 -0
- package/package-lock.json +14305 -0
- package/package.json +89 -10
- package/public/favicon.ico +0 -0
- package/src/App/App.ts +27 -0
- package/src/App/Auth/Auth.ts +105 -0
- package/src/App/Auth/Auth.vue +98 -0
- package/src/App/Auth/Logout.vue +14 -0
- package/src/App/Auth/User.ts +6 -0
- package/src/App/BlackBox.ts +75 -0
- package/src/App/Config.ts +6 -0
- package/src/App/Generators/generators.ts +47 -0
- package/src/App/Home/Home.vue +16 -0
- package/src/App/Services/Http/FakeHttp.ts +8 -0
- package/src/App/Services/Http/Http.ts +51 -0
- package/src/App/Services/Message/Message.ts +49 -0
- package/src/App/Services/Message/Message.vue +15 -0
- package/src/App/Services/Navigation/Navigation.ts +83 -0
- package/src/App/Services/Navigation/Navigation.vue +59 -0
- package/src/App/Services/Routing/FakeRouter.ts +7 -0
- package/src/App/Services/Routing/NotFoundRoute.vue +13 -0
- package/src/App/Services/Routing/Router.ts +262 -0
- package/src/App/Services/Routing/Routes.ts +49 -0
- package/src/App/Stubs/SingleBookResultStub.ts +13 -0
- package/src/App/Traits/UseApp.ts +6 -0
- package/src/App/Traits/UseBlackline.ts +0 -0
- package/src/App/Traits/UseQuasar.ts +8 -0
- package/src/behavior.ts +269 -0
- package/src/config.ts +15 -0
- package/src/dev/dev-utils.ts +78 -0
- package/src/index.ts +83 -0
- package/src/ivue.ts +296 -0
- package/src/kernel.ts +810 -0
- package/src/tests/auth.spec.ts +48 -0
- package/src/traits/UseCapsule.ts +28 -0
- package/src/traits/UseEmit.ts +3 -0
- package/src/traits/UseInstance.ts +17 -0
- package/src/traits/UseMounting.ts +23 -0
- package/src/traits/UseRefs.ts +17 -0
- package/src/traits/UseRoute.ts +6 -0
- package/src/traits/UseRouter.ts +5 -0
- package/src/traits/UseRouting.ts +7 -0
- package/src/traits/UseTick.ts +5 -0
- package/src/traits/UseVue.ts +38 -0
- package/src/types/core.ts +64 -0
- package/src/utils/dispose-garbage.ts +34 -0
- package/src/utils/extend.ts +85 -0
- package/src/utils/getters.ts +62 -0
- package/src/utils/index.ts +16 -0
- package/src/utils/is.ts +22 -0
- package/src/utils/pre.ts +29 -0
- package/src/utils/raw.ts +19 -0
- package/src/utils/safe-class-name.ts +15 -0
- package/src/utils/traits.ts +121 -0
- package/tsconfig.app.json +47 -0
- package/tsconfig.json +14 -0
- package/tsconfig.node.json +14 -0
- package/tsconfig.vitest.json +9 -0
- package/vite.config.ts +55 -0
- package/vitest.config.ts +18 -0
- package/dist/index.js +0 -218
- package/docs/index.html +0 -195
- package/docs/index.json +0 -3
- package/docs/input.html +0 -41
- package/docs/items.html +0 -42
- package/gulpfile.js +0 -5
- package/src/components/checkbox.js +0 -47
- package/src/components/data.js +0 -6
- package/src/components/file.js +0 -40
- package/src/components/form.js +0 -7
- package/src/components/index.js +0 -15
- package/src/components/input.js +0 -80
- package/src/components/items.js +0 -65
- package/src/components/modal.js +0 -42
- package/src/components/paginate-old.js +0 -88
- package/src/components/paginate.js +0 -35
- package/src/components/select-search.js +0 -152
- package/src/components/select.js +0 -62
- package/src/components/submit.js +0 -10
- package/src/components/textarea.js +0 -72
- package/src/components/upload.js +0 -49
- package/src/directives/href.js +0 -10
- package/src/directives/index.js +0 -1
- package/src/filters/date.js +0 -3
- package/src/filters/datetime.js +0 -3
- package/src/filters/index.js +0 -4
- package/src/filters/json.js +0 -3
- package/src/filters/money.js +0 -3
- package/src/index.js +0 -4
- package/src/mixins/data.js +0 -13
- package/src/mixins/form.js +0 -85
- package/src/mixins/resource.js +0 -31
- package/src/services/client.js +0 -32
- package/src/services/flash.js +0 -17
- package/src/services/index.js +0 -2
package/src/behavior.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { effectScope, type EffectScope } from 'vue'
|
|
2
|
+
import { Mapping } from './kernel'
|
|
3
|
+
import { tryOnScopeDispose } from "@vueuse/core";
|
|
4
|
+
import type { AnyClass, Class, Null } from './types/core'
|
|
5
|
+
import type { InterceptsFns, Intercept, InterceptsMap, InterceptFn, InterceptOptions, InterceptAttachTo } from './types/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hash maps for all available intercept methods.
|
|
9
|
+
*/
|
|
10
|
+
export const intercepts: InterceptsMap = {
|
|
11
|
+
before: new Map(),
|
|
12
|
+
after: new Map()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Run intercept attached to the Class constructor.
|
|
17
|
+
*
|
|
18
|
+
* @param type
|
|
19
|
+
* @param mapping
|
|
20
|
+
* @param intercept
|
|
21
|
+
* @return
|
|
22
|
+
*/
|
|
23
|
+
export function interceptConstructor (
|
|
24
|
+
type: keyof InterceptsMap, obj: any, intercept: Intercept
|
|
25
|
+
) {
|
|
26
|
+
const fns = intercepts[type].get(obj) as InterceptsFns
|
|
27
|
+
for (let i = 0; i < fns?.length; i++)
|
|
28
|
+
if (true === fns[i](intercept, ...intercept.args))
|
|
29
|
+
return intercept.return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Add intercept to prototype or instance method.
|
|
34
|
+
*
|
|
35
|
+
* @param type
|
|
36
|
+
* @param fn
|
|
37
|
+
* @param callback
|
|
38
|
+
* @param opts
|
|
39
|
+
*/
|
|
40
|
+
function addIntercept (type: keyof InterceptsMap, fn: InterceptFn, callback: any, opts: InterceptOptions) {
|
|
41
|
+
if (intercepts[type].has(fn)) {
|
|
42
|
+
intercepts[type].get(fn)?.[opts.top ? 'unshift' : 'push'](callback)
|
|
43
|
+
} else {
|
|
44
|
+
intercepts[type].set(fn, [callback])
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Autobinds intercept to the class method automatically or directly.
|
|
50
|
+
* This way there is no need to specify an intercept via behavior prop
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* class Example {
|
|
54
|
+
* behavior: {
|
|
55
|
+
* methodName: IVUE.SCOPED_INTERCEPT,
|
|
56
|
+
* methodName2: IVUE.INTERCEPT
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
* You can just do:
|
|
61
|
+
* class Example {} without the behavior prop and attach the event like this:
|
|
62
|
+
*
|
|
63
|
+
* ```
|
|
64
|
+
* before([Example, Examplpe.prototype.methodName], function (intercept) {
|
|
65
|
+
* intercept.return = 100
|
|
66
|
+
* return true
|
|
67
|
+
* })
|
|
68
|
+
* ```
|
|
69
|
+
* @param to Attach to this Function or [Class, Function].
|
|
70
|
+
* @param scoped Whether we want to enable scope disposal for memory leak control.
|
|
71
|
+
* @returns Function or Class to attach the intercept event function to.
|
|
72
|
+
*/
|
|
73
|
+
function autobindIntercept (to: Function | [Class, Function], scoped: boolean): InterceptFn {
|
|
74
|
+
|
|
75
|
+
if (Array.isArray(to)) {
|
|
76
|
+
|
|
77
|
+
if (typeof to[0] !== 'function') {
|
|
78
|
+
throw new Error('ivue.kernel.behavior: Cannot autobind intercept to ' + to[0] + '. Supply a valid Class to autobind behavior.')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (typeof to[1] === 'function') {
|
|
82
|
+
|
|
83
|
+
// Analyze function definition
|
|
84
|
+
const fnString = to[1].toString()
|
|
85
|
+
const isClass = fnString.substring(0, 5) === 'class'
|
|
86
|
+
|
|
87
|
+
if (!isClass) {
|
|
88
|
+
// Determine function name
|
|
89
|
+
const firstBrace = fnString.indexOf('(')
|
|
90
|
+
let [maybeAsync, funcName] = fnString.substring(0, firstBrace).split(' ')
|
|
91
|
+
funcName = maybeAsync === 'async' ? funcName : maybeAsync
|
|
92
|
+
|
|
93
|
+
// Attach behavior
|
|
94
|
+
to[0].behavior = {
|
|
95
|
+
...(typeof to[0].behavior === 'object' ? to[0].behavior : {}),
|
|
96
|
+
funcName: scoped ? IVUE.SCOPED_INTERCEPT : IVUE.INTERCEPT
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// resolved function
|
|
101
|
+
return to[1] as InterceptFn
|
|
102
|
+
} else {
|
|
103
|
+
throw new Error('ivue.kernel.behavior: Cannot autobind intercept "' + to[1] + '" to ' + (to[0]?.name ?? to[0]))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return to as InterceptFn
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Function to run before an interceptable method in ivue.
|
|
112
|
+
*
|
|
113
|
+
* @param fn
|
|
114
|
+
* @param callback
|
|
115
|
+
* @param opts
|
|
116
|
+
*/
|
|
117
|
+
export function before (
|
|
118
|
+
to: InterceptAttachTo,
|
|
119
|
+
callback: InterceptFn,
|
|
120
|
+
opts: InterceptOptions = {
|
|
121
|
+
top: false,
|
|
122
|
+
scoped: false
|
|
123
|
+
}
|
|
124
|
+
) {
|
|
125
|
+
addIntercept('before', autobindIntercept(to, opts.scoped), callback, opts)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Function to run after an interceptable method in ivue.
|
|
130
|
+
*
|
|
131
|
+
* @param fn
|
|
132
|
+
* @param callback
|
|
133
|
+
* @param opts
|
|
134
|
+
*/
|
|
135
|
+
export function after (
|
|
136
|
+
to: InterceptAttachTo,
|
|
137
|
+
callback: InterceptFn,
|
|
138
|
+
opts: InterceptOptions = {
|
|
139
|
+
top: false,
|
|
140
|
+
scoped: false
|
|
141
|
+
}
|
|
142
|
+
) {
|
|
143
|
+
addIntercept('after', autobindIntercept(to, opts.scoped), callback, opts)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Run method intercepts.
|
|
148
|
+
*
|
|
149
|
+
* @param type
|
|
150
|
+
* @param self
|
|
151
|
+
* @param prop
|
|
152
|
+
* @param args
|
|
153
|
+
* @param intercept
|
|
154
|
+
*/
|
|
155
|
+
export function interceptMethod (type: keyof InterceptsMap, self: Class, prop: string, args: any[], intercept: Intercept) {
|
|
156
|
+
|
|
157
|
+
// Run intercepts that are attached to the prototype of the self object
|
|
158
|
+
let fns: InterceptsFns = intercepts[type].get(self.constructor.prototype[prop])
|
|
159
|
+
for (let i = 0; i < fns?.length; i++) {
|
|
160
|
+
if (true === fns[i](intercept, ...args))
|
|
161
|
+
return true // return true -> to short circuit the execution chain
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Run intercepts that are attached to the instance of self itself
|
|
165
|
+
fns = intercepts[type].get(self[prop])
|
|
166
|
+
for (let i = 0; i < fns?.length; i++) {
|
|
167
|
+
if (true === fns[i](intercept, ...args))
|
|
168
|
+
return true // return true -> to short circuit the execution chain
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// If there is no short circuit, we should return undefined like a function without a return
|
|
172
|
+
return void (0)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Behavior definitions:
|
|
177
|
+
*
|
|
178
|
+
* SCOPED: Allows watch(), computed(), watchEffect() to be auto garbage collected.
|
|
179
|
+
*
|
|
180
|
+
* SCOPED_INTERCEPT: Allows scoping AND before & after method intercepts.
|
|
181
|
+
*
|
|
182
|
+
* INTERCEPT: Allows before & after method intercepts only,
|
|
183
|
+
* watch(), computed(), watchEffect() will NOT be garbage collected.
|
|
184
|
+
*
|
|
185
|
+
* OFF: For objects -> makes them markRaw() non-reactive,
|
|
186
|
+
* For getters -> makes them non-computed normal getters.
|
|
187
|
+
*/
|
|
188
|
+
export enum IVUE {
|
|
189
|
+
SCOPED = 'SCOPED',
|
|
190
|
+
SCOPED_INTERCEPT = 'SCOPED_INTERCEPT',
|
|
191
|
+
INTERCEPT = 'INTERCEPT',
|
|
192
|
+
OFF = 'OFF'
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Override function depending on behavior type.
|
|
197
|
+
* @see IVUE
|
|
198
|
+
*
|
|
199
|
+
* @param type
|
|
200
|
+
* @param func
|
|
201
|
+
* @param self
|
|
202
|
+
* @param prop
|
|
203
|
+
*/
|
|
204
|
+
export function changeMethodBehavior<T extends AnyClass> (mapping: Mapping, type: IVUE, func: Function, self: Class, prop: string, scope: EffectScope, intercept: Intercept) {
|
|
205
|
+
// Define a default void return
|
|
206
|
+
let result = void (0)
|
|
207
|
+
// Handle basic scoped most often scenario early
|
|
208
|
+
// Usually the init() function
|
|
209
|
+
if (type === IVUE.SCOPED) {
|
|
210
|
+
// Inside scoped you can put watch(), computed(), watchEffect()
|
|
211
|
+
// and it will be auto garbage collected on scope destruction
|
|
212
|
+
return Object.defineProperty(self, prop, {
|
|
213
|
+
value: function (...args: any) {
|
|
214
|
+
scope.run(() => result = func.bind(self)(...args))
|
|
215
|
+
return result
|
|
216
|
+
},
|
|
217
|
+
writable: true,
|
|
218
|
+
configurable: true,
|
|
219
|
+
enumerable: false
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Process the interceptable methods.
|
|
225
|
+
*
|
|
226
|
+
* @param args
|
|
227
|
+
* @returns
|
|
228
|
+
*/
|
|
229
|
+
const processMethodIntercept = (...args: any) => {
|
|
230
|
+
|
|
231
|
+
intercept = { mapping, self, return: result, name: prop, args }
|
|
232
|
+
|
|
233
|
+
if (true === interceptMethod('before', self, prop, args, intercept))
|
|
234
|
+
return intercept.return // short circuit, if intercept returns true
|
|
235
|
+
|
|
236
|
+
result = func.bind(self)(...args)
|
|
237
|
+
intercept.return = result
|
|
238
|
+
|
|
239
|
+
if (true === interceptMethod('after', self, prop, args, intercept))
|
|
240
|
+
return intercept.return // short circuit, if intercept returns true
|
|
241
|
+
|
|
242
|
+
return intercept.return
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
switch (type) {
|
|
246
|
+
case IVUE.INTERCEPT:
|
|
247
|
+
// Basic, fast, non-scoped intercepts
|
|
248
|
+
return Object.defineProperty(self, prop, {
|
|
249
|
+
value: function (...args: any) {
|
|
250
|
+
return processMethodIntercept(...args)
|
|
251
|
+
},
|
|
252
|
+
writable: true,
|
|
253
|
+
configurable: true,
|
|
254
|
+
enumerable: false
|
|
255
|
+
})
|
|
256
|
+
case IVUE.SCOPED_INTERCEPT:
|
|
257
|
+
// Inside scoped you can put watch(), computed(), watchEffect()
|
|
258
|
+
// and it will be auto garbage collected on scope destruction
|
|
259
|
+
return Object.defineProperty(self, prop, {
|
|
260
|
+
value: function (...args: any) {
|
|
261
|
+
scope.run(() => result = processMethodIntercept(...args))
|
|
262
|
+
return result
|
|
263
|
+
},
|
|
264
|
+
writable: true,
|
|
265
|
+
configurable: true,
|
|
266
|
+
enumerable: false
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { extend } from "./utils"
|
|
2
|
+
|
|
3
|
+
export type Config = {
|
|
4
|
+
router?: any,
|
|
5
|
+
debug?: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export let config: Config = {
|
|
9
|
+
router: null,
|
|
10
|
+
debug: false
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function setup (options: Config = {}) {
|
|
14
|
+
extend(config, options)
|
|
15
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functions in this file were created during development
|
|
3
|
+
* process, but are not actually used in the final files.
|
|
4
|
+
*
|
|
5
|
+
* They are good resources to derive other functions
|
|
6
|
+
* or use in other projects.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const magicPropsMap = new Map()
|
|
10
|
+
/**
|
|
11
|
+
* Get all magic properties (getters & setters) of an object instance.
|
|
12
|
+
*
|
|
13
|
+
* @param instance
|
|
14
|
+
*/
|
|
15
|
+
export function getMagicProperties (instance) {
|
|
16
|
+
|
|
17
|
+
let proto = Object.getPrototypeOf(instance)
|
|
18
|
+
|
|
19
|
+
if (magicPropsMap.has(proto)) {
|
|
20
|
+
// console.log('from map!!', proto)
|
|
21
|
+
return magicPropsMap.get(proto)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const originalPrototype = proto
|
|
25
|
+
|
|
26
|
+
let props: string[] | undefined = []
|
|
27
|
+
while (proto && proto.constructor.name !== 'Object') {
|
|
28
|
+
const protoProps = Object.entries(
|
|
29
|
+
Object.getOwnPropertyDescriptors(proto)
|
|
30
|
+
)
|
|
31
|
+
// eslint-disable-next-line prefer-spread
|
|
32
|
+
props.push.apply(props, protoProps)
|
|
33
|
+
proto = Object.getPrototypeOf(proto.constructor.prototype)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const magicProps = { get: {}, set: {} }
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < props.length; i++) {
|
|
39
|
+
if (props[i][0] !== '__proto__') {
|
|
40
|
+
if (typeof props[i][1].get === 'function') {
|
|
41
|
+
// getters
|
|
42
|
+
magicProps.get[props[i][0]] = true
|
|
43
|
+
}
|
|
44
|
+
if (typeof props[i][1].set === 'function') {
|
|
45
|
+
// setters
|
|
46
|
+
magicProps.set[props[i][0]] = true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
props = undefined
|
|
52
|
+
magicPropsMap.set(originalPrototype, magicProps)
|
|
53
|
+
|
|
54
|
+
return magicProps
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get all object properties including all ancestor prototype properties.
|
|
59
|
+
*
|
|
60
|
+
* @param obj
|
|
61
|
+
*/
|
|
62
|
+
export function getAllProperties (obj) {
|
|
63
|
+
|
|
64
|
+
let proto = Object.getPrototypeOf(obj)
|
|
65
|
+
const props = Object.getOwnPropertyNames(obj)
|
|
66
|
+
|
|
67
|
+
// this determines all the ancestor prototype props as well
|
|
68
|
+
while (proto && proto.constructor.name !== 'Object') {
|
|
69
|
+
const protoProps = Object.getOwnPropertyNames(proto)
|
|
70
|
+
// caller, callee, arguments are not accessible so should be skipped
|
|
71
|
+
.filter(el => !['caller', 'callee', 'arguments'].includes(el))
|
|
72
|
+
// eslint-disable-next-line prefer-spread
|
|
73
|
+
props.push.apply(props, protoProps)
|
|
74
|
+
proto = Object.getPrototypeOf(proto.constructor.prototype)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return Array.from(new Set(props))
|
|
78
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Null, AnyObj, AnyClass, Class, Params,
|
|
3
|
+
IVue, IVueToRefs, IVueToRefsObj,
|
|
4
|
+
MappingScope, MappingType, InferredArgs, Getters,
|
|
5
|
+
InterceptsMap, Intercept, InterceptOptions,
|
|
6
|
+
InterceptsFns, InterceptFn, InterceptAttachTo,
|
|
7
|
+
} from "./types/core"
|
|
8
|
+
|
|
9
|
+
import { config, setup } from "./config"
|
|
10
|
+
|
|
11
|
+
import { ivue, iobj, ivueTransform } from "./ivue"
|
|
12
|
+
|
|
13
|
+
import { Mapping, Kernel, kernel, ivueInversify, bind, get, make, use, init } from "./kernel"
|
|
14
|
+
|
|
15
|
+
import { IVUE, after, before } from "./behavior"
|
|
16
|
+
|
|
17
|
+
import { raw, unraw, Traits, extend, pre } from "./utils"
|
|
18
|
+
|
|
19
|
+
import { UseCapsule } from './traits/UseCapsule';
|
|
20
|
+
import { UseInstance } from './traits/UseInstance';
|
|
21
|
+
import { UseMounting } from './traits/UseMounting';
|
|
22
|
+
import { UseRefs } from './traits/UseRefs';
|
|
23
|
+
import { UseRoute } from './traits/UseRoute';
|
|
24
|
+
import { UseRouter } from './traits/UseRouter';
|
|
25
|
+
import { UseRouting } from './traits/UseRouting';
|
|
26
|
+
import { UseEmit } from './traits/UseEmit';
|
|
27
|
+
import { UseTick } from './traits/UseTick';
|
|
28
|
+
import { UseVue } from './traits/UseVue';
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
// Config
|
|
32
|
+
config,
|
|
33
|
+
setup,
|
|
34
|
+
|
|
35
|
+
// ivue
|
|
36
|
+
ivue,
|
|
37
|
+
iobj,
|
|
38
|
+
ivueTransform,
|
|
39
|
+
|
|
40
|
+
// Kernel
|
|
41
|
+
Mapping, // class
|
|
42
|
+
Kernel, // class
|
|
43
|
+
ivueInversify,
|
|
44
|
+
kernel,
|
|
45
|
+
bind,
|
|
46
|
+
get,
|
|
47
|
+
make,
|
|
48
|
+
use,
|
|
49
|
+
init,
|
|
50
|
+
|
|
51
|
+
// Behavior
|
|
52
|
+
IVUE, // enum
|
|
53
|
+
before,
|
|
54
|
+
after,
|
|
55
|
+
|
|
56
|
+
// Traits
|
|
57
|
+
UseCapsule,
|
|
58
|
+
UseEmit,
|
|
59
|
+
UseInstance,
|
|
60
|
+
UseMounting,
|
|
61
|
+
UseRefs,
|
|
62
|
+
UseRoute,
|
|
63
|
+
UseRouter,
|
|
64
|
+
UseRouting,
|
|
65
|
+
UseTick,
|
|
66
|
+
UseVue,
|
|
67
|
+
|
|
68
|
+
// Utils
|
|
69
|
+
raw,
|
|
70
|
+
unraw,
|
|
71
|
+
Traits,
|
|
72
|
+
extend,
|
|
73
|
+
pre
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Types
|
|
77
|
+
export type {
|
|
78
|
+
Null, AnyObj, AnyClass, Class, Params,
|
|
79
|
+
IVue, IVueToRefs, IVueToRefsObj,
|
|
80
|
+
MappingScope, MappingType, InferredArgs, Getters,
|
|
81
|
+
InterceptsMap, Intercept, InterceptOptions,
|
|
82
|
+
InterceptsFns, InterceptFn, InterceptAttachTo,
|
|
83
|
+
}
|