vsn 0.1.16 → 0.1.17

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 (110) hide show
  1. package/demo/vision.js +1 -1
  2. package/dist/Scope.d.ts +1 -0
  3. package/dist/vision.min.js +1 -0
  4. package/main.py +16 -0
  5. package/package.json +1 -1
  6. package/src/AST.ts +13 -9
  7. package/src/Scope.ts +7 -0
  8. package/test/AST.spec.ts +41 -12
  9. package/dist/AST.js +0 -1995
  10. package/dist/AST.js.map +0 -1
  11. package/dist/Attribute.js +0 -187
  12. package/dist/Attribute.js.map +0 -1
  13. package/dist/Bencmark.js +0 -179
  14. package/dist/Bencmark.js.map +0 -1
  15. package/dist/Configuration.js +0 -64
  16. package/dist/Configuration.js.map +0 -1
  17. package/dist/Controller.js +0 -39
  18. package/dist/Controller.js.map +0 -1
  19. package/dist/DOM/DOMObject.js +0 -45
  20. package/dist/DOM/DOMObject.js.map +0 -1
  21. package/dist/DOM/WrappedDocument.js +0 -34
  22. package/dist/DOM/WrappedDocument.js.map +0 -1
  23. package/dist/DOM/WrappedWindow.js +0 -45
  24. package/dist/DOM/WrappedWindow.js.map +0 -1
  25. package/dist/DOM.js +0 -547
  26. package/dist/DOM.js.map +0 -1
  27. package/dist/Formats.js +0 -44
  28. package/dist/Formats.js.map +0 -1
  29. package/dist/Query.js +0 -66
  30. package/dist/Query.js.map +0 -1
  31. package/dist/Registry.js +0 -138
  32. package/dist/Registry.js.map +0 -1
  33. package/dist/Scope.js +0 -499
  34. package/dist/Scope.js.map +0 -1
  35. package/dist/Tag/List.js +0 -85
  36. package/dist/Tag/List.js.map +0 -1
  37. package/dist/Tag.js +0 -715
  38. package/dist/Tag.js.map +0 -1
  39. package/dist/Types.js +0 -48
  40. package/dist/Types.js.map +0 -1
  41. package/dist/Vision.js +0 -161
  42. package/dist/Vision.js.map +0 -1
  43. package/dist/attributes/AddClassIf.js +0 -93
  44. package/dist/attributes/AddClassIf.js.map +0 -1
  45. package/dist/attributes/Bind.js +0 -272
  46. package/dist/attributes/Bind.js.map +0 -1
  47. package/dist/attributes/ClassConstructor.js +0 -104
  48. package/dist/attributes/ClassConstructor.js.map +0 -1
  49. package/dist/attributes/ClickRemoveClass.js +0 -102
  50. package/dist/attributes/ClickRemoveClass.js.map +0 -1
  51. package/dist/attributes/ClickToggleClass.js +0 -102
  52. package/dist/attributes/ClickToggleClass.js.map +0 -1
  53. package/dist/attributes/ControllerAttribute.js +0 -28
  54. package/dist/attributes/ControllerAttribute.js.map +0 -1
  55. package/dist/attributes/DisableIf.js +0 -94
  56. package/dist/attributes/DisableIf.js.map +0 -1
  57. package/dist/attributes/Exec.js +0 -102
  58. package/dist/attributes/Exec.js.map +0 -1
  59. package/dist/attributes/Format.js +0 -96
  60. package/dist/attributes/Format.js.map +0 -1
  61. package/dist/attributes/If.js +0 -147
  62. package/dist/attributes/If.js.map +0 -1
  63. package/dist/attributes/JSONAttribute.js +0 -115
  64. package/dist/attributes/JSONAttribute.js.map +0 -1
  65. package/dist/attributes/KeyAbstract.js +0 -110
  66. package/dist/attributes/KeyAbstract.js.map +0 -1
  67. package/dist/attributes/KeyDown.js +0 -82
  68. package/dist/attributes/KeyDown.js.map +0 -1
  69. package/dist/attributes/KeyUp.js +0 -82
  70. package/dist/attributes/KeyUp.js.map +0 -1
  71. package/dist/attributes/List.js +0 -273
  72. package/dist/attributes/List.js.map +0 -1
  73. package/dist/attributes/ListItem.js +0 -135
  74. package/dist/attributes/ListItem.js.map +0 -1
  75. package/dist/attributes/ListItemModel.js +0 -39
  76. package/dist/attributes/ListItemModel.js.map +0 -1
  77. package/dist/attributes/ModelAttribute.js +0 -29
  78. package/dist/attributes/ModelAttribute.js.map +0 -1
  79. package/dist/attributes/Name.js +0 -88
  80. package/dist/attributes/Name.js.map +0 -1
  81. package/dist/attributes/On.js +0 -123
  82. package/dist/attributes/On.js.map +0 -1
  83. package/dist/attributes/Radio.js +0 -127
  84. package/dist/attributes/Radio.js.map +0 -1
  85. package/dist/attributes/Referenced.js +0 -38
  86. package/dist/attributes/Referenced.js.map +0 -1
  87. package/dist/attributes/RootAttribute.js +0 -85
  88. package/dist/attributes/RootAttribute.js.map +0 -1
  89. package/dist/attributes/ScopeAttribute.js +0 -40
  90. package/dist/attributes/ScopeAttribute.js.map +0 -1
  91. package/dist/attributes/ScopeChange.js +0 -124
  92. package/dist/attributes/ScopeChange.js.map +0 -1
  93. package/dist/attributes/SetAttribute.js +0 -130
  94. package/dist/attributes/SetAttribute.js.map +0 -1
  95. package/dist/attributes/StandardAttribute.js +0 -168
  96. package/dist/attributes/StandardAttribute.js.map +0 -1
  97. package/dist/attributes/Template.js +0 -39
  98. package/dist/attributes/Template.js.map +0 -1
  99. package/dist/attributes/TypeAttribute.js +0 -101
  100. package/dist/attributes/TypeAttribute.js.map +0 -1
  101. package/dist/attributes/_imports.js +0 -58
  102. package/dist/attributes/_imports.js.map +0 -1
  103. package/dist/helpers/DOMHelper.js +0 -81
  104. package/dist/helpers/DOMHelper.js.map +0 -1
  105. package/dist/helpers/ElementHelper.js +0 -25
  106. package/dist/helpers/ElementHelper.js.map +0 -1
  107. package/dist/helpers/VisionHelper.js +0 -71
  108. package/dist/helpers/VisionHelper.js.map +0 -1
  109. package/dist/helpers/decorators.js +0 -38
  110. package/dist/helpers/decorators.js.map +0 -1
