@mulsense/xnew 0.1.9 → 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 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,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
- source: AudioBufferSourceNode;
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 { xnew } from '../core/xnew';
2
- export declare function ResizeEvent(self: any): void;
3
- export declare function UserEvent(self: xnew.Unit): void;
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 TouchDPad(self: xnew.Unit, { size, fill, fillOpacity, stroke, strokeOpacity, strokeWidth, strokeLinejoin }?: {
12
- size?: number | undefined;
13
- fill?: string | undefined;
14
- fillOpacity?: number | undefined;
15
- stroke?: string | undefined;
16
- strokeOpacity?: number | undefined;
17
- strokeWidth?: number | undefined;
18
- strokeLinejoin?: string | undefined;
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 delay;
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(timeout: Function, transition: Function | null, delay: number, loop?: boolean);
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,13 +33,6 @@ 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;
@@ -77,4 +70,41 @@ export declare class Unit {
77
70
  static subon(unit: Unit, target: UnitElement | Window | Document, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
78
71
  static suboff(unit: Unit, target: UnitElement | Window | Document | null, type?: string, listener?: Function): void;
79
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
+ }
80
110
  export {};
@@ -121,24 +121,24 @@ export declare const xnew: CreateUnit & {
121
121
  find(component: Function): Unit[];
122
122
  /**
123
123
  * Executes a callback once after a delay, managed by component lifecycle
124
- * @param callback - Function to execute after delay
125
- * @param delay - Delay in milliseconds
124
+ * @param timeout - Function to execute after Interval
125
+ * @param interval - Interval duration in milliseconds
126
126
  * @returns Object with clear() method to cancel the timeout
127
127
  * @example
128
128
  * const timer = xnew.timeout(() => console.log('Delayed'), 1000)
129
129
  * // Cancel if needed: timer.clear()
130
130
  */
131
- timeout(callback: Function, delay?: number): any;
131
+ timeout(timeout: Function, interval?: number): any;
132
132
  /**
133
133
  * Executes a callback repeatedly at specified intervals, managed by component lifecycle
134
- * @param callback - Function to execute at each interval
135
- * @param delay - Interval duration in milliseconds
134
+ * @param timeout - Function to execute at each interval
135
+ * @param interval - Interval duration in milliseconds
136
136
  * @returns Object with clear() method to stop the interval
137
137
  * @example
138
138
  * const timer = xnew.interval(() => console.log('Tick'), 1000)
139
139
  * // Stop when needed: timer.clear()
140
140
  */
141
- interval(callback: Function, delay: number): any;
141
+ interval(timeout: Function, interval: number): any;
142
142
  /**
143
143
  * Creates a transition animation with easing, executing callback with progress values
144
144
  * @param callback - Function called with progress value (0.0 to 1.0)
@@ -146,13 +146,13 @@ export declare const xnew: CreateUnit & {
146
146
  * @param easing - Easing function: 'linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out' (default: 'linear')
147
147
  * @returns Object with clear() and next() methods for controlling transitions
148
148
  * @example
149
- * xnew.transition(progress => {
150
- * element.style.opacity = progress
151
- * }, 500, 'ease-out').next(progress => {
152
- * element.style.transform = `scale(${progress})`
149
+ * xnew.transition(p => {
150
+ * element.style.opacity = p
151
+ * }, 500, 'ease-out').transition(p => {
152
+ * element.style.transform = `scale(${p})`
153
153
  * }, 300)
154
154
  */
155
- transition(callback: Function, interval: number, easing?: string): any;
155
+ transition(transition: Function, interval?: number, easing?: string): any;
156
156
  /**
157
157
  * Creates an event listener manager for a target element with automatic cleanup
158
158
  * @param target - Element, Window, or Document to attach listeners to
@@ -1,13 +1,11 @@
1
1
  import { xnew as base } from './core/xnew';
2
2
  import { Unit } from './core/unit';
3
- import { ResizeEvent } from './basics/ResizeEvent';
4
- import { PointerEvent } from './basics/PointerEvent';
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
11
  import { audio } from './audio/audio';
package/dist/xnew.d.ts CHANGED
@@ -59,13 +59,6 @@ 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;
@@ -103,6 +96,13 @@ declare class Unit {
103
96
  static subon(unit: Unit, target: UnitElement | Window | Document, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
104
97
  static suboff(unit: Unit, target: UnitElement | Window | Document | null, type?: string, listener?: Function): void;
105
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
+ }
106
106
 
107
107
  interface CreateUnit {
108
108
  /**
@@ -226,24 +226,24 @@ declare const xnew$1: CreateUnit & {
226
226
  find(component: Function): Unit[];
227
227
  /**
228
228
  * Executes a callback once after a delay, managed by component lifecycle
229
- * @param callback - Function to execute after delay
230
- * @param delay - Delay in milliseconds
229
+ * @param timeout - Function to execute after Interval
230
+ * @param interval - Interval duration in milliseconds
231
231
  * @returns Object with clear() method to cancel the timeout
232
232
  * @example
233
233
  * const timer = xnew.timeout(() => console.log('Delayed'), 1000)
234
234
  * // Cancel if needed: timer.clear()
235
235
  */
236
- timeout(callback: Function, delay?: number): any;
236
+ timeout(timeout: Function, interval?: number): any;
237
237
  /**
238
238
  * Executes a callback repeatedly at specified intervals, managed by component lifecycle
239
- * @param callback - Function to execute at each interval
240
- * @param delay - Interval duration in milliseconds
239
+ * @param timeout - Function to execute at each interval
240
+ * @param interval - Interval duration in milliseconds
241
241
  * @returns Object with clear() method to stop the interval
242
242
  * @example
243
243
  * const timer = xnew.interval(() => console.log('Tick'), 1000)
244
244
  * // Stop when needed: timer.clear()
245
245
  */
246
- interval(callback: Function, delay: number): any;
246
+ interval(timeout: Function, interval: number): any;
247
247
  /**
248
248
  * Creates a transition animation with easing, executing callback with progress values
249
249
  * @param callback - Function called with progress value (0.0 to 1.0)
@@ -251,13 +251,13 @@ declare const xnew$1: CreateUnit & {
251
251
  * @param easing - Easing function: 'linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out' (default: 'linear')
252
252
  * @returns Object with clear() and next() methods for controlling transitions
253
253
  * @example
254
- * xnew.transition(progress => {
255
- * element.style.opacity = progress
256
- * }, 500, 'ease-out').next(progress => {
257
- * element.style.transform = `scale(${progress})`
254
+ * xnew.transition(p => {
255
+ * element.style.opacity = p
256
+ * }, 500, 'ease-out').transition(p => {
257
+ * element.style.transform = `scale(${p})`
258
258
  * }, 300)
259
259
  */
260
- transition(callback: Function, interval: number, easing?: string): any;
260
+ transition(transition: Function, interval?: number, easing?: string): any;
261
261
  /**
262
262
  * Creates an event listener manager for a target element with automatic cleanup
263
263
  * @param target - Element, Window, or Document to attach listeners to
@@ -283,11 +283,29 @@ declare const xnew$1: CreateUnit & {
283
283
  capture(execute: (unit: Unit) => boolean | void): void;
284
284
  };
285
285
 
286
- declare function ResizeEvent(resize: Unit): void;
287
-
288
- declare function PointerEvent(unit: Unit): void;
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
+ };
289
305
 
306
+ declare function ResizeEvent(resize: Unit): void;
290
307
  declare function KeyboardEvent(unit: Unit): void;
308
+ declare function PointerEvent(unit: Unit): void;
291
309
 
292
310
  declare function Screen(screen: Unit, { width, height, fit }?: {
293
311
  width?: number | undefined;
@@ -339,26 +357,6 @@ declare function TabContent(content: Unit, { key }?: {
339
357
  }): void;
340
358
  };
341
359
 
342
- declare function AccordionFrame(frame: Unit, { open, duration, easing }?: {
343
- open?: boolean;
344
- duration?: number;
345
- easing?: string;
346
- }): {
347
- toggle(): void;
348
- open(): void;
349
- close(): void;
350
- };
351
- declare function AccordionHeader(header: Unit, {}?: {}): void;
352
- declare function AccordionBullet(bullet: Unit, { type }?: {
353
- type?: string;
354
- }): void;
355
- declare function AccordionContent(content: Unit, {}?: {}): {
356
- transition({ element, rate }: {
357
- element: HTMLElement;
358
- rate: number;
359
- }): void;
360
- };
361
-
362
360
  declare function DragFrame(frame: Unit, { x, y }?: {
363
361
  x?: number;
364
362
  y?: number;