@jay-framework/wix-media 0.19.1 → 0.19.3

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.
@@ -51,22 +51,24 @@ URL format: `https://static.wixstatic.com/media/{mediaId}/v1/{mode}/{params}/fil
51
51
 
52
52
  ## Responsive Images
53
53
 
54
- Use `srcset` and `sizes` to let the browser pick the best image size for the viewport. Generate multiple sizes from the same Wix media URL:
54
+ Use `srcset` and `sizes` to let the browser pick the best image size for the viewport. Generate multiple sizes from the same Wix media URL.
55
+
56
+ **Important:** In `srcset` attributes, commas separate image candidates per the HTML spec. Wix media URL parameters also use commas (`w_400,h_400`). To prevent the browser from splitting URLs at parameter commas, use `%2C` instead of `,` inside `srcset` URLs. The `src` attribute does not need encoding.
55
57
 
56
58
  ```html
57
59
  <img
58
60
  src="{url}/v1/fill/w_400,h_400/file.webp"
59
- srcset="{url}/v1/fill/w_300,h_300/file.webp 300w,
60
- {url}/v1/fill/w_400,h_400/file.webp 400w,
61
- {url}/v1/fill/w_600,h_600/file.webp 600w,
62
- {url}/v1/fill/w_800,h_800/file.webp 800w"
61
+ srcset="{url}/v1/fill/w_300%2Ch_300/file.webp 300w,
62
+ {url}/v1/fill/w_400%2Ch_400/file.webp 400w,
63
+ {url}/v1/fill/w_600%2Ch_600/file.webp 600w,
64
+ {url}/v1/fill/w_800%2Ch_800/file.webp 800w"
63
65
  sizes="(max-width: 600px) 100vw, (max-width: 900px) 50vw, 25vw"
64
66
  alt="description"
65
67
  />
66
68
  ```
67
69
 
68
- - `src` — fallback for browsers that don't support srcset
69
- - `srcset` — candidate images with their width in pixels (`w` descriptor)
70
+ - `src` — fallback for browsers that don't support srcset (use `,` normally)
71
+ - `srcset` — candidate images with their width in pixels (`w` descriptor) — use `%2C` for commas in URL paths
70
72
  - `sizes` — tells the browser how wide the image will be at each breakpoint
71
73
 
72
74
  Match `sizes` to your CSS layout (grid columns, container widths). The browser combines `sizes` with the device pixel ratio to pick the smallest sufficient image from `srcset`.
@@ -76,9 +78,9 @@ For hero/banner images that span the full viewport:
76
78
  ```html
77
79
  <img
78
80
  src="{url}/v1/fill/w_1200,h_600/file.webp"
79
- srcset="{url}/v1/fill/w_600,h_300/file.webp 600w,
80
- {url}/v1/fill/w_1200,h_600/file.webp 1200w,
81
- {url}/v1/fill/w_1920,h_960/file.webp 1920w"
81
+ srcset="{url}/v1/fill/w_600%2Ch_300/file.webp 600w,
82
+ {url}/v1/fill/w_1200%2Ch_600/file.webp 1200w,
83
+ {url}/v1/fill/w_1920%2Ch_960/file.webp 1920w"
82
84
  sizes="100vw"
83
85
  alt="description"
84
86
  />
package/dist/index.js CHANGED
@@ -11,7 +11,9 @@ import * as path$1 from "node:path";
11
11
  const WIXSTATIC_MEDIA_RE = /static\.wixstatic\.com\/media\//;
12
12
  const V1_TRANSFORM_RE = /\/v1\//;
13
13
  const IMAGE_EXTENSIONS_RE = /\.(jpe?g|png|gif|webp|svg|bmp|ico)$/i;
14
+ const SRCSET_UNENCODED_COMMA_RE = /\/v1\/[^/]+\/[^/]*[a-z]_\d+,[a-z]_\d+/;
14
15
  const MEDIA_SRC_ATTRS = ["src", "poster"];
