@mulsense/xnew 0.5.2 → 0.5.3

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/dist/xnew.d.ts CHANGED
@@ -20,7 +20,7 @@ declare class MapMap<Key1, Key2, Value> extends Map<Key1, Map<Key2, Value>> {
20
20
  delete(key1: Key1, key2: Key2): boolean;
21
21
  }
22
22
 
23
- declare class EventManager {
23
+ declare class Eventor {
24
24
  private map;
25
25
  add(element: HTMLElement | SVGElement, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
26
26
  remove(type: string, listener: Function): void;
@@ -40,6 +40,14 @@ declare class EventManager {
40
40
  }
41
41
 
42
42
  type UnitElement = HTMLElement | SVGElement;
43
+ declare class UnitPromise {
44
+ promise: Promise<any>;
45
+ component: Function | null;
46
+ constructor(promise: Promise<any>, component: Function | null);
47
+ then(callback: Function): UnitPromise;
48
+ catch(callback: Function): UnitPromise;
49
+ finally(callback: Function): UnitPromise;
50
+ }
43
51
  interface Context {
44
52
  stack: Context | null;
45
53
  key?: string;
@@ -55,9 +63,6 @@ interface Internal {
55
63
  parent: Unit | null;
56
64
  target: Object | null;
57
65
  props?: Object;
58
- config: {
59
- protect: boolean;
60
- };
61
66
  baseElement: UnitElement;
62
67
  baseContext: Context;
63
68
  baseComponent: Function;
@@ -67,6 +72,7 @@ interface Internal {
67
72
  anchor: UnitElement | null;
68
73
  state: string;
69
74
  tostart: boolean;
75
+ protected: boolean;
70
76
  ancestors: Unit[];
71
77
  children: Unit[];
72
78
  promises: UnitPromise[];
@@ -82,12 +88,12 @@ interface Internal {
82
88
  listener: Function;
83
89
  execute: Function;
84
90
  }[]>;
85
- eventManager: EventManager;
91
+ eventor: Eventor;
86
92
  }
87
93
  declare class Unit {
88
94
  [key: string]: any;
89
95
  _: Internal;
90
- constructor(parent: Unit | null, target: UnitElement | string | null, component?: Function | string, props?: Object, config?: any);
96
+ constructor(parent: Unit | null, target: UnitElement | string | null, component?: Function | string | number, props?: Object);
91
97
  get element(): UnitElement;
92
98
  start(): void;
93
99
  stop(): void;
@@ -95,7 +101,7 @@ declare class Unit {
95
101
  reboot(): void;
96
102
  static initialize(unit: Unit, anchor: UnitElement | null): void;
97
103
  static finalize(unit: Unit): void;
98
- static nest(unit: Unit, htmlString: string, textContent?: string): UnitElement;
104
+ static nest(unit: Unit, tag: string, textContent?: string | number): UnitElement;
99
105
  static currentComponent: Function;
100
106
  static extend(unit: Unit, component: Function, props?: Object): {
101
107
  [key: string]: any;
@@ -107,7 +113,6 @@ declare class Unit {
107
113
  static rootUnit: Unit;
108
114
  static currentUnit: Unit;
109
115
  static reset(): void;
110
- static wrap(unit: Unit, listener: Function): (...args: any[]) => any;
111
116
  static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
112
117
  static snapshot(unit: Unit): Snapshot;
113
118
  static context(unit: Unit, key: string, value?: any): any;
@@ -120,14 +125,6 @@ declare class Unit {
120
125
  static off(unit: Unit, type: string, listener?: Function): void;
121
126
  static emit(type: string, ...args: any[]): void;
122
127
  }
123
- declare class UnitPromise {
124
- promise: Promise<any>;
125
- component: Function | null;
126
- constructor(promise: Promise<any>, component: Function | null);
127
- then(callback: Function): UnitPromise;
128
- catch(callback: Function): UnitPromise;
129
- finally(callback: Function): UnitPromise;
130
- }
131
128
 
132
129
  interface CreateUnit {
133
130
  /**
@@ -157,29 +154,26 @@ declare function Accordion(unit: Unit, { open, duration, easing }?: {
157
154
  duration?: number;
158
155
  easing?: string;
159
156
  }): {
160
- state: number;
161
157
  toggle(): void;
162
158
  open(): void;
163
159
  close(): void;
164
160
  };
165
-
166
- declare function Screen(unit: Unit, { width, height, fit }?: {
167
- width?: number | undefined;
168
- height?: number | undefined;
169
- fit?: string | undefined;
170
- }): {
171
- readonly canvas: UnitElement;
172
- resize(width: number, height: number): void;
173
- };
174
-
175
161
  declare function Modal(unit: Unit, { duration, easing }?: {
176
162
  duration?: number;
177
163
  easing?: string;
178
164
  }): {
179
- state: number;
180
165
  close(): void;
181
166
  };
182
167
 
168
+ type ScreenFit = 'contain' | 'cover' | 'fill' | 'resize';
169
+ declare function Screen(unit: Unit, { width, height, fit }?: {
170
+ width?: number;
171
+ height?: number;
172
+ fit?: ScreenFit;
173
+ }): {
174
+ readonly canvas: UnitElement;
175
+ };
176
+
183
177
  declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
184
178
  stroke?: string;
185
179
  strokeOpacity?: number;
@@ -189,7 +183,7 @@ declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, s
189
183
  fill?: string;
190
184
  fillOpacity?: number;
191
185
  }): void;
192
- declare function DirectionalPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
186
+ declare function DPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
193
187
  diagonal?: boolean;
194
188
  stroke?: string;
195
189
  strokeOpacity?: number;
@@ -243,7 +237,7 @@ declare namespace xnew {
243
237
  type Unit = InstanceType<typeof Unit>;
244
238
  }
245
239
  declare const xnew: CreateUnit & {
246
- nest(htmlString: string, textContent?: string): HTMLElement | SVGElement;
240
+ nest(tag: string, textContent?: string | number): HTMLElement | SVGElement;
247
241
  extend(component: Function, props?: Object): {
248
242
  [key: string]: any;
249
243
  };
@@ -258,14 +252,14 @@ declare const xnew: CreateUnit & {
258
252
  timeout(timeout: Function, duration?: number): any;
259
253
  interval(timeout: Function, duration: number, iterations?: number): any;
260
254
  transition(transition: Function, duration?: number, easing?: string): any;
261
- protect(...args: any[]): Unit;
255
+ protect(): void;
262
256
  } & {
263
257
  basics: {
264
258
  Screen: typeof Screen;
265
259
  Modal: typeof Modal;
266
260
  Accordion: typeof Accordion;
267
261
  AnalogStick: typeof AnalogStick;
268
- DirectionalPad: typeof DirectionalPad;
262
+ DPad: typeof DPad;
269
263
  };
270
264
  audio: {
271
265
  load(path: string): UnitPromise;