package/src/Scope.ts CHANGED
@@ -101,6 +101,13 @@ export class WrappedArray<T> extends Array<T> {
101
101
  return removed;
102
102
  }
103
103
 
104
+ get(key: string) {
105
+ const keys: string[] = [
106
+ 'length'
107
+ ];
108
+ return keys.indexOf(key) > -1 ? this[key] : undefined;
109
+ }
110
+
104
111
  get length(): number {
105
112
  let c: number = 0;
106
113
  for (const item of this) {
package/test/AST.spec.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {Promise as SimplePromise, IDeferred} from 'simple-ts-promise';
2
- import {Scope} from "../src/Scope";
2
+ import {Scope, WrappedArray} from "../src/Scope";
3
3
  import {Tree} from "../src/AST";
4
4
  import {DOM} from "../src/DOM";
5
5
 
@@ -144,20 +144,44 @@ describe('Tree', () => {
144
144
  expect(await tree.evaluate(scope, dom)).toBe(true);
145
145
  // Multiple if statements
146
146
  tree = new Tree(`
147
- poop = 15;
148
- if (poop > 5) {
149
- poop = 3;
147
+ foo = 15;
148
+ if (foo > 5) {
149
+ foo = 3;
150
150
  } else if (true) {
151
- poop = 5;
151
+ foo = 5;
152
152
  } else {
153
- poop = false;
153
+ foo = false;
154
154
  }
155
- if (poop == 3) {
156
- poop = 5;
155
+ if (foo == 3) {
156
+ foo = 5;
157
157
  }`);
158
158
  await tree.evaluate(scope, dom);
159
- expect(scope.get('poop')).toBe(5);
160
- console.log('=========================');
159
+ expect(scope.get('foo')).toBe(5);
160
+
161
+ // Array literals should be instantiaed as WrappedArray
162
+ tree = new Tree(`[123,456];`);
163
+ expect((await tree.evaluate(scope, dom)) instanceof WrappedArray).toBe(true);
164
+
165
+ // Array if statement and length test
166
+ tree = new Tree(`
167
+ foo1 = [1234,5678,9101112];
168
+ bar1 = [];
169
+ fooLength = foo1.length;
170
+ fooTest = false;
171
+ barTest = false;
172
+
173
+ if (foo1) {
174
+ fooTest = true;
175
+ }
176
+
177
+ if (bar1) {
178
+ barTest = true;
179
+ }
180
+ `);
181
+ await tree.evaluate(scope, dom);
182
+ expect(scope.get('fooTest')).toBe(true);
183
+ expect(scope.get('barTest')).toBe(false);
184
+ expect(scope.get('fooLength')).toBe(3);
161
185
  });
162
186
 
163
187
  it("should be able to assign variables properly", async () => {
@@ -203,11 +227,16 @@ describe('Tree', () => {
203
227
  const dom: DOM = new DOM(document, false);
204
228
  await tree.evaluate(scope, dom);
205
229
  const something = scope.get('something');
206
- expect(something).toEqual([5,6,10]);
230
+ expect(something.length).toEqual(3);
231
+ expect(something[0]).toEqual(5);
232
+ expect(something[1]).toEqual(6);
233
+ expect(something[2]).toEqual(10);
207
234
 
208
235
  tree = new Tree(`something -= 5;`);
209
236
  await tree.evaluate(scope, dom);
210
- expect(something).toEqual([6,10]);
237
+ expect(something.length).toEqual(2);
238
+ expect(something[0]).toEqual(6);
239
+ expect(something[1]).toEqual(10);
211
240
  });
212
241
 
213
242
  it("should be able to block properly with promises", async () => {