@expressive/mvc 0.45.0 → 0.46.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.d.ts +2 -2
- package/dist/index.js +17 -11
- package/dist/index.mjs +17 -11
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ declare namespace Model {
|
|
|
15
15
|
type Field<T> = Exclude<keyof T, keyof Model>;
|
|
16
16
|
/** Any valid key for controller, including but not limited to Field<T>. */
|
|
17
17
|
type Event<T> = Field<T> | (string & {}) | number | symbol;
|
|
18
|
-
/** Object overlay which may be used to override values and methods
|
|
18
|
+
/** Object overlay which may be used to override values and methods on a model. */
|
|
19
19
|
type Assign<T> = {
|
|
20
20
|
[K in Exclude<keyof T, keyof Model>]?: T[K] extends (...args: infer A) => infer R ? (this: T, ...args: A) => R : T[K];
|
|
21
21
|
} & Record<string, unknown>;
|
|
@@ -380,7 +380,7 @@ declare class Context {
|
|
|
380
380
|
key(T: Model.Type, upstream?: boolean): keyof this;
|
|
381
381
|
has(model: Model): (() => void) | undefined;
|
|
382
382
|
get<T extends Model>(Type: Model.Type<T>): T | undefined;
|
|
383
|
-
include(inputs: Context.Input
|
|
383
|
+
include(inputs: Context.Input, forEach?: (added: Model, explicit: boolean) => void): void;
|
|
384
384
|
put<T extends Model>(T: Model.Type<T>, I: T | ((model: T) => void), implicit?: boolean, writable?: boolean): void;
|
|
385
385
|
add<T extends Model>(input: T | Model.Type<T>, implicit?: boolean): T;
|
|
386
386
|
push(inputs?: Context.Input): this;
|
package/dist/index.js
CHANGED
|
@@ -66,13 +66,16 @@ function watch(from, key, value) {
|
|
|
66
66
|
var PENDING = /* @__PURE__ */ new WeakMap();
|
|
67
67
|
function event(source, key) {
|
|
68
68
|
const subs = LISTENER.get(source);
|
|
69
|
+
const ready = !subs.has(onReady);
|
|
70
|
+
if (key === true && ready)
|
|
71
|
+
return;
|
|
69
72
|
let pending = PENDING.get(source);
|
|
70
73
|
if (pending) {
|
|
71
74
|
pending.add(key);
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
77
|
PENDING.set(source, pending = new Set(
|
|
75
|
-
key !== true &&
|
|
78
|
+
key !== true && ready ? [key] : [true, key]
|
|
76
79
|
));
|
|
77
80
|
pending.forEach((key2) => {
|
|
78
81
|
pending.delete(key2);
|
|
@@ -266,11 +269,12 @@ var Model = class _Model {
|
|
|
266
269
|
return event(this, null);
|
|
267
270
|
if (typeof arg1 == "object")
|
|
268
271
|
assign(self, arg1);
|
|
269
|
-
else if (arg1
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
else if (arg1 == void 0)
|
|
273
|
+
event(this, true);
|
|
274
|
+
else if (1 in arguments)
|
|
275
|
+
update(self, arg1, arg2, arg3);
|
|
276
|
+
else
|
|
277
|
+
push(self, arg1);
|
|
274
278
|
if (PENDING2.has(self))
|
|
275
279
|
return {
|
|
276
280
|
then: (res) => new Promise((res2) => {
|
|
@@ -732,7 +736,7 @@ var Context = class {
|
|
|
732
736
|
throw new Error(`Did find ${Type} in context, but multiple were defined.`);
|
|
733
737
|
return result;
|
|
734
738
|
}
|
|
735
|
-
include(inputs) {
|
|
739
|
+
include(inputs, forEach) {
|
|
736
740
|
const init = /* @__PURE__ */ new Map();
|
|
737
741
|
if (typeof inputs == "function" || inputs instanceof Model)
|
|
738
742
|
inputs = { [0]: inputs };
|
|
@@ -752,10 +756,13 @@ var Context = class {
|
|
|
752
756
|
} else if (exists !== input) {
|
|
753
757
|
this.pop();
|
|
754
758
|
this.id = uid();
|
|
755
|
-
|
|
759
|
+
this.include(inputs);
|
|
756
760
|
}
|
|
757
761
|
}
|
|
758
|
-
for (const [model] of init) {
|
|
762
|
+
for (const [model, explicit] of init) {
|
|
763
|
+
if (forEach)
|
|
764
|
+
forEach(model, explicit);
|
|
765
|
+
model.set();
|
|
759
766
|
this.has(model);
|
|
760
767
|
const expects = Expects.get(model);
|
|
761
768
|
if (expects)
|
|
@@ -767,7 +774,6 @@ var Context = class {
|
|
|
767
774
|
init.set(value, false);
|
|
768
775
|
}
|
|
769
776
|
}
|
|
770
|
-
return init;
|
|
771
777
|
}
|
|
772
778
|
put(T, I, implicit, writable) {
|
|
773
779
|
do {
|
|
@@ -788,7 +794,7 @@ var Context = class {
|
|
|
788
794
|
let I;
|
|
789
795
|
if (typeof input == "function") {
|
|
790
796
|
T = input;
|
|
791
|
-
I = input
|
|
797
|
+
I = new input();
|
|
792
798
|
} else {
|
|
793
799
|
I = input;
|
|
794
800
|
T = I.constructor;
|
package/dist/index.mjs
CHANGED
|
@@ -32,13 +32,16 @@ function watch(from, key, value) {
|
|
|
32
32
|
var PENDING = /* @__PURE__ */ new WeakMap();
|
|
33
33
|
function event(source, key) {
|
|
34
34
|
const subs = LISTENER.get(source);
|
|
35
|
+
const ready = !subs.has(onReady);
|
|
36
|
+
if (key === true && ready)
|
|
37
|
+
return;
|
|
35
38
|
let pending = PENDING.get(source);
|
|
36
39
|
if (pending) {
|
|
37
40
|
pending.add(key);
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
40
43
|
PENDING.set(source, pending = new Set(
|
|
41
|
-
key !== true &&
|
|
44
|
+
key !== true && ready ? [key] : [true, key]
|
|
42
45
|
));
|
|
43
46
|
pending.forEach((key2) => {
|
|
44
47
|
pending.delete(key2);
|
|
@@ -232,11 +235,12 @@ var Model = class _Model {
|
|
|
232
235
|
return event(this, null);
|
|
233
236
|
if (typeof arg1 == "object")
|
|
234
237
|
assign(self, arg1);
|
|
235
|
-
else if (arg1
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
else if (arg1 == void 0)
|
|
239
|
+
event(this, true);
|
|
240
|
+
else if (1 in arguments)
|
|
241
|
+
update(self, arg1, arg2, arg3);
|
|
242
|
+
else
|
|
243
|
+
push(self, arg1);
|
|
240
244
|
if (PENDING2.has(self))
|
|
241
245
|
return {
|
|
242
246
|
then: (res) => new Promise((res2) => {
|
|
@@ -698,7 +702,7 @@ var Context = class {
|
|
|
698
702
|
throw new Error(`Did find ${Type} in context, but multiple were defined.`);
|
|
699
703
|
return result;
|
|
700
704
|
}
|
|
701
|
-
include(inputs) {
|
|
705
|
+
include(inputs, forEach) {
|
|
702
706
|
const init = /* @__PURE__ */ new Map();
|
|
703
707
|
if (typeof inputs == "function" || inputs instanceof Model)
|
|
704
708
|
inputs = { [0]: inputs };
|
|
@@ -718,10 +722,13 @@ var Context = class {
|
|
|
718
722
|
} else if (exists !== input) {
|
|
719
723
|
this.pop();
|
|
720
724
|
this.id = uid();
|
|
721
|
-
|
|
725
|
+
this.include(inputs);
|
|
722
726
|
}
|
|
723
727
|
}
|
|
724
|
-
for (const [model] of init) {
|
|
728
|
+
for (const [model, explicit] of init) {
|
|
729
|
+
if (forEach)
|
|
730
|
+
forEach(model, explicit);
|
|
731
|
+
model.set();
|
|
725
732
|
this.has(model);
|
|
726
733
|
const expects = Expects.get(model);
|
|
727
734
|
if (expects)
|
|
@@ -733,7 +740,6 @@ var Context = class {
|
|
|
733
740
|
init.set(value, false);
|
|
734
741
|
}
|
|
735
742
|
}
|
|
736
|
-
return init;
|
|
737
743
|
}
|
|
738
744
|
put(T, I, implicit, writable) {
|
|
739
745
|
do {
|
|
@@ -754,7 +760,7 @@ var Context = class {
|
|
|
754
760
|
let I;
|
|
755
761
|
if (typeof input == "function") {
|
|
756
762
|
T = input;
|
|
757
|
-
I = input
|
|
763
|
+
I = new input();
|
|
758
764
|
} else {
|
|
759
765
|
I = input;
|
|
760
766
|
T = I.constructor;
|
package/package.json
CHANGED