vaderjs 1.0.3 → 1.0.4

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
@@ -2,8 +2,13 @@
2
2
  "compilerOptions": {
3
3
  "allowJs": true,
4
4
  "checkJs": true,
5
-
5
+ "jsx": "react",
6
+ "module": "esnext",
7
+ "moduleResolution": "node",
8
+ "noEmit": true,
9
+ "strict": true, // Enforce strict type checking
10
+ "forceConsistentCasingInFileNames": true, // Ensures consistent file name casing
11
+ "noImplicitAny": true,
6
12
  },
7
- "include": ["/"],
8
-
9
- }
13
+ "include": ["/"]
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A Reactive Framework for Single-Page Applications (SPA)",
5
5
  "main": "vader.js",
6
6
  "scripts": {
package/vader.js CHANGED
@@ -310,6 +310,7 @@ export function component(name, options) {
310
310
  window.useEffect = useEffect;
311
311
  window.useAuth = useAuth;
312
312
  window.useSyncStore = useSyncStore;
313
+
313
314
  const updateComponent = () => {
314
315
  const componentContainer = document.querySelector(
315
316
  `[data-component="${name}"]`
@@ -332,7 +333,7 @@ export function component(name, options) {
332
333
  * @returns
333
334
  */
334
335
 
335
- const render = (props) => {
336
+ const render = async (props) => {
336
337
  storedProps = props;
337
338
  const componentContainer = document.querySelector(
338
339
  `[data-component="${name}"]`
@@ -340,14 +341,14 @@ export function component(name, options) {
340
341
  if (componentContainer) {
341
342
  runEffects();
342
343
 
343
- componentContainer.innerHTML = options.render(
344
+ componentContainer.innerHTML = await options.render(
344
345
  states,
345
346
  (storedProps = null)
346
347
  );
347
348
  } else {
348
349
  return vhtml`
349
350
  <div data-component="${name}">
350
- ${options.render(
351
+ ${await options.render(
351
352
  states,
352
353
  props
353
354
  )}
@@ -371,3 +372,22 @@ export function component(name, options) {
371
372
  export const rf = (name, fn) => {
372
373
  window[name] = fn;
373
374
  };
375
+ /**
376
+ * @function include
377
+ * @description Allows you to include html file
378
+ * @returns - modified string with html content
379
+ * @param {string} path
380
+ */
381
+
382
+ export const include = (path) => {
383
+ return fetch(`./${path}`)
384
+ .then((res) => {
385
+ if(res.status === 404){
386
+ throw new Error(`No file found at ${path}`)
387
+ }
388
+ return res.text()
389
+ })
390
+ .then((data) => {
391
+ return new Function(`return \`${data}\`;`)()
392
+ })
393
+ };
package/vaderRouter.js CHANGED
@@ -81,7 +81,15 @@ class VaderRouter {
81
81
  status: 404,
82
82
  message: "Page not found",
83
83
  };
84
- this.handleError("404", errBody);
84
+ const res = {
85
+ return: function (data) {
86
+ this.hooked = false;
87
+ },
88
+ render: function (selector, data) {
89
+ document.querySelector(selector).innerHTML = data;
90
+ }
91
+ }
92
+ this.handleError("404", errBody, res);
85
93
  }
86
94
  });
87
95
  }
@@ -111,9 +119,9 @@ class VaderRouter {
111
119
  * @description used by start() to handle errors.
112
120
  */
113
121
 
114
- handleError(type, data) {
122
+ handleError(type, data, res) {
115
123
  if (this.errorHandlers[type]) {
116
- this.errorHandlers[type](data);
124
+ this.errorHandlers[type](data, res);
117
125
  } else {
118
126
  console.error(`No error handler found for type: ${type}`);
119
127
  }
@@ -1,20 +0,0 @@
1
- <header>
2
- <div>
3
- <h1>Header</h1>
4
- <test
5
- ${props.styles}
6
- >${props.color}</test>
7
-
8
- ${
9
- function(){
10
-
11
- if(props.color === 'red'){
12
- return `<h1>Red</h1>`
13
- }else{
14
- return `<h1>Not Red</h1>`
15
- }
16
-
17
- }()
18
- }
19
- </div>
20
- </header>
package/config.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "port": 3001,
3
- "type": "http",
4
- "origin": "http://localhost:3000",
5
- "path": "/api"
6
-
7
- }