vasille 2.2.0 → 2.3.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.
Files changed (43) hide show
  1. package/README.md +34 -28
  2. package/cdn/es2015.js +548 -548
  3. package/cdn/es5.js +616 -608
  4. package/flow-typed/vasille.js +55 -50
  5. package/lib/binding/attribute.js +1 -1
  6. package/lib/binding/binding.js +5 -5
  7. package/lib/binding/class.js +2 -2
  8. package/lib/binding/style.js +1 -1
  9. package/lib/core/core.js +21 -15
  10. package/lib/core/destroyable.js +2 -2
  11. package/lib/core/ivalue.js +4 -4
  12. package/lib/functional/reactivity.js +1 -1
  13. package/lib/index.js +2 -3
  14. package/lib/models/array-model.js +6 -9
  15. package/lib/models/object-model.js +3 -17
  16. package/lib/node/app.js +3 -3
  17. package/lib/node/node.js +53 -42
  18. package/lib/node/watch.js +1 -1
  19. package/lib/v/index.js +1 -1
  20. package/lib/value/expression.js +13 -13
  21. package/lib/value/mirror.js +15 -15
  22. package/lib/value/pointer.js +5 -5
  23. package/lib/value/reference.js +18 -18
  24. package/lib/views/base-view.js +1 -1
  25. package/lib/views/object-view.js +1 -1
  26. package/lib/views/repeat-node.js +4 -4
  27. package/package.json +1 -1
  28. package/types/binding/binding.d.ts +1 -1
  29. package/types/core/core.d.ts +8 -6
  30. package/types/core/destroyable.d.ts +2 -2
  31. package/types/core/ivalue.d.ts +4 -4
  32. package/types/functional/options.d.ts +2 -2
  33. package/types/index.d.ts +3 -4
  34. package/types/models/array-model.d.ts +1 -1
  35. package/types/models/object-model.d.ts +1 -1
  36. package/types/node/node.d.ts +18 -15
  37. package/types/node/watch.d.ts +2 -2
  38. package/types/v/index.d.ts +4 -0
  39. package/types/value/expression.d.ts +5 -5
  40. package/types/value/mirror.d.ts +6 -6
  41. package/types/value/pointer.d.ts +1 -1
  42. package/types/value/reference.d.ts +7 -7
  43. package/types/views/repeat-node.d.ts +3 -3
@@ -11,7 +11,6 @@ export declare class ArrayModel<T> extends Array<T> implements ListenableModel<T
11
11
  * @param data {Array} input data
12
12
  */
13
13
  constructor(data?: Array<T>);
14
- proxy(): ArrayModel<T>;
15
14
  /**
16
15
  * Gets the last item of array
17
16
  * @return {*} the last item of array
@@ -99,6 +98,7 @@ export declare class ArrayModel<T> extends Array<T> implements ListenableModel<T
99
98
  * @return {this}
100
99
  */
101
100
  removeOne(v: T): this;
101
+ replace(at: number, with_: T): this;
102
102
  enableReactivity(): void;
103
103
  disableReactivity(): void;
104
104
  }
@@ -27,12 +27,12 @@ export declare class ObjectModel<T> extends Object implements ListenableModel<st
27
27
  * @return {ObjectModel} a pointer to this
28
28
  */
29
29
  set(key: string, v: T): this;
30
+ get values(): Record<string, T>;
30
31
  /**
31
32
  * Deletes an object property
32
33
  * @param key {string} property name
33
34
  */
34
35
  delete(key: string): void;
35
- proxy(): Record<string, T>;
36
36
  enableReactivity(): void;
37
37
  disableReactivity(): void;
38
38
  }
@@ -1,7 +1,7 @@
1
1
  import { Reactive, ReactivePrivate } from "../core/core";
2
2
  import { IValue } from "../core/ivalue";
3
3
  import type { AppNode } from "./app";
4
- import { Options, TagOptions } from "../functional/options";
4
+ import { FragmentOptions, TagOptions } from "../functional/options";
5
5
  import { AcceptedTagsMap } from "../spec/react";
6
6
  /**
7
7
  * Represents a Vasille.js node
@@ -39,13 +39,13 @@ export declare class FragmentPrivate extends ReactivePrivate {
39
39
  /**
40
40
  * Unlinks all bindings
41
41
  */
42
- destroy(): void;
42
+ $destroy(): void;
43
43
  }
44
44
  /**
45
45
  * This class is symbolic
46
46
  * @extends Reactive
47
47
  */