16
+ const MEDIA_SRCSET_ATTRS = ["srcset"];
15
17
  const MEDIA_ELEMENTS = /* @__PURE__ */ new Set(["img", "video", "source"]);
16
18
  function checkStaticWixUrl(value) {
17
19
  return WIXSTATIC_MEDIA_RE.test(value) && !V1_TRANSFORM_RE.test(value);
@@ -55,7 +57,7 @@ const validate = (ctx) => {
55
57
  } else if (isLocalImagePath(staticValue)) {
56
58
  findings.push({
57
59
  severity: "error",
58
- message: "Local image reference — upload to Wix Media Manager and use a Wix media URL with optimization parameters. See agent-kit/wix-media.md.",
60
+ message: `Local image reference '${staticValue}' run \`jay-stack-cli run wix-media/upload-public\` to upload local images to Wix Media Manager, then use the Wix media URL with optimization parameters. See agent-kit/wix-media.md.`,
59
61
  element: `<${tagName}>`,
60
62
  attribute: attr
61
63
  });
@@ -78,6 +80,23 @@ const validate = (ctx) => {
78
80
  }
79
81
  }
80
82
  }
83
+ for (const attr of MEDIA_SRCSET_ATTRS) {
84
+ const value = el.getAttribute(attr);
85
+ if (!value) continue;
86
+ const parts = parseTemplateParts(value);
87
+ for (const part of parts) {
88
+ if (part.kind !== "static") continue;
89
+ if (SRCSET_UNENCODED_COMMA_RE.test(part.value)) {
90
+ findings.push({
91
+ severity: "error",
92
+ message: "Wix media URL in srcset has unencoded commas in parameters (e.g. w_400,h_300). The srcset attribute uses commas to separate image candidates, so commas inside URLs must be encoded as %2C (e.g. w_400%2Ch_300). See agent-kit/wix-media.md.",
93
+ element: `<${tagName}>`,
94
+ attribute: attr
95
+ });
96
+ break;
97
+ }
98
+ }
99
+ }
81
100
  });
82
101
  return findings;
83
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/wix-media",
3
- "version": "0.19.1",
3
+ "version": "0.19.3",
4
4
  "type": "module",
5
5
  "description": "Wix Media Manager plugin for Jay Framework — media validation, index generation, and agent-kit references",
6
6
  "license": "Apache-2.0",
@@ -25,19 +25,19 @@
25
25
  "test": "vitest run"
26
26
  },
27
27
  "dependencies": {
28
- "@jay-framework/compiler-jay-html": "^0.19.1",
29
- "@jay-framework/compiler-shared": "^0.19.1",
30
- "@jay-framework/component": "^0.19.1",
31
- "@jay-framework/fullstack-component": "^0.19.1",
32
- "@jay-framework/stack-server-runtime": "^0.19.1",
33
- "@jay-framework/wix-server-client": "^0.19.1",
34
- "@jay-framework/wix-utils": "^0.19.1",
28
+ "@jay-framework/compiler-jay-html": "^0.19.3",
29
+ "@jay-framework/compiler-shared": "^0.19.3",
30
+ "@jay-framework/component": "^0.19.3",
31
+ "@jay-framework/fullstack-component": "^0.19.3",
32
+ "@jay-framework/stack-server-runtime": "^0.19.3",
33
+ "@jay-framework/wix-server-client": "^0.19.3",
34
+ "@jay-framework/wix-utils": "^0.19.3",
35
35
  "@wix/media": "^1.0.247",
36
36
  "@wix/sdk": "^1.21.5"
37
37
  },
38
38
  "devDependencies": {
39
- "@jay-framework/compiler-jay-stack": "^0.19.1",
40
- "@jay-framework/vite-plugin": "^0.19.1",
39
+ "@jay-framework/compiler-jay-stack": "^0.19.3",
40
+ "@jay-framework/vite-plugin": "^0.19.3",
41
41
  "@types/node": "^20.11.0",
42
42
  "node-html-parser": "^6.1.0",
43
43
  "rimraf": "^5.0.5",