vsn 0.1.55 → 0.1.58

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 (49) hide show
  1. package/demo/demo.html +183 -62
  2. package/demo/vsn.js +2 -1
  3. package/dist/AST/FunctionNode.d.ts +18 -0
  4. package/dist/AST/FunctionNode.js +87 -0
  5. package/dist/AST/FunctionNode.js.map +1 -1
  6. package/dist/DOM/DOMObject.d.ts +6 -1
  7. package/dist/DOM/DOMObject.js.map +1 -1
  8. package/dist/DOM.js +46 -76
  9. package/dist/DOM.js.map +1 -1
  10. package/dist/Tag.d.ts +3 -2
  11. package/dist/Tag.js +42 -18
  12. package/dist/Tag.js.map +1 -1
  13. package/dist/Types.js +1 -1
  14. package/dist/Types.js.map +1 -1
  15. package/dist/attributes/Bind.js.map +1 -1
  16. package/dist/attributes/KeyAbstract.js +1 -1
  17. package/dist/attributes/KeyAbstract.js.map +1 -1
  18. package/dist/attributes/KeyDown.js +1 -1
  19. package/dist/attributes/KeyDown.js.map +1 -1
  20. package/dist/attributes/KeyUp.js +1 -1
  21. package/dist/attributes/KeyUp.js.map +1 -1
  22. package/dist/attributes/LazyAttribute.js +2 -2
  23. package/dist/attributes/LazyAttribute.js.map +1 -1
  24. package/dist/attributes/List.js +13 -9
  25. package/dist/attributes/List.js.map +1 -1
  26. package/dist/attributes/On.js +1 -1
  27. package/dist/attributes/On.js.map +1 -1
  28. package/dist/attributes/StandardAttribute.js +1 -0
  29. package/dist/attributes/StandardAttribute.js.map +1 -1
  30. package/dist/vsn.d.ts +1 -1
  31. package/dist/vsn.js +2 -2
  32. package/dist/vsn.js.map +1 -1
  33. package/package.json +3 -4
  34. package/src/AST/FunctionNode.ts +31 -0
  35. package/src/DOM/DOMObject.ts +7 -1
  36. package/src/DOM.ts +0 -20
  37. package/src/Tag.ts +44 -19
  38. package/src/Types.ts +1 -1
  39. package/src/attributes/Bind.ts +1 -2
  40. package/src/attributes/KeyAbstract.ts +1 -1
  41. package/src/attributes/KeyDown.ts +1 -1
  42. package/src/attributes/KeyUp.ts +1 -1
  43. package/src/attributes/LazyAttribute.ts +2 -2
  44. package/src/attributes/List.ts +2 -0
  45. package/src/attributes/On.ts +1 -1
  46. package/src/attributes/StandardAttribute.ts +1 -0
  47. package/src/vsn.ts +2 -2
  48. package/test/attributes/ListItem.spec.ts +1 -0
  49. package/webpack.config.js +10 -0
@@ -12,7 +12,7 @@ export class LazyAttribute extends On {
12
12
  }
13
13
 
14
14
  public async connect() {
15
- this.tag.addEventHandler('scroll', ['passive'], this.handleEvent.bind(this));
15
+ this.tag.addEventHandler('scroll', ['passive'], this.handleEvent, this);
16
16
  await this.handleEvent();
17
17
  }
18
18
 
@@ -20,7 +20,7 @@ export class LazyAttribute extends On {
20
20
  if (!this.loaded && window.scrollY + window.outerHeight >= this.eleTop) {
21
21
  this.loaded = true;
22
22
  await this.handler.evaluate(this.tag.scope, this.tag.dom, this.tag);
23
- this.tag.removeEventHandler('scroll', this.handleEvent.bind(this));
23
+ this.tag.removeEventHandler('scroll', this.handleEvent, this);
24
24
  }
25
25
  }
26
26
  }
@@ -25,9 +25,11 @@ export class List extends Attribute {
25
25
  public async setup() {
26
26
  if (this.tag.element.children.length > 0) {
27
27
  const template = this.tag.element.children[0];
28
+ const templateTag: Tag = await this.tag.dom.getTagForElement(template);
28
29
 
29
30
  if (template) {
30
31
  if (template.hasAttribute('vsn-template')) {
32
+ templateTag.parentTag = this.tag; // Set parentTag before removing from DOM
31
33
  template.removeAttribute('vsn-template');
32
34
  this.tag.element.removeChild(template);
33
35
  this.template = template;
@@ -32,7 +32,7 @@ export abstract class On extends Attribute {
32
32
  }
33
33
 
34
34
  public async connect() {
35
- this.tag.addEventHandler(this.getAttributeBinding(), this.getAttributeModifiers(), this.handleEvent.bind(this));
35
+ this.tag.addEventHandler(this.getAttributeBinding(), this.getAttributeModifiers(), this.handleEvent, this);
36
36
  await super.connect();
37
37
  }
38
38
  }
@@ -16,6 +16,7 @@ export class StandardAttribute extends Attribute {
16
16
  }
17
17
 
18
18
  public async connect() {
19
+ this.tag.scope.on(`change:${this.key}`, (v) => { console.log('updated', v);});
19
20
  this.tag.scope.on(`change:${this.key}`, this.updateTo.bind(this));
20
21
  await super.connect();
21
22
  }
package/src/vsn.ts CHANGED
@@ -43,7 +43,7 @@ export class Vision extends EventDispatcher {
43
43
  return this._dom;
44
44
  }
45
45
 
46
- public async eval(code: string) {
46
+ public async exec(code: string) {
47
47
  return await this._dom.exec(code);
48
48
  }
49
49
 
@@ -55,7 +55,7 @@ export class Vision extends EventDispatcher {
55
55
  await this._dom.buildFrom(document, true);
56
56
  const now = (new Date()).getTime();
57
57
  const setupTime = now - startTime;
58
- console.warn(`Took ${setupTime}ms to start up VisionJS. https://www.vsnjs.com/`);
58
+ console.warn(`Took ${setupTime}ms to start up VisionJS. https://www.vsnjs.com/`, window ? `v${window['VSN_VERSION']}` : null);
59
59
  }
60
60
 
61
61
  public static get instance() {
@@ -68,6 +68,7 @@ describe('ListItem', () => {
68
68
  </ul>
69
69
  </div>
70
70
  `;
71
+ console.log('########### test');
71
72
  const dom = new DOM(document);
72
73
  dom.once('built', async () => {
73
74
  const list = await dom.getTagForElement(document.getElementById('test'));
package/webpack.config.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const path = require('path');
2
2
  const webpack = require("webpack");
3
+ const TerserPlugin = require("terser-webpack-plugin");
3
4
 
4
5
  const defaultConfiguration = {
5
6
  entry: './src/vsn.ts',
@@ -20,6 +21,15 @@ const defaultConfiguration = {
20
21
  filename: 'vsn.min.js',
21
22
  path: path.resolve(__dirname, 'dist'),
22
23
  },
24
+ optimization: {
25
+ minimizer: [new TerserPlugin({
26
+ terserOptions: {
27
+ format: {
28
+ preamble: `/* Copyright ${new Date().getUTCFullYear()}, VSNjs. ${require('./package.json').name} ${require('./package.json').version} (${new Date().toUTCString()}) */if (window) window['VSN_VERSION']='${require('./package.json').version}';`
29
+ }
30
+ }
31
+ })],
32
+ }
23
33
  };
24
34
 
25
35
  function buildConfig(env) {