vaderjs 1.9.5 → 1.9.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.
Files changed (3) hide show
  1. package/index.ts +13 -8
  2. package/main.js +3 -1
  3. package/package.json +1 -1
package/index.ts CHANGED
@@ -37,13 +37,15 @@ declare global {
37
37
  //@ts-ignore
38
38
  globalThis.isServer = typeof window === "undefined";
39
39
  //@ts-ignore
40
- globalThis.params = {
41
- [Symbol.iterator]: function* () {
42
- for (const key in this) {
43
- yield [key, this[key]];
44
- }
45
- },
46
- };
40
+ if(isServer){
41
+ globalThis.params = {
42
+ [Symbol.iterator]: function* () {
43
+ for (const key in this) {
44
+ yield [key, this[key]];
45
+ }
46
+ },
47
+ };
48
+ }
47
49
 
48
50
 
49
51
 
@@ -153,9 +155,12 @@ export const e = (element, props, ...children) => {
153
155
  firstEl = { type: "div", props: { key: instance.key, ...props }, children };
154
156
  firstEl.props = { key: instance.key, ...firstEl.props, ...props };
155
157
  firstEl.props["idKey"] = instance.key;
156
- instance.props = firstEl.props;
158
+ instance.props = firstEl.props;
157
159
  return firstEl;
158
160
  default:
161
+ if(!element) {
162
+ return "";
163
+ }
159
164
  let el = { type: element, props: props || {}, children: children || [] };
160
165
  if (el.type !== "head") {
161
166
  el.props = { idKey: crypto.randomUUID(), ...el.props };
package/main.js CHANGED
@@ -216,11 +216,13 @@ async function generateApp() {
216
216
  r = r.replace(process.cwd().replace(/\\/g, '/') + '/app', '')
217
217
  r = r.replace('.jsx', '.js').replace('.tsx', '.js')
218
218
  fs.mkdirSync(path.join(process.cwd() + '/dist', path.dirname(r)), { recursive: true })
219
+ let params = routes.match(route).params || {}
220
+ // handle route params multiple and
219
221
  fs.writeFileSync(process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r), `
220
222
  let route = window.location.pathname.split('/').filter(v => v !== '')
221
223
  let params = {
222
224
  ${Object.keys(routes.match(route).params || {}).length > 0 ? Object.keys(routes.match(route).params || {}).map(p => {
223
- return `${p}: route[${Object.keys(routes.match(route).params).indexOf(p) + Object.keys(routes.match(route).params).length}]`
225
+ return `${p}: route[${Object.keys(routes.match(route).params || {}).indexOf(p)}]`
224
226
  }).join(',') : ""}
225
227
  }
226
228
  \n${code}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.9.5",
3
+ "version": "1.9.7",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"