@mulsense/xnew 0.6.7 → 0.7.0
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/xpixi.js +6 -1
- package/dist/addons/xpixi.mjs +6 -1
- package/dist/addons/xthree.js +16 -0
- package/dist/addons/xthree.mjs +16 -0
- package/dist/xnew.d.ts +63 -65
- package/dist/xnew.js +188 -89
- package/dist/xnew.mjs +188 -89
- package/package.json +1 -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.7.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.7.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.7.x
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
Then import it in your JavaScript file:
|
package/dist/addons/xpixi.js
CHANGED
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
nest(object) {
|
|
31
31
|
xnew(Nest, { object });
|
|
32
|
+
xnew.extend(() => {
|
|
33
|
+
return {
|
|
34
|
+
get pixiObject() { return object; }
|
|
35
|
+
};
|
|
36
|
+
});
|
|
32
37
|
return object;
|
|
33
38
|
},
|
|
34
39
|
get renderer() {
|
|
@@ -52,7 +57,7 @@
|
|
|
52
57
|
})).then((value) => {
|
|
53
58
|
renderer = value;
|
|
54
59
|
});
|
|
55
|
-
|
|
60
|
+
const scene = new PIXI__namespace.Container();
|
|
56
61
|
return {
|
|
57
62
|
get renderer() { return renderer; },
|
|
58
63
|
get scene() { return scene; },
|
package/dist/addons/xpixi.mjs
CHANGED
|
@@ -7,6 +7,11 @@ var xpixi = {
|
|
|
7
7
|
},
|
|
8
8
|
nest(object) {
|
|
9
9
|
xnew(Nest, { object });
|
|
10
|
+
xnew.extend(() => {
|
|
11
|
+
return {
|
|
12
|
+
get pixiObject() { return object; }
|
|
13
|
+
};
|
|
14
|
+
});
|
|
10
15
|
return object;
|
|
11
16
|
},
|
|
12
17
|
get renderer() {
|
|
@@ -30,7 +35,7 @@ function Root(unit, { canvas }) {
|
|
|
30
35
|
})).then((value) => {
|
|
31
36
|
renderer = value;
|
|
32
37
|
});
|
|
33
|
-
|
|
38
|
+
const scene = new PIXI.Container();
|
|
34
39
|
return {
|
|
35
40
|
get renderer() { return renderer; },
|
|
36
41
|
get scene() { return scene; },
|
package/dist/addons/xthree.js
CHANGED
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
nest(object) {
|
|
31
31
|
xnew(Nest, { object });
|
|
32
|
+
xnew.extend(() => {
|
|
33
|
+
return {
|
|
34
|
+
get threeObject() { return object; }
|
|
35
|
+
};
|
|
36
|
+
});
|
|
32
37
|
return object;
|
|
33
38
|
},
|
|
34
39
|
get renderer() {
|
|
@@ -67,6 +72,17 @@
|
|
|
67
72
|
parent.add(object);
|
|
68
73
|
unit.on('finalize', () => {
|
|
69
74
|
parent.remove(object);
|
|
75
|
+
object.traverse((obj) => {
|
|
76
|
+
if (obj.isMesh) {
|
|
77
|
+
obj.geometry.dispose();
|
|
78
|
+
if (Array.isArray(obj.material)) {
|
|
79
|
+
obj.material.forEach((mat) => mat.dispose());
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
obj.material.dispose();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
70
86
|
});
|
|
71
87
|
return {
|
|
72
88
|
get threeObject() { return object; },
|
package/dist/addons/xthree.mjs
CHANGED
|
@@ -7,6 +7,11 @@ var xthree = {
|
|
|
7
7
|
},
|
|
8
8
|
nest(object) {
|
|
9
9
|
xnew(Nest, { object });
|
|
10
|
+
xnew.extend(() => {
|
|
11
|
+
return {
|
|
12
|
+
get threeObject() { return object; }
|
|
13
|
+
};
|
|
14
|
+
});
|
|
10
15
|
return object;
|
|
11
16
|
},
|
|
12
17
|
get renderer() {
|
|
@@ -45,6 +50,17 @@ function Nest(unit, { object }) {
|
|
|
45
50
|
parent.add(object);
|
|
46
51
|
unit.on('finalize', () => {
|
|
47
52
|
parent.remove(object);
|
|
53
|
+
object.traverse((obj) => {
|
|
54
|
+
if (obj.isMesh) {
|
|
55
|
+
obj.geometry.dispose();
|
|
56
|
+
if (Array.isArray(obj.material)) {
|
|
57
|
+
obj.material.forEach((mat) => mat.dispose());
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
obj.material.dispose();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
48
64
|
});
|
|
49
65
|
return {
|
|
50
66
|
get threeObject() { return object; },
|
package/dist/xnew.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare class Eventor {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
type UnitElement = HTMLElement | SVGElement;
|
|
47
|
+
type UnitArgs = [Component?: Function | string, props?: Object] | [target: UnitElement | string, Component?: Function | string, props?: Object];
|
|
47
48
|
interface Context {
|
|
48
49
|
previous: Context | null;
|
|
49
50
|
key?: any;
|
|
@@ -55,39 +56,38 @@ interface Snapshot {
|
|
|
55
56
|
element: UnitElement;
|
|
56
57
|
Component: Function | null;
|
|
57
58
|
}
|
|
58
|
-
interface Internal {
|
|
59
|
-
parent: Unit | null;
|
|
60
|
-
ancestors: Unit[];
|
|
61
|
-
children: Unit[];
|
|
62
|
-
state: string;
|
|
63
|
-
tostart: boolean;
|
|
64
|
-
protected: boolean;
|
|
65
|
-
promises: UnitPromise[];
|
|
66
|
-
results: Record<string, any>;
|
|
67
|
-
defines: Record<string, any>;
|
|
68
|
-
systems: Record<string, {
|
|
69
|
-
listener: Function;
|
|
70
|
-
execute: Function;
|
|
71
|
-
}[]>;
|
|
72
|
-
currentElement: UnitElement;
|
|
73
|
-
currentContext: Context;
|
|
74
|
-
currentComponent: Function | null;
|
|
75
|
-
nestElements: {
|
|
76
|
-
element: UnitElement;
|
|
77
|
-
owned: boolean;
|
|
78
|
-
}[];
|
|
79
|
-
Components: Function[];
|
|
80
|
-
listeners: MapMap<string, Function, {
|
|
81
|
-
element: UnitElement;
|
|
82
|
-
Component: Function | null;
|
|
83
|
-
execute: Function;
|
|
84
|
-
}>;
|
|
85
|
-
eventor: Eventor;
|
|
86
|
-
}
|
|
87
59
|
declare class Unit {
|
|
88
60
|
[key: string]: any;
|
|
89
|
-
_:
|
|
90
|
-
|
|
61
|
+
_: {
|
|
62
|
+
parent: Unit | null;
|
|
63
|
+
ancestors: Unit[];
|
|
64
|
+
children: Unit[];
|
|
65
|
+
state: string;
|
|
66
|
+
tostart: boolean;
|
|
67
|
+
protected: boolean;
|
|
68
|
+
promises: UnitPromise[];
|
|
69
|
+
results: Record<string, any>;
|
|
70
|
+
defines: Record<string, any>;
|
|
71
|
+
systems: Record<string, {
|
|
72
|
+
listener: Function;
|
|
73
|
+
execute: Function;
|
|
74
|
+
}[]>;
|
|
75
|
+
currentElement: UnitElement;
|
|
76
|
+
currentContext: Context;
|
|
77
|
+
currentComponent: Function | null;
|
|
78
|
+
nestElements: {
|
|
79
|
+
element: UnitElement;
|
|
80
|
+
owned: boolean;
|
|
81
|
+
}[];
|
|
82
|
+
Components: Function[];
|
|
83
|
+
listeners: MapMap<string, Function, {
|
|
84
|
+
element: UnitElement;
|
|
85
|
+
Component: Function | null;
|
|
86
|
+
execute: Function;
|
|
87
|
+
}>;
|
|
88
|
+
eventor: Eventor;
|
|
89
|
+
};
|
|
90
|
+
constructor(parent: Unit | null, ...args: UnitArgs);
|
|
91
91
|
get element(): UnitElement;
|
|
92
92
|
start(): void;
|
|
93
93
|
stop(): void;
|
|
@@ -120,49 +120,26 @@ declare class Unit {
|
|
|
120
120
|
static emit(type: string, props?: object): void;
|
|
121
121
|
}
|
|
122
122
|
declare class UnitPromise {
|
|
123
|
-
promise
|
|
124
|
-
|
|
125
|
-
constructor(promise: Promise<any>, Component: Function | null);
|
|
123
|
+
private promise;
|
|
124
|
+
constructor(promise: Promise<any>);
|
|
126
125
|
then(callback: Function): UnitPromise;
|
|
127
126
|
catch(callback: Function): UnitPromise;
|
|
128
127
|
finally(callback: Function): UnitPromise;
|
|
128
|
+
static all(promises: UnitPromise[]): UnitPromise;
|
|
129
129
|
private wrap;
|
|
130
130
|
}
|
|
131
131
|
declare class UnitTimer {
|
|
132
132
|
private unit;
|
|
133
133
|
private queue;
|
|
134
134
|
clear(): void;
|
|
135
|
-
timeout(
|
|
136
|
-
interval(
|
|
135
|
+
timeout(timeout: Function, duration?: number): UnitTimer;
|
|
136
|
+
interval(timeout: Function, duration?: number, iterations?: number): UnitTimer;
|
|
137
137
|
transition(transition: Function, duration?: number, easing?: string): UnitTimer;
|
|
138
138
|
private static execute;
|
|
139
139
|
private static next;
|
|
140
140
|
private static Component;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
interface CreateUnit {
|
|
144
|
-
/**
|
|
145
|
-
* creates a new Unit component
|
|
146
|
-
* @param Component - component function
|
|
147
|
-
* @param props - properties for component function
|
|
148
|
-
* @returns a new Unit instance
|
|
149
|
-
* @example
|
|
150
|
-
* const unit = xnew(MyComponent, { data: 0 })
|
|
151
|
-
*/
|
|
152
|
-
(Component?: Function | string, props?: Object): Unit;
|
|
153
|
-
/**
|
|
154
|
-
* creates a new Unit component
|
|
155
|
-
* @param target - HTMLElement | SVGElement, or HTML tag for new element
|
|
156
|
-
* @param Component - component function
|
|
157
|
-
* @param props - properties for component function
|
|
158
|
-
* @returns a new Unit instance
|
|
159
|
-
* @example
|
|
160
|
-
* const unit = xnew(element, MyComponent, { data: 0 })
|
|
161
|
-
* const unit = xnew('<div>', MyComponent, { data: 0 })
|
|
162
|
-
*/
|
|
163
|
-
(target: HTMLElement | SVGElement | string, Component?: Function | string, props?: Object): Unit;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
143
|
interface TransitionOptions {
|
|
167
144
|
duration?: number;
|
|
168
145
|
easing?: string;
|
|
@@ -179,10 +156,13 @@ declare function Accordion(unit: Unit): void;
|
|
|
179
156
|
declare function Popup(unit: Unit): void;
|
|
180
157
|
|
|
181
158
|
type ScreenFit = 'contain' | 'cover';
|
|
182
|
-
declare function Screen(unit: Unit, {
|
|
183
|
-
|
|
159
|
+
declare function Screen(unit: Unit, { width, height, fit }?: {
|
|
160
|
+
width?: number;
|
|
161
|
+
height?: number;
|
|
184
162
|
fit?: ScreenFit;
|
|
185
|
-
}):
|
|
163
|
+
}): {
|
|
164
|
+
readonly canvas: UnitElement;
|
|
165
|
+
};
|
|
186
166
|
|
|
187
167
|
declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
|
|
188
168
|
stroke?: string;
|
|
@@ -227,12 +207,21 @@ declare function Panel(unit: Unit, { params }: PanelOptions): {
|
|
|
227
207
|
separator(): void;
|
|
228
208
|
};
|
|
229
209
|
|
|
210
|
+
declare function Scene(unit: Unit): void;
|
|
230
211
|
declare function Flow(unit: Unit): {
|
|
231
212
|
get scene(): Unit | null;
|
|
232
213
|
set scene(value: Unit);
|
|
233
|
-
next(Component: Function, props?: any): void;
|
|
214
|
+
next(Component: Function, props?: any, callback?: Function): void;
|
|
234
215
|
};
|
|
235
216
|
|
|
217
|
+
declare class XImage {
|
|
218
|
+
canvas: HTMLCanvasElement;
|
|
219
|
+
constructor(canvas: HTMLCanvasElement);
|
|
220
|
+
constructor(width: number, height: number);
|
|
221
|
+
clip(x: number, y: number, width: number, height: number): XImage;
|
|
222
|
+
download(filename: string): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
236
225
|
type SynthesizerOptions = {
|
|
237
226
|
oscillator: OscillatorOptions;
|
|
238
227
|
amp: AmpOptions;
|
|
@@ -277,17 +266,22 @@ declare namespace xnew {
|
|
|
277
266
|
type Unit = InstanceType<typeof Unit>;
|
|
278
267
|
type UnitTimer = InstanceType<typeof UnitTimer>;
|
|
279
268
|
}
|
|
280
|
-
declare const xnew:
|
|
269
|
+
declare const xnew: ((...args: UnitArgs) => Unit) & {
|
|
281
270
|
nest(target: UnitElement | string): HTMLElement | SVGElement;
|
|
282
271
|
extend(Component: Function, props?: Object): {
|
|
283
272
|
[key: string]: any;
|
|
284
273
|
};
|
|
274
|
+
append(parent: Unit, ...args: UnitArgs): void;
|
|
285
275
|
context(key: any): any;
|
|
286
276
|
promise(promise: Function | Promise<any> | Unit): UnitPromise;
|
|
287
277
|
then(callback: Function): UnitPromise;
|
|
288
278
|
catch(callback: Function): UnitPromise;
|
|
289
|
-
commit(object?: Record<string, any>): void;
|
|
290
279
|
finally(callback: Function): UnitPromise;
|
|
280
|
+
resolvers(): {
|
|
281
|
+
resolve(): void;
|
|
282
|
+
reject(): void;
|
|
283
|
+
};
|
|
284
|
+
output(object?: Record<string, any>): void;
|
|
291
285
|
scope(callback: any): any;
|
|
292
286
|
find(Component: Function): Unit[];
|
|
293
287
|
emit(type: string, ...args: any[]): void;
|
|
@@ -305,12 +299,16 @@ declare const xnew: CreateUnit & {
|
|
|
305
299
|
Accordion: typeof Accordion;
|
|
306
300
|
Popup: typeof Popup;
|
|
307
301
|
Flow: typeof Flow;
|
|
302
|
+
Scene: typeof Scene;
|
|
308
303
|
};
|
|
309
304
|
audio: {
|
|
310
305
|
load(path: string): UnitPromise;
|
|
311
306
|
synthesizer(props: SynthesizerOptions): Synthesizer;
|
|
312
307
|
volume: number;
|
|
313
308
|
};
|
|
309
|
+
image: {
|
|
310
|
+
from(canvas: HTMLCanvasElement): XImage;
|
|
311
|
+
};
|
|
314
312
|
};
|
|
315
313
|
|
|
316
314
|
export { xnew as default };
|