@lime-bundles/widget 3.3.0 → 3.4.0
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/dist/index.cjs +31 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +32 -19
- package/dist/index.js.map +1 -1
- package/dist/lime-bundle.global.js +16 -16
- package/dist/lime-bundle.global.js.map +1 -1
- package/docs/react-nextjs.md +14 -5
- package/docs/web-component.md +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -105,14 +105,20 @@ declare class LimeBundleElement extends HTMLElement {
|
|
|
105
105
|
private isMarketHidden;
|
|
106
106
|
private fetchBundle;
|
|
107
107
|
/**
|
|
108
|
-
* Resolve the visitor's
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* the
|
|
108
|
+
* Resolve the visitor's assigned variant for every primary bundle in a link
|
|
109
|
+
* group. Runs in parallel; any assignment failure logs internally and still
|
|
110
|
+
* renders the primary (safe default). The `getLinkGroupAssignment` helper
|
|
111
|
+
* persists the bucket via a first-party cookie; variant attribution is
|
|
112
|
+
* recorded server-side from the cart-line `_lime_bundle_gid` + `_lime_link_group`
|
|
113
|
+
* attributes the cart-add path stamps when an assignment lands on a non-primary
|
|
114
|
+
* variant.
|
|
115
|
+
*
|
|
116
|
+
* When the assignment points to a non-primary variant the SDK swaps in that
|
|
117
|
+
* variant's `ParsedBundle` from the primary's `linkGroup.variants` list. The
|
|
118
|
+
* variant data must already be present in the storefront query response — the
|
|
119
|
+
* SDK does NOT issue a separate metaobject fetch on the hot path.
|
|
114
120
|
*/
|
|
115
|
-
private
|
|
121
|
+
private applyLinkGroupVariants;
|
|
116
122
|
private fetchSingleBundle;
|
|
117
123
|
private fetchProductBundles;
|
|
118
124
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -105,14 +105,20 @@ declare class LimeBundleElement extends HTMLElement {
|
|
|
105
105
|
private isMarketHidden;
|
|
106
106
|
private fetchBundle;
|
|
107
107
|
/**
|
|
108
|
-
* Resolve the visitor's
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* the
|
|
108
|
+
* Resolve the visitor's assigned variant for every primary bundle in a link
|
|
109
|
+
* group. Runs in parallel; any assignment failure logs internally and still
|
|
110
|
+
* renders the primary (safe default). The `getLinkGroupAssignment` helper
|
|
111
|
+
* persists the bucket via a first-party cookie; variant attribution is
|
|
112
|
+
* recorded server-side from the cart-line `_lime_bundle_gid` + `_lime_link_group`
|
|
113
|
+
* attributes the cart-add path stamps when an assignment lands on a non-primary
|
|
114
|
+
* variant.
|
|
115
|
+
*
|
|
116
|
+
* When the assignment points to a non-primary variant the SDK swaps in that
|
|
117
|
+
* variant's `ParsedBundle` from the primary's `linkGroup.variants` list. The
|
|
118
|
+
* variant data must already be present in the storefront query response — the
|
|
119
|
+
* SDK does NOT issue a separate metaobject fetch on the hot path.
|
|
114
120
|
*/
|
|
115
|
-
private
|
|
121
|
+
private applyLinkGroupVariants;
|
|
116
122
|
private fetchSingleBundle;
|
|
117
123
|
private fetchProductBundles;
|
|
118
124
|
/**
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
reportAddToCart,
|
|
13
13
|
injectCustomCss,
|
|
14
14
|
sanitizeCustomCss,
|
|
15
|
-
|
|
16
|
-
applyABVariantB,
|
|
15
|
+
getLinkGroupAssignment,
|
|
17
16
|
hasInContext,
|
|
18
17
|
withInContext
|
|
19
18
|
} from "@lime-bundles/core";
|
|
@@ -4303,7 +4302,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
4303
4302
|
const sanitized = sanitizeCustomCss(css.shop.metafield.value);
|
|
4304
4303
|
if (sanitized.ok) this.shopCustomCss = sanitized.css;
|
|
4305
4304
|
}
|
|
4306
|
-
await this.
|
|
4305
|
+
await this.applyLinkGroupVariants();
|
|
4307
4306
|
this.renderBundles();
|
|
4308
4307
|
} catch (err) {
|
|
4309
4308
|
if (controller.signal.aborted) return;
|
|
@@ -4315,33 +4314,47 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
4315
4314
|
}
|
|
4316
4315
|
}
|
|
4317
4316
|
/**
|
|
4318
|
-
* Resolve the visitor's
|
|
4319
|
-
*
|
|
4320
|
-
*
|
|
4321
|
-
*
|
|
4322
|
-
*
|
|
4323
|
-
* the
|
|
4317
|
+
* Resolve the visitor's assigned variant for every primary bundle in a link
|
|
4318
|
+
* group. Runs in parallel; any assignment failure logs internally and still
|
|
4319
|
+
* renders the primary (safe default). The `getLinkGroupAssignment` helper
|
|
4320
|
+
* persists the bucket via a first-party cookie; variant attribution is
|
|
4321
|
+
* recorded server-side from the cart-line `_lime_bundle_gid` + `_lime_link_group`
|
|
4322
|
+
* attributes the cart-add path stamps when an assignment lands on a non-primary
|
|
4323
|
+
* variant.
|
|
4324
|
+
*
|
|
4325
|
+
* When the assignment points to a non-primary variant the SDK swaps in that
|
|
4326
|
+
* variant's `ParsedBundle` from the primary's `linkGroup.variants` list. The
|
|
4327
|
+
* variant data must already be present in the storefront query response — the
|
|
4328
|
+
* SDK does NOT issue a separate metaobject fetch on the hot path.
|
|
4324
4329
|
*/
|
|
4325
|
-
async
|
|
4330
|
+
async applyLinkGroupVariants() {
|
|
4326
4331
|
if (this.bundles.length === 0) return;
|
|
4332
|
+
const bundleLookupByMetaobjectId = /* @__PURE__ */ new Map();
|
|
4333
|
+
for (const b of this.bundles) {
|
|
4334
|
+
bundleLookupByMetaobjectId.set(b.id, b);
|
|
4335
|
+
}
|
|
4327
4336
|
const results = await Promise.all(
|
|
4328
4337
|
this.bundles.map(async (bundle) => {
|
|
4329
|
-
|
|
4338
|
+
const lg = bundle.linkGroup;
|
|
4339
|
+
if (!lg || !lg.isPrimary || !lg.variants || lg.variants.length < 2) {
|
|
4340
|
+
return bundle;
|
|
4341
|
+
}
|
|
4330
4342
|
try {
|
|
4331
|
-
const assignment = await
|
|
4332
|
-
|
|
4333
|
-
|
|
4343
|
+
const assignment = await getLinkGroupAssignment(lg.id, lg.variants);
|
|
4344
|
+
if (!assignment) return bundle;
|
|
4345
|
+
if (assignment.variantMetaobjectId === bundle.id) return bundle;
|
|
4346
|
+
const swap = bundleLookupByMetaobjectId.get(
|
|
4347
|
+
assignment.variantMetaobjectId
|
|
4334
4348
|
);
|
|
4335
|
-
if (
|
|
4336
|
-
|
|
4337
|
-
}
|
|
4349
|
+
if (!swap) return bundle;
|
|
4350
|
+
return swap;
|
|
4338
4351
|
} catch (err) {
|
|
4339
4352
|
console.warn(
|
|
4340
|
-
`[lime-bundle]
|
|
4353
|
+
`[lime-bundle] link-group assignment failed for bundle ${bundle.id}; falling back to primary.`,
|
|
4341
4354
|
err
|
|
4342
4355
|
);
|
|
4356
|
+
return bundle;
|
|
4343
4357
|
}
|
|
4344
|
-
return bundle;
|
|
4345
4358
|
})
|
|
4346
4359
|
);
|
|
4347
4360
|
this.bundles = results;
|