@mulsense/xnew 0.6.4 → 0.6.6

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.
@@ -6,7 +6,7 @@
6
6
 
7
7
  var xmatter = {
8
8
  initialize({} = {}) {
9
- xnew(Root, {});
9
+ xnew.promise(xnew(Root, {}));
10
10
  },
11
11
  get engine() {
12
12
  var _a;
@@ -3,7 +3,7 @@ import Matter from 'matter-js';
3
3
 
4
4
  var xmatter = {
5
5
  initialize({} = {}) {
6
- xnew(Root, {});
6
+ xnew.promise(xnew(Root, {}));
7
7
  },
8
8
  get engine() {
9
9
  var _a;
@@ -25,7 +25,7 @@
25
25
 
26
26
  var xpixi = {
27
27
  initialize({ canvas = null } = {}) {
28
- xnew(Root, { canvas });
28
+ xnew.promise(xnew(Root, { canvas }));
29
29
  },
30
30
  nest(object) {
31
31
  xnew(Nest, { object });
@@ -49,7 +49,9 @@
49
49
  xnew.promise(PIXI__namespace.autoDetectRenderer({
50
50
  width: canvas.width, height: canvas.height, view: canvas,
51
51
  antialias: true, backgroundAlpha: 0,
52
- })).then((value) => renderer = value);
52
+ })).then((value) => {
53
+ renderer = value;
54
+ });
53
55
  let scene = new PIXI__namespace.Container();
54
56
  return {
55
57
  get renderer() { return renderer; },
@@ -3,7 +3,7 @@ import * as PIXI from 'pixi.js';
3
3
 
4
4
  var xpixi = {
5
5
  initialize({ canvas = null } = {}) {
6
- xnew(Root, { canvas });
6
+ xnew.promise(xnew(Root, { canvas }));
7
7
  },
8
8
  nest(object) {
9
9
  xnew(Nest, { object });
@@ -27,7 +27,9 @@ function Root(unit, { canvas }) {
27
27
  xnew.promise(PIXI.autoDetectRenderer({
28
28
  width: canvas.width, height: canvas.height, view: canvas,
29
29
  antialias: true, backgroundAlpha: 0,
30
- })).then((value) => renderer = value);
30
+ })).then((value) => {
31
+ renderer = value;
32
+ });
31
33
  let scene = new PIXI.Container();
32
34
  return {
33
35
  get renderer() { return renderer; },
@@ -6,7 +6,7 @@
6
6
 
7
7
  var xrapier2d = {
8
8
  initialize({ gravity = { x: 0.0, y: -9.81 } } = {}) {
9
- xnew(Root, { gravity });
9
+ xnew.promise(xnew(Root, { gravity }));
10
10
  },
11
11
  get world() {
12
12
  var _a;
@@ -3,7 +3,7 @@ import RAPIER from '@dimforge/rapier2d-compat';
3
3
 
4
4
  var xrapier2d = {
5
5
  initialize({ gravity = { x: 0.0, y: -9.81 } } = {}) {
6
- xnew(Root, { gravity });
6
+ xnew.promise(xnew(Root, { gravity }));
7
7
  },
8
8
  get world() {
9
9
  var _a;
@@ -6,7 +6,7 @@
6
6
 
7
7
  var xrapier3d = {
8
8
  initialize({ gravity = { x: 0.0, y: -9.81, z: 0.0 } } = {}) {
9
- xnew(Root, { gravity });
9
+ xnew.promise(xnew(Root, { gravity }));
10
10
  },
11
11
  get world() {
12
12
  var _a;
@@ -3,7 +3,7 @@ import RAPIER from '@dimforge/rapier3d-compat';
3
3
 
4
4
  var xrapier3d = {
5
5
  initialize({ gravity = { x: 0.0, y: -9.81, z: 0.0 } } = {}) {
6
- xnew(Root, { gravity });
6
+ xnew.promise(xnew(Root, { gravity }));
7
7
  },
8
8
  get world() {
9
9
  var _a;
@@ -25,7 +25,7 @@
25
25
 
26
26
  var xthree = {
27
27
  initialize({ canvas = null, camera = null } = {}) {
28
- xnew(Root, { canvas, camera });
28
+ xnew.promise(xnew(Root, { canvas, camera }));
29
29
  },
30
30
  nest(object) {
31
31
  xnew(Nest, { object });
@@ -3,7 +3,7 @@ import * as THREE from 'three';
3
3
 
4
4
  var xthree = {
5
5
  initialize({ canvas = null, camera = null } = {}) {
6
- xnew(Root, { canvas, camera });
6
+ xnew.promise(xnew(Root, { canvas, camera }));
7
7
  },
8
8
  nest(object) {
9
9
  xnew(Nest, { object });
package/dist/xnew.d.ts CHANGED
@@ -44,28 +44,8 @@ declare class Eventor {
44
44
  }
45
45
 
46
46
  type UnitElement = HTMLElement | SVGElement;
47
- declare class UnitPromise {
48
- promise: Promise<any>;
49
- Component: Function | null;
50
- constructor(promise: Promise<any>, Component: Function | null);
51
- then(callback: Function): UnitPromise;
52
- catch(callback: Function): UnitPromise;
53
- finally(callback: Function): UnitPromise;
54
- private wrap;
55
- }
56
- declare class UnitTimer {
57
- private unit;
58
- private stack;
59
- clear(): void;
60
- timeout(callback: Function, duration?: number): UnitTimer;
61
- interval(callback: Function, duration?: number, iterations?: number): UnitTimer;
62
- transition(transition: Function, duration?: number, easing?: string): UnitTimer;
63
- private static execute;
64
- private static next;
65
- private static Component;
66
- }
67
47
  interface Context {
68
- stack: Context | null;
48
+ previous: Context | null;
69
49
  key?: any;
70
50
  value?: any;
71
51
  }
@@ -73,33 +53,28 @@ interface Snapshot {
73
53
  unit: Unit;
74
54
  context: Context;
75
55
  element: UnitElement;
76
- component: Function | null;
56
+ Component: Function | null;
77
57
  }
78
58
  interface Internal {
79
59
  parent: Unit | null;
80
- target: Object | null;
81
- props?: Object;
82
- baseElement: UnitElement;
83
- baseContext: Context;
84
- baseComponent: Function;
85
- currentElement: UnitElement;
86
- currentContext: Context;
87
- currentComponent: Function | null;
88
- anchor: UnitElement | null;
89
60
  state: string;
90
61
  tostart: boolean;
91
62
  protected: boolean;
63
+ currentElement: UnitElement;
64
+ currentContext: Context;
65
+ currentComponent: Function | null;
92
66
  ancestors: Unit[];
93
67
  children: Unit[];
94
68
  promises: UnitPromise[];
69
+ results: Record<string, any>;
95
70
  nestElements: {
96
71
  element: UnitElement;
97
72
  owned: boolean;
98
73
  }[];
99
- components: Function[];
74
+ Components: Function[];
100
75
  listeners: MapMap<string, Function, {
101
76
  element: UnitElement;
102
- component: Function | null;
77
+ Component: Function | null;
103
78
  execute: Function;
104
79
  }>;
105
80
  defines: Record<string, any>;
@@ -112,13 +87,11 @@ interface Internal {
112
87
  declare class Unit {
113
88
  [key: string]: any;
114
89
  _: Internal;
115
- constructor(parent: Unit | null, target: UnitElement | string | null, component?: Function | string | number, props?: Object);
90
+ constructor(parent: Unit | null, target: UnitElement | string | null, Component?: Function | string | number, props?: Object);
116
91
  get element(): UnitElement;
117
92
  start(): void;
118
93
  stop(): void;
119
94
  finalize(): void;
120
- reboot(): void;
121
- static initialize(unit: Unit, anchor: UnitElement | null): void;
122
95
  static finalize(unit: Unit): void;
123
96
  static nest(unit: Unit, target: UnitElement | string, textContent?: string | number): UnitElement;
124
97
  static currentComponent: Function;
@@ -134,7 +107,9 @@ declare class Unit {
134
107
  static reset(): void;
135
108
  static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
136
109
  static snapshot(unit: Unit): Snapshot;
137
- static context(unit: Unit, key: any, value?: any): any;
110
+ static unit2Contexts: MapSet<Unit, Context>;
111
+ static addContext(unit: Unit, orner: Unit, key: any, value?: Unit): void;
112
+ static getContext(unit: Unit, key: any): any;
138
113
  static component2units: MapSet<Function, Unit>;
139
114
  static find(Component: Function): Unit[];
140
115
  static type2units: MapSet<string, Unit>;
@@ -144,6 +119,26 @@ declare class Unit {
144
119
  static off(unit: Unit, type: string, listener?: Function): void;
145
120
  static emit(type: string, props?: object): void;
146
121
  }
122
+ declare class UnitPromise {
123
+ promise: Promise<any>;
124
+ Component: Function | null;
125
+ constructor(promise: Promise<any>, Component: Function | null);
126
+ then(callback: Function): UnitPromise;
127
+ catch(callback: Function): UnitPromise;
128
+ finally(callback: Function): UnitPromise;
129
+ private wrap;
130
+ }
131
+ declare class UnitTimer {
132
+ private unit;
133
+ private queue;
134
+ clear(): void;
135
+ timeout(callback: Function, duration?: number): UnitTimer;
136
+ interval(callback: Function, duration?: number, iterations?: number): UnitTimer;
137
+ transition(transition: Function, duration?: number, easing?: string): UnitTimer;
138
+ private static execute;
139
+ private static next;
140
+ private static Component;
141
+ }
147
142
 
148
143
  interface CreateUnit {
149
144
  /**
@@ -216,15 +211,19 @@ interface PanelOptions {
216
211
  declare function Panel(unit: Unit, { name, open, params }: PanelOptions): {
217
212
  group({ name, open, params }: PanelOptions, inner: Function): Unit;
218
213
  button(key: string): Unit;
219
- select(key: string, { options }?: {
220
- options?: string[];
214
+ select(key: string, { value, items }?: {
215
+ value?: string;
216
+ items?: string[];
221
217
  }): Unit;
222
- range(key: string, options?: {
218
+ range(key: string, { value, min, max, step }?: {
219
+ value?: number;
223
220
  min?: number;
224
221
  max?: number;
225
222
  step?: number;
226
223
  }): Unit;
227
- checkbox(key: string): Unit;
224
+ checkbox(key: string, { value }?: {
225
+ value?: boolean;
226
+ }): Unit;
228
227
  separator(): void;
229
228
  };
230
229
 
@@ -278,15 +277,17 @@ declare const xnew: CreateUnit & {
278
277
  [key: string]: any;
279
278
  };
280
279
  context(component: Function): any;
281
- promise(promise: Promise<any> | Unit): UnitPromise;
280
+ promise(promise: Function | Promise<any> | Unit): UnitPromise;
282
281
  then(callback: Function): UnitPromise;
283
282
  catch(callback: Function): UnitPromise;
283
+ resolve(value?: any): void;
284
+ reject(reason?: any): void;
284
285
  finally(callback: Function): UnitPromise;
285
286
  scope(callback: any): any;
286
287
  find(component: Function): Unit[];
287
288
  emit(type: string, ...args: any[]): void;
288
- timeout(timeout: Function, duration?: number): UnitTimer;
289
- interval(interval: Function, duration: number, iterations?: number): UnitTimer;
289
+ timeout(callback: Function, duration?: number): UnitTimer;
290
+ interval(callback: Function, duration: number, iterations?: number): UnitTimer;
290
291
  transition(transition: Function, duration?: number, easing?: string): UnitTimer;
291
292
  protect(): void;
292
293
  } & {