@weaverse/hydrogen 5.14.0 → 5.14.1
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/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +53 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -930,7 +930,6 @@ declare module '@shopify/hydrogen' {
|
|
|
930
930
|
PUBLIC_SHOPIFY_INBOX_SHOP_ID: string;
|
|
931
931
|
PUBLIC_STORE_DOMAIN: string;
|
|
932
932
|
PUBLIC_STOREFRONT_API_TOKEN: string;
|
|
933
|
-
WEAVERSE_API_BASE?: string;
|
|
934
933
|
WEAVERSE_API_KEY: string;
|
|
935
934
|
WEAVERSE_HOST?: string;
|
|
936
935
|
WEAVERSE_PROJECT_ID: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -930,7 +930,6 @@ declare module '@shopify/hydrogen' {
|
|
|
930
930
|
PUBLIC_SHOPIFY_INBOX_SHOP_ID: string;
|
|
931
931
|
PUBLIC_STORE_DOMAIN: string;
|
|
932
932
|
PUBLIC_STOREFRONT_API_TOKEN: string;
|
|
933
|
-
WEAVERSE_API_BASE?: string;
|
|
934
933
|
WEAVERSE_API_KEY: string;
|
|
935
934
|
WEAVERSE_HOST?: string;
|
|
936
935
|
WEAVERSE_PROJECT_ID: string;
|
package/dist/index.js
CHANGED
|
@@ -297,7 +297,6 @@ function getWeaverseConfigs(request, env) {
|
|
|
297
297
|
WEAVERSE_PROJECT_ID,
|
|
298
298
|
WEAVERSE_API_KEY,
|
|
299
299
|
WEAVERSE_HOST,
|
|
300
|
-
WEAVERSE_API_BASE,
|
|
301
300
|
PUBLIC_STORE_DOMAIN,
|
|
302
301
|
PUBLIC_STOREFRONT_API_TOKEN
|
|
303
302
|
} = env || {};
|
|
@@ -313,10 +312,11 @@ function getWeaverseConfigs(request, env) {
|
|
|
313
312
|
} = queries;
|
|
314
313
|
let url = new URL(request.url);
|
|
315
314
|
let isRevisionPreview = url.searchParams.has("__revisionId");
|
|
315
|
+
let resolvedWeaverseHost = weaverseHost || WEAVERSE_HOST || envFromProcess.WEAVERSE_HOST || "https://studio.weaverse.io";
|
|
316
316
|
return {
|
|
317
317
|
projectId: weaverseProjectId || WEAVERSE_PROJECT_ID || envFromProcess.WEAVERSE_PROJECT_ID || "",
|
|
318
|
-
weaverseHost:
|
|
319
|
-
weaverseApiBase:
|
|
318
|
+
weaverseHost: resolvedWeaverseHost,
|
|
319
|
+
weaverseApiBase: resolvedWeaverseHost,
|
|
320
320
|
weaverseApiKey: weaverseApiKey || WEAVERSE_API_KEY || envFromProcess.WEAVERSE_API_KEY || "",
|
|
321
321
|
weaverseVersion: weaverseVersion || "",
|
|
322
322
|
isDesignMode,
|
|
@@ -507,6 +507,46 @@ function hasWeaverseData(value) {
|
|
|
507
507
|
}
|
|
508
508
|
return value.weaverseData !== void 0;
|
|
509
509
|
}
|
|
510
|
+
|
|
511
|
+
// src/utils/studio-request-info.ts
|
|
512
|
+
function getBrowserLocation() {
|
|
513
|
+
if (typeof window === "undefined") {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
return window.location;
|
|
517
|
+
}
|
|
518
|
+
function getQueriesFromSearch(search) {
|
|
519
|
+
let queries = {};
|
|
520
|
+
let params = new URLSearchParams(search);
|
|
521
|
+
for (let [key, value] of params.entries()) {
|
|
522
|
+
if (value === "true") {
|
|
523
|
+
queries[key] = true;
|
|
524
|
+
} else if (value === "false") {
|
|
525
|
+
queries[key] = false;
|
|
526
|
+
} else {
|
|
527
|
+
queries[key] = value;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return queries;
|
|
531
|
+
}
|
|
532
|
+
function normalizeDesignModeRequestInfo(params, browserLocation = getBrowserLocation()) {
|
|
533
|
+
if (!(params.isDesignMode && browserLocation)) {
|
|
534
|
+
return params;
|
|
535
|
+
}
|
|
536
|
+
let { pathname, search } = browserLocation;
|
|
537
|
+
if (params.requestInfo.pathname === pathname && params.requestInfo.search === search) {
|
|
538
|
+
return params;
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
...params,
|
|
542
|
+
requestInfo: {
|
|
543
|
+
...params.requestInfo,
|
|
544
|
+
pathname,
|
|
545
|
+
queries: getQueriesFromSearch(search),
|
|
546
|
+
search
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
}
|
|
510
550
|
var ThemeSettingsStore = class {
|
|
511
551
|
settings = {};
|
|
512
552
|
schema;
|
|
@@ -826,22 +866,23 @@ var WeaverseHydrogen = class extends react.Weaverse {
|
|
|
826
866
|
};
|
|
827
867
|
};
|
|
828
868
|
function createWeaverseInstance(params) {
|
|
869
|
+
const normalizedParams = normalizeDesignModeRequestInfo(params);
|
|
829
870
|
if (react.isBrowser) {
|
|
830
871
|
window.__weaverses = window.__weaverses || {};
|
|
831
|
-
let weaverse = window.__weaverses[
|
|
832
|
-
if (!weaverse || weaverse?.requestInfo?.pathname !==
|
|
833
|
-
weaverse = new WeaverseHydrogen(
|
|
834
|
-
window.__weaverses[
|
|
872
|
+
let weaverse = window.__weaverses[normalizedParams.pageId];
|
|
873
|
+
if (!weaverse || weaverse?.requestInfo?.pathname !== normalizedParams.requestInfo.pathname || weaverse?.requestInfo?.search !== normalizedParams.requestInfo.search) {
|
|
874
|
+
weaverse = new WeaverseHydrogen(normalizedParams);
|
|
875
|
+
window.__weaverses[normalizedParams.pageId] = weaverse;
|
|
835
876
|
}
|
|
836
877
|
if (weaverse?.isDesignMode) {
|
|
837
|
-
weaverse.requestInfo =
|
|
878
|
+
weaverse.requestInfo = normalizedParams.requestInfo;
|
|
838
879
|
if (hasWeaverseStudio(window)) {
|
|
839
|
-
window.weaverseStudio.refreshStudio(
|
|
880
|
+
window.weaverseStudio.refreshStudio(normalizedParams);
|
|
840
881
|
}
|
|
841
882
|
}
|
|
842
883
|
return weaverse;
|
|
843
884
|
}
|
|
844
|
-
return new WeaverseHydrogen(
|
|
885
|
+
return new WeaverseHydrogen(normalizedParams);
|
|
845
886
|
}
|
|
846
887
|
var StudioBridge = react$1.memo(({ context }) => {
|
|
847
888
|
useStudio(context);
|
|
@@ -1286,11 +1327,8 @@ var WeaverseClient = class {
|
|
|
1286
1327
|
}
|
|
1287
1328
|
};
|
|
1288
1329
|
// Helper method for building API URLs consistently
|
|
1289
|
-
getApiUrl(endpoint
|
|
1290
|
-
const { weaverseHost
|
|
1291
|
-
if (useProxy) {
|
|
1292
|
-
return `${weaverseApiBase}/v1/${endpoint}?projectId=${projectId}`;
|
|
1293
|
-
}
|
|
1330
|
+
getApiUrl(endpoint) {
|
|
1331
|
+
const { weaverseHost } = this.configs;
|
|
1294
1332
|
return `${weaverseHost}/api/public/${endpoint}`;
|
|
1295
1333
|
}
|
|
1296
1334
|
/**
|