typecomposer 0.0.40 → 0.0.42
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/dist/cjs/core/components/navigation/MenuBarElement.js +0 -1
- package/dist/cjs/core/components/navigation/MenuBarElement.js.map +1 -1
- package/dist/cjs/core/element/action/SelectField.js +0 -1
- package/dist/cjs/core/element/action/SelectField.js.map +1 -1
- package/dist/cjs/core/element/base/Elements.js +2 -3
- package/dist/cjs/core/element/base/Elements.js.map +1 -1
- package/dist/cjs/core/element/base/InheritClasses.js +1 -4
- package/dist/cjs/core/element/base/InheritClasses.js.map +1 -1
- package/dist/cjs/core/element/image/IconElement.js.map +1 -1
- package/dist/cjs/core/element/text/TextFieldElement.js +5 -5
- package/dist/cjs/core/element/text/TextFieldElement.js.map +1 -1
- package/dist/cjs/core/factory/editor/Editor.js +0 -19
- package/dist/cjs/core/factory/editor/Editor.js.map +1 -1
- package/dist/cjs/core/ref/Ref.d.ts +22 -26
- package/dist/cjs/core/ref/Ref.js +88 -102
- package/dist/cjs/core/ref/Ref.js.map +1 -1
- package/dist/cjs/core/ref/RefDefineProperty.d.ts +10 -0
- package/dist/cjs/core/ref/RefDefineProperty.js +140 -0
- package/dist/cjs/core/ref/RefDefineProperty.js.map +1 -0
- package/dist/cjs/core/ref/RefMap.d.ts +19 -0
- package/dist/cjs/core/ref/RefMap.js +82 -0
- package/dist/cjs/core/ref/RefMap.js.map +1 -0
- package/dist/cjs/core/ref/RefString.d.ts +9 -4
- package/dist/cjs/core/ref/RefString.js +15 -17
- package/dist/cjs/core/ref/RefString.js.map +1 -1
- package/dist/cjs/core/ref/SubscribeRef.d.ts +8 -0
- package/dist/cjs/core/ref/SubscribeRef.js +3 -0
- package/dist/cjs/core/ref/SubscribeRef.js.map +1 -0
- package/dist/cjs/core/ref/index.d.ts +2 -1
- package/dist/cjs/core/ref/index.js +2 -1
- package/dist/cjs/core/ref/index.js.map +1 -1
- package/dist/cjs/global/global.js +8 -102
- package/dist/cjs/global/global.js.map +1 -1
- package/dist/cjs/styles/index.js +2 -22
- package/dist/cjs/styles/index.js.map +1 -1
- package/dist/esm/core/components/navigation/MenuBarElement.js +0 -1
- package/dist/esm/core/components/navigation/MenuBarElement.js.map +1 -1
- package/dist/esm/core/element/action/SelectField.js +0 -1
- package/dist/esm/core/element/action/SelectField.js.map +1 -1
- package/dist/esm/core/element/base/Elements.js +2 -3
- package/dist/esm/core/element/base/Elements.js.map +1 -1
- package/dist/esm/core/element/base/InheritClasses.js +1 -4
- package/dist/esm/core/element/base/InheritClasses.js.map +1 -1
- package/dist/esm/core/element/image/IconElement.js.map +1 -1
- package/dist/esm/core/element/text/TextFieldElement.js +6 -6
- package/dist/esm/core/element/text/TextFieldElement.js.map +1 -1
- package/dist/esm/core/factory/editor/Editor.js +0 -19
- package/dist/esm/core/factory/editor/Editor.js.map +1 -1
- package/dist/esm/core/ref/Ref.d.ts +22 -26
- package/dist/esm/core/ref/Ref.js +85 -99
- package/dist/esm/core/ref/Ref.js.map +1 -1
- package/dist/esm/core/ref/RefDefineProperty.d.ts +10 -0
- package/dist/esm/core/ref/RefDefineProperty.js +137 -0
- package/dist/esm/core/ref/RefDefineProperty.js.map +1 -0
- package/dist/esm/core/ref/RefMap.d.ts +19 -0
- package/dist/esm/core/ref/RefMap.js +78 -0
- package/dist/esm/core/ref/RefMap.js.map +1 -0
- package/dist/esm/core/ref/RefString.d.ts +9 -4
- package/dist/esm/core/ref/RefString.js +15 -17
- package/dist/esm/core/ref/RefString.js.map +1 -1
- package/dist/esm/core/ref/SubscribeRef.d.ts +8 -0
- package/dist/esm/core/ref/SubscribeRef.js +2 -0
- package/dist/esm/core/ref/SubscribeRef.js.map +1 -0
- package/dist/esm/core/ref/index.d.ts +2 -1
- package/dist/esm/core/ref/index.js +1 -1
- package/dist/esm/core/ref/index.js.map +1 -1
- package/dist/esm/global/global.js +9 -103
- package/dist/esm/global/global.js.map +1 -1
- package/dist/esm/styles/index.js +2 -22
- package/dist/esm/styles/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/core/ref/RefComponent.d.ts +0 -22
- package/dist/cjs/core/ref/RefComponent.js +0 -86
- package/dist/cjs/core/ref/RefComponent.js.map +0 -1
- package/dist/cjs/core/ref/RefProxyHandler.d.ts +0 -16
- package/dist/cjs/core/ref/RefProxyHandler.js +0 -153
- package/dist/cjs/core/ref/RefProxyHandler.js.map +0 -1
- package/dist/cjs/core/ref/WeakRefMap.d.ts +0 -13
- package/dist/cjs/core/ref/WeakRefMap.js +0 -110
- package/dist/cjs/core/ref/WeakRefMap.js.map +0 -1
- package/dist/cjs/core/ref2/Ref.d.ts +0 -26
- package/dist/cjs/core/ref2/Ref.js +0 -108
- package/dist/cjs/core/ref2/Ref.js.map +0 -1
- package/dist/cjs/core/ref2/RefComponent.d.ts +0 -22
- package/dist/cjs/core/ref2/RefComponent.js +0 -86
- package/dist/cjs/core/ref2/RefComponent.js.map +0 -1
- package/dist/cjs/core/ref2/RefProxyHandler.d.ts +0 -16
- package/dist/cjs/core/ref2/RefProxyHandler.js +0 -153
- package/dist/cjs/core/ref2/RefProxyHandler.js.map +0 -1
- package/dist/cjs/core/ref2/index.d.ts +0 -3
- package/dist/cjs/core/ref2/index.js +0 -10
- package/dist/cjs/core/ref2/index.js.map +0 -1
- package/dist/esm/core/ref/RefComponent.d.ts +0 -22
- package/dist/esm/core/ref/RefComponent.js +0 -81
- package/dist/esm/core/ref/RefComponent.js.map +0 -1
- package/dist/esm/core/ref/RefProxyHandler.d.ts +0 -16
- package/dist/esm/core/ref/RefProxyHandler.js +0 -148
- package/dist/esm/core/ref/RefProxyHandler.js.map +0 -1
- package/dist/esm/core/ref/WeakRefMap.d.ts +0 -13
- package/dist/esm/core/ref/WeakRefMap.js +0 -106
- package/dist/esm/core/ref/WeakRefMap.js.map +0 -1
- package/dist/esm/core/ref2/Ref.d.ts +0 -26
- package/dist/esm/core/ref2/Ref.js +0 -104
- package/dist/esm/core/ref2/Ref.js.map +0 -1
- package/dist/esm/core/ref2/RefComponent.d.ts +0 -22
- package/dist/esm/core/ref2/RefComponent.js +0 -81
- package/dist/esm/core/ref2/RefComponent.js.map +0 -1
- package/dist/esm/core/ref2/RefProxyHandler.d.ts +0 -16
- package/dist/esm/core/ref2/RefProxyHandler.js +0 -148
- package/dist/esm/core/ref2/RefProxyHandler.js.map +0 -1
- package/dist/esm/core/ref2/index.d.ts +0 -3
- package/dist/esm/core/ref2/index.js +0 -4
- package/dist/esm/core/ref2/index.js.map +0 -1
package/dist/esm/core/ref/Ref.js
CHANGED
|
@@ -1,124 +1,110 @@
|
|
|
1
1
|
import { RefString } from "./RefString";
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { RefProperties } from "./RefDefineProperty";
|
|
3
|
+
function subscribe(target, prop, refPropertyKey) {
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
return this.__subscribe__(target, prop, refPropertyKey);
|
|
6
|
+
}
|
|
7
|
+
//@ts-ignore
|
|
8
|
+
function onChange(fun, target) {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
this.__onChange__(fun, target);
|
|
11
|
+
}
|
|
12
|
+
function toString() {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
return this.__parent__ ? JSON.stringify(this) : JSON.stringify(this.value);
|
|
15
|
+
}
|
|
16
|
+
function toJSON() {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
return this.__parent__ ? JSON.parse(JSON.stringify(this)) : JSON.parse(JSON.stringify(this.value));
|
|
19
|
+
}
|
|
20
|
+
function updateRef(proxy, value) {
|
|
21
|
+
for (const key in value) {
|
|
22
|
+
const _value = value[key];
|
|
23
|
+
if (typeof _value == "object") {
|
|
24
|
+
if (proxy[key] === undefined)
|
|
25
|
+
Reflect.set(proxy, key, RefProxy(_value, proxy));
|
|
26
|
+
else
|
|
27
|
+
updateRef(proxy[key], _value);
|
|
28
|
+
}
|
|
29
|
+
else
|
|
30
|
+
Reflect.set(proxy, key, _value);
|
|
8
31
|
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function RefProxy(target, parent) {
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
const v = target; //parent != undefined ? target : target.value;
|
|
9
37
|
const proxy = new Proxy(target, {
|
|
10
38
|
get: (target, prop, receiver) => {
|
|
11
39
|
const value = Reflect.get(target, prop, receiver);
|
|
12
|
-
if (typeof value === "string")
|
|
40
|
+
if (parent && typeof value === "string")
|
|
13
41
|
return new RefString(value, prop, proxy);
|
|
14
42
|
return value;
|
|
15
43
|
},
|
|
16
44
|
set: (target, prop, value, receiver) => {
|
|
17
45
|
if (value instanceof RefString)
|
|
18
46
|
value = value?.toString();
|
|
19
|
-
const result = Reflect.set(target, prop, value, receiver);
|
|
20
|
-
|
|
47
|
+
const result = typeof value === "object" && typeof target[prop] == "object" ? updateRef(target[prop], value) != undefined : Reflect.set(target, prop, value, receiver);
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
proxy.__notify__(prop, value);
|
|
21
50
|
return result;
|
|
22
51
|
},
|
|
23
52
|
deleteProperty: (target, prop) => {
|
|
24
53
|
const result = Reflect.deleteProperty(target, prop);
|
|
25
|
-
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
proxy.__notify__(prop, undefined);
|
|
26
56
|
return result;
|
|
27
57
|
},
|
|
28
58
|
});
|
|
29
|
-
|
|
30
|
-
value
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
proxy["setValue"] = function (value, propertyKey) {
|
|
41
|
-
if (propertyKey)
|
|
42
|
-
proxy[propertyKey] = value;
|
|
43
|
-
else
|
|
44
|
-
proxy["value"] = value;
|
|
45
|
-
};
|
|
46
|
-
const json = JSON.stringify(proxy);
|
|
47
|
-
console.log(JSON.parse(json));
|
|
59
|
+
for (const key in v) {
|
|
60
|
+
const value = v[key];
|
|
61
|
+
if (typeof value === "object" && value !== null)
|
|
62
|
+
Reflect.set(v, key, RefProxy(value, proxy));
|
|
63
|
+
}
|
|
64
|
+
RefProperties.definePropertieParent(proxy, parent);
|
|
65
|
+
RefProperties.definePropertieSubscribe(proxy);
|
|
66
|
+
RefProperties.definePropertieOnChange(proxy);
|
|
67
|
+
RefProperties.definePropertieNotify(proxy);
|
|
68
|
+
RefProperties.definePropertieListOnChange(proxy);
|
|
48
69
|
return proxy;
|
|
49
70
|
}
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
get value() {
|
|
58
|
-
return this._value.value;
|
|
59
|
-
}
|
|
60
|
-
set value(value) {
|
|
61
|
-
if (typeof value === "object" && value !== null) {
|
|
62
|
-
this._value = { value: createProxy(value, this) };
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this._value = { value };
|
|
66
|
-
}
|
|
67
|
-
this.notify(undefined);
|
|
68
|
-
}
|
|
69
|
-
notify(refPropertyKey) {
|
|
70
|
-
const subscribers = Ref.__subscribers.getSubscribes(this);
|
|
71
|
-
subscribers.forEach((subscriber) => {
|
|
72
|
-
if (subscriber.refPropertyKey != undefined && subscriber.refPropertyKey != refPropertyKey)
|
|
73
|
-
return;
|
|
74
|
-
const target = subscriber.target.deref();
|
|
75
|
-
if (subscriber.isUnsubscribed || target === undefined) {
|
|
76
|
-
this.unsubscribe(subscriber);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (subscriber.prop !== undefined) {
|
|
80
|
-
target[subscriber.prop] = refPropertyKey == undefined ? this.value : this.value[refPropertyKey];
|
|
81
|
-
}
|
|
82
|
-
else if (subscriber.fun !== undefined) {
|
|
83
|
-
const fun = subscriber.fun;
|
|
84
|
-
if (fun === undefined) {
|
|
85
|
-
this.unsubscribe(subscriber);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
fun(this.value);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
async subscribe(target, prop, refPropertyKey) {
|
|
93
|
-
if (target === undefined)
|
|
94
|
-
return;
|
|
95
|
-
const subscriber = { target: new WeakRef(target), prop: undefined, fun: undefined, ref: new WeakRef(this), isUnsubscribed: false, refPropertyKey };
|
|
96
|
-
if (typeof prop === "string" || typeof prop === "symbol")
|
|
97
|
-
subscriber.prop = prop;
|
|
98
|
-
else if (typeof prop === "function")
|
|
99
|
-
subscriber.fun = prop;
|
|
100
|
-
Ref.registry(subscriber);
|
|
101
|
-
}
|
|
102
|
-
async unsubscribe(subscriber) {
|
|
103
|
-
console.log("unsubscribe: ", subscriber);
|
|
104
|
-
subscriber.isUnsubscribed = true;
|
|
105
|
-
await Ref.unregistry(subscriber);
|
|
106
|
-
}
|
|
107
|
-
static async registry(subscriber) {
|
|
108
|
-
if (subscriber.isUnsubscribed)
|
|
109
|
-
return;
|
|
110
|
-
Ref.__registry.register(subscriber.target, subscriber);
|
|
111
|
-
Ref.__subscribers.set(subscriber.target.deref(), subscriber);
|
|
71
|
+
export function isRef(obj) {
|
|
72
|
+
return typeof obj == "object" && "__subscribe__" in obj && "__onChange__" in obj && "__parent__" in obj && "__notify__" in obj;
|
|
73
|
+
}
|
|
74
|
+
export function refType(base) {
|
|
75
|
+
function __subscribe__(target, prop, refPropertyKey) {
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
return this.__subscribe__(target, prop, refPropertyKey);
|
|
112
78
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
79
|
+
//@ts-ignore
|
|
80
|
+
function __onChange__(fun, target) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
this.__onChange__(fun, target);
|
|
116
83
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
84
|
+
if (isRef(base)) {
|
|
85
|
+
const a = { __subscribe__, __onChange__, toString: () => "", toJSON: () => base, ...base };
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
a.__subscribe__ = subscribe.bind(a);
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
a.__onChange__ = onChange.bind(a);
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
a.toString = toString.bind(a);
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
a.toJSON = toJSON.bind(a);
|
|
94
|
+
return a;
|
|
120
95
|
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
export function ref(value) {
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
const r = RefProxy({ value, subscribe, onChange, toString: () => "", toJSON: () => value }, this);
|
|
101
|
+
r.subscribe = subscribe.bind(r);
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
(r.onChange) = onChange.bind(r);
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
r.toString = toString.bind(r);
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
r.toJSON = toJSON.bind(r);
|
|
108
|
+
return r;
|
|
121
109
|
}
|
|
122
|
-
export const isRef = (value) => value instanceof Ref;
|
|
123
|
-
export const ref = (value) => new Ref(value);
|
|
124
110
|
//# sourceMappingURL=Ref.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.js","sourceRoot":"","sources":["../../../../src/core/ref/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Ref.js","sourceRoot":"","sources":["../../../../src/core/ref/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,SAAS,SAAS,CAAC,MAAW,EAAE,IAA8C,EAAE,cAAgC;IAC9G,aAAa;IACb,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,cAAc,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function definePropertieSubscribe(proxy: any): void;
|
|
5
|
+
function definePropertieOnChange(proxy: any): void;
|
|
6
|
+
function definePropertieListOnChange(proxy: any): void;
|
|
7
|
+
function baseNotify(subscriber: subscribeRef<any>, prop: string | symbol | undefined, value: any): void;
|
|
8
|
+
function definePropertieNotify(proxy: any): void;
|
|
9
|
+
function definePropertieSetValue(proxy: any): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { RefMap } from "./RefMap";
|
|
2
|
+
import { RefString } from "./RefString";
|
|
3
|
+
export var RefProperties;
|
|
4
|
+
(function (RefProperties) {
|
|
5
|
+
function definePropertieParent(proxy, parent) {
|
|
6
|
+
Object.defineProperty(proxy, "__parent__", {
|
|
7
|
+
value: parent,
|
|
8
|
+
configurable: false,
|
|
9
|
+
enumerable: false,
|
|
10
|
+
writable: false,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
RefProperties.definePropertieParent = definePropertieParent;
|
|
14
|
+
function definePropertieSubscribe(proxy) {
|
|
15
|
+
Object.defineProperty(proxy, "__subscribe__", {
|
|
16
|
+
value: function (target, prop, refPropertyKey) {
|
|
17
|
+
if (target === undefined)
|
|
18
|
+
return undefined;
|
|
19
|
+
const subscriber = {
|
|
20
|
+
target: new WeakRef(target),
|
|
21
|
+
prop: undefined,
|
|
22
|
+
fun: undefined,
|
|
23
|
+
ref: new WeakRef(proxy),
|
|
24
|
+
isUnsubscribed: false,
|
|
25
|
+
refPropertyKey,
|
|
26
|
+
};
|
|
27
|
+
if (typeof prop === "string" || typeof prop === "symbol")
|
|
28
|
+
subscriber.prop = prop;
|
|
29
|
+
else if (typeof prop === "function")
|
|
30
|
+
subscriber.fun = prop;
|
|
31
|
+
RefMap.subscribe(subscriber);
|
|
32
|
+
if (prop != undefined && (typeof prop === "string" || typeof prop === "symbol"))
|
|
33
|
+
baseNotify(subscriber, prop, refPropertyKey ? proxy[refPropertyKey] : proxy["value"]);
|
|
34
|
+
return subscriber;
|
|
35
|
+
}.bind(proxy),
|
|
36
|
+
configurable: false,
|
|
37
|
+
enumerable: false,
|
|
38
|
+
writable: false,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
RefProperties.definePropertieSubscribe = definePropertieSubscribe;
|
|
42
|
+
function definePropertieOnChange(proxy) {
|
|
43
|
+
Object.defineProperty(proxy, "__onChange__", {
|
|
44
|
+
value: function (fun) {
|
|
45
|
+
const subscriber = { target: new WeakRef(fun), prop: undefined, fun: fun, ref: new WeakRef(proxy), isUnsubscribed: false };
|
|
46
|
+
proxy.__list_change__.push(subscriber);
|
|
47
|
+
if (subscriber.fun)
|
|
48
|
+
subscriber.fun(proxy);
|
|
49
|
+
}.bind(proxy),
|
|
50
|
+
configurable: false,
|
|
51
|
+
enumerable: false,
|
|
52
|
+
writable: false,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
RefProperties.definePropertieOnChange = definePropertieOnChange;
|
|
56
|
+
function definePropertieListOnChange(proxy) {
|
|
57
|
+
const subscribers = [];
|
|
58
|
+
Object.defineProperty(proxy, "__list_change__", {
|
|
59
|
+
value: subscribers,
|
|
60
|
+
configurable: false,
|
|
61
|
+
enumerable: false,
|
|
62
|
+
writable: false,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
RefProperties.definePropertieListOnChange = definePropertieListOnChange;
|
|
66
|
+
function baseNotify(subscriber, prop, value) {
|
|
67
|
+
if (value instanceof RefString)
|
|
68
|
+
value = value.toString();
|
|
69
|
+
if (subscriber.fun)
|
|
70
|
+
subscriber.fun(value);
|
|
71
|
+
else if (subscriber.target.deref() && prop) {
|
|
72
|
+
const target = subscriber.target.deref();
|
|
73
|
+
target[subscriber.prop] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
RefProperties.baseNotify = baseNotify;
|
|
77
|
+
function baseNotifyChange(proxy, parents) {
|
|
78
|
+
const subscribersChange = proxy?.__list_change__ || [];
|
|
79
|
+
for (const subscriber of subscribersChange) {
|
|
80
|
+
if (subscriber.target == undefined || subscriber.target?.deref() == undefined) {
|
|
81
|
+
subscriber.isUnsubscribed = true;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (subscriber.isUnsubscribed)
|
|
85
|
+
continue;
|
|
86
|
+
if (subscriber.fun)
|
|
87
|
+
subscriber.fun(proxy);
|
|
88
|
+
}
|
|
89
|
+
if (proxy.__parent__) {
|
|
90
|
+
parents.push(proxy);
|
|
91
|
+
if (parents.find((p) => p === proxy.__parent__) !== undefined)
|
|
92
|
+
return;
|
|
93
|
+
baseNotifyChange(proxy.__parent__, parents);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function definePropertieNotify(proxy) {
|
|
97
|
+
Object.defineProperty(proxy, "__notify__", {
|
|
98
|
+
value: function (prop, value) {
|
|
99
|
+
const subscribers = RefMap.getSubscribes(proxy);
|
|
100
|
+
for (const subscriber of subscribers) {
|
|
101
|
+
baseNotify(subscriber, prop, value);
|
|
102
|
+
}
|
|
103
|
+
baseNotifyChange(proxy, []);
|
|
104
|
+
}.bind(proxy),
|
|
105
|
+
configurable: false,
|
|
106
|
+
enumerable: false,
|
|
107
|
+
writable: false,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
RefProperties.definePropertieNotify = definePropertieNotify;
|
|
111
|
+
function definePropertieSetValue(proxy) {
|
|
112
|
+
// value: string, propertyKey: string | symbol
|
|
113
|
+
Object.defineProperty(proxy, "__setValue__", {
|
|
114
|
+
value: function (value, propertyKey) {
|
|
115
|
+
if (propertyKey) {
|
|
116
|
+
if (proxy.__parent__) {
|
|
117
|
+
proxy[propertyKey] = value;
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
proxy.value[propertyKey] = value;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
if (proxy.__parent__) {
|
|
124
|
+
proxy = value;
|
|
125
|
+
}
|
|
126
|
+
else
|
|
127
|
+
proxy.value = value;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
configurable: false,
|
|
131
|
+
enumerable: false,
|
|
132
|
+
writable: false,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
RefProperties.definePropertieSetValue = definePropertieSetValue;
|
|
136
|
+
})(RefProperties || (RefProperties = {}));
|
|
137
|
+
//# sourceMappingURL=RefDefineProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefDefineProperty.js","sourceRoot":"","sources":["../../../../src/core/ref/RefDefineProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,KAAW,aAAa,CAsH7B;AAtHD,WAAiB,aAAa;IAC5B,SAAgB,qBAAqB,CAAC,KAAU,EAAE,MAAW;QAC3D,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE;YACzC,KAAK,EAAE,MAAM;YACb,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;IAPe,mCAAqB,wBAOpC,CAAA;IAED,SAAgB,wBAAwB,CAAC,KAAU;QACjD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE;YAC5C,KAAK,EAAE,UAAU,MAAW,EAAE,IAA8C,EAAE,cAAgC;gBAC5G,IAAI,MAAM,KAAK,SAAS;oBAAE,OAAO,SAAS,CAAC;gBAC3C,MAAM,UAAU,GAAsB;oBACpC,MAAM,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC;oBAC3B,IAAI,EAAE,SAAS;oBACf,GAAG,EAAE,SAAS;oBACd,GAAG,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;oBACvB,cAAc,EAAE,KAAK;oBACrB,cAAc;iBACf,CAAC;gBACF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,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AC1C,CAAC;qBAAM,CAAC;oBACN,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;wBACrB,KAAK,GAAG,KAAK,CAAC;oBAChB,CAAC;;wBAAM,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;gBAC7B,CAAC;YACH,CAAC;YACD,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;IAlBe,qCAAuB,0BAkBtC,CAAA;AACH,CAAC,EAtHgB,aAAa,KAAb,aAAa,QAsH7B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { subscribeRef } from "./SubscribeRef";
|
|
2
|
+
export declare class WeakRefMap<K extends object, V> {
|
|
3
|
+
private map;
|
|
4
|
+
private keys;
|
|
5
|
+
private _length;
|
|
6
|
+
constructor();
|
|
7
|
+
set(key: K, value: V): V | undefined;
|
|
8
|
+
get(key: K): V | undefined;
|
|
9
|
+
has(key: K): boolean;
|
|
10
|
+
delete(key: K): boolean;
|
|
11
|
+
clear(): void;
|
|
12
|
+
get length(): number;
|
|
13
|
+
forEach(callback: (value: V, key: K, map: WeakMap<K, V>) => void): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare namespace RefMap {
|
|
16
|
+
function subscribe(subscriber: subscribeRef<any>): void;
|
|
17
|
+
function unsubscribe(subscriber: subscribeRef<any>): void;
|
|
18
|
+
function getSubscribes(_ref: any): subscribeRef<any>[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export class WeakRefMap {
|
|
2
|
+
map;
|
|
3
|
+
keys;
|
|
4
|
+
_length = 0;
|
|
5
|
+
constructor() {
|
|
6
|
+
this.map = new WeakMap();
|
|
7
|
+
this.keys = [];
|
|
8
|
+
}
|
|
9
|
+
set(key, value) {
|
|
10
|
+
const data = this.map.get(key);
|
|
11
|
+
if (data === undefined)
|
|
12
|
+
this._length++;
|
|
13
|
+
this.map.set(key, value);
|
|
14
|
+
if (this.keys.find((k) => k.deref() === key) === undefined)
|
|
15
|
+
this.keys.push(new WeakRef(key));
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
get(key) {
|
|
19
|
+
return this.map.get(key);
|
|
20
|
+
}
|
|
21
|
+
has(key) {
|
|
22
|
+
return this.map.has(key);
|
|
23
|
+
}
|
|
24
|
+
delete(key) {
|
|
25
|
+
const d = this.map.delete(key);
|
|
26
|
+
if (d)
|
|
27
|
+
this._length--;
|
|
28
|
+
return d;
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.map = new WeakMap();
|
|
32
|
+
this._length = 0;
|
|
33
|
+
}
|
|
34
|
+
get length() {
|
|
35
|
+
return this._length;
|
|
36
|
+
}
|
|
37
|
+
async forEach(callback) {
|
|
38
|
+
for (const key of this.keys) {
|
|
39
|
+
const strongKey = key.deref();
|
|
40
|
+
if (strongKey === undefined)
|
|
41
|
+
continue;
|
|
42
|
+
const value = this.map.get(strongKey);
|
|
43
|
+
if (value !== undefined) {
|
|
44
|
+
callback(value, strongKey, this.map);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export var RefMap;
|
|
50
|
+
(function (RefMap) {
|
|
51
|
+
const map = new WeakRefMap();
|
|
52
|
+
function subscribe(subscriber) {
|
|
53
|
+
const subscribers = map.get(subscriber.target.deref()) || new Map();
|
|
54
|
+
subscribers.set(subscriber.prop || String(subscriber.fun), subscriber);
|
|
55
|
+
map.set(subscriber.target.deref(), subscribers);
|
|
56
|
+
}
|
|
57
|
+
RefMap.subscribe = subscribe;
|
|
58
|
+
function unsubscribe(subscriber) {
|
|
59
|
+
const subscribers = map.get(subscriber.target.deref());
|
|
60
|
+
if (subscribers === undefined)
|
|
61
|
+
return;
|
|
62
|
+
subscribers.delete(subscriber.prop || String(subscriber.fun));
|
|
63
|
+
map.set(subscriber.target.deref(), subscribers);
|
|
64
|
+
}
|
|
65
|
+
RefMap.unsubscribe = unsubscribe;
|
|
66
|
+
function getSubscribes(_ref) {
|
|
67
|
+
const subscribers = [];
|
|
68
|
+
map.forEach((value) => {
|
|
69
|
+
value.forEach((value) => {
|
|
70
|
+
if (value.ref.deref() === _ref)
|
|
71
|
+
subscribers.push(value);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return subscribers;
|
|
75
|
+
}
|
|
76
|
+
RefMap.getSubscribes = getSubscribes;
|
|
77
|
+
})(RefMap || (RefMap = {}));
|
|
78
|
+
//# sourceMappingURL=RefMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefMap.js","sourceRoot":"","sources":["../../../../src/core/ref/RefMap.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,UAAU;IACb,GAAG,CAAgB;IACnB,IAAI,CAAe;IACnB,OAAO,GAAW,CAAC,CAAC;IAE5B;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC7F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAAC,GAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG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
+
__subscribe__(target: any, propertyKey: string | symbol, refPropertyKey: string | symbol): void;
|
|
6
|
+
} & any;
|
|
7
|
+
constructor(valor: string, refPropertyKey: string | symbol, proxy: {
|
|
8
|
+
__subscribe__(target: any, propertyKey: string | symbol, refPropertyKey: string | symbol): void;
|
|
9
|
+
} & any);
|
|
10
|
+
__setValue__(value: string, propertyKey: string | symbol): void;
|
|
11
|
+
__subscribe__(target: {}, propertyKey: string | symbol, refPropertyKey?: string | symbol): void;
|
|
7
12
|
onChange(fun: (value: any) => void, target?: {}): void;
|
|
8
13
|
get value(): any;
|
|
9
14
|
toString(): string;
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
export class RefString extends String {
|
|
2
|
+
valor;
|
|
2
3
|
refPropertyKey;
|
|
3
|
-
|
|
4
|
-
constructor(valor, refPropertyKey,
|
|
4
|
+
proxy;
|
|
5
|
+
constructor(valor, refPropertyKey, proxy) {
|
|
5
6
|
super(valor);
|
|
7
|
+
this.valor = valor;
|
|
6
8
|
this.refPropertyKey = refPropertyKey;
|
|
7
|
-
this.
|
|
9
|
+
this.proxy = proxy;
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
if (this.
|
|
11
|
-
this.
|
|
11
|
+
__setValue__(value, propertyKey) {
|
|
12
|
+
if (this.proxy)
|
|
13
|
+
this.proxy[propertyKey] = value;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
if (this.
|
|
15
|
-
this.
|
|
15
|
+
__subscribe__(target, propertyKey, refPropertyKey) {
|
|
16
|
+
if (this.proxy) {
|
|
17
|
+
this.proxy.__subscribe__(target, propertyKey, refPropertyKey);
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
onChange(fun, target) {
|
|
19
|
-
if (this.
|
|
20
|
-
this.
|
|
21
|
+
if (this.proxy) {
|
|
22
|
+
this.proxy.__onChange_(target, fun);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
get value() {
|
|
24
|
-
return this.
|
|
26
|
+
return this.proxy[this.refPropertyKey];
|
|
25
27
|
}
|
|
26
28
|
toString() {
|
|
27
|
-
|
|
28
|
-
if (this.refTarget && this.refPropertyKey)
|
|
29
|
-
return this.refTarget[this.refPropertyKey] || "";
|
|
30
|
-
else
|
|
31
|
-
return this.toString();
|
|
29
|
+
return String(this.valor);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
//# sourceMappingURL=RefString.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefString.js","sourceRoot":"","sources":["../../../../src/core/ref/RefString.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAU,SAAQ,MAAM;
|
|
1
|
+
{"version":3,"file":"RefString.js","sourceRoot":"","sources":["../../../../src/core/ref/RefString.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAU,SAAQ,MAAM;IAEzB;IACD;IACA;IAHT,YACU,KAAa,EACd,cAA+B,EAC/B,KAEA;QAEP,KAAK,CAAC,KAAK,CAAC,CAAC;QANL,UAAK,GAAL,KAAK,CAAQ;QACd,mBAAc,GAAd,cAAc,CAAiB;QAC/B,UAAK,GAAL,KAAK,CAEL;IAGT,CAAC;IAED,YAAY,CAAC,KAAa,EAAE,WAA4B;QACtD,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;IAClD,CAAC;IAED,aAAa,CAAC,MAAU,EAAE,WAA4B,EAAE,cAAgC;QACtF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,GAAyB,EAAE,MAAW;QAC7C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubscribeRef.js","sourceRoot":"","sources":["../../../../src/core/ref/SubscribeRef.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/ref/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/ref/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|