@expressive/mvc 0.36.2 → 0.36.3
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.d.ts +3 -1
- package/dist/index.js +12 -10
- package/dist/index.mjs +12 -10
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,11 @@ declare namespace Model {
|
|
|
5
5
|
type New<T extends Model = Model> = (new () => T) & typeof Model;
|
|
6
6
|
/** Subset of `keyof T` which are not methods or defined by base Model U. **/
|
|
7
7
|
type Field<T> = Exclude<keyof T, keyof Model>;
|
|
8
|
+
/** Any valid key for controller, including but not limited to keyof T. */
|
|
8
9
|
type Key<T> = Field<T> | (string & {}) | number | symbol;
|
|
10
|
+
/** Value for a given property managed by a controller. */
|
|
9
11
|
type Value<T extends Model, K extends Key<T>> = K extends keyof T ? T[K] extends Ref<infer V> ? V : T[K] : unknown;
|
|
12
|
+
type Event<T extends Model> = (this: T, key: unknown, source: T) => (() => void) | void | null;
|
|
10
13
|
type OnUpdate<T extends Model, K extends Key<T>> = (this: T, value: Value<T, K>, key: K, thisArg: K) => void;
|
|
11
14
|
/** Export/Import compatible value for a given property in a Model. */
|
|
12
15
|
type Export<R> = R extends Ref<infer T> ? T : R extends Model ? State<R> : R;
|
|
@@ -29,7 +32,6 @@ declare namespace Model {
|
|
|
29
32
|
};
|
|
30
33
|
/** A callback function which is subscribed to parent and updates when values change. */
|
|
31
34
|
type Effect<T> = (this: T, current: T, updated: Set<Model.Key<T>>) => ((update: boolean | null) => void) | Promise<void> | null | void;
|
|
32
|
-
type Event<T extends Model> = (this: T, key: unknown, source: T) => (() => void) | void | null;
|
|
33
35
|
namespace Instruction {
|
|
34
36
|
type Getter<T> = (source: Model) => T;
|
|
35
37
|
type Setter<T> = (value: T, previous: T) => boolean | void | (() => T);
|
package/dist/index.js
CHANGED
|
@@ -335,17 +335,19 @@ function update(subject, key, value, silent) {
|
|
|
335
335
|
return;
|
|
336
336
|
push(subject, key);
|
|
337
337
|
}
|
|
338
|
-
function push(subject, key) {
|
|
338
|
+
function push(subject, key, silent) {
|
|
339
339
|
let pending = PENDING2.get(subject);
|
|
340
340
|
if (!pending) {
|
|
341
341
|
PENDING2.set(subject, pending = /* @__PURE__ */ new Set());
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
if (!silent)
|
|
343
|
+
queue(() => {
|
|
344
|
+
event(subject, false);
|
|
345
|
+
PENDING2.delete(subject);
|
|
346
|
+
});
|
|
346
347
|
}
|
|
347
348
|
pending.add(key);
|
|
348
|
-
|
|
349
|
+
if (!silent)
|
|
350
|
+
event(subject, key);
|
|
349
351
|
}
|
|
350
352
|
function extract(from) {
|
|
351
353
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -570,10 +572,10 @@ function compute(subject, key, source, setter) {
|
|
|
570
572
|
compute2(true);
|
|
571
573
|
else if (STALE.delete(compute2))
|
|
572
574
|
compute2();
|
|
573
|
-
return (
|
|
574
|
-
if (
|
|
575
|
+
return (didUpdate) => {
|
|
576
|
+
if (didUpdate) {
|
|
575
577
|
STALE.add(compute2);
|
|
576
|
-
subject
|
|
578
|
+
push(subject, key, true);
|
|
577
579
|
}
|
|
578
580
|
};
|
|
579
581
|
});
|
|
@@ -588,7 +590,7 @@ function compute(subject, key, source, setter) {
|
|
|
588
590
|
throw err;
|
|
589
591
|
console.error(err);
|
|
590
592
|
}
|
|
591
|
-
subject
|
|
593
|
+
update(subject, key, next, !isAsync);
|
|
592
594
|
}
|
|
593
595
|
return () => {
|
|
594
596
|
if (!proxy) {
|
package/dist/index.mjs
CHANGED
|
@@ -302,17 +302,19 @@ function update(subject, key, value, silent) {
|
|
|
302
302
|
return;
|
|
303
303
|
push(subject, key);
|
|
304
304
|
}
|
|
305
|
-
function push(subject, key) {
|
|
305
|
+
function push(subject, key, silent) {
|
|
306
306
|
let pending = PENDING2.get(subject);
|
|
307
307
|
if (!pending) {
|
|
308
308
|
PENDING2.set(subject, pending = /* @__PURE__ */ new Set());
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
if (!silent)
|
|
310
|
+
queue(() => {
|
|
311
|
+
event(subject, false);
|
|
312
|
+
PENDING2.delete(subject);
|
|
313
|
+
});
|
|
313
314
|
}
|
|
314
315
|
pending.add(key);
|
|
315
|
-
|
|
316
|
+
if (!silent)
|
|
317
|
+
event(subject, key);
|
|
316
318
|
}
|
|
317
319
|
function extract(from) {
|
|
318
320
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -537,10 +539,10 @@ function compute(subject, key, source, setter) {
|
|
|
537
539
|
compute2(true);
|
|
538
540
|
else if (STALE.delete(compute2))
|
|
539
541
|
compute2();
|
|
540
|
-
return (
|
|
541
|
-
if (
|
|
542
|
+
return (didUpdate) => {
|
|
543
|
+
if (didUpdate) {
|
|
542
544
|
STALE.add(compute2);
|
|
543
|
-
subject
|
|
545
|
+
push(subject, key, true);
|
|
544
546
|
}
|
|
545
547
|
};
|
|
546
548
|
});
|
|
@@ -555,7 +557,7 @@ function compute(subject, key, source, setter) {
|
|
|
555
557
|
throw err;
|
|
556
558
|
console.error(err);
|
|
557
559
|
}
|
|
558
|
-
subject
|
|
560
|
+
update(subject, key, next, !isAsync);
|
|
559
561
|
}
|
|
560
562
|
return () => {
|
|
561
563
|
if (!proxy) {
|
package/package.json
CHANGED