@expressive/mvc 0.53.2 → 0.53.5
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 +14 -16
- package/dist/index.mjs +11 -13
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -370,12 +370,12 @@ declare function set<T>(factory: set.Factory<T> | Promise<T>, required: false):
|
|
|
370
370
|
*/
|
|
371
371
|
declare function set<T>(factory: set.Factory<T> | Promise<T>, required?: boolean): T;
|
|
372
372
|
/**
|
|
373
|
-
* Set a property with empty placeholder and update callback.
|
|
373
|
+
* Set a property with empty placeholder and/or update callback.
|
|
374
374
|
*
|
|
375
375
|
* @param value - Starting value for property. If undefined, suspense will be thrown on access, until value is set and accepted by callback.
|
|
376
376
|
* @param onUpdate - Callback run when property is set. If returns false, update is not accepted and property will keep previous value.
|
|
377
377
|
*/
|
|
378
|
-
declare function set<T>(value: T | undefined, onUpdate
|
|
378
|
+
declare function set<T>(value: T | undefined, onUpdate?: set.Callback<T>): T;
|
|
379
379
|
|
|
380
380
|
declare function use<T>(instruction: Model.Instruction<T>): T extends void ? unknown : T;
|
|
381
381
|
declare function use<T extends Model>(Type: Model.Init<T>, required: false): T | undefined;
|
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
Context: () => Context,
|
|
24
24
|
Model: () => Model,
|
|
25
25
|
addListener: () => addListener,
|
|
@@ -32,7 +32,7 @@ __export(src_exports, {
|
|
|
32
32
|
set: () => set,
|
|
33
33
|
use: () => use
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// src/control.ts
|
|
38
38
|
var onReady = () => null;
|
|
@@ -300,10 +300,8 @@ function prepare(model) {
|
|
|
300
300
|
while (T.name) {
|
|
301
301
|
for (const cb of NOTIFY.get(T) || [])
|
|
302
302
|
addListener(model, cb);
|
|
303
|
-
if (T === Model)
|
|
304
|
-
|
|
305
|
-
else
|
|
306
|
-
chain.unshift(T);
|
|
303
|
+
if (T === Model) break;
|
|
304
|
+
else chain.unshift(T);
|
|
307
305
|
T = Object.getPrototypeOf(T);
|
|
308
306
|
}
|
|
309
307
|
for (const type of chain) {
|
|
@@ -789,7 +787,7 @@ function ref(arg, arg2) {
|
|
|
789
787
|
// src/instruction/set.ts
|
|
790
788
|
function set(value, argument) {
|
|
791
789
|
return use((key2, subject) => {
|
|
792
|
-
const
|
|
790
|
+
const property = {};
|
|
793
791
|
if (typeof value == "function" || value instanceof Promise) {
|
|
794
792
|
let init3 = function() {
|
|
795
793
|
if (typeof value == "function")
|
|
@@ -799,14 +797,14 @@ function set(value, argument) {
|
|
|
799
797
|
console.warn(`Generating initial value for ${subject}.${key2} failed.`);
|
|
800
798
|
throw err;
|
|
801
799
|
}
|
|
802
|
-
|
|
800
|
+
property.get = argument === true;
|
|
803
801
|
if (value instanceof Promise) {
|
|
804
802
|
value.then((value2) => {
|
|
805
803
|
update(subject, key2, value2);
|
|
806
804
|
return value2;
|
|
807
805
|
}).catch((err) => {
|
|
808
806
|
event(subject, key2);
|
|
809
|
-
|
|
807
|
+
property.get = () => {
|
|
810
808
|
throw err;
|
|
811
809
|
};
|
|
812
810
|
});
|
|
@@ -819,12 +817,12 @@ function set(value, argument) {
|
|
|
819
817
|
if (argument)
|
|
820
818
|
init3();
|
|
821
819
|
else
|
|
822
|
-
|
|
820
|
+
property.get = init3;
|
|
823
821
|
} else if (value !== void 0)
|
|
824
|
-
|
|
822
|
+
property.value = value;
|
|
825
823
|
if (typeof argument == "function") {
|
|
826
824
|
let unSet;
|
|
827
|
-
|
|
825
|
+
property.set = function(value2, previous) {
|
|
828
826
|
const out = argument.call(this, value2, previous);
|
|
829
827
|
if (out === false)
|
|
830
828
|
return out;
|
|
@@ -834,11 +832,11 @@ function set(value, argument) {
|
|
|
834
832
|
unSet = out;
|
|
835
833
|
};
|
|
836
834
|
} else
|
|
837
|
-
|
|
838
|
-
|
|
835
|
+
property.set = (value2) => {
|
|
836
|
+
property.get = void 0;
|
|
839
837
|
update(subject, key2, value2);
|
|
840
838
|
};
|
|
841
|
-
return
|
|
839
|
+
return property;
|
|
842
840
|
});
|
|
843
841
|
}
|
|
844
842
|
function attempt(fn) {
|
package/dist/index.mjs
CHANGED
|
@@ -264,10 +264,8 @@ function prepare(model) {
|
|
|
264
264
|
while (T.name) {
|
|
265
265
|
for (const cb of NOTIFY.get(T) || [])
|
|
266
266
|
addListener(model, cb);
|
|
267
|
-
if (T === Model)
|
|
268
|
-
|
|
269
|
-
else
|
|
270
|
-
chain.unshift(T);
|
|
267
|
+
if (T === Model) break;
|
|
268
|
+
else chain.unshift(T);
|
|
271
269
|
T = Object.getPrototypeOf(T);
|
|
272
270
|
}
|
|
273
271
|
for (const type of chain) {
|
|
@@ -753,7 +751,7 @@ function ref(arg, arg2) {
|
|
|
753
751
|
// src/instruction/set.ts
|
|
754
752
|
function set(value, argument) {
|
|
755
753
|
return use((key2, subject) => {
|
|
756
|
-
const
|
|
754
|
+
const property = {};
|
|
757
755
|
if (typeof value == "function" || value instanceof Promise) {
|
|
758
756
|
let init3 = function() {
|
|
759
757
|
if (typeof value == "function")
|
|
@@ -763,14 +761,14 @@ function set(value, argument) {
|
|
|
763
761
|
console.warn(`Generating initial value for ${subject}.${key2} failed.`);
|
|
764
762
|
throw err;
|
|
765
763
|
}
|
|
766
|
-
|
|
764
|
+
property.get = argument === true;
|
|
767
765
|
if (value instanceof Promise) {
|
|
768
766
|
value.then((value2) => {
|
|
769
767
|
update(subject, key2, value2);
|
|
770
768
|
return value2;
|
|
771
769
|
}).catch((err) => {
|
|
772
770
|
event(subject, key2);
|
|
773
|
-
|
|
771
|
+
property.get = () => {
|
|
774
772
|
throw err;
|
|
775
773
|
};
|
|
776
774
|
});
|
|
@@ -783,12 +781,12 @@ function set(value, argument) {
|
|
|
783
781
|
if (argument)
|
|
784
782
|
init3();
|
|
785
783
|
else
|
|
786
|
-
|
|
784
|
+
property.get = init3;
|
|
787
785
|
} else if (value !== void 0)
|
|
788
|
-
|
|
786
|
+
property.value = value;
|
|
789
787
|
if (typeof argument == "function") {
|
|
790
788
|
let unSet;
|
|
791
|
-
|
|
789
|
+
property.set = function(value2, previous) {
|
|
792
790
|
const out = argument.call(this, value2, previous);
|
|
793
791
|
if (out === false)
|
|
794
792
|
return out;
|
|
@@ -798,11 +796,11 @@ function set(value, argument) {
|
|
|
798
796
|
unSet = out;
|
|
799
797
|
};
|
|
800
798
|
} else
|
|
801
|
-
|
|
802
|
-
|
|
799
|
+
property.set = (value2) => {
|
|
800
|
+
property.get = void 0;
|
|
803
801
|
update(subject, key2, value2);
|
|
804
802
|
};
|
|
805
|
-
return
|
|
803
|
+
return property;
|
|
806
804
|
});
|
|
807
805
|
}
|
|
808
806
|
function attempt(fn) {
|
package/package.json
CHANGED
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
"preversion": "npm run test && npm run build"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
+
"@types/node": "^18.19.0",
|
|
32
33
|
"jest": "^27.0.6",
|
|
33
34
|
"tsup": "^8.0.2"
|
|
34
35
|
},
|
|
35
|
-
"version": "0.53.
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"version": "0.53.5",
|
|
37
|
+
"gitHead": "7db2ee1e4e62b3ac065c69a9dc94a03edf37fb85"
|
|
37
38
|
}
|