@mulsense/xnew 0.3.6 → 0.4.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 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.3.x/dist/xnew.js"></script>
16
+ <script src="https://unpkg.com/@mulsense/xnew@0.4.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.3.x/dist/xnew.mjs"
25
+ "@mulsense/xnew": "https://unpkg.com/@mulsense/xnew@0.4.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.3.x
40
+ npm install @mulsense/xnew@0.4.x
41
41
  ```
42
42
 
43
43
  Then import it in your JavaScript file:
@@ -21,7 +21,7 @@
21
21
  const root = {};
22
22
  xnew.context('xmatter.root', root);
23
23
  root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
24
- unit.on('logicupdate', () => {
24
+ unit.on('process', () => {
25
25
  Matter.Engine.update(root.engine);
26
26
  });
27
27
  }
@@ -18,7 +18,7 @@ function Root(unit, { engine }) {
18
18
  const root = {};
19
19
  xnew.context('xmatter.root', root);
20
20
  root.engine = engine !== null && engine !== void 0 ? engine : Matter.Engine.create();
21
- unit.on('logicupdate', () => {
21
+ unit.on('process', () => {
22
22
  Matter.Engine.update(root.engine);
23
23
  });
24
24
  }
@@ -19,7 +19,7 @@
19
19
  xnew.promise(RAPIER.init()).then(() => {
20
20
  root.world = new RAPIER.World(gravity);
21
21
  });
22
- self.on('fixedupdate', () => {
22
+ self.on('process', () => {
23
23
  root.world.step();
24
24
  });
25
25
  }
@@ -16,7 +16,7 @@ function Root(self, { gravity }) {
16
16
  xnew.promise(RAPIER.init()).then(() => {
17
17
  root.world = new RAPIER.World(gravity);
18
18
  });
19
- self.on('fixedupdate', () => {
19
+ self.on('process', () => {
20
20
  root.world.step();
21
21
  });
22
22
  }
@@ -19,7 +19,7 @@
19
19
  xnew.promise(RAPIER.init()).then(() => {
20
20
  root.world = new RAPIER.World(gravity);
21
21
  });
22
- self.on('logicupdate', () => {
22
+ self.on('process', () => {
23
23
  root.world.step();
24
24
  });
25
25
  }
@@ -16,7 +16,7 @@ function Root(self, { gravity }) {
16
16
  xnew.promise(RAPIER.init()).then(() => {
17
17
  root.world = new RAPIER.World(gravity);
18
18
  });
19
- self.on('logicupdate', () => {
19
+ self.on('process', () => {
20
20
  root.world.step();
21
21
  });
22
22
  }
package/dist/xnew.d.ts CHANGED
@@ -27,6 +27,35 @@ declare class Ticker {
27
27
  }
28
28
 
29
29
  type UnitElement = HTMLElement | SVGElement;
30
+
31
+ interface EventProps {
32
+ element: UnitElement;
33
+ type: string;
34
+ listener: Function;
35
+ options?: boolean | AddEventListenerOptions;
36
+ }
37
+ declare class EventManager {
38
+ private map;
39
+ add(props: EventProps): void;
40
+ remove({ type, listener }: {
41
+ type: string;
42
+ listener: Function;
43
+ }): void;
44
+ private basic;
45
+ private resize;
46
+ private click;
47
+ private click_outside;
48
+ private pointer;
49
+ private mouse;
50
+ private touch;
51
+ private pointer_outside;
52
+ private wheel;
53
+ private drag;
54
+ private gesture;
55
+ private key;
56
+ private key_arrow;
57
+ }
58
+
30
59
  interface Context {
31
60
  stack: Context | null;
32
61
  key?: string;
@@ -37,7 +66,7 @@ interface Snapshot {
37
66
  context: Context;
38
67
  element: UnitElement;
39
68
  }
40
- interface UnitInternal {
69
+ interface Internal {
41
70
  parent: Unit | null;
42
71
  target: Object | null;
43
72
  props?: Object;
@@ -62,10 +91,11 @@ interface UnitInternal {
62
91
  }>;
63
92
  defines: Record<string, any>;
64
93
  systems: Record<string, Function[]>;
94
+ eventManager: EventManager;
65
95
  }
66
96
  declare class Unit {
67
97
  [key: string]: any;
68
- _: UnitInternal;
98
+ _: Internal;
69
99
  constructor(parent: Unit | null, ...args: any[]);
70
100
  get element(): UnitElement;
71
101
  start(): void;
@@ -81,7 +111,7 @@ declare class Unit {
81
111
  static start(unit: Unit): void;
82
112
  static stop(unit: Unit): void;
83
113
  static update(unit: Unit): void;
84
- static logicupdate(unit: Unit): void;
114
+ static process(unit: Unit): void;
85
115
  static root: Unit;
86
116
  static current: Unit;
87
117
  static ticker: Ticker;
@@ -275,12 +305,7 @@ declare function AccordionContent(content: Unit, {}?: {}): {
275
305
  }): void;
276
306
  };
277
307
 
278
- declare function ResizeEvent(resize: Unit): void;
279
- declare function DirectEvent(unit: Unit): void;
280
- declare function KeyboardEvent(keyboard: Unit): void;
281
- declare function PointerEvent(unit: Unit): void;
282
-
283
- declare function Screen(screen: Unit, { width, height, fit }?: {
308
+ declare function Screen(unit: Unit, { width, height, fit }?: {
284
309
  width?: number | undefined;
285
310
  height?: number | undefined;
286
311
  fit?: string | undefined;
@@ -332,7 +357,7 @@ declare function DragFrame(frame: Unit, { x, y }?: {
332
357
  x?: number;
333
358
  y?: number;
334
359
  }): void;
335
- declare function DragTarget(target: Unit, {}?: {}): void;
360
+ declare function DragTarget(unit: Unit, {}?: {}): void;
336
361
 
337
362
  declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
338
363
  stroke?: string;
@@ -359,8 +384,6 @@ declare function TextStream(unit: Unit, { text, speed, fade }?: {
359
384
  fade?: number;
360
385
  }): void;
361
386
 
362
- declare function VolumeController(unit: Unit, {}?: {}): void;
363
-
364
387
  declare const icons: {
365
388
  AcademicCap(unit: Unit, props: Object): void;
366
389
  AdjustmentsHorizontal(unit: Unit, props: Object): void;
@@ -730,10 +753,6 @@ declare class Synthesizer {
730
753
 
731
754
  declare const basics: {
732
755
  Screen: typeof Screen;
733
- PointerEvent: typeof PointerEvent;
734
- DirectEvent: typeof DirectEvent;
735
- ResizeEvent: typeof ResizeEvent;
736
- KeyboardEvent: typeof KeyboardEvent;
737
756
  ModalFrame: typeof ModalFrame;
738
757
  ModalContent: typeof ModalContent;
739
758
  AccordionFrame: typeof AccordionFrame;
@@ -748,7 +767,6 @@ declare const basics: {
748
767
  DragTarget: typeof DragTarget;
749
768
  AnalogStick: typeof AnalogStick;
750
769
  DirectionalPad: typeof DirectionalPad;
751
- VolumeController: typeof VolumeController;
752
770
  };
753
771
 
754
772
  declare const audio: {