vue-spear-tip 0.1.2 → 0.1.4
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/package.json +36 -10
- package/.github/workflows/publish.yml +0 -25
- package/index.cjs +0 -5
- package/index.d.cts +0 -0
- package/index.d.ts +0 -0
- package/index.js +0 -5
- package/src/Interfaces/IBaseVueComponent.ts +0 -7
- package/src/Interfaces/IVueClass.ts +0 -226
- package/src/components/BaseComponent.vue +0 -22
- package/src/core/Computed.ts +0 -38
- package/src/core/Props.ts +0 -70
- package/src/core/VueClass.ts +0 -79
- package/src/core/VueClassComponent.ts +0 -347
- package/src/core/Watch.ts +0 -45
- package/src/core/index.ts +0 -9
- package/tsconfig.json +0 -14
- package/vite.config.ts +0 -0
package/package.json
CHANGED
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-spear-tip",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./
|
|
6
|
-
"module": "./
|
|
5
|
+
"main": "./dist/vue-spear-tip.cjs.js",
|
|
6
|
+
"module": "./dist/vue-spear-tip.es.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"build:examples": "vite build --mode examples",
|
|
10
|
+
"dev": "vite dev"
|
|
11
|
+
},
|
|
7
12
|
"exports": {
|
|
8
13
|
".": {
|
|
9
|
-
"
|
|
10
|
-
"require": "./index.cjs",
|
|
11
|
-
"types": {
|
|
12
|
-
"require": "./index.d.cts",
|
|
13
|
-
"default": "./index.d.ts"
|
|
14
|
-
}
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
15
|
}
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@bunchtogether/vite-plugin-flow": "^1.0.2",
|
|
22
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
23
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
24
|
+
"pug": "^3.*",
|
|
25
|
+
"sass-embedded": "^1.93.2",
|
|
26
|
+
"typescript": "^5.*",
|
|
27
|
+
"unocss": "^66.*",
|
|
28
|
+
"unocss-preset-scalpel": "^1.2.7",
|
|
29
|
+
"vite": "^7.*",
|
|
30
|
+
"vite-plugin-pug": "^0.4.1",
|
|
31
|
+
"vue": "^3.5.*"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"vue",
|
|
36
|
+
"typescript",
|
|
37
|
+
"class",
|
|
38
|
+
"component",
|
|
39
|
+
"oop",
|
|
40
|
+
"kit",
|
|
41
|
+
"frontend"
|
|
42
|
+
]
|
|
17
43
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Publish Package
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches: [ main ]
|
|
5
|
-
release:
|
|
6
|
-
types: [published]
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: read
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
publish:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v5
|
|
16
|
-
- uses: actions/setup-node@v4
|
|
17
|
-
with:
|
|
18
|
-
node-version: '22'
|
|
19
|
-
registry-url: 'https://registry.npmjs.org'
|
|
20
|
-
token: ${{ secrets.NPM_TOKEN }}
|
|
21
|
-
- run: npm install -g npm@latest
|
|
22
|
-
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
23
|
-
- run: npm publish
|
|
24
|
-
env:
|
|
25
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/index.d.cts
DELETED
|
File without changes
|
package/index.d.ts
DELETED
|
File without changes
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import {VNode} from '@vue/runtime-core'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Наследуемый интерфейс компонента vue
|
|
5
|
-
* @interface IVueClass
|
|
6
|
-
* @typedef {Function} mounted Mount
|
|
7
|
-
*/
|
|
8
|
-
export default interface IVueClass {
|
|
9
|
-
readonly mixins: Array<any>
|
|
10
|
-
readonly components: {[key:string|symbol|number]:any}
|
|
11
|
-
readonly emits: Array<string>
|
|
12
|
-
readonly emitsParent: Array<string>
|
|
13
|
-
readonly inject: Array<string>
|
|
14
|
-
readonly injectParent: Array<string>
|
|
15
|
-
readonly provide: {[key:string]:any}
|
|
16
|
-
readonly provideParent: {[key:string]:(...args: any) => any}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Название компонента. Определяется автоматически по названию класса если наследовать от View.
|
|
20
|
-
*/
|
|
21
|
-
readonly name: string
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Экземпляр класса. Учтите, что контекст this не будет содержать vue элементов.
|
|
25
|
-
*/
|
|
26
|
-
readonly instance?: this
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Содержит привязки атрибутов и события в родительском компоненте,
|
|
30
|
-
* которые не были распознаны (и исключены) как
|
|
31
|
-
* [входные параметры](https://v3.ru.vuejs.org/ru/api/options-data.html#props)
|
|
32
|
-
* компонента или пользовательские события.
|
|
33
|
-
* Если компонент не объявляет входные параметры или
|
|
34
|
-
* [пользовательские события](https://v3.ru.vuejs.org/ru/api/options-data.html#emits),
|
|
35
|
-
* тут будут все привязки из родительского компонента,
|
|
36
|
-
* которые можно передать через v-bind="$attrs" внутреннему компоненту —
|
|
37
|
-
* удобно при создании компонентов высшего порядка (HOC, High Order Components).
|
|
38
|
-
*
|
|
39
|
-
* **См. также**
|
|
40
|
-
*
|
|
41
|
-
* [$attrs](https://v3.ru.vuejs.org/ru/api/instance-properties.html#attrs)
|
|
42
|
-
*
|
|
43
|
-
* [Передача обычных атрибутов](https://v3.ru.vuejs.org/ru/guide/component-attrs.html)
|
|
44
|
-
*
|
|
45
|
-
* [Options API / Разное — inheritAttrs](https://v3.ru.vuejs.org/ru/api/options-misc.html#inheritattrs)
|
|
46
|
-
*/
|
|
47
|
-
readonly $attrs: Object
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Объект с данными, за которыми осуществляет наблюдение экземпляр компонента.
|
|
51
|
-
* Экземпляр компонента проксирует доступ к свойствам объекта данных.
|
|
52
|
-
*
|
|
53
|
-
* **См. также**
|
|
54
|
-
*
|
|
55
|
-
* [$data](https://v3.ru.vuejs.org/ru/api/instance-properties.html#data)
|
|
56
|
-
*
|
|
57
|
-
* [Options API / Локальное состояние — data](https://v3.ru.vuejs.org/ru/api/options-data.html#data)
|
|
58
|
-
*/
|
|
59
|
-
readonly $data: Object
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Корневой элемент DOM, которым управляет экземпляр компонента.
|
|
63
|
-
*
|
|
64
|
-
* Для компонентов использующих [фрагменты](https://v3.ru.vuejs.org/ru/guide/migration/fragments.html),
|
|
65
|
-
* `$el` будет узлом DOM, с помощью которого Vue будет отслеживать место компонента в DOM.
|
|
66
|
-
* Рекомендуется использовать ссылки на элементы шаблона для доступа к элементам DOM напрямую,
|
|
67
|
-
* а не полагаться на `$el`
|
|
68
|
-
*
|
|
69
|
-
* **См. также**
|
|
70
|
-
*
|
|
71
|
-
* [$el](https://v3.ru.vuejs.org/ru/api/instance-properties.html#el)
|
|
72
|
-
*/
|
|
73
|
-
readonly $el: HTMLElement
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Опции инициализации, используемые для текущего экземпляра компонента.
|
|
77
|
-
* Полезно, если потребуется добавить пользовательские свойства в опции:
|
|
78
|
-
*
|
|
79
|
-
* **См. также**
|
|
80
|
-
*
|
|
81
|
-
* [$options](https://v3.ru.vuejs.org/ru/api/instance-properties.html#options)
|
|
82
|
-
*/
|
|
83
|
-
readonly $options: {
|
|
84
|
-
__scopeId: string
|
|
85
|
-
__file: string
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Родительский экземпляр, если таковой имеется
|
|
90
|
-
*
|
|
91
|
-
* **См. также**
|
|
92
|
-
*
|
|
93
|
-
* [$parent](https://v3.ru.vuejs.org/ru/api/instance-properties.html#parent)
|
|
94
|
-
*/
|
|
95
|
-
readonly $parent: IVueClass|null
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Объект, содержащий текущие входные параметры, которые получил компонент.
|
|
99
|
-
* Экземпляр компонента проксирует доступ к свойствам объекта входных параметров.
|
|
100
|
-
*
|
|
101
|
-
* **См. также**
|
|
102
|
-
*
|
|
103
|
-
* [$props](https://v3.ru.vuejs.org/ru/api/instance-properties.html#props)
|
|
104
|
-
*/
|
|
105
|
-
readonly $props: {[key:string]:any}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Объект из DOM-элементов и экземпляров компонентов, зарегистрированных с помощью
|
|
109
|
-
* [атрибутов ref](https://v3.ru.vuejs.org/ru/guide/component-template-refs.html).
|
|
110
|
-
*
|
|
111
|
-
* **См. также**
|
|
112
|
-
*
|
|
113
|
-
* [Ссылки на элементы шаблона](https://v3.ru.vuejs.org/ru/guide/component-template-refs.html)
|
|
114
|
-
* [Специальные атрибуты — ref](https://v3.ru.vuejs.org/ru/api/special-attributes.html#ref)
|
|
115
|
-
*/
|
|
116
|
-
readonly $refs: {
|
|
117
|
-
[key:string]:HTMLElement|HTMLInputElement|undefined|
|
|
118
|
-
HTMLElement[]|HTMLInputElement[]
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Экземпляр корневого компонента текущего дерева компонентов.
|
|
123
|
-
* Если у текущего экземпляра нет родителя, то значением будет он сам.
|
|
124
|
-
*/
|
|
125
|
-
readonly $root: {
|
|
126
|
-
// [key:string]:any
|
|
127
|
-
readonly APP?: any
|
|
128
|
-
}|this|any
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Используется для программного доступа к содержимому, распределяемому с помощью слотов.
|
|
132
|
-
* Каждый именованный слот имеет соответствующее свойство
|
|
133
|
-
* (например, содержимое v-slot:foo будет доступно через this.$slots.foo()).
|
|
134
|
-
*/
|
|
135
|
-
readonly $slots: {
|
|
136
|
-
default: () => VNode[]
|
|
137
|
-
} & {
|
|
138
|
-
[key: string]: (() => VNode[]) | undefined
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Генерирует событие на текущем экземпляре.
|
|
143
|
-
* Любые дополнительные аргументы будут переданы в callback функции прослушивания события.
|
|
144
|
-
* @param {String} eventName Название события
|
|
145
|
-
* @param {*} args Аргументы передаваемые в него
|
|
146
|
-
*/
|
|
147
|
-
$emit(eventName: string, ...args: any[]): void
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Откладывает вызов коллбэка до следующего цикла обновления DOM.
|
|
151
|
-
* @param {Function} callback
|
|
152
|
-
*/
|
|
153
|
-
$forceUpdate(callback?: Function): void
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Отслеживание изменений реактивного свойства или функции вычисляемого свойства.
|
|
157
|
-
* @param {String} source
|
|
158
|
-
* @param {Function} callback
|
|
159
|
-
* @param {VueWatchOptions} options
|
|
160
|
-
*/
|
|
161
|
-
$watch(source?: string | Function, callback?: Function | object, options?: VueWatchOptions): void
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Откладывает вызов коллбэка до следующего цикла обновления DOM.
|
|
165
|
-
* @param {Function} callback
|
|
166
|
-
*/
|
|
167
|
-
$nextTick(callback?: Function): void
|
|
168
|
-
|
|
169
|
-
/** Параметры vue компонента */
|
|
170
|
-
readonly $: {
|
|
171
|
-
[key: string]: any,
|
|
172
|
-
uid: number,
|
|
173
|
-
app: {
|
|
174
|
-
[key: string]: any,
|
|
175
|
-
appContext: {
|
|
176
|
-
[key: string]: any,
|
|
177
|
-
version: string
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
vnode: {
|
|
181
|
-
[key: string]: any,
|
|
182
|
-
scopeId: string,
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// Хуки жизненного цикла
|
|
188
|
-
beforeCreate(): void
|
|
189
|
-
created(): void
|
|
190
|
-
beforeMount(): void
|
|
191
|
-
mounted(): void
|
|
192
|
-
beforeUpdate(): void
|
|
193
|
-
updated(): void
|
|
194
|
-
beforeUnmount(): void
|
|
195
|
-
unmounted(): void
|
|
196
|
-
|
|
197
|
-
// Родительские хуки
|
|
198
|
-
beforeCreateParent(): void
|
|
199
|
-
createdParent(): void
|
|
200
|
-
beforeMountParent(): void
|
|
201
|
-
mountedParent(): void
|
|
202
|
-
beforeUpdateParent(): void
|
|
203
|
-
updatedParent(): void
|
|
204
|
-
beforeUnmountParent(): void
|
|
205
|
-
unmountedParent(): void
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Рекурсивный пропуск шагов
|
|
209
|
-
* @param {Function} callback
|
|
210
|
-
* @param {Number} steps Количество шагов (тиков, смен сцен), которые нужно пропустить
|
|
211
|
-
*/
|
|
212
|
-
nextTick(callback: () => void, steps?: number): void
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Проверка наличия внешнего обработчика события
|
|
216
|
-
* @param name
|
|
217
|
-
*/
|
|
218
|
-
hasExternalHandlerEvent(name: string): boolean
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export interface VueWatchOptions {
|
|
222
|
-
deep?: boolean,
|
|
223
|
-
immediate?: boolean,
|
|
224
|
-
once?: boolean,
|
|
225
|
-
flush?: string,
|
|
226
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import IBaseVueComponent from '../Interfaces/IBaseVueComponent'
|
|
3
|
-
import VueClass from '../Vue/VueClass'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Базовый компонент.
|
|
7
|
-
* В дальнейшем планируется в него внедрять полезные методы и реактивные свойства (размеры окна, тип и т.д.).
|
|
8
|
-
* От него можно наследовать любой компонент.
|
|
9
|
-
*/
|
|
10
|
-
export default abstract class BaseComponent extends VueClass implements IBaseVueComponent {
|
|
11
|
-
emitsParent = ['update:modelValue']
|
|
12
|
-
declare readonly $root: {
|
|
13
|
-
[key: string]: any
|
|
14
|
-
}
|
|
15
|
-
constructor() {
|
|
16
|
-
super()
|
|
17
|
-
}
|
|
18
|
-
mountedParent() {
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
</script>
|
package/src/core/Computed.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Трансформация метода в vue computed функцию
|
|
3
|
-
* @param {String} propertyName Название свойства
|
|
4
|
-
* @constructor
|
|
5
|
-
*/
|
|
6
|
-
export const Computed = function(propertyName: string): any {
|
|
7
|
-
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { // @ts-ignore
|
|
8
|
-
if(!globalThis._vueClassInstances[target.constructor.name]) { // @ts-ignore
|
|
9
|
-
globalThis._vueClassInstances[target.constructor.name] = new target.constructor // @ts-ignore
|
|
10
|
-
globalThis._vueClassInstances[target.constructor.name].name = 'test' // @ts-ignore
|
|
11
|
-
globalThis._vueClassInstances[target.constructor.name].name = // @ts-ignore
|
|
12
|
-
globalThis._vueClassInstances[target.constructor.name]?.constructor?.name?.toString() // @ts-ignore
|
|
13
|
-
?? globalThis._vueClassInstances[target.constructor.name]['name'] // @ts-ignore
|
|
14
|
-
?? ''
|
|
15
|
-
}
|
|
16
|
-
if(!target?.constructor?.prototype?.__vue_computed__) {
|
|
17
|
-
target.constructor.prototype.__vue_computed__ = {}
|
|
18
|
-
}
|
|
19
|
-
if(!target?.constructor?.prototype?.__vue_computed__[target.constructor.name]) {
|
|
20
|
-
target.constructor.prototype.__vue_computed__[target.constructor.name] = {}
|
|
21
|
-
}
|
|
22
|
-
target.constructor.prototype.__vue_computed__[target.constructor.name][propertyName ?? propertyKey] // @ts-ignore
|
|
23
|
-
= globalThis._vueClassInstances[target.constructor.name][propertyKey]
|
|
24
|
-
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
if(!globalThis._vueComputed[target.constructor.name]) { // @ts-ignore
|
|
27
|
-
globalThis._vueComputed[target.constructor.name] = {}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
let callback = globalThis._vueClassInstances[target.constructor.name][propertyKey] // @ts-ignore
|
|
32
|
-
globalThis._vueClassInstances[target.constructor.name][propertyKey] = undefined // @ts-ignore
|
|
33
|
-
delete globalThis._vueClassInstances[target.constructor.name][propertyKey] // @ts-ignore
|
|
34
|
-
globalThis._vueComputed[target.constructor.name][propertyName ?? propertyKey] = {
|
|
35
|
-
get: callback
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/core/Props.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import {DebuggerEvent} from 'vue/dist/vue.esm-bundler'
|
|
3
|
-
|
|
4
|
-
type VuePropsTypes = typeof String | typeof Number | typeof Array | typeof Boolean | typeof Object |
|
|
5
|
-
typeof Date | typeof Function | typeof Symbol | null
|
|
6
|
-
|
|
7
|
-
type WatchCallback<T> = (
|
|
8
|
-
value: T,
|
|
9
|
-
oldValue: T,
|
|
10
|
-
onCleanup: (cleanupFn: () => void) => void
|
|
11
|
-
) => void
|
|
12
|
-
|
|
13
|
-
interface VuePropObj {
|
|
14
|
-
type: VuePropsTypes | VuePropsTypes[],
|
|
15
|
-
validator?: Function,
|
|
16
|
-
default?: any,
|
|
17
|
-
required?: boolean,
|
|
18
|
-
event?: string,
|
|
19
|
-
deep?: boolean, // default: false
|
|
20
|
-
handler?: WatchCallback<any> | string
|
|
21
|
-
immediate?: boolean // default: false
|
|
22
|
-
flush?: 'pre' | 'post' | 'sync' // default: 'pre'
|
|
23
|
-
onTrack?: (event: DebuggerEvent) => void
|
|
24
|
-
onTrigger?: (event: DebuggerEvent) => void
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Трансформация свойства во vue property
|
|
29
|
-
* @param propDataOrType
|
|
30
|
-
* @param types
|
|
31
|
-
* @constructor
|
|
32
|
-
*/
|
|
33
|
-
export const Prop = (
|
|
34
|
-
propDataOrType: VuePropsTypes | VuePropObj,
|
|
35
|
-
...types: (VuePropsTypes)[]
|
|
36
|
-
): any => {
|
|
37
|
-
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
if(!globalThis._vueClassInstances[target.constructor.name]) {
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
globalThis._vueClassInstances[target.constructor.name] = new target.constructor
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
globalThis._vueClassInstances[target.constructor.name].name =
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
globalThis._vueClassInstances[target.constructor.name]?.constructor?.name?.toString()
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
?? globalThis._vueClassInstances[target.constructor.name]['name']
|
|
48
|
-
?? ''
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let TypeObj = typeof propDataOrType == 'object' ? propDataOrType : {
|
|
52
|
-
type: [propDataOrType, ...types]
|
|
53
|
-
}
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
if(globalThis._vueClassInstances[target.constructor.name][propertyKey]) {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
TypeObj.default = globalThis._vueClassInstances[target.constructor.name][propertyKey]
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
if(!globalThis._vueClassProps[target.constructor.name]) {
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
globalThis._vueClassProps[target.constructor.name] = {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
globalThis._vueClassProps[target.constructor.name][propertyKey] = TypeObj
|
|
68
|
-
// console.log(globalThis._vueClassInstances[target.constructor.name], target.constructor.name, globalThis._vueClassProps[target.constructor.name])
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/core/VueClass.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { VNode } from "@vue/runtime-core"
|
|
2
|
-
import IVueClass from '../Interfaces/IVueClass'
|
|
3
|
-
|
|
4
|
-
export default abstract class VueClass implements IVueClass {
|
|
5
|
-
public readonly mixins: Array<any> = []
|
|
6
|
-
public readonly components: {[key:string|symbol|number]:any} = {}
|
|
7
|
-
public readonly emits: Array<string> = []
|
|
8
|
-
public readonly emitsParent: Array<string> = []
|
|
9
|
-
public readonly inject: Array<string> = []
|
|
10
|
-
public readonly injectParent: Array<string> = []
|
|
11
|
-
public readonly provide: {[key:string]:any} = {}
|
|
12
|
-
public readonly provideParent: {[key:string]:(...args: any) => any} = {}
|
|
13
|
-
|
|
14
|
-
readonly name: string
|
|
15
|
-
readonly instance?: this = this
|
|
16
|
-
readonly $attrs: {[key:string]:any} = {}
|
|
17
|
-
readonly $data: {[key:string]:any} = {}
|
|
18
|
-
readonly $el: HTMLElement // $I.Frontend.HTML.Element
|
|
19
|
-
readonly $options: {
|
|
20
|
-
__scopeId: string
|
|
21
|
-
__file: string
|
|
22
|
-
}
|
|
23
|
-
readonly $parent: VueClass|null
|
|
24
|
-
readonly $props: Object
|
|
25
|
-
readonly $refs: {
|
|
26
|
-
[key:string]: HTMLElement|HTMLInputElement|HTMLElement[]|HTMLInputElement[]
|
|
27
|
-
}
|
|
28
|
-
readonly $root: {
|
|
29
|
-
// [key:string]:any
|
|
30
|
-
readonly APP?: any
|
|
31
|
-
}|this|any
|
|
32
|
-
readonly $slots: {
|
|
33
|
-
default: () => VNode[]
|
|
34
|
-
} & {
|
|
35
|
-
[key: string]: (() => VNode[]) | undefined
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
$emit(eventName: string, ...args: any[]): void {}
|
|
39
|
-
$forceUpdate(callback?: Function): void {}
|
|
40
|
-
$watch(source?: string | Function, callback?: Function | object, options?: any /* VueWatchOptions */): void {}
|
|
41
|
-
$nextTick(callback?: Function): void {}
|
|
42
|
-
|
|
43
|
-
readonly $: {
|
|
44
|
-
[key: string]: any,
|
|
45
|
-
uid: number,
|
|
46
|
-
app: {
|
|
47
|
-
[key: string]: any,
|
|
48
|
-
appContext: {
|
|
49
|
-
[key: string]: any,
|
|
50
|
-
version: string
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
vnode: {
|
|
54
|
-
[key: string]: any,
|
|
55
|
-
scopeId: string,
|
|
56
|
-
}
|
|
57
|
-
} = {} as any
|
|
58
|
-
|
|
59
|
-
beforeCreate() {}
|
|
60
|
-
created() {}
|
|
61
|
-
beforeMount() {}
|
|
62
|
-
mounted() {}
|
|
63
|
-
beforeUpdate() {}
|
|
64
|
-
updated() {}
|
|
65
|
-
beforeUnmount() {}
|
|
66
|
-
unmounted() {}
|
|
67
|
-
|
|
68
|
-
beforeCreateParent() {}
|
|
69
|
-
createdParent() {}
|
|
70
|
-
beforeMountParent() {}
|
|
71
|
-
mountedParent() {}
|
|
72
|
-
beforeUpdateParent() {}
|
|
73
|
-
updatedParent() {}
|
|
74
|
-
beforeUnmountParent() {}
|
|
75
|
-
unmountedParent() {}
|
|
76
|
-
|
|
77
|
-
nextTick(callback: () => void, steps: number = 1) {}
|
|
78
|
-
hasExternalHandlerEvent(name: string): boolean {return false}
|
|
79
|
-
}
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import {defineComponent, getCurrentInstance, nextTick} from 'vue' // @ts-ignore
|
|
2
|
-
import VueClass from "./VueClass.ts"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Параметры readonly из экземпляра vue
|
|
6
|
-
*/
|
|
7
|
-
const vueDefaultProps = [
|
|
8
|
-
'$attrs', '$data', '$el', '$off', '$on','$emit', '$forceUpdate',
|
|
9
|
-
'$nextTick', '$options', '$parent', '$props', '$refs',
|
|
10
|
-
'$root', '$slots', '$watch'
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
type VueProps = {
|
|
14
|
-
/** Название компонента */
|
|
15
|
-
name?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Объявляем типы для глобального хранилища
|
|
19
|
-
declare global {
|
|
20
|
-
var _vueClassInstances: Record<string, any>
|
|
21
|
-
var _vueClassProps: Record<string, Record<string, any>>
|
|
22
|
-
var _vueClassWatchers: Record<string, Record<string, any>>
|
|
23
|
-
var _vueComputed: Record<string, Record<string, any>>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Инициализация глобальных объектов, если они не существуют
|
|
27
|
-
if (typeof globalThis._vueClassInstances === 'undefined') {
|
|
28
|
-
globalThis._vueClassInstances = {}
|
|
29
|
-
}
|
|
30
|
-
if (typeof globalThis._vueClassProps === 'undefined') {
|
|
31
|
-
globalThis._vueClassProps = {}
|
|
32
|
-
}
|
|
33
|
-
if (typeof globalThis._vueClassWatchers === 'undefined') {
|
|
34
|
-
globalThis._vueClassWatchers = {}
|
|
35
|
-
}
|
|
36
|
-
if (typeof globalThis._vueComputed === 'undefined') {
|
|
37
|
-
globalThis._vueComputed = {}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Декоратор для создания компонента на основе класса VueClass
|
|
42
|
-
* @param options - опции компонента или конструктор класса
|
|
43
|
-
* @example
|
|
44
|
-
* \@VueClassComponent({ // TODO нужно обновлять при разработке и получать при сборке, необходим написать vite плагин
|
|
45
|
-
* makeGlobal: true, // <- сделать глобальным, если название совпадёт с системным, то будет проигнорировано
|
|
46
|
-
* }) ComponentNameWebview extends Webview {
|
|
47
|
-
*
|
|
48
|
-
* }
|
|
49
|
-
* @example
|
|
50
|
-
* \@VueClassComponent ComponentNameWebview extends Webview {
|
|
51
|
-
*
|
|
52
|
-
* }
|
|
53
|
-
* @returns - декоратор для класса
|
|
54
|
-
*/
|
|
55
|
-
function VueClassComponentDecorator<P = {}>(
|
|
56
|
-
options: P | (new (...args: any[]) => any)
|
|
57
|
-
): any {
|
|
58
|
-
// Если передан конструктор (используется как @VueClassComponent)
|
|
59
|
-
if (typeof options === 'function') { // @ts-ignore
|
|
60
|
-
return createComponent(options)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Если передан объект с опциями (используется как @VueClassComponent(options))
|
|
64
|
-
return function(constructor: new (...args: any[]) => any) {
|
|
65
|
-
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
return createComponent(constructor, options)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
function createComponent<T extends { new(...args: any[]): {} }>(
|
|
73
|
-
constructor: T,
|
|
74
|
-
options: any = {}
|
|
75
|
-
): T & VueClass {
|
|
76
|
-
// Создаем инстанс класса или получаем существующий
|
|
77
|
-
let vueClassInstance = globalThis?._vueClassInstances[constructor.name] ?? new constructor()
|
|
78
|
-
|
|
79
|
-
// Проверка наследования от VueClass
|
|
80
|
-
if (!(vueClassInstance instanceof VueClass)) {
|
|
81
|
-
throw `Класс ${constructor.name} должен наследоваться от класса VueClass или его потомков`
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Сохраняем инстанс, если его еще нет
|
|
85
|
-
if (!globalThis?._vueClassInstances[constructor.name]) {
|
|
86
|
-
globalThis._vueClassInstances[constructor.name] = vueClassInstance
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Получаем методы
|
|
90
|
-
const methods = {}
|
|
91
|
-
const VCC = new VueClassChild()
|
|
92
|
-
for (let m of arrayDiff(getMethods(vueClassInstance), getMethods(VCC, true))) { // @ts-ignore
|
|
93
|
-
methods[m] = vueClassInstance[m]
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Обработка props
|
|
97
|
-
const dataProps = {}
|
|
98
|
-
let props = Object.assign({}, (globalThis._vueClassProps[constructor.name] ?? {}))
|
|
99
|
-
let pProps = Object.getPrototypeOf(vueClassInstance)
|
|
100
|
-
|
|
101
|
-
do {
|
|
102
|
-
props = Object.assign(props, (globalThis._vueClassProps[pProps.constructor.name] ?? {}))
|
|
103
|
-
} while ((pProps = Object.getPrototypeOf(pProps)) instanceof VueClass)
|
|
104
|
-
|
|
105
|
-
// Обработка свойств объекта
|
|
106
|
-
for (let p of getObjProps(vueClassInstance)) {
|
|
107
|
-
if (!props[p]) { // @ts-ignore
|
|
108
|
-
dataProps[p] = vueClassInstance[p]
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Обработка watchers
|
|
113
|
-
let watch = Object.assign({}, (globalThis._vueClassWatchers[constructor.name] ?? {}))
|
|
114
|
-
let pWatch = Object.getPrototypeOf(vueClassInstance)
|
|
115
|
-
|
|
116
|
-
do {
|
|
117
|
-
watch = Object.assign(watch, (globalThis._vueClassWatchers[pWatch.constructor.name] ?? {}))
|
|
118
|
-
} while ((pWatch = Object.getPrototypeOf(pWatch)) instanceof VueClass)
|
|
119
|
-
|
|
120
|
-
// Обработка computed свойств
|
|
121
|
-
let computed = Object.assign({}, (globalThis._vueComputed[constructor.name] ?? {}))
|
|
122
|
-
for (let name in computed) { // @ts-ignore
|
|
123
|
-
delete vueClassInstance[name]
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
let componentOutHandlers: string[] = []
|
|
127
|
-
|
|
128
|
-
// @ts-ignore Возвращаем Vue компонент
|
|
129
|
-
return defineComponent({
|
|
130
|
-
props,
|
|
131
|
-
watch,
|
|
132
|
-
computed,
|
|
133
|
-
name: vueClassInstance['name'] ?? vueClassInstance['instance']?.constructor?.name,
|
|
134
|
-
mixins: vueClassInstance.mixins,
|
|
135
|
-
components: vueClassInstance.components,
|
|
136
|
-
emits: vueClassInstance.emits.concat(vueClassInstance.emitsParent),
|
|
137
|
-
inject: vueClassInstance.inject.concat(vueClassInstance.injectParent),
|
|
138
|
-
provide: {...vueClassInstance.provideParent, ...vueClassInstance.provide},
|
|
139
|
-
beforeCreate: function() {
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
// console.log(this.$parent?.$options.__scopeId, this.$options.__scopeId)
|
|
142
|
-
// @ts-ignore Пересоздаём экземпляр, так как функция декоратора вызывается один раз
|
|
143
|
-
vueClassInstance = new constructor()
|
|
144
|
-
// console.log(getCurrentInstance()?.parent?.vnode?.type?.__scopeId)
|
|
145
|
-
vueClassInstance.$options = this.$options
|
|
146
|
-
vueClassInstance.$parent = this.$parent
|
|
147
|
-
vueClassInstance.$root = this.$root
|
|
148
|
-
vueClassInstance.$slots = this.$slots
|
|
149
|
-
// console.log(vueClassInstance, vueClassInstance.__vue_props__)
|
|
150
|
-
|
|
151
|
-
// @ts-ignore
|
|
152
|
-
vueClassInstance['instance'] = vueClassInstance // @ts-ignore
|
|
153
|
-
this.name = vueClassInstance['name'] ?? vueClassInstance['instance']?.constructor.name
|
|
154
|
-
/**
|
|
155
|
-
* Рекурсивный пропуск шагов
|
|
156
|
-
* @see $nextTick
|
|
157
|
-
* @param {Function} callback
|
|
158
|
-
* @param {Number} steps Количество шагов, которые нужно пропустить
|
|
159
|
-
*/ // @ts-ignore
|
|
160
|
-
this.nextTick = vueClassInstance.nextTick = (callback: () => void, steps: number = 1) => {
|
|
161
|
-
const recursiveNextTick = (remainingSteps: number) => {
|
|
162
|
-
this.$nextTick(() => {
|
|
163
|
-
if (remainingSteps > 1) {
|
|
164
|
-
recursiveNextTick(remainingSteps - 1)
|
|
165
|
-
}
|
|
166
|
-
else if (typeof callback == 'function' && !(callback instanceof Promise)) {
|
|
167
|
-
callback?.call?.(this)
|
|
168
|
-
}
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
recursiveNextTick(steps)
|
|
172
|
-
}
|
|
173
|
-
vueClassInstance.beforeCreateParent.call(this)
|
|
174
|
-
vueClassInstance.beforeCreate.call(this)
|
|
175
|
-
},
|
|
176
|
-
created: function() { // @ts-ignore
|
|
177
|
-
this.name = vueClassInstance['name'] ?? vueClassInstance['instance']?.constructor.name
|
|
178
|
-
for(let method in methods) { // @ts-ignore
|
|
179
|
-
this[method] = vueClassInstance[method].bind(this)
|
|
180
|
-
}
|
|
181
|
-
vueClassInstance.createdParent.call(this)
|
|
182
|
-
vueClassInstance.created.call(this)
|
|
183
|
-
},
|
|
184
|
-
beforeMount: function() {
|
|
185
|
-
vueClassInstance.beforeMountParent.call(this)
|
|
186
|
-
vueClassInstance.beforeMount.call(this)
|
|
187
|
-
const updateEventHandlers = () => {
|
|
188
|
-
const instance = getCurrentInstance() // @ts-ignore
|
|
189
|
-
if (instance && instance.vnode.props) { // @ts-ignore
|
|
190
|
-
componentOutHandlers = Object.keys(instance.vnode.props)
|
|
191
|
-
.filter(key => key.startsWith('on'))
|
|
192
|
-
.map(key => key.slice(2).toLowerCase())
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
updateEventHandlers()
|
|
197
|
-
|
|
198
|
-
// Дополнительная проверка после монтирования
|
|
199
|
-
nextTick(() => {
|
|
200
|
-
updateEventHandlers()
|
|
201
|
-
}) // @ts-ignore
|
|
202
|
-
this['hasExternalHandlerEvent'] = (event: string) => componentOutHandlers.includes(event)
|
|
203
|
-
},
|
|
204
|
-
mounted: function() {
|
|
205
|
-
vueClassInstance.mountedParent.call(this)
|
|
206
|
-
vueClassInstance.mounted.call(this)
|
|
207
|
-
// console.log(this.computed)
|
|
208
|
-
},
|
|
209
|
-
beforeUpdate: function() {
|
|
210
|
-
vueClassInstance.beforeUpdateParent.call(this)
|
|
211
|
-
vueClassInstance.beforeUpdate.call(this)
|
|
212
|
-
const updateEventHandlers = () => {
|
|
213
|
-
const instance = getCurrentInstance() // @ts-ignore
|
|
214
|
-
if (instance && instance.vnode.props) { // @ts-ignore
|
|
215
|
-
componentOutHandlers = Object.keys(instance.vnode.props)
|
|
216
|
-
.filter(key => key.startsWith('on'))
|
|
217
|
-
.map(key => key.slice(2).toLowerCase())
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
updateEventHandlers()
|
|
222
|
-
|
|
223
|
-
// Дополнительная проверка после монтирования
|
|
224
|
-
nextTick(() => {
|
|
225
|
-
updateEventHandlers()
|
|
226
|
-
}) // @ts-ignore
|
|
227
|
-
this['hasExternalHandlerEvent'] = (event: string) => componentOutHandlers.includes(event)
|
|
228
|
-
},
|
|
229
|
-
updated: function() {
|
|
230
|
-
vueClassInstance.updatedParent.call(this)
|
|
231
|
-
vueClassInstance.updated.call(this)
|
|
232
|
-
},
|
|
233
|
-
beforeUnmount: function() {
|
|
234
|
-
vueClassInstance.beforeUnmountParent.call(this)
|
|
235
|
-
vueClassInstance.beforeUnmount.call(this)
|
|
236
|
-
},
|
|
237
|
-
unmounted: function() {
|
|
238
|
-
vueClassInstance.unmountedParent.call(this)
|
|
239
|
-
vueClassInstance.unmounted.call(this)
|
|
240
|
-
},
|
|
241
|
-
data: function() {
|
|
242
|
-
return {...dataProps, ...{__vue_class_instance__:null}}
|
|
243
|
-
},
|
|
244
|
-
})
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export const VueClassComponent = VueClassComponentDecorator
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Получение списка методов из класса
|
|
251
|
-
* @param {Object} obj Запущенный экземпляр класса
|
|
252
|
-
* @param {Boolean} ignoreVueClassBreak Игнорировать ли методы класса `VueClass`
|
|
253
|
-
*/
|
|
254
|
-
function getMethods(obj: object, ignoreVueClassBreak: boolean = false) {
|
|
255
|
-
let properties = new Set()
|
|
256
|
-
let currentObj = obj
|
|
257
|
-
do {
|
|
258
|
-
if(!ignoreVueClassBreak && currentObj.constructor.name == 'VueClass') {
|
|
259
|
-
break
|
|
260
|
-
}
|
|
261
|
-
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item))
|
|
262
|
-
} while ((currentObj = Object.getPrototypeOf(currentObj))) // @ts-ignore
|
|
263
|
-
return [...properties.keys()].filter((item: any) => typeof obj[item] === 'function' && typeof Object[item] != 'function')
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Получение списка параметров из класса
|
|
268
|
-
* @param {Object} obj Запущенный экземпляр класса
|
|
269
|
-
* @param {Boolean} ignoreVueClassBreak Игнорировать ли методы класса `VueClass`
|
|
270
|
-
*/
|
|
271
|
-
function getObjProps(obj: any, ignoreVueClassBreak: boolean = false): any[] {
|
|
272
|
-
let properties = new Set()
|
|
273
|
-
let currentObj = obj
|
|
274
|
-
do {
|
|
275
|
-
if(!ignoreVueClassBreak && currentObj.constructor.name == 'VueClass') {
|
|
276
|
-
break
|
|
277
|
-
}
|
|
278
|
-
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item))
|
|
279
|
-
} while ((currentObj = Object.getPrototypeOf(currentObj))) // @ts-ignore
|
|
280
|
-
return [...properties.keys()].filter((item: any) => {
|
|
281
|
-
return vueDefaultProps.indexOf(item) == -1
|
|
282
|
-
&& item != '__vue_props__'
|
|
283
|
-
&& obj[item] !== 'function' // @ts-ignore
|
|
284
|
-
&& typeof Object[item] != 'function'
|
|
285
|
-
}
|
|
286
|
-
)
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Расширение Vue объекта
|
|
291
|
-
* @param vueInstance
|
|
292
|
-
* @param watch
|
|
293
|
-
* @param computed
|
|
294
|
-
*/
|
|
295
|
-
function extendVueInstance(vueInstance: any, watch: any, computed: any) {
|
|
296
|
-
const p = new Proxy(vueInstance, {
|
|
297
|
-
get(target, prop, receiver) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// -----------------------------------
|
|
301
|
-
// Дополнение метода `$nextTick`
|
|
302
|
-
// -----------------------------------
|
|
303
|
-
if (prop === '$nextTick') {
|
|
304
|
-
return function(fn: () => void, steps: number = 1) {
|
|
305
|
-
const recursiveNextTick = function (remainingSteps: number) {
|
|
306
|
-
vueInstance.$nextTick(() => {
|
|
307
|
-
if (remainingSteps > 1) {
|
|
308
|
-
recursiveNextTick(remainingSteps - 1)
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
fn.call(vueInstance)
|
|
312
|
-
}
|
|
313
|
-
})
|
|
314
|
-
}.bind(vueInstance)
|
|
315
|
-
|
|
316
|
-
recursiveNextTick(steps)
|
|
317
|
-
}.bind(vueInstance)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return target[prop]
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
for (let n in watch) {
|
|
324
|
-
watch[n].handler = watch[n].handler.bind(p)
|
|
325
|
-
}
|
|
326
|
-
for (let n in computed) {
|
|
327
|
-
computed[n].get = computed[n].get.bind(p)
|
|
328
|
-
}
|
|
329
|
-
return p
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Получение различий из массивов
|
|
334
|
-
* @param {Array} a
|
|
335
|
-
* @param {Array} b
|
|
336
|
-
*/
|
|
337
|
-
function arrayDiff(a: any[], b: any[]): any[] {
|
|
338
|
-
return a.filter((v) => !b.includes(v))
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
class VueClassChild extends VueClass {}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
export {
|
|
346
|
-
VueClass
|
|
347
|
-
}
|
package/src/core/Watch.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Трансформация метода в vue watch функцию
|
|
3
|
-
* @param {String} propertyName Название свойства
|
|
4
|
-
* @param {boolean} deep Следить ли за изменениями объекта в глубину
|
|
5
|
-
* @param {boolean} immediate Выполнить ли метод сразу, не учитывая есть ли изменения
|
|
6
|
-
* @constructor
|
|
7
|
-
*/
|
|
8
|
-
export const Watch = function(propertyName: string, deep: boolean = false, immediate: boolean = false): any {
|
|
9
|
-
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
if(!globalThis._vueClassInstances[target.constructor.name]) {
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
globalThis._vueClassInstances[target.constructor.name] = new target.constructor
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
globalThis._vueClassInstances[target.constructor.name].name =
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
globalThis._vueClassInstances[target.constructor.name]?.constructor?.name?.toString()
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
?? globalThis._vueClassInstances[target.constructor.name]['name']
|
|
20
|
-
?? ''
|
|
21
|
-
}
|
|
22
|
-
if(!target?.constructor?.prototype?.__vue_watch__) {
|
|
23
|
-
target.constructor.prototype.__vue_watch__ = {}
|
|
24
|
-
}
|
|
25
|
-
if(!target?.constructor?.prototype?.__vue_watch__[target.constructor.name]) {
|
|
26
|
-
target.constructor.prototype.__vue_watch__[target.constructor.name] = {}
|
|
27
|
-
}
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
target.constructor.prototype.__vue_watch__[target.constructor.name][propertyName] = globalThis._vueClassInstances[target.constructor.name][propertyKey]
|
|
30
|
-
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
if(!globalThis._vueClassWatchers[target.constructor.name]) {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
globalThis._vueClassWatchers[target.constructor.name] = {}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// @ts-ignore
|
|
38
|
-
globalThis._vueClassWatchers[target.constructor.name][propertyName] = {
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
handler: globalThis._vueClassInstances[target.constructor.name][propertyKey],
|
|
41
|
-
deep: deep,
|
|
42
|
-
immediate: immediate,
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
package/src/core/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
globalThis._vueClassInstances = {};globalThis._vueClassProps = {};globalThis._vueClassWatchers = {};globalThis._vueComputed = {}
|
|
3
|
-
|
|
4
|
-
export * from './VueClassComponent'
|
|
5
|
-
export * from './Props'
|
|
6
|
-
export * from './Watch'
|
|
7
|
-
export * from './Computed' // @ts-ignore
|
|
8
|
-
export {BaseComponent} from '../Components/BaseComponent.vue'
|
|
9
|
-
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"outDir": "dist",
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"emitDecoratorMetadata": true,
|
|
11
|
-
"experimentalDecorators": true
|
|
12
|
-
},
|
|
13
|
-
"include": ["vite.config.*", "src/**/*", "src/**/*.vue"]
|
|
14
|
-
}
|
package/vite.config.ts
DELETED
|
File without changes
|