@mulsense/xnew 0.3.0 → 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 +4 -4
- package/dist/types/core/xnew.d.ts +1 -1
- package/dist/xnew.d.ts +5 -5
- package/dist/xnew.js +19 -11
- package/dist/xnew.mjs +19 -11
- 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;
|
|
@@ -26,7 +26,7 @@ interface UnitInternal {
|
|
|
26
26
|
protected: boolean;
|
|
27
27
|
ancestors: Unit[];
|
|
28
28
|
children: Unit[];
|
|
29
|
-
promises:
|
|
29
|
+
promises: UnitPromise[];
|
|
30
30
|
elements: UnitElement[];
|
|
31
31
|
components: Function[];
|
|
32
32
|
listeners: MapMap<string, Function, {
|
|
@@ -41,7 +41,6 @@ export declare class Unit {
|
|
|
41
41
|
_: UnitInternal;
|
|
42
42
|
constructor(parent: Unit | null, ...args: any[]);
|
|
43
43
|
get element(): UnitElement;
|
|
44
|
-
get components(): Function[];
|
|
45
44
|
start(): void;
|
|
46
45
|
stop(): void;
|
|
47
46
|
finalize(): void;
|
|
@@ -71,8 +70,9 @@ export declare class Unit {
|
|
|
71
70
|
static emit(type: string, ...args: any[]): void;
|
|
72
71
|
}
|
|
73
72
|
export declare class UnitPromise {
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
promise: Promise<any>;
|
|
74
|
+
useResult: Boolean;
|
|
75
|
+
constructor(promise: Promise<any>, useResult: Boolean);
|
|
76
76
|
then(callback: Function): UnitPromise;
|
|
77
77
|
catch(callback: Function): UnitPromise;
|
|
78
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
|
@@ -52,7 +52,7 @@ interface UnitInternal {
|
|
|
52
52
|
protected: boolean;
|
|
53
53
|
ancestors: Unit[];
|
|
54
54
|
children: Unit[];
|
|
55
|
-
promises:
|
|
55
|
+
promises: UnitPromise[];
|
|
56
56
|
elements: UnitElement[];
|
|
57
57
|
components: Function[];
|
|
58
58
|
listeners: MapMap<string, Function, {
|
|
@@ -67,7 +67,6 @@ declare class Unit {
|
|
|
67
67
|
_: UnitInternal;
|
|
68
68
|
constructor(parent: Unit | null, ...args: any[]);
|
|
69
69
|
get element(): UnitElement;
|
|
70
|
-
get components(): Function[];
|
|
71
70
|
start(): void;
|
|
72
71
|
stop(): void;
|
|
73
72
|
finalize(): void;
|
|
@@ -97,8 +96,9 @@ declare class Unit {
|
|
|
97
96
|
static emit(type: string, ...args: any[]): void;
|
|
98
97
|
}
|
|
99
98
|
declare class UnitPromise {
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
promise: Promise<any>;
|
|
100
|
+
useResult: Boolean;
|
|
101
|
+
constructor(promise: Promise<any>, useResult: Boolean);
|
|
102
102
|
then(callback: Function): UnitPromise;
|
|
103
103
|
catch(callback: Function): UnitPromise;
|
|
104
104
|
finally(callback: Function): UnitPromise;
|
|
@@ -170,7 +170,7 @@ declare const xnew$1: CreateUnit & {
|
|
|
170
170
|
* @example
|
|
171
171
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
172
172
|
*/
|
|
173
|
-
promise(promise: Promise<any
|
|
173
|
+
promise(promise: Promise<any>, useResult?: Boolean): UnitPromise;
|
|
174
174
|
/**
|
|
175
175
|
* Handles successful resolution of all registered promises in the current component
|
|
176
176
|
* @param callback - Function to call when all promises resolve
|
package/dist/xnew.js
CHANGED
|
@@ -262,9 +262,6 @@
|
|
|
262
262
|
get element() {
|
|
263
263
|
return this._.currentElement;
|
|
264
264
|
}
|
|
265
|
-
get components() {
|
|
266
|
-
return this._.components;
|
|
267
|
-
}
|
|
268
265
|
start() {
|
|
269
266
|
this._.tostart = true;
|
|
270
267
|
}
|
|
@@ -313,7 +310,7 @@
|
|
|
313
310
|
// setup component
|
|
314
311
|
Unit.extend(unit, unit._.baseComponent, unit._.props);
|
|
315
312
|
// whether the unit promise was resolved
|
|
316
|
-
Promise.all(unit._.promises).then(() => unit._.state = 'initialized');
|
|
313
|
+
Promise.all(unit._.promises.map(p => p.promise)).then(() => unit._.state = 'initialized');
|
|
317
314
|
Unit.current = backup;
|
|
318
315
|
}
|
|
319
316
|
static finalize(unit) {
|
|
@@ -530,7 +527,10 @@
|
|
|
530
527
|
// unit promise
|
|
531
528
|
//----------------------------------------------------------------------------------------------------
|
|
532
529
|
class UnitPromise {
|
|
533
|
-
constructor(promise) {
|
|
530
|
+
constructor(promise, useResult) {
|
|
531
|
+
this.promise = promise;
|
|
532
|
+
this.useResult = useResult;
|
|
533
|
+
}
|
|
534
534
|
then(callback) {
|
|
535
535
|
this.promise = this.promise.then(Unit.wrap(Unit.current, callback));
|
|
536
536
|
return this;
|
|
@@ -678,10 +678,10 @@
|
|
|
678
678
|
* @example
|
|
679
679
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
680
680
|
*/
|
|
681
|
-
promise(promise) {
|
|
681
|
+
promise(promise, useResult = true) {
|
|
682
682
|
try {
|
|
683
|
-
Unit.current._.promises.push(promise);
|
|
684
|
-
return
|
|
683
|
+
Unit.current._.promises.push(new UnitPromise(promise, useResult));
|
|
684
|
+
return Unit.current._.promises[Unit.current._.promises.length - 1];
|
|
685
685
|
}
|
|
686
686
|
catch (error) {
|
|
687
687
|
console.error('xnew.promise(promise: Promise<any>): ', error);
|
|
@@ -697,7 +697,11 @@
|
|
|
697
697
|
*/
|
|
698
698
|
then(callback) {
|
|
699
699
|
try {
|
|
700
|
-
|
|
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
|
+
});
|
|
701
705
|
}
|
|
702
706
|
catch (error) {
|
|
703
707
|
console.error('xnew.then(callback: Function): ', error);
|
|
@@ -713,7 +717,9 @@
|
|
|
713
717
|
*/
|
|
714
718
|
catch(callback) {
|
|
715
719
|
try {
|
|
716
|
-
|
|
720
|
+
const promises = Unit.current._.promises;
|
|
721
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
722
|
+
.catch(callback);
|
|
717
723
|
}
|
|
718
724
|
catch (error) {
|
|
719
725
|
console.error('xnew.catch(callback: Function): ', error);
|
|
@@ -729,7 +735,9 @@
|
|
|
729
735
|
*/
|
|
730
736
|
finally(callback) {
|
|
731
737
|
try {
|
|
732
|
-
|
|
738
|
+
const promises = Unit.current._.promises;
|
|
739
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
740
|
+
.finally(callback);
|
|
733
741
|
}
|
|
734
742
|
catch (error) {
|
|
735
743
|
console.error('xnew.finally(callback: Function): ', error);
|
package/dist/xnew.mjs
CHANGED
|
@@ -256,9 +256,6 @@ class Unit {
|
|
|
256
256
|
get element() {
|
|
257
257
|
return this._.currentElement;
|
|
258
258
|
}
|
|
259
|
-
get components() {
|
|
260
|
-
return this._.components;
|
|
261
|
-
}
|
|
262
259
|
start() {
|
|
263
260
|
this._.tostart = true;
|
|
264
261
|
}
|
|
@@ -307,7 +304,7 @@ class Unit {
|
|
|
307
304
|
// setup component
|
|
308
305
|
Unit.extend(unit, unit._.baseComponent, unit._.props);
|
|
309
306
|
// whether the unit promise was resolved
|
|
310
|
-
Promise.all(unit._.promises).then(() => unit._.state = 'initialized');
|
|
307
|
+
Promise.all(unit._.promises.map(p => p.promise)).then(() => unit._.state = 'initialized');
|
|
311
308
|
Unit.current = backup;
|
|
312
309
|
}
|
|
313
310
|
static finalize(unit) {
|
|
@@ -524,7 +521,10 @@ Unit.type2units = new MapSet();
|
|
|
524
521
|
// unit promise
|
|
525
522
|
//----------------------------------------------------------------------------------------------------
|
|
526
523
|
class UnitPromise {
|
|
527
|
-
constructor(promise) {
|
|
524
|
+
constructor(promise, useResult) {
|
|
525
|
+
this.promise = promise;
|
|
526
|
+
this.useResult = useResult;
|
|
527
|
+
}
|
|
528
528
|
then(callback) {
|
|
529
529
|
this.promise = this.promise.then(Unit.wrap(Unit.current, callback));
|
|
530
530
|
return this;
|
|
@@ -672,10 +672,10 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
672
672
|
* @example
|
|
673
673
|
* xnew.promise(fetchData()).then(data => console.log(data))
|
|
674
674
|
*/
|
|
675
|
-
promise(promise) {
|
|
675
|
+
promise(promise, useResult = true) {
|
|
676
676
|
try {
|
|
677
|
-
Unit.current._.promises.push(promise);
|
|
678
|
-
return
|
|
677
|
+
Unit.current._.promises.push(new UnitPromise(promise, useResult));
|
|
678
|
+
return Unit.current._.promises[Unit.current._.promises.length - 1];
|
|
679
679
|
}
|
|
680
680
|
catch (error) {
|
|
681
681
|
console.error('xnew.promise(promise: Promise<any>): ', error);
|
|
@@ -691,7 +691,11 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
691
691
|
*/
|
|
692
692
|
then(callback) {
|
|
693
693
|
try {
|
|
694
|
-
|
|
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
|
+
});
|
|
695
699
|
}
|
|
696
700
|
catch (error) {
|
|
697
701
|
console.error('xnew.then(callback: Function): ', error);
|
|
@@ -707,7 +711,9 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
707
711
|
*/
|
|
708
712
|
catch(callback) {
|
|
709
713
|
try {
|
|
710
|
-
|
|
714
|
+
const promises = Unit.current._.promises;
|
|
715
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
716
|
+
.catch(callback);
|
|
711
717
|
}
|
|
712
718
|
catch (error) {
|
|
713
719
|
console.error('xnew.catch(callback: Function): ', error);
|
|
@@ -723,7 +729,9 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
723
729
|
*/
|
|
724
730
|
finally(callback) {
|
|
725
731
|
try {
|
|
726
|
-
|
|
732
|
+
const promises = Unit.current._.promises;
|
|
733
|
+
return new UnitPromise(Promise.all(promises.map(p => p.promise)), true)
|
|
734
|
+
.finally(callback);
|
|
727
735
|
}
|
|
728
736
|
catch (error) {
|
|
729
737
|
console.error('xnew.finally(callback: Function): ', error);
|