vaderjs 1.2.6 → 1.2.8

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "className":{
3
-
3
+ "name":"className"
4
4
  }
5
5
  }
package/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @version 1.1.5
5
5
  *
6
6
  */
7
- import Vader, { include, useRef } from './vader.js';
7
+ import Vader, { include} from './vader.js';
8
8
  // @ts-ignore
9
9
  import VaderRouter from './vaderRouter.js';
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "A Reactive Framework for Single-Page Applications (SPA)",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -62,6 +62,23 @@ or
62
62
  ```
63
63
  ## Key Features
64
64
 
65
+ ### Client Fly Rendering
66
+
67
+ Vaderjs allows you to render your components & manipulate worker side vs main thread. This allows for faster page speeds and better user experience.
68
+
69
+ ```javascript
70
+ import Vader from "vaderjs";
71
+ class Home extends Vader.Component {
72
+ constructor() {
73
+ super();
74
+ this.cfr = true; // enable client fly rendering - this is optionals
75
+ }
76
+ render() {
77
+ return this.html(`<div>Hello World</div>`);
78
+ }
79
+ }
80
+ ```
81
+
65
82
  ### Declarative Routing
66
83
 
67
84
  ```javascript
@@ -202,13 +219,21 @@ export class App extends Vader.Component{
202
219
  As of v1.1.0 - Vader allows you to include html files as templates
203
220
 
204
221
  ```html
205
- // views/app.html
222
+ // views/app.vjs
223
+ <body>
224
+ <div>Hello World</div>
225
+ <h1>{{title}}</h1>
226
+ <slot id="app" />
227
+ </body>
228
+ ```
229
+ ```html
230
+ // pages/app.html
231
+ <include src="views/app.vjs"/>
232
+ <body>
233
+ <app tittle="this is a component">
234
+ <div> this is apps children! </div>
235
+ </app>
206
236
 
207
- <div>
208
- ${
209
- window.location.hash === "#/home" ? "Home page" : "Not on the Home Page"
210
- }
211
- </div>
212
237
  ```
213
238
 
214
239
  ```js
@@ -220,7 +245,7 @@ class Home extends Vader.Component {
220
245
  super();
221
246
  }
222
247
  render() {
223
- return this.html(include("views/app.html"));
248
+ return this.html(include("pages/app.html"));
224
249
  }
225
250
  }
226
251
 
@@ -0,0 +1,17 @@
1
+ // A launch configuration that launches the extension inside a new window
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ {
6
+ "version": "0.2.0",
7
+ "configurations": [
8
+ {
9
+ "name": "Extension",
10
+ "type": "extensionHost",
11
+ "request": "launch",
12
+ "args": [
13
+ "--extensionDevelopmentPath=${workspaceFolder}"
14
+ ]
15
+ }
16
+ ]
17
+ }
@@ -0,0 +1,4 @@
1
+ .vscode/**
2
+ .vscode-test/**
3
+ .gitignore
4
+ vsc-extension-quickstart.md
@@ -0,0 +1,9 @@
1
+ # Change Log
2
+
3
+ All notable changes to the "vader" extension will be documented in this file.
4
+
5
+ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6
+
7
+ ## [Unreleased]
8
+
9
+ - Initial release
@@ -0,0 +1,26 @@
1
+ # vader README
2
+
3
+
4
+ ## Features
5
+
6
+ HTML syntax highlighting for vader files & intellisense / autocomplete for html elements and vader.js methods
7
+
8
+ Shows deprecated methods as deprecated in the intellisense - and shows suggestions for alternatives
9
+
10
+ ## Requirements
11
+
12
+ Common knowlege of HTML and vader.js!
13
+
14
+
15
+ ## Known Issues
16
+
17
+
18
+
19
+ ## Release Notes
20
+
21
+ Users appreciate release notes as you update your extension.
22
+
23
+ ### 1.0.0
24
+
25
+ Initial release of vader
26
+
@@ -0,0 +1,70 @@
1
+ const vscode = require('vscode');
2
+ const html_completes = require('./html_completion/html_completion');
3
+ function activate(context) {
4
+
5
+ let completes = []
6
+ const include = vscode.languages.registerCompletionItemProvider(
7
+ 'vader',
8
+ {
9
+ provideCompletionItems(document, position) {
10
+ const linePrefix = document.lineAt(position).text.trim();
11
+ if(!linePrefix.startsWith('in')) {
12
+ return undefined;
13
+ }
14
+ let complete = new vscode.CompletionItem('include()', vscode.CompletionItemKind.Function);
15
+ complete.insertText = new vscode.SnippetString('include("${1:file}")');
16
+
17
+ complete.tags = [vscode.CompletionItemTag.Deprecated]
18
+
19
+ complete.documentation = new vscode.MarkdownString(`Include a view file into your template\n - @param \`\string\`\ file - The file to include\n- @returns {string} - the parsed html code to client`, true)
20
+ return [complete]
21
+ }
22
+ },
23
+ )
24
+
25
+ const comment = vscode.languages.registerCompletionItemProvider('vader', {
26
+ provideCompletionItems(document, position) {
27
+ const linePrefix = document.lineAt(position).text.slice(0, position.character);
28
+ if(!linePrefix.includes('-')) {
29
+ return undefined;
30
+ }
31
+ let complete = new vscode.CompletionItem('-', vscode.CompletionItemKind.Property);
32
+ complete.insertText = new vscode.SnippetString('-- \n ${1:comment} \n--');
33
+ complete.documentation = new vscode.MarkdownString(`Create a multi line comment`, true)
34
+ return [complete]
35
+
36
+ },
37
+ }, )
38
+
39
+ const syntaxeror = vscode.languages.registerCompletionItemProvider('vader', {
40
+ provideCompletionItems(document, position) {
41
+ let firstline = document.lineAt(0).text.trim();
42
+ let lastline = document.lineAt(document.lineCount - 1).text.trim();
43
+ if(!firstline.includes('body') || !lastline.includes('body')) {
44
+
45
+ vscode.window.showWarningMessage('Syntax error: missing <body> tag in template\n vader may cut off your code if not present')
46
+
47
+ return undefined;
48
+ }
49
+ },
50
+ })
51
+
52
+
53
+
54
+
55
+ const includehover = vscode.languages.registerHoverProvider('vader', {
56
+ provideHover(document, position) {
57
+ const linePrefix = document.lineAt(position).text.slice(0, position.character);
58
+ if (!linePrefix.startsWith('in')) {
59
+ return undefined;
60
+ }
61
+ let complete = new vscode.Hover(new vscode.MarkdownString(`Include a view file into your template\n - @param {string} file - The file to include\n- @returns {string} - the parsed html code to client`, true))
62
+ return complete
63
+ }
64
+ })
65
+
66
+
67
+ context.subscriptions.push(include, html_completes, comment, includehover, syntaxeror,completes);
68
+ }
69
+
70
+ module.exports.activate = activate;
@@ -0,0 +1,91 @@
1
+ const vscode = require('vscode');
2
+ let completes = []
3
+ const html_completes = vscode.languages.registerCompletionItemProvider('vader', {
4
+ provideCompletionItems(document, position) {
5
+ let line = document.lineAt(position).text.trim();
6
+
7
+ let {tags, attributes} = JSON.parse(require('fs').readFileSync(require('path').join(__dirname, 'html_completion.json'), 'utf8'))
8
+
9
+ let items = []
10
+
11
+
12
+
13
+ for(tag in tags){
14
+
15
+ if(!line.startsWith('<') && !line.endsWith('>')){
16
+ continue
17
+ }
18
+ let complete = new vscode.CompletionItem(tag, tags[tag].type && tags[tag].type === "keyword" ? vscode.CompletionItemKind.Keyword : vscode.CompletionItemKind.Module);
19
+ // make sure its not in range between a entering < and closing > with a space in between
20
+ if(line.startsWith('<') && line.endsWith('>') && line.includes(' ')){
21
+ // remove the tag from the completion
22
+ let line = document.lineAt(position).text.trim();
23
+ complete.range = new vscode.Range(new vscode.Position(position.line, line.indexOf('<')), new vscode.Position(position.line, line.indexOf('<') + tag.length))
24
+ }
25
+ complete.insertText = new vscode.SnippetString(tags[tag].body);
26
+ if(tags[tag].deprecated){
27
+ complete.tags = [vscode.CompletionItemTag.Deprecated]
28
+ }
29
+ complete.documentation = new vscode.MarkdownString(tags[tag].description, true)
30
+ items.push(complete)
31
+ }
32
+ for(attribute in attributes){
33
+ let line = document.lineAt(position).text.trim();
34
+ if(line.includes('<') || line.includes('>') ){
35
+ let tag = line.split('<')[1] ? line.split('<')[1].split('>')[0].split(' ')[0] : line.split('>')[0]
36
+ let valid_in = attributes[attribute].valid_in
37
+ if(valid_in.includes(tag) || valid_in.includes('*')){
38
+ let complete = new vscode.CompletionItem(attribute, vscode.CompletionItemKind.Property);
39
+ if(attributes[attribute].deprecated){
40
+ complete.tags = [vscode.CompletionItemTag.Deprecated]
41
+ }
42
+ complete.insertText = new vscode.SnippetString(attributes[attribute].body);
43
+ complete.documentation = new vscode.MarkdownString(attributes[attribute].description, true)
44
+ items.push(complete)
45
+ }
46
+
47
+
48
+
49
+ }
50
+ }
51
+ return items
52
+ },
53
+ } , )
54
+
55
+ const hovercompletes = vscode.languages.registerHoverProvider('vader', {
56
+ provideHover(document, position) {
57
+ let selection = document.getText(document.getWordRangeAtPosition(position));
58
+
59
+
60
+ let {tags, attributes} = JSON.parse(require('fs').readFileSync(require('path').join(__dirname, 'html_completion.json'), 'utf8'))
61
+ let line = document.lineAt(position.line).text.trim();
62
+
63
+ // make sure no attributes are in the hover position
64
+ if (selection === line.split('<')[1].split('>')[0].split(' ')[0]) {
65
+ let tag = line.split('<')[1].split('>')[0].split(' ')[0]
66
+ if (tags[tag]) {
67
+ return new vscode.Hover(new vscode.MarkdownString(tags[tag].description, true))
68
+ }
69
+ }
70
+ // get the parent tag
71
+ let parent_tag = line.split('<')[1].split('>')[0].split(' ')[0]
72
+ // get the attribute
73
+ let tag_attributes = line.split('<')[1].split('>')[0].split(' ')
74
+ for (let i = 0; i < tag_attributes.length; i++) {
75
+ let attribute = tag_attributes[i]
76
+ if (attribute.includes('=')) {
77
+ attribute = attribute.split('=')[0]
78
+ }
79
+ if (attribute === selection) {
80
+ if (attributes[attribute]) {
81
+ return new vscode.Hover(new vscode.MarkdownString(attributes[attribute].description, true))
82
+ }
83
+ }
84
+ }
85
+
86
+ return null; // Return null if no matching tag or attribute is found.
87
+ }
88
+ });
89
+ completes.push(html_completes, hovercompletes)
90
+
91
+ module.exports = completes