@weaverse/core 0.5.9 → 0.5.10

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.ts CHANGED
@@ -63,6 +63,7 @@ declare type WeaverseType = {
63
63
  appUrl?: string;
64
64
  projectKey?: string;
65
65
  projectData?: ProjectDataType;
66
+ isDesignMode?: boolean;
66
67
  };
67
68
  /**
68
69
  * WeaverseItemStore is a store for Weaverse item, it can be used to subscribe/update the item data
@@ -127,12 +128,12 @@ declare class Weaverse {
127
128
  */
128
129
  listeners: Set<any>;
129
130
  /**
130
- * check whether the sdk is inEditor or not
131
- * if isEditor is true, it means the sdk is inEditor mode, render the editor UI
131
+ * check whether the sdk is isDesignMode or not
132
+ * if isDesignMode is true, it means the sdk is isDesignMode mode, render the editor UI
132
133
  * else render the preview UI, plain HTML + CSS + React hydrate
133
134
  * @type {boolean}
134
135
  */
135
- isEditor: boolean;
136
+ isDesignMode: boolean;
136
137
  /**
137
138
  * stitches instance for handling CSS stylesheet, media, theme for Weaverse project
138
139
  */
@@ -150,7 +151,7 @@ declare class Weaverse {
150
151
  * @param projectData {ProjectDataType} Weaverse project data, by default, user can provide project data via React Component.
151
152
  * @param mediaBreakPoints {object} Pass down custom media query breakpoints or just use the default.
152
153
  */
153
- constructor({ appUrl, projectKey, projectData, mediaBreakPoints }?: WeaverseType);
154
+ constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode }?: WeaverseType);
154
155
  /**
155
156
  * register the custom React Component to Weaverse, store it into Weaverse.elementInstances
156
157
  * @param element {WeaverseElement} custom React Component
package/dist/index.js CHANGED
@@ -93,7 +93,7 @@ var WeaverseItemStore = class {
93
93
  }
94
94
  };
95
95
  var _Weaverse = class {
96
- constructor({ appUrl, projectKey, projectData, mediaBreakPoints } = {}) {
96
+ constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode } = {}) {
97
97
  this.elementInstances = /* @__PURE__ */ new Map();
98
98
  this.itemInstances = /* @__PURE__ */ new Map();
99
99
  this.appUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://weaverse.io";
@@ -103,7 +103,7 @@ var _Weaverse = class {
103
103
  rootId: 0
104
104
  };
105
105
  this.listeners = /* @__PURE__ */ new Set();
106
- this.isEditor = false;
106
+ this.isDesignMode = false;
107
107
  this.mediaBreakPoints = {
108
108
  desktop: "all",
109
109
  mobile: "(max-width: 767.98px)"
@@ -126,6 +126,8 @@ var _Weaverse = class {
126
126
  this.appUrl = appUrl || this.appUrl;
127
127
  this.projectKey = projectKey || this.projectKey;
128
128
  this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
129
+ this.isDesignMode = isDesignMode || this.isDesignMode;
130
+ console.log("set design mode", this.isDesignMode);
129
131
  projectData && (this.projectData = projectData);
130
132
  this.init();
131
133
  }
@@ -143,8 +145,8 @@ var _Weaverse = class {
143
145
  this.initProjectItemData();
144
146
  }
145
147
  loadStudio() {
146
- if (isIframe) {
147
- this.isEditor = true;
148
+ console.log("this.isDesignMode", this.isDesignMode);
149
+ if (this.isDesignMode && isIframe) {
148
150
  let initStudio = () => {
149
151
  this.studioBridge = new window.WeaverseStudioBridge(this);
150
152
  this.studioBridge.subscribeMessageEvent();
@@ -169,7 +171,7 @@ var _Weaverse = class {
169
171
  }
170
172
  triggerUpdate() {
171
173
  this.listeners.forEach((fn) => fn());
172
- if (this.isEditor && this.studioBridge) {
174
+ if (this.isDesignMode && this.studioBridge) {
173
175
  this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
174
176
  projectData: this.projectData,
175
177
  projectKey: this.projectKey,
package/dist/index.mjs CHANGED
@@ -64,7 +64,7 @@ var WeaverseItemStore = class {
64
64
  }
65
65
  };
66
66
  var _Weaverse = class {
67
- constructor({ appUrl, projectKey, projectData, mediaBreakPoints } = {}) {
67
+ constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode } = {}) {
68
68
  this.elementInstances = /* @__PURE__ */ new Map();
69
69
  this.itemInstances = /* @__PURE__ */ new Map();
70
70
  this.appUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://weaverse.io";
@@ -74,7 +74,7 @@ var _Weaverse = class {
74
74
  rootId: 0
75
75
  };
76
76
  this.listeners = /* @__PURE__ */ new Set();
77
- this.isEditor = false;
77
+ this.isDesignMode = false;
78
78
  this.mediaBreakPoints = {
79
79
  desktop: "all",
80
80
  mobile: "(max-width: 767.98px)"
@@ -97,6 +97,8 @@ var _Weaverse = class {
97
97
  this.appUrl = appUrl || this.appUrl;
98
98
  this.projectKey = projectKey || this.projectKey;
99
99
  this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
100
+ this.isDesignMode = isDesignMode || this.isDesignMode;
101
+ console.log("set design mode", this.isDesignMode);
100
102
  projectData && (this.projectData = projectData);
101
103
  this.init();
102
104
  }
@@ -114,8 +116,8 @@ var _Weaverse = class {
114
116
  this.initProjectItemData();
115
117
  }
116
118
  loadStudio() {
117
- if (isIframe) {
118
- this.isEditor = true;
119
+ console.log("this.isDesignMode", this.isDesignMode);
120
+ if (this.isDesignMode && isIframe) {
119
121
  let initStudio = () => {
120
122
  this.studioBridge = new window.WeaverseStudioBridge(this);
121
123
  this.studioBridge.subscribeMessageEvent();
@@ -140,7 +142,7 @@ var _Weaverse = class {
140
142
  }
141
143
  triggerUpdate() {
142
144
  this.listeners.forEach((fn) => fn());
143
- if (this.isEditor && this.studioBridge) {
145
+ if (this.isDesignMode && this.studioBridge) {
144
146
  this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
145
147
  projectData: this.projectData,
146
148
  projectKey: this.projectKey,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.9",
2
+ "version": "0.5.10",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",