@mulsense/xnew 0.7.0 → 0.7.1
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/xnew.d.ts +5 -7
- package/dist/xnew.js +28 -26
- package/dist/xnew.mjs +28 -26
- package/package.json +1 -1
package/dist/xnew.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ declare class Unit {
|
|
|
75
75
|
currentElement: UnitElement;
|
|
76
76
|
currentContext: Context;
|
|
77
77
|
currentComponent: Function | null;
|
|
78
|
+
afterSnapshot: Snapshot | null;
|
|
78
79
|
nestElements: {
|
|
79
80
|
element: UnitElement;
|
|
80
81
|
owned: boolean;
|
|
@@ -207,18 +208,16 @@ declare function Panel(unit: Unit, { params }: PanelOptions): {
|
|
|
207
208
|
separator(): void;
|
|
208
209
|
};
|
|
209
210
|
|
|
210
|
-
declare function Scene(unit: Unit):
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
set scene(value: Unit);
|
|
214
|
-
next(Component: Function, props?: any, callback?: Function): void;
|
|
211
|
+
declare function Scene(unit: Unit): {
|
|
212
|
+
moveTo(Component: Function, props?: any): void;
|
|
213
|
+
append(Component: Function, props?: any): void;
|
|
215
214
|
};
|
|
216
215
|
|
|
217
216
|
declare class XImage {
|
|
218
217
|
canvas: HTMLCanvasElement;
|
|
219
218
|
constructor(canvas: HTMLCanvasElement);
|
|
220
219
|
constructor(width: number, height: number);
|
|
221
|
-
|
|
220
|
+
crop(x: number, y: number, width: number, height: number): XImage;
|
|
222
221
|
download(filename: string): void;
|
|
223
222
|
}
|
|
224
223
|
|
|
@@ -298,7 +297,6 @@ declare const xnew: ((...args: UnitArgs) => Unit) & {
|
|
|
298
297
|
Panel: typeof Panel;
|
|
299
298
|
Accordion: typeof Accordion;
|
|
300
299
|
Popup: typeof Popup;
|
|
301
|
-
Flow: typeof Flow;
|
|
302
300
|
Scene: typeof Scene;
|
|
303
301
|
};
|
|
304
302
|
audio: {
|
package/dist/xnew.js
CHANGED
|
@@ -571,6 +571,7 @@
|
|
|
571
571
|
currentElement: baseElement,
|
|
572
572
|
currentContext: baseContext,
|
|
573
573
|
currentComponent: null,
|
|
574
|
+
afterSnapshot: null,
|
|
574
575
|
ancestors: parent ? [parent, ...parent._.ancestors] : [],
|
|
575
576
|
children: [],
|
|
576
577
|
nestElements: [],
|
|
@@ -591,6 +592,7 @@
|
|
|
591
592
|
if (this._.state === 'invoked') {
|
|
592
593
|
this._.state = 'initialized';
|
|
593
594
|
}
|
|
595
|
+
this._.afterSnapshot = Unit.snapshot(this);
|
|
594
596
|
Unit.currentUnit = backup;
|
|
595
597
|
}
|
|
596
598
|
get element() {
|
|
@@ -997,14 +999,32 @@
|
|
|
997
999
|
}
|
|
998
1000
|
},
|
|
999
1001
|
append(parent, ...args) {
|
|
1002
|
+
var _a;
|
|
1000
1003
|
try {
|
|
1001
|
-
|
|
1004
|
+
const snapshot = (_a = parent._.afterSnapshot) !== null && _a !== void 0 ? _a : Unit.snapshot(parent);
|
|
1005
|
+
Unit.scope(snapshot, () => {
|
|
1006
|
+
new Unit(parent, ...args);
|
|
1007
|
+
});
|
|
1002
1008
|
}
|
|
1003
1009
|
catch (error) {
|
|
1004
1010
|
console.error('xnew.append(parent: Unit, ...args: UnitArgs): ', error);
|
|
1005
1011
|
throw error;
|
|
1006
1012
|
}
|
|
1007
1013
|
},
|
|
1014
|
+
next(unit, ...args) {
|
|
1015
|
+
var _a;
|
|
1016
|
+
try {
|
|
1017
|
+
const parent = unit._.parent;
|
|
1018
|
+
const snapshot = (_a = parent._.afterSnapshot) !== null && _a !== void 0 ? _a : Unit.snapshot(parent);
|
|
1019
|
+
Unit.scope(snapshot, () => {
|
|
1020
|
+
new Unit(parent, ...args);
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
catch (error) {
|
|
1024
|
+
console.error('xnew.next(unit: Unit, ...args: UnitArgs): ', error);
|
|
1025
|
+
throw error;
|
|
1026
|
+
}
|
|
1027
|
+
},
|
|
1008
1028
|
/**
|
|
1009
1029
|
* Gets the Unit instance associated with the given component in the ancestor context chain
|
|
1010
1030
|
* @param key - component function used as context key
|
|
@@ -1611,31 +1631,14 @@
|
|
|
1611
1631
|
}
|
|
1612
1632
|
|
|
1613
1633
|
function Scene(unit) {
|
|
1614
|
-
}
|
|
1615
|
-
function Flow(unit) {
|
|
1616
|
-
let scene = null;
|
|
1617
1634
|
return {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
get scene() {
|
|
1622
|
-
return scene;
|
|
1623
|
-
},
|
|
1624
|
-
next(Component, props, callback) {
|
|
1625
|
-
callback = callback !== null && callback !== void 0 ? callback : defaultCallback;
|
|
1626
|
-
callback(scene, create);
|
|
1627
|
-
function defaultCallback(current, create) {
|
|
1628
|
-
current === null || current === void 0 ? void 0 : current.finalize();
|
|
1629
|
-
create();
|
|
1630
|
-
}
|
|
1631
|
-
function create() {
|
|
1632
|
-
scene = xnew$1((unit) => {
|
|
1633
|
-
xnew$1.extend(Scene);
|
|
1634
|
-
xnew$1.extend(Component, props);
|
|
1635
|
-
});
|
|
1636
|
-
return scene;
|
|
1637
|
-
}
|
|
1635
|
+
moveTo(Component, props) {
|
|
1636
|
+
xnew$1.next(unit, Component, props);
|
|
1637
|
+
unit.finalize();
|
|
1638
1638
|
},
|
|
1639
|
+
append(Component, props) {
|
|
1640
|
+
xnew$1.append(unit, Component, props);
|
|
1641
|
+
}
|
|
1639
1642
|
};
|
|
1640
1643
|
}
|
|
1641
1644
|
|
|
@@ -1651,7 +1654,7 @@
|
|
|
1651
1654
|
this.canvas = canvas;
|
|
1652
1655
|
}
|
|
1653
1656
|
}
|
|
1654
|
-
|
|
1657
|
+
crop(x, y, width, height) {
|
|
1655
1658
|
var _a;
|
|
1656
1659
|
const canvas = document.createElement('canvas');
|
|
1657
1660
|
canvas.width = width;
|
|
@@ -1899,7 +1902,6 @@
|
|
|
1899
1902
|
Panel,
|
|
1900
1903
|
Accordion,
|
|
1901
1904
|
Popup,
|
|
1902
|
-
Flow,
|
|
1903
1905
|
Scene,
|
|
1904
1906
|
};
|
|
1905
1907
|
const audio = {
|
package/dist/xnew.mjs
CHANGED
|
@@ -565,6 +565,7 @@ class Unit {
|
|
|
565
565
|
currentElement: baseElement,
|
|
566
566
|
currentContext: baseContext,
|
|
567
567
|
currentComponent: null,
|
|
568
|
+
afterSnapshot: null,
|
|
568
569
|
ancestors: parent ? [parent, ...parent._.ancestors] : [],
|
|
569
570
|
children: [],
|
|
570
571
|
nestElements: [],
|
|
@@ -585,6 +586,7 @@ class Unit {
|
|
|
585
586
|
if (this._.state === 'invoked') {
|
|
586
587
|
this._.state = 'initialized';
|
|
587
588
|
}
|
|
589
|
+
this._.afterSnapshot = Unit.snapshot(this);
|
|
588
590
|
Unit.currentUnit = backup;
|
|
589
591
|
}
|
|
590
592
|
get element() {
|
|
@@ -991,14 +993,32 @@ function (...args) {
|
|
|
991
993
|
}
|
|
992
994
|
},
|
|
993
995
|
append(parent, ...args) {
|
|
996
|
+
var _a;
|
|
994
997
|
try {
|
|
995
|
-
|
|
998
|
+
const snapshot = (_a = parent._.afterSnapshot) !== null && _a !== void 0 ? _a : Unit.snapshot(parent);
|
|
999
|
+
Unit.scope(snapshot, () => {
|
|
1000
|
+
new Unit(parent, ...args);
|
|
1001
|
+
});
|
|
996
1002
|
}
|
|
997
1003
|
catch (error) {
|
|
998
1004
|
console.error('xnew.append(parent: Unit, ...args: UnitArgs): ', error);
|
|
999
1005
|
throw error;
|
|
1000
1006
|
}
|
|
1001
1007
|
},
|
|
1008
|
+
next(unit, ...args) {
|
|
1009
|
+
var _a;
|
|
1010
|
+
try {
|
|
1011
|
+
const parent = unit._.parent;
|
|
1012
|
+
const snapshot = (_a = parent._.afterSnapshot) !== null && _a !== void 0 ? _a : Unit.snapshot(parent);
|
|
1013
|
+
Unit.scope(snapshot, () => {
|
|
1014
|
+
new Unit(parent, ...args);
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
catch (error) {
|
|
1018
|
+
console.error('xnew.next(unit: Unit, ...args: UnitArgs): ', error);
|
|
1019
|
+
throw error;
|
|
1020
|
+
}
|
|
1021
|
+
},
|
|
1002
1022
|
/**
|
|
1003
1023
|
* Gets the Unit instance associated with the given component in the ancestor context chain
|
|
1004
1024
|
* @param key - component function used as context key
|
|
@@ -1605,31 +1625,14 @@ function Select(_, { key = '', value, items = [] } = {}) {
|
|
|
1605
1625
|
}
|
|
1606
1626
|
|
|
1607
1627
|
function Scene(unit) {
|
|
1608
|
-
}
|
|
1609
|
-
function Flow(unit) {
|
|
1610
|
-
let scene = null;
|
|
1611
1628
|
return {
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
get scene() {
|
|
1616
|
-
return scene;
|
|
1617
|
-
},
|
|
1618
|
-
next(Component, props, callback) {
|
|
1619
|
-
callback = callback !== null && callback !== void 0 ? callback : defaultCallback;
|
|
1620
|
-
callback(scene, create);
|
|
1621
|
-
function defaultCallback(current, create) {
|
|
1622
|
-
current === null || current === void 0 ? void 0 : current.finalize();
|
|
1623
|
-
create();
|
|
1624
|
-
}
|
|
1625
|
-
function create() {
|
|
1626
|
-
scene = xnew$1((unit) => {
|
|
1627
|
-
xnew$1.extend(Scene);
|
|
1628
|
-
xnew$1.extend(Component, props);
|
|
1629
|
-
});
|
|
1630
|
-
return scene;
|
|
1631
|
-
}
|
|
1629
|
+
moveTo(Component, props) {
|
|
1630
|
+
xnew$1.next(unit, Component, props);
|
|
1631
|
+
unit.finalize();
|
|
1632
1632
|
},
|
|
1633
|
+
append(Component, props) {
|
|
1634
|
+
xnew$1.append(unit, Component, props);
|
|
1635
|
+
}
|
|
1633
1636
|
};
|
|
1634
1637
|
}
|
|
1635
1638
|
|
|
@@ -1645,7 +1648,7 @@ class XImage {
|
|
|
1645
1648
|
this.canvas = canvas;
|
|
1646
1649
|
}
|
|
1647
1650
|
}
|
|
1648
|
-
|
|
1651
|
+
crop(x, y, width, height) {
|
|
1649
1652
|
var _a;
|
|
1650
1653
|
const canvas = document.createElement('canvas');
|
|
1651
1654
|
canvas.width = width;
|
|
@@ -1893,7 +1896,6 @@ const basics = {
|
|
|
1893
1896
|
Panel,
|
|
1894
1897
|
Accordion,
|
|
1895
1898
|
Popup,
|
|
1896
|
-
Flow,
|
|
1897
1899
|
Scene,
|
|
1898
1900
|
};
|
|
1899
1901
|
const audio = {
|