48
- export declare class Fragment<T extends Options = Options> extends Reactive {
48
+ export declare class Fragment<T extends FragmentOptions = FragmentOptions> extends Reactive {
49
49
  /**
50
50
  * Private part
51
51
  * @protected
@@ -74,7 +74,8 @@ export declare class Fragment<T extends Options = Options> extends Reactive {
74
74
  * @param data {*} additional data
75
75
  */
76
76
  preinit(app: AppNode, parent: Fragment, data?: unknown): void;
77
- protected compose(input: Options): void;
77
+ init(): T['return'];
78
+ protected compose(input: T): void;
78
79
  /** To be overloaded: ready event handler */
79
80
  ready(): void;
80
81
  /**
@@ -118,7 +119,7 @@ export declare class Fragment<T extends Options = Options> extends Reactive {
118
119
  * @param node {Fragment} vasille element to insert
119
120
  * @param callback {function($ : *)}
120
121
  */
121
- create<T extends Fragment>(node: T, callback?: T['input']['slot']): void;
122
+ create<T extends Fragment>(node: T, callback?: T['input']['slot']): T['input']['return'];
122
123
  /**
123
124
  * Defines an if node
124
125
  * @param cond {IValue} condition
@@ -149,7 +150,7 @@ export declare class Fragment<T extends Options = Options> extends Reactive {
149
150
  insertBefore(node: Fragment): void;
150
151
  insertAfter(node: Fragment): void;
151
152
  remove(): void;
152
- destroy(): void;
153
+ $destroy(): void;
153
154
  }
154
155
  /**
155
156
  * The private part of a text node
@@ -169,7 +170,7 @@ export declare class TextNodePrivate extends FragmentPrivate {
169
170
  /**
170
171
  * Clear node data
171
172
  */
172
- destroy(): void;
173
+ $destroy(): void;
173
174
  }
174
175
  /**
175
176
  * Represents a text node
@@ -181,7 +182,7 @@ export declare class TextNode extends Fragment {
181
182
  constructor($?: TextNodePrivate);
182
183
  preinit(app: AppNode, parent: Fragment, text?: IValue<string> | string): void;
183
184
  protected findFirstChild(): Node;
184
- destroy(): void;
185
+ $destroy(): void;
185
186
  }
186
187
  /**
187
188
  * The private part of a base node
@@ -200,7 +201,7 @@ export declare class INodePrivate extends FragmentPrivate {
200
201
  */
201
202
  node: Element;
202
203
  constructor();
203
- destroy(): void;
204
+ $destroy(): void;
204
205
  }
205
206
  /**
206
207
  * Vasille node which can manipulate an element node
@@ -307,7 +308,7 @@ export declare class Tag<K extends keyof AcceptedTagsMap> extends INode<TagOptio
307
308
  /**
308
309
  * Runs GC
309
310
  */
310
- destroy(): void;
311
+ $destroy(): void;
311
312
  }
312
313
  /**
313
314
  * Represents a vasille extension node
@@ -316,7 +317,8 @@ export declare class Tag<K extends keyof AcceptedTagsMap> extends INode<TagOptio
316
317
  */
317
318
  export declare class Extension<T extends TagOptions<any> = TagOptions<any>> extends INode<T> {
318
319
  preinit(app: AppNode, parent: Fragment): void;
319
- destroy(): void;
320
+ extend(options: T): void;
321
+ $destroy(): void;
320
322
  }
321
323
  /**
322
324
  * Node which cas has just a child
@@ -324,6 +326,7 @@ export declare class Extension<T extends TagOptions<any> = TagOptions<any>> exte
324
326
  * @extends Extension
325
327
  */
326
328
  export declare class Component<T extends TagOptions<any>> extends Extension<T> {
329
+ init(): void;
327
330
  ready(): void;
328
331
  preinit(app: AppNode, parent: Fragment): void;
329
332
  }
@@ -355,7 +358,7 @@ export declare class SwitchedNodePrivate extends FragmentPrivate {
355
358
  /**
356
359
  * Runs GC
357
360
  */
358
- destroy(): void;
361
+ $destroy(): void;
359
362
  }
360
363
  /**
361
364
  * Defines a node witch can switch its children conditionally
@@ -376,7 +379,7 @@ export declare class SwitchedNode extends Fragment {
376
379
  */
377
380
  createChild(cb: (node: Fragment) => void): void;
378
381
  ready(): void;
379
- destroy(): void;
382
+ $destroy(): void;
380
383
  }
381
384
  /**
382
385
  * The private part of a text node
@@ -394,7 +397,7 @@ export declare class DebugPrivate extends FragmentPrivate {
394
397
  /**
395
398
  * Clear node data
396
399
  */
397
- destroy(): void;
400
+ $destroy(): void;
398
401
  }
399
402
  /**
400
403
  * Represents a debug node
@@ -412,5 +415,5 @@ export declare class DebugNode extends Fragment {
412
415
  /**
413
416
  * Runs garbage collector
414
417
  */
415
- destroy(): void;
418
+ $destroy(): void;
416
419
  }
@@ -1,7 +1,7 @@
1
1
  import { Fragment } from "./node";
2
2
  import { IValue } from "../core/ivalue";
