@mulsense/xnew 0.3.1 → 0.3.2
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/addons/xpixi.js +1 -6
- package/dist/addons/xpixi.mjs +1 -6
- package/dist/addons/xrapier2d.js +1 -1
- package/dist/addons/xrapier2d.mjs +1 -1
- package/dist/types/core/unit.d.ts +2 -1
- package/dist/types/core/xnew.d.ts +1 -1
- package/dist/xnew.d.ts +3 -2
- package/dist/xnew.js +17 -6
- package/dist/xnew.mjs +17 -6
- package/package.json +1 -1
package/dist/addons/xpixi.js
CHANGED
|
@@ -60,12 +60,7 @@
|
|
|
60
60
|
antialias: true, backgroundAlpha: 0,
|
|
61
61
|
});
|
|
62
62
|
root.renderer = null;
|
|
63
|
-
|
|
64
|
-
xnew.promise(renderer).then((renderer) => root.renderer = renderer);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
root.renderer = renderer;
|
|
68
|
-
}
|
|
63
|
+
xnew.promise(renderer, false).then((renderer) => root.renderer = renderer);
|
|
69
64
|
root.updates = [];
|
|
70
65
|
root.scene = new PIXI__namespace.Container();
|
|
71
66
|
xnew.context('xpixi.object', root.scene);
|
package/dist/addons/xpixi.mjs
CHANGED
|
@@ -38,12 +38,7 @@ function Root(self, { canvas }) {
|
|
|
38
38
|
antialias: true, backgroundAlpha: 0,
|
|
39
39
|
});
|
|
40
40
|
root.renderer = null;
|
|
41
|
-
|
|
42
|
-
xnew.promise(renderer).then((renderer) => root.renderer = renderer);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
root.renderer = renderer;
|
|
46
|
-
}
|
|
41
|
+
xnew.promise(renderer, false).then((renderer) => root.renderer = renderer);
|
|
47
42
|
root.updates = [];
|
|
48
43
|
root.scene = new PIXI.Container();
|
|
49
44
|
xnew.context('xpixi.object', root.scene);
|
package/dist/addons/xrapier2d.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
function Root(self, { gravity, timestep }) {
|
|
21
21
|
const root = {};
|
|
22
22
|
xnew.context('xrapier2d.root', root);
|
|
23
|
-
xnew.promise(RAPIER.init()).then(() => {
|
|
23
|
+
xnew.promise(RAPIER.init(), false).then(() => {
|
|
24
24
|
root.world = new RAPIER.World(gravity);
|
|
25
25
|
if (timestep !== null) {
|
|
26
26
|
root.world.timestep = timestep;
|
|
@@ -17,7 +17,7 @@ var xrapier2d = {
|
|
|
17
17
|
function Root(self, { gravity, timestep }) {
|
|
18
18
|
const root = {};
|
|
19
19
|
xnew.context('xrapier2d.root', root);
|
|
20
|
-
xnew.promise(RAPIER.init()).then(() => {
|
|
20
|
+
xnew.promise(RAPIER.init(), false).then(() => {
|
|
21
21
|
root.world = new RAPIER.World(gravity);
|
|
22
22
|
if (timestep !== null) {
|
|
23
23
|
root.world.timestep = timestep;
|
|
@@ -71,7 +71,8 @@ export declare class Unit {
|
|
|
71
71
|
}
|
|
72
72
|
export declare class UnitPromise {
|
|
73
73
|
promise: Promise<any>;
|
|
74
|
-
|
|
74
|
+
useResult: Boolean;
|
|
75
|
+
constructor(promise: Promise<any>, useResult: Boolean);
|
|
75
76
|
then(callback: Function): UnitPromise;
|
|
76
77
|
catch(callback: Function): UnitPromise;
|
|
77
78
|
finally(callback: Function): UnitPromise;
|
|
@@ -65,7 +65,7 @@ export declare const xnew: CreateUnit & {
|
|
|
65
65
|
* @example
|
|
66
66
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
67
67
|
*/
|
|
68
|
-
promise(promise: Promise<any
|
|
68
|
+
promise(promise: Promise<any>, useResult?: Boolean): UnitPromise;
|
|
69
69
|
/**
|
|
70
70
|
* Handles successful resolution of all registered promises in the current component
|
|
71
71
|
* @param callback - Function to call when all promises resolve
|
package/dist/xnew.d.ts
CHANGED
|
@@ -97,7 +97,8 @@ declare class Unit {
|
|
|
97
97
|
}
|
|
98
98
|
declare class UnitPromise {
|
|
99
99
|
promise: Promise<any>;
|
|
100
|
-
|
|
100
|
+
useResult: Boolean;
|
|
101
|
+
constructor(promise: Promise<any>, useResult: Boolean);
|
|
101
102
|
then(callback: Function): UnitPromise;
|
|
102
103
|
catch(callback: Function): UnitPromise;
|
|
103
104
|
finally(callback: Function): UnitPromise;
|
|
@@ -169,7 +170,7 @@ declare const xnew$1: CreateUnit & {
|
|
|
169
170
|
* @example
|
|
170
171
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
171
172
|
*/
|
|
172
|
-
promise(promise: Promise<any
|
|
173
|
+
promise(promise: Promise<any>, useResult?: Boolean): UnitPromise;
|
|
173
174
|
/**
|
|
174
175
|
* Handles successful resolution of all registered promises in the current component
|
|
175
176
|
* @param callback - Function to call when all promises resolve
|
package/dist/xnew.js
CHANGED
|
@@ -527,7 +527,10 @@
|
|
|
527
527
|
// unit promise
|
|
528
528
|
//----------------------------------------------------------------------------------------------------
|
|
529
529
|
class UnitPromise {
|
|
530
|
-
constructor(promise) {
|
|
530
|
+
constructor(promise, useResult) {
|
|
531
|
+
this.promise = promise;
|
|
532
|
+
this.useResult = useResult;
|
|
533
|
+
}
|
|
531
534
|
then(callback) {
|
|
532
535
|
this.promise = this.promise.then(Unit.wrap(Unit.current, callback));
|
|
533
536
|
return this;
|
|
@@ -675,9 +678,9 @@
|
|
|
675
678
|
* @example
|
|
676
679
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
677
680
|
*/
|
|
678
|
-
promise(promise) {
|
|
681
|
+
promise(promise, useResult = true) {
|
|
679
682
|
try {
|
|
680
|
-
Unit.current._.promises.push(new UnitPromise(promise));
|
|
683
|
+
Unit.current._.promises.push(new UnitPromise(promise, useResult));
|
|
681
684
|
return Unit.current._.promises[Unit.current._.promises.length - 1];
|
|
682
685
|
}
|
|
683
686
|
catch (error) {
|
|
@@ -694,7 +697,11 @@
|
|
|
694
697
|
*/
|
|
695
698
|
then(callback) {
|
|
696
699
|
try {
|
|
697
|
-
|
|
700
|
+
const promises = Unit.current._.promises;
|
|
701
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
702
|
+
.then((results) => {
|
|
703
|
+
callback(results.filter((_result, index) => promises[index].useResult));
|
|
704
|
+
});
|
|
698
705
|
}
|
|
699
706
|
catch (error) {
|
|
700
707
|
console.error('xnew.then(callback: Function): ', error);
|
|
@@ -710,7 +717,9 @@
|
|
|
710
717
|
*/
|
|
711
718
|
catch(callback) {
|
|
712
719
|
try {
|
|
713
|
-
|
|
720
|
+
const promises = Unit.current._.promises;
|
|
721
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
722
|
+
.catch(callback);
|
|
714
723
|
}
|
|
715
724
|
catch (error) {
|
|
716
725
|
console.error('xnew.catch(callback: Function): ', error);
|
|
@@ -726,7 +735,9 @@
|
|
|
726
735
|
*/
|
|
727
736
|
finally(callback) {
|
|
728
737
|
try {
|
|
729
|
-
|
|
738
|
+
const promises = Unit.current._.promises;
|
|
739
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
740
|
+
.finally(callback);
|
|
730
741
|
}
|
|
731
742
|
catch (error) {
|
|
732
743
|
console.error('xnew.finally(callback: Function): ', error);
|
package/dist/xnew.mjs
CHANGED
|
@@ -521,7 +521,10 @@ Unit.type2units = new MapSet();
|
|
|
521
521
|
// unit promise
|
|
522
522
|
//----------------------------------------------------------------------------------------------------
|
|
523
523
|
class UnitPromise {
|
|
524
|
-
constructor(promise) {
|
|
524
|
+
constructor(promise, useResult) {
|
|
525
|
+
this.promise = promise;
|
|
526
|
+
this.useResult = useResult;
|
|
527
|
+
}
|
|
525
528
|
then(callback) {
|
|
526
529
|
this.promise = this.promise.then(Unit.wrap(Unit.current, callback));
|
|
527
530
|
return this;
|
|
@@ -669,9 +672,9 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
669
672
|
* @example
|
|
670
673
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
671
674
|
*/
|
|
672
|
-
promise(promise) {
|
|
675
|
+
promise(promise, useResult = true) {
|
|
673
676
|
try {
|
|
674
|
-
Unit.current._.promises.push(new UnitPromise(promise));
|
|
677
|
+
Unit.current._.promises.push(new UnitPromise(promise, useResult));
|
|
675
678
|
return Unit.current._.promises[Unit.current._.promises.length - 1];
|
|
676
679
|
}
|
|
677
680
|
catch (error) {
|
|
@@ -688,7 +691,11 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
688
691
|
*/
|
|
689
692
|
then(callback) {
|
|
690
693
|
try {
|
|
691
|
-
|
|
694
|
+
const promises = Unit.current._.promises;
|
|
695
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
696
|
+
.then((results) => {
|
|
697
|
+
callback(results.filter((_result, index) => promises[index].useResult));
|
|
698
|
+
});
|
|
692
699
|
}
|
|
693
700
|
catch (error) {
|
|
694
701
|
console.error('xnew.then(callback: Function): ', error);
|
|
@@ -704,7 +711,9 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
704
711
|
*/
|
|
705
712
|
catch(callback) {
|
|
706
713
|
try {
|
|
707
|
-
|
|
714
|
+
const promises = Unit.current._.promises;
|
|
715
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
716
|
+
.catch(callback);
|
|
708
717
|
}
|
|
709
718
|
catch (error) {
|
|
710
719
|
console.error('xnew.catch(callback: Function): ', error);
|
|
@@ -720,7 +729,9 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
720
729
|
*/
|
|
721
730
|
finally(callback) {
|
|
722
731
|
try {
|
|
723
|
-
|
|
732
|
+
const promises = Unit.current._.promises;
|
|
733
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
734
|
+
.finally(callback);
|
|
724
735
|
}
|
|
725
736
|
catch (error) {
|
|
726
737
|
console.error('xnew.finally(callback: Function): ', error);
|