@primestyleai/tryon 5.10.105 → 5.10.106

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.
@@ -1,46 +1,4 @@
1
1
  "use client";
2
- const TAG$3 = "[primestyle-shadow]";
3
- const collected = [];
4
- if (typeof document !== "undefined" && document.head) {
5
- let shouldCapture = function(node) {
6
- return node instanceof HTMLStyleElement;
7
- };
8
- const origAppend = document.head.appendChild.bind(document.head);
9
- const origInsertBefore = document.head.insertBefore.bind(document.head);
10
- document.head.appendChild = function(node) {
11
- if (shouldCapture(node)) {
12
- collected.push(node);
13
- console.log(`${TAG$3} captured style tag (${node.textContent?.length ?? 0} chars)`);
14
- }
15
- return origAppend(node);
16
- };
17
- document.head.insertBefore = function(node, ref) {
18
- if (shouldCapture(node)) {
19
- collected.push(node);
20
- console.log(`${TAG$3} captured style tag via insertBefore (${node.textContent?.length ?? 0} chars)`);
21
- }
22
- return origInsertBefore(node, ref);
23
- };
24
- }
25
- function getCollectedCss() {
26
- const parts = [];
27
- for (const el2 of collected) {
28
- const text = el2.textContent;
29
- if (text) parts.push(text);
30
- }
31
- return parts.join("\n\n");
32
- }
33
- function injectStylesIntoShadow(shadow) {
34
- const css = getCollectedCss();
35
- if (!css) {
36
- console.warn(`${TAG$3} no SDK styles collected — widget may render unstyled`);
37
- return;
38
- }
39
- const style = document.createElement("style");
40
- style.setAttribute("data-primestyle", "sdk-styles");
41
- style.textContent = css;
42
- shadow.appendChild(style);
43
- }
44
2
  var react = { exports: {} };
45
3
  var react_production_min = {};
46
4
  /**
@@ -30333,29 +30291,10 @@ async function mount(el2) {
30333
30291
  props.sizeGuideData = fetched;
30334
30292
  }
30335
30293
  }
30336
- let shadow;
30337
- try {
30338
- shadow = el2.shadowRoot ?? el2.attachShadow({ mode: "open" });
30339
- injectStylesIntoShadow(shadow);
30340
- } catch (err) {
30341
- console.warn(`${TAG} shadow attach failed — falling back to direct mount`, err);
30342
- shadow = el2;
30343
- }
30344
- let mountTarget;
30345
- if (shadow instanceof ShadowRoot) {
30346
- mountTarget = shadow.querySelector("[data-primestyle-mount]") ?? (() => {
30347
- const c = document.createElement("div");
30348
- c.setAttribute("data-primestyle-mount", "");
30349
- shadow.appendChild(c);
30350
- return c;
30351
- })();
30352
- } else {
30353
- mountTarget = shadow;
30354
- }
30355
30294
  if (props.sizeGuideData) {
30356
30295
  try {
30357
30296
  const buttonStyles = props.buttonStyles;
30358
- createSizeGuideButton(mountTarget, props.sizeGuideData, {
30297
+ createSizeGuideButton(el2, props.sizeGuideData, {
30359
30298
  accentColor: buttonStyles?.backgroundColor
30360
30299
  });
30361
30300
  console.log(`${TAG} ✓ size guide button mounted`);
@@ -30364,10 +30303,10 @@ async function mount(el2) {
30364
30303
  }
30365
30304
  }
30366
30305
  try {
30367
- const root = createRoot(mountTarget);
30306
+ const root = createRoot(el2);
30368
30307
  root.render(reactExports.createElement(PrimeStyleTryon, props));
30369
30308
  MOUNTED.set(el2, root);
30370
- console.log(`${TAG} ✓ mounted React component (shadow-isolated)`);
30309
+ console.log(`${TAG} ✓ mounted React component`);
30371
30310
  maybeFireProductView(el2);
30372
30311
  } catch (err) {
30373
30312
  console.error(`${TAG} ✗ React mount failed`, err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.10.105",
3
+ "version": "5.10.106",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",
@@ -1,34 +0,0 @@
1
- /**
2
- * Shadow-DOM style collector.
3
- *
4
- * Vite injects all CSS imported by the storefront bundle as <style>
5
- * tags appended to document.head at module-eval time. Theme app
6
- * extensions render into the merchant's theme DOM, so those styles
7
- * coexist with the merchant's theme CSS — and the theme's CSS leaks
8
- * into our widget (table borders, button resets, font-family, etc).
9
- *
10
- * To isolate the widget inside a shadow root we need our SDK styles
11
- * inside that shadow root, NOT in document.head. The cleanest way to
12
- * intercept vite's runtime injection is to monkey-patch
13
- * `document.head.appendChild` before our other imports evaluate, so
14
- * every <style> tag the SDK emits during module load gets captured
15
- * here and re-injected into each shadow root we mount later.
16
- *
17
- * IMPORTANT: this file MUST be imported as the *first* import of
18
- * `src/storefront/index.ts`, before React or any CSS-importing module.
19
- * ES module evaluation order is import-tree depth-first, so a
20
- * side-effect import at the top of the entry runs before the rest.
21
- */
22
- /**
23
- * Returns CSS text concatenated from every <style> tag captured at
24
- * module load + any <style> tags that were already in document.head
25
- * matching SDK selector patterns (defense-in-depth for cases where
26
- * patching missed an injection).
27
- */
28
- export declare function getCollectedCss(): string;
29
- /**
30
- * Inject the SDK's collected styles into a shadow root so the widget
31
- * looks identical regardless of theme. Idempotent — call once per
32
- * shadow root after attachShadow().
33
- */
34
- export declare function injectStylesIntoShadow(shadow: ShadowRoot): void;