vaderjs 1.1.5 → 1.1.7

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/jsconfig.json CHANGED
@@ -6,5 +6,12 @@
6
6
  "module": "commonjs",
7
7
  "alwaysStrict": true
8
8
 
9
- }
9
+ },
10
+ "exclude": [
11
+ "node_modules",
12
+ "dist"
13
+ ],
14
+ "include": [
15
+ "**/*.js"
16
+ ]
10
17
  }
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "A Reactive Framework for Single-Page Applications (SPA)",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "tsc",
8
- "lint:types": "tsc"
7
+ "test": "tsc --noEmit "
9
8
  },
10
9
  "repository": {
11
10
  "type": "git",
package/readme.md CHANGED
@@ -54,6 +54,12 @@ or
54
54
 
55
55
  4. Create dynamic SPAs with enhanced user experiences.
56
56
 
57
+ 5. Type checking / testing
58
+ - Vader has jsdoc annotations built in but also allows ts using the tsconfig
59
+
60
+ ```bash
61
+ npm run test // validate your code
62
+ ```
57
63
  ## Key Features
58
64
 
59
65
  ### Declarative Routing
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2016",
4
+ "module": "commonjs",
5
+ "allowJs": true,
6
+ "checkJs": true
7
+
8
+ },
9
+ "include": [
10
+ "**/*.js"
11
+ ],
12
+ "exclude": [
13
+ "node_modules",
14
+ "dist",
15
+ "website"
16
+ ],
17
+ "compileOnSave": true,
18
+ }
package/vader.js CHANGED
@@ -20,6 +20,8 @@ export const useRef = (ref /** @type {string} */) => {
20
20
  const update = (data) => {
21
21
  // Parse the new HTML data
22
22
  const newDom = new DOMParser().parseFromString(data, "text/html");
23
+
24
+
23
25
  const newHtml = newDom.body.firstChild;
24
26
 
25
27
  if (el) {
package/vaderRouter.js CHANGED
@@ -195,6 +195,11 @@ class VaderRouter {
195
195
  ) {
196
196
  return false;
197
197
  }
198
+ /**
199
+ * @alias query
200
+ * @type {Object}
201
+ * @property {Object} params - The params object.
202
+ */
198
203
  const query = {};
199
204
 
200
205
  const queryString = window.location.hash.substring(1).split("?")[1];
@@ -233,9 +238,7 @@ class VaderRouter {
233
238
  * @description Allows you to perform actions when the currentRoute changes.
234
239
  */
235
240
  const res = {
236
- return: function (data) {
237
- this.hooked = false;
238
- },
241
+
239
242
  render: function (selector, data) {
240
243
  document.querySelector(selector).innerHTML = data;
241
244
  },
@@ -249,7 +252,12 @@ class VaderRouter {
249
252
  this.hooked = false;
250
253
  return false;
251
254
  }
252
-
255
+
256
+ /**
257
+ * @alias kill
258
+ * @description Allows you to kill a route.
259
+ * @param {string} path
260
+ */
253
261
  kill(path) {
254
262
  if (this.routes[path]) {
255
263
  delete this.routes[path];
@@ -310,6 +318,10 @@ class VaderRouter {
310
318
  }
311
319
  }
312
320
 
321
+ /**
322
+ * @alias onload
323
+ * @param {Function} callback
324
+ */
313
325
  onload(callback) {
314
326
  // await dom to be done make sure no new elements are added
315
327
  if (
@@ -333,8 +345,16 @@ class VaderRouter {
333
345
  */
334
346
  on(path, callback) {
335
347
  window.addEventListener("hashchange", () => {
336
- const paramNames = [];
337
- const queryNames = [];
348
+ /**
349
+ * @alias paramNames
350
+ * @typedef {Array}
351
+ */
352
+ const paramNames = new Array();
353
+ /**
354
+ * @alias queryNames
355
+ * @typedef {Array}
356
+ */
357
+ const queryNames = new Array();
338
358
  const parsedPath = path
339
359
  .split("/")
340
360
  .map((part) => {
@@ -381,6 +401,7 @@ class VaderRouter {
381
401
  const params = {};
382
402
 
383
403
  for (let i = 0; i < paramNames.length; i++) {
404
+ // @ts-ignore
384
405
  params[paramNames[i]] = matches[i + 1];
385
406
  }
386
407
  if (
@@ -401,6 +422,7 @@ class VaderRouter {
401
422
  const queryParts = queryString.split("&");
402
423
  for (let i = 0; i < queryParts.length; i++) {
403
424
  const queryParam = queryParts[i].split("=");
425
+ // @ts-ignore
404
426
  query[queryParam[0]] = queryParam[1];
405
427
  }
406
428
  }
@@ -411,9 +433,7 @@ class VaderRouter {
411
433
  method: "POST",
412
434
  };
413
435
  const res = {
414
- return: function (data) {
415
- this.hooked = false;
416
- },
436
+
417
437
  /**
418
438
  * @alias send
419
439
  * @param {String} selector
@@ -425,6 +445,7 @@ class VaderRouter {
425
445
  * res.send('#root', '<h1>Hello World</h1>');
426
446
  * */
427
447
  send: function (selector, data) {
448
+ // @ts-ignore
428
449
  document.querySelector(selector).innerHTML = data;
429
450
  },
430
451
  /**
@@ -436,6 +457,7 @@ class VaderRouter {
436
457
  * @description Allows you to perform actions when the currentRoute changes.
437
458
  */
438
459
  render: function (selector, data) {
460
+ // @ts-ignore
439
461
  document.querySelector(selector).innerHTML = data;
440
462
  },
441
463
  };