@mulsense/xnew 0.4.6 → 0.4.8
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 +3 -0
- package/dist/addons/xpixi.mjs +3 -0
- package/dist/addons/xthree.js +3 -0
- package/dist/addons/xthree.mjs +3 -0
- package/dist/xnew.d.ts +5 -2
- package/dist/xnew.js +43 -25
- package/dist/xnew.mjs +43 -25
- package/package.json +1 -6
package/dist/addons/xpixi.js
CHANGED
package/dist/addons/xpixi.mjs
CHANGED
package/dist/addons/xthree.js
CHANGED
package/dist/addons/xthree.mjs
CHANGED
package/dist/xnew.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ interface Internal {
|
|
|
88
88
|
declare class Unit {
|
|
89
89
|
[key: string]: any;
|
|
90
90
|
_: Internal;
|
|
91
|
-
constructor(parent: Unit | null,
|
|
91
|
+
constructor(parent: Unit | null, target: UnitElement | string | null, component?: Function | string, props?: Object, config?: any);
|
|
92
92
|
get element(): UnitElement;
|
|
93
93
|
start(): void;
|
|
94
94
|
stop(): void;
|
|
@@ -151,7 +151,7 @@ interface CreateUnit {
|
|
|
151
151
|
* const unit = xnew('#selector', MyComponent, { data: 0 })
|
|
152
152
|
* const unit = xnew('<div>', MyComponent, { data: 0 })
|
|
153
153
|
*/
|
|
154
|
-
(target: HTMLElement | SVGElement, Component?: Function | string, props?: Object): Unit;
|
|
154
|
+
(target: HTMLElement | SVGElement | string, Component?: Function | string, props?: Object): Unit;
|
|
155
155
|
}
|
|
156
156
|
declare const xnew$1: CreateUnit & {
|
|
157
157
|
/**
|
|
@@ -276,6 +276,7 @@ declare const xnew$1: CreateUnit & {
|
|
|
276
276
|
* }, 300)
|
|
277
277
|
*/
|
|
278
278
|
transition(transition: Function, duration?: number, easing?: string): any;
|
|
279
|
+
protect(...args: any[]): Unit;
|
|
279
280
|
};
|
|
280
281
|
|
|
281
282
|
declare function Accordion(unit: Unit, { open, duration, easing }?: {
|
|
@@ -391,6 +392,8 @@ declare namespace xnew {
|
|
|
391
392
|
declare const xnew: (typeof xnew$1) & {
|
|
392
393
|
basics: typeof basics;
|
|
393
394
|
audio: typeof audio;
|
|
395
|
+
} & {
|
|
396
|
+
global: any;
|
|
394
397
|
};
|
|
395
398
|
|
|
396
399
|
export { xnew as default };
|
package/dist/xnew.js
CHANGED
|
@@ -528,27 +528,8 @@
|
|
|
528
528
|
// unit
|
|
529
529
|
//----------------------------------------------------------------------------------------------------
|
|
530
530
|
class Unit {
|
|
531
|
-
constructor(parent,
|
|
531
|
+
constructor(parent, target, component, props, config) {
|
|
532
532
|
var _a, _b;
|
|
533
|
-
let target;
|
|
534
|
-
if (args[0] instanceof HTMLElement || args[0] instanceof SVGElement) {
|
|
535
|
-
target = args.shift(); // an existing html element
|
|
536
|
-
}
|
|
537
|
-
else if (typeof args[0] === 'string' && args[0].match(/<((\w+)[^>]*?)\/?>/)) {
|
|
538
|
-
target = args.shift();
|
|
539
|
-
}
|
|
540
|
-
else if (typeof args[0] === 'string') {
|
|
541
|
-
const query = args.shift();
|
|
542
|
-
target = document.querySelector(query);
|
|
543
|
-
if (target === null)
|
|
544
|
-
throw new Error(`'${query}' can not be found.`);
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
target = null;
|
|
548
|
-
}
|
|
549
|
-
const component = args.shift();
|
|
550
|
-
const props = args.shift();
|
|
551
|
-
const config = args.shift();
|
|
552
533
|
let baseElement;
|
|
553
534
|
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
554
535
|
baseElement = target;
|
|
@@ -883,7 +864,7 @@
|
|
|
883
864
|
class UnitTimer {
|
|
884
865
|
constructor(options) {
|
|
885
866
|
this.stack = [];
|
|
886
|
-
this.unit = new Unit(Unit.currentUnit, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
867
|
+
this.unit = new Unit(Unit.currentUnit, null, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
887
868
|
}
|
|
888
869
|
clear() {
|
|
889
870
|
this.stack = [];
|
|
@@ -903,7 +884,7 @@
|
|
|
903
884
|
}
|
|
904
885
|
static execute(timer, options) {
|
|
905
886
|
if (timer.unit._.state === 'finalized') {
|
|
906
|
-
timer.unit = new Unit(Unit.currentUnit, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
887
|
+
timer.unit = new Unit(Unit.currentUnit, null, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
907
888
|
}
|
|
908
889
|
else if (timer.stack.length === 0) {
|
|
909
890
|
timer.stack.push(Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
@@ -915,7 +896,7 @@
|
|
|
915
896
|
}
|
|
916
897
|
static next(timer) {
|
|
917
898
|
if (timer.stack.length > 0) {
|
|
918
|
-
timer.unit = new Unit(Unit.currentUnit, UnitTimer.Component, timer.stack.shift());
|
|
899
|
+
timer.unit = new Unit(Unit.currentUnit, null, UnitTimer.Component, timer.stack.shift());
|
|
919
900
|
timer.unit.on('finalize', () => { UnitTimer.next(timer); });
|
|
920
901
|
}
|
|
921
902
|
}
|
|
@@ -941,10 +922,32 @@
|
|
|
941
922
|
}
|
|
942
923
|
}
|
|
943
924
|
|
|
925
|
+
function parseArguments(...args) {
|
|
926
|
+
let target;
|
|
927
|
+
if (args[0] instanceof HTMLElement || args[0] instanceof SVGElement) {
|
|
928
|
+
target = args.shift(); // an existing html element
|
|
929
|
+
}
|
|
930
|
+
else if (typeof args[0] === 'string' && args[0].match(/<((\w+)[^>]*?)\/?>/)) {
|
|
931
|
+
target = args.shift();
|
|
932
|
+
}
|
|
933
|
+
else if (typeof args[0] === 'string') {
|
|
934
|
+
const query = args.shift();
|
|
935
|
+
target = document.querySelector(query);
|
|
936
|
+
if (target === null)
|
|
937
|
+
throw new Error(`'${query}' can not be found.`);
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
target = null;
|
|
941
|
+
}
|
|
942
|
+
const component = args.shift();
|
|
943
|
+
const props = args.shift();
|
|
944
|
+
return { target, component, props };
|
|
945
|
+
}
|
|
944
946
|
const xnew$1 = Object.assign(function (...args) {
|
|
945
947
|
if (Unit.rootUnit === undefined)
|
|
946
948
|
Unit.reset();
|
|
947
|
-
|
|
949
|
+
const { target, component, props } = parseArguments(...args);
|
|
950
|
+
return new Unit(Unit.currentUnit, target, component, props, { protect: false });
|
|
948
951
|
}, {
|
|
949
952
|
/**
|
|
950
953
|
* Creates a nested HTML/SVG element within the current component
|
|
@@ -1158,6 +1161,12 @@
|
|
|
1158
1161
|
transition(transition, duration = 0, easing = 'linear') {
|
|
1159
1162
|
return new UnitTimer({ transition, duration, easing, iterations: 1 });
|
|
1160
1163
|
},
|
|
1164
|
+
protect(...args) {
|
|
1165
|
+
if (Unit.rootUnit === undefined)
|
|
1166
|
+
Unit.reset();
|
|
1167
|
+
const { target, component, props } = parseArguments(...args);
|
|
1168
|
+
return new Unit(Unit.currentUnit, target, component, props, { protect: true });
|
|
1169
|
+
},
|
|
1161
1170
|
});
|
|
1162
1171
|
|
|
1163
1172
|
function Accordion(unit, { open = false, duration = 200, easing = 'ease' } = {}) {
|
|
@@ -1671,7 +1680,16 @@
|
|
|
1671
1680
|
master.gain.value = value;
|
|
1672
1681
|
}
|
|
1673
1682
|
};
|
|
1674
|
-
const
|
|
1683
|
+
const temp = Object.assign(xnew$1, { basics, audio });
|
|
1684
|
+
Object.defineProperty(temp, 'global', {
|
|
1685
|
+
get: function () {
|
|
1686
|
+
return temp.context('xnew.global');
|
|
1687
|
+
},
|
|
1688
|
+
set: function (value) {
|
|
1689
|
+
temp.context('xnew.global', value);
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
const xnew = temp;
|
|
1675
1693
|
|
|
1676
1694
|
return xnew;
|
|
1677
1695
|
|
package/dist/xnew.mjs
CHANGED
|
@@ -522,27 +522,8 @@ function pointer(element, event) {
|
|
|
522
522
|
// unit
|
|
523
523
|
//----------------------------------------------------------------------------------------------------
|
|
524
524
|
class Unit {
|
|
525
|
-
constructor(parent,
|
|
525
|
+
constructor(parent, target, component, props, config) {
|
|
526
526
|
var _a, _b;
|
|
527
|
-
let target;
|
|
528
|
-
if (args[0] instanceof HTMLElement || args[0] instanceof SVGElement) {
|
|
529
|
-
target = args.shift(); // an existing html element
|
|
530
|
-
}
|
|
531
|
-
else if (typeof args[0] === 'string' && args[0].match(/<((\w+)[^>]*?)\/?>/)) {
|
|
532
|
-
target = args.shift();
|
|
533
|
-
}
|
|
534
|
-
else if (typeof args[0] === 'string') {
|
|
535
|
-
const query = args.shift();
|
|
536
|
-
target = document.querySelector(query);
|
|
537
|
-
if (target === null)
|
|
538
|
-
throw new Error(`'${query}' can not be found.`);
|
|
539
|
-
}
|
|
540
|
-
else {
|
|
541
|
-
target = null;
|
|
542
|
-
}
|
|
543
|
-
const component = args.shift();
|
|
544
|
-
const props = args.shift();
|
|
545
|
-
const config = args.shift();
|
|
546
527
|
let baseElement;
|
|
547
528
|
if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
548
529
|
baseElement = target;
|
|
@@ -877,7 +858,7 @@ class UnitPromise {
|
|
|
877
858
|
class UnitTimer {
|
|
878
859
|
constructor(options) {
|
|
879
860
|
this.stack = [];
|
|
880
|
-
this.unit = new Unit(Unit.currentUnit, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
861
|
+
this.unit = new Unit(Unit.currentUnit, null, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
881
862
|
}
|
|
882
863
|
clear() {
|
|
883
864
|
this.stack = [];
|
|
@@ -897,7 +878,7 @@ class UnitTimer {
|
|
|
897
878
|
}
|
|
898
879
|
static execute(timer, options) {
|
|
899
880
|
if (timer.unit._.state === 'finalized') {
|
|
900
|
-
timer.unit = new Unit(Unit.currentUnit, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
881
|
+
timer.unit = new Unit(Unit.currentUnit, null, UnitTimer.Component, Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
901
882
|
}
|
|
902
883
|
else if (timer.stack.length === 0) {
|
|
903
884
|
timer.stack.push(Object.assign({ snapshot: Unit.snapshot(Unit.currentUnit) }, options));
|
|
@@ -909,7 +890,7 @@ class UnitTimer {
|
|
|
909
890
|
}
|
|
910
891
|
static next(timer) {
|
|
911
892
|
if (timer.stack.length > 0) {
|
|
912
|
-
timer.unit = new Unit(Unit.currentUnit, UnitTimer.Component, timer.stack.shift());
|
|
893
|
+
timer.unit = new Unit(Unit.currentUnit, null, UnitTimer.Component, timer.stack.shift());
|
|
913
894
|
timer.unit.on('finalize', () => { UnitTimer.next(timer); });
|
|
914
895
|
}
|
|
915
896
|
}
|
|
@@ -935,10 +916,32 @@ class UnitTimer {
|
|
|
935
916
|
}
|
|
936
917
|
}
|
|
937
918
|
|
|
919
|
+
function parseArguments(...args) {
|
|
920
|
+
let target;
|
|
921
|
+
if (args[0] instanceof HTMLElement || args[0] instanceof SVGElement) {
|
|
922
|
+
target = args.shift(); // an existing html element
|
|
923
|
+
}
|
|
924
|
+
else if (typeof args[0] === 'string' && args[0].match(/<((\w+)[^>]*?)\/?>/)) {
|
|
925
|
+
target = args.shift();
|
|
926
|
+
}
|
|
927
|
+
else if (typeof args[0] === 'string') {
|
|
928
|
+
const query = args.shift();
|
|
929
|
+
target = document.querySelector(query);
|
|
930
|
+
if (target === null)
|
|
931
|
+
throw new Error(`'${query}' can not be found.`);
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
target = null;
|
|
935
|
+
}
|
|
936
|
+
const component = args.shift();
|
|
937
|
+
const props = args.shift();
|
|
938
|
+
return { target, component, props };
|
|
939
|
+
}
|
|
938
940
|
const xnew$1 = Object.assign(function (...args) {
|
|
939
941
|
if (Unit.rootUnit === undefined)
|
|
940
942
|
Unit.reset();
|
|
941
|
-
|
|
943
|
+
const { target, component, props } = parseArguments(...args);
|
|
944
|
+
return new Unit(Unit.currentUnit, target, component, props, { protect: false });
|
|
942
945
|
}, {
|
|
943
946
|
/**
|
|
944
947
|
* Creates a nested HTML/SVG element within the current component
|
|
@@ -1152,6 +1155,12 @@ const xnew$1 = Object.assign(function (...args) {
|
|
|
1152
1155
|
transition(transition, duration = 0, easing = 'linear') {
|
|
1153
1156
|
return new UnitTimer({ transition, duration, easing, iterations: 1 });
|
|
1154
1157
|
},
|
|
1158
|
+
protect(...args) {
|
|
1159
|
+
if (Unit.rootUnit === undefined)
|
|
1160
|
+
Unit.reset();
|
|
1161
|
+
const { target, component, props } = parseArguments(...args);
|
|
1162
|
+
return new Unit(Unit.currentUnit, target, component, props, { protect: true });
|
|
1163
|
+
},
|
|
1155
1164
|
});
|
|
1156
1165
|
|
|
1157
1166
|
function Accordion(unit, { open = false, duration = 200, easing = 'ease' } = {}) {
|
|
@@ -1665,6 +1674,15 @@ const audio = {
|
|
|
1665
1674
|
master.gain.value = value;
|
|
1666
1675
|
}
|
|
1667
1676
|
};
|
|
1668
|
-
const
|
|
1677
|
+
const temp = Object.assign(xnew$1, { basics, audio });
|
|
1678
|
+
Object.defineProperty(temp, 'global', {
|
|
1679
|
+
get: function () {
|
|
1680
|
+
return temp.context('xnew.global');
|
|
1681
|
+
},
|
|
1682
|
+
set: function (value) {
|
|
1683
|
+
temp.context('xnew.global', value);
|
|
1684
|
+
}
|
|
1685
|
+
});
|
|
1686
|
+
const xnew = temp;
|
|
1669
1687
|
|
|
1670
1688
|
export { xnew as default };
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"keywords": [
|
|
5
5
|
"Component-Oriented Programming"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.4.
|
|
7
|
+
"version": "0.4.8",
|
|
8
8
|
"main": "dist/xnew.js",
|
|
9
9
|
"module": "dist/xnew.mjs",
|
|
10
10
|
"types": "dist/xnew.d.ts",
|
|
@@ -14,11 +14,6 @@
|
|
|
14
14
|
"import": "./dist/xnew.mjs",
|
|
15
15
|
"require": "./dist/xnew.js"
|
|
16
16
|
},
|
|
17
|
-
"./addons/xaudio": {
|
|
18
|
-
"types": "./dist/addons/xaudio.d.ts",
|
|
19
|
-
"import": "./dist/addons/xaudio.mjs",
|
|
20
|
-
"require": "./dist/addons/xaudio.js"
|
|
21
|
-
},
|
|
22
17
|
"./addons/xmatter": {
|
|
23
18
|
"types": "./dist/addons/xmatter.d.ts",
|
|
24
19
|
"import": "./dist/addons/xmatter.mjs",
|