@weaverse/core 0.5.7 → 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
@@ -33,7 +33,7 @@ declare type InspectorOption = {
33
33
  value: TODO;
34
34
  label: string;
35
35
  };
36
- declare type InspectorInputType = "alignment" | "color" | "switch" | "spacing" | "textarea" | "input" | "select" | "grid" | "flex";
36
+ declare type InspectorInputType = "alignment" | "color" | "dimensions" | "flex" | "grid" | "input" | "switch" | "spacing" | "textarea" | "select" | "visibility" | "border" | "image";
37
37
  declare global {
38
38
  interface Window {
39
39
  WeaverseStudioBridge: TODO;
@@ -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
  */
@@ -141,7 +142,6 @@ declare class Weaverse {
141
142
  static WeaverseItemStore: typeof WeaverseItemStore;
142
143
  mediaBreakPoints: {
143
144
  desktop: string;
144
- tablet: string;
145
145
  mobile: string;
146
146
  };
147
147
  /**
@@ -151,7 +151,7 @@ declare class Weaverse {
151
151
  * @param projectData {ProjectDataType} Weaverse project data, by default, user can provide project data via React Component.
152
152
  * @param mediaBreakPoints {object} Pass down custom media query breakpoints or just use the default.
153
153
  */
154
- constructor({ appUrl, projectKey, projectData, mediaBreakPoints }?: WeaverseType);
154
+ constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode }?: WeaverseType);
155
155
  /**
156
156
  * register the custom React Component to Weaverse, store it into Weaverse.elementInstances
157
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,10 +103,9 @@ 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
- tablet: "(max-width: 1023.98px)",
110
109
  mobile: "(max-width: 767.98px)"
111
110
  };
112
111
  this.initStitches = () => {
@@ -127,6 +126,8 @@ var _Weaverse = class {
127
126
  this.appUrl = appUrl || this.appUrl;
128
127
  this.projectKey = projectKey || this.projectKey;
129
128
  this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
129
+ this.isDesignMode = isDesignMode || this.isDesignMode;
130
+ console.log("set design mode", this.isDesignMode);
130
131
  projectData && (this.projectData = projectData);
131
132
  this.init();
132
133
  }
@@ -144,8 +145,8 @@ var _Weaverse = class {
144
145
  this.initProjectItemData();
145
146
  }
146
147
  loadStudio() {
147
- if (isIframe) {
148
- this.isEditor = true;
148
+ console.log("this.isDesignMode", this.isDesignMode);
149
+ if (this.isDesignMode && isIframe) {
149
150
  let initStudio = () => {
150
151
  this.studioBridge = new window.WeaverseStudioBridge(this);
151
152
  this.studioBridge.subscribeMessageEvent();
@@ -170,7 +171,7 @@ var _Weaverse = class {
170
171
  }
171
172
  triggerUpdate() {
172
173
  this.listeners.forEach((fn) => fn());
173
- if (this.isEditor && this.studioBridge) {
174
+ if (this.isDesignMode && this.studioBridge) {
174
175
  this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
175
176
  projectData: this.projectData,
176
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,10 +74,9 @@ 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
- tablet: "(max-width: 1023.98px)",
81
80
  mobile: "(max-width: 767.98px)"
82
81
  };
83
82
  this.initStitches = () => {
@@ -98,6 +97,8 @@ var _Weaverse = class {
98
97
  this.appUrl = appUrl || this.appUrl;
99
98
  this.projectKey = projectKey || this.projectKey;
100
99
  this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
100
+ this.isDesignMode = isDesignMode || this.isDesignMode;
101
+ console.log("set design mode", this.isDesignMode);
101
102
  projectData && (this.projectData = projectData);
102
103
  this.init();
103
104
  }
@@ -115,8 +116,8 @@ var _Weaverse = class {
115
116
  this.initProjectItemData();
116
117
  }
117
118
  loadStudio() {
118
- if (isIframe) {
119
- this.isEditor = true;
119
+ console.log("this.isDesignMode", this.isDesignMode);
120
+ if (this.isDesignMode && isIframe) {
120
121
  let initStudio = () => {
121
122
  this.studioBridge = new window.WeaverseStudioBridge(this);
122
123
  this.studioBridge.subscribeMessageEvent();
@@ -141,7 +142,7 @@ var _Weaverse = class {
141
142
  }
142
143
  triggerUpdate() {
143
144
  this.listeners.forEach((fn) => fn());
144
- if (this.isEditor && this.studioBridge) {
145
+ if (this.isDesignMode && this.studioBridge) {
145
146
  this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
146
147
  projectData: this.projectData,
147
148
  projectKey: this.projectKey,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.7",
2
+ "version": "0.5.10",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",