@matthesketh/utopia-core 0.0.4 → 0.1.0
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.cjs +19 -2
- package/dist/index.js +19 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,8 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var subscriberStack = [];
|
|
31
31
|
var currentSubscriber = null;
|
|
32
32
|
var batchDepth = 0;
|
|
33
|
+
var computeDepth = 0;
|
|
34
|
+
var MAX_COMPUTE_DEPTH = 100;
|
|
33
35
|
var pendingEffects = /* @__PURE__ */ new Set();
|
|
34
36
|
function pushSubscriber(sub) {
|
|
35
37
|
subscriberStack.push(currentSubscriber);
|
|
@@ -147,6 +149,10 @@ var ComputedNode = class {
|
|
|
147
149
|
}
|
|
148
150
|
/** Recompute the derived value. */
|
|
149
151
|
_recompute() {
|
|
152
|
+
if (computeDepth >= MAX_COMPUTE_DEPTH) {
|
|
153
|
+
throw new Error("Circular dependency detected in computed chain");
|
|
154
|
+
}
|
|
155
|
+
computeDepth++;
|
|
150
156
|
this._computing = true;
|
|
151
157
|
this._cleanup();
|
|
152
158
|
pushSubscriber(this);
|
|
@@ -159,6 +165,7 @@ var ComputedNode = class {
|
|
|
159
165
|
this._signalNode._value = newValue;
|
|
160
166
|
}
|
|
161
167
|
} finally {
|
|
168
|
+
computeDepth--;
|
|
162
169
|
popSubscriber();
|
|
163
170
|
this._computing = false;
|
|
164
171
|
}
|
|
@@ -209,7 +216,11 @@ var EffectNode = class {
|
|
|
209
216
|
return;
|
|
210
217
|
}
|
|
211
218
|
if (this._cleanupFn) {
|
|
212
|
-
|
|
219
|
+
try {
|
|
220
|
+
this._cleanupFn();
|
|
221
|
+
} catch (err) {
|
|
222
|
+
console.error("Error in effect cleanup:", err);
|
|
223
|
+
}
|
|
213
224
|
this._cleanupFn = void 0;
|
|
214
225
|
}
|
|
215
226
|
this._unsubscribe();
|
|
@@ -217,6 +228,8 @@ var EffectNode = class {
|
|
|
217
228
|
try {
|
|
218
229
|
const result = this._fn();
|
|
219
230
|
this._cleanupFn = typeof result === "function" ? result : void 0;
|
|
231
|
+
} catch (err) {
|
|
232
|
+
console.error("Error in effect:", err);
|
|
220
233
|
} finally {
|
|
221
234
|
popSubscriber();
|
|
222
235
|
this._queued = false;
|
|
@@ -233,7 +246,11 @@ var EffectNode = class {
|
|
|
233
246
|
_dispose() {
|
|
234
247
|
this._disposed = true;
|
|
235
248
|
if (this._cleanupFn) {
|
|
236
|
-
|
|
249
|
+
try {
|
|
250
|
+
this._cleanupFn();
|
|
251
|
+
} catch (err) {
|
|
252
|
+
console.error("Error in effect cleanup:", err);
|
|
253
|
+
}
|
|
237
254
|
this._cleanupFn = void 0;
|
|
238
255
|
}
|
|
239
256
|
this._unsubscribe();
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
var subscriberStack = [];
|
|
3
3
|
var currentSubscriber = null;
|
|
4
4
|
var batchDepth = 0;
|
|
5
|
+
var computeDepth = 0;
|
|
6
|
+
var MAX_COMPUTE_DEPTH = 100;
|
|
5
7
|
var pendingEffects = /* @__PURE__ */ new Set();
|
|
6
8
|
function pushSubscriber(sub) {
|
|
7
9
|
subscriberStack.push(currentSubscriber);
|
|
@@ -119,6 +121,10 @@ var ComputedNode = class {
|
|
|
119
121
|
}
|
|
120
122
|
/** Recompute the derived value. */
|
|
121
123
|
_recompute() {
|
|
124
|
+
if (computeDepth >= MAX_COMPUTE_DEPTH) {
|
|
125
|
+
throw new Error("Circular dependency detected in computed chain");
|
|
126
|
+
}
|
|
127
|
+
computeDepth++;
|
|
122
128
|
this._computing = true;
|
|
123
129
|
this._cleanup();
|
|
124
130
|
pushSubscriber(this);
|
|
@@ -131,6 +137,7 @@ var ComputedNode = class {
|
|
|
131
137
|
this._signalNode._value = newValue;
|
|
132
138
|
}
|
|
133
139
|
} finally {
|
|
140
|
+
computeDepth--;
|
|
134
141
|
popSubscriber();
|
|
135
142
|
this._computing = false;
|
|
136
143
|
}
|
|
@@ -181,7 +188,11 @@ var EffectNode = class {
|
|
|
181
188
|
return;
|
|
182
189
|
}
|
|
183
190
|
if (this._cleanupFn) {
|
|
184
|
-
|
|
191
|
+
try {
|
|
192
|
+
this._cleanupFn();
|
|
193
|
+
} catch (err) {
|
|
194
|
+
console.error("Error in effect cleanup:", err);
|
|
195
|
+
}
|
|
185
196
|
this._cleanupFn = void 0;
|
|
186
197
|
}
|
|
187
198
|
this._unsubscribe();
|
|
@@ -189,6 +200,8 @@ var EffectNode = class {
|
|
|
189
200
|
try {
|
|
190
201
|
const result = this._fn();
|
|
191
202
|
this._cleanupFn = typeof result === "function" ? result : void 0;
|
|
203
|
+
} catch (err) {
|
|
204
|
+
console.error("Error in effect:", err);
|
|
192
205
|
} finally {
|
|
193
206
|
popSubscriber();
|
|
194
207
|
this._queued = false;
|
|
@@ -205,7 +218,11 @@ var EffectNode = class {
|
|
|
205
218
|
_dispose() {
|
|
206
219
|
this._disposed = true;
|
|
207
220
|
if (this._cleanupFn) {
|
|
208
|
-
|
|
221
|
+
try {
|
|
222
|
+
this._cleanupFn();
|
|
223
|
+
} catch (err) {
|
|
224
|
+
console.error("Error in effect cleanup:", err);
|
|
225
|
+
}
|
|
209
226
|
this._cleanupFn = void 0;
|
|
210
227
|
}
|
|
211
228
|
this._unsubscribe();
|