@mulsense/xnew 0.1.8 → 0.1.10
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 +46 -46
- package/dist/types/audio/audio.d.ts +55 -2
- package/dist/types/audio/loader.d.ts +6 -2
- package/dist/types/basics/Event.d.ts +4 -3
- package/dist/types/basics/Touch.d.ts +9 -8
- package/dist/types/core/time.d.ts +6 -2
- package/dist/types/core/unit.d.ts +41 -10
- package/dist/types/core/xnew.d.ts +11 -21
- package/dist/types/index.d.ts +3 -12
- package/dist/xnew.d.ts +48 -63
- package/dist/xnew.js +375 -400
- package/dist/xnew.mjs +375 -400
- package/package.json +78 -78
- package/dist/addons/xmatter.d.ts +0 -6
- package/dist/addons/xmatter.js +0 -43
- package/dist/addons/xmatter.mjs +0 -38
- package/dist/addons/xpixi.d.ts +0 -10
- package/dist/addons/xpixi.js +0 -99
- package/dist/addons/xpixi.mjs +0 -75
- package/dist/addons/xrapier2d.d.ts +0 -6
- package/dist/addons/xrapier2d.js +0 -69
- package/dist/addons/xrapier2d.mjs +0 -64
- package/dist/addons/xthree.d.ts +0 -9
- package/dist/addons/xthree.js +0 -77
- package/dist/addons/xthree.mjs +0 -53
- package/dist/types/basics/Block.d.ts +0 -24
- package/dist/types/basics/Bullet.d.ts +0 -7
- package/dist/types/basics/ControlPanel.d.ts +0 -7
- package/dist/types/basics/Navigation.d.ts +0 -1
- package/dist/types/basics/Panel.d.ts +0 -6
- package/dist/types/basics/Popup.d.ts +0 -8
- package/dist/types/basics/TabView.d.ts +0 -18
- package/dist/types/basics/Tabs.d.ts +0 -8
- package/dist/types/basics/Transition.d.ts +0 -17
- package/dist/types/basics/WorkSpace.d.ts +0 -16
- package/dist/types/core/util.d.ts +0 -1
- package/dist/types/xnew.d.ts +0 -8
package/README.md
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# xnew
|
|
2
|
-
`xnew` is a JavaScript / TypeScript library for component-oriented programming,
|
|
3
|
-
providing a flexible architecture well-suited for applications with dynamic scenes and games.
|
|
4
|
-
|
|
5
|
-
[**Visit the xnew website**](https://mulsense.github.io/xnew)
|
|
6
|
-
|
|
7
|
-
<div>
|
|
8
|
-
<img src="website/static/img/introduction.svg" width="500" alt="xnew introduction" />
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
## Setup
|
|
12
|
-
|
|
13
|
-
### Via CDN
|
|
14
|
-
Include the following script in your HTML file:
|
|
15
|
-
```html
|
|
16
|
-
<script src="https://unpkg.com/@mulsense/xnew@0.1.x/dist/xnew.js"></script>
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Via CDN (ESM)
|
|
20
|
-
Use the ES module version with an import map:
|
|
21
|
-
```html
|
|
22
|
-
<script type="importmap">
|
|
23
|
-
{
|
|
24
|
-
"imports": {
|
|
25
|
-
"@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.1.x/dist/xnew.mjs"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<script type="module">
|
|
31
|
-
import xnew from '@mulsense/xnew';
|
|
32
|
-
|
|
33
|
-
// Your code here
|
|
34
|
-
</script>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Via npm
|
|
38
|
-
Install `xnew` using npm:
|
|
39
|
-
```bash
|
|
40
|
-
npm install @mulsense/xnew@0.1.x
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Then import it in your JavaScript file:
|
|
44
|
-
```js
|
|
45
|
-
import xnew from '@mulsense/xnew';
|
|
46
|
-
```
|
|
1
|
+
# xnew
|
|
2
|
+
`xnew` is a JavaScript / TypeScript library for component-oriented programming,
|
|
3
|
+
providing a flexible architecture well-suited for applications with dynamic scenes and games.
|
|
4
|
+
|
|
5
|
+
[**Visit the xnew website**](https://mulsense.github.io/xnew)
|
|
6
|
+
|
|
7
|
+
<div>
|
|
8
|
+
<img src="website/static/img/introduction.svg" width="500" alt="xnew introduction" />
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Via CDN
|
|
14
|
+
Include the following script in your HTML file:
|
|
15
|
+
```html
|
|
16
|
+
<script src="https://unpkg.com/@mulsense/xnew@0.1.x/dist/xnew.js"></script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Via CDN (ESM)
|
|
20
|
+
Use the ES module version with an import map:
|
|
21
|
+
```html
|
|
22
|
+
<script type="importmap">
|
|
23
|
+
{
|
|
24
|
+
"imports": {
|
|
25
|
+
"@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.1.x/dist/xnew.mjs"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script type="module">
|
|
31
|
+
import xnew from '@mulsense/xnew';
|
|
32
|
+
|
|
33
|
+
// Your code here
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Via npm
|
|
38
|
+
Install `xnew` using npm:
|
|
39
|
+
```bash
|
|
40
|
+
npm install @mulsense/xnew@0.1.x
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then import it in your JavaScript file:
|
|
44
|
+
```js
|
|
45
|
+
import xnew from '@mulsense/xnew';
|
|
46
|
+
```
|
|
@@ -1,2 +1,55 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
1
|
+
export declare const audio: {
|
|
2
|
+
load(path: string): AudioFile;
|
|
3
|
+
synthesizer(props: SynthProps): Synthesizer;
|
|
4
|
+
volume: number;
|
|
5
|
+
};
|
|
6
|
+
declare class AudioFile {
|
|
7
|
+
buffer?: AudioBuffer;
|
|
8
|
+
promise: Promise<void>;
|
|
9
|
+
source?: AudioBufferSourceNode;
|
|
10
|
+
amp?: GainNode;
|
|
11
|
+
start: number | null;
|
|
12
|
+
constructor(path: string);
|
|
13
|
+
play(offset?: number, loop?: boolean): void;
|
|
14
|
+
pause(): number | undefined;
|
|
15
|
+
}
|
|
16
|
+
type SynthProps = {
|
|
17
|
+
oscillator: OscillatorOptions;
|
|
18
|
+
amp: AmpOptions;
|
|
19
|
+
filter?: FilterOptions;
|
|
20
|
+
reverb?: ReverbOptions;
|
|
21
|
+
bpm?: number;
|
|
22
|
+
};
|
|
23
|
+
type OscillatorOptions = {
|
|
24
|
+
type: OscillatorType;
|
|
25
|
+
envelope?: Envelope;
|
|
26
|
+
LFO?: LFO;
|
|
27
|
+
};
|
|
28
|
+
type FilterOptions = {
|
|
29
|
+
type: BiquadFilterType;
|
|
30
|
+
cutoff: number;
|
|
31
|
+
};
|
|
32
|
+
type AmpOptions = {
|
|
33
|
+
envelope: Envelope;
|
|
34
|
+
};
|
|
35
|
+
type ReverbOptions = {
|
|
36
|
+
time: number;
|
|
37
|
+
mix: number;
|
|
38
|
+
};
|
|
39
|
+
type Envelope = {
|
|
40
|
+
amount: number;
|
|
41
|
+
ADSR: [number, number, number, number];
|
|
42
|
+
};
|
|
43
|
+
type LFO = {
|
|
44
|
+
amount: number;
|
|
45
|
+
type: OscillatorType;
|
|
46
|
+
rate: number;
|
|
47
|
+
};
|
|
48
|
+
declare class Synthesizer {
|
|
49
|
+
props: SynthProps;
|
|
50
|
+
constructor(props: SynthProps);
|
|
51
|
+
press(frequency: number | string, duration?: number | string, wait?: number): {
|
|
52
|
+
release: () => void;
|
|
53
|
+
} | undefined;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { AudioNodeMap } from './audio';
|
|
1
2
|
export declare function load(path: string): AudioFile;
|
|
2
3
|
declare class AudioFile {
|
|
3
4
|
data: any;
|
|
4
5
|
startTime: number | null;
|
|
5
|
-
|
|
6
|
-
amp: GainNode;
|
|
6
|
+
nodes: AudioNodeMap;
|
|
7
7
|
constructor(path: string);
|
|
8
8
|
isReady(): boolean;
|
|
9
9
|
get promise(): Promise<void>;
|
|
10
|
+
set volume(value: number);
|
|
11
|
+
get volume(): number;
|
|
12
|
+
set loop(value: boolean);
|
|
13
|
+
get loop(): boolean;
|
|
10
14
|
play(offset?: number): void;
|
|
11
15
|
pause(): number | undefined;
|
|
12
16
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function ResizeEvent(
|
|
3
|
-
export declare function
|
|
1
|
+
import { Unit } from '../core/unit';
|
|
2
|
+
export declare function ResizeEvent(resize: Unit): void;
|
|
3
|
+
export declare function KeyboardEvent(unit: Unit): void;
|
|
4
|
+
export declare function PointerEvent(unit: Unit): void;
|
|
@@ -8,14 +8,15 @@ export declare function TouchStick(self: xnew.Unit, { size, fill, fillOpacity, s
|
|
|
8
8
|
strokeWidth?: number | undefined;
|
|
9
9
|
strokeLinejoin?: string | undefined;
|
|
10
10
|
}): void;
|
|
11
|
-
export declare function
|
|
12
|
-
size?: number
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export declare function DirectionalPad(self: xnew.Unit, { size, diagonal, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
|
|
12
|
+
size?: number;
|
|
13
|
+
diagonal?: boolean;
|
|
14
|
+
fill?: string;
|
|
15
|
+
fillOpacity?: number;
|
|
16
|
+
stroke?: string;
|
|
17
|
+
strokeOpacity?: number;
|
|
18
|
+
strokeWidth?: number;
|
|
19
|
+
strokeLinejoin?: string;
|
|
19
20
|
}): void;
|
|
20
21
|
export declare function TouchButton(self: xnew.Unit, { size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
|
|
21
22
|
size?: number | undefined;
|
|
@@ -6,15 +6,19 @@ export declare class Ticker {
|
|
|
6
6
|
export declare class Timer {
|
|
7
7
|
private timeout;
|
|
8
8
|
private transition;
|
|
9
|
-
private
|
|
9
|
+
private interval;
|
|
10
10
|
private loop;
|
|
11
|
+
private easing;
|
|
11
12
|
private id;
|
|
12
13
|
private time;
|
|
13
14
|
private offset;
|
|
14
15
|
private status;
|
|
15
16
|
private visibilitychange;
|
|
16
17
|
private ticker;
|
|
17
|
-
constructor(
|
|
18
|
+
constructor(transition: Function | null, timeout: Function | null, interval?: number, { loop, easing }?: {
|
|
19
|
+
loop?: boolean;
|
|
20
|
+
easing?: string;
|
|
21
|
+
});
|
|
18
22
|
clear(): void;
|
|
19
23
|
elapsed(): number;
|
|
20
24
|
start(): void;
|
|
@@ -33,23 +33,17 @@ interface UnitInternal {
|
|
|
33
33
|
defines: Record<string, any>;
|
|
34
34
|
systems: Record<string, Function[]>;
|
|
35
35
|
}
|
|
36
|
-
export declare class UnitPromise {
|
|
37
|
-
private promise;
|
|
38
|
-
constructor(promise: Promise<any>);
|
|
39
|
-
then(callback: Function): UnitPromise;
|
|
40
|
-
catch(callback: Function): UnitPromise;
|
|
41
|
-
finally(callback: Function): UnitPromise;
|
|
42
|
-
}
|
|
43
36
|
export declare class Unit {
|
|
44
37
|
[key: string]: any;
|
|
45
38
|
_: UnitInternal;
|
|
46
|
-
constructor(parent: Unit | null,
|
|
39
|
+
constructor(parent: Unit | null, ...args: any[]);
|
|
47
40
|
get element(): UnitElement;
|
|
48
41
|
get components(): Function[];
|
|
49
42
|
start(): void;
|
|
50
43
|
stop(): void;
|
|
51
44
|
finalize(): void;
|
|
52
45
|
reboot(): void;
|
|
46
|
+
append(...args: any[]): void;
|
|
53
47
|
static initialize(unit: Unit, anchor: UnitElement | null): void;
|
|
54
48
|
static finalize(unit: Unit): void;
|
|
55
49
|
static nest(unit: Unit, tag: string): UnitElement;
|
|
@@ -67,13 +61,50 @@ export declare class Unit {
|
|
|
67
61
|
static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
|
|
68
62
|
static snapshot(unit: Unit): Snapshot;
|
|
69
63
|
static context(unit: Unit, key: string, value?: any): any;
|
|
70
|
-
static
|
|
64
|
+
static component2units: MapSet<Function, Unit>;
|
|
71
65
|
static find(component: Function): Unit[];
|
|
72
|
-
static
|
|
66
|
+
static type2units: MapSet<string, Unit>;
|
|
73
67
|
on(type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
74
68
|
off(type?: string, listener?: Function): void;
|
|
75
69
|
emit(type: string, ...args: any[]): void;
|
|
76
70
|
static subon(unit: Unit, target: UnitElement | Window | Document, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
77
71
|
static suboff(unit: Unit, target: UnitElement | Window | Document | null, type?: string, listener?: Function): void;
|
|
78
72
|
}
|
|
73
|
+
export declare class UnitPromise {
|
|
74
|
+
private promise;
|
|
75
|
+
constructor(promise: Promise<any>);
|
|
76
|
+
then(callback: Function): UnitPromise;
|
|
77
|
+
catch(callback: Function): UnitPromise;
|
|
78
|
+
finally(callback: Function): UnitPromise;
|
|
79
|
+
}
|
|
80
|
+
export declare class UnitTimer {
|
|
81
|
+
private unit;
|
|
82
|
+
private stack;
|
|
83
|
+
constructor({ transition, timeout, interval, easing, loop }: {
|
|
84
|
+
transition?: Function;
|
|
85
|
+
timeout?: Function;
|
|
86
|
+
interval: number;
|
|
87
|
+
easing?: string;
|
|
88
|
+
loop?: boolean;
|
|
89
|
+
});
|
|
90
|
+
clear(): void;
|
|
91
|
+
timeout(timeout: Function, interval?: number): this;
|
|
92
|
+
transition(transition: Function, interval?: number, easing?: string): this;
|
|
93
|
+
static execute(timer: UnitTimer, { transition, timeout, interval, easing, loop }: {
|
|
94
|
+
transition?: Function;
|
|
95
|
+
timeout?: Function;
|
|
96
|
+
interval: number;
|
|
97
|
+
easing?: string;
|
|
98
|
+
loop?: boolean;
|
|
99
|
+
}): void;
|
|
100
|
+
static next(timer: UnitTimer): void;
|
|
101
|
+
static Component(unit: Unit, { snapshot, transition, timeout, interval, loop, easing }: {
|
|
102
|
+
snapshot: Snapshot;
|
|
103
|
+
transition?: Function;
|
|
104
|
+
timeout?: Function;
|
|
105
|
+
interval?: number;
|
|
106
|
+
loop?: boolean;
|
|
107
|
+
easing?: string;
|
|
108
|
+
}): void;
|
|
109
|
+
}
|
|
79
110
|
export {};
|
|
@@ -119,36 +119,26 @@ export declare const xnew: CreateUnit & {
|
|
|
119
119
|
* buttons.forEach(btn => btn.finalize())
|
|
120
120
|
*/
|
|
121
121
|
find(component: Function): Unit[];
|
|
122
|
-
/**
|
|
123
|
-
* Appends new components to existing component(s) in the tree
|
|
124
|
-
* @param anchor - Component function or Unit instance to append to
|
|
125
|
-
* @param args - Arguments to pass to xnew for creating child components
|
|
126
|
-
* @throws Error if anchor parameter is invalid
|
|
127
|
-
* @example
|
|
128
|
-
* xnew.append(MyContainer, ChildComponent, { prop: 'value' })
|
|
129
|
-
* xnew.append(unitInstance, AnotherComponent)
|
|
130
|
-
*/
|
|
131
|
-
append(anchor: Unit, ...args: any[]): void;
|
|
132
122
|
/**
|
|
133
123
|
* Executes a callback once after a delay, managed by component lifecycle
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
124
|
+
* @param timeout - Function to execute after Interval
|
|
125
|
+
* @param interval - Interval duration in milliseconds
|
|
136
126
|
* @returns Object with clear() method to cancel the timeout
|
|
137
127
|
* @example
|
|
138
128
|
* const timer = xnew.timeout(() => console.log('Delayed'), 1000)
|
|
139
129
|
* // Cancel if needed: timer.clear()
|
|
140
130
|
*/
|
|
141
|
-
timeout(
|
|
131
|
+
timeout(timeout: Function, interval?: number): any;
|
|
142
132
|
/**
|
|
143
133
|
* Executes a callback repeatedly at specified intervals, managed by component lifecycle
|
|
144
|
-
* @param
|
|
145
|
-
* @param
|
|
134
|
+
* @param timeout - Function to execute at each interval
|
|
135
|
+
* @param interval - Interval duration in milliseconds
|
|
146
136
|
* @returns Object with clear() method to stop the interval
|
|
147
137
|
* @example
|
|
148
138
|
* const timer = xnew.interval(() => console.log('Tick'), 1000)
|
|
149
139
|
* // Stop when needed: timer.clear()
|
|
150
140
|
*/
|
|
151
|
-
interval(
|
|
141
|
+
interval(timeout: Function, interval: number): any;
|
|
152
142
|
/**
|
|
153
143
|
* Creates a transition animation with easing, executing callback with progress values
|
|
154
144
|
* @param callback - Function called with progress value (0.0 to 1.0)
|
|
@@ -156,13 +146,13 @@ export declare const xnew: CreateUnit & {
|
|
|
156
146
|
* @param easing - Easing function: 'linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out' (default: 'linear')
|
|
157
147
|
* @returns Object with clear() and next() methods for controlling transitions
|
|
158
148
|
* @example
|
|
159
|
-
* xnew.transition(
|
|
160
|
-
* element.style.opacity =
|
|
161
|
-
* }, 500, 'ease-out').
|
|
162
|
-
* element.style.transform = `scale(${
|
|
149
|
+
* xnew.transition(p => {
|
|
150
|
+
* element.style.opacity = p
|
|
151
|
+
* }, 500, 'ease-out').transition(p => {
|
|
152
|
+
* element.style.transform = `scale(${p})`
|
|
163
153
|
* }, 300)
|
|
164
154
|
*/
|
|
165
|
-
transition(
|
|
155
|
+
transition(transition: Function, interval?: number, easing?: string): any;
|
|
166
156
|
/**
|
|
167
157
|
* Creates an event listener manager for a target element with automatic cleanup
|
|
168
158
|
* @param target - Element, Window, or Document to attach listeners to
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { xnew as base } from './core/xnew';
|
|
2
2
|
import { Unit } from './core/unit';
|
|
3
|
-
import {
|
|
4
|
-
import { PointerEvent } from './basics/
|
|
5
|
-
import { KeyboardEvent } from './basics/KeyboardEvent';
|
|
3
|
+
import { AccordionFrame, AccordionHeader, AccordionBullet, AccordionContent } from './basics/Accordion';
|
|
4
|
+
import { ResizeEvent, PointerEvent, KeyboardEvent } from './basics/Event';
|
|
6
5
|
import { Screen } from './basics/Screen';
|
|
7
6
|
import { InputFrame } from './basics/Input';
|
|
8
7
|
import { ModalFrame, ModalContent } from './basics/Modal';
|
|
9
8
|
import { TabFrame, TabButton, TabContent } from './basics/Tab';
|
|
10
|
-
import { AccordionFrame, AccordionHeader, AccordionBullet, AccordionContent } from './basics/Accordion';
|
|
11
9
|
import { DragFrame, DragTarget } from './basics/Drag';
|
|
12
10
|
import { AnalogStick, DirectionalPad } from './basics/Controller';
|
|
13
|
-
import {
|
|
14
|
-
import { synthesizer } from './audio/synthesizer';
|
|
11
|
+
import { audio } from './audio/audio';
|
|
15
12
|
declare const basics: {
|
|
16
13
|
Screen: typeof Screen;
|
|
17
14
|
PointerEvent: typeof PointerEvent;
|
|
@@ -32,12 +29,6 @@ declare const basics: {
|
|
|
32
29
|
AnalogStick: typeof AnalogStick;
|
|
33
30
|
DirectionalPad: typeof DirectionalPad;
|
|
34
31
|
};
|
|
35
|
-
declare const audio: {
|
|
36
|
-
master: GainNode;
|
|
37
|
-
context: AudioContext;
|
|
38
|
-
synthesizer: typeof synthesizer;
|
|
39
|
-
load: typeof load;
|
|
40
|
-
};
|
|
41
32
|
declare namespace xnew {
|
|
42
33
|
type Unit = InstanceType<typeof Unit>;
|
|
43
34
|
}
|
package/dist/xnew.d.ts
CHANGED
|
@@ -59,23 +59,17 @@ interface UnitInternal {
|
|
|
59
59
|
defines: Record<string, any>;
|
|
60
60
|
systems: Record<string, Function[]>;
|
|
61
61
|
}
|
|
62
|
-
declare class UnitPromise {
|
|
63
|
-
private promise;
|
|
64
|
-
constructor(promise: Promise<any>);
|
|
65
|
-
then(callback: Function): UnitPromise;
|
|
66
|
-
catch(callback: Function): UnitPromise;
|
|
67
|
-
finally(callback: Function): UnitPromise;
|
|
68
|
-
}
|
|
69
62
|
declare class Unit {
|
|
70
63
|
[key: string]: any;
|
|
71
64
|
_: UnitInternal;
|
|
72
|
-
constructor(parent: Unit | null,
|
|
65
|
+
constructor(parent: Unit | null, ...args: any[]);
|
|
73
66
|
get element(): UnitElement;
|
|
74
67
|
get components(): Function[];
|
|
75
68
|
start(): void;
|
|
76
69
|
stop(): void;
|
|
77
70
|
finalize(): void;
|
|
78
71
|
reboot(): void;
|
|
72
|
+
append(...args: any[]): void;
|
|
79
73
|
static initialize(unit: Unit, anchor: UnitElement | null): void;
|
|
80
74
|
static finalize(unit: Unit): void;
|
|
81
75
|
static nest(unit: Unit, tag: string): UnitElement;
|
|
@@ -93,15 +87,22 @@ declare class Unit {
|
|
|
93
87
|
static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
|
|
94
88
|
static snapshot(unit: Unit): Snapshot;
|
|
95
89
|
static context(unit: Unit, key: string, value?: any): any;
|
|
96
|
-
static
|
|
90
|
+
static component2units: MapSet<Function, Unit>;
|
|
97
91
|
static find(component: Function): Unit[];
|
|
98
|
-
static
|
|
92
|
+
static type2units: MapSet<string, Unit>;
|
|
99
93
|
on(type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
100
94
|
off(type?: string, listener?: Function): void;
|
|
101
95
|
emit(type: string, ...args: any[]): void;
|
|
102
96
|
static subon(unit: Unit, target: UnitElement | Window | Document, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
|
|
103
97
|
static suboff(unit: Unit, target: UnitElement | Window | Document | null, type?: string, listener?: Function): void;
|
|
104
98
|
}
|
|
99
|
+
declare class UnitPromise {
|
|
100
|
+
private promise;
|
|
101
|
+
constructor(promise: Promise<any>);
|
|
102
|
+
then(callback: Function): UnitPromise;
|
|
103
|
+
catch(callback: Function): UnitPromise;
|
|
104
|
+
finally(callback: Function): UnitPromise;
|
|
105
|
+
}
|
|
105
106
|
|
|
106
107
|
interface CreateUnit {
|
|
107
108
|
/**
|
|
@@ -223,36 +224,26 @@ declare const xnew$1: CreateUnit & {
|
|
|
223
224
|
* buttons.forEach(btn => btn.finalize())
|
|
224
225
|
*/
|
|
225
226
|
find(component: Function): Unit[];
|
|
226
|
-
/**
|
|
227
|
-
* Appends new components to existing component(s) in the tree
|
|
228
|
-
* @param anchor - Component function or Unit instance to append to
|
|
229
|
-
* @param args - Arguments to pass to xnew for creating child components
|
|
230
|
-
* @throws Error if anchor parameter is invalid
|
|
231
|
-
* @example
|
|
232
|
-
* xnew.append(MyContainer, ChildComponent, { prop: 'value' })
|
|
233
|
-
* xnew.append(unitInstance, AnotherComponent)
|
|
234
|
-
*/
|
|
235
|
-
append(anchor: Unit, ...args: any[]): void;
|
|
236
227
|
/**
|
|
237
228
|
* Executes a callback once after a delay, managed by component lifecycle
|
|
238
|
-
* @param
|
|
239
|
-
* @param
|
|
229
|
+
* @param timeout - Function to execute after Interval
|
|
230
|
+
* @param interval - Interval duration in milliseconds
|
|
240
231
|
* @returns Object with clear() method to cancel the timeout
|
|
241
232
|
* @example
|
|
242
233
|
* const timer = xnew.timeout(() => console.log('Delayed'), 1000)
|
|
243
234
|
* // Cancel if needed: timer.clear()
|
|
244
235
|
*/
|
|
245
|
-
timeout(
|
|
236
|
+
timeout(timeout: Function, interval?: number): any;
|
|
246
237
|
/**
|
|
247
238
|
* Executes a callback repeatedly at specified intervals, managed by component lifecycle
|
|
248
|
-
* @param
|
|
249
|
-
* @param
|
|
239
|
+
* @param timeout - Function to execute at each interval
|
|
240
|
+
* @param interval - Interval duration in milliseconds
|
|
250
241
|
* @returns Object with clear() method to stop the interval
|
|
251
242
|
* @example
|
|
252
243
|
* const timer = xnew.interval(() => console.log('Tick'), 1000)
|
|
253
244
|
* // Stop when needed: timer.clear()
|
|
254
245
|
*/
|
|
255
|
-
interval(
|
|
246
|
+
interval(timeout: Function, interval: number): any;
|
|
256
247
|
/**
|
|
257
248
|
* Creates a transition animation with easing, executing callback with progress values
|
|
258
249
|
* @param callback - Function called with progress value (0.0 to 1.0)
|
|
@@ -260,13 +251,13 @@ declare const xnew$1: CreateUnit & {
|
|
|
260
251
|
* @param easing - Easing function: 'linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out' (default: 'linear')
|
|
261
252
|
* @returns Object with clear() and next() methods for controlling transitions
|
|
262
253
|
* @example
|
|
263
|
-
* xnew.transition(
|
|
264
|
-
* element.style.opacity =
|
|
265
|
-
* }, 500, 'ease-out').
|
|
266
|
-
* element.style.transform = `scale(${
|
|
254
|
+
* xnew.transition(p => {
|
|
255
|
+
* element.style.opacity = p
|
|
256
|
+
* }, 500, 'ease-out').transition(p => {
|
|
257
|
+
* element.style.transform = `scale(${p})`
|
|
267
258
|
* }, 300)
|
|
268
259
|
*/
|
|
269
|
-
transition(
|
|
260
|
+
transition(transition: Function, interval?: number, easing?: string): any;
|
|
270
261
|
/**
|
|
271
262
|
* Creates an event listener manager for a target element with automatic cleanup
|
|
272
263
|
* @param target - Element, Window, or Document to attach listeners to
|
|
@@ -292,11 +283,29 @@ declare const xnew$1: CreateUnit & {
|
|
|
292
283
|
capture(execute: (unit: Unit) => boolean | void): void;
|
|
293
284
|
};
|
|
294
285
|
|
|
295
|
-
declare function
|
|
296
|
-
|
|
297
|
-
|
|
286
|
+
declare function AccordionFrame(frame: Unit, { open, duration, easing }?: {
|
|
287
|
+
open?: boolean;
|
|
288
|
+
duration?: number;
|
|
289
|
+
easing?: string;
|
|
290
|
+
}): {
|
|
291
|
+
toggle(): void;
|
|
292
|
+
open(): void;
|
|
293
|
+
close(): void;
|
|
294
|
+
};
|
|
295
|
+
declare function AccordionHeader(header: Unit, {}?: {}): void;
|
|
296
|
+
declare function AccordionBullet(bullet: Unit, { type }?: {
|
|
297
|
+
type?: string;
|
|
298
|
+
}): void;
|
|
299
|
+
declare function AccordionContent(content: Unit, {}?: {}): {
|
|
300
|
+
transition({ element, rate }: {
|
|
301
|
+
element: HTMLElement;
|
|
302
|
+
rate: number;
|
|
303
|
+
}): void;
|
|
304
|
+
};
|
|
298
305
|
|
|
306
|
+
declare function ResizeEvent(resize: Unit): void;
|
|
299
307
|
declare function KeyboardEvent(unit: Unit): void;
|
|
308
|
+
declare function PointerEvent(unit: Unit): void;
|
|
300
309
|
|
|
301
310
|
declare function Screen(screen: Unit, { width, height, fit }?: {
|
|
302
311
|
width?: number | undefined;
|
|
@@ -348,26 +357,6 @@ declare function TabContent(content: Unit, { key }?: {
|
|
|
348
357
|
}): void;
|
|
349
358
|
};
|
|
350
359
|
|
|
351
|
-
declare function AccordionFrame(frame: Unit, { open, duration, easing }?: {
|
|
352
|
-
open?: boolean;
|
|
353
|
-
duration?: number;
|
|
354
|
-
easing?: string;
|
|
355
|
-
}): {
|
|
356
|
-
toggle(): void;
|
|
357
|
-
open(): void;
|
|
358
|
-
close(): void;
|
|
359
|
-
};
|
|
360
|
-
declare function AccordionHeader(header: Unit, {}?: {}): void;
|
|
361
|
-
declare function AccordionBullet(bullet: Unit, { type }?: {
|
|
362
|
-
type?: string;
|
|
363
|
-
}): void;
|
|
364
|
-
declare function AccordionContent(content: Unit, {}?: {}): {
|
|
365
|
-
transition({ element, rate }: {
|
|
366
|
-
element: HTMLElement;
|
|
367
|
-
rate: number;
|
|
368
|
-
}): void;
|
|
369
|
-
};
|
|
370
|
-
|
|
371
360
|
declare function DragFrame(frame: Unit, { x, y }?: {
|
|
372
361
|
x?: number;
|
|
373
362
|
y?: number;
|
|
@@ -395,7 +384,11 @@ declare function DirectionalPad(self: Unit, { size, diagonal, fill, fillOpacity,
|
|
|
395
384
|
strokeLinejoin?: string;
|
|
396
385
|
}): void;
|
|
397
386
|
|
|
398
|
-
declare
|
|
387
|
+
declare const audio: {
|
|
388
|
+
load(path: string): AudioFile;
|
|
389
|
+
synthesizer(props: SynthProps): Synthesizer;
|
|
390
|
+
volume: number;
|
|
391
|
+
};
|
|
399
392
|
declare class AudioFile {
|
|
400
393
|
buffer?: AudioBuffer;
|
|
401
394
|
promise: Promise<void>;
|
|
@@ -406,8 +399,6 @@ declare class AudioFile {
|
|
|
406
399
|
play(offset?: number, loop?: boolean): void;
|
|
407
400
|
pause(): number | undefined;
|
|
408
401
|
}
|
|
409
|
-
|
|
410
|
-
declare function synthesizer(props: SynthProps): Synthesizer;
|
|
411
402
|
type SynthProps = {
|
|
412
403
|
oscillator: OscillatorOptions;
|
|
413
404
|
amp: AmpOptions;
|
|
@@ -468,12 +459,6 @@ declare const basics: {
|
|
|
468
459
|
AnalogStick: typeof AnalogStick;
|
|
469
460
|
DirectionalPad: typeof DirectionalPad;
|
|
470
461
|
};
|
|
471
|
-
declare const audio: {
|
|
472
|
-
master: GainNode;
|
|
473
|
-
context: AudioContext;
|
|
474
|
-
synthesizer: typeof synthesizer;
|
|
475
|
-
load: typeof load;
|
|
476
|
-
};
|
|
477
462
|
declare namespace xnew {
|
|
478
463
|
type Unit = InstanceType<typeof Unit>;
|
|
479
464
|
}
|