@mulsense/xnew 0.2.2 → 0.3.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/README.md +3 -3
- package/dist/addons/xmatter.d.ts +1 -1
- package/dist/addons/xmatter.js +7 -19
- package/dist/addons/xmatter.mjs +7 -19
- package/dist/addons/xpixi.d.ts +0 -3
- package/dist/addons/xpixi.js +3 -8
- package/dist/addons/xpixi.mjs +3 -8
- package/dist/addons/xrapier2d.js +2 -2
- package/dist/addons/xrapier2d.mjs +2 -2
- package/dist/addons/xthree.js +4 -4
- package/dist/addons/xthree.mjs +4 -4
- package/dist/types/basics/Controller.d.ts +6 -17
- package/dist/types/basics/Text.d.ts +6 -0
- package/dist/types/core/unit.d.ts +5 -4
- package/dist/types/core/xnew.d.ts +2 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/xnew.d.ts +20 -21
- package/dist/xnew.js +1867 -845
- package/dist/xnew.mjs +1867 -845
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ providing a flexible architecture well-suited for applications with dynamic scen
|
|
|
13
13
|
### Via CDN
|
|
14
14
|
Include the following script in your HTML file:
|
|
15
15
|
```html
|
|
16
|
-
<script src="https://unpkg.com/@mulsense/xnew@0.
|
|
16
|
+
<script src="https://unpkg.com/@mulsense/xnew@0.3.x/dist/xnew.js"></script>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
### Via CDN (ESM)
|
|
@@ -22,7 +22,7 @@ Use the ES module version with an import map:
|
|
|
22
22
|
<script type="importmap">
|
|
23
23
|
{
|
|
24
24
|
"imports": {
|
|
25
|
-
"@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.
|
|
25
|
+
"@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.3.x/dist/xnew.mjs"
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
</script>
|
|
@@ -37,7 +37,7 @@ import xnew from '@mulsense/xnew';
|
|
|
37
37
|
### Via npm
|
|
38
38
|
Install `xnew` using npm:
|
|
39
39
|
```bash
|
|
40
|
-
npm install @mulsense/xnew@0.
|
|
40
|
+
npm install @mulsense/xnew@0.3.x
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
Then import it in your JavaScript file:
|
package/dist/addons/xmatter.d.ts
CHANGED
package/dist/addons/xmatter.js
CHANGED
|
@@ -8,33 +8,21 @@
|
|
|
8
8
|
initialize({ engine = null } = {}) {
|
|
9
9
|
xnew.extend(Root, { engine });
|
|
10
10
|
},
|
|
11
|
-
nest(object) {
|
|
12
|
-
xnew.extend(Nest, { object });
|
|
13
|
-
return object;
|
|
14
|
-
},
|
|
15
11
|
get engine() {
|
|
16
12
|
var _a;
|
|
17
13
|
return (_a = xnew.context('xmatter.root')) === null || _a === void 0 ? void 0 : _a.engine;
|
|
18
14
|
},
|
|
15
|
+
get world() {
|
|
16
|
+
var _a;
|
|
17
|
+
return (_a = xnew.context('xmatter.root')) === null || _a === void 0 ? void 0 : _a.engine.world;
|
|
18
|
+
},
|
|
19
19
|
};
|
|
20
|
-
function Root(
|
|
20
|
+
function Root(unit, { engine }) {
|
|
21
21
|
const root = {};
|
|
22
22
|
xnew.context('xmatter.root', root);
|
|
23
|
-
root.isActive = true;
|
|
24
23
|
root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (root.isActive) {
|
|
28
|
-
Matter.Engine.update(root.engine);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function Nest(self, { object }) {
|
|
33
|
-
const parent = xnew.context('xmatter.object');
|
|
34
|
-
xnew.context('xmatter.object', object);
|
|
35
|
-
Matter.Composite.add(parent, object);
|
|
36
|
-
self.on('-finalize', () => {
|
|
37
|
-
Matter.Composite.remove(parent, object);
|
|
24
|
+
unit.on('update', () => {
|
|
25
|
+
Matter.Engine.update(root.engine);
|
|
38
26
|
});
|
|
39
27
|
}
|
|
40
28
|
|
package/dist/addons/xmatter.mjs
CHANGED
|
@@ -5,33 +5,21 @@ var xmatter = {
|
|
|
5
5
|
initialize({ engine = null } = {}) {
|
|
6
6
|
xnew.extend(Root, { engine });
|
|
7
7
|
},
|
|
8
|
-
nest(object) {
|
|
9
|
-
xnew.extend(Nest, { object });
|
|
10
|
-
return object;
|
|
11
|
-
},
|
|
12
8
|
get engine() {
|
|
13
9
|
var _a;
|
|
14
10
|
return (_a = xnew.context('xmatter.root')) === null || _a === void 0 ? void 0 : _a.engine;
|
|
15
11
|
},
|
|
12
|
+
get world() {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = xnew.context('xmatter.root')) === null || _a === void 0 ? void 0 : _a.engine.world;
|
|
15
|
+
},
|
|
16
16
|
};
|
|
17
|
-
function Root(
|
|
17
|
+
function Root(unit, { engine }) {
|
|
18
18
|
const root = {};
|
|
19
19
|
xnew.context('xmatter.root', root);
|
|
20
|
-
root.isActive = true;
|
|
21
20
|
root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (root.isActive) {
|
|
25
|
-
Matter.Engine.update(root.engine);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function Nest(self, { object }) {
|
|
30
|
-
const parent = xnew.context('xmatter.object');
|
|
31
|
-
xnew.context('xmatter.object', object);
|
|
32
|
-
Matter.Composite.add(parent, object);
|
|
33
|
-
self.on('-finalize', () => {
|
|
34
|
-
Matter.Composite.remove(parent, object);
|
|
21
|
+
unit.on('update', () => {
|
|
22
|
+
Matter.Engine.update(root.engine);
|
|
35
23
|
});
|
|
36
24
|
}
|
|
37
25
|
|
package/dist/addons/xpixi.d.ts
CHANGED
package/dist/addons/xpixi.js
CHANGED
|
@@ -50,11 +50,6 @@
|
|
|
50
50
|
var _a;
|
|
51
51
|
return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
52
52
|
},
|
|
53
|
-
capture({ rect } = {}) {
|
|
54
|
-
const root = xnew.context('xpixi.root');
|
|
55
|
-
const frame = rect ? new PIXI__namespace.Rectangle(rect[0], rect[1], rect[2], rect[3]) : new PIXI__namespace.Rectangle(0, 0, root.canvas.width, root.canvas.height);
|
|
56
|
-
return root.renderer.extract.base64({ target: root.scene, frame });
|
|
57
|
-
}
|
|
58
53
|
};
|
|
59
54
|
function Root(self, { canvas }) {
|
|
60
55
|
const root = {};
|
|
@@ -74,7 +69,7 @@
|
|
|
74
69
|
root.updates = [];
|
|
75
70
|
root.scene = new PIXI__namespace.Container();
|
|
76
71
|
xnew.context('xpixi.object', root.scene);
|
|
77
|
-
self.on('
|
|
72
|
+
self.on('update', () => {
|
|
78
73
|
root.updates.forEach((update) => {
|
|
79
74
|
update();
|
|
80
75
|
});
|
|
@@ -87,14 +82,14 @@
|
|
|
87
82
|
const parent = xnew.context('xpixi.object');
|
|
88
83
|
xnew.context('xpixi.object', object);
|
|
89
84
|
parent.addChild(object);
|
|
90
|
-
self.on('
|
|
85
|
+
self.on('finalize', () => {
|
|
91
86
|
parent.removeChild(object);
|
|
92
87
|
});
|
|
93
88
|
}
|
|
94
89
|
function PreUpdate(self, callback) {
|
|
95
90
|
const root = xnew.context('xpixi.root');
|
|
96
91
|
root.updates.push(callback);
|
|
97
|
-
self.on('
|
|
92
|
+
self.on('finalize', () => {
|
|
98
93
|
root.updates = root.updates.filter((update) => update !== callback);
|
|
99
94
|
});
|
|
100
95
|
}
|
package/dist/addons/xpixi.mjs
CHANGED
|
@@ -28,11 +28,6 @@ var xpixi = {
|
|
|
28
28
|
var _a;
|
|
29
29
|
return (_a = xnew.context('xpixi.root')) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
30
30
|
},
|
|
31
|
-
capture({ rect } = {}) {
|
|
32
|
-
const root = xnew.context('xpixi.root');
|
|
33
|
-
const frame = rect ? new PIXI.Rectangle(rect[0], rect[1], rect[2], rect[3]) : new PIXI.Rectangle(0, 0, root.canvas.width, root.canvas.height);
|
|
34
|
-
return root.renderer.extract.base64({ target: root.scene, frame });
|
|
35
|
-
}
|
|
36
31
|
};
|
|
37
32
|
function Root(self, { canvas }) {
|
|
38
33
|
const root = {};
|
|
@@ -52,7 +47,7 @@ function Root(self, { canvas }) {
|
|
|
52
47
|
root.updates = [];
|
|
53
48
|
root.scene = new PIXI.Container();
|
|
54
49
|
xnew.context('xpixi.object', root.scene);
|
|
55
|
-
self.on('
|
|
50
|
+
self.on('update', () => {
|
|
56
51
|
root.updates.forEach((update) => {
|
|
57
52
|
update();
|
|
58
53
|
});
|
|
@@ -65,14 +60,14 @@ function Nest(self, { object }) {
|
|
|
65
60
|
const parent = xnew.context('xpixi.object');
|
|
66
61
|
xnew.context('xpixi.object', object);
|
|
67
62
|
parent.addChild(object);
|
|
68
|
-
self.on('
|
|
63
|
+
self.on('finalize', () => {
|
|
69
64
|
parent.removeChild(object);
|
|
70
65
|
});
|
|
71
66
|
}
|
|
72
67
|
function PreUpdate(self, callback) {
|
|
73
68
|
const root = xnew.context('xpixi.root');
|
|
74
69
|
root.updates.push(callback);
|
|
75
|
-
self.on('
|
|
70
|
+
self.on('finalize', () => {
|
|
76
71
|
root.updates = root.updates.filter((update) => update !== callback);
|
|
77
72
|
});
|
|
78
73
|
}
|
package/dist/addons/xrapier2d.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
// xnew.extend(Nest, root.world);
|
|
29
29
|
});
|
|
30
|
-
self.on('
|
|
30
|
+
self.on('update', () => {
|
|
31
31
|
if (root.world) {
|
|
32
32
|
root.world.step();
|
|
33
33
|
}
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
console.log(temp, type, object);
|
|
41
41
|
// Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
|
|
42
42
|
// when created, so we only need to handle removal on finalize
|
|
43
|
-
self.on('
|
|
43
|
+
self.on('finalize', () => {
|
|
44
44
|
try {
|
|
45
45
|
// Check if object is a RigidBody
|
|
46
46
|
if (type === 'rigidBody') {
|
|
@@ -24,7 +24,7 @@ function Root(self, { gravity, timestep }) {
|
|
|
24
24
|
}
|
|
25
25
|
// xnew.extend(Nest, root.world);
|
|
26
26
|
});
|
|
27
|
-
self.on('
|
|
27
|
+
self.on('update', () => {
|
|
28
28
|
if (root.world) {
|
|
29
29
|
root.world.step();
|
|
30
30
|
}
|
|
@@ -37,7 +37,7 @@ function Connect(self, { type, object }) {
|
|
|
37
37
|
console.log(temp, type, object);
|
|
38
38
|
// Rapier2D objects (RigidBody, Collider, etc.) are already added to the world
|
|
39
39
|
// when created, so we only need to handle removal on finalize
|
|
40
|
-
self.on('
|
|
40
|
+
self.on('finalize', () => {
|
|
41
41
|
try {
|
|
42
42
|
// Check if object is a RigidBody
|
|
43
43
|
if (type === 'rigidBody') {
|
package/dist/addons/xthree.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
function Root(
|
|
51
|
+
function Root(unit, { canvas, camera }) {
|
|
52
52
|
const root = {};
|
|
53
53
|
xnew.context('xthree.root', root);
|
|
54
54
|
root.canvas = canvas;
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
root.camera = camera !== null && camera !== void 0 ? camera : new THREE__namespace.PerspectiveCamera(45, root.renderer.domElement.width / root.renderer.domElement.height);
|
|
58
58
|
root.scene = new THREE__namespace.Scene();
|
|
59
59
|
xnew.context('xthree.object', root.scene);
|
|
60
|
-
|
|
60
|
+
unit.on('update', () => {
|
|
61
61
|
root.renderer.render(root.scene, root.camera);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
function Nest(
|
|
64
|
+
function Nest(unit, { object }) {
|
|
65
65
|
const parent = xnew.context('xthree.object');
|
|
66
66
|
xnew.context('xthree.object', object);
|
|
67
67
|
if (parent) {
|
|
68
68
|
parent === null || parent === void 0 ? void 0 : parent.add(object);
|
|
69
|
-
|
|
69
|
+
unit.on('finalize', () => {
|
|
70
70
|
parent === null || parent === void 0 ? void 0 : parent.remove(object);
|
|
71
71
|
});
|
|
72
72
|
}
|
package/dist/addons/xthree.mjs
CHANGED
|
@@ -26,7 +26,7 @@ var xthree = {
|
|
|
26
26
|
return (_a = xnew.context('xthree.root')) === null || _a === void 0 ? void 0 : _a.canvas;
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
function Root(
|
|
29
|
+
function Root(unit, { canvas, camera }) {
|
|
30
30
|
const root = {};
|
|
31
31
|
xnew.context('xthree.root', root);
|
|
32
32
|
root.canvas = canvas;
|
|
@@ -35,16 +35,16 @@ function Root(self, { canvas, camera }) {
|
|
|
35
35
|
root.camera = camera !== null && camera !== void 0 ? camera : new THREE.PerspectiveCamera(45, root.renderer.domElement.width / root.renderer.domElement.height);
|
|
36
36
|
root.scene = new THREE.Scene();
|
|
37
37
|
xnew.context('xthree.object', root.scene);
|
|
38
|
-
|
|
38
|
+
unit.on('update', () => {
|
|
39
39
|
root.renderer.render(root.scene, root.camera);
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function Nest(
|
|
42
|
+
function Nest(unit, { object }) {
|
|
43
43
|
const parent = xnew.context('xthree.object');
|
|
44
44
|
xnew.context('xthree.object', object);
|
|
45
45
|
if (parent) {
|
|
46
46
|
parent === null || parent === void 0 ? void 0 : parent.add(object);
|
|
47
|
-
|
|
47
|
+
unit.on('finalize', () => {
|
|
48
48
|
parent === null || parent === void 0 ? void 0 : parent.remove(object);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
import { Unit } from '../core/unit';
|
|
2
|
-
export declare function AnalogStick(
|
|
3
|
-
size?: number;
|
|
4
|
-
diagonal?: boolean;
|
|
5
|
-
fill?: string;
|
|
6
|
-
fillOpacity?: number;
|
|
2
|
+
export declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
7
3
|
stroke?: string;
|
|
8
4
|
strokeOpacity?: number;
|
|
9
5
|
strokeWidth?: number;
|
|
10
6
|
strokeLinejoin?: string;
|
|
11
|
-
}): void;
|
|
12
|
-
export declare function DirectionalPad(self: Unit, { size, diagonal, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
|
|
13
|
-
size?: number;
|
|
14
7
|
diagonal?: boolean;
|
|
15
8
|
fill?: string;
|
|
16
9
|
fillOpacity?: number;
|
|
10
|
+
}): void;
|
|
11
|
+
export declare function DirectionalPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
12
|
+
diagonal?: boolean;
|
|
17
13
|
stroke?: string;
|
|
18
14
|
strokeOpacity?: number;
|
|
19
15
|
strokeWidth?: number;
|
|
20
16
|
strokeLinejoin?: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
size?: number | undefined;
|
|
24
|
-
fill?: string | undefined;
|
|
25
|
-
fillOpacity?: number | undefined;
|
|
26
|
-
stroke?: string | undefined;
|
|
27
|
-
strokeOpacity?: number | undefined;
|
|
28
|
-
strokeWidth?: number | undefined;
|
|
29
|
-
strokeLinejoin?: string | undefined;
|
|
17
|
+
fill?: string;
|
|
18
|
+
fillOpacity?: number;
|
|
30
19
|
}): void;
|
|
@@ -23,8 +23,10 @@ interface UnitInternal {
|
|
|
23
23
|
anchor: UnitElement | null;
|
|
24
24
|
state: string;
|
|
25
25
|
tostart: boolean;
|
|
26
|
+
protected: boolean;
|
|
27
|
+
ancestors: Unit[];
|
|
26
28
|
children: Unit[];
|
|
27
|
-
promises:
|
|
29
|
+
promises: UnitPromise[];
|
|
28
30
|
elements: UnitElement[];
|
|
29
31
|
components: Function[];
|
|
30
32
|
listeners: MapMap<string, Function, {
|
|
@@ -39,7 +41,6 @@ export declare class Unit {
|
|
|
39
41
|
_: UnitInternal;
|
|
40
42
|
constructor(parent: Unit | null, ...args: any[]);
|
|
41
43
|
get element(): UnitElement;
|
|
42
|
-
get components(): Function[];
|
|
43
44
|
start(): void;
|
|
44
45
|
stop(): void;
|
|
45
46
|
finalize(): void;
|
|
@@ -66,10 +67,10 @@ export declare class Unit {
|
|
|
66
67
|
static type2units: MapSet<string, Unit>;
|
|
67
68
|
on(type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
68
69
|
off(type?: string, listener?: Function): void;
|
|
69
|
-
emit(type: string, ...args: any[]): void;
|
|
70
|
+
static emit(type: string, ...args: any[]): void;
|
|
70
71
|
}
|
|
71
72
|
export declare class UnitPromise {
|
|
72
|
-
|
|
73
|
+
promise: Promise<any>;
|
|
73
74
|
constructor(promise: Promise<any>);
|
|
74
75
|
then(callback: Function): UnitPromise;
|
|
75
76
|
catch(callback: Function): UnitPromise;
|
|
@@ -90,15 +90,6 @@ export declare const xnew: CreateUnit & {
|
|
|
90
90
|
* xnew.finally(() => console.log('All promises settled'))
|
|
91
91
|
*/
|
|
92
92
|
finally(callback: Function): UnitPromise;
|
|
93
|
-
/**
|
|
94
|
-
* Fetches a resource and registers the promise with the current component
|
|
95
|
-
* @param url - URL to fetch
|
|
96
|
-
* @param options - Optional fetch options (method, headers, body, etc.)
|
|
97
|
-
* @returns UnitPromise wrapping the fetch promise
|
|
98
|
-
* @example
|
|
99
|
-
* xnew.fetch('/api/users').then(res => res.json()).then(data => console.log(data))
|
|
100
|
-
*/
|
|
101
|
-
fetch(url: string, options?: object): UnitPromise;
|
|
102
93
|
/**
|
|
103
94
|
* Creates a scoped callback that captures the current component context
|
|
104
95
|
* @param callback - Function to wrap with current scope
|
|
@@ -119,6 +110,7 @@ export declare const xnew: CreateUnit & {
|
|
|
119
110
|
* buttons.forEach(btn => btn.finalize())
|
|
120
111
|
*/
|
|
121
112
|
find(component: Function): Unit[];
|
|
113
|
+
emit(type: string, ...args: any[]): void;
|
|
122
114
|
/**
|
|
123
115
|
* Executes a callback once after a delay, managed by component lifecycle
|
|
124
116
|
* @param timeout - Function to execute after Duration
|
|
@@ -153,5 +145,6 @@ export declare const xnew: CreateUnit & {
|
|
|
153
145
|
* }, 300)
|
|
154
146
|
*/
|
|
155
147
|
transition(transition: Function, duration?: number, easing?: string): any;
|
|
148
|
+
protect(): void;
|
|
156
149
|
};
|
|
157
150
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { ModalFrame, ModalContent } from './basics/Modal';
|
|
|
7
7
|
import { TabFrame, TabButton, TabContent } from './basics/Tab';
|
|
8
8
|
import { DragFrame, DragTarget } from './basics/Drag';
|
|
9
9
|
import { AnalogStick, DirectionalPad } from './basics/Controller';
|
|
10
|
+
import { TextStream } from './basics/Text';
|
|
10
11
|
import { VolumeController } from './basics/Audio';
|
|
11
12
|
import { icons } from './icons/icons';
|
|
12
13
|
declare const basics: {
|
|
@@ -23,6 +24,7 @@ declare const basics: {
|
|
|
23
24
|
TabFrame: typeof TabFrame;
|
|
24
25
|
TabButton: typeof TabButton;
|
|
25
26
|
TabContent: typeof TabContent;
|
|
27
|
+
TextStream: typeof TextStream;
|
|
26
28
|
DragFrame: typeof DragFrame;
|
|
27
29
|
DragTarget: typeof DragTarget;
|
|
28
30
|
AnalogStick: typeof AnalogStick;
|
package/dist/xnew.d.ts
CHANGED
|
@@ -49,8 +49,10 @@ interface UnitInternal {
|
|
|
49
49
|
anchor: UnitElement | null;
|
|
50
50
|
state: string;
|
|
51
51
|
tostart: boolean;
|
|
52
|
+
protected: boolean;
|
|
53
|
+
ancestors: Unit[];
|
|
52
54
|
children: Unit[];
|
|
53
|
-
promises:
|
|
55
|
+
promises: UnitPromise[];
|
|
54
56
|
elements: UnitElement[];
|
|
55
57
|
components: Function[];
|
|
56
58
|
listeners: MapMap<string, Function, {
|
|
@@ -65,7 +67,6 @@ declare class Unit {
|
|
|
65
67
|
_: UnitInternal;
|
|
66
68
|
constructor(parent: Unit | null, ...args: any[]);
|
|
67
69
|
get element(): UnitElement;
|
|
68
|
-
get components(): Function[];
|
|
69
70
|
start(): void;
|
|
70
71
|
stop(): void;
|
|
71
72
|
finalize(): void;
|
|
@@ -92,10 +93,10 @@ declare class Unit {
|
|
|
92
93
|
static type2units: MapSet<string, Unit>;
|
|
93
94
|
on(type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
94
95
|
off(type?: string, listener?: Function): void;
|
|
95
|
-
emit(type: string, ...args: any[]): void;
|
|
96
|
+
static emit(type: string, ...args: any[]): void;
|
|
96
97
|
}
|
|
97
98
|
declare class UnitPromise {
|
|
98
|
-
|
|
99
|
+
promise: Promise<any>;
|
|
99
100
|
constructor(promise: Promise<any>);
|
|
100
101
|
then(callback: Function): UnitPromise;
|
|
101
102
|
catch(callback: Function): UnitPromise;
|
|
@@ -193,15 +194,6 @@ declare const xnew$1: CreateUnit & {
|
|
|
193
194
|
* xnew.finally(() => console.log('All promises settled'))
|
|
194
195
|
*/
|
|
195
196
|
finally(callback: Function): UnitPromise;
|
|
196
|
-
/**
|
|
197
|
-
* Fetches a resource and registers the promise with the current component
|
|
198
|
-
* @param url - URL to fetch
|
|
199
|
-
* @param options - Optional fetch options (method, headers, body, etc.)
|
|
200
|
-
* @returns UnitPromise wrapping the fetch promise
|
|
201
|
-
* @example
|
|
202
|
-
* xnew.fetch('/api/users').then(res => res.json()).then(data => console.log(data))
|
|
203
|
-
*/
|
|
204
|
-
fetch(url: string, options?: object): UnitPromise;
|
|
205
197
|
/**
|
|
206
198
|
* Creates a scoped callback that captures the current component context
|
|
207
199
|
* @param callback - Function to wrap with current scope
|
|
@@ -222,6 +214,7 @@ declare const xnew$1: CreateUnit & {
|
|
|
222
214
|
* buttons.forEach(btn => btn.finalize())
|
|
223
215
|
*/
|
|
224
216
|
find(component: Function): Unit[];
|
|
217
|
+
emit(type: string, ...args: any[]): void;
|
|
225
218
|
/**
|
|
226
219
|
* Executes a callback once after a delay, managed by component lifecycle
|
|
227
220
|
* @param timeout - Function to execute after Duration
|
|
@@ -256,6 +249,7 @@ declare const xnew$1: CreateUnit & {
|
|
|
256
249
|
* }, 300)
|
|
257
250
|
*/
|
|
258
251
|
transition(transition: Function, duration?: number, easing?: string): any;
|
|
252
|
+
protect(): void;
|
|
259
253
|
};
|
|
260
254
|
|
|
261
255
|
declare function AccordionFrame(frame: Unit, { open, duration, easing }?: {
|
|
@@ -336,25 +330,29 @@ declare function DragFrame(frame: Unit, { x, y }?: {
|
|
|
336
330
|
}): void;
|
|
337
331
|
declare function DragTarget(target: Unit, {}?: {}): void;
|
|
338
332
|
|
|
339
|
-
declare function AnalogStick(
|
|
340
|
-
size?: number;
|
|
341
|
-
diagonal?: boolean;
|
|
342
|
-
fill?: string;
|
|
343
|
-
fillOpacity?: number;
|
|
333
|
+
declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
344
334
|
stroke?: string;
|
|
345
335
|
strokeOpacity?: number;
|
|
346
336
|
strokeWidth?: number;
|
|
347
337
|
strokeLinejoin?: string;
|
|
348
|
-
}): void;
|
|
349
|
-
declare function DirectionalPad(self: Unit, { size, diagonal, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
|
|
350
|
-
size?: number;
|
|
351
338
|
diagonal?: boolean;
|
|
352
339
|
fill?: string;
|
|
353
340
|
fillOpacity?: number;
|
|
341
|
+
}): void;
|
|
342
|
+
declare function DirectionalPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
343
|
+
diagonal?: boolean;
|
|
354
344
|
stroke?: string;
|
|
355
345
|
strokeOpacity?: number;
|
|
356
346
|
strokeWidth?: number;
|
|
357
347
|
strokeLinejoin?: string;
|
|
348
|
+
fill?: string;
|
|
349
|
+
fillOpacity?: number;
|
|
350
|
+
}): void;
|
|
351
|
+
|
|
352
|
+
declare function TextStream(unit: Unit, { text, speed, fade }?: {
|
|
353
|
+
text?: string;
|
|
354
|
+
speed?: number;
|
|
355
|
+
fade?: number;
|
|
358
356
|
}): void;
|
|
359
357
|
|
|
360
358
|
declare function VolumeController(unit: Unit, {}?: {}): void;
|
|
@@ -740,6 +738,7 @@ declare const basics: {
|
|
|
740
738
|
TabFrame: typeof TabFrame;
|
|
741
739
|
TabButton: typeof TabButton;
|
|
742
740
|
TabContent: typeof TabContent;
|
|
741
|
+
TextStream: typeof TextStream;
|
|
743
742
|
DragFrame: typeof DragFrame;
|
|
744
743
|
DragTarget: typeof DragTarget;
|
|
745
744
|
AnalogStick: typeof AnalogStick;
|