@weaverse/core 0.6.21 → 0.6.24
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 +111 -64
- package/dist/index.js +25 -25
- package/dist/index.mjs +25 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,98 +1,153 @@
|
|
|
1
|
-
import { CSSProperties } from '@stitches/core';
|
|
2
1
|
import { ForwardRefExoticComponent, RefObject } from 'react';
|
|
3
|
-
import Stitches from '@stitches/core
|
|
2
|
+
import * as Stitches from '@stitches/core';
|
|
3
|
+
import Stitches$1 from '@stitches/core/types/stitches';
|
|
4
4
|
|
|
5
|
+
declare const stichesUtils: {
|
|
6
|
+
m: (value: string) => {
|
|
7
|
+
margin: string;
|
|
8
|
+
};
|
|
9
|
+
mt: (value: string) => {
|
|
10
|
+
marginTop: string;
|
|
11
|
+
};
|
|
12
|
+
mr: (value: string) => {
|
|
13
|
+
marginRight: string;
|
|
14
|
+
};
|
|
15
|
+
mb: (value: string) => {
|
|
16
|
+
marginBottom: string;
|
|
17
|
+
};
|
|
18
|
+
ml: (value: string) => {
|
|
19
|
+
marginLeft: string;
|
|
20
|
+
};
|
|
21
|
+
mx: (value: string) => {
|
|
22
|
+
marginLeft: string;
|
|
23
|
+
marginRight: string;
|
|
24
|
+
};
|
|
25
|
+
my: (value: string) => {
|
|
26
|
+
marginTop: string;
|
|
27
|
+
marginBottom: string;
|
|
28
|
+
};
|
|
29
|
+
size: (value: string) => {
|
|
30
|
+
width: string;
|
|
31
|
+
height: string;
|
|
32
|
+
};
|
|
33
|
+
px: (value: string) => {
|
|
34
|
+
paddingLeft: string;
|
|
35
|
+
paddingRight: string;
|
|
36
|
+
};
|
|
37
|
+
py: (value: string) => {
|
|
38
|
+
paddingTop: string;
|
|
39
|
+
paddingBottom: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
declare type TODO = any;
|
|
5
44
|
interface ProjectDataType {
|
|
6
|
-
items:
|
|
45
|
+
items: ElementData[];
|
|
7
46
|
rootId: string;
|
|
8
47
|
script: {
|
|
9
48
|
css: string;
|
|
10
49
|
js: string;
|
|
11
50
|
};
|
|
12
51
|
}
|
|
13
|
-
|
|
52
|
+
interface WeaverseType {
|
|
14
53
|
mediaBreakPoints?: any;
|
|
15
54
|
appUrl?: string;
|
|
16
55
|
projectKey?: string;
|
|
17
56
|
projectData?: ProjectDataType;
|
|
18
57
|
isDesignMode?: boolean;
|
|
19
58
|
ssrMode?: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare type TODO = any;
|
|
22
|
-
declare type WeaverseElementMap = {
|
|
23
|
-
[key: string]: WeaverseElement;
|
|
24
|
-
};
|
|
59
|
+
}
|
|
25
60
|
declare type WeaverseElement = {
|
|
26
61
|
Component: ForwardRefExoticComponent<any>;
|
|
27
62
|
type: string;
|
|
28
|
-
schema?:
|
|
63
|
+
schema?: ElementSchema;
|
|
29
64
|
};
|
|
65
|
+
interface ElementsMap {
|
|
66
|
+
[key: string]: WeaverseElement;
|
|
67
|
+
}
|
|
30
68
|
declare type CatalogGroup = "essential" | "composition" | "other";
|
|
31
|
-
|
|
69
|
+
interface ElementCatalog {
|
|
32
70
|
name: string;
|
|
33
71
|
icon?: string;
|
|
34
72
|
group?: CatalogGroup;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
declare type
|
|
38
|
-
|
|
39
|
-
};
|
|
73
|
+
data?: ElementData[];
|
|
74
|
+
}
|
|
75
|
+
declare type FlagType = "draggable" | "resizable" | "sortable" | "droppable";
|
|
76
|
+
declare type ElementFlags = Partial<Record<FlagType, boolean>>;
|
|
40
77
|
declare type ToolbarAction = "duplicate" | "delete" | "edit-button" | "insert-link" | "select-template" | "copy-styles" | "paste-styles";
|
|
41
|
-
|
|
78
|
+
interface ChildElement {
|
|
42
79
|
label: string;
|
|
43
80
|
selector: string;
|
|
81
|
+
}
|
|
82
|
+
declare type ParentType = "container" | "layout" | "root";
|
|
83
|
+
declare type GridSize = {
|
|
84
|
+
rowSpan: number;
|
|
85
|
+
colSpan: number;
|
|
44
86
|
};
|
|
45
|
-
|
|
46
|
-
declare type WeaverseElementSchema = {
|
|
47
|
-
type: string;
|
|
48
|
-
parentType: ElementParentType;
|
|
87
|
+
interface ElementSchema {
|
|
49
88
|
title: string;
|
|
89
|
+
type: string;
|
|
90
|
+
parentType: ParentType;
|
|
91
|
+
gridSize?: GridSize;
|
|
50
92
|
inspector?: ElementInspector;
|
|
51
93
|
toolbar?: (ToolbarAction | ToolbarAction[])[];
|
|
52
|
-
|
|
53
|
-
catalog?:
|
|
54
|
-
flags?:
|
|
55
|
-
}
|
|
56
|
-
|
|
94
|
+
childElements?: ChildElement[];
|
|
95
|
+
catalog?: ElementCatalog;
|
|
96
|
+
flags?: ElementFlags;
|
|
97
|
+
}
|
|
98
|
+
interface ElementData {
|
|
57
99
|
id: string;
|
|
58
100
|
type: string;
|
|
59
|
-
childIds?: (string | number)[]
|
|
60
|
-
css?:
|
|
101
|
+
childIds?: (string | number)[];
|
|
102
|
+
css?: ElementCSS;
|
|
61
103
|
[key: string]: any;
|
|
104
|
+
}
|
|
105
|
+
declare type WeaverseCSSProperties = Stitches.CSS & Partial<Record<keyof typeof stichesUtils, string | number>>;
|
|
106
|
+
declare type ChildElementCSS = Partial<{
|
|
107
|
+
[selector: string]: WeaverseCSSProperties & ChildElementCSS;
|
|
108
|
+
}>;
|
|
109
|
+
interface ElementCSS {
|
|
110
|
+
"@desktop"?: WeaverseCSSProperties | ChildElementCSS;
|
|
111
|
+
"@mobile"?: WeaverseCSSProperties | ChildElementCSS;
|
|
112
|
+
}
|
|
113
|
+
interface ElementInspector {
|
|
114
|
+
settings?: (AdvancedGroup | BasicGroup)[];
|
|
115
|
+
styles?: (AdvancedGroup | BasicGroup)[];
|
|
116
|
+
}
|
|
117
|
+
declare type AdvancedGroup = {
|
|
118
|
+
type: AdvancedInput;
|
|
62
119
|
};
|
|
63
|
-
declare type
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"@mobile"?: CSSProperties | {
|
|
68
|
-
[key: string]: CSSProperties;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
declare type ElementInspector = {
|
|
72
|
-
settings?: InspectorInput[];
|
|
73
|
-
styles?: InspectorInput[];
|
|
120
|
+
declare type BasicGroup = {
|
|
121
|
+
type: "basic";
|
|
122
|
+
label: string;
|
|
123
|
+
inputs: BasicInput[];
|
|
74
124
|
};
|
|
75
|
-
declare type
|
|
125
|
+
declare type AdvancedInput = "alignment" | "background" | "border" | "countdown" | "dimensions" | "form" | "instagram" | "product" | "spacing" | "visibility";
|
|
126
|
+
interface BasicInput {
|
|
76
127
|
type: InputType;
|
|
77
|
-
label
|
|
78
|
-
name
|
|
128
|
+
label: string;
|
|
129
|
+
name: string;
|
|
79
130
|
defaultValue?: string;
|
|
131
|
+
placeholder?: string;
|
|
80
132
|
helpText?: string;
|
|
81
|
-
options?:
|
|
133
|
+
options?: {
|
|
134
|
+
value: string;
|
|
135
|
+
label: string;
|
|
136
|
+
}[];
|
|
82
137
|
conditions?: TODO[];
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
declare type InputType = "select" | "checkbox" | "radio" | "range" | "button" | "image" | "file" | "hidden" | "alignment" | "color" | "dimensions" | "flex" | "grid" | "input" | "switch" | "spacing" | "textarea" | "visibility" | "border" | "background" | "typography" | "shadow" | "position" | "overflow" | "display" | "other";
|
|
138
|
+
}
|
|
139
|
+
declare type InputType = "select" | "radio" | "range" | "button" | "image" | "color" | "text" | "switch" | "textarea";
|
|
86
140
|
declare global {
|
|
87
141
|
interface Window {
|
|
88
142
|
WeaverseStudioBridge: TODO;
|
|
89
143
|
weaverseShopifyProducts: TODO;
|
|
144
|
+
weaverseGlobalSettings: TODO;
|
|
90
145
|
}
|
|
91
146
|
}
|
|
92
147
|
|
|
93
148
|
/**
|
|
94
149
|
* WeaverseItemStore is a store for Weaverse item, it can be used to subscribe/update the item data
|
|
95
|
-
* @param itemData {
|
|
150
|
+
* @param itemData {ElementData} Weaverse item data
|
|
96
151
|
* @param weaverse {Weaverse} Weaverse instance
|
|
97
152
|
* @example
|
|
98
153
|
* useEffect(() => {
|
|
@@ -110,15 +165,15 @@ declare class WeaverseItemStore {
|
|
|
110
165
|
ref: RefObject<HTMLElement>;
|
|
111
166
|
weaverse: Weaverse;
|
|
112
167
|
stitchesClass: string;
|
|
113
|
-
_data:
|
|
114
|
-
_flags:
|
|
115
|
-
constructor(itemData:
|
|
168
|
+
_data: ElementData;
|
|
169
|
+
_flags: ElementFlags;
|
|
170
|
+
constructor(itemData: ElementData, weaverse: Weaverse);
|
|
116
171
|
get _id(): string;
|
|
117
172
|
get _element(): HTMLElement | null;
|
|
118
173
|
get Element(): WeaverseElement | undefined;
|
|
119
|
-
set data(data: Omit<
|
|
120
|
-
get data():
|
|
121
|
-
setData: (data: Omit<
|
|
174
|
+
set data(data: Omit<ElementData, "id" | "type">);
|
|
175
|
+
get data(): ElementData;
|
|
176
|
+
setData: (data: Omit<ElementData, "id" | "type">) => ElementData;
|
|
122
177
|
subscribe: (fn: any) => void;
|
|
123
178
|
unsubscribe: (fn: any) => void;
|
|
124
179
|
triggerUpdate: () => void;
|
|
@@ -156,13 +211,6 @@ declare class Weaverse {
|
|
|
156
211
|
* @type {Map<string, (data: any) => void>}
|
|
157
212
|
*/
|
|
158
213
|
listeners: Set<any>;
|
|
159
|
-
/**
|
|
160
|
-
* check whether the sdk is isDesignMode or not
|
|
161
|
-
* if isDesignMode is true, it means the sdk is isDesignMode mode, render the editor UI
|
|
162
|
-
* else render the preview UI, plain HTML + CSS + React hydrate
|
|
163
|
-
* @type {boolean}
|
|
164
|
-
*/
|
|
165
|
-
isDesignMode: boolean;
|
|
166
214
|
/**
|
|
167
215
|
* Use in element to optionally render special HTML for hydration
|
|
168
216
|
* @type {boolean}
|
|
@@ -171,7 +219,7 @@ declare class Weaverse {
|
|
|
171
219
|
/**
|
|
172
220
|
* stitches instance for handling CSS stylesheet, media, theme for Weaverse project
|
|
173
221
|
*/
|
|
174
|
-
stitchesInstance: Stitches | any;
|
|
222
|
+
stitchesInstance: Stitches$1 | any;
|
|
175
223
|
studioBridge?: any;
|
|
176
224
|
static WeaverseItemStore: typeof WeaverseItemStore;
|
|
177
225
|
mediaBreakPoints: {
|
|
@@ -184,10 +232,9 @@ declare class Weaverse {
|
|
|
184
232
|
* @param projectKey {string} Weaverse project key to access project data via API
|
|
185
233
|
* @param projectData {ProjectDataType} Weaverse project data, by default, user can provide project data via React Component.
|
|
186
234
|
* @param mediaBreakPoints {object} Pass down custom media query breakpoints or just use the default.
|
|
187
|
-
* @param isDesignMode {boolean} check whether the sdk is isDesignMode or not
|
|
188
235
|
* @param ssrMode {boolean} Use in element to optionally render special HTML for hydration
|
|
189
236
|
*/
|
|
190
|
-
constructor({ appUrl, projectKey, projectData, mediaBreakPoints,
|
|
237
|
+
constructor({ appUrl, projectKey, projectData, mediaBreakPoints, ssrMode }?: WeaverseType);
|
|
191
238
|
loadStudio(): void;
|
|
192
239
|
/**
|
|
193
240
|
* register the custom React Component to Weaverse, store it into Weaverse.elementInstances
|
|
@@ -222,4 +269,4 @@ declare const isReactNative: boolean;
|
|
|
222
269
|
declare const isBrowser: boolean;
|
|
223
270
|
declare const isIframe: boolean;
|
|
224
271
|
|
|
225
|
-
export { CatalogGroup,
|
|
272
|
+
export { AdvancedGroup, AdvancedInput, BasicGroup, BasicInput, CatalogGroup, ChildElement, ChildElementCSS, ElementCSS, ElementCatalog, ElementData, ElementFlags, ElementInspector, ElementSchema, ElementsMap, FlagType, GridSize, InputType, ParentType, ProjectDataType, TODO, ToolbarAction, Weaverse, WeaverseCSSProperties, WeaverseElement, WeaverseItemStore, WeaverseType, isBrowser, isIframe, isReactNative };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
47
47
|
// src/core.ts
|
|
48
48
|
var stitches = __toESM(require("@stitches/core"));
|
|
49
49
|
|
|
50
|
+
// src/utils/index.ts
|
|
51
|
+
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
52
|
+
var isBrowser = typeof window !== "undefined" && !isReactNative;
|
|
53
|
+
var isIframe = isBrowser && window.top !== window.self;
|
|
54
|
+
|
|
50
55
|
// src/utils/styles.ts
|
|
51
56
|
var stichesUtils = {
|
|
52
57
|
m: (value) => ({
|
|
@@ -86,11 +91,6 @@ var stichesUtils = {
|
|
|
86
91
|
})
|
|
87
92
|
};
|
|
88
93
|
|
|
89
|
-
// src/utils/index.ts
|
|
90
|
-
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
91
|
-
var isBrowser = typeof window !== "undefined" && !isReactNative;
|
|
92
|
-
var isIframe = isBrowser && window.top !== window.self;
|
|
93
|
-
|
|
94
94
|
// src/core.ts
|
|
95
95
|
var WeaverseItemStore = class {
|
|
96
96
|
constructor(itemData, weaverse) {
|
|
@@ -142,7 +142,7 @@ var WeaverseItemStore = class {
|
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
var _Weaverse = class {
|
|
145
|
-
constructor({ appUrl, projectKey, projectData, mediaBreakPoints,
|
|
145
|
+
constructor({ appUrl, projectKey, projectData, mediaBreakPoints, ssrMode } = {}) {
|
|
146
146
|
this.elementInstances = /* @__PURE__ */ new Map();
|
|
147
147
|
this.itemInstances = /* @__PURE__ */ new Map();
|
|
148
148
|
this.appUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://weaverse.io";
|
|
@@ -153,7 +153,6 @@ var _Weaverse = class {
|
|
|
153
153
|
script: { css: "", js: "" }
|
|
154
154
|
};
|
|
155
155
|
this.listeners = /* @__PURE__ */ new Set();
|
|
156
|
-
this.isDesignMode = false;
|
|
157
156
|
this.ssrMode = false;
|
|
158
157
|
this.mediaBreakPoints = {
|
|
159
158
|
desktop: "all",
|
|
@@ -169,30 +168,34 @@ var _Weaverse = class {
|
|
|
169
168
|
this.appUrl = appUrl || this.appUrl;
|
|
170
169
|
this.projectKey = projectKey || this.projectKey;
|
|
171
170
|
this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
|
|
172
|
-
this.isDesignMode = isDesignMode || this.isDesignMode;
|
|
173
171
|
this.ssrMode = ssrMode || this.ssrMode;
|
|
174
172
|
projectData && (this.projectData = projectData);
|
|
175
173
|
this.init();
|
|
176
174
|
}
|
|
177
175
|
loadStudio() {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
176
|
+
setTimeout(() => {
|
|
177
|
+
if (isIframe) {
|
|
178
|
+
const initStudio = () => {
|
|
179
|
+
this.studioBridge = new window.WeaverseStudioBridge(this);
|
|
180
|
+
this.triggerUpdate();
|
|
181
|
+
};
|
|
182
|
+
if (!window.WeaverseStudioBridge) {
|
|
183
|
+
const studioBridgeScript = document.createElement("script");
|
|
184
|
+
studioBridgeScript.src = `${this.appUrl}/assets/studio/studio-bridge.js`;
|
|
185
|
+
studioBridgeScript.type = "module";
|
|
186
|
+
studioBridgeScript.onload = initStudio;
|
|
187
|
+
document.body.appendChild(studioBridgeScript);
|
|
188
|
+
} else {
|
|
189
|
+
initStudio();
|
|
190
|
+
}
|
|
191
191
|
}
|
|
192
|
-
}
|
|
192
|
+
}, 2e3);
|
|
193
193
|
}
|
|
194
194
|
registerElement(element) {
|
|
195
195
|
if (element == null ? void 0 : element.type) {
|
|
196
|
+
if (this.elementInstances.has(element.type)) {
|
|
197
|
+
throw new Error(`Weaverse: Element '${element.type}' already registered`);
|
|
198
|
+
}
|
|
196
199
|
this.elementInstances.set(element == null ? void 0 : element.type, element);
|
|
197
200
|
} else {
|
|
198
201
|
throw new Error("Weaverse: registerElement: `type` is required");
|
|
@@ -201,9 +204,6 @@ var _Weaverse = class {
|
|
|
201
204
|
init() {
|
|
202
205
|
this.initStitches();
|
|
203
206
|
this.initProjectItemData();
|
|
204
|
-
setTimeout(() => {
|
|
205
|
-
this.loadStudio();
|
|
206
|
-
}, 1e3);
|
|
207
207
|
}
|
|
208
208
|
subscribe(fn) {
|
|
209
209
|
this.listeners.add(fn);
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,11 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
// src/core.ts
|
|
19
19
|
import * as stitches from "@stitches/core";
|
|
20
20
|
|
|
21
|
+
// src/utils/index.ts
|
|
22
|
+
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
23
|
+
var isBrowser = typeof window !== "undefined" && !isReactNative;
|
|
24
|
+
var isIframe = isBrowser && window.top !== window.self;
|
|
25
|
+
|
|
21
26
|
// src/utils/styles.ts
|
|
22
27
|
var stichesUtils = {
|
|
23
28
|
m: (value) => ({
|
|
@@ -57,11 +62,6 @@ var stichesUtils = {
|
|
|
57
62
|
})
|
|
58
63
|
};
|
|
59
64
|
|
|
60
|
-
// src/utils/index.ts
|
|
61
|
-
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
62
|
-
var isBrowser = typeof window !== "undefined" && !isReactNative;
|
|
63
|
-
var isIframe = isBrowser && window.top !== window.self;
|
|
64
|
-
|
|
65
65
|
// src/core.ts
|
|
66
66
|
var WeaverseItemStore = class {
|
|
67
67
|
constructor(itemData, weaverse) {
|
|
@@ -113,7 +113,7 @@ var WeaverseItemStore = class {
|
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
var _Weaverse = class {
|
|
116
|
-
constructor({ appUrl, projectKey, projectData, mediaBreakPoints,
|
|
116
|
+
constructor({ appUrl, projectKey, projectData, mediaBreakPoints, ssrMode } = {}) {
|
|
117
117
|
this.elementInstances = /* @__PURE__ */ new Map();
|
|
118
118
|
this.itemInstances = /* @__PURE__ */ new Map();
|
|
119
119
|
this.appUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://weaverse.io";
|
|
@@ -124,7 +124,6 @@ var _Weaverse = class {
|
|
|
124
124
|
script: { css: "", js: "" }
|
|
125
125
|
};
|
|
126
126
|
this.listeners = /* @__PURE__ */ new Set();
|
|
127
|
-
this.isDesignMode = false;
|
|
128
127
|
this.ssrMode = false;
|
|
129
128
|
this.mediaBreakPoints = {
|
|
130
129
|
desktop: "all",
|
|
@@ -140,30 +139,34 @@ var _Weaverse = class {
|
|
|
140
139
|
this.appUrl = appUrl || this.appUrl;
|
|
141
140
|
this.projectKey = projectKey || this.projectKey;
|
|
142
141
|
this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
|
|
143
|
-
this.isDesignMode = isDesignMode || this.isDesignMode;
|
|
144
142
|
this.ssrMode = ssrMode || this.ssrMode;
|
|
145
143
|
projectData && (this.projectData = projectData);
|
|
146
144
|
this.init();
|
|
147
145
|
}
|
|
148
146
|
loadStudio() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
147
|
+
setTimeout(() => {
|
|
148
|
+
if (isIframe) {
|
|
149
|
+
const initStudio = () => {
|
|
150
|
+
this.studioBridge = new window.WeaverseStudioBridge(this);
|
|
151
|
+
this.triggerUpdate();
|
|
152
|
+
};
|
|
153
|
+
if (!window.WeaverseStudioBridge) {
|
|
154
|
+
const studioBridgeScript = document.createElement("script");
|
|
155
|
+
studioBridgeScript.src = `${this.appUrl}/assets/studio/studio-bridge.js`;
|
|
156
|
+
studioBridgeScript.type = "module";
|
|
157
|
+
studioBridgeScript.onload = initStudio;
|
|
158
|
+
document.body.appendChild(studioBridgeScript);
|
|
159
|
+
} else {
|
|
160
|
+
initStudio();
|
|
161
|
+
}
|
|
162
162
|
}
|
|
163
|
-
}
|
|
163
|
+
}, 2e3);
|
|
164
164
|
}
|
|
165
165
|
registerElement(element) {
|
|
166
166
|
if (element == null ? void 0 : element.type) {
|
|
167
|
+
if (this.elementInstances.has(element.type)) {
|
|
168
|
+
throw new Error(`Weaverse: Element '${element.type}' already registered`);
|
|
169
|
+
}
|
|
167
170
|
this.elementInstances.set(element == null ? void 0 : element.type, element);
|
|
168
171
|
} else {
|
|
169
172
|
throw new Error("Weaverse: registerElement: `type` is required");
|
|
@@ -172,9 +175,6 @@ var _Weaverse = class {
|
|
|
172
175
|
init() {
|
|
173
176
|
this.initStitches();
|
|
174
177
|
this.initProjectItemData();
|
|
175
|
-
setTimeout(() => {
|
|
176
|
-
this.loadStudio();
|
|
177
|
-
}, 1e3);
|
|
178
178
|
}
|
|
179
179
|
subscribe(fn) {
|
|
180
180
|
this.listeners.add(fn);
|
package/package.json
CHANGED