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