@mulsense/xnew 0.5.2 → 0.5.4

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,15 @@ 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
+ interface TimerOptions {
24
+ transition?: Function;
25
+ timeout?: Function;
26
+ duration: number;
27
+ iterations: number;
28
+ easing?: string;
29
+ }
30
+
31
+ declare class Eventor {
24
32
  private map;
25
33
  add(element: HTMLElement | SVGElement, type: string, listener: Function, options?: boolean | AddEventListenerOptions): void;
26
34
  remove(type: string, listener: Function): void;
@@ -40,6 +48,29 @@ declare class EventManager {
40
48
  }
41
49
 
42
50
  type UnitElement = HTMLElement | SVGElement;
51
+ declare class UnitPromise {
52
+ promise: Promise<any>;
53
+ component: Function | null;
54
+ constructor(promise: Promise<any>, component: Function | null);
55
+ then(callback: Function): UnitPromise;
56
+ catch(callback: Function): UnitPromise;
57
+ finally(callback: Function): UnitPromise;
58
+ }
59
+ declare class UnitTimer {
60
+ private unit;
61
+ private stack;
62
+ constructor(options: TimerOptions);
63
+ clear(): void;
64
+ timeout(timeout: Function, duration?: number): this;
65
+ iteration(timeout: Function, duration?: number, iterations?: number): this;
66
+ transition(transition: Function, duration?: number, easing?: string): this;
67
+ static execute(timer: UnitTimer, options: TimerOptions): void;
68
+ static next(timer: UnitTimer): void;
69
+ static Component(unit: Unit, { options, snapshot }: {
70
+ options: TimerOptions;
71
+ snapshot: Snapshot;
72
+ }): void;
73
+ }
43
74
  interface Context {
44
75
  stack: Context | null;
45
76
  key?: string;
@@ -55,9 +86,6 @@ interface Internal {
55
86
  parent: Unit | null;
56
87
  target: Object | null;
57
88
  props?: Object;
58
- config: {
59
- protect: boolean;
60
- };
61
89
  baseElement: UnitElement;
62
90
  baseContext: Context;
63
91
  baseComponent: Function;
@@ -67,11 +95,15 @@ interface Internal {
67
95
  anchor: UnitElement | null;
68
96
  state: string;
69
97
  tostart: boolean;
98
+ protected: boolean;
70
99
  ancestors: Unit[];
71
100
  children: Unit[];
72
101
  promises: UnitPromise[];
73
102
  elements: UnitElement[];
74
- components: Function[];
103
+ extends: {
104
+ component: Function;
105
+ defines: Record<string, any>;
106
+ }[];
75
107
  listeners: MapMap<string, Function, {
76
108
  element: UnitElement;
77
109
  component: Function | null;
@@ -82,12 +114,12 @@ interface Internal {
82
114
  listener: Function;
83
115
  execute: Function;
84
116
  }[]>;
85
- eventManager: EventManager;
117
+ eventor: Eventor;
86
118
  }
87
119
  declare class Unit {
88
120
  [key: string]: any;
89
121
  _: Internal;
90
- constructor(parent: Unit | null, target: UnitElement | string | null, component?: Function | string, props?: Object, config?: any);
122
+ constructor(parent: Unit | null, target: UnitElement | string | null, component?: Function | string | number, props?: Object);
91
123
  get element(): UnitElement;
92
124
  start(): void;
93
125
  stop(): void;
@@ -95,7 +127,7 @@ declare class Unit {
95
127
  reboot(): void;
96
128
  static initialize(unit: Unit, anchor: UnitElement | null): void;
97
129
  static finalize(unit: Unit): void;
98
- static nest(unit: Unit, htmlString: string, textContent?: string): UnitElement;
130
+ static nest(unit: Unit, tag: string, textContent?: string | number): UnitElement;
99
131
  static currentComponent: Function;
100
132
  static extend(unit: Unit, component: Function, props?: Object): {
101
133
  [key: string]: any;
@@ -107,7 +139,6 @@ declare class Unit {
107
139
  static rootUnit: Unit;
108
140
  static currentUnit: Unit;
109
141
  static reset(): void;
110
- static wrap(unit: Unit, listener: Function): (...args: any[]) => any;
111
142
  static scope(snapshot: Snapshot, func: Function, ...args: any[]): any;
112
143
  static snapshot(unit: Unit): Snapshot;
113
144
  static context(unit: Unit, key: string, value?: any): any;
@@ -120,14 +151,6 @@ declare class Unit {
120
151
  static off(unit: Unit, type: string, listener?: Function): void;
121
152
  static emit(type: string, ...args: any[]): void;
122
153
  }
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
154
 
132
155
  interface CreateUnit {
133
156
  /**
@@ -152,32 +175,21 @@ interface CreateUnit {
152
175
  (target: HTMLElement | SVGElement | string, Component?: Function | string, props?: Object): Unit;
153
176
  }
154
177
 
155
- declare function Accordion(unit: Unit, { open, duration, easing }?: {
156
- open?: boolean;
157
- duration?: number;
158
- easing?: string;
178
+ declare function OpenAndClose(unit: Unit, { state: initialState }?: {
179
+ state?: number;
159
180
  }): {
160
- state: number;
161
- toggle(): void;
162
- open(): void;
163
- close(): void;
181
+ toggle(duration?: number, easing?: string): void;
182
+ open(duration?: number, easing?: string): void;
183
+ close(duration?: number, easing?: string): void;
164
184
  };
165
185
 
186
+ type ScreenFit = 'contain' | 'cover' | 'fill' | 'resize';
166
187
  declare function Screen(unit: Unit, { width, height, fit }?: {
167
- width?: number | undefined;
168
- height?: number | undefined;
169
- fit?: string | undefined;
188
+ width?: number;
189
+ height?: number;
190
+ fit?: ScreenFit;
170
191
  }): {
171
192
  readonly canvas: UnitElement;
172
- resize(width: number, height: number): void;
173
- };
174
-
175
- declare function Modal(unit: Unit, { duration, easing }?: {
176
- duration?: number;
177
- easing?: string;
178
- }): {
179
- state: number;
180
- close(): void;
181
193
  };
182
194
 
183
195
  declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
@@ -189,7 +201,7 @@ declare function AnalogStick(unit: Unit, { stroke, strokeOpacity, strokeWidth, s
189
201
  fill?: string;
190
202
  fillOpacity?: number;
191
203
  }): void;
192
- declare function DirectionalPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
204
+ declare function DPad(unit: Unit, { diagonal, stroke, strokeOpacity, strokeWidth, strokeLinejoin, fill, fillOpacity }?: {
193
205
  diagonal?: boolean;
194
206
  stroke?: string;
195
207
  strokeOpacity?: number;
@@ -241,12 +253,16 @@ declare class Synthesizer {
241
253
 
242
254
  declare namespace xnew {
243
255
  type Unit = InstanceType<typeof Unit>;
256
+ type UnitTimer = InstanceType<typeof UnitTimer>;
244
257
  }
245
258
  declare const xnew: CreateUnit & {
246
- nest(htmlString: string, textContent?: string): HTMLElement | SVGElement;
259
+ nest(tag: string, textContent?: string | number): HTMLElement | SVGElement;
247
260
  extend(component: Function, props?: Object): {
248
261
  [key: string]: any;
249
262
  };
263
+ internal(component: Function, props?: Object): {
264
+ [key: string]: any;
265
+ };
250
266
  context(key: string, value?: any): any;
251
267
  promise(promise: Promise<any>): UnitPromise;
252
268
  then(callback: Function): UnitPromise;
@@ -255,17 +271,18 @@ declare const xnew: CreateUnit & {
255
271
  scope(callback: any): any;
256
272
  find(component: Function): Unit[];
257
273
  emit(type: string, ...args: any[]): void;
258
- timeout(timeout: Function, duration?: number): any;
259
- interval(timeout: Function, duration: number, iterations?: number): any;
260
- transition(transition: Function, duration?: number, easing?: string): any;
261
- protect(...args: any[]): Unit;
274
+ timeout(timeout: Function, duration?: number): UnitTimer;
275
+ interval(timeout: Function, duration: number, iterations?: number): UnitTimer;
276
+ transition(transition: Function, duration?: number, easing?: string): UnitTimer;
277
+ protect(): void;
262
278
  } & {
263
279
  basics: {
264
280
  Screen: typeof Screen;
265
- Modal: typeof Modal;
266
- Accordion: typeof Accordion;
281
+ Modal: any;
282
+ Accordion: any;
283
+ OpenAndClose: typeof OpenAndClose;
267
284
  AnalogStick: typeof AnalogStick;
268
- DirectionalPad: typeof DirectionalPad;
285
+ DPad: typeof DPad;
269
286
  };
270
287
  audio: {
271
288
  load(path: string): UnitPromise;