@weaverse/next 0.1.0-alpha.14 → 0.1.0-alpha.16
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.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types/renderer.d.ts +2 -1
- package/dist/types/renderer.d.ts.map +1 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/studio-script-src.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/renderer.tsx +2 -1
- package/src/runtime.ts +49 -15
- package/src/studio-script-src.ts +4 -1
package/dist/index.js
CHANGED
|
@@ -674,6 +674,12 @@ function getConfigString(configs, key) {
|
|
|
674
674
|
let value = configs?.[key];
|
|
675
675
|
return typeof value === "string" ? value : void 0;
|
|
676
676
|
}
|
|
677
|
+
function resolveModeFlag(config, key) {
|
|
678
|
+
return config.client?.requestContext?.[key] === true || config.data.configs?.[key] === true;
|
|
679
|
+
}
|
|
680
|
+
function resolveSectionType(config) {
|
|
681
|
+
return config.client?.requestContext?.sectionType || getConfigString(config.data.configs, "sectionType") || void 0;
|
|
682
|
+
}
|
|
677
683
|
function getRecordString(record, key) {
|
|
678
684
|
let value = record?.[key];
|
|
679
685
|
return typeof value === "string" ? value : void 0;
|
|
@@ -768,22 +774,26 @@ var WeaverseNextRuntime = class extends react.Weaverse {
|
|
|
768
774
|
let page = getRenderablePage(data);
|
|
769
775
|
let configs = data.configs;
|
|
770
776
|
let requestContext = client?.requestContext;
|
|
777
|
+
let isDesignMode = resolveModeFlag(config, "isDesignMode");
|
|
778
|
+
let isPreviewMode = resolveModeFlag(config, "isPreviewMode");
|
|
779
|
+
let isRevisionPreview = resolveModeFlag(config, "isRevisionPreview");
|
|
780
|
+
let sectionType = resolveSectionType(config);
|
|
771
781
|
let projectId = resolveProjectId(client, data, page.id);
|
|
772
782
|
ensureNextItemConstructor();
|
|
773
783
|
super({
|
|
774
784
|
projectId,
|
|
775
785
|
data: page,
|
|
776
|
-
isDesignMode
|
|
786
|
+
isDesignMode,
|
|
777
787
|
weaverseHost: getConfigString(configs, "weaverseHost"),
|
|
778
788
|
weaverseVersion: getConfigString(configs, "weaverseVersion")
|
|
779
789
|
});
|
|
780
790
|
this.pageId = page.id;
|
|
781
791
|
this.dataContext = resolveDataContext(config);
|
|
782
792
|
this.requestInfo = buildWeaverseNextRequestInfo(requestContext);
|
|
783
|
-
this.isDesignMode =
|
|
784
|
-
this.isPreviewMode =
|
|
785
|
-
this.isRevisionPreview =
|
|
786
|
-
this.sectionType =
|
|
793
|
+
this.isDesignMode = isDesignMode;
|
|
794
|
+
this.isPreviewMode = isPreviewMode;
|
|
795
|
+
this.isRevisionPreview = isRevisionPreview;
|
|
796
|
+
this.sectionType = sectionType;
|
|
787
797
|
let translationStore = config.translationStore ?? new TranslationStore();
|
|
788
798
|
this.internal = {
|
|
789
799
|
merchantOverrides: config.merchantOverrides,
|
|
@@ -915,7 +925,11 @@ function createWeaverseNextRuntime(config) {
|
|
|
915
925
|
let existing = runtimeWindow?.__weaverses?.[page.id];
|
|
916
926
|
let requestKey = getRuntimeKey(page.id, requestInfo);
|
|
917
927
|
if (existing?.__weaverseNextRequestKey === requestKey) {
|
|
918
|
-
let
|
|
928
|
+
let configs = config.data.configs;
|
|
929
|
+
let nextIsDesignMode = resolveModeFlag(config, "isDesignMode");
|
|
930
|
+
let nextIsPreviewMode = resolveModeFlag(config, "isPreviewMode");
|
|
931
|
+
let nextIsRevisionPreview = resolveModeFlag(config, "isRevisionPreview");
|
|
932
|
+
let nextSectionType = resolveSectionType(config);
|
|
919
933
|
if (existing.isDesignMode || nextIsDesignMode) {
|
|
920
934
|
existing.pendingProjectData = void 0;
|
|
921
935
|
} else {
|
|
@@ -926,11 +940,11 @@ function createWeaverseNextRuntime(config) {
|
|
|
926
940
|
existing.requestInfo = requestInfo;
|
|
927
941
|
existing.projectId = resolveProjectId(config.client, config.data, page.id);
|
|
928
942
|
existing.isDesignMode = nextIsDesignMode;
|
|
929
|
-
existing.isPreviewMode =
|
|
930
|
-
existing.isRevisionPreview =
|
|
931
|
-
existing.sectionType =
|
|
932
|
-
existing.weaverseHost = getConfigString(
|
|
933
|
-
existing.weaverseVersion = getConfigString(
|
|
943
|
+
existing.isPreviewMode = nextIsPreviewMode;
|
|
944
|
+
existing.isRevisionPreview = nextIsRevisionPreview;
|
|
945
|
+
existing.sectionType = nextSectionType;
|
|
946
|
+
existing.weaverseHost = getConfigString(configs, "weaverseHost") ?? existing.weaverseHost;
|
|
947
|
+
existing.weaverseVersion = getConfigString(configs, "weaverseVersion") ?? existing.weaverseVersion;
|
|
934
948
|
existing.internal.pageAssignment = config.data.pageAssignment;
|
|
935
949
|
existing.internal.project = config.data.project;
|
|
936
950
|
if (config.navigate) {
|
|
@@ -1348,7 +1362,7 @@ function resolveWeaverseNextStudioScriptSrc(context, options = {}) {
|
|
|
1348
1362
|
if (!isTrustedStudioOrigin(origin, storefrontHostname)) {
|
|
1349
1363
|
return null;
|
|
1350
1364
|
}
|
|
1351
|
-
let bundle =
|
|
1365
|
+
let bundle = isPreviewMode || isRevisionPreview ? "preview.js" : "index.js";
|
|
1352
1366
|
let version = last(searchParams, "weaverseVersion");
|
|
1353
1367
|
let url = `${origin}/static/studio/next/${bundle}`;
|
|
1354
1368
|
return version ? `${url}?v=${encodeURIComponent(version)}` : url;
|