@replohq/sdk 2.20.0 → 2.20.2
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/README.md +3 -173
- package/_vendor/replo-utils/lib/json.d.ts +0 -4
- package/_vendor/replo-utils/lib/json.mjs +1 -4
- package/_vendor/replo-utils/lib/misc.mjs +1 -1
- package/_vendor/replo-utils/lib/object.mjs +89 -3
- package/_vendor/schemas/contentManifest.mjs +1 -3
- package/chunk-B7XDEXPL.mjs +19 -0
- package/consent/replo-scripts.d.ts +2 -6
- package/consent/replo-scripts.js +26 -33
- package/lib/buildMetadata.js +3 -3
- package/package.json +5 -9
- package/chunk-DMJ5VUD6.mjs +0 -89
- package/chunk-QYGRVXWQ.mjs +0 -32
package/README.md
CHANGED
|
@@ -1,177 +1,7 @@
|
|
|
1
1
|
# `@replohq/sdk`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
analytics, consent handling, routing helpers, and Next.js integrations used by
|
|
5
|
-
Replo-powered storefronts.
|
|
3
|
+
React providers, data loaders, cart utilities, analytics, and Next.js integrations for Replo storefronts.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Install, set up, and read the API reference: https://docs.replo.app/sdk
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
pnpm add @replohq/sdk @opennextjs/cloudflare @tanstack/react-query
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
The application must use Next.js 15 or newer and React 18.2 or newer. React,
|
|
16
|
-
React DOM, and their type packages are peer dependencies and are normally
|
|
17
|
-
already present in a Next.js application.
|
|
18
|
-
|
|
19
|
-
## Set up the provider
|
|
20
|
-
|
|
21
|
-
Mount `ReploProvider` once around the application. It provides the query
|
|
22
|
-
client, cart state, analytics, and loader error handling used by the rest of
|
|
23
|
-
the SDK. Render managed third-party scripts separately with `ReploScripts` from
|
|
24
|
-
`@replohq/sdk/consent/replo-scripts`.
|
|
25
|
-
|
|
26
|
-
```tsx
|
|
27
|
-
// app/layout.tsx
|
|
28
|
-
import { ReploProvider } from "@replohq/sdk/providers/replo-provider";
|
|
29
|
-
|
|
30
|
-
export default function RootLayout({ children }: React.PropsWithChildren) {
|
|
31
|
-
return (
|
|
32
|
-
<html lang="en">
|
|
33
|
-
<body>
|
|
34
|
-
<ReploProvider>{children}</ReploProvider>
|
|
35
|
-
</body>
|
|
36
|
-
</html>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`ReploProvider` is an async Server Component. Components that use SDK hooks or
|
|
42
|
-
loaders must render beneath it.
|
|
43
|
-
|
|
44
|
-
## Buy now checkout
|
|
45
|
-
|
|
46
|
-
Use `useBuyNow` from `@replohq/sdk/cart/hooks/use-buy-now` to send a shopper
|
|
47
|
-
directly to checkout. Shopify checkout applies selling plans and discount codes.
|
|
48
|
-
Stripe checkout ignores both, logs a server warning when either is supplied,
|
|
49
|
-
and still creates the checkout session.
|
|
50
|
-
|
|
51
|
-
## Data loaders
|
|
52
|
-
|
|
53
|
-
Data loaders retrieve data from integrations configured for the Replo project.
|
|
54
|
-
Use constants from `DATA_LOADER_KEYS` instead of copying loader-key strings.
|
|
55
|
-
The key selects the integration operation and is also the first part of the
|
|
56
|
-
React Query cache key.
|
|
57
|
-
|
|
58
|
-
Loader components are Client Components that pass data to a render function:
|
|
59
|
-
|
|
60
|
-
```tsx
|
|
61
|
-
// components/product-title.tsx
|
|
62
|
-
"use client";
|
|
63
|
-
|
|
64
|
-
import { ProductLoader } from "@replohq/sdk/loaders/product-loader";
|
|
65
|
-
import { DATA_LOADER_KEYS } from "@replohq/sdk/loaders/loader-keys";
|
|
66
|
-
|
|
67
|
-
export function ProductTitle({ handle }: { handle: string }) {
|
|
68
|
-
return (
|
|
69
|
-
<ProductLoader
|
|
70
|
-
loaderKey={DATA_LOADER_KEYS.SHOPIFY_PRODUCT}
|
|
71
|
-
handle={handle}
|
|
72
|
-
loadingFallback={<p>Loading…</p>}
|
|
73
|
-
fallback={<p>Product unavailable.</p>}
|
|
74
|
-
>
|
|
75
|
-
{(product) => <h1>{product.title}</h1>}
|
|
76
|
-
</ProductLoader>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Loader environments and integrations
|
|
82
|
-
|
|
83
|
-
Loaders fetch on the server: directly during SSR, and through a Server Action
|
|
84
|
-
after hydration. The application needs its Replo project configuration in every
|
|
85
|
-
environment:
|
|
86
|
-
|
|
87
|
-
- During local development and builds, `wrangler.jsonc` must provide
|
|
88
|
-
`CANOPY_API_HOST` and `PROJECT_ID` in `vars`.
|
|
89
|
-
- In a deployed OpenNext/Cloudflare environment, provide the same values as
|
|
90
|
-
runtime bindings.
|
|
91
|
-
- Connect each integration in the Replo project; the site holds no provider
|
|
92
|
-
credentials.
|
|
93
|
-
|
|
94
|
-
Use these public loader components and keys for each configured integration:
|
|
95
|
-
|
|
96
|
-
| Integration | Loader component | `DATA_LOADER_KEYS` value |
|
|
97
|
-
| --- | --- | --- |
|
|
98
|
-
| Shopify Storefront | `ProductLoader` | `SHOPIFY_PRODUCT` |
|
|
99
|
-
| Replo product catalog | `ProductLoader` | `REPLO_PRODUCT` |
|
|
100
|
-
| Shopify Storefront | `CollectionLoader` | `SHOPIFY_COLLECTION` |
|
|
101
|
-
| Shopify Storefront | `CollectionProductsLoader` | `SHOPIFY_COLLECTION_PRODUCTS` |
|
|
102
|
-
| Shopify Storefront | `MetaobjectLoader` | `SHOPIFY_METAOBJECT` |
|
|
103
|
-
| Shopify Storefront | `MetaobjectsLoader` | `SHOPIFY_METAOBJECTS` |
|
|
104
|
-
| Shopify Storefront | `ShopLoader` | `SHOPIFY_SHOP` |
|
|
105
|
-
| Okendo | `OkendoReviewsLoader` | `OKENDO_PRODUCT_REVIEWS` |
|
|
106
|
-
| Okendo | `OkendoReviewAggregateLoader` | `OKENDO_PRODUCT_REVIEW_AGGREGATE` |
|
|
107
|
-
| Rebuy | `RebuyRecommendationsLoader` | `REBUY_RECOMMENDATIONS` |
|
|
108
|
-
| Levanta | `LevantaProductLoader` | `LEVANTA_PRODUCT` |
|
|
109
|
-
| Smile.io | `SmileVipTiersLoader` | `SMILE_IO_VIP_TIERS` |
|
|
110
|
-
| Smile.io | `SmileEarningRulesLoader` | `SMILE_IO_EARNING_RULES` |
|
|
111
|
-
| Smile.io | `SmileRewardsLoader` | `SMILE_IO_REWARDS` |
|
|
112
|
-
| LoyaltyLion | `LoyaltyLionEarningRulesLoader` | `LOYALTYLION_EARNING_RULES` |
|
|
113
|
-
| LoyaltyLion | `LoyaltyLionRewardsLoader` | `LOYALTYLION_REWARDS` |
|
|
114
|
-
| LoyaltyLion | `LoyaltyLionTiersLoader` | `LOYALTYLION_TIERS` |
|
|
115
|
-
| LoyaltyLion | `LoyaltyLionPointsForPriceLoader` | `LOYALTYLION_POINTS_FOR_PRICE` |
|
|
116
|
-
| Yotpo | `YotpoReviewsLoader` | `YOTPO_PRODUCT_REVIEWS` |
|
|
117
|
-
| Yotpo | `YotpoReviewAggregateLoader` | `YOTPO_PRODUCT_REVIEW_AGGREGATE` |
|
|
118
|
-
| Reviews.io | `ReviewsIoReviewsLoader` | `REVIEWS_IO_PRODUCT_REVIEWS` |
|
|
119
|
-
| Reviews.io | `ReviewsIoReviewAggregateLoader` | `REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE` |
|
|
120
|
-
| Loox | `LooxReviewsLoader` | `LOOX_PRODUCT_REVIEWS` |
|
|
121
|
-
| Loox | `LooxReviewAggregateLoader` | `LOOX_PRODUCT_REVIEW_AGGREGATE` |
|
|
122
|
-
| Judge.me | `JudgemeReviewsLoader` | `JUDGEME_PRODUCT_REVIEWS` |
|
|
123
|
-
| Judge.me | `JudgemeReviewAggregateLoader` | `JUDGEME_PRODUCT_REVIEW_AGGREGATE` |
|
|
124
|
-
| Statsig | `StatsigExperimentLoader` | `STATSIG_EXPERIMENT` |
|
|
125
|
-
| Contentful | `ContentfulEntryLoader` | `CONTENTFUL_ENTRY` |
|
|
126
|
-
| Contentful | `ContentfulEntriesLoader` | `CONTENTFUL_ENTRIES` |
|
|
127
|
-
|
|
128
|
-
Import each component from its kebab-case subpath, for example
|
|
129
|
-
`CollectionLoader` from `@replohq/sdk/loaders/collection-loader`.
|
|
130
|
-
|
|
131
|
-
### Prefetch on the server
|
|
132
|
-
|
|
133
|
-
`PrefetchedLoaders` is a Server Component that fetches loader data during SSR
|
|
134
|
-
and hydrates the React Query cache. Wrap the matching Client Component to avoid
|
|
135
|
-
a loading state on the first paint:
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
// app/products/[handle]/page.tsx
|
|
139
|
-
import { PrefetchedLoaders } from "@replohq/sdk/loaders/prefetch-loaders";
|
|
140
|
-
import { DATA_LOADER_KEYS } from "@replohq/sdk/loaders/loader-keys";
|
|
141
|
-
|
|
142
|
-
import { ProductTitle } from "../../../components/product-title";
|
|
143
|
-
|
|
144
|
-
export default async function ProductPage({
|
|
145
|
-
params,
|
|
146
|
-
}: {
|
|
147
|
-
params: Promise<{ handle: string }>;
|
|
148
|
-
}) {
|
|
149
|
-
const { handle } = await params;
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<PrefetchedLoaders
|
|
153
|
-
queries={[
|
|
154
|
-
{
|
|
155
|
-
loaderKey: DATA_LOADER_KEYS.SHOPIFY_PRODUCT,
|
|
156
|
-
args: { handle },
|
|
157
|
-
},
|
|
158
|
-
]}
|
|
159
|
-
>
|
|
160
|
-
<ProductTitle handle={handle} />
|
|
161
|
-
</PrefetchedLoaders>
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
The `loaderKey` and complete `args` object must exactly match the props used by
|
|
167
|
-
the loader component, including optional locale, pagination, or metafield
|
|
168
|
-
arguments. `PrefetchedLoaders` accepts `revalidateSeconds` per query; it
|
|
169
|
-
defaults to 60 seconds, and `false` enables indefinite tag-based caching.
|
|
170
|
-
|
|
171
|
-
Server-only code that does not hydrate a loader component can call
|
|
172
|
-
`invokeLoaderServer` from `@replohq/sdk/loaders/invoke-loader-server`.
|
|
173
|
-
|
|
174
|
-
## License
|
|
175
|
-
|
|
176
|
-
This package is proprietary software. See [LICENSE](./LICENSE)
|
|
177
|
-
(`SEE LICENSE IN LICENSE`) and the [Replo Terms of Service](https://replo.app/terms).
|
|
7
|
+
This package is proprietary software. Use is covered by the Replo Terms of Service (https://replo.app/terms).
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
export declare function parseJsonOrNull(json: string): unknown | null;
|
|
2
|
-
export declare function omitJsonObjectFieldsOrNull({ json, fields, }: {
|
|
3
|
-
json: string;
|
|
4
|
-
fields: string[];
|
|
5
|
-
}): string | null;
|
|
6
2
|
export declare function jsonStringifyOrNull(value: unknown): string | null;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export { jsonStringifyOrNull,
|
|
2
|
-
import '../../../chunk-DMJ5VUD6.mjs';
|
|
3
|
-
import '../../../chunk-GNIXARC7.mjs';
|
|
4
|
-
import '../../../chunk-JBCOJHZN.mjs';
|
|
1
|
+
export { jsonStringifyOrNull, parseJsonOrNull } from '../../../chunk-B7XDEXPL.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-GNIXARC7.mjs';
|
|
1
2
|
import { nodeUtil_default, baseUnary_default, getTag_default, identity_default, isFunction_default, defineProperty_default, isArrayLike_default, isIndex_default, eq_default, Stack_default, keysIn_default, isBuffer_default, isTypedArray_default, isArguments_default, isPrototype_default, baseKeys_default, baseAssignValue_default, getAllKeysIn_default, getAllKeys_default, keys_default, getPrototype_default, getSymbolsIn_default, getSymbols_default, Uint8Array_default, assignValue_default } from '../../../chunk-N4WC2Z43.mjs';
|
|
2
3
|
export { isFunction_default as isFunction } from '../../../chunk-N4WC2Z43.mjs';
|
|
3
|
-
export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-GNIXARC7.mjs';
|
|
4
4
|
import { root_default, Symbol_default, isObjectLike_default, isObject_default, isArray_default, baseGetTag_default } from '../../../chunk-JBCOJHZN.mjs';
|
|
5
5
|
|
|
6
6
|
function arrayEach(array, iteratee) {
|
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
import '../../../chunk-
|
|
3
|
-
|
|
1
|
+
import { isString_default, isNumber_default } from '../../../chunk-GNIXARC7.mjs';
|
|
2
|
+
import { isObject_default } from '../../../chunk-JBCOJHZN.mjs';
|
|
3
|
+
|
|
4
|
+
var has = Object.prototype.hasOwnProperty;
|
|
5
|
+
function dequal(foo, bar) {
|
|
6
|
+
var ctor, len;
|
|
7
|
+
if (foo === bar) return true;
|
|
8
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
9
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
10
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
11
|
+
if (ctor === Array) {
|
|
12
|
+
if ((len = foo.length) === bar.length) {
|
|
13
|
+
while (len-- && dequal(foo[len], bar[len])) ;
|
|
14
|
+
}
|
|
15
|
+
return len === -1;
|
|
16
|
+
}
|
|
17
|
+
if (!ctor || typeof foo === "object") {
|
|
18
|
+
len = 0;
|
|
19
|
+
for (ctor in foo) {
|
|
20
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
21
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
22
|
+
}
|
|
23
|
+
return Object.keys(bar).length === len;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return foo !== foo && bar !== bar;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function forEachPrimitiveValue({
|
|
30
|
+
target,
|
|
31
|
+
fn,
|
|
32
|
+
valueConversionFunction
|
|
33
|
+
}) {
|
|
34
|
+
if (!target) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
for (const [key, value] of Object.entries(target)) {
|
|
38
|
+
if (isObject_default(value)) {
|
|
39
|
+
const newTarget = valueConversionFunction ? valueConversionFunction(value) : value;
|
|
40
|
+
forEachPrimitiveValue({ target: newTarget, fn });
|
|
41
|
+
}
|
|
42
|
+
if (isString_default(value) || isNumber_default(value)) {
|
|
43
|
+
fn(value, key, target);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function shallowEqual(objA, objB) {
|
|
48
|
+
if (Object.is(objA, objB)) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const keysA = Object.keys(objA);
|
|
55
|
+
const keysB = Object.keys(objB);
|
|
56
|
+
if (keysA.length !== keysB.length) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
60
|
+
const currentKey = keysA[i];
|
|
61
|
+
if (!Object.hasOwnProperty.call(objB, currentKey) ||
|
|
62
|
+
!Object.is(objA[currentKey], objB[currentKey])) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
var deepEqual = dequal;
|
|
69
|
+
function omit(obj, keysToOmit) {
|
|
70
|
+
const result = { ...obj };
|
|
71
|
+
for (const key of keysToOmit) {
|
|
72
|
+
delete result[key];
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
function filterUndefined(data) {
|
|
77
|
+
const result = {};
|
|
78
|
+
for (const [key, value] of Object.entries(data)) {
|
|
79
|
+
if (value !== void 0) {
|
|
80
|
+
result[key] = value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
function toNullableIfDefined(value) {
|
|
86
|
+
return value === void 0 ? void 0 : value ?? null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { deepEqual, filterUndefined, forEachPrimitiveValue, omit, shallowEqual, toNullableIfDefined };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { parseContentEntryDocument, getContentRenderableEntryValues, getContentEntryFieldValidationIssues } from '../../chunk-4YTXURVN.mjs';
|
|
2
2
|
import { isValidContentSlug, CONTENT_COLLECTION_SCHEMA_FILENAME, CONTENT_ENTRY_FILE_EXTENSION, contentCollectionFileSchema, CONTENT_ENTRY_PUBLISHED_FILE_EXTENSION } from '../../chunk-RQ76VK3L.mjs';
|
|
3
3
|
import '../../chunk-N4WC2Z43.mjs';
|
|
4
|
-
import { parseJsonOrNull } from '../../chunk-QYGRVXWQ.mjs';
|
|
5
|
-
import '../../chunk-DMJ5VUD6.mjs';
|
|
6
|
-
import '../../chunk-GNIXARC7.mjs';
|
|
7
4
|
import '../../chunk-JBCOJHZN.mjs';
|
|
5
|
+
import { parseJsonOrNull } from '../../chunk-B7XDEXPL.mjs';
|
|
8
6
|
import * as z from 'zod';
|
|
9
7
|
|
|
10
8
|
var contentManifestSchema = z.object({
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function parseJsonOrNull(json) {
|
|
2
|
+
try {
|
|
3
|
+
return JSON.parse(json);
|
|
4
|
+
} catch {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function jsonStringifyOrNull(value) {
|
|
9
|
+
if (value === null || value === void 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return JSON.stringify(value);
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { jsonStringifyOrNull, parseJsonOrNull };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ScriptTagDescriptor } from "../_vendor/schemas/generated/consent";
|
|
2
2
|
import type { ConsentCategory, ReploScriptEntry } from "./types";
|
|
3
|
-
import { Component } from "react";
|
|
4
3
|
/**
|
|
5
4
|
* Injects the resolved tags into `document.head` once a caller has decided
|
|
6
5
|
* consent allows it. Reused both for author-managed `ReploScripts` entries and
|
|
@@ -16,12 +15,9 @@ type InjectedScriptProps = {
|
|
|
16
15
|
descriptors: ScriptTagDescriptor[];
|
|
17
16
|
/** Used under a delegated platform to derive the attributes that gate the tag. */
|
|
18
17
|
requiredConsent?: ConsentCategory[];
|
|
19
|
-
usercentricsService?: string;
|
|
18
|
+
usercentricsService?: string | null;
|
|
20
19
|
};
|
|
21
|
-
export declare
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
render(): null;
|
|
24
|
-
}
|
|
20
|
+
export declare function InjectedScript({ baseId, descriptors, requiredConsent, usercentricsService, }: InjectedScriptProps): null;
|
|
25
21
|
/**
|
|
26
22
|
* The single registry component for all managed tracking scripts on the site.
|
|
27
23
|
* Authored once in `app/layout.tsx`; the agent/miniapp only edit the `scripts`
|
package/consent/replo-scripts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect } from "react";
|
|
4
4
|
import {
|
|
5
5
|
buildGrantMarker,
|
|
6
6
|
enableConsentDelegation,
|
|
@@ -59,30 +59,30 @@ function descriptorsFor(entry) {
|
|
|
59
59
|
}
|
|
60
60
|
return buildScriptTags(entry);
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
function InjectedScript({
|
|
63
|
+
baseId,
|
|
64
|
+
descriptors,
|
|
65
|
+
requiredConsent = [],
|
|
66
|
+
usercentricsService = null
|
|
67
|
+
}) {
|
|
68
|
+
useEffect(() => {
|
|
65
69
|
injectGatedScript({
|
|
66
|
-
baseId
|
|
67
|
-
descriptors
|
|
70
|
+
baseId,
|
|
71
|
+
descriptors,
|
|
68
72
|
requiredConsent,
|
|
69
73
|
usercentricsService
|
|
70
74
|
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
+
}, []);
|
|
76
|
+
return null;
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
registerScript(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
78
|
+
function ScriptRegistration({ script }) {
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
registerScript(script);
|
|
81
|
+
return () => {
|
|
82
|
+
unregisterScript(script.id);
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
return null;
|
|
86
86
|
}
|
|
87
87
|
function registrationFor(entry, loaderContainerId) {
|
|
88
88
|
const id = scriptId(entry);
|
|
@@ -121,23 +121,16 @@ function ManagedScript({
|
|
|
121
121
|
baseId: id,
|
|
122
122
|
descriptors: descriptorsFor(entry),
|
|
123
123
|
requiredConsent,
|
|
124
|
-
usercentricsService
|
|
124
|
+
usercentricsService
|
|
125
125
|
}
|
|
126
126
|
)
|
|
127
127
|
] });
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
componentWillUnmount() {
|
|
136
|
-
this.uninstall();
|
|
137
|
-
}
|
|
138
|
-
render() {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
129
|
+
function ConsentWindowApi() {
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
return installConsentWindowApi();
|
|
132
|
+
}, []);
|
|
133
|
+
return null;
|
|
141
134
|
}
|
|
142
135
|
function ReploScripts({ scripts }) {
|
|
143
136
|
const platform = findConsentPlatform(scripts);
|
package/lib/buildMetadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const BUILD_METADATA = {
|
|
2
2
|
"packageName": "@replohq/sdk",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.2",
|
|
4
4
|
"branch": "HEAD",
|
|
5
|
-
"commit": "
|
|
6
|
-
"builtAt": "2026-11-
|
|
5
|
+
"commit": "437e1e853916beee996b6b16fc2d77f31da0638d",
|
|
6
|
+
"builtAt": "2026-11-07T00:33:22.871Z"
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/sdk",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.2",
|
|
4
4
|
"reploBuild": {
|
|
5
5
|
"packageName": "@replohq/sdk",
|
|
6
|
-
"version": "2.20.
|
|
6
|
+
"version": "2.20.2",
|
|
7
7
|
"branch": "HEAD",
|
|
8
|
-
"commit": "
|
|
9
|
-
"builtAt": "2026-11-
|
|
8
|
+
"commit": "437e1e853916beee996b6b16fc2d77f31da0638d",
|
|
9
|
+
"builtAt": "2026-11-07T00:33:22.871Z"
|
|
10
10
|
},
|
|
11
11
|
"description": "Replo SDK — cart, analytics, and data loaders for agent-built Next.js sites.",
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -361,11 +361,7 @@
|
|
|
361
361
|
"react": ">=18.2.0",
|
|
362
362
|
"react-dom": ">=18.2.0"
|
|
363
363
|
},
|
|
364
|
-
"
|
|
365
|
-
"type": "git",
|
|
366
|
-
"url": "git+https://github.com/replohq/andytown.git",
|
|
367
|
-
"directory": "packages/sdk"
|
|
368
|
-
},
|
|
364
|
+
"homepage": "https://docs.replo.app/sdk",
|
|
369
365
|
"publishConfig": {
|
|
370
366
|
"registry": "https://registry.npmjs.org/",
|
|
371
367
|
"access": "public"
|
package/chunk-DMJ5VUD6.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { isString_default, isNumber_default } from './chunk-GNIXARC7.mjs';
|
|
2
|
-
import { isObject_default } from './chunk-JBCOJHZN.mjs';
|
|
3
|
-
|
|
4
|
-
var has = Object.prototype.hasOwnProperty;
|
|
5
|
-
function dequal(foo, bar) {
|
|
6
|
-
var ctor, len;
|
|
7
|
-
if (foo === bar) return true;
|
|
8
|
-
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
9
|
-
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
10
|
-
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
11
|
-
if (ctor === Array) {
|
|
12
|
-
if ((len = foo.length) === bar.length) {
|
|
13
|
-
while (len-- && dequal(foo[len], bar[len])) ;
|
|
14
|
-
}
|
|
15
|
-
return len === -1;
|
|
16
|
-
}
|
|
17
|
-
if (!ctor || typeof foo === "object") {
|
|
18
|
-
len = 0;
|
|
19
|
-
for (ctor in foo) {
|
|
20
|
-
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
21
|
-
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
22
|
-
}
|
|
23
|
-
return Object.keys(bar).length === len;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return foo !== foo && bar !== bar;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function forEachPrimitiveValue({
|
|
30
|
-
target,
|
|
31
|
-
fn,
|
|
32
|
-
valueConversionFunction
|
|
33
|
-
}) {
|
|
34
|
-
if (!target) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
for (const [key, value] of Object.entries(target)) {
|
|
38
|
-
if (isObject_default(value)) {
|
|
39
|
-
const newTarget = valueConversionFunction ? valueConversionFunction(value) : value;
|
|
40
|
-
forEachPrimitiveValue({ target: newTarget, fn });
|
|
41
|
-
}
|
|
42
|
-
if (isString_default(value) || isNumber_default(value)) {
|
|
43
|
-
fn(value, key, target);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function shallowEqual(objA, objB) {
|
|
48
|
-
if (Object.is(objA, objB)) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const keysA = Object.keys(objA);
|
|
55
|
-
const keysB = Object.keys(objB);
|
|
56
|
-
if (keysA.length !== keysB.length) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
for (let i = 0; i < keysA.length; i++) {
|
|
60
|
-
const currentKey = keysA[i];
|
|
61
|
-
if (!Object.hasOwnProperty.call(objB, currentKey) ||
|
|
62
|
-
!Object.is(objA[currentKey], objB[currentKey])) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
var deepEqual = dequal;
|
|
69
|
-
function omit(obj, keysToOmit) {
|
|
70
|
-
const result = { ...obj };
|
|
71
|
-
for (const key of keysToOmit) {
|
|
72
|
-
delete result[key];
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
function filterUndefined(data) {
|
|
77
|
-
const result = {};
|
|
78
|
-
for (const [key, value] of Object.entries(data)) {
|
|
79
|
-
if (value !== void 0) {
|
|
80
|
-
result[key] = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
function toNullableIfDefined(value) {
|
|
86
|
-
return value === void 0 ? void 0 : value ?? null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { deepEqual, filterUndefined, forEachPrimitiveValue, omit, shallowEqual, toNullableIfDefined };
|
package/chunk-QYGRVXWQ.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { omit } from './chunk-DMJ5VUD6.mjs';
|
|
2
|
-
|
|
3
|
-
function parseJsonOrNull(json) {
|
|
4
|
-
try {
|
|
5
|
-
return JSON.parse(json);
|
|
6
|
-
} catch {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function omitJsonObjectFieldsOrNull({
|
|
11
|
-
json,
|
|
12
|
-
fields
|
|
13
|
-
}) {
|
|
14
|
-
const parsedJson = parseJsonOrNull(json);
|
|
15
|
-
if (typeof parsedJson !== "object" || parsedJson === null || Array.isArray(parsedJson)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const jsonObject = { ...parsedJson };
|
|
19
|
-
return jsonStringifyOrNull(omit(jsonObject, fields));
|
|
20
|
-
}
|
|
21
|
-
function jsonStringifyOrNull(value) {
|
|
22
|
-
if (value === null || value === void 0) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
return JSON.stringify(value);
|
|
27
|
-
} catch {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { jsonStringifyOrNull, omitJsonObjectFieldsOrNull, parseJsonOrNull };
|