@weaverse/next 0.1.0-alpha.15 → 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 +25 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -11
- 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/package.json +1 -1
- package/src/renderer.tsx +2 -1
- package/src/runtime.ts +49 -15
package/dist/index.mjs
CHANGED
|
@@ -509,6 +509,12 @@ function getConfigString(configs, key) {
|
|
|
509
509
|
let value = configs?.[key];
|
|
510
510
|
return typeof value === "string" ? value : void 0;
|
|
511
511
|
}
|
|
512
|
+
function resolveModeFlag(config, key) {
|
|
513
|
+
return config.client?.requestContext?.[key] === true || config.data.configs?.[key] === true;
|
|
514
|
+
}
|
|
515
|
+
function resolveSectionType(config) {
|
|
516
|
+
return config.client?.requestContext?.sectionType || getConfigString(config.data.configs, "sectionType") || void 0;
|
|
517
|
+
}
|
|
512
518
|
function getRecordString(record, key) {
|
|
513
519
|
let value = record?.[key];
|
|
514
520
|
return typeof value === "string" ? value : void 0;
|
|
@@ -603,22 +609,26 @@ var WeaverseNextRuntime = class extends Weaverse {
|
|
|
603
609
|
let page = getRenderablePage(data);
|
|
604
610
|
let configs = data.configs;
|
|
605
611
|
let requestContext = client?.requestContext;
|
|
612
|
+
let isDesignMode = resolveModeFlag(config, "isDesignMode");
|
|
613
|
+
let isPreviewMode = resolveModeFlag(config, "isPreviewMode");
|
|
614
|
+
let isRevisionPreview = resolveModeFlag(config, "isRevisionPreview");
|
|
615
|
+
let sectionType = resolveSectionType(config);
|
|
606
616
|
let projectId = resolveProjectId(client, data, page.id);
|
|
607
617
|
ensureNextItemConstructor();
|
|
608
618
|
super({
|
|
609
619
|
projectId,
|
|
610
620
|
data: page,
|
|
611
|
-
isDesignMode
|
|
621
|
+
isDesignMode,
|
|
612
622
|
weaverseHost: getConfigString(configs, "weaverseHost"),
|
|
613
623
|
weaverseVersion: getConfigString(configs, "weaverseVersion")
|
|
614
624
|
});
|
|
615
625
|
this.pageId = page.id;
|
|
616
626
|
this.dataContext = resolveDataContext(config);
|
|
617
627
|
this.requestInfo = buildWeaverseNextRequestInfo(requestContext);
|
|
618
|
-
this.isDesignMode =
|
|
619
|
-
this.isPreviewMode =
|
|
620
|
-
this.isRevisionPreview =
|
|
621
|
-
this.sectionType =
|
|
628
|
+
this.isDesignMode = isDesignMode;
|
|
629
|
+
this.isPreviewMode = isPreviewMode;
|
|
630
|
+
this.isRevisionPreview = isRevisionPreview;
|
|
631
|
+
this.sectionType = sectionType;
|
|
622
632
|
let translationStore = config.translationStore ?? new TranslationStore();
|
|
623
633
|
this.internal = {
|
|
624
634
|
merchantOverrides: config.merchantOverrides,
|
|
@@ -750,7 +760,11 @@ function createWeaverseNextRuntime(config) {
|
|
|
750
760
|
let existing = runtimeWindow?.__weaverses?.[page.id];
|
|
751
761
|
let requestKey = getRuntimeKey(page.id, requestInfo);
|
|
752
762
|
if (existing?.__weaverseNextRequestKey === requestKey) {
|
|
753
|
-
let
|
|
763
|
+
let configs = config.data.configs;
|
|
764
|
+
let nextIsDesignMode = resolveModeFlag(config, "isDesignMode");
|
|
765
|
+
let nextIsPreviewMode = resolveModeFlag(config, "isPreviewMode");
|
|
766
|
+
let nextIsRevisionPreview = resolveModeFlag(config, "isRevisionPreview");
|
|
767
|
+
let nextSectionType = resolveSectionType(config);
|
|
754
768
|
if (existing.isDesignMode || nextIsDesignMode) {
|
|
755
769
|
existing.pendingProjectData = void 0;
|
|
756
770
|
} else {
|
|
@@ -761,11 +775,11 @@ function createWeaverseNextRuntime(config) {
|
|
|
761
775
|
existing.requestInfo = requestInfo;
|
|
762
776
|
existing.projectId = resolveProjectId(config.client, config.data, page.id);
|
|
763
777
|
existing.isDesignMode = nextIsDesignMode;
|
|
764
|
-
existing.isPreviewMode =
|
|
765
|
-
existing.isRevisionPreview =
|
|
766
|
-
existing.sectionType =
|
|
767
|
-
existing.weaverseHost = getConfigString(
|
|
768
|
-
existing.weaverseVersion = getConfigString(
|
|
778
|
+
existing.isPreviewMode = nextIsPreviewMode;
|
|
779
|
+
existing.isRevisionPreview = nextIsRevisionPreview;
|
|
780
|
+
existing.sectionType = nextSectionType;
|
|
781
|
+
existing.weaverseHost = getConfigString(configs, "weaverseHost") ?? existing.weaverseHost;
|
|
782
|
+
existing.weaverseVersion = getConfigString(configs, "weaverseVersion") ?? existing.weaverseVersion;
|
|
769
783
|
existing.internal.pageAssignment = config.data.pageAssignment;
|
|
770
784
|
existing.internal.project = config.data.project;
|
|
771
785
|
if (config.navigate) {
|