@weaverse/core 0.2.1 → 0.3.0

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/core.esm.js DELETED
@@ -1,340 +0,0 @@
1
- import fetch from 'isomorphic-unfetch';
2
- import { env } from 'process';
3
-
4
- var isReactNative = typeof navigator === 'object' && navigator.product === 'ReactNative';
5
- var isBrowser = typeof window !== 'undefined' && !isReactNative;
6
- var isIframe = isBrowser && window.top !== window.self;
7
-
8
- /**
9
- * When the editor is ready, we'll load this studio-bridge code.
10
- * This is for processing data between the editor and the workspace project.
11
- * It will not load in production mode or not running when the editor is not detected/ready.
12
- */
13
-
14
- var StudioBridge = /*#__PURE__*/function () {
15
- function StudioBridge(weaverse) {
16
- var _this = this;
17
-
18
- /**
19
- * handle the message event from editor(parent window)
20
- * the message type will start with "weavers.",
21
- * when an item got message to update, get the item instance and setData to it
22
- * @param event {MessageEvent}
23
- */
24
- this.handleMessageEvent = function (event) {
25
- var _event$data, _event$data$type;
26
-
27
- if ((_event$data = event.data) != null && (_event$data$type = _event$data.type) != null && _event$data$type.startsWith('weaverse.')) {
28
- var type = event.data.type;
29
-
30
- switch (type) {
31
- case 'weaverse.editor.ready':
32
- _this.weaverse.isEditor = true;
33
- break;
34
-
35
- case 'weaverse.editor.update':
36
- var payload = event.data.payload;
37
- var itemId = payload.itemId,
38
- background = payload.background;
39
-
40
- var instance = _this.weaverse.itemInstances.get(itemId);
41
-
42
- if (instance) {
43
- instance.setData({
44
- css: {
45
- background: background
46
- }
47
- });
48
- }
49
-
50
- }
51
- }
52
- };
53
-
54
- this.handleMouseDown = function (e) {
55
- console.log('handleMouseDown', e);
56
-
57
- _this.sendMessageToEditor('weaverse.editor.mouseDown', {});
58
- };
59
-
60
- this.weaverse = weaverse;
61
- this.handleProps = {
62
- onMouseDownCapture: this.handleMouseDown.bind(this)
63
- };
64
- }
65
- /**
66
- * subscribe to window message event from editor(parent window), and handle the message event
67
- */
68
-
69
-
70
- var _proto = StudioBridge.prototype;
71
-
72
- _proto.subscribeMessageEvent = function subscribeMessageEvent() {
73
- var _this2 = this;
74
-
75
- if (typeof this.currentFrameSubscription === 'function') {
76
- this.currentFrameSubscription();
77
- }
78
-
79
- isBrowser && window.addEventListener('message', this.handleMessageEvent);
80
-
81
- this.currentFrameSubscription = function () {
82
- isBrowser && window.removeEventListener('message', _this2.handleMessageEvent);
83
- };
84
-
85
- return this.currentFrameSubscription;
86
- };
87
-
88
- _proto.sendMessageToEditor = function sendMessageToEditor(type, payload) {
89
- isBrowser && window.parent.postMessage({
90
- type: type,
91
- payload: payload
92
- }, '*');
93
- };
94
-
95
- return StudioBridge;
96
- }();
97
-
98
- // TODO: Implement Weaverse SDK class
99
- // using stitches core only for framework-agnostic code
100
-
101
- var stitches = /*#__PURE__*/require('@stitches/core');
102
-
103
- var Weaverse = /*#__PURE__*/function () {
104
- /**
105
- * constructor
106
- * @param appUrl {string} Weaverse base URL that can provide by user/developer. for local development, use localhost:3000
107
- * @param projectKey {string} Weaverse project key to access project data via API
108
- * @param projectData {ProjectDataType} Weaverse project data, by default, user can provide project data via React Component.
109
- */
110
- function Weaverse(_temp) {
111
- var _ref = _temp === void 0 ? {} : _temp,
112
- appUrl = _ref.appUrl,
113
- projectKey = _ref.projectKey,
114
- projectData = _ref.projectData;
115
-
116
- /**
117
- * For storing, registering element React component from Weaverse or created by user/developer
118
- * @type {Map<string, React.Component>}
119
- */
120
- this.elementInstances = new Map();
121
- /**
122
- * list of element/items store to provide data, handle state update, state sharing, etc.
123
- * @type {Map<string, any>}
124
- */
125
-
126
- this.itemInstances = new Map();
127
- /**
128
- * Weaverse base URL that can provide by user/developer. for local development, use localhost:3000
129
- * @type {string}
130
- */
131
-
132
- this.appUrl = env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://weaverse.io';
133
- /**
134
- * Weaverse project key to access project data via API
135
- * @type {string}
136
- */
137
-
138
- this.projectKey = '';
139
- /**
140
- * Weaverse project data, by default, user can provide project data via React Component:
141
- * <WeaverseRoot defaultData={projectData} /> it will be used to server-side rendering
142
- */
143
-
144
- this.projectData = {
145
- items: []
146
- };
147
- /**
148
- * storing subscribe callback function for any component that want to listen to the change of WeaverseRoot
149
- * @type {Map<string, (data: any) => void>}
150
- */
151
-
152
- this.listeners = new Set();
153
- /**
154
- * check whether the sdk is inEditor or not
155
- * if isEditor is true, it means the sdk is inEditor mode, render the editor UI
156
- * else render the preview UI, plain HTML + CSS + React hydrate
157
- * @type {boolean}
158
- */
159
-
160
- this.isEditor = false;
161
- this.appUrl = appUrl || this.appUrl;
162
- this.projectKey = projectKey || this.projectKey;
163
- projectData && (this.projectData = projectData);
164
- this.init();
165
- }
166
- /**
167
- * register the custom React Component to Weaverse, store it into Weaverse.elementInstances
168
- * @param name {string} unique name of the custom React Component
169
- * @param element {React.Component} custom React Component
170
- */
171
-
172
-
173
- var _proto = Weaverse.prototype;
174
-
175
- _proto.registerElement = function registerElement(name, element) {
176
- this.elementInstances.set(name, element);
177
- };
178
-
179
- _proto.init = function init() {
180
- // init the stitches instance
181
- this.stitchesInstance = stitches.createStitches({
182
- prefix: 'weaverse',
183
- media: {
184
- bp1: '(min-width: 640px)',
185
- bp2: '(max-width: 768px)',
186
- bp3: '(min-width: 1024px)'
187
- }
188
- });
189
- };
190
-
191
- _proto.loadStudio = function loadStudio() {
192
- console.log('process.env.NODE_ENV', env.NODE_ENV); // only load studio bridge if it's in editor mode
193
-
194
- if (env.NODE_ENV !== 'production') {
195
- // TODO: separate studio bridge into a separate package
196
- // in development mode, we should use localhost:3000 as appUrl
197
- // this.appUrl = 'http://localhost:3000'
198
- // let StudioBridge = require('./studio-bridge')
199
- this.studioBridge = new StudioBridge(this);
200
- console.log('Weaverse: init studio bridge', this.studioBridge);
201
- this.studioBridge.subscribeMessageEvent();
202
- return true;
203
- }
204
-
205
- return false;
206
- };
207
-
208
- _proto.subscribe = function subscribe(fn) {
209
- this.listeners.add(fn);
210
- };
211
-
212
- _proto.unsubscribe = function unsubscribe(fn) {
213
- this.listeners["delete"](fn);
214
- };
215
-
216
- _proto.triggerUpdate = function triggerUpdate() {
217
- this.listeners.forEach(function (fn) {
218
- return fn();
219
- });
220
- this.triggerEditorUpdate();
221
- }
222
- /**
223
- * fetch data from Weaverse API (https://weaverse.io/api/v1/projects/:projectKey)
224
- */
225
- ;
226
-
227
- _proto.fetchProjectData = function fetchProjectData() {
228
- return fetch(this.appUrl + ("/api/public/" + this.projectKey)).then(function (r) {
229
- return r.json();
230
- })["catch"](console.error);
231
- }
232
- /**
233
- * fetch and update the project data, then trigger update to re-render the WeaverseRoot
234
- */
235
- ;
236
-
237
- _proto.updateProjectData = function updateProjectData() {
238
-
239
- console.log('this.projectData', this.projectData);
240
- this.initItemData();
241
- this.triggerUpdate();
242
- return;
243
- };
244
-
245
- _proto.triggerEditorUpdate = function triggerEditorUpdate(type) {
246
- if (type === void 0) {
247
- type = 'weaverse.workspace.init';
248
- }
249
-
250
- if (this.isEditor) {
251
- var _window$top;
252
-
253
- (_window$top = window.top) == null ? void 0 : _window$top.postMessage({
254
- type: type,
255
- payload: {
256
- projectKey: this.projectKey,
257
- projectData: this.projectData
258
- }
259
- }, '*');
260
- }
261
- };
262
-
263
- _proto.initItemData = function initItemData() {
264
- var _this2 = this;
265
-
266
- var data = this.projectData;
267
-
268
- if (data.items) {
269
- data.items.forEach(function (item) {
270
- var itemStore = _this2.itemInstances.get(item.id) || new WeaverseItemStore(item, _this2);
271
-
272
- _this2.itemInstances.set(item.id, itemStore);
273
- });
274
- }
275
- };
276
-
277
- return Weaverse;
278
- }();
279
- /**
280
- * WeaverseItemStore is a store for Weaverse item, it can be used to subscribe/update the item data
281
- * @param itemData {ProjectDataItemType} Weaverse item data
282
- * @param weaverse {Weaverse} Weaverse instance
283
- * Usage:
284
- * ```jsx
285
- * useEffect(() => {
286
- * let handleUpdate = (update: any) => {
287
- * setData({...update})
288
- * }
289
- * itemInstance.subscribe(handleUpdate)
290
- * return () => {
291
- * itemInstance.unsubscribe(handleUpdate)
292
- * }
293
- * }, [])
294
- * ```
295
- */
296
-
297
- var WeaverseItemStore = function WeaverseItemStore(itemData, weaverse) {
298
- var _this3 = this;
299
-
300
- if (itemData === void 0) {
301
- itemData = {};
302
- }
303
-
304
- this.data = {};
305
- this.listeners = new Set();
306
- this.ref = {
307
- current: null
308
- };
309
-
310
- this.setData = function (data) {
311
- _this3.data = Object.assign(_this3.data, data);
312
-
313
- _this3.triggerUpdate();
314
- };
315
-
316
- this.subscribe = function (fn) {
317
- _this3.listeners.add(fn);
318
- };
319
-
320
- this.unsubscribe = function (fn) {
321
- _this3.listeners["delete"](fn);
322
- };
323
-
324
- this.triggerUpdate = function () {
325
- _this3.listeners.forEach(function (fn) {
326
- return fn(_this3.data);
327
- });
328
- };
329
-
330
- this.data = itemData;
331
- var _itemData = itemData,
332
- type = _itemData.type;
333
-
334
- if (type) {
335
- this.Component = weaverse.elementInstances.get(type);
336
- }
337
- };
338
-
339
- export { Weaverse, WeaverseItemStore, isBrowser, isIframe, isReactNative };
340
- //# sourceMappingURL=core.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.esm.js","sources":["../src/utils/index.ts","../src/studio-bridge.ts","../src/core.ts"],"sourcesContent":["export const isReactNative = typeof navigator === 'object' && navigator.product === 'ReactNative'\nexport const isBrowser = typeof window !== 'undefined' && !isReactNative\nexport const isIframe = isBrowser && window.top !== window.self","import {isBrowser} from './utils'\nimport type {Weaverse} from '.'\n\n/**\n * When the editor is ready, we'll load this studio-bridge code.\n * This is for processing data between the editor and the workspace project.\n * It will not load in production mode or not running when the editor is not detected/ready.\n */\n\nexport class StudioBridge {\n weaverse: Weaverse\n\n /**\n * instance for subscribing to window message, save it to currentFrameSubscription then can remove it when unmount\n */\n currentFrameSubscription: any\n handleProps: any\n constructor(weaverse: Weaverse) {\n this.weaverse = weaverse\n this.handleProps = {\n onMouseDownCapture: this.handleMouseDown.bind(this)\n }\n }\n\n /**\n * subscribe to window message event from editor(parent window), and handle the message event\n */\n subscribeMessageEvent() {\n if (typeof this.currentFrameSubscription === 'function') {\n this.currentFrameSubscription()\n }\n isBrowser && window.addEventListener('message', this.handleMessageEvent)\n this.currentFrameSubscription = () => {\n isBrowser && window.removeEventListener('message', this.handleMessageEvent)\n }\n return this.currentFrameSubscription\n }\n\n /**\n * handle the message event from editor(parent window)\n * the message type will start with \"weavers.\",\n * when an item got message to update, get the item instance and setData to it\n * @param event {MessageEvent}\n */\n handleMessageEvent = (event: MessageEvent) => {\n if (event.data?.type?.startsWith('weaverse.')) {\n let type = event.data.type\n switch (type) {\n case 'weaverse.editor.ready':\n this.weaverse.isEditor = true\n break\n case 'weaverse.editor.update':\n let {payload} = event.data\n let {itemId, background} = payload\n let instance = this.weaverse.itemInstances.get(itemId)\n if (instance) {\n instance.setData({\n css: {\n background\n }\n })\n }\n }\n }\n }\n\n sendMessageToEditor(type: string, payload: any) {\n isBrowser && window.parent.postMessage({type, payload}, '*')\n }\n\n handleMouseDown = (e: MouseEvent) => {\n console.log('handleMouseDown', e)\n this.sendMessageToEditor('weaverse.editor.mouseDown', {})\n }\n}\n\n\nexport default StudioBridge","// TODO: Implement Weaverse SDK class\n// Only core code is implemented here, avoid importing other packages,\n// the core code should be framework agnostic, no react, vue, angular, etc.\nimport fetch from 'isomorphic-unfetch'\nimport * as process from 'process'\nimport StudioBridge from './studio-bridge'\nimport Stitches from '@stitches/core/types/stitches'\n// stitches problem, we should use require instead of import\n// using stitches core only for framework-agnostic code\nlet stitches = require('@stitches/core')\n\n\nexport interface ProjectDataItemType {\n type: string\n name?: string\n id: string | number\n description?: string\n childIds?: Array<string | number>\n css?: {\n [key: string]: string\n }\n}\n\nexport interface ProjectDataType {\n items: ProjectDataItemType[]\n}\n\n\nexport type WeaverseType = {\n [key: string]: any\n appUrl?: string,\n projectKey?: string,\n projectData?: ProjectDataType\n}\n\n\nexport class Weaverse {\n /**\n * For storing, registering element React component from Weaverse or created by user/developer\n * @type {Map<string, React.Component>}\n */\n elementInstances = new Map<string, any>()\n /**\n * list of element/items store to provide data, handle state update, state sharing, etc.\n * @type {Map<string, any>}\n */\n itemInstances = new Map<string | number, WeaverseItemStore>()\n /**\n * Weaverse base URL that can provide by user/developer. for local development, use localhost:3000\n * @type {string}\n */\n appUrl: string = process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : 'https://weaverse.io'\n /**\n * Weaverse project key to access project data via API\n * @type {string}\n */\n projectKey: string = ''\n /**\n * Weaverse project data, by default, user can provide project data via React Component:\n * <WeaverseRoot defaultData={projectData} /> it will be used to server-side rendering\n */\n projectData: ProjectDataType = {\n items: []\n }\n /**\n * storing subscribe callback function for any component that want to listen to the change of WeaverseRoot\n * @type {Map<string, (data: any) => void>}\n */\n listeners: Set<any> = new Set()\n /**\n * check whether the sdk is inEditor or not\n * if isEditor is true, it means the sdk is inEditor mode, render the editor UI\n * else render the preview UI, plain HTML + CSS + React hydrate\n * @type {boolean}\n */\n isEditor = false\n /**\n * stitches instance for handling CSS stylesheet, media, theme for Weaverse project\n */\n stitchesInstance: Stitches | any\n\n studioBridge?: StudioBridge\n\n /**\n * constructor\n * @param appUrl {string} Weaverse base URL that can provide by user/developer. for local development, use localhost:3000\n * @param projectKey {string} Weaverse project key to access project data via API\n * @param projectData {ProjectDataType} Weaverse project data, by default, user can provide project data via React Component.\n */\n constructor({appUrl, projectKey, projectData}: WeaverseType = {}) {\n this.appUrl = appUrl || this.appUrl\n this.projectKey = projectKey || this.projectKey\n projectData && (this.projectData = projectData)\n this.init()\n }\n\n /**\n * register the custom React Component to Weaverse, store it into Weaverse.elementInstances\n * @param name {string} unique name of the custom React Component\n * @param element {React.Component} custom React Component\n */\n registerElement(name: string, element: any) {\n this.elementInstances.set(name, element)\n }\n\n init() {\n // init the stitches instance\n this.stitchesInstance = stitches.createStitches(\n {\n prefix: 'weaverse',\n media: {\n bp1: '(min-width: 640px)',\n bp2: '(max-width: 768px)',\n bp3: '(min-width: 1024px)'\n }\n }\n )\n }\n\n loadStudio() {\n console.log('process.env.NODE_ENV', process.env.NODE_ENV)\n // only load studio bridge if it's in editor mode\n if (process.env.NODE_ENV !== 'production') {\n // TODO: separate studio bridge into a separate package\n // in development mode, we should use localhost:3000 as appUrl\n // this.appUrl = 'http://localhost:3000'\n // let StudioBridge = require('./studio-bridge')\n this.studioBridge = new StudioBridge(this)\n console.log('Weaverse: init studio bridge', this.studioBridge)\n\n this.studioBridge.subscribeMessageEvent()\n return true\n }\n return false\n }\n\n subscribe(fn: any) {\n this.listeners.add(fn)\n }\n\n unsubscribe(fn: any) {\n this.listeners.delete(fn)\n }\n\n triggerUpdate() {\n this.listeners.forEach(fn => fn())\n this.triggerEditorUpdate()\n }\n\n /**\n * fetch data from Weaverse API (https://weaverse.io/api/v1/projects/:projectKey)\n */\n fetchProjectData() {\n return fetch(this.appUrl + `/api/public/${this.projectKey}`).then(r => r.json()).catch(console.error)\n }\n\n /**\n * fetch and update the project data, then trigger update to re-render the WeaverseRoot\n */\n updateProjectData() {\n console.log('this.projectData', this.projectData)\n this.initItemData()\n this.triggerUpdate()\n return\n if (this.projectKey) {\n this.fetchProjectData().then(data => {\n if (data) {\n this.projectData = data\n this.initItemData()\n this.triggerUpdate()\n }\n }).catch(err => {\n console.error(err)\n })\n }\n }\n\n\n triggerEditorUpdate(type = 'weaverse.workspace.init') {\n if (this.isEditor) {\n window.top?.postMessage({\n type, payload: {\n projectKey: this.projectKey,\n projectData: this.projectData\n }\n }, '*')\n }\n }\n\n initItemData() {\n let data = this.projectData\n if (data.items) {\n data.items.forEach(item => {\n let itemStore = this.itemInstances.get(item.id) || new WeaverseItemStore(item, this)\n this.itemInstances.set(item.id, itemStore)\n })\n }\n }\n}\n\n/**\n * WeaverseItemStore is a store for Weaverse item, it can be used to subscribe/update the item data\n * @param itemData {ProjectDataItemType} Weaverse item data\n * @param weaverse {Weaverse} Weaverse instance\n * Usage:\n * ```jsx\n * useEffect(() => {\n * let handleUpdate = (update: any) => {\n * setData({...update})\n * }\n * itemInstance.subscribe(handleUpdate)\n * return () => {\n * itemInstance.unsubscribe(handleUpdate)\n * }\n * }, [])\n * ```\n */\nexport class WeaverseItemStore {\n data: any = {}\n listeners: Set<any> = new Set()\n Component: any\n ref: any = {\n current: null\n }\n\n constructor(itemData: any = {}, weaverse: Weaverse) {\n this.data = itemData\n let {type} = itemData\n if (type) {\n this.Component = weaverse.elementInstances.get(type)\n }\n }\n\n setData = (data: any) => {\n this.data = Object.assign(this.data, data)\n this.triggerUpdate()\n }\n\n subscribe = (fn: any) => {\n this.listeners.add(fn)\n }\n\n unsubscribe = (fn: any) => {\n this.listeners.delete(fn)\n }\n\n triggerUpdate = () => {\n this.listeners.forEach(fn => {\n return fn(this.data)\n })\n }\n}"],"names":["isReactNative","navigator","product","isBrowser","window","isIframe","top","self","StudioBridge","weaverse","event","data","type","startsWith","isEditor","payload","itemId","background","instance","itemInstances","get","setData","css","e","console","log","sendMessageToEditor","handleProps","onMouseDownCapture","handleMouseDown","bind","subscribeMessageEvent","currentFrameSubscription","addEventListener","handleMessageEvent","removeEventListener","parent","postMessage","stitches","require","Weaverse","appUrl","projectKey","projectData","Map","process","NODE_ENV","items","Set","init","registerElement","name","element","elementInstances","set","stitchesInstance","createStitches","prefix","media","bp1","bp2","bp3","loadStudio","studioBridge","subscribe","fn","listeners","add","unsubscribe","triggerUpdate","forEach","triggerEditorUpdate","fetchProjectData","fetch","then","r","json","error","updateProjectData","initItemData","item","itemStore","id","WeaverseItemStore","itemData","current","Object","assign","Component"],"mappings":";;;IAAaA,aAAa,GAAG,OAAOC,SAAP,KAAqB,QAArB,IAAiCA,SAAS,CAACC,OAAV,KAAsB;IACvEC,SAAS,GAAG,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAACJ;IAC9CK,QAAQ,GAAGF,SAAS,IAAIC,MAAM,CAACE,GAAP,KAAeF,MAAM,CAACG;;ACC3D;;;;;;AAMA,IAAaC,YAAb;AAQE,wBAAYC,QAAZ;;;AAqBA;;;;;;A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BA,IAAaE,iBAAb,GAQE,2BAAYC,QAAZ,EAAgC3E,QAAhC;;;MAAY2E;AAAAA,IAAAA,WAAgB;;;AAP5B,WAAA,GAAY,EAAZ;AACA,gBAAA,GAAsB,IAAIpC,GAAJ,EAAtB;AAEA,UAAA,GAAW;AACTqC,IAAAA,OAAO,EAAE;AADA,GAAX;;AAYA,cAAA,GAAU,UAAC1E,IAAD;AACR,IAAA,MAAI,CAACA,IAAL,GAAY2E,MAAM,CAACC,MAAP,CAAc,MAAI,CAAC5E,IAAnB,EAAyBA,IAAzB,CAAZ;;AACA,IAAA,MAAI,CAAC0D,aAAL;AACD,GAHD;;AAKA,gBAAA,GAAY,UAACJ,EAAD;AACV,IAAA,MAAI,CAACC,SAAL,CAAeC,GAAf,CAAmBF,EAAnB;AACD,GAFD;;AAIA,kBAAA,GAAc,UAACA,EAAD;AACZ,IAAA,MAAI,CAACC,SAAL,WAAsBD,EAAtB;AACD,GAFD;;AAIA,oBAAA,GAAgB;AACd,IAAA,MAAI,CAACC,SAAL,CAAeI,OAAf,CAAuB,UAAAL,EAAE;AACvB,aAAOA,EAAE,CAAC,MAAI,CAACtD,IAAN,CAAT;AACD,KAFD;AAGD,GAJD;;AApBE,OAAKA,IAAL,GAAYyE,QAAZ;AACA,kBAAaA,QAAb;AAAA,MAAKxE,IAAL,aAAKA,IAAL;;AACA,MAAIA,IAAJ,EAAU;AACR,SAAK4E,SAAL,GAAiB/E,QAAQ,CAAC4C,gBAAT,CAA0BjC,GAA1B,CAA8BR,IAA9B,CAAjB;AACD;AACF,CAdH;;;;"}
@@ -1,29 +0,0 @@
1
- import type { Weaverse } from '.';
2
- /**
3
- * When the editor is ready, we'll load this studio-bridge code.
4
- * This is for processing data between the editor and the workspace project.
5
- * It will not load in production mode or not running when the editor is not detected/ready.
6
- */
7
- export declare class StudioBridge {
8
- weaverse: Weaverse;
9
- /**
10
- * instance for subscribing to window message, save it to currentFrameSubscription then can remove it when unmount
11
- */
12
- currentFrameSubscription: any;
13
- handleProps: any;
14
- constructor(weaverse: Weaverse);
15
- /**
16
- * subscribe to window message event from editor(parent window), and handle the message event
17
- */
18
- subscribeMessageEvent(): any;
19
- /**
20
- * handle the message event from editor(parent window)
21
- * the message type will start with "weavers.",
22
- * when an item got message to update, get the item instance and setData to it
23
- * @param event {MessageEvent}
24
- */
25
- handleMessageEvent: (event: MessageEvent) => void;
26
- sendMessageToEditor(type: string, payload: any): void;
27
- handleMouseDown: (e: MouseEvent) => void;
28
- }
29
- export default StudioBridge;
@@ -1,3 +0,0 @@
1
- export declare const isReactNative: boolean;
2
- export declare const isBrowser: boolean;
3
- export declare const isIframe: boolean;