@amplifyup/sdk 0.3.0 → 0.3.1-uat.104.gfd92fe0
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 +16 -0
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +55 -5
- package/dist/index.d.ts +55 -5
- package/dist/index.js +49 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -9
- package/dist/index.mjs.map +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1128,6 +1128,39 @@ async function fetchContent(options) {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
|
+
// src/consent.ts
|
|
1132
|
+
var STORAGE_KEY = "amplifyup_consent";
|
|
1133
|
+
var current = null;
|
|
1134
|
+
var loaded = false;
|
|
1135
|
+
function readStored() {
|
|
1136
|
+
try {
|
|
1137
|
+
const value = typeof window !== "undefined" ? window.localStorage.getItem(STORAGE_KEY) : null;
|
|
1138
|
+
return value === "granted" || value === "denied" ? value : null;
|
|
1139
|
+
} catch {
|
|
1140
|
+
return null;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
function writeStored(state) {
|
|
1144
|
+
try {
|
|
1145
|
+
if (typeof window === "undefined") return;
|
|
1146
|
+
if (state) window.localStorage.setItem(STORAGE_KEY, state);
|
|
1147
|
+
else window.localStorage.removeItem(STORAGE_KEY);
|
|
1148
|
+
} catch {
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
function setConsent(state) {
|
|
1152
|
+
current = state;
|
|
1153
|
+
loaded = true;
|
|
1154
|
+
writeStored(state);
|
|
1155
|
+
}
|
|
1156
|
+
function getConsent() {
|
|
1157
|
+
if (!loaded) {
|
|
1158
|
+
current = readStored();
|
|
1159
|
+
loaded = true;
|
|
1160
|
+
}
|
|
1161
|
+
return current;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1131
1164
|
// src/delivery/forms.ts
|
|
1132
1165
|
var DeliveryRequestError = class extends Error {
|
|
1133
1166
|
constructor(message, status) {
|
|
@@ -1167,10 +1200,16 @@ var submitForm = async (formId, values, options = {}) => {
|
|
|
1167
1200
|
throw new DeliveryRequestError("Forms do not submit in preview.", 0);
|
|
1168
1201
|
}
|
|
1169
1202
|
const fetchFn = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
1203
|
+
const consent = getConsent();
|
|
1204
|
+
const page2 = typeof window !== "undefined" ? window.location.href : void 0;
|
|
1170
1205
|
const response = await fetchFn(formUrl(formId, "/submit"), {
|
|
1171
1206
|
method: "POST",
|
|
1172
|
-
headers: {
|
|
1173
|
-
|
|
1207
|
+
headers: {
|
|
1208
|
+
Accept: "application/json",
|
|
1209
|
+
"Content-Type": "application/json",
|
|
1210
|
+
...consent ? { "x-amplifyup-consent": consent } : {}
|
|
1211
|
+
},
|
|
1212
|
+
body: JSON.stringify({ values, page: page2 })
|
|
1174
1213
|
});
|
|
1175
1214
|
if (response.status === 422) {
|
|
1176
1215
|
const body2 = await response.json();
|
|
@@ -3625,16 +3664,16 @@ Available Console Commands:
|
|
|
3625
3664
|
}
|
|
3626
3665
|
buildComponentHierarchy(element) {
|
|
3627
3666
|
const hierarchy = [];
|
|
3628
|
-
let
|
|
3667
|
+
let current2 = element;
|
|
3629
3668
|
let sawPageSlot = false;
|
|
3630
|
-
while (
|
|
3631
|
-
if (
|
|
3632
|
-
hierarchy.push(
|
|
3633
|
-
if (
|
|
3669
|
+
while (current2) {
|
|
3670
|
+
if (current2.hasAttribute("data-amplifyup-component") || current2.hasAttribute("data-component-id") || current2.hasAttribute("data-amplifyup-slot") || current2.hasAttribute("data-slot-id") || current2.hasAttribute("data-node-id") || current2.hasAttribute("data-amplifyup-node")) {
|
|
3671
|
+
hierarchy.push(current2);
|
|
3672
|
+
if (current2.getAttribute("data-slot-source") === "page") {
|
|
3634
3673
|
sawPageSlot = true;
|
|
3635
3674
|
}
|
|
3636
3675
|
}
|
|
3637
|
-
|
|
3676
|
+
current2 = current2.parentElement;
|
|
3638
3677
|
}
|
|
3639
3678
|
const ordered = hierarchy.reverse();
|
|
3640
3679
|
if (!sawPageSlot) {
|
|
@@ -3857,6 +3896,6 @@ var verifyAWSConnection = () => {
|
|
|
3857
3896
|
};
|
|
3858
3897
|
var src_default = getSDK();
|
|
3859
3898
|
|
|
3860
|
-
export { AMPLIFYUP_EDITOR_ROUTE, ANON_COOKIE_NAME, AmplifyUpSDK, DWELL_ACTIVITY_IDLE_MS, DeliveryRequestError, EdgeResolveError, QueryContentError, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, SelectVariantsError, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, src_default as default, fetchContent, fetchEdgeQuery, fetchEdgeResolve, fetchEdgeSelect, fetchPageConfig, getDiagnostics, getFormDefinition, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getSessionId2 as getSessionId, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpEditorRoute, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, isWorkingContentRequest, mapResolvedToPageConfig, nextPageSpec, normalizeAmplifyUpTarget, normalizeRoute, page, queryContent, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, routeChange, searchSpec, selectVariants, setProfileFields, setupComponentViewTracking, setupEventTracking, submitForm, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
3899
|
+
export { AMPLIFYUP_EDITOR_ROUTE, ANON_COOKIE_NAME, AmplifyUpSDK, DWELL_ACTIVITY_IDLE_MS, DeliveryRequestError, EdgeResolveError, QueryContentError, SESSION_COOKIE_NAME, SESSION_IDLE_GAP_MS, SelectVariantsError, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, src_default as default, fetchContent, fetchEdgeQuery, fetchEdgeResolve, fetchEdgeSelect, fetchPageConfig, getConsent, getDiagnostics, getFormDefinition, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getSessionId2 as getSessionId, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpEditorRoute, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, isWorkingContentRequest, mapResolvedToPageConfig, nextPageSpec, normalizeAmplifyUpTarget, normalizeRoute, page, queryContent, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, routeChange, searchSpec, selectVariants, setConsent, setProfileFields, setupComponentViewTracking, setupEventTracking, submitForm, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
3861
3900
|
//# sourceMappingURL=index.mjs.map
|
|
3862
3901
|
//# sourceMappingURL=index.mjs.map
|