@weaverse/core 0.5.11 → 0.6.1

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
@@ -9,31 +9,26 @@ declare type WeaverseElement = {
9
9
  schema: WeaverseElementSchema;
10
10
  };
11
11
  declare type WeaverseElementSchema = {
12
- title: string;
12
+ title?: string;
13
13
  type: string;
14
- settings: WeaverseElementSetting[];
14
+ settings?: WeaverseElementSettingInput[];
15
+ styles?: WeaverseElementStyleInput[];
15
16
  toolbar?: TODO;
16
17
  data?: TODO;
17
18
  };
18
- declare type WeaverseElementSetting = {
19
- tab: string;
20
- label: string;
21
- inspectors: WeaverseElementInspector[];
22
- };
23
- declare type WeaverseElementInspector = {
24
- binding?: "data" | "style";
25
- key?: string;
26
- label?: string;
27
- placeholder?: string;
28
- type: InspectorInputType;
29
- options?: InspectorOption[];
30
- default?: TODO;
19
+ declare type WeaverseElementStyleInput = {
20
+ name?: string;
21
+ type: 'alignment' | 'color' | 'dimensions' | 'flex' | 'grid' | 'input' | 'switch' | 'spacing' | 'textarea' | 'visibility' | 'border' | 'background' | 'typography' | 'shadow' | 'position' | 'overflow' | 'display' | 'other';
22
+ defaultValue?: string;
31
23
  };
32
- declare type InspectorOption = {
33
- value: TODO;
34
- label: string;
24
+ declare type WeaverseElementSettingInput = {
25
+ type: 'input' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'color' | 'range' | 'button' | 'image';
26
+ name: string;
27
+ defaultValue?: string;
28
+ helpText?: string;
29
+ options?: TODO[];
30
+ condition?: TODO;
35
31
  };
36
- declare type InspectorInputType = "alignment" | "color" | "dimensions" | "flex" | "grid" | "input" | "switch" | "spacing" | "textarea" | "select" | "visibility" | "border" | "image";
37
32
  declare global {
38
33
  interface Window {
39
34
  WeaverseStudioBridge: TODO;
@@ -185,4 +180,4 @@ declare const isReactNative: boolean;
185
180
  declare const isBrowser: boolean;
186
181
  declare const isIframe: boolean;
187
182
 
188
- export { InspectorInputType, InspectorOption, MediaBreakpoints, ProjectDataItemType, ProjectDataType, TODO, Weaverse, WeaverseElement, WeaverseElementInspector, WeaverseElementMap, WeaverseElementSchema, WeaverseElementSetting, WeaverseItemStore, WeaverseType, isBrowser, isIframe, isReactNative };
183
+ export { MediaBreakpoints, ProjectDataItemType, ProjectDataType, TODO, Weaverse, WeaverseElement, WeaverseElementMap, WeaverseElementSchema, WeaverseElementSettingInput, WeaverseElementStyleInput, WeaverseItemStore, WeaverseType, isBrowser, isIframe, isReactNative };
package/dist/index.js CHANGED
@@ -127,7 +127,6 @@ var _Weaverse = class {
127
127
  this.projectKey = projectKey || this.projectKey;
128
128
  this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
129
129
  this.isDesignMode = isDesignMode || this.isDesignMode;
130
- console.log("set design mode", this.isDesignMode);
131
130
  projectData && (this.projectData = projectData);
132
131
  this.init();
133
132
  }
@@ -143,13 +142,12 @@ var _Weaverse = class {
143
142
  this.initStitches();
144
143
  this.loadStudio();
145
144
  this.initProjectItemData();
145
+ this.updateProjectData();
146
146
  }
147
147
  loadStudio() {
148
- console.log("this.isDesignMode", this.isDesignMode);
149
148
  if (this.isDesignMode && isIframe) {
150
149
  let initStudio = () => {
151
150
  this.studioBridge = new window.WeaverseStudioBridge(this);
152
- this.studioBridge.subscribeMessageEvent();
153
151
  this.triggerUpdate();
154
152
  };
155
153
  if (!window.WeaverseStudioBridge) {
@@ -171,13 +169,6 @@ var _Weaverse = class {
171
169
  }
172
170
  triggerUpdate() {
173
171
  this.listeners.forEach((fn) => fn());
174
- if (this.isDesignMode && this.studioBridge) {
175
- this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
176
- projectData: this.projectData,
177
- projectKey: this.projectKey,
178
- appUrl: this.appUrl
179
- });
180
- }
181
172
  }
182
173
  static fetchProjectData({
183
174
  fetch = globalThis.fetch,
@@ -187,7 +178,7 @@ var _Weaverse = class {
187
178
  return fetch(appUrl + `/api/public/${projectKey}`).then((r) => r.json()).catch(console.error);
188
179
  }
189
180
  updateProjectData() {
190
- if (this.projectKey) {
181
+ if (this.projectKey && !this.projectData.rootId) {
191
182
  _Weaverse.fetchProjectData({ appUrl: this.appUrl, projectKey: this.projectKey }).then((data) => {
192
183
  if (data) {
193
184
  this.projectData = data;
package/dist/index.mjs CHANGED
@@ -98,7 +98,6 @@ var _Weaverse = class {
98
98
  this.projectKey = projectKey || this.projectKey;
99
99
  this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
100
100
  this.isDesignMode = isDesignMode || this.isDesignMode;
101
- console.log("set design mode", this.isDesignMode);
102
101
  projectData && (this.projectData = projectData);
103
102
  this.init();
104
103
  }
@@ -114,13 +113,12 @@ var _Weaverse = class {
114
113
  this.initStitches();
115
114
  this.loadStudio();
116
115
  this.initProjectItemData();
116
+ this.updateProjectData();
117
117
  }
118
118
  loadStudio() {
119
- console.log("this.isDesignMode", this.isDesignMode);
120
119
  if (this.isDesignMode && isIframe) {
121
120
  let initStudio = () => {
122
121
  this.studioBridge = new window.WeaverseStudioBridge(this);
123
- this.studioBridge.subscribeMessageEvent();
124
122
  this.triggerUpdate();
125
123
  };
126
124
  if (!window.WeaverseStudioBridge) {
@@ -142,13 +140,6 @@ var _Weaverse = class {
142
140
  }
143
141
  triggerUpdate() {
144
142
  this.listeners.forEach((fn) => fn());
145
- if (this.isDesignMode && this.studioBridge) {
146
- this.studioBridge.sendMessageToEditor("weaverse.editor.updateProject", {
147
- projectData: this.projectData,
148
- projectKey: this.projectKey,
149
- appUrl: this.appUrl
150
- });
151
- }
152
143
  }
153
144
  static fetchProjectData({
154
145
  fetch = globalThis.fetch,
@@ -158,7 +149,7 @@ var _Weaverse = class {
158
149
  return fetch(appUrl + `/api/public/${projectKey}`).then((r) => r.json()).catch(console.error);
159
150
  }
160
151
  updateProjectData() {
161
- if (this.projectKey) {
152
+ if (this.projectKey && !this.projectData.rootId) {
162
153
  _Weaverse.fetchProjectData({ appUrl: this.appUrl, projectKey: this.projectKey }).then((data) => {
163
154
  if (data) {
164
155
  this.projectData = data;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.11",
2
+ "version": "0.6.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",