vsn 0.1.60 → 0.1.61

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/demo/xhr.html CHANGED
@@ -1,16 +1,35 @@
1
1
  <div id="huh-wut" vsn-scope>
2
2
  <style>
3
- bb {
3
+ bb,
4
+ .something-special {
4
5
  display: block;
5
6
  }
6
7
  </style>
7
8
  <script vsn-script type="text/vsn">
8
- huh_wut = 1;
9
+ class something-special {
10
+ func construct() {
11
+ $color = "#ff00ff";
12
+ something = "something";
13
+ @text = 'huh?';
14
+ }
15
+
16
+ func click() {
17
+ }
18
+
19
+ func t() {
20
+ $color = 'red';
21
+ @text = 'wut?';
22
+ }
23
+ }
24
+
25
+ ?>(:parent).huh_wut = 1;
9
26
  func add(a, b) {
10
27
  ?(bb).@text = `asd 123 ${a} ${b} hmm?`;
11
28
  return a + b;
12
29
  }
13
30
  </script>
31
+ <div class="something-special" vsn-on:click="t()">asd</div>
32
+ <div class="something-special" vsn-on:click="t()">asd</div>
14
33
  <bb>bb</bb>
15
34
  <span vsn-bind="huh_wut"></span>
16
35
  <a href="" vsn-on:click|preventdefault="huh_wut = add(huh_wut, 1)">Click me!</a>
@@ -0,0 +1,20 @@
1
+ import { Scope } from "../Scope";
2
+ import { DOM } from "../DOM";
3
+ import { Tag } from "../Tag";
4
+ import { Token, TreeNode } from "../AST";
5
+ import { Node } from "./Node";
6
+ import { BlockNode } from "./BlockNode";
7
+ export declare class ClassNode extends Node implements TreeNode {
8
+ readonly name: string;
9
+ readonly block: BlockNode;
10
+ static readonly classes: {
11
+ [name: string]: ClassNode;
12
+ };
13
+ protected requiresPrep: boolean;
14
+ readonly classScope: Scope;
15
+ constructor(name: string, block: BlockNode);
16
+ prepare(scope: Scope, dom: DOM, tag?: Tag): Promise<void>;
17
+ prepareTag(tag: Tag, dom: DOM): Promise<void>;
18
+ evaluate(scope: Scope, dom: DOM, tag?: Tag): Promise<any>;
19
+ static parse(lastNode: any, token: any, tokens: Token[]): ClassNode;
20
+ }
package/dist/AST.d.ts CHANGED
@@ -34,52 +34,53 @@ export declare enum TokenType {
34
34
  ELSE_IF = 12,
35
35
  ELSE = 13,
36
36
  FUNC = 14,
37
- NAME = 15,
38
- L_BRACE = 16,
39
- R_BRACE = 17,
40
- L_BRACKET = 18,
41
- R_BRACKET = 19,
42
- L_PAREN = 20,
43
- R_PAREN = 21,
44
- TILDE = 22,
45
- PERIOD = 23,
46
- COMMA = 24,
47
- COLON = 25,
48
- SEMICOLON = 26,
49
- STRING_FORMAT = 27,
50
- STRING_LITERAL = 28,
51
- NUMBER_LITERAL = 29,
52
- BOOLEAN_LITERAL = 30,
53
- NULL_LITERAL = 31,
54
- STRICT_EQUALS = 32,
55
- STRICT_NOT_EQUALS = 33,
56
- EQUALS = 34,
57
- NOT_EQUALS = 35,
58
- GREATER_THAN_EQUAL = 36,
59
- LESS_THAN_EQUAL = 37,
60
- GREATER_THAN = 38,
61
- LESS_THAN = 39,
62
- ASSIGN = 40,
63
- AND = 41,
64
- OR = 42,
65
- ADD = 43,
66
- SUBTRACT = 44,
67
- MULTIPLY = 45,
68
- DIVIDE = 46,
69
- ADD_ASSIGN = 47,
70
- SUBTRACT_ASSIGN = 48,
71
- MULTIPLY_ASSIGN = 49,
72
- DIVIDE_ASSIGN = 50,
73
- EXCLAMATION_POINT = 51,
74
- ELEMENT_REFERENCE = 52,
75
- ELEMENT_ATTRIBUTE = 53,
76
- ELEMENT_STYLE = 54,
77
- ELEMENT_QUERY = 55,
78
- UNIT = 56,
79
- XHR_GET = 57,
80
- XHR_POST = 58,
81
- XHR_PUT = 59,
82
- XHR_DELETE = 60
37
+ CLASS = 15,
38
+ NAME = 16,
39
+ L_BRACE = 17,
40
+ R_BRACE = 18,
41
+ L_BRACKET = 19,
42
+ R_BRACKET = 20,
43
+ L_PAREN = 21,
44
+ R_PAREN = 22,
45
+ TILDE = 23,
46
+ PERIOD = 24,
47
+ COMMA = 25,
48
+ COLON = 26,
49
+ SEMICOLON = 27,
50
+ STRING_FORMAT = 28,
51
+ STRING_LITERAL = 29,
52
+ NUMBER_LITERAL = 30,
53
+ BOOLEAN_LITERAL = 31,
54
+ NULL_LITERAL = 32,
55
+ STRICT_EQUALS = 33,
56
+ STRICT_NOT_EQUALS = 34,
57
+ EQUALS = 35,
58
+ NOT_EQUALS = 36,
59
+ GREATER_THAN_EQUAL = 37,
60
+ LESS_THAN_EQUAL = 38,
61
+ GREATER_THAN = 39,
62
+ LESS_THAN = 40,
63
+ ASSIGN = 41,
64
+ AND = 42,
65
+ OR = 43,
66
+ ADD = 44,
67
+ SUBTRACT = 45,
68
+ MULTIPLY = 46,
69
+ DIVIDE = 47,
70
+ ADD_ASSIGN = 48,
71
+ SUBTRACT_ASSIGN = 49,
72
+ MULTIPLY_ASSIGN = 50,
73
+ DIVIDE_ASSIGN = 51,
74
+ EXCLAMATION_POINT = 52,
75
+ ELEMENT_REFERENCE = 53,
76
+ ELEMENT_ATTRIBUTE = 54,
77
+ ELEMENT_STYLE = 55,
78
+ ELEMENT_QUERY = 56,
79
+ UNIT = 57,
80
+ XHR_GET = 58,
81
+ XHR_POST = 59,
82
+ XHR_PUT = 60,
83
+ XHR_DELETE = 61
83
84
  }
84
85
  export interface TreeNode<T = any> {
85
86
  evaluate(scope: Scope, dom: DOM, tag?: Tag): any;
package/dist/DOM.d.ts CHANGED
@@ -4,6 +4,7 @@ import { WrappedWindow } from "./DOM/WrappedWindow";
4
4
  import { WrappedDocument } from "./DOM/WrappedDocument";
5
5
  import { Scope } from "./Scope";
6
6
  import { EventDispatcher } from "./EventDispatcher";
7
+ import { ClassNode } from "./AST/ClassNode";
7
8
  export declare class DOM extends EventDispatcher {
8
9
  protected rootElement: Document;
9
10
  protected debug: boolean;
@@ -19,6 +20,7 @@ export declare class DOM extends EventDispatcher {
19
20
  constructor(rootElement: Document, build?: boolean, debug?: boolean);
20
21
  get root(): Tag;
21
22
  get(selector: string, create?: boolean, tag?: Tag): Promise<TagList>;
23
+ prepareDOMClass(className: string, classObject: ClassNode): Promise<void>;
22
24
  getFromTag(tag: Tag, selector: string, create?: boolean): Promise<TagList>;
23
25
  registerElementInRoot(tag: Tag): void;
24
26
  querySelectorAll(q: string, tag?: Tag): NodeList | HTMLElement[];
@@ -1,5 +1,6 @@
1
1
  import { EventDispatcher } from "./EventDispatcher";
2
2
  import { IPromise } from "./SimplePromise";
3
+ import { ClassNode } from "./AST/ClassNode";
3
4
  export declare function register(store: string, key?: string, setup?: () => void): (target: any, _key?: string) => void;
4
5
  export declare class RegistryStore extends EventDispatcher {
5
6
  private timeouts;
@@ -11,7 +12,7 @@ export declare class RegistryStore extends EventDispatcher {
11
12
  }
12
13
  export declare class Registry extends EventDispatcher {
13
14
  protected static _instance: Registry;
14
- readonly components: RegistryStore;
15
+ readonly controllers: RegistryStore;
15
16
  readonly classes: RegistryStore;
16
17
  readonly models: RegistryStore;
17
18
  readonly templates: RegistryStore;
@@ -20,8 +21,7 @@ export declare class Registry extends EventDispatcher {
20
21
  readonly formats: RegistryStore;
21
22
  readonly attributes: RegistryStore;
22
23
  constructor();
23
- static component(key?: string, setup?: any): (target: any, _key?: string) => void;
24
- static class(key?: string, setup?: any): (target: any, _key?: string) => void;
24
+ static class(cls: ClassNode): void;
25
25
  static controller(key?: string, setup?: any): (target: any, _key?: string) => void;
26
26
  static model(key?: string, setup?: any): (target: any, _key?: string) => void;
27
27
  static template(key?: string, setup?: any): (target: any, _key?: string) => void;
package/dist/Scope.d.ts CHANGED
@@ -25,3 +25,6 @@ export declare class Scope extends EventDispatcher {
25
25
  unwrap(): void;
26
26
  static fromObject(obj: any, parentScope?: Scope): Scope;
27
27
  }
28
+ export declare class FunctionScope extends Scope {
29
+ set(key: string, value: any): void;
30
+ }
@@ -1,3 +1,10 @@
1
- import { ClassConstructor } from "./ClassConstructor";
2
- export declare class ControllerAttribute extends ClassConstructor {
1
+ import { Attribute } from "../Attribute";
2
+ export declare class ControllerAttribute extends Attribute {
3
+ static readonly canDefer: boolean;
4
+ static readonly scoped: boolean;
5
+ protected attributeKey: string;
6
+ protected className: string;
7
+ protected defaultClassName: string;
8
+ setup(): Promise<void>;
9
+ protected instantiateClass(cls: any): void;
3
10
  }
@@ -1,4 +1,4 @@
1
- import { ClassConstructor } from "./ClassConstructor";
2
- export declare class ModelAttribute extends ClassConstructor {
1
+ import { ControllerAttribute } from "./ControllerAttribute";
2
+ export declare class ModelAttribute extends ControllerAttribute {
3
3
  static readonly canDefer: boolean;
4
4
  }