@cfdez11/vex 0.8.1 → 0.8.2

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/README.md CHANGED
@@ -697,6 +697,11 @@ sequenceDiagram
697
697
  - [x] `vex.config.json` — configurable `srcDir` and `watchIgnore`
698
698
  - [x] Published to npm as `@cfdez11/vex`
699
699
  - [x] VS Code extension with syntax highlighting and go-to-definition
700
+ - [ ] Refactor client component prop pipeline: evaluate `:props` expressions directly in `streaming.js` with the page scope instead of going through `template.js` → `String()` → `JSON.stringify` → `JSON.parse`. Eliminates the unnecessary serialization round-trip for array/object props.
701
+ - [ ] esbuild minification: enable `minify: true` in `generateClientBundle` and `buildUserFile` for production builds. Zero-cost win — esbuild is already in the pipeline.
702
+ - [ ] esbuild source maps: enable `sourcemap: "inline"` in dev mode so browser devtools show original source instead of the bundle.
703
+ - [ ] esbuild browser target: add `target: ["es2020"]` (or configurable) to transpile modern syntax for broader browser compatibility.
704
+ - [ ] esbuild code splitting: shared npm packages (e.g. `date-fns`) are currently inlined into every component bundle separately. Code splitting would emit a shared chunk, reducing total download size when multiple components share the same dependency.
700
705
  - [ ] Devtools
701
706
  - [ ] Typescript in framework
702
707
  - [ ] Allow typescript to devs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfdez11/vex",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "A vanilla JavaScript meta-framework with file-based routing, SSR/CSR/SSG/ISR and Vue-like reactivity",
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -28,12 +28,20 @@ import {
28
28
  * // id: 'my-component'
29
29
  * // }
30
30
  */
31
+ function decodeAttrValue(raw) {
32
+ const decoded = raw.replace(/"/g, '"');
33
+ if (decoded.startsWith("[") || decoded.startsWith("{")) {
34
+ try { return JSON.parse(decoded); } catch {}
35
+ }
36
+ return decoded;
37
+ }
38
+
31
39
  function parseAttributes(rawAttrs) {
32
40
  const attrs = {};
33
41
  const regex =
34
42
  /:([\w-]+)=(?:"([^"]*)"|'([^']*)')|@([\w-]+)=(?:"([^"]*)"|'([^']*)')|([\w:-]+)=(?:"([^"]*)"|'([^']*)')/g;
35
43
  let match;
36
-
44
+
37
45
  while ((match = regex.exec(rawAttrs)) !== null) {
38
46
  if (match[1]) {
39
47
  // Dynamic prop :prop
@@ -42,8 +50,8 @@ function parseAttributes(rawAttrs) {
42
50
  // Event handler @event
43
51
  attrs[match[4]] = match[5] ?? match[6] ?? "";
44
52
  } else if (match[7]) {
45
- // Static prop
46
- attrs[match[7]] = match[8] ?? match[9] ?? "";
53
+ // Static prop — decode " and recover arrays/objects serialized by template.js
54
+ attrs[match[7]] = decodeAttrValue(match[8] ?? match[9] ?? "");
47
55
  }
48
56
  }
49
57
 
@@ -154,15 +154,23 @@ function processNode(node, scope, previousRendered = false) {
154
154
  const isSuspenseFallback =
155
155
  name === ":fallback" && node.name === "Suspense";
156
156
  const realName = name.slice(1);
157
- attrs[realName] = !isSuspenseFallback
158
- ? String(getDataValue(value, scope))
159
- : value;
157
+ if (!isSuspenseFallback) {
158
+ const val = getDataValue(value, scope);
159
+ attrs[realName] = (val !== null && val !== undefined && typeof val === "object")
160
+ ? JSON.stringify(val)
161
+ : String(val ?? "");
162
+ } else {
163
+ attrs[realName] = value;
164
+ }
160
165
  delete attrs[name];
161
166
  }
162
167
 
163
168
  if (name.startsWith("x-bind:")) {
164
169
  const realName = name.slice(7);
165
- attrs[realName] = String(getDataValue(value, scope));
170
+ const val = getDataValue(value, scope);
171
+ attrs[realName] = (val !== null && val !== undefined && typeof val === "object")
172
+ ? JSON.stringify(val)
173
+ : String(val ?? "");
166
174
  delete attrs[name];
167
175
  }
168
176
  }