@weaverse/core 0.5.9 → 0.5.12

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,7 @@ 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;
129
130
  projectData && (this.projectData = projectData);
130
131
  this.init();
131
132
  }
@@ -143,11 +144,9 @@ var _Weaverse = class {
143
144
  this.initProjectItemData();
144
145
  }
145
146
  loadStudio() {
146
- if (isIframe) {
147
- this.isEditor = true;
147
+ if (this.isDesignMode && isIframe) {
148
148
  let initStudio = () => {
149
149
  this.studioBridge = new window.WeaverseStudioBridge(this);
150
- this.studioBridge.subscribeMessageEvent();
151
150
  this.triggerUpdate();
152
151
  };
153
152
  if (!window.WeaverseStudioBridge) {
@@ -169,7 +168,7 @@ var _Weaverse = class {
169
168
  }
170
169
  triggerUpdate() {
171
170
  this.listeners.forEach((fn) => fn());
172
- if (this.isEditor && this.studioBridge) {
171
+ if (this.isDesignMode && this.studioBridge) {
173
172
  this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
174
173
  projectData: this.projectData,
175
174
  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,7 @@ 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;
100
101
  projectData && (this.projectData = projectData);
101
102
  this.init();
102
103
  }
@@ -114,11 +115,9 @@ var _Weaverse = class {
114
115
  this.initProjectItemData();
115
116
  }
116
117
  loadStudio() {
117
- if (isIframe) {
118
- this.isEditor = true;
118
+ if (this.isDesignMode && isIframe) {
119
119
  let initStudio = () => {
120
120
  this.studioBridge = new window.WeaverseStudioBridge(this);
121
- this.studioBridge.subscribeMessageEvent();
122
121
  this.triggerUpdate();
123
122
  };
124
123
  if (!window.WeaverseStudioBridge) {
@@ -140,7 +139,7 @@ var _Weaverse = class {
140
139
  }
141
140
  triggerUpdate() {
142
141
  this.listeners.forEach((fn) => fn());
143
- if (this.isEditor && this.studioBridge) {
142
+ if (this.isDesignMode && this.studioBridge) {
144
143
  this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
145
144
  projectData: this.projectData,
146
145
  projectKey: this.projectKey,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.9",
2
+ "version": "0.5.12",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",