@amplifyup/sdk 0.1.3 → 0.1.5
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 +9 -8
- package/dist/AmplifyRenderer.d.mts +1 -1
- package/dist/AmplifyRenderer.d.ts +1 -1
- package/dist/AmplifyRenderer.js +39 -7
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +39 -7
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -7
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +39 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +39 -7
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +0 -6
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +0 -6
- package/dist/server.mjs.map +1 -1
- package/dist/{types-Xv9P55Dj.d.mts → types-B2Swk8BW.d.mts} +10 -7
- package/dist/{types-Xv9P55Dj.d.ts → types-B2Swk8BW.d.ts} +10 -7
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -242,14 +242,16 @@ function resolveAmplifyUpTarget(options) {
|
|
|
242
242
|
if (isAmplifyUpTarget(envTarget)) {
|
|
243
243
|
return normalizeAmplifyUpTarget(envTarget);
|
|
244
244
|
}
|
|
245
|
-
if (typeof window !== "undefined") {
|
|
246
|
-
const host = window.location.hostname;
|
|
247
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
248
|
-
return "local";
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
245
|
return "production";
|
|
252
246
|
}
|
|
247
|
+
function isRemoteOrchestratorUrl(orchestratorUrl) {
|
|
248
|
+
try {
|
|
249
|
+
const host = new URL(orchestratorUrl).hostname.toLowerCase();
|
|
250
|
+
return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
|
|
251
|
+
} catch {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
253
255
|
function localOrchestratorUrl() {
|
|
254
256
|
const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
|
|
255
257
|
return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
|
|
@@ -284,6 +286,26 @@ function resolveAmplifyUpUrls(target) {
|
|
|
284
286
|
}
|
|
285
287
|
|
|
286
288
|
// src/index.ts
|
|
289
|
+
function readPreviewQueryOverrides() {
|
|
290
|
+
if (typeof window === "undefined") return {};
|
|
291
|
+
const params = new URLSearchParams(window.location.search);
|
|
292
|
+
if (params.get("preview") !== "true" && params.get("visualEditor") !== "true") {
|
|
293
|
+
return {};
|
|
294
|
+
}
|
|
295
|
+
const overrides = {};
|
|
296
|
+
const orchestratorFromQuery = params.get("orchestratorUrl");
|
|
297
|
+
if (orchestratorFromQuery) {
|
|
298
|
+
try {
|
|
299
|
+
overrides.orchestratorUrl = new URL(orchestratorFromQuery).origin.replace(/\/$/, "");
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const trackingFromQuery = params.get("trackingId");
|
|
304
|
+
if (trackingFromQuery) {
|
|
305
|
+
overrides.trackingId = trackingFromQuery;
|
|
306
|
+
}
|
|
307
|
+
return overrides;
|
|
308
|
+
}
|
|
287
309
|
var AmplifyUpSDK = class {
|
|
288
310
|
constructor(adapter) {
|
|
289
311
|
this.config = null;
|
|
@@ -409,8 +431,18 @@ var AmplifyUpSDK = class {
|
|
|
409
431
|
this.apiGatewayUrl = urls.apiGatewayUrl;
|
|
410
432
|
this.orchestratorUrl = urls.orchestratorUrl;
|
|
411
433
|
this.decisionApiUrl = urls.decisionApiUrl;
|
|
434
|
+
const previewOverrides = readPreviewQueryOverrides();
|
|
435
|
+
if (previewOverrides.orchestratorUrl) {
|
|
436
|
+
this.orchestratorUrl = previewOverrides.orchestratorUrl;
|
|
437
|
+
if (isRemoteOrchestratorUrl(previewOverrides.orchestratorUrl)) {
|
|
438
|
+
const prodUrls = resolveAmplifyUpUrls("production");
|
|
439
|
+
this.target = "production";
|
|
440
|
+
this.apiGatewayUrl = prodUrls.apiGatewayUrl;
|
|
441
|
+
this.decisionApiUrl = prodUrls.decisionApiUrl;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
412
444
|
this.config = {
|
|
413
|
-
trackingId: config.trackingId,
|
|
445
|
+
trackingId: previewOverrides.trackingId || config.trackingId,
|
|
414
446
|
debug: config.debug ?? true,
|
|
415
447
|
// Enable debug by default
|
|
416
448
|
target: this.target,
|