@weaverse/core 0.7.68 → 0.7.70
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 +3 -1
- package/dist/index.js +27 -24
- package/dist/index.mjs +27 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -301,7 +301,9 @@ declare class Weaverse {
|
|
|
301
301
|
*/
|
|
302
302
|
constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode }?: WeaverseType);
|
|
303
303
|
init({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode }?: WeaverseType): void;
|
|
304
|
-
|
|
304
|
+
initialized: boolean;
|
|
305
|
+
initializeData: (data: any) => void;
|
|
306
|
+
loadStudio(version?: string): void;
|
|
305
307
|
/**
|
|
306
308
|
* Register the custom React Component to Weaverse, store it into Weaverse.elementInstances
|
|
307
309
|
* @param element {WeaverseElement} custom React Component
|
package/dist/index.js
CHANGED
|
@@ -218,6 +218,22 @@ var Weaverse = class {
|
|
|
218
218
|
// tablet: "(max-width: 1023.98px)", // to set css for tablet, {'@tablet' : { // css }},
|
|
219
219
|
mobile: "(max-width: 767.98px)"
|
|
220
220
|
};
|
|
221
|
+
this.initialized = false;
|
|
222
|
+
this.initializeData = (data) => {
|
|
223
|
+
if (!this.initialized) {
|
|
224
|
+
let { projectData, published, id, projectKey, studioUrl } = data;
|
|
225
|
+
this.projectKey = projectKey || this.projectKey;
|
|
226
|
+
this.appUrl = studioUrl || this.appUrl;
|
|
227
|
+
this.projectData = { ...projectData, pageId: id };
|
|
228
|
+
this.isDesignMode = !published;
|
|
229
|
+
this.initProjectItemData();
|
|
230
|
+
if (this.isDesignMode) {
|
|
231
|
+
this.triggerUpdate();
|
|
232
|
+
this.loadStudio();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
this.initialized = true;
|
|
236
|
+
};
|
|
221
237
|
this.initStitches = () => {
|
|
222
238
|
this.stitchesInstance = this.stitchesInstance || stitches.createStitches({
|
|
223
239
|
prefix: "weaverse",
|
|
@@ -237,29 +253,16 @@ var Weaverse = class {
|
|
|
237
253
|
this.initStitches();
|
|
238
254
|
this.initProjectItemData();
|
|
239
255
|
}
|
|
240
|
-
// initialized = false
|
|
241
|
-
// initializeData = (data: InitializeData) => {
|
|
242
|
-
// if (!this.initialized) {
|
|
243
|
-
// let { data: pageData, published, id, projectKey, studioUrl } = data
|
|
244
|
-
// this.projectKey = projectKey || this.projectKey
|
|
245
|
-
// this.appUrl = studioUrl || this.appUrl
|
|
246
|
-
// this.projectData = { ...pageData, pageId: id }
|
|
247
|
-
// this.isDesignMode = !published
|
|
248
|
-
// this.initProjectItemData()
|
|
249
|
-
// if (this.isDesignMode) {
|
|
250
|
-
// this.triggerUpdate()
|
|
251
|
-
// this.loadStudio()
|
|
252
|
-
// }
|
|
253
|
-
// }
|
|
254
|
-
// this.initialized = true
|
|
255
|
-
// }
|
|
256
256
|
loadStudio(version) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
console.log("load studio");
|
|
258
|
+
if (isIframe && this.isDesignMode && !this.studioBridge) {
|
|
259
|
+
const initStudio = () => {
|
|
260
|
+
this.studioBridge = new window.WeaverseStudioBridge(this);
|
|
261
|
+
this.triggerUpdate();
|
|
262
|
+
console.log("Studio loaded", this);
|
|
263
|
+
clearInterval(i);
|
|
264
|
+
};
|
|
265
|
+
let i = setInterval(() => {
|
|
263
266
|
if (!window.WeaverseStudioBridge) {
|
|
264
267
|
let studioBridgeScript = document.createElement("script");
|
|
265
268
|
studioBridgeScript.src = `${this.appUrl}/assets/studio/studio-bridge.js?v=${version}`;
|
|
@@ -269,8 +272,8 @@ var Weaverse = class {
|
|
|
269
272
|
} else {
|
|
270
273
|
initStudio();
|
|
271
274
|
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
275
|
+
}, 2e3);
|
|
276
|
+
}
|
|
274
277
|
}
|
|
275
278
|
/**
|
|
276
279
|
* Register the custom React Component to Weaverse, store it into Weaverse.elementInstances
|
package/dist/index.mjs
CHANGED
|
@@ -177,6 +177,22 @@ var Weaverse = class {
|
|
|
177
177
|
// tablet: "(max-width: 1023.98px)", // to set css for tablet, {'@tablet' : { // css }},
|
|
178
178
|
mobile: "(max-width: 767.98px)"
|
|
179
179
|
};
|
|
180
|
+
this.initialized = false;
|
|
181
|
+
this.initializeData = (data) => {
|
|
182
|
+
if (!this.initialized) {
|
|
183
|
+
let { projectData, published, id, projectKey, studioUrl } = data;
|
|
184
|
+
this.projectKey = projectKey || this.projectKey;
|
|
185
|
+
this.appUrl = studioUrl || this.appUrl;
|
|
186
|
+
this.projectData = { ...projectData, pageId: id };
|
|
187
|
+
this.isDesignMode = !published;
|
|
188
|
+
this.initProjectItemData();
|
|
189
|
+
if (this.isDesignMode) {
|
|
190
|
+
this.triggerUpdate();
|
|
191
|
+
this.loadStudio();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
this.initialized = true;
|
|
195
|
+
};
|
|
180
196
|
this.initStitches = () => {
|
|
181
197
|
this.stitchesInstance = this.stitchesInstance || stitches.createStitches({
|
|
182
198
|
prefix: "weaverse",
|
|
@@ -196,29 +212,16 @@ var Weaverse = class {
|
|
|
196
212
|
this.initStitches();
|
|
197
213
|
this.initProjectItemData();
|
|
198
214
|
}
|
|
199
|
-
// initialized = false
|
|
200
|
-
// initializeData = (data: InitializeData) => {
|
|
201
|
-
// if (!this.initialized) {
|
|
202
|
-
// let { data: pageData, published, id, projectKey, studioUrl } = data
|
|
203
|
-
// this.projectKey = projectKey || this.projectKey
|
|
204
|
-
// this.appUrl = studioUrl || this.appUrl
|
|
205
|
-
// this.projectData = { ...pageData, pageId: id }
|
|
206
|
-
// this.isDesignMode = !published
|
|
207
|
-
// this.initProjectItemData()
|
|
208
|
-
// if (this.isDesignMode) {
|
|
209
|
-
// this.triggerUpdate()
|
|
210
|
-
// this.loadStudio()
|
|
211
|
-
// }
|
|
212
|
-
// }
|
|
213
|
-
// this.initialized = true
|
|
214
|
-
// }
|
|
215
215
|
loadStudio(version) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
console.log("load studio");
|
|
217
|
+
if (isIframe && this.isDesignMode && !this.studioBridge) {
|
|
218
|
+
const initStudio = () => {
|
|
219
|
+
this.studioBridge = new window.WeaverseStudioBridge(this);
|
|
220
|
+
this.triggerUpdate();
|
|
221
|
+
console.log("Studio loaded", this);
|
|
222
|
+
clearInterval(i);
|
|
223
|
+
};
|
|
224
|
+
let i = setInterval(() => {
|
|
222
225
|
if (!window.WeaverseStudioBridge) {
|
|
223
226
|
let studioBridgeScript = document.createElement("script");
|
|
224
227
|
studioBridgeScript.src = `${this.appUrl}/assets/studio/studio-bridge.js?v=${version}`;
|
|
@@ -228,8 +231,8 @@ var Weaverse = class {
|
|
|
228
231
|
} else {
|
|
229
232
|
initStudio();
|
|
230
233
|
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
234
|
+
}, 2e3);
|
|
235
|
+
}
|
|
233
236
|
}
|
|
234
237
|
/**
|
|
235
238
|
* Register the custom React Component to Weaverse, store it into Weaverse.elementInstances
|
package/package.json
CHANGED