@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/index.mjs
CHANGED
|
@@ -230,14 +230,16 @@ function resolveAmplifyUpTarget(options) {
|
|
|
230
230
|
if (isAmplifyUpTarget(envTarget)) {
|
|
231
231
|
return normalizeAmplifyUpTarget(envTarget);
|
|
232
232
|
}
|
|
233
|
-
if (typeof window !== "undefined") {
|
|
234
|
-
const host = window.location.hostname;
|
|
235
|
-
if (host === "localhost" || host === "127.0.0.1") {
|
|
236
|
-
return "local";
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
233
|
return "production";
|
|
240
234
|
}
|
|
235
|
+
function isRemoteOrchestratorUrl(orchestratorUrl) {
|
|
236
|
+
try {
|
|
237
|
+
const host = new URL(orchestratorUrl).hostname.toLowerCase();
|
|
238
|
+
return host !== "localhost" && host !== "127.0.0.1" && host !== "::1";
|
|
239
|
+
} catch {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
241
243
|
function localOrchestratorUrl() {
|
|
242
244
|
const fromEnv = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_ORCHESTRATOR_URL : void 0;
|
|
243
245
|
return (fromEnv || "http://localhost:5001").replace(/\/$/, "");
|
|
@@ -272,6 +274,26 @@ function resolveAmplifyUpUrls(target) {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
// src/index.ts
|
|
277
|
+
function readPreviewQueryOverrides() {
|
|
278
|
+
if (typeof window === "undefined") return {};
|
|
279
|
+
const params = new URLSearchParams(window.location.search);
|
|
280
|
+
if (params.get("preview") !== "true" && params.get("visualEditor") !== "true") {
|
|
281
|
+
return {};
|
|
282
|
+
}
|
|
283
|
+
const overrides = {};
|
|
284
|
+
const orchestratorFromQuery = params.get("orchestratorUrl");
|
|
285
|
+
if (orchestratorFromQuery) {
|
|
286
|
+
try {
|
|
287
|
+
overrides.orchestratorUrl = new URL(orchestratorFromQuery).origin.replace(/\/$/, "");
|
|
288
|
+
} catch {
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const trackingFromQuery = params.get("trackingId");
|
|
292
|
+
if (trackingFromQuery) {
|
|
293
|
+
overrides.trackingId = trackingFromQuery;
|
|
294
|
+
}
|
|
295
|
+
return overrides;
|
|
296
|
+
}
|
|
275
297
|
var AmplifyUpSDK = class {
|
|
276
298
|
constructor(adapter) {
|
|
277
299
|
this.config = null;
|
|
@@ -397,8 +419,18 @@ var AmplifyUpSDK = class {
|
|
|
397
419
|
this.apiGatewayUrl = urls.apiGatewayUrl;
|
|
398
420
|
this.orchestratorUrl = urls.orchestratorUrl;
|
|
399
421
|
this.decisionApiUrl = urls.decisionApiUrl;
|
|
422
|
+
const previewOverrides = readPreviewQueryOverrides();
|
|
423
|
+
if (previewOverrides.orchestratorUrl) {
|
|
424
|
+
this.orchestratorUrl = previewOverrides.orchestratorUrl;
|
|
425
|
+
if (isRemoteOrchestratorUrl(previewOverrides.orchestratorUrl)) {
|
|
426
|
+
const prodUrls = resolveAmplifyUpUrls("production");
|
|
427
|
+
this.target = "production";
|
|
428
|
+
this.apiGatewayUrl = prodUrls.apiGatewayUrl;
|
|
429
|
+
this.decisionApiUrl = prodUrls.decisionApiUrl;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
400
432
|
this.config = {
|
|
401
|
-
trackingId: config.trackingId,
|
|
433
|
+
trackingId: previewOverrides.trackingId || config.trackingId,
|
|
402
434
|
debug: config.debug ?? true,
|
|
403
435
|
// Enable debug by default
|
|
404
436
|
target: this.target,
|