typecomposer 0.1.43 → 0.1.45
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/core/components/AlertPanel.d.ts +7 -6
- package/core/components/AlertPanel.js +3 -2
- package/core/components/AlertPanel.js.map +1 -1
- package/core/components/AvatarPanel.d.ts +3 -2
- package/core/components/AvatarPanel.js +2 -2
- package/core/components/AvatarPanel.js.map +1 -1
- package/core/components/BorderPanel.d.ts +3 -2
- package/core/components/BorderPanel.js +2 -1
- package/core/components/BorderPanel.js.map +1 -1
- package/core/components/CardPanel.d.ts +3 -2
- package/core/components/CardPanel.js +2 -1
- package/core/components/CardPanel.js.map +1 -1
- package/core/components/CheckBox.d.ts +4 -2
- package/core/components/CheckBox.js +7 -5
- package/core/components/CheckBox.js.map +1 -1
- package/core/components/ColorPicker.d.ts +3 -2
- package/core/components/ColorPicker.js +11 -8
- package/core/components/ColorPicker.js.map +1 -1
- package/core/components/ContextMenu.d.ts +5 -3
- package/core/components/ContextMenu.js +5 -3
- package/core/components/ContextMenu.js.map +1 -1
- package/core/components/DialogPanel.d.ts +5 -4
- package/core/components/DialogPanel.js +8 -8
- package/core/components/DialogPanel.js.map +1 -1
- package/core/components/DropDown.d.ts +5 -3
- package/core/components/DropDown.js +5 -3
- package/core/components/DropDown.js.map +1 -1
- package/core/components/FlowPanel.d.ts +3 -2
- package/core/components/FlowPanel.js +3 -2
- package/core/components/FlowPanel.js.map +1 -1
- package/core/components/ForEach.d.ts +3 -2
- package/core/components/ForEach.js +2 -1
- package/core/components/ForEach.js.map +1 -1
- package/core/components/GridPanel.d.ts +3 -2
- package/core/components/GridPanel.js +2 -1
- package/core/components/GridPanel.js.map +1 -1
- package/core/components/HBox.d.ts +3 -2
- package/core/components/HBox.js +2 -1
- package/core/components/HBox.js.map +1 -1
- package/core/components/LazyLoading.d.ts +3 -2
- package/core/components/LazyLoading.js +3 -2
- package/core/components/LazyLoading.js.map +1 -1
- package/core/components/ListPanel.d.ts +3 -2
- package/core/components/ListPanel.js +2 -1
- package/core/components/ListPanel.js.map +1 -1
- package/core/components/PopUpButton.d.ts +3 -2
- package/core/components/PopUpButton.js +6 -3
- package/core/components/PopUpButton.js.map +1 -1
- package/core/components/ScrollPanel.d.ts +3 -2
- package/core/components/ScrollPanel.js +2 -1
- package/core/components/ScrollPanel.js.map +1 -1
- package/core/components/SliderPanel.d.ts +3 -2
- package/core/components/SliderPanel.js +4 -5
- package/core/components/SliderPanel.js.map +1 -1
- package/core/components/StackPanel.d.ts +3 -2
- package/core/components/StackPanel.js +2 -1
- package/core/components/StackPanel.js.map +1 -1
- package/core/components/TabItem.d.ts +1 -0
- package/core/components/TabItem.js +7 -4
- package/core/components/TabItem.js.map +1 -1
- package/core/components/TabPanel.d.ts +3 -2
- package/core/components/TabPanel.js +2 -1
- package/core/components/TabPanel.js.map +1 -1
- package/core/components/TablePanel.d.ts +6 -4
- package/core/components/TablePanel.js +4 -2
- package/core/components/TablePanel.js.map +1 -1
- package/core/components/TextEdit.d.ts +1 -0
- package/core/components/TextEdit.js +4 -2
- package/core/components/TextEdit.js.map +1 -1
- package/core/components/TextField.d.ts +1 -0
- package/core/components/TextField.js +3 -2
- package/core/components/TextField.js.map +1 -1
- package/core/components/ToggleButton.d.ts +3 -2
- package/core/components/ToggleButton.js +2 -1
- package/core/components/ToggleButton.js.map +1 -1
- package/core/components/Tooltip.d.ts +3 -2
- package/core/components/Tooltip.js +2 -1
- package/core/components/Tooltip.js.map +1 -1
- package/core/components/VBox.d.ts +3 -2
- package/core/components/VBox.js +2 -1
- package/core/components/VBox.js.map +1 -1
- package/core/components/VirtualScroll copy 2.d.ts +2 -2
- package/core/components/VirtualScroll copy 2.js +2 -8
- package/core/components/VirtualScroll copy 2.js.map +1 -1
- package/core/components/VirtualScroll.d.ts +3 -2
- package/core/components/VirtualScroll.js +3 -2
- package/core/components/VirtualScroll.js.map +1 -1
- package/core/element/AbbreviationElement.d.ts +3 -2
- package/core/element/AbbreviationElement.js +2 -3
- package/core/element/AbbreviationElement.js.map +1 -1
- package/core/element/AnchorElement.d.ts +4 -3
- package/core/element/AnchorElement.js +2 -1
- package/core/element/AnchorElement.js.map +1 -1
- package/core/element/AreaElement.d.ts +3 -2
- package/core/element/AreaElement.js +2 -1
- package/core/element/AreaElement.js.map +1 -1
- package/core/element/ArticleElement.d.ts +3 -2
- package/core/element/ArticleElement.js +2 -1
- package/core/element/ArticleElement.js.map +1 -1
- package/core/element/AudioElement.d.ts +3 -2
- package/core/element/AudioElement.js +2 -1
- package/core/element/AudioElement.js.map +1 -1
- package/core/element/BaseElement.d.ts +3 -2
- package/core/element/BaseElement.js +2 -1
- package/core/element/BaseElement.js.map +1 -1
- package/core/element/BodyElement.d.ts +3 -2
- package/core/element/BodyElement.js +2 -1
- package/core/element/BodyElement.js.map +1 -1
- package/core/element/BoldElement.d.ts +3 -2
- package/core/element/BoldElement.js +2 -1
- package/core/element/BoldElement.js.map +1 -1
- package/core/element/BreakElement.d.ts +3 -2
- package/core/element/BreakElement.js +2 -1
- package/core/element/BreakElement.js.map +1 -1
- package/core/element/ButtonElement.d.ts +3 -2
- package/core/element/ButtonElement.js +2 -1
- package/core/element/ButtonElement.js.map +1 -1
- package/core/element/CanvasElement.d.ts +3 -2
- package/core/element/CanvasElement.js +2 -1
- package/core/element/CanvasElement.js.map +1 -1
- package/core/element/CaptionElement.d.ts +3 -2
- package/core/element/CaptionElement.js +2 -1
- package/core/element/CaptionElement.js.map +1 -1
- package/core/element/CiteElement.d.ts +3 -2
- package/core/element/CiteElement.js +2 -1
- package/core/element/CiteElement.js.map +1 -1
- package/core/element/CodeElement.d.ts +3 -2
- package/core/element/CodeElement.js +2 -1
- package/core/element/CodeElement.js.map +1 -1
- package/core/element/DataListElement.d.ts +3 -2
- package/core/element/DataListElement.js +2 -1
- package/core/element/DataListElement.js.map +1 -1
- package/core/element/DefinitionDescriptionElement.d.ts +3 -2
- package/core/element/DefinitionDescriptionElement.js +2 -1
- package/core/element/DefinitionDescriptionElement.js.map +1 -1
- package/core/element/DefinitionElement.d.ts +3 -2
- package/core/element/DefinitionElement.js +2 -1
- package/core/element/DefinitionElement.js.map +1 -1
- package/core/element/DeletedTextElement.d.ts +3 -2
- package/core/element/DeletedTextElement.js +2 -1
- package/core/element/DeletedTextElement.js.map +1 -1
- package/core/element/DetailsElement.d.ts +3 -2
- package/core/element/DetailsElement.js +2 -1
- package/core/element/DetailsElement.js.map +1 -1
- package/core/element/DialogElement.d.ts +3 -2
- package/core/element/DialogElement.js +2 -1
- package/core/element/DialogElement.js.map +1 -1
- package/core/element/DivElement.d.ts +3 -2
- package/core/element/DivElement.js +2 -1
- package/core/element/DivElement.js.map +1 -1
- package/core/element/EmElement.d.ts +3 -2
- package/core/element/EmElement.js +2 -1
- package/core/element/EmElement.js.map +1 -1
- package/core/element/EmbedElement.d.ts +3 -2
- package/core/element/EmbedElement.js +2 -1
- package/core/element/EmbedElement.js.map +1 -1
- package/core/element/FieldSetElement.d.ts +3 -2
- package/core/element/FieldSetElement.js +2 -1
- package/core/element/FieldSetElement.js.map +1 -1
- package/core/element/FooterElement.d.ts +3 -2
- package/core/element/FooterElement.js +2 -1
- package/core/element/FooterElement.js.map +1 -1
- package/core/element/FormElement.d.ts +3 -2
- package/core/element/FormElement.js +2 -1
- package/core/element/FormElement.js.map +1 -1
- package/core/element/Fragment.d.ts +0 -1
- package/core/element/Fragment.js +6 -50
- package/core/element/Fragment.js.map +1 -1
- package/core/element/H1Element.d.ts +3 -2
- package/core/element/H1Element.js +2 -1
- package/core/element/H1Element.js.map +1 -1
- package/core/element/H2Element.d.ts +3 -2
- package/core/element/H2Element.js +2 -1
- package/core/element/H2Element.js.map +1 -1
- package/core/element/H3Element.d.ts +3 -2
- package/core/element/H3Element.js +2 -1
- package/core/element/H3Element.js.map +1 -1
- package/core/element/H4Element.d.ts +3 -2
- package/core/element/H4Element.js +2 -1
- package/core/element/H4Element.js.map +1 -1
- package/core/element/H5Element.d.ts +3 -2
- package/core/element/H5Element.js +2 -1
- package/core/element/H5Element.js.map +1 -1
- package/core/element/H6Element.d.ts +3 -2
- package/core/element/H6Element.js +2 -1
- package/core/element/H6Element.js.map +1 -1
- package/core/element/HeadElement.d.ts +3 -2
- package/core/element/HeadElement.js +2 -1
- package/core/element/HeadElement.js.map +1 -1
- package/core/element/HeaderElement.d.ts +3 -2
- package/core/element/HeaderElement.js +2 -1
- package/core/element/HeaderElement.js.map +1 -1
- package/core/element/HorizontalRuleElement.d.ts +3 -2
- package/core/element/HorizontalRuleElement.js +2 -1
- package/core/element/HorizontalRuleElement.js.map +1 -1
- package/core/element/HtmlElement.d.ts +3 -2
- package/core/element/HtmlElement.js +2 -1
- package/core/element/HtmlElement.js.map +1 -1
- package/core/element/IFrameElement.d.ts +3 -2
- package/core/element/IFrameElement.js +2 -1
- package/core/element/IFrameElement.js.map +1 -1
- package/core/element/ILayout.d.ts +3 -2
- package/core/element/ILayout.js +2 -1
- package/core/element/ILayout.js.map +1 -1
- package/core/element/IconElement.d.ts +3 -2
- package/core/element/IconElement.js +2 -1
- package/core/element/IconElement.js.map +1 -1
- package/core/element/IdiomaticElement.d.ts +1 -0
- package/core/element/IdiomaticElement.js +2 -1
- package/core/element/IdiomaticElement.js.map +1 -1
- package/core/element/ImageElement.d.ts +3 -2
- package/core/element/ImageElement.js +2 -1
- package/core/element/ImageElement.js.map +1 -1
- package/core/element/InputElement.d.ts +3 -2
- package/core/element/InputElement.js +2 -1
- package/core/element/InputElement.js.map +1 -1
- package/core/element/LabelElement.d.ts +3 -2
- package/core/element/LabelElement.js +2 -1
- package/core/element/LabelElement.js.map +1 -1
- package/core/element/LegendElement.d.ts +3 -2
- package/core/element/LegendElement.js +2 -1
- package/core/element/LegendElement.js.map +1 -1
- package/core/element/ListItemElement.d.ts +3 -2
- package/core/element/ListItemElement.js +2 -1
- package/core/element/ListItemElement.js.map +1 -1
- package/core/element/MainElement.d.ts +3 -2
- package/core/element/MainElement.js +2 -1
- package/core/element/MainElement.js.map +1 -1
- package/core/element/NavElement.d.ts +3 -2
- package/core/element/NavElement.js +2 -1
- package/core/element/NavElement.js.map +1 -1
- package/core/element/OrderedListElement.d.ts +3 -2
- package/core/element/OrderedListElement.js +2 -1
- package/core/element/OrderedListElement.js.map +1 -1
- package/core/element/ParagraphElement.d.ts +3 -2
- package/core/element/ParagraphElement.js +2 -1
- package/core/element/ParagraphElement.js.map +1 -1
- package/core/element/PreElement.d.ts +3 -2
- package/core/element/PreElement.js +2 -1
- package/core/element/PreElement.js.map +1 -1
- package/core/element/SectionElement.d.ts +3 -2
- package/core/element/SectionElement.js +2 -1
- package/core/element/SectionElement.js.map +1 -1
- package/core/element/SelectElement.d.ts +3 -2
- package/core/element/SelectElement.js +2 -1
- package/core/element/SelectElement.js.map +1 -1
- package/core/element/SourceElement.d.ts +3 -2
- package/core/element/SourceElement.js +2 -1
- package/core/element/SourceElement.js.map +1 -1
- package/core/element/SpanElement.d.ts +3 -2
- package/core/element/SpanElement.js +2 -1
- package/core/element/SpanElement.js.map +1 -1
- package/core/element/StrongElement.d.ts +3 -2
- package/core/element/StrongElement.js +2 -1
- package/core/element/StrongElement.js.map +1 -1
- package/core/element/StyleElement.d.ts +3 -2
- package/core/element/StyleElement.js +2 -1
- package/core/element/StyleElement.js.map +1 -1
- package/core/element/SummaryElement.d.ts +3 -2
- package/core/element/SummaryElement.js +2 -1
- package/core/element/SummaryElement.js.map +1 -1
- package/core/element/SvgElement.d.ts +4 -3
- package/core/element/SvgElement.js +1 -0
- package/core/element/SvgElement.js.map +1 -1
- package/core/element/TableBodyElement.d.ts +3 -2
- package/core/element/TableBodyElement.js +2 -1
- package/core/element/TableBodyElement.js.map +1 -1
- package/core/element/TableCellElement.d.ts +3 -2
- package/core/element/TableCellElement.js +2 -1
- package/core/element/TableCellElement.js.map +1 -1
- package/core/element/TableColElement.d.ts +3 -2
- package/core/element/TableColElement.js +2 -1
- package/core/element/TableColElement.js.map +1 -1
- package/core/element/TableColGroupElement.d.ts +3 -2
- package/core/element/TableColGroupElement.js +2 -1
- package/core/element/TableColGroupElement.js.map +1 -1
- package/core/element/TableElement.d.ts +3 -2
- package/core/element/TableElement.js +2 -1
- package/core/element/TableElement.js.map +1 -1
- package/core/element/TableFootElement.d.ts +3 -2
- package/core/element/TableFootElement.js +2 -1
- package/core/element/TableFootElement.js.map +1 -1
- package/core/element/TableFootRowElement.d.ts +3 -2
- package/core/element/TableFootRowElement.js +2 -1
- package/core/element/TableFootRowElement.js.map +1 -1
- package/core/element/TableHeadCellElement.d.ts +3 -2
- package/core/element/TableHeadCellElement.js +2 -1
- package/core/element/TableHeadCellElement.js.map +1 -1
- package/core/element/TableHeadElement.d.ts +3 -2
- package/core/element/TableHeadElement.js +2 -1
- package/core/element/TableHeadElement.js.map +1 -1
- package/core/element/TableHeadRowElement.d.ts +3 -2
- package/core/element/TableHeadRowElement.js +2 -1
- package/core/element/TableHeadRowElement.js.map +1 -1
- package/core/element/TableRowElement.d.ts +3 -2
- package/core/element/TableRowElement.js +2 -1
- package/core/element/TableRowElement.js.map +1 -1
- package/core/element/TextAreaElement.d.ts +3 -2
- package/core/element/TextAreaElement.js +2 -1
- package/core/element/TextAreaElement.js.map +1 -1
- package/core/element/UListElement.d.ts +3 -2
- package/core/element/UListElement.js +2 -1
- package/core/element/UListElement.js.map +1 -1
- package/core/element/VideoElement.d.ts +3 -2
- package/core/element/VideoElement.js +2 -1
- package/core/element/VideoElement.js.map +1 -1
- package/core/ref/Computed.d.ts +3 -0
- package/core/ref/Computed.js +75 -0
- package/core/ref/Computed.js.map +1 -0
- package/core/ref/RefBoolean.d.ts +72 -7
- package/core/ref/RefBoolean.js +68 -7
- package/core/ref/RefBoolean.js.map +1 -1
- package/core/ref/RefContainer.d.ts +5 -2
- package/core/ref/RefContainer.js +14 -6
- package/core/ref/RefContainer.js.map +1 -1
- package/core/ref/RefList.d.ts +84 -16
- package/core/ref/RefList.js +112 -32
- package/core/ref/RefList.js.map +1 -1
- package/core/ref/RefMap.d.ts +82 -7
- package/core/ref/RefMap.js +88 -10
- package/core/ref/RefMap.js.map +1 -1
- package/core/ref/RefNumber.d.ts +103 -15
- package/core/ref/RefNumber.js +117 -29
- package/core/ref/RefNumber.js.map +1 -1
- package/core/ref/RefObject copy.d.ts +124 -0
- package/core/ref/RefObject copy.js +271 -0
- package/core/ref/RefObject copy.js.map +1 -0
- package/core/ref/RefObject.d.ts +94 -8
- package/core/ref/RefObject.js +56 -51
- package/core/ref/RefObject.js.map +1 -1
- package/core/ref/RefSet.d.ts +78 -4
- package/core/ref/RefSet.js +86 -10
- package/core/ref/RefSet.js.map +1 -1
- package/core/ref/RefState.d.ts +1 -0
- package/core/ref/RefState.js +3 -0
- package/core/ref/RefState.js.map +1 -1
- package/core/ref/RefString.d.ts +114 -41
- package/core/ref/RefString.js +141 -164
- package/core/ref/RefString.js.map +1 -1
- package/core/ref/index.d.ts +1 -1
- package/core/ref/index.js +1 -2
- package/core/ref/index.js.map +1 -1
- package/core/router/RouteView.d.ts +3 -2
- package/core/router/RouteView.js +2 -1
- package/core/router/RouteView.js.map +1 -1
- package/core/styles/index.d.ts +2 -2
- package/core/styles/index.js.map +1 -1
- package/global/index.d.ts +5 -4
- package/global/index.js +395 -225
- package/global/index.js.map +1 -1
- package/package.json +3 -3
- package/typings/index.d.ts +11 -2
package/core/ref/RefObject.js
CHANGED
|
@@ -2,13 +2,12 @@ import { RefNumber, RefString, RefBoolean, RefMap, RefList, Ref, RefState } from
|
|
|
2
2
|
import { RefContainer } from "./RefContainer";
|
|
3
3
|
import { RefSet } from "./RefSet";
|
|
4
4
|
class RefObjectContainer extends RefContainer {
|
|
5
|
-
refKey;
|
|
6
5
|
root;
|
|
7
6
|
instance = { value: null };
|
|
8
|
-
constructor(value,
|
|
7
|
+
constructor(value, root) {
|
|
9
8
|
super(value, root);
|
|
10
|
-
this.refKey = refKey;
|
|
11
9
|
this.root = root;
|
|
10
|
+
this.value = createObservador(value, this);
|
|
12
11
|
if (isApplyProxy(value)) {
|
|
13
12
|
RefObjectContainer.createObject.bind(this)(this.value, value, this);
|
|
14
13
|
}
|
|
@@ -31,37 +30,38 @@ class RefObjectContainer extends RefContainer {
|
|
|
31
30
|
proxy[key] = value[key];
|
|
32
31
|
continue;
|
|
33
32
|
}
|
|
34
|
-
const refKey = container.refKey && `${container.refKey}:${key}`;
|
|
35
33
|
if (value[key] instanceof Array) {
|
|
36
34
|
// @ts-ignore
|
|
37
|
-
proxy[key] = new RefList(value[key]
|
|
35
|
+
proxy[key] = new RefList(value[key]);
|
|
38
36
|
}
|
|
39
37
|
else if (value[key] instanceof Set) {
|
|
40
38
|
// @ts-ignore
|
|
41
|
-
proxy[key] = new RefSet(value[key]
|
|
39
|
+
proxy[key] = new RefSet(value[key]);
|
|
42
40
|
}
|
|
43
41
|
else if (value[key] instanceof Map) {
|
|
44
42
|
// @ts-ignore
|
|
45
|
-
proxy[key] = new RefMap(value[key]
|
|
43
|
+
proxy[key] = new RefMap(value[key]);
|
|
46
44
|
}
|
|
47
45
|
else if (typeof value[key] === "string" || value[key] instanceof String) {
|
|
48
46
|
// @ts-ignore
|
|
49
|
-
proxy[key] = new RefString(value[key].valueOf()
|
|
47
|
+
proxy[key] = new RefString(value[key].valueOf());
|
|
50
48
|
}
|
|
51
49
|
else if (typeof value[key] === "number" || value[key] instanceof Number) {
|
|
52
50
|
// @ts-ignore
|
|
53
|
-
proxy[key] = new RefNumber(value[key].valueOf()
|
|
51
|
+
proxy[key] = new RefNumber(value[key].valueOf());
|
|
54
52
|
}
|
|
55
53
|
else if (typeof value[key] === "boolean" || value[key] instanceof Boolean) {
|
|
56
54
|
// @ts-ignore
|
|
57
|
-
proxy[key] = new RefBoolean(value[key].valueOf()
|
|
55
|
+
proxy[key] = new RefBoolean(value[key].valueOf());
|
|
58
56
|
}
|
|
59
57
|
else if (value[key] instanceof Element) {
|
|
60
58
|
//proxy[key] =
|
|
61
59
|
}
|
|
62
60
|
else if (value[key] instanceof Object) {
|
|
63
|
-
if (Object.getPrototypeOf(proxy) === Object.prototype)
|
|
64
|
-
|
|
61
|
+
if (Object.getPrototypeOf(proxy) === Object.prototype) {
|
|
62
|
+
const con = new RefObjectContainer(value[key], (container["root"] || this));
|
|
63
|
+
proxy[key] = con.value;
|
|
64
|
+
}
|
|
65
65
|
else
|
|
66
66
|
proxy[key] = value[key];
|
|
67
67
|
}
|
|
@@ -109,17 +109,17 @@ class RefObjectContainer extends RefContainer {
|
|
|
109
109
|
RefObjectContainer.createObject.bind(this)(proxy, newObject, container);
|
|
110
110
|
}
|
|
111
111
|
emitAll(propertyName, value) {
|
|
112
|
-
super.emitAll(propertyName, value);
|
|
112
|
+
super.emitAll(propertyName, value, value);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
// @ts-ignore
|
|
116
115
|
function applyProxy(target, key, value, receiver, container) {
|
|
117
116
|
if (target[key] instanceof ref) {
|
|
118
117
|
// @ts-ignore
|
|
119
118
|
target[key].emit(key, value);
|
|
120
119
|
}
|
|
121
|
-
else if (!(target[key] instanceof Element) && target[key] instanceof Object) {
|
|
122
|
-
|
|
120
|
+
else if ((!(target[key] instanceof Element)) && target[key] instanceof Object) {
|
|
121
|
+
if (Object.getPrototypeOf(target[key]) === Object.prototype)
|
|
122
|
+
RefObjectContainer.applyObject(target[key], value, container);
|
|
123
123
|
}
|
|
124
124
|
else if (value !== undefined && value !== null) {
|
|
125
125
|
RefObjectContainer.createObject(target, { [key]: value }, container);
|
|
@@ -136,8 +136,9 @@ function isApplyProxy(value) {
|
|
|
136
136
|
return (Object.getPrototypeOf(value) === Object.prototype || Array.isArray(value)
|
|
137
137
|
|| value instanceof Map || value instanceof Set || value instanceof Number || value instanceof Boolean || value instanceof String);
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
139
|
+
function createObservador(obj, container) {
|
|
140
|
+
// if (!obj) obj = {} as T;
|
|
141
|
+
const refObject = new Proxy(obj || {}, {
|
|
141
142
|
// @ts-ignore
|
|
142
143
|
get(target, key, receiver) {
|
|
143
144
|
if (key == "toString")
|
|
@@ -166,37 +167,37 @@ function creatObservador(obj, container) {
|
|
|
166
167
|
container.value = refObject;
|
|
167
168
|
return refObject;
|
|
168
169
|
}
|
|
169
|
-
export function ref(value
|
|
170
|
-
if (value === undefined || value === null)
|
|
171
|
-
throw new Error("ref: value cannot be null or undefined");
|
|
170
|
+
export function ref(value) {
|
|
171
|
+
// if (value === undefined || value === null) throw new Error("ref: value cannot be null or undefined");
|
|
172
172
|
value = deepCopy(value);
|
|
173
173
|
if (typeof value === "string" || value instanceof String) {
|
|
174
|
-
return new RefString(value.valueOf()
|
|
174
|
+
return new RefString(value.valueOf());
|
|
175
175
|
}
|
|
176
176
|
else if (typeof value === "number" || value instanceof Number) {
|
|
177
|
-
return new RefNumber(value.valueOf()
|
|
177
|
+
return new RefNumber(value.valueOf());
|
|
178
178
|
}
|
|
179
179
|
else if (typeof value === "boolean" || value instanceof Boolean) {
|
|
180
|
-
return new RefBoolean(value.valueOf()
|
|
180
|
+
return new RefBoolean(value.valueOf());
|
|
181
181
|
}
|
|
182
182
|
else if (value instanceof Array) {
|
|
183
|
-
return new RefList(value
|
|
183
|
+
return new RefList(value);
|
|
184
184
|
}
|
|
185
185
|
else if (value instanceof Set) {
|
|
186
|
-
return new RefSet(value
|
|
186
|
+
return new RefSet(value);
|
|
187
187
|
}
|
|
188
188
|
else if (value instanceof Map) {
|
|
189
|
-
return new RefMap(value
|
|
189
|
+
return new RefMap(value);
|
|
190
190
|
}
|
|
191
|
-
const container = new RefObjectContainer(value
|
|
192
|
-
const proxy = creatObservador(value, container);
|
|
191
|
+
const container = new RefObjectContainer(value);
|
|
193
192
|
const instance = {
|
|
194
|
-
value:
|
|
193
|
+
value: container.value,
|
|
195
194
|
subscribe: container.subscribe.bind(container),
|
|
195
|
+
listen: container.listen.bind(container),
|
|
196
196
|
unsubscribe: container.unsubscribe.bind(container),
|
|
197
197
|
toString: container.toString.bind(container),
|
|
198
198
|
toJSON: container.toJSON.bind(container),
|
|
199
199
|
valueOf: container.valueOf.bind(container),
|
|
200
|
+
id: container.id
|
|
200
201
|
};
|
|
201
202
|
container["instance"] = instance;
|
|
202
203
|
Object.defineProperty(instance, Symbol.iterator, {
|
|
@@ -208,17 +209,16 @@ export function ref(value, refKey) {
|
|
|
208
209
|
});
|
|
209
210
|
Object.defineProperty(instance, "value", {
|
|
210
211
|
get() {
|
|
211
|
-
return
|
|
212
|
+
return container.value;
|
|
212
213
|
},
|
|
213
214
|
set(value) {
|
|
214
|
-
RefObjectContainer.applyObject(
|
|
215
|
+
RefObjectContainer.applyObject(container.value, value, container);
|
|
215
216
|
container.emitAll("value", value);
|
|
216
217
|
},
|
|
217
218
|
});
|
|
218
219
|
Object.setPrototypeOf(instance, ref.prototype);
|
|
219
220
|
// @ts-ignore
|
|
220
|
-
|
|
221
|
-
Ref.set(refKey, instance);
|
|
221
|
+
Ref.set(container.id, instance);
|
|
222
222
|
return instance;
|
|
223
223
|
}
|
|
224
224
|
Object.defineProperty(ref, Symbol.hasInstance, {
|
|
@@ -235,23 +235,28 @@ Object.defineProperty(ref, Symbol.hasInstance, {
|
|
|
235
235
|
instance instanceof RefState));
|
|
236
236
|
},
|
|
237
237
|
});
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const r = ref(fn()
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
238
|
+
// function computedTemplateStringsArray<T>(fn: TemplateStringsArray, ...values: any[]): DynamicRef<T> {
|
|
239
|
+
// const observers: any[] = values.pop();
|
|
240
|
+
// console.log("computed", fn, "values", values);
|
|
241
|
+
// const r = ref(fn.reduce((acc, str, i) => {
|
|
242
|
+
// // @ts-ignore
|
|
243
|
+
// return acc + str + (values[i] !== undefined ? (values[i] instanceof ref) ? values[i].value : values[i] : "");
|
|
244
|
+
// }, ""));
|
|
245
|
+
// const func = () => {
|
|
246
|
+
// r.value = fn.reduce((acc, str, i) => {
|
|
247
|
+
// // @ts-ignore
|
|
248
|
+
// return acc + str + (values[i] !== undefined ? (values[i] instanceof ref) ? values[i].value : values[i] : "");
|
|
249
|
+
// }, "");
|
|
250
|
+
// }
|
|
251
|
+
// for (const item of observers) {
|
|
252
|
+
// if (item instanceof ref) {
|
|
253
|
+
// // @ts-ignore
|
|
254
|
+
// item.listen(func);
|
|
255
|
+
// }
|
|
256
|
+
// }
|
|
257
|
+
// // @ts-ignore
|
|
258
|
+
// return r
|
|
259
|
+
// }
|
|
255
260
|
export const Interface = {
|
|
256
261
|
empty: function () {
|
|
257
262
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefObject.js","sourceRoot":"","sources":["../../../src/core/ref/RefObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAwB,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAmB,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AACxI,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAU,MAAM,UAAU,CAAC;AAE1C,MAAM,kBAAmB,SAAQ,YAAY;IAKhC;
|
|
1
|
+
{"version":3,"file":"RefObject.js","sourceRoot":"","sources":["../../../src/core/ref/RefObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAwB,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAmB,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AACxI,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAU,MAAM,UAAU,CAAC;AAE1C,MAAM,kBAAmB,SAAQ,YAAY;IAKhC;IAHX,QAAQ,GAAmB,EAAE,KAAK,EAAE,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b,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChC,OAAO,QAAe,CAAC;AAEzB,CAAC;AAID,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE;IAC7C,KAAK,EAAE,UAAU,QAAa;QAC5B,OAAO,CACL,CAAC,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC1C,CAAC,QAAQ,KAAK,GAAG;gBACf,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,SAAS;gBACjD,QAAQ,YAAY,SAAS;gBAC7B,QAAQ,YAAY,SAAS;gBAC7B,QAAQ,YAAY,UAAU;gBAC9B,QAAQ,YAAY,OAAO;gBAC3B,QAAQ,YAAY,MAAM;gBAC1B,QAAQ,YAAY,MAAM;gBAC1B,QAAQ,YAAY,QAAQ,CAAC,CAChC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAOH,wGAAwG;AACxG,2CAA2C;AAC3C,mDAAmD;AAEnD,gDAAgD;AAChD,sBAAsB;AACtB,sHAAsH;AACtH,aAAa;AACb,yBAAyB;AACzB,6CAA6C;AAC7C,sBAAsB;AACtB,sHAAsH;AACtH,cAAc;AACd,MAAM;AACN,oCAAoC;AACpC,iCAAiC;AACjC,oBAAoB;AACpB,2BAA2B;AAC3B,QAAQ;AACR,MAAM;AACN,kBAAkB;AAClB,aAAa;AACb,IAAI;AAIJ,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,KAAK,EAAE;QACL,OAAO,EAAO,CAAC;IACjB,CAAC;CACF,CAAA"}
|
package/core/ref/RefSet.d.ts
CHANGED
|
@@ -1,25 +1,99 @@
|
|
|
1
1
|
import { ref } from ".";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Creates a reactive wrapper for a Set of values.
|
|
4
|
+
*
|
|
5
|
+
* @param values - Optional array of initial values for the Set.
|
|
6
|
+
* @returns A new instance of RefSet.
|
|
7
|
+
*/
|
|
3
8
|
export declare function refSet<U>(values?: readonly U[] | null): RefSet<U>;
|
|
9
|
+
/**
|
|
10
|
+
* A type alias representing either a native Set or a reactive RefSet.
|
|
11
|
+
*/
|
|
4
12
|
export type refSet<U> = Set<U> | RefSet<U>;
|
|
13
|
+
/**
|
|
14
|
+
* A reactive wrapper around the native Set object.
|
|
15
|
+
* Notifies subscribers when the contents of the Set are mutated.
|
|
16
|
+
*/
|
|
5
17
|
export declare class RefSet<U> extends Set<U> implements ref<Set<U>> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Internal container that manages the reactive value and subscribers.
|
|
20
|
+
*/
|
|
21
|
+
private readonly container;
|
|
22
|
+
readonly id: string;
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new reactive Set instance.
|
|
25
|
+
*
|
|
26
|
+
* @param values - Optional array of initial values.
|
|
27
|
+
* @param refKey - Optional identifier to register in the global Ref registry.
|
|
28
|
+
*/
|
|
29
|
+
constructor(values?: readonly U[] | null);
|
|
30
|
+
/**
|
|
31
|
+
* Emits a change event to all subscribers for a given mutation.
|
|
32
|
+
*
|
|
33
|
+
* @param propertyName - The mutation name (e.g., "add", "delete", "clear").
|
|
34
|
+
* @param value - The current state of the Set.
|
|
35
|
+
*/
|
|
9
36
|
private emit;
|
|
37
|
+
/** Reactive subscription methods **/
|
|
10
38
|
subscribe(target: (arg: Set<U>) => void): boolean;
|
|
11
39
|
subscribe(target: (arg: Set<U>) => void, onUnsubscribe: Function): boolean;
|
|
12
40
|
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
13
41
|
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
14
42
|
subscribe(target: object | ((arg: Set<U>) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Subscribes to future changes without emitting the current value.
|
|
45
|
+
*
|
|
46
|
+
* @param target - A callback function to be called on update.
|
|
47
|
+
* @param onUnsubscribe - Optional callback for when unsubscribed.
|
|
48
|
+
* @returns true if subscription was successful.
|
|
49
|
+
*/
|
|
50
|
+
listen(target: (arg: Set<U>) => void, onUnsubscribe?: Function): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Unsubscribes a function or object-property pair from receiving updates.
|
|
53
|
+
*/
|
|
15
54
|
unsubscribe(target: (arg: Set<U>) => void): boolean;
|
|
16
55
|
unsubscribe(targe: object, propertyName: string | symbol): boolean;
|
|
56
|
+
/** Reactive mutation overrides **/
|
|
57
|
+
/**
|
|
58
|
+
* Adds a new value to the Set and notifies subscribers.
|
|
59
|
+
*
|
|
60
|
+
* @param value - The value to add.
|
|
61
|
+
* @returns The Set instance.
|
|
62
|
+
*/
|
|
17
63
|
add(value: U): this;
|
|
64
|
+
/**
|
|
65
|
+
* Removes a value from the Set and notifies subscribers.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The value to remove.
|
|
68
|
+
* @returns True if the value was present and removed.
|
|
69
|
+
*/
|
|
18
70
|
delete(value: U): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Removes all values from the Set and notifies subscribers.
|
|
73
|
+
*/
|
|
19
74
|
clear(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Returns a shallow copy of the current Set state.
|
|
77
|
+
*/
|
|
20
78
|
valueOf(): Set<U>;
|
|
79
|
+
/**
|
|
80
|
+
* Ensures native Set is used in methods like `slice`, `filter`, etc.
|
|
81
|
+
*/
|
|
21
82
|
static get [Symbol.species](): SetConstructor;
|
|
83
|
+
/** Value access and serialization **/
|
|
84
|
+
/**
|
|
85
|
+
* Gets the current Set value.
|
|
86
|
+
*/
|
|
22
87
|
get value(): Set<U>;
|
|
88
|
+
/**
|
|
89
|
+
* Replaces the entire Set with a new Set and notifies subscribers.
|
|
90
|
+
* If the same Set reference is passed, no update is triggered.
|
|
91
|
+
*
|
|
92
|
+
* @param value - A new Set instance to replace the current content.
|
|
93
|
+
*/
|
|
23
94
|
set value(value: Set<U>);
|
|
95
|
+
/**
|
|
96
|
+
* Serializes the Set to an object with numeric keys for JSON output.
|
|
97
|
+
*/
|
|
24
98
|
toJSON(): any;
|
|
25
99
|
}
|
package/core/ref/RefSet.js
CHANGED
|
@@ -1,56 +1,129 @@
|
|
|
1
1
|
import { Ref } from ".";
|
|
2
2
|
import { RefContainer } from "./RefContainer";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a reactive wrapper for a Set of values.
|
|
5
|
+
*
|
|
6
|
+
* @param values - Optional array of initial values for the Set.
|
|
7
|
+
* @returns A new instance of RefSet.
|
|
8
|
+
*/
|
|
3
9
|
export function refSet(values) {
|
|
4
10
|
return new RefSet(values);
|
|
5
11
|
}
|
|
12
|
+
// Enables `instanceof refSet` to work with RefSet instances
|
|
6
13
|
Object.defineProperty(refSet, Symbol.hasInstance, {
|
|
7
14
|
value: function (instance) {
|
|
8
15
|
return !!instance && instance instanceof RefSet;
|
|
9
16
|
},
|
|
10
17
|
});
|
|
11
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A reactive wrapper around the native Set object.
|
|
20
|
+
* Notifies subscribers when the contents of the Set are mutated.
|
|
21
|
+
*/
|
|
12
22
|
export class RefSet extends Set {
|
|
23
|
+
/**
|
|
24
|
+
* Internal container that manages the reactive value and subscribers.
|
|
25
|
+
*/
|
|
13
26
|
container = new RefContainer(this);
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
id;
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a new reactive Set instance.
|
|
30
|
+
*
|
|
31
|
+
* @param values - Optional array of initial values.
|
|
32
|
+
* @param refKey - Optional identifier to register in the global Ref registry.
|
|
33
|
+
*/
|
|
34
|
+
constructor(values) {
|
|
16
35
|
super();
|
|
17
|
-
this.
|
|
36
|
+
this.id = this.container.id;
|
|
18
37
|
this.value = new Set(values);
|
|
19
|
-
|
|
38
|
+
Ref.set(this.id, this);
|
|
20
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Emits a change event to all subscribers for a given mutation.
|
|
42
|
+
*
|
|
43
|
+
* @param propertyName - The mutation name (e.g., "add", "delete", "clear").
|
|
44
|
+
* @param value - The current state of the Set.
|
|
45
|
+
*/
|
|
21
46
|
// @ts-ignore
|
|
22
47
|
emit(propertyName, value) {
|
|
23
|
-
this.container.emitAll(propertyName, value);
|
|
48
|
+
this.container.emitAll(propertyName, value, this.valueOf());
|
|
24
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Subscribes to changes and immediately emits the current Set.
|
|
52
|
+
*/
|
|
25
53
|
subscribe(target, propertyName, onUnsubscribe) {
|
|
26
|
-
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this);
|
|
54
|
+
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this, this.valueOf());
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Subscribes to future changes without emitting the current value.
|
|
58
|
+
*
|
|
59
|
+
* @param target - A callback function to be called on update.
|
|
60
|
+
* @param onUnsubscribe - Optional callback for when unsubscribed.
|
|
61
|
+
* @returns true if subscription was successful.
|
|
62
|
+
*/
|
|
63
|
+
listen(target, onUnsubscribe) {
|
|
64
|
+
return this.container.subscribe(target, onUnsubscribe) !== undefined;
|
|
27
65
|
}
|
|
28
66
|
unsubscribe(targe, propertyName = "") {
|
|
29
67
|
return this.container.unsubscribe(targe, propertyName);
|
|
30
68
|
}
|
|
69
|
+
/** Reactive mutation overrides **/
|
|
70
|
+
/**
|
|
71
|
+
* Adds a new value to the Set and notifies subscribers.
|
|
72
|
+
*
|
|
73
|
+
* @param value - The value to add.
|
|
74
|
+
* @returns The Set instance.
|
|
75
|
+
*/
|
|
31
76
|
add(value) {
|
|
77
|
+
const oldValue = this.valueOf();
|
|
32
78
|
const result = super.add(value);
|
|
33
|
-
this.container.emitAll("add", this);
|
|
79
|
+
this.container.emitAll("add", this, oldValue);
|
|
34
80
|
return result;
|
|
35
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Removes a value from the Set and notifies subscribers.
|
|
84
|
+
*
|
|
85
|
+
* @param value - The value to remove.
|
|
86
|
+
* @returns True if the value was present and removed.
|
|
87
|
+
*/
|
|
36
88
|
delete(value) {
|
|
89
|
+
const oldValue = this.valueOf();
|
|
37
90
|
const result = super.delete(value);
|
|
38
|
-
this.container.emitAll("delete", this);
|
|
91
|
+
this.container.emitAll("delete", this, oldValue);
|
|
39
92
|
return result;
|
|
40
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Removes all values from the Set and notifies subscribers.
|
|
96
|
+
*/
|
|
41
97
|
clear() {
|
|
98
|
+
const oldValue = this.valueOf();
|
|
42
99
|
super.clear();
|
|
43
|
-
this.container.emitAll("clear", this);
|
|
100
|
+
this.container.emitAll("clear", this, oldValue);
|
|
44
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns a shallow copy of the current Set state.
|
|
104
|
+
*/
|
|
45
105
|
valueOf() {
|
|
46
106
|
return new Set(Array.from(this));
|
|
47
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Ensures native Set is used in methods like `slice`, `filter`, etc.
|
|
110
|
+
*/
|
|
48
111
|
static get [Symbol.species]() {
|
|
49
112
|
return Set;
|
|
50
113
|
}
|
|
114
|
+
/** Value access and serialization **/
|
|
115
|
+
/**
|
|
116
|
+
* Gets the current Set value.
|
|
117
|
+
*/
|
|
51
118
|
get value() {
|
|
52
119
|
return this.container.value.valueOf();
|
|
53
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Replaces the entire Set with a new Set and notifies subscribers.
|
|
123
|
+
* If the same Set reference is passed, no update is triggered.
|
|
124
|
+
*
|
|
125
|
+
* @param value - A new Set instance to replace the current content.
|
|
126
|
+
*/
|
|
54
127
|
set value(value) {
|
|
55
128
|
if (this === value)
|
|
56
129
|
return;
|
|
@@ -60,6 +133,9 @@ export class RefSet extends Set {
|
|
|
60
133
|
}
|
|
61
134
|
this.emit("value", value);
|
|
62
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Serializes the Set to an object with numeric keys for JSON output.
|
|
138
|
+
*/
|
|
63
139
|
toJSON() {
|
|
64
140
|
const obj = {};
|
|
65
141
|
let i = 0;
|
package/core/ref/RefSet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefSet.js","sourceRoot":"","sources":["../../../src/core/ref/RefSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,MAAM,CAAI,MAA4B;IACpD,OAAO,IAAI,MAAM,CAAI,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE;IAChD,KAAK,EAAE,UAAU,QAAa;QAC5B,OAAO,CAAC,CAAC,QAAQ,IAAI,QAAQ,YAAY,MAAM,CAAC;IAClD,CAAC;CACF,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"RefSet.js","sourceRoot":"","sources":["../../../src/core/ref/RefSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAI,MAA4B;IACpD,OAAO,IAAI,MAAM,CAAI,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,4DAA4D;AAC5D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE;IAChD,KAAK,EAAE,UAAU,QAAa;QAC5B,OAAO,CAAC,CAAC,QAAQ,IAAI,QAAQ,YAAY,MAAM,CAAC;IAClD,CAAC;CACF,CAAC,CAAC;AAOH;;;GAGG;AACH,MAAM,OAAO,MAAU,SAAQ,GAAM;IACnC;;OAEG;IACc,SAAS,GAAiB,IAAI,YAAY,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OAEG;IACH,MAAM;QACJ,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
package/core/ref/RefState.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class RefState<T> implements ref<T> {
|
|
|
14
14
|
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
15
15
|
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
16
16
|
subscribe(target: object | ((arg: boolean) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
17
|
+
listen(target: (arg: T) => void, onUnsubscribe?: Function): boolean;
|
|
17
18
|
unsubscribe(target: (arg: T) => void): boolean;
|
|
18
19
|
unsubscribe(target: object, propertyName: string | symbol): boolean;
|
|
19
20
|
get value(): T;
|
package/core/ref/RefState.js
CHANGED
|
@@ -51,6 +51,9 @@ export class RefState {
|
|
|
51
51
|
this.#subscribers.push({ target, propertyName, onUnsubscribe });
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
|
+
listen(target, onUnsubscribe) {
|
|
55
|
+
return this.subscribe(target, onUnsubscribe);
|
|
56
|
+
}
|
|
54
57
|
unsubscribe(targe, propertyName = "") {
|
|
55
58
|
if (this.ref) {
|
|
56
59
|
// @ts-ignore
|
package/core/ref/RefState.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefState.js","sourceRoot":"","sources":["../../../src/core/ref/RefState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAE7B,MAAM,UAAU,QAAQ,CAAI,MAAc;IACxC,OAAO,IAAI,QAAQ,CAAI,MAAM,CAAC,CAAC;AACjC,CA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