3
- import { Options } from "../functional/options";
4
- interface WatchOptions<T> extends Options {
3
+ import { FragmentOptions } from "../functional/options";
4
+ interface WatchOptions<T> extends FragmentOptions {
5
5
  model: IValue<T>;
6
6
  slot?: (node: Fragment, value: T) => void;
7
7
  }
@@ -7,6 +7,10 @@ import { AppOptions } from "../node/app";
7
7
  import { Reference } from "../value/reference";
8
8
  import { merge } from "../functional/merge";
9
9
  export { debug, arrayModel, mapModel, objectModel, setModel, expr, forward, mirror, point, ref, setValue, valueOf, watch, Options, TagOptions, AppOptions };
10
+ export declare type VApp<In extends AppOptions<any> = AppOptions<'div'>> = (node: Element, opts: In) => In['return'];
11
+ export declare type VComponent<In extends TagOptions<any>> = (opts: In, callback?: In['slot']) => In['return'];
12
+ export declare type VFragment<In extends Options = Options> = (opts: In, callback?: In['slot']) => In['return'];
13
+ export declare type VExtension<In extends TagOptions<any>> = (opts: In, callback?: In['slot']) => In['return'];
10
14
  export declare const v: {
11
15
  merge: typeof merge;
12
16
  destructor(): any;
@@ -39,9 +39,9 @@ export declare class Expression<T, Args extends unknown[]> extends IValue<T> {
39
39
  constructor(func: (...args: Args) => T, link: boolean, ...values: KindOfIValue<Args>);
40
40
  get $(): T;
41
41
  set $(value: T);
42
- on(handler: (value: T) => void): this;
43
- off(handler: (value: T) => void): this;
44
- enable(): this;
45
- disable(): this;
46
- destroy(): void;
42
+ $on(handler: (value: T) => void): this;
43
+ $off(handler: (value: T) => void): this;
44
+ $enable(): this;
45
+ $disable(): this;
46
+ $destroy(): void;
47
47
  }
@@ -11,16 +11,16 @@ export declare class Mirror<T> extends Reference<T> {
11
11
  * pointed value
12
12
  * @type IValue
13
13
  */
14
- protected pointedValue: IValue<T>;
14
+ protected $pointedValue: IValue<T>;
15
15
  /**
16
16
  * Collection of handlers
17
17
  * @type Set
18
18
  */
19
- private readonly handler;
19
+ private readonly $handler;
20
20
  /**
21
21
  * Ensure forward only synchronization
22
22
  */
23
- forwardOnly: boolean;
23
+ $forwardOnly: boolean;
24
24
  /**
25
25
  * Constructs a notifiable bind to a value
26
26
  * @param value {IValue} is initial value
@@ -29,7 +29,7 @@ export declare class Mirror<T> extends Reference<T> {
29
29
  constructor(value: IValue<T>, forwardOnly?: boolean);
30
30
  get $(): T;
31
31
  set $(v: T);
32
- enable(): void;
33
- disable(): void;
34
- destroy(): void;
32
+ $enable(): void;
33
+ $disable(): void;
34
+ $destroy(): void;
35
35
  }
@@ -15,5 +15,5 @@ export declare class Pointer<T> extends Mirror<T> {
15
15
  * Point a new ivalue
16
16
  * @param value {IValue} value to point
17
17
  */
18
- point(value: IValue<T>): void;
18
+ set $$(value: IValue<T>);
19
19
  }
@@ -9,22 +9,22 @@ export declare class Reference<T> extends IValue<T> {
9
9
  * The encapsulated value
10
10
  * @type {*}
11
11
  */
12
- private value;
12
+ private $value;
13
13
  /**
14
14
  * Array of handlers
15
15
  * @type {Set}
16
16
  * @readonly
17
17
  */
18
- private readonly onchange;
18
+ private readonly $onchange;
19
19
  /**
20
20
  * @param value {any} the initial value
21
21
  */
22
22
  constructor(value: T);
23
23
  get $(): T;
24
24
  set $(value: T);
25
- enable(): void;
26
- disable(): void;
27
- on(handler: (value: T) => void): void;
28
- off(handler: (value: T) => void): void;
29
- destroy(): void;
25
+ $enable(): void;
26
+ $disable(): void;
27
+ $on(handler: (value: T) => void): void;
28
+ $off(handler: (value: T) => void): void;
29
+ $destroy(): void;
30
30
  }
@@ -1,5 +1,5 @@
1
1
  import { Fragment, INodePrivate } from "../node/node";
2
- import { Options } from "../functional/options";
2
+ import { FragmentOptions } from "../functional/options";
3
3
  /**
4
4
  * Private part of repeat node
5
5
  * @class RepeatNodePrivate
@@ -12,9 +12,9 @@ export declare class RepeatNodePrivate<IdT> extends INodePrivate {
12
12
  */
13
13
  nodes: Map<IdT, Fragment>;
14
14
  constructor();
15
- destroy(): void;
15
+ $destroy(): void;
16
16
  }
17
- export interface RNO<T, IdT> extends Options {
17
+ export interface RNO<T, IdT> extends FragmentOptions {
18
18
  slot?: (node: Fragment, value: T, index: IdT) => void;
19
19
  }
20
20
  /**