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

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.19",
4
4
  "description": "Web Component to preview GLTF models with Babylon.js",
5
5
  "author": "Alex Moreno Palacio <amoreno@preference.es>",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
- import "@panzoom/panzoom";
1
+ // Explicitly target the ESM bundle so esbuild (platform=node) picks up the default export.
2
+ import Panzoom from "@panzoom/panzoom/dist/panzoom.es.js";
2
3
 
3
4
  /**
4
5
  * PanzoomController - Encapsulates the logic for managing pan and zoom interactions on a given DOM element.
@@ -161,7 +161,7 @@ export default class PrefViewer3D extends HTMLElement {
161
161
 
162
162
  this.#canvas = document.createElement("canvas");
163
163
  this.#wrapper.appendChild(this.#canvas);
164
-
164
+
165
165
  const style = document.createElement("style");
166
166
  style.textContent = PrefViewer3DStyles;
167
167
  this.append(style);
@@ -421,7 +421,7 @@ export default class PrefViewer3D extends HTMLElement {
421
421
  tried: toSetDetail,
422
422
  success: settedDetail,
423
423
  };
424
-
424
+
425
425
  const customEventOptions = {
426
426
  bubbles: true,
427
427
  cancelable: true,
@@ -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