@preference-sl/pref-viewer 2.11.0-beta.17 → 2.11.0-beta.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preference-sl/pref-viewer",
3
- "version": "2.11.0-beta.17",
3
+ "version": "2.11.0-beta.18",
4
4
  "description": "Web Component to preview GLTF models with Babylon.js",
5
5
  "author": "Alex Moreno Palacio <amoreno@preference.es>",
6
6
  "scripts": {
@@ -121,6 +121,29 @@ export default class SVGResolver {
121
121
  return [value, size];
122
122
  }
123
123
 
124
+ // Some payloads are base64 of UTF-16 strings, which leave NUL bytes after atob; strip them and retry.
125
+ const cleanedDecoded = decoded.replace(/\u0000/g, "");
126
+ if (cleanedDecoded !== decoded && isSvg(cleanedDecoded)) {
127
+ size = raw.length;
128
+ value = cleanedDecoded;
129
+ return [value, size];
130
+ }
131
+
132
+ // Last resort: attempt decoding the binary buffer as UTF-16LE when available (TextDecoder is native in browsers).
133
+ if (typeof TextDecoder !== "undefined") {
134
+ try {
135
+ const bytes = Uint8Array.from(decoded, (c) => c.charCodeAt(0));
136
+ const utf16 = new TextDecoder("utf-16le").decode(bytes);
137
+ if (isSvg(utf16)) {
138
+ size = raw.length;
139
+ value = utf16;
140
+ return [value, size];
141
+ }
142
+ } catch {
143
+ // ignore and fall through
144
+ }
145
+ }
146
+
124
147
  return [value, size];
125
148
  }
126
149