@amplifyup/sdk 0.1.73 → 0.1.75
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/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +97 -12
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +97 -12
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +100 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -34
- package/dist/index.mjs.map +1 -1
- package/dist/{query-Hay-oVYp.d.ts → query-B23UsNIv.d.ts} +1 -1
- package/dist/{query-B_DU7yEm.d.mts → query-CV8x3oQT.d.mts} +1 -1
- package/dist/react.d.mts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +106 -35
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +106 -35
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -1
- package/dist/server.mjs.map +1 -1
- package/dist/{types-CGeBbx84.d.mts → types-D4TSd2Yt.d.mts} +23 -2
- package/dist/{types-CGeBbx84.d.ts → types-D4TSd2Yt.d.ts} +23 -2
- package/package.json +1 -1
package/dist/react.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { L as LayoutComponentProps, P as PageConfig, F as Field$1,
|
|
3
|
-
export {
|
|
2
|
+
import { L as LayoutComponentProps, P as PageConfig, F as Field$1, m as FIELDS_BRAND, d as AmplifyUpConfig, f as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-D4TSd2Yt.mjs';
|
|
3
|
+
export { x as FieldRef, y as Fields, B as ImageValue, z as ListRow, D as PortableRef, Z as ZoneConfig, o as attachFieldEnvelopes, q as composerStoreKey, p as envelopeListRows, w as isBrandedFields, u as isFieldEnvelope, v as isReadOnlyRowField, s as listOwnerFromSpec, t as toFieldEnvelopes } from './types-D4TSd2Yt.mjs';
|
|
4
4
|
import react__default, { ReactNode } from 'react';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.mjs';
|
|
6
|
-
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
6
|
+
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-CV8x3oQT.mjs';
|
|
7
7
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.mjs';
|
|
8
8
|
|
|
9
9
|
type RenderComponentContext = {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { L as LayoutComponentProps, P as PageConfig, F as Field$1,
|
|
3
|
-
export {
|
|
2
|
+
import { L as LayoutComponentProps, P as PageConfig, F as Field$1, m as FIELDS_BRAND, d as AmplifyUpConfig, f as AmplifyPageContextInput, C as ContentSource, A as AmplifyContentMeta } from './types-D4TSd2Yt.js';
|
|
3
|
+
export { x as FieldRef, y as Fields, B as ImageValue, z as ListRow, D as PortableRef, Z as ZoneConfig, o as attachFieldEnvelopes, q as composerStoreKey, p as envelopeListRows, w as isBrandedFields, u as isFieldEnvelope, v as isReadOnlyRowField, s as listOwnerFromSpec, t as toFieldEnvelopes } from './types-D4TSd2Yt.js';
|
|
4
4
|
import react__default, { ReactNode } from 'react';
|
|
5
5
|
export { AmplifyRenderer } from './AmplifyRenderer.js';
|
|
6
|
-
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-
|
|
6
|
+
export { Q as QueryContentError, e as QueryContentOptions, k as QueryFilter, l as QueryFilterOp, i as QueryPagination, h as QueryResult, m as QuerySort, j as QuerySpec, S as SelectVariantsError, a as SelectVariantsOptions, b as SelectVariantsResult, n as nextPageSpec, q as queryContent, d as searchSpec, s as selectVariants } from './query-B23UsNIv.js';
|
|
7
7
|
export { i as isComposerPreview, a as isPreviewRequest, b as isWorkingContentRequest } from './preview-_vHmzRen.js';
|
|
8
8
|
|
|
9
9
|
type RenderComponentContext = {
|
package/dist/react.js
CHANGED
|
@@ -843,6 +843,7 @@ function applyPageContext(input, opts) {
|
|
|
843
843
|
}
|
|
844
844
|
const pageFields = {};
|
|
845
845
|
for (const pf of opts.pageData?.pageFields || []) {
|
|
846
|
+
if (pf.dataType === "taxonomy") continue;
|
|
846
847
|
if (pf.source === "static") {
|
|
847
848
|
if (pf.value !== void 0) pageFields[pf.key] = pf.value;
|
|
848
849
|
continue;
|
|
@@ -865,6 +866,7 @@ function applyPageContext(input, opts) {
|
|
|
865
866
|
function staticPageFieldsFromSnapshot(pageData) {
|
|
866
867
|
const pageFields = {};
|
|
867
868
|
for (const pf of pageData?.pageFields || []) {
|
|
869
|
+
if (pf.dataType === "taxonomy") continue;
|
|
868
870
|
if (pf.source === "static" && pf.value !== void 0) {
|
|
869
871
|
pageFields[pf.key] = pf.value;
|
|
870
872
|
}
|
|
@@ -882,13 +884,19 @@ function attachStaticPageContext(pageData, pageRoute) {
|
|
|
882
884
|
pageRoute: pageRoute || ""
|
|
883
885
|
};
|
|
884
886
|
}
|
|
887
|
+
function withPageTaxonomies(properties, taxonomies) {
|
|
888
|
+
if (!taxonomies || Object.keys(taxonomies).length === 0) return properties;
|
|
889
|
+
const page = properties.page && typeof properties.page === "object" && !Array.isArray(properties.page) ? properties.page : { fields: {} };
|
|
890
|
+
return { ...properties, page: { ...page, taxonomies } };
|
|
891
|
+
}
|
|
885
892
|
function mergeEventContext(properties, attached) {
|
|
886
893
|
if (!attached) return properties;
|
|
887
894
|
return {
|
|
888
895
|
...properties,
|
|
889
896
|
...attached.resource ? { resource: attached.resource } : {},
|
|
890
897
|
page: attached.page,
|
|
891
|
-
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {}
|
|
898
|
+
...attached.pageRoute ? { pageRoute: attached.pageRoute } : {},
|
|
899
|
+
...attached.pageResource ? { pageResource: attached.pageResource } : {}
|
|
892
900
|
};
|
|
893
901
|
}
|
|
894
902
|
var PAGE_RESOURCE_MARKER = "__amplifyupPageResource";
|
|
@@ -950,6 +958,27 @@ function hydratePageResourceProps(props, fields) {
|
|
|
950
958
|
return out;
|
|
951
959
|
}
|
|
952
960
|
|
|
961
|
+
// src/edge/normalizeRoute.ts
|
|
962
|
+
function normalizeRoute(route) {
|
|
963
|
+
let path = String(route || "").trim();
|
|
964
|
+
if (!path) return "/";
|
|
965
|
+
try {
|
|
966
|
+
if (/^https?:\/\//i.test(path)) {
|
|
967
|
+
path = new URL(path).pathname;
|
|
968
|
+
}
|
|
969
|
+
} catch {
|
|
970
|
+
}
|
|
971
|
+
const q = path.indexOf("?");
|
|
972
|
+
if (q >= 0) path = path.slice(0, q);
|
|
973
|
+
const h = path.indexOf("#");
|
|
974
|
+
if (h >= 0) path = path.slice(0, h);
|
|
975
|
+
if (!path.startsWith("/")) path = `/${path}`;
|
|
976
|
+
if (path.length > 1 && path.endsWith("/")) {
|
|
977
|
+
path = path.replace(/\/+$/, "");
|
|
978
|
+
}
|
|
979
|
+
return path || "/";
|
|
980
|
+
}
|
|
981
|
+
|
|
953
982
|
// src/page-resource-runtime.ts
|
|
954
983
|
var pageResourceFields = null;
|
|
955
984
|
function setPageResourceFields(fields) {
|
|
@@ -1047,27 +1076,6 @@ function previewLayoutReady(opts) {
|
|
|
1047
1076
|
return true;
|
|
1048
1077
|
}
|
|
1049
1078
|
|
|
1050
|
-
// src/edge/normalizeRoute.ts
|
|
1051
|
-
function normalizeRoute(route) {
|
|
1052
|
-
let path = String(route || "").trim();
|
|
1053
|
-
if (!path) return "/";
|
|
1054
|
-
try {
|
|
1055
|
-
if (/^https?:\/\//i.test(path)) {
|
|
1056
|
-
path = new URL(path).pathname;
|
|
1057
|
-
}
|
|
1058
|
-
} catch {
|
|
1059
|
-
}
|
|
1060
|
-
const q = path.indexOf("?");
|
|
1061
|
-
if (q >= 0) path = path.slice(0, q);
|
|
1062
|
-
const h = path.indexOf("#");
|
|
1063
|
-
if (h >= 0) path = path.slice(0, h);
|
|
1064
|
-
if (!path.startsWith("/")) path = `/${path}`;
|
|
1065
|
-
if (path.length > 1 && path.endsWith("/")) {
|
|
1066
|
-
path = path.replace(/\/+$/, "");
|
|
1067
|
-
}
|
|
1068
|
-
return path || "/";
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
1079
|
// src/edge/variantKeys.ts
|
|
1072
1080
|
function serializeVariantKeys(keys) {
|
|
1073
1081
|
if (!keys) return "";
|
|
@@ -1188,7 +1196,9 @@ function mapResolvedToPageConfig(payload) {
|
|
|
1188
1196
|
description: payload.meta?.degraded ? "degraded" : void 0
|
|
1189
1197
|
},
|
|
1190
1198
|
...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {},
|
|
1191
|
-
...payload.pageData ? { pageData: payload.pageData } : {}
|
|
1199
|
+
...payload.pageData ? { pageData: payload.pageData } : {},
|
|
1200
|
+
...payload.pageResources ? { pageResources: payload.pageResources } : {},
|
|
1201
|
+
...payload.pageTaxonomies ? { pageTaxonomies: payload.pageTaxonomies } : {}
|
|
1192
1202
|
};
|
|
1193
1203
|
}
|
|
1194
1204
|
function collectDegraded(payload) {
|
|
@@ -1420,6 +1430,7 @@ function searchSpec(pagination, field, term) {
|
|
|
1420
1430
|
}
|
|
1421
1431
|
|
|
1422
1432
|
// src/index.ts
|
|
1433
|
+
var PAGE_VIEW_HOLD_MS = 1500;
|
|
1423
1434
|
var DWELL_ACTIVITY_IDLE_MS = 2 * 60 * 1e3;
|
|
1424
1435
|
var DWELL_POLL_MS = 5e3;
|
|
1425
1436
|
function readPreviewQueryOverrides() {
|
|
@@ -1490,8 +1501,15 @@ var AmplifyUpSDK = class {
|
|
|
1490
1501
|
this.pendingPageContext = null;
|
|
1491
1502
|
this.attachedPageContext = null;
|
|
1492
1503
|
this.resolvedPageData = null;
|
|
1504
|
+
this.resolvedPageResource = null;
|
|
1493
1505
|
this.resolvedPageRoute = "";
|
|
1494
1506
|
this.resolvedRouteParams = {};
|
|
1507
|
+
/** Path whose delivery response is in flight; page_view for it is held. */
|
|
1508
|
+
this.pendingResolvePath = null;
|
|
1509
|
+
this.heldPageView = null;
|
|
1510
|
+
this.resolvedPageTaxonomies = null;
|
|
1511
|
+
/** Path the taxonomies above were resolved for. */
|
|
1512
|
+
this.resolvedTaxonomiesPath = null;
|
|
1495
1513
|
this.historyHooksInstalled = false;
|
|
1496
1514
|
this.pageEngagementState = {
|
|
1497
1515
|
reached: /* @__PURE__ */ new Set(),
|
|
@@ -2022,31 +2040,65 @@ var AmplifyUpSDK = class {
|
|
|
2022
2040
|
* Apply published pageData (from /v1/resolve) so field validation and
|
|
2023
2041
|
* mapped page fields can run.
|
|
2024
2042
|
*/
|
|
2025
|
-
applyResolvedPageData(pageData, pageRoute, routeParams) {
|
|
2043
|
+
applyResolvedPageData(pageData, pageRoute, routeParams, pageResources, pageTaxonomies) {
|
|
2026
2044
|
this.resolvedPageData = pageData || null;
|
|
2045
|
+
this.resolvedPageTaxonomies = pageTaxonomies || null;
|
|
2046
|
+
this.resolvedTaxonomiesPath = this.pendingResolvePath;
|
|
2027
2047
|
if (pageRoute) this.resolvedPageRoute = pageRoute;
|
|
2028
2048
|
if (routeParams) this.resolvedRouteParams = routeParams;
|
|
2049
|
+
const firstResourceName = pageData?.resources?.[0]?.name;
|
|
2050
|
+
const resolvedForPage = (firstResourceName ? pageResources?.[firstResourceName] : void 0) || (pageResources ? Object.values(pageResources)[0] : void 0);
|
|
2051
|
+
this.resolvedPageResource = resolvedForPage || null;
|
|
2029
2052
|
this.recomputeAttachedContext();
|
|
2030
2053
|
}
|
|
2031
2054
|
recomputeAttachedContext() {
|
|
2032
2055
|
if (!this.pendingPageContext) {
|
|
2033
|
-
this.attachedPageContext =
|
|
2034
|
-
this.resolvedPageData,
|
|
2035
|
-
this.resolvedPageRoute
|
|
2056
|
+
this.attachedPageContext = this.withPageResource(
|
|
2057
|
+
attachStaticPageContext(this.resolvedPageData, this.resolvedPageRoute)
|
|
2036
2058
|
);
|
|
2037
2059
|
setPageResourceFields(null);
|
|
2038
2060
|
return;
|
|
2039
2061
|
}
|
|
2040
|
-
this.attachedPageContext =
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2062
|
+
this.attachedPageContext = this.withPageResource(
|
|
2063
|
+
applyPageContext(this.pendingPageContext, {
|
|
2064
|
+
pageData: this.resolvedPageData,
|
|
2065
|
+
routeParams: this.resolvedRouteParams,
|
|
2066
|
+
pageRoute: this.resolvedPageRoute
|
|
2067
|
+
})
|
|
2068
|
+
);
|
|
2045
2069
|
setPageResourceFields(this.attachedPageContext?.resource?.fields || null);
|
|
2046
2070
|
}
|
|
2071
|
+
/** Stamp the resolved entry onto the context so events carry it. */
|
|
2072
|
+
withPageResource(context) {
|
|
2073
|
+
if (!context || !this.resolvedPageResource) return context;
|
|
2074
|
+
const { entity, providerId, docId } = this.resolvedPageResource;
|
|
2075
|
+
return { ...context, pageResource: { entity, providerId, docId } };
|
|
2076
|
+
}
|
|
2047
2077
|
getAttachedPageContext() {
|
|
2048
2078
|
return this.attachedPageContext;
|
|
2049
2079
|
}
|
|
2080
|
+
/**
|
|
2081
|
+
* The page's delivery response for `path` is on its way. A page_view for the
|
|
2082
|
+
* same path waits for it (up to PAGE_VIEW_HOLD_MS) so it carries the page's
|
|
2083
|
+
* taxonomies.
|
|
2084
|
+
*/
|
|
2085
|
+
beginPageResolve(path) {
|
|
2086
|
+
this.pendingResolvePath = normalizeRoute(path);
|
|
2087
|
+
this.resolvedPageTaxonomies = null;
|
|
2088
|
+
this.resolvedTaxonomiesPath = null;
|
|
2089
|
+
}
|
|
2090
|
+
endPageResolve(path) {
|
|
2091
|
+
if (this.pendingResolvePath !== normalizeRoute(path)) return;
|
|
2092
|
+
this.pendingResolvePath = null;
|
|
2093
|
+
this.flushHeldPageView();
|
|
2094
|
+
}
|
|
2095
|
+
flushHeldPageView() {
|
|
2096
|
+
const held = this.heldPageView;
|
|
2097
|
+
if (!held) return;
|
|
2098
|
+
clearTimeout(held.timer);
|
|
2099
|
+
this.heldPageView = null;
|
|
2100
|
+
this.sendPageView(held.url, held.properties);
|
|
2101
|
+
}
|
|
2050
2102
|
/**
|
|
2051
2103
|
* Track a page view
|
|
2052
2104
|
*/
|
|
@@ -2057,6 +2109,21 @@ var AmplifyUpSDK = class {
|
|
|
2057
2109
|
if (!this.isInitialized()) {
|
|
2058
2110
|
return;
|
|
2059
2111
|
}
|
|
2112
|
+
this.lastTrackedPath = url;
|
|
2113
|
+
if (this.pendingResolvePath && this.pendingResolvePath === normalizeRoute(url)) {
|
|
2114
|
+
this.flushHeldPageView();
|
|
2115
|
+
this.heldPageView = {
|
|
2116
|
+
url,
|
|
2117
|
+
properties,
|
|
2118
|
+
timer: setTimeout(() => this.flushHeldPageView(), PAGE_VIEW_HOLD_MS)
|
|
2119
|
+
};
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
this.flushHeldPageView();
|
|
2123
|
+
this.sendPageView(url, properties);
|
|
2124
|
+
}
|
|
2125
|
+
sendPageView(url, properties) {
|
|
2126
|
+
const taxonomies = this.resolvedTaxonomiesPath && this.resolvedTaxonomiesPath === normalizeRoute(url) ? this.resolvedPageTaxonomies : null;
|
|
2060
2127
|
const instanceId = getInstanceId();
|
|
2061
2128
|
const sessionId = getSessionId();
|
|
2062
2129
|
const pageProperties = {
|
|
@@ -2068,10 +2135,9 @@ var AmplifyUpSDK = class {
|
|
|
2068
2135
|
sessionId,
|
|
2069
2136
|
trackingId: this.config?.trackingId,
|
|
2070
2137
|
// Timestamp is included in event payload
|
|
2071
|
-
...mergeEventContext(properties || {}, this.attachedPageContext)
|
|
2138
|
+
...withPageTaxonomies(mergeEventContext(properties || {}, this.attachedPageContext), taxonomies)
|
|
2072
2139
|
};
|
|
2073
2140
|
this.adapter.page(pageProperties);
|
|
2074
|
-
this.lastTrackedPath = url;
|
|
2075
2141
|
}
|
|
2076
2142
|
/**
|
|
2077
2143
|
* Track an event
|
|
@@ -5518,6 +5584,8 @@ function AmplifyUpProvider({
|
|
|
5518
5584
|
React3.useEffect(() => {
|
|
5519
5585
|
let cancelled = false;
|
|
5520
5586
|
const sdk = getSDK();
|
|
5587
|
+
const heldRoute = isComposerPreview() || config.clientPersonalization !== false ? getActualRoute() : null;
|
|
5588
|
+
if (heldRoute) sdk.beginPageResolve(heldRoute);
|
|
5521
5589
|
const run = async () => {
|
|
5522
5590
|
try {
|
|
5523
5591
|
await sdk.init({
|
|
@@ -5596,7 +5664,9 @@ function AmplifyUpProvider({
|
|
|
5596
5664
|
sdk.applyResolvedPageData(
|
|
5597
5665
|
result.pageConfig.pageData || null,
|
|
5598
5666
|
result.pageConfig.route,
|
|
5599
|
-
extractRouteParams(result.pageConfig.route, actualRoute)
|
|
5667
|
+
extractRouteParams(result.pageConfig.route, actualRoute),
|
|
5668
|
+
result.pageConfig.pageResources || null,
|
|
5669
|
+
result.pageConfig.pageTaxonomies || null
|
|
5600
5670
|
);
|
|
5601
5671
|
}
|
|
5602
5672
|
setInitialized(true);
|
|
@@ -5620,6 +5690,7 @@ function AmplifyUpProvider({
|
|
|
5620
5690
|
setSource(null);
|
|
5621
5691
|
setMeta(null);
|
|
5622
5692
|
} finally {
|
|
5693
|
+
if (heldRoute) sdk.endPageResolve(heldRoute);
|
|
5623
5694
|
if (!cancelled) setLoading(false);
|
|
5624
5695
|
}
|
|
5625
5696
|
};
|