@jay-framework/reactive 0.22.2 → 0.23.1
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/index.js +7 -16
- package/dist/tracing.js +17 -18
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
var MeasureOfChange = /* @__PURE__ */ ((MeasureOfChange2) => {
|
|
8
5
|
MeasureOfChange2[MeasureOfChange2["NO_CHANGE"] = 0] = "NO_CHANGE";
|
|
9
6
|
MeasureOfChange2[MeasureOfChange2["PARTIAL"] = 1] = "PARTIAL";
|
|
@@ -88,15 +85,13 @@ class Reactive {
|
|
|
88
85
|
let newValue = value();
|
|
89
86
|
setter(newValue);
|
|
90
87
|
});
|
|
91
|
-
} else
|
|
92
|
-
setter(value);
|
|
88
|
+
} else setter(value);
|
|
93
89
|
getter[GetterMark] = true;
|
|
94
90
|
setter[SetterMark] = true;
|
|
95
91
|
return [getter, setter];
|
|
96
92
|
}
|
|
97
93
|
triggerReaction(index, measureOfChange, paired) {
|
|
98
|
-
if (!this.inBatchReactions && !paired)
|
|
99
|
-
this.ScheduleAutoBatchRuns();
|
|
94
|
+
if (!this.inBatchReactions && !paired) this.ScheduleAutoBatchRuns();
|
|
100
95
|
this.batchedReactionsToRun[index] = Math.max(
|
|
101
96
|
measureOfChange,
|
|
102
97
|
this.batchedReactionsToRun[index] || 0
|
|
@@ -117,8 +112,7 @@ class Reactive {
|
|
|
117
112
|
);
|
|
118
113
|
}
|
|
119
114
|
batchReactions(func) {
|
|
120
|
-
if (this.inBatchReactions || this.inFlush)
|
|
121
|
-
return func();
|
|
115
|
+
if (this.inBatchReactions || this.inFlush) return func();
|
|
122
116
|
this.inBatchReactions = true;
|
|
123
117
|
[this.dirty, this.dirtyResolve] = mkResolvablePromise();
|
|
124
118
|
try {
|
|
@@ -155,8 +149,7 @@ class Reactive {
|
|
|
155
149
|
}
|
|
156
150
|
}
|
|
157
151
|
flush() {
|
|
158
|
-
if (this.inFlush || this.disabled)
|
|
159
|
-
return;
|
|
152
|
+
if (this.inFlush || this.disabled) return;
|
|
160
153
|
this.inFlush = true;
|
|
161
154
|
try {
|
|
162
155
|
for (let index = 0; index < this.batchedReactionsToRun.length; index++)
|
|
@@ -164,8 +157,7 @@ class Reactive {
|
|
|
164
157
|
this.runReaction(index, this.batchedReactionsToRun[index]);
|
|
165
158
|
if (this.isAutoBatchScheduled) {
|
|
166
159
|
this.isAutoBatchScheduled = false;
|
|
167
|
-
if (this.timeout)
|
|
168
|
-
clearTimeout(this.timeout);
|
|
160
|
+
if (this.timeout) clearTimeout(this.timeout);
|
|
169
161
|
this.timeout = void 0;
|
|
170
162
|
}
|
|
171
163
|
this.batchedReactionsToRun = [];
|
|
@@ -173,8 +165,7 @@ class Reactive {
|
|
|
173
165
|
} finally {
|
|
174
166
|
this.inFlush = false;
|
|
175
167
|
this.reactivesToFlush.forEach((reactive) => {
|
|
176
|
-
if (!reactive.inBatchReactions)
|
|
177
|
-
reactive.flush();
|
|
168
|
+
if (!reactive.inBatchReactions) reactive.flush();
|
|
178
169
|
});
|
|
179
170
|
this.reactivesToFlush.clear();
|
|
180
171
|
}
|
package/dist/tracing.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import { Reactive, MeasureOfChange, setMkReactive } from "./index.js";
|
|
2
5
|
class ReactiveTracer {
|
|
3
6
|
constructor(flushToConsole = false) {
|
|
7
|
+
__publicField(this, "log", []);
|
|
8
|
+
__publicField(this, "getStates", []);
|
|
9
|
+
__publicField(this, "setStates", []);
|
|
10
|
+
__publicField(this, "scheduledReactions", []);
|
|
11
|
+
__publicField(this, "inReaction", -1);
|
|
12
|
+
__publicField(this, "batches", []);
|
|
13
|
+
__publicField(this, "reactionLogPosition", []);
|
|
14
|
+
__publicField(this, "ident", "");
|
|
15
|
+
__publicField(this, "settingSignalFromBatch", "");
|
|
4
16
|
this.flushToConsole = flushToConsole;
|
|
5
|
-
this.log = [];
|
|
6
|
-
this.getStates = [];
|
|
7
|
-
this.setStates = [];
|
|
8
|
-
this.scheduledReactions = [];
|
|
9
|
-
this.inReaction = -1;
|
|
10
|
-
this.batches = [];
|
|
11
|
-
this.reactionLogPosition = [];
|
|
12
|
-
this.ident = "";
|
|
13
|
-
this.settingSignalFromBatch = "";
|
|
14
17
|
}
|
|
15
18
|
logGetState(name) {
|
|
16
|
-
if (this.inReaction > -1)
|
|
17
|
-
this.getStates[this.inReaction].add(name);
|
|
19
|
+
if (this.inReaction > -1) this.getStates[this.inReaction].add(name);
|
|
18
20
|
}
|
|
19
21
|
logSetState(name) {
|
|
20
|
-
if (this.inReaction > -1)
|
|
21
|
-
this.setStates[this.inReaction].add(name);
|
|
22
|
+
if (this.inReaction > -1) this.setStates[this.inReaction].add(name);
|
|
22
23
|
else {
|
|
23
24
|
this.scheduledReactions[this.inReaction] = /* @__PURE__ */ new Set();
|
|
24
25
|
this.settingSignalFromBatch = name;
|
|
@@ -49,8 +50,7 @@ class ReactiveTracer {
|
|
|
49
50
|
const logMessage = `${this.ident}${name} - ${reactionName}: (${signalGetters}) -> (${signalSetters}) --> (${scheduledReactions})`;
|
|
50
51
|
this.log.splice(reactionLogPosition, 0, logMessage);
|
|
51
52
|
this.inReaction--;
|
|
52
|
-
if (this.inReaction === -1)
|
|
53
|
-
this.flushLog();
|
|
53
|
+
if (this.inReaction === -1) this.flushLog();
|
|
54
54
|
}
|
|
55
55
|
beforeBatch(name) {
|
|
56
56
|
this.batches.push(name);
|
|
@@ -79,8 +79,7 @@ class ReactiveTracer {
|
|
|
79
79
|
}
|
|
80
80
|
doLog(message) {
|
|
81
81
|
this.log.push(`${this.ident}${message}`);
|
|
82
|
-
if (this.inReaction === -1)
|
|
83
|
-
this.flushLog();
|
|
82
|
+
if (this.inReaction === -1) this.flushLog();
|
|
84
83
|
}
|
|
85
84
|
flushLog() {
|
|
86
85
|
if (this.flushToConsole) {
|
|
@@ -120,9 +119,9 @@ function formatReactionName(num) {
|
|
|
120
119
|
class ReactiveWithTracking extends Reactive {
|
|
121
120
|
constructor(name, reactiveTracer) {
|
|
122
121
|
super();
|
|
122
|
+
__publicField(this, "stateIndex", 1);
|
|
123
123
|
this.name = name;
|
|
124
124
|
this.reactiveTracer = reactiveTracer;
|
|
125
|
-
this.stateIndex = 1;
|
|
126
125
|
}
|
|
127
126
|
createSignal(value, measureOfChange = MeasureOfChange.FULL) {
|
|
128
127
|
const stateName = this.name + this.stateIndex++;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/reactive",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test:watch": "vitest"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@jay-framework/dev-environment": "^0.
|
|
27
|
+
"@jay-framework/dev-environment": "^0.23.1",
|
|
28
28
|
"@types/node": "^20.11.5",
|
|
29
29
|
"rimraf": "^5.0.5",
|
|
30
30
|
"tsup": "^8.0.1",
|