typecomposer 0.1.43 → 0.1.44
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/DialogPanel.d.ts +2 -2
- package/core/components/DialogPanel.js +7 -7
- package/core/components/DialogPanel.js.map +1 -1
- package/core/ref/RefBoolean.d.ts +69 -0
- package/core/ref/RefBoolean.js +64 -0
- package/core/ref/RefBoolean.js.map +1 -1
- package/core/ref/RefContainer.d.ts +1 -0
- package/core/ref/RefContainer.js +3 -0
- package/core/ref/RefContainer.js.map +1 -1
- package/core/ref/RefList.d.ts +81 -9
- package/core/ref/RefList.js +80 -12
- package/core/ref/RefList.js.map +1 -1
- package/core/ref/RefMap.d.ts +79 -0
- package/core/ref/RefMap.js +78 -1
- package/core/ref/RefMap.js.map +1 -1
- package/core/ref/RefNumber.d.ts +101 -8
- package/core/ref/RefNumber.js +116 -25
- package/core/ref/RefNumber.js.map +1 -1
- package/core/ref/RefObject.d.ts +92 -1
- package/core/ref/RefObject.js +39 -8
- package/core/ref/RefObject.js.map +1 -1
- package/core/ref/RefSet.d.ts +78 -0
- package/core/ref/RefSet.js +77 -1
- 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 +116 -40
- package/core/ref/RefString.js +141 -159
- package/core/ref/RefString.js.map +1 -1
- package/core/ref/index.d.ts +0 -1
- package/core/ref/index.js +0 -2
- package/core/ref/index.js.map +1 -1
- package/global/index.js +115 -121
- package/global/index.js.map +1 -1
- package/package.json +3 -3
package/core/ref/RefList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefList.js","sourceRoot":"","sources":["../../../src/core/ref/RefList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAg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AAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,IAAI,KAAK,CAAC,KAAU;QAClB,aAAa;QACb,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO;QAC3B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CAEF"}
|
package/core/ref/RefMap.d.ts
CHANGED
|
@@ -1,25 +1,104 @@
|
|
|
1
1
|
import { ref } from ".";
|
|
2
2
|
import { RefContainer } from "./RefContainer";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new reactive map from the given entries.
|
|
5
|
+
*
|
|
6
|
+
* @param entries - Optional initial key-value pairs.
|
|
7
|
+
* @returns A reactive RefMap instance.
|
|
8
|
+
*/
|
|
3
9
|
export declare function refMap<K, V>(entries?: readonly (readonly [K, V])[] | null): RefMap<K, V>;
|
|
10
|
+
/**
|
|
11
|
+
* A type representing either a native Map or a reactive RefMap.
|
|
12
|
+
*/
|
|
4
13
|
export type refMap<K, V> = Map<K, V> | RefMap<K, V>;
|
|
14
|
+
/**
|
|
15
|
+
* A reactive wrapper around the native Map object.
|
|
16
|
+
* Supports automatic reactivity and subscription to changes.
|
|
17
|
+
*/
|
|
5
18
|
export declare class RefMap<K, V> extends Map<K, V> implements ref<Map<K, V>> {
|
|
19
|
+
/**
|
|
20
|
+
* Internal container managing subscribers and value propagation.
|
|
21
|
+
*/
|
|
6
22
|
readonly container: RefContainer;
|
|
23
|
+
/**
|
|
24
|
+
* Optional key to register the reference globally.
|
|
25
|
+
*/
|
|
7
26
|
readonly refKey: string;
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new reactive map instance.
|
|
29
|
+
*
|
|
30
|
+
* @param entries - Optional initial entries to populate the map.
|
|
31
|
+
* @param refKey - Optional registration key for the Ref registry.
|
|
32
|
+
*/
|
|
8
33
|
constructor(entries?: readonly (readonly [K, V])[] | null, refKey?: string);
|
|
34
|
+
/**
|
|
35
|
+
* Emits a change event to all subscribers for a given mutation type.
|
|
36
|
+
*
|
|
37
|
+
* @param propertyName - The kind of mutation (e.g., "set", "clear").
|
|
38
|
+
* @param value - The current state of the map.
|
|
39
|
+
*/
|
|
9
40
|
private emit;
|
|
41
|
+
/** Reactive subscription methods **/
|
|
10
42
|
subscribe(target: (arg: Map<K, V>) => void): boolean;
|
|
11
43
|
subscribe(target: (arg: Map<K, V>) => void, onUnsubscribe: Function): boolean;
|
|
12
44
|
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
13
45
|
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
14
46
|
subscribe(target: object | ((arg: Map<K, V>) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Subscribes to future changes without emitting the current value.
|
|
49
|
+
*
|
|
50
|
+
* @param target - Function to call on change.
|
|
51
|
+
* @param onUnsubscribe - Optional callback to invoke on unsubscription.
|
|
52
|
+
*/
|
|
53
|
+
listen(target: (arg: Map<K, V>) => void, onUnsubscribe?: Function): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Unsubscribes a function or object-property pair from receiving updates.
|
|
56
|
+
*/
|
|
15
57
|
unsubscribe(target: (arg: Map<K, V>) => void): boolean;
|
|
16
58
|
unsubscribe(targe: object, propertyName: string | symbol): boolean;
|
|
59
|
+
/** Reactive mutation overrides **/
|
|
60
|
+
/**
|
|
61
|
+
* Sets a value for a given key and notifies subscribers.
|
|
62
|
+
*
|
|
63
|
+
* @param key - The key to insert or update.
|
|
64
|
+
* @param value - The value to associate with the key.
|
|
65
|
+
* @returns The map itself.
|
|
66
|
+
*/
|
|
17
67
|
set(key: K, value: V): this;
|
|
68
|
+
/**
|
|
69
|
+
* Deletes a key-value pair and notifies subscribers.
|
|
70
|
+
*
|
|
71
|
+
* @param key - The key to delete.
|
|
72
|
+
* @returns True if the key existed and was removed.
|
|
73
|
+
*/
|
|
18
74
|
delete(key: K): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Clears all entries from the map and notifies subscribers.
|
|
77
|
+
*/
|
|
19
78
|
clear(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a shallow copy of the current map state.
|
|
81
|
+
*/
|
|
20
82
|
valueOf(): Map<K, V>;
|
|
83
|
+
/**
|
|
84
|
+
* Ensures native `Map` is returned when using `Map` methods that create new instances.
|
|
85
|
+
*/
|
|
21
86
|
static get [Symbol.species](): MapConstructor;
|
|
87
|
+
/**
|
|
88
|
+
* Gets the current value of the reactive map.
|
|
89
|
+
* Returns a shallow copy to prevent unintended mutation.
|
|
90
|
+
*/
|
|
22
91
|
get value(): Map<K, V>;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the entire contents of the map to match the given Map instance.
|
|
94
|
+
* If the same reference is passed, no update is triggered.
|
|
95
|
+
*
|
|
96
|
+
* @param value - A new Map to replace the current contents.
|
|
97
|
+
*/
|
|
23
98
|
set value(value: Map<K, V>);
|
|
99
|
+
/**
|
|
100
|
+
* Serializes the map to a plain JavaScript object for JSON output.
|
|
101
|
+
* Note: keys are converted to string.
|
|
102
|
+
*/
|
|
24
103
|
toJSON(): any;
|
|
25
104
|
}
|
package/core/ref/RefMap.js
CHANGED
|
@@ -1,56 +1,129 @@
|
|
|
1
1
|
import { Ref } from ".";
|
|
2
2
|
import { RefContainer } from "./RefContainer";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new reactive map from the given entries.
|
|
5
|
+
*
|
|
6
|
+
* @param entries - Optional initial key-value pairs.
|
|
7
|
+
* @returns A reactive RefMap instance.
|
|
8
|
+
*/
|
|
3
9
|
export function refMap(entries) {
|
|
4
10
|
return new RefMap(entries);
|
|
5
11
|
}
|
|
12
|
+
// Enables `instanceof refMap` to work correctly
|
|
6
13
|
Object.defineProperty(refMap, Symbol.hasInstance, {
|
|
7
14
|
value: function (instance) {
|
|
8
15
|
return !!instance && instance instanceof RefMap;
|
|
9
16
|
},
|
|
10
17
|
});
|
|
11
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A reactive wrapper around the native Map object.
|
|
20
|
+
* Supports automatic reactivity and subscription to changes.
|
|
21
|
+
*/
|
|
12
22
|
export class RefMap extends Map {
|
|
23
|
+
/**
|
|
24
|
+
* Internal container managing subscribers and value propagation.
|
|
25
|
+
*/
|
|
13
26
|
container = new RefContainer(this);
|
|
27
|
+
/**
|
|
28
|
+
* Optional key to register the reference globally.
|
|
29
|
+
*/
|
|
14
30
|
refKey;
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new reactive map instance.
|
|
33
|
+
*
|
|
34
|
+
* @param entries - Optional initial entries to populate the map.
|
|
35
|
+
* @param refKey - Optional registration key for the Ref registry.
|
|
36
|
+
*/
|
|
15
37
|
constructor(entries, refKey) {
|
|
16
38
|
super();
|
|
17
39
|
this.refKey = refKey;
|
|
18
40
|
refKey && Ref.set(refKey, this);
|
|
19
41
|
this.value = new Map(entries);
|
|
20
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Emits a change event to all subscribers for a given mutation type.
|
|
45
|
+
*
|
|
46
|
+
* @param propertyName - The kind of mutation (e.g., "set", "clear").
|
|
47
|
+
* @param value - The current state of the map.
|
|
48
|
+
*/
|
|
21
49
|
// @ts-ignore
|
|
22
50
|
emit(propertyName, value) {
|
|
23
51
|
this.container.emitAll(propertyName, value);
|
|
24
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Subscribes to changes and immediately emits the current map value.
|
|
55
|
+
*/
|
|
25
56
|
subscribe(target, propertyName, onUnsubscribe) {
|
|
26
57
|
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this);
|
|
27
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Subscribes to future changes without emitting the current value.
|
|
61
|
+
*
|
|
62
|
+
* @param target - Function to call on change.
|
|
63
|
+
* @param onUnsubscribe - Optional callback to invoke on unsubscription.
|
|
64
|
+
*/
|
|
65
|
+
listen(target, onUnsubscribe) {
|
|
66
|
+
return this.container.subscribe(target, onUnsubscribe) !== undefined;
|
|
67
|
+
}
|
|
28
68
|
unsubscribe(targe, propertyName = "") {
|
|
29
69
|
return this.container.unsubscribe(targe, propertyName);
|
|
30
70
|
}
|
|
71
|
+
/** Reactive mutation overrides **/
|
|
72
|
+
/**
|
|
73
|
+
* Sets a value for a given key and notifies subscribers.
|
|
74
|
+
*
|
|
75
|
+
* @param key - The key to insert or update.
|
|
76
|
+
* @param value - The value to associate with the key.
|
|
77
|
+
* @returns The map itself.
|
|
78
|
+
*/
|
|
31
79
|
set(key, value) {
|
|
32
80
|
const result = super.set(key, value);
|
|
33
81
|
this.container.emitAll("set", this);
|
|
34
82
|
return result;
|
|
35
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Deletes a key-value pair and notifies subscribers.
|
|
86
|
+
*
|
|
87
|
+
* @param key - The key to delete.
|
|
88
|
+
* @returns True if the key existed and was removed.
|
|
89
|
+
*/
|
|
36
90
|
delete(key) {
|
|
37
91
|
const result = super.delete(key);
|
|
38
92
|
this.container.emitAll("delete", this);
|
|
39
93
|
return result;
|
|
40
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Clears all entries from the map and notifies subscribers.
|
|
97
|
+
*/
|
|
41
98
|
clear() {
|
|
42
99
|
super.clear();
|
|
43
100
|
this.container.emitAll("clear", this);
|
|
44
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns a shallow copy of the current map state.
|
|
104
|
+
*/
|
|
45
105
|
valueOf() {
|
|
46
106
|
return new Map(Array.from(this));
|
|
47
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Ensures native `Map` is returned when using `Map` methods that create new instances.
|
|
110
|
+
*/
|
|
48
111
|
static get [Symbol.species]() {
|
|
49
112
|
return Map;
|
|
50
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Gets the current value of the reactive map.
|
|
116
|
+
* Returns a shallow copy to prevent unintended mutation.
|
|
117
|
+
*/
|
|
51
118
|
get value() {
|
|
52
119
|
return this.container.value.valueOf();
|
|
53
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Sets the entire contents of the map to match the given Map instance.
|
|
123
|
+
* If the same reference is passed, no update is triggered.
|
|
124
|
+
*
|
|
125
|
+
* @param value - A new Map to replace the current contents.
|
|
126
|
+
*/
|
|
54
127
|
set value(value) {
|
|
55
128
|
if (this === value)
|
|
56
129
|
return;
|
|
@@ -60,6 +133,10 @@ export class RefMap extends Map {
|
|
|
60
133
|
}
|
|
61
134
|
this.emit("value", value);
|
|
62
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Serializes the map to a plain JavaScript object for JSON output.
|
|
138
|
+
* Note: keys are converted to string.
|
|
139
|
+
*/
|
|
63
140
|
toJSON() {
|
|
64
141
|
const obj = {};
|
|
65
142
|
for (const [k, v] of this.value) {
|
package/core/ref/RefMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefMap.js","sourceRoot":"","sources":["../../../src/core/ref/RefMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,MAAM,CAAO,OAA6C;IACxE,OAAO,IAAI,MAAM,CAAO,OAAO,CAAC,CAAC;AACnC,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":"RefMap.js","sourceRoot":"","sources":["../../../src/core/ref/RefMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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K;YAAE,OAAO;QAC3B,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;YAC/B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,MAAM;QACJ,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
package/core/ref/RefNumber.d.ts
CHANGED
|
@@ -1,30 +1,123 @@
|
|
|
1
1
|
import { ref } from ".";
|
|
2
2
|
import { RefContainer } from "./RefContainer";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a reactive wrapper for a numeric value.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The initial number value.
|
|
7
|
+
* @returns A new instance of RefNumber.
|
|
8
|
+
*/
|
|
3
9
|
export declare function refNumber(value: number): RefNumber;
|
|
10
|
+
/**
|
|
11
|
+
* A union type representing either a primitive number or a reactive RefNumber.
|
|
12
|
+
*/
|
|
4
13
|
export type refNumber = number | RefNumber;
|
|
14
|
+
/**
|
|
15
|
+
* A reactive wrapper for numbers that behaves like a Number object.
|
|
16
|
+
* Allows subscriptions to value changes and integrates with primitive operations.
|
|
17
|
+
*/
|
|
5
18
|
export declare class RefNumber implements Number, ref<number> {
|
|
19
|
+
/**
|
|
20
|
+
* The container holding the internal value and managing subscriptions.
|
|
21
|
+
*/
|
|
6
22
|
readonly container: RefContainer;
|
|
23
|
+
/**
|
|
24
|
+
* A unique identifier used for external reference tracking (optional).
|
|
25
|
+
*/
|
|
7
26
|
readonly refKey: string;
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new reactive number wrapper.
|
|
29
|
+
*
|
|
30
|
+
* @param value - The initial number value.
|
|
31
|
+
* @param refKey - Optional key used to register in a shared Ref registry.
|
|
32
|
+
*/
|
|
8
33
|
constructor(value: number, refKey?: string);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Emits a change notification if the value has changed.
|
|
36
|
+
*
|
|
37
|
+
* @param propertyName - The name of the property being updated (usually "value").
|
|
38
|
+
* @param value - The new number value to assign.
|
|
39
|
+
*/
|
|
14
40
|
private emit;
|
|
41
|
+
/** Reactive subscription methods **/
|
|
15
42
|
subscribe(target: (arg: number) => void): boolean;
|
|
16
43
|
subscribe(target: (arg: number) => void, onUnsubscribe: Function): boolean;
|
|
17
44
|
subscribe(target: object, propertyName: string | symbol): boolean;
|
|
18
45
|
subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
|
|
19
46
|
subscribe(target: object | ((arg: number) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Subscribes to future value changes without emitting the current number.
|
|
49
|
+
*
|
|
50
|
+
* @param target - A function to be called on future updates.
|
|
51
|
+
* @param onUnsubscribe - Optional callback to be called upon unsubscription.
|
|
52
|
+
* @returns true if successfully subscribed.
|
|
53
|
+
*/
|
|
54
|
+
listen(target: (arg: number) => void, onUnsubscribe?: Function): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Unsubscribes a function or object property from receiving value updates.
|
|
57
|
+
*/
|
|
20
58
|
unsubscribe(target: (arg: number) => void): boolean;
|
|
21
59
|
unsubscribe(targe: object, propertyName: string | symbol): boolean;
|
|
22
|
-
|
|
23
|
-
|
|
60
|
+
/** Value access and primitives **/
|
|
61
|
+
/**
|
|
62
|
+
* Gets the current number value.
|
|
63
|
+
*/
|
|
24
64
|
get value(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Sets a new number value and notifies subscribers if it changed.
|
|
67
|
+
*
|
|
68
|
+
* @param value - The new number to set.
|
|
69
|
+
*/
|
|
25
70
|
set value(value: number);
|
|
71
|
+
/**
|
|
72
|
+
* Returns the primitive number value.
|
|
73
|
+
*/
|
|
74
|
+
valueOf(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Converts the value to a string using an optional radix.
|
|
77
|
+
*
|
|
78
|
+
* @param radix - An integer between 2 and 36 specifying the base.
|
|
79
|
+
*/
|
|
80
|
+
toString(radix?: number): string;
|
|
81
|
+
/**
|
|
82
|
+
* Converts the value to fixed-point notation.
|
|
83
|
+
*
|
|
84
|
+
* @param fractionDigits - Number of digits after the decimal point.
|
|
85
|
+
*/
|
|
86
|
+
toFixed(fractionDigits?: number): string;
|
|
87
|
+
/**
|
|
88
|
+
* Converts the value to exponential notation.
|
|
89
|
+
*
|
|
90
|
+
* @param fractionDigits - Number of digits after the decimal point.
|
|
91
|
+
*/
|
|
92
|
+
toExponential(fractionDigits?: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Formats the number to a specified precision.
|
|
95
|
+
*
|
|
96
|
+
* @param precision - Total number of significant digits.
|
|
97
|
+
*/
|
|
98
|
+
toPrecision(precision?: number): string;
|
|
99
|
+
/**
|
|
100
|
+
* Formats the number according to locale-specific rules.
|
|
101
|
+
*
|
|
102
|
+
* @param locales - A locale string or array of locale strings.
|
|
103
|
+
* @param options - Formatting options.
|
|
104
|
+
*/
|
|
105
|
+
toLocaleString(locales?: string, options?: Intl.NumberFormatOptions): string;
|
|
106
|
+
/**
|
|
107
|
+
* Supports automatic type coercion to a number in JS expressions.
|
|
108
|
+
*
|
|
109
|
+
* @param hint - Either "number", "string", or "default".
|
|
110
|
+
*/
|
|
111
|
+
[Symbol.toPrimitive](hint: string): number;
|
|
112
|
+
/**
|
|
113
|
+
* Identifies this class as a subtype of `Number`.
|
|
114
|
+
*/
|
|
115
|
+
static get [Symbol.species](): NumberConstructor;
|
|
116
|
+
/**
|
|
117
|
+
* Serializes the current value for JSON output.
|
|
118
|
+
* If this instance is the root ref, emits the raw value, otherwise wraps it.
|
|
119
|
+
*/
|
|
26
120
|
toJSON(): number | {
|
|
27
121
|
value: number;
|
|
28
122
|
};
|
|
29
|
-
toString(radix?: number): string;
|
|
30
123
|
}
|
package/core/ref/RefNumber.js
CHANGED
|
@@ -1,69 +1,160 @@
|
|
|
1
1
|
import { Ref } from ".";
|
|
2
2
|
import { RefContainer } from "./RefContainer";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a reactive wrapper for a numeric value.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The initial number value.
|
|
7
|
+
* @returns A new instance of RefNumber.
|
|
8
|
+
*/
|
|
3
9
|
export function refNumber(value) {
|
|
4
10
|
return new RefNumber(value);
|
|
5
11
|
}
|
|
12
|
+
// Enables `instanceof refNumber` to return true for RefNumber instances
|
|
6
13
|
Object.defineProperty(refNumber, Symbol.hasInstance, {
|
|
7
14
|
value: function (instance) {
|
|
8
15
|
return !!instance && instance instanceof RefNumber;
|
|
9
16
|
},
|
|
10
17
|
});
|
|
11
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A reactive wrapper for numbers that behaves like a Number object.
|
|
20
|
+
* Allows subscriptions to value changes and integrates with primitive operations.
|
|
21
|
+
*/
|
|
12
22
|
export class RefNumber {
|
|
23
|
+
/**
|
|
24
|
+
* The container holding the internal value and managing subscriptions.
|
|
25
|
+
*/
|
|
13
26
|
container;
|
|
27
|
+
/**
|
|
28
|
+
* A unique identifier used for external reference tracking (optional).
|
|
29
|
+
*/
|
|
14
30
|
refKey;
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new reactive number wrapper.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The initial number value.
|
|
35
|
+
* @param refKey - Optional key used to register in a shared Ref registry.
|
|
36
|
+
*/
|
|
15
37
|
constructor(value, refKey) {
|
|
16
38
|
this.refKey = refKey;
|
|
17
39
|
this.container = new RefContainer(value);
|
|
18
40
|
refKey && Ref.set(refKey, this);
|
|
19
41
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
toPrecision(precision) {
|
|
27
|
-
return this.value.toPrecision(precision);
|
|
28
|
-
}
|
|
29
|
-
valueOf() {
|
|
30
|
-
return this.value.valueOf();
|
|
31
|
-
}
|
|
32
|
-
toLocaleString(locales, options) {
|
|
33
|
-
return this.value.toLocaleString(locales, options);
|
|
34
|
-
}
|
|
42
|
+
/**
|
|
43
|
+
* Emits a change notification if the value has changed.
|
|
44
|
+
*
|
|
45
|
+
* @param propertyName - The name of the property being updated (usually "value").
|
|
46
|
+
* @param value - The new number value to assign.
|
|
47
|
+
*/
|
|
35
48
|
// @ts-ignore
|
|
36
49
|
emit(propertyName, value) {
|
|
37
50
|
if (this.value === value.valueOf())
|
|
38
51
|
return;
|
|
39
52
|
this.container.emitAll(propertyName, (this.container.value = value.valueOf()));
|
|
40
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Subscribes to value changes and immediately emits the current number.
|
|
56
|
+
*/
|
|
41
57
|
subscribe(target, propertyName, onUnsubscribe) {
|
|
42
58
|
return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this.value);
|
|
43
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Subscribes to future value changes without emitting the current number.
|
|
62
|
+
*
|
|
63
|
+
* @param target - A function to be called on future updates.
|
|
64
|
+
* @param onUnsubscribe - Optional callback to be called upon unsubscription.
|
|
65
|
+
* @returns true if successfully subscribed.
|
|
66
|
+
*/
|
|
67
|
+
listen(target, onUnsubscribe) {
|
|
68
|
+
return this.container.subscribe(target, onUnsubscribe) !== undefined;
|
|
69
|
+
}
|
|
44
70
|
unsubscribe(targe, propertyName = "") {
|
|
45
71
|
return this.container.unsubscribe(targe, propertyName);
|
|
46
72
|
}
|
|
73
|
+
/** Value access and primitives **/
|
|
74
|
+
/**
|
|
75
|
+
* Gets the current number value.
|
|
76
|
+
*/
|
|
77
|
+
get value() {
|
|
78
|
+
return this.container.value;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sets a new number value and notifies subscribers if it changed.
|
|
82
|
+
*
|
|
83
|
+
* @param value - The new number to set.
|
|
84
|
+
*/
|
|
85
|
+
set value(value) {
|
|
86
|
+
this.emit("value", value);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the primitive number value.
|
|
90
|
+
*/
|
|
91
|
+
valueOf() {
|
|
92
|
+
return this.value.valueOf();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Converts the value to a string using an optional radix.
|
|
96
|
+
*
|
|
97
|
+
* @param radix - An integer between 2 and 36 specifying the base.
|
|
98
|
+
*/
|
|
99
|
+
toString(radix) {
|
|
100
|
+
return this.value.toString(radix);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Converts the value to fixed-point notation.
|
|
104
|
+
*
|
|
105
|
+
* @param fractionDigits - Number of digits after the decimal point.
|
|
106
|
+
*/
|
|
107
|
+
toFixed(fractionDigits) {
|
|
108
|
+
return this.value.toFixed(fractionDigits);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Converts the value to exponential notation.
|
|
112
|
+
*
|
|
113
|
+
* @param fractionDigits - Number of digits after the decimal point.
|
|
114
|
+
*/
|
|
115
|
+
toExponential(fractionDigits) {
|
|
116
|
+
return this.value.toExponential(fractionDigits);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Formats the number to a specified precision.
|
|
120
|
+
*
|
|
121
|
+
* @param precision - Total number of significant digits.
|
|
122
|
+
*/
|
|
123
|
+
toPrecision(precision) {
|
|
124
|
+
return this.value.toPrecision(precision);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Formats the number according to locale-specific rules.
|
|
128
|
+
*
|
|
129
|
+
* @param locales - A locale string or array of locale strings.
|
|
130
|
+
* @param options - Formatting options.
|
|
131
|
+
*/
|
|
132
|
+
toLocaleString(locales, options) {
|
|
133
|
+
return this.value.toLocaleString(locales, options);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Supports automatic type coercion to a number in JS expressions.
|
|
137
|
+
*
|
|
138
|
+
* @param hint - Either "number", "string", or "default".
|
|
139
|
+
*/
|
|
47
140
|
[Symbol.toPrimitive](hint) {
|
|
48
141
|
if (hint === "number" || hint === "default") {
|
|
49
142
|
return this.value;
|
|
50
143
|
}
|
|
51
144
|
return this.valueOf();
|
|
52
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Identifies this class as a subtype of `Number`.
|
|
148
|
+
*/
|
|
53
149
|
static get [Symbol.species]() {
|
|
54
150
|
return Number;
|
|
55
151
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.emit("value", value);
|
|
61
|
-
}
|
|
152
|
+
/**
|
|
153
|
+
* Serializes the current value for JSON output.
|
|
154
|
+
* If this instance is the root ref, emits the raw value, otherwise wraps it.
|
|
155
|
+
*/
|
|
62
156
|
toJSON() {
|
|
63
157
|
return this.container.root ? this.value : { value: this.value };
|
|
64
158
|
}
|
|
65
|
-
toString(radix) {
|
|
66
|
-
return this.value.toString(radix);
|
|
67
|
-
}
|
|
68
159
|
}
|
|
69
160
|
//# sourceMappingURL=RefNumber.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RefNumber.js","sourceRoot":"","sources":["../../../src/core/ref/RefNumber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,E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