@weaverse/core 5.17.0 → 5.18.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/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types/core.d.ts +96 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/icon-name.d.ts +217 -0
- package/dist/types/icon-name.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +192 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/event-emitter.d.ts +16 -0
- package/dist/types/utils/event-emitter.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +23 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +5 -4
- package/src/core.ts +251 -0
- package/src/icon-name.d.ts +215 -0
- package/src/index.ts +11 -0
- package/src/types.ts +264 -0
- package/src/utils/event-emitter.ts +31 -0
- package/src/utils/index.ts +71 -0
- package/dist/index.d.mts +0 -413
- package/dist/index.d.ts +0 -413
package/dist/index.d.mts
DELETED
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, ForwardRefExoticComponent, RefObject } from 'react';
|
|
2
|
-
|
|
3
|
-
// This file is generated from Weaverse Studio
|
|
4
|
-
|
|
5
|
-
type IconName =
|
|
6
|
-
| 'accessibility'
|
|
7
|
-
| 'activity-square'
|
|
8
|
-
| 'alarm-clock-off'
|
|
9
|
-
| 'alarm-clock'
|
|
10
|
-
| 'alarm-minus'
|
|
11
|
-
| 'alarm-plus'
|
|
12
|
-
| 'album'
|
|
13
|
-
| 'alert-circle'
|
|
14
|
-
| 'alert-octagon'
|
|
15
|
-
| 'alert-triangle'
|
|
16
|
-
| 'align-box-center-bottom-outline'
|
|
17
|
-
| 'align-box-center-middle-outline'
|
|
18
|
-
| 'align-box-center-top-outline'
|
|
19
|
-
| 'align-box-left-bottom-outline'
|
|
20
|
-
| 'align-box-left-middle-outline'
|
|
21
|
-
| 'align-box-left-top-outline'
|
|
22
|
-
| 'align-box-right-bottom-outline'
|
|
23
|
-
| 'align-box-right-middle-outline'
|
|
24
|
-
| 'align-box-right-top-outline'
|
|
25
|
-
| 'align-center-vertical'
|
|
26
|
-
| 'align-end-vertical'
|
|
27
|
-
| 'align-left'
|
|
28
|
-
| 'align-right'
|
|
29
|
-
| 'align-start-vertical'
|
|
30
|
-
| 'arrow-down-a-z'
|
|
31
|
-
| 'arrow-down-narrow-wide'
|
|
32
|
-
| 'arrow-left-from-line'
|
|
33
|
-
| 'arrow-left-right'
|
|
34
|
-
| 'arrow-up-a-z'
|
|
35
|
-
| 'arrow-up-narrow-wide'
|
|
36
|
-
| 'atom'
|
|
37
|
-
| 'blocks'
|
|
38
|
-
| 'book-image'
|
|
39
|
-
| 'book-marked'
|
|
40
|
-
| 'book-text'
|
|
41
|
-
| 'book'
|
|
42
|
-
| 'box-select'
|
|
43
|
-
| 'box'
|
|
44
|
-
| 'boxes'
|
|
45
|
-
| 'brackets'
|
|
46
|
-
| 'calendar-minus'
|
|
47
|
-
| 'calendar-plus'
|
|
48
|
-
| 'calendar'
|
|
49
|
-
| 'check-check'
|
|
50
|
-
| 'check-circle'
|
|
51
|
-
| 'check'
|
|
52
|
-
| 'chevron-down'
|
|
53
|
-
| 'chevron-left'
|
|
54
|
-
| 'chevron-right'
|
|
55
|
-
| 'chevron-up'
|
|
56
|
-
| 'chevrons-up-down'
|
|
57
|
-
| 'circle-dot'
|
|
58
|
-
| 'circle'
|
|
59
|
-
| 'code'
|
|
60
|
-
| 'columns-2'
|
|
61
|
-
| 'columns-3'
|
|
62
|
-
| 'concierge-bell'
|
|
63
|
-
| 'contact'
|
|
64
|
-
| 'copy'
|
|
65
|
-
| 'corner-up-left'
|
|
66
|
-
| 'expand'
|
|
67
|
-
| 'external-link'
|
|
68
|
-
| 'eye-off'
|
|
69
|
-
| 'eye'
|
|
70
|
-
| 'facebook'
|
|
71
|
-
| 'file-code-2'
|
|
72
|
-
| 'file-plus-2'
|
|
73
|
-
| 'file-search'
|
|
74
|
-
| 'file-text'
|
|
75
|
-
| 'file'
|
|
76
|
-
| 'filter'
|
|
77
|
-
| 'flag'
|
|
78
|
-
| 'flask-conical'
|
|
79
|
-
| 'focus'
|
|
80
|
-
| 'fold-horizontal'
|
|
81
|
-
| 'fold-vertical'
|
|
82
|
-
| 'folder-git-2'
|
|
83
|
-
| 'folder-open'
|
|
84
|
-
| 'folder-plus'
|
|
85
|
-
| 'folder-search'
|
|
86
|
-
| 'folder-symlink'
|
|
87
|
-
| 'folder'
|
|
88
|
-
| 'form-input'
|
|
89
|
-
| 'frown'
|
|
90
|
-
| 'gallery-horizontal-end'
|
|
91
|
-
| 'gallery-horizontal'
|
|
92
|
-
| 'gauge'
|
|
93
|
-
| 'github'
|
|
94
|
-
| 'globe'
|
|
95
|
-
| 'grid-2x2'
|
|
96
|
-
| 'grip-vertical'
|
|
97
|
-
| 'hammer'
|
|
98
|
-
| 'hard-drive-download'
|
|
99
|
-
| 'help-circle'
|
|
100
|
-
| 'home'
|
|
101
|
-
| 'hourglass'
|
|
102
|
-
| 'image-off'
|
|
103
|
-
| 'image-plus'
|
|
104
|
-
| 'image'
|
|
105
|
-
| 'images'
|
|
106
|
-
| 'info'
|
|
107
|
-
| 'languages'
|
|
108
|
-
| 'layers'
|
|
109
|
-
| 'layout-dashboard'
|
|
110
|
-
| 'layout-grid'
|
|
111
|
-
| 'layout-list'
|
|
112
|
-
| 'layout-panel-left'
|
|
113
|
-
| 'layout-template'
|
|
114
|
-
| 'life-buoy'
|
|
115
|
-
| 'lightbulb'
|
|
116
|
-
| 'link'
|
|
117
|
-
| 'linkedin'
|
|
118
|
-
| 'list-end'
|
|
119
|
-
| 'list-start'
|
|
120
|
-
| 'list-todo'
|
|
121
|
-
| 'loader-2'
|
|
122
|
-
| 'loader'
|
|
123
|
-
| 'log-out'
|
|
124
|
-
| 'map-pinned'
|
|
125
|
-
| 'map'
|
|
126
|
-
| 'maximize'
|
|
127
|
-
| 'message-circle'
|
|
128
|
-
| 'message-square'
|
|
129
|
-
| 'messages-square'
|
|
130
|
-
| 'minimize'
|
|
131
|
-
| 'minus'
|
|
132
|
-
| 'monitor-play'
|
|
133
|
-
| 'monitor'
|
|
134
|
-
| 'moon'
|
|
135
|
-
| 'more-horizontal'
|
|
136
|
-
| 'more-vertical'
|
|
137
|
-
| 'mouse-pointer-2'
|
|
138
|
-
| 'mouse-pointer-click'
|
|
139
|
-
| 'mouse-pointer-square-dashed'
|
|
140
|
-
| 'mouse-pointer-square'
|
|
141
|
-
| 'mouse-pointer'
|
|
142
|
-
| 'mouse'
|
|
143
|
-
| 'move-down-left'
|
|
144
|
-
| 'move-down-right'
|
|
145
|
-
| 'move-down'
|
|
146
|
-
| 'move-horizontal'
|
|
147
|
-
| 'move-left'
|
|
148
|
-
| 'move-right'
|
|
149
|
-
| 'move-up-left'
|
|
150
|
-
| 'move-up-right'
|
|
151
|
-
| 'move-up'
|
|
152
|
-
| 'newspaper'
|
|
153
|
-
| 'notebook-tabs'
|
|
154
|
-
| 'package-check'
|
|
155
|
-
| 'package-open'
|
|
156
|
-
| 'package'
|
|
157
|
-
| 'paintbrush-2'
|
|
158
|
-
| 'paintbrush'
|
|
159
|
-
| 'palette'
|
|
160
|
-
| 'panel-left'
|
|
161
|
-
| 'pen'
|
|
162
|
-
| 'pencil-line'
|
|
163
|
-
| 'pencil'
|
|
164
|
-
| 'phone'
|
|
165
|
-
| 'plane-landing'
|
|
166
|
-
| 'play-circle'
|
|
167
|
-
| 'plus-circle'
|
|
168
|
-
| 'plus-square'
|
|
169
|
-
| 'plus'
|
|
170
|
-
| 'presentation'
|
|
171
|
-
| 'puzzle'
|
|
172
|
-
| 'rectangle-horizontal'
|
|
173
|
-
| 'rocket'
|
|
174
|
-
| 'search'
|
|
175
|
-
| 'settings'
|
|
176
|
-
| 'shield-question'
|
|
177
|
-
| 'shopping-bag'
|
|
178
|
-
| 'shopping-cart'
|
|
179
|
-
| 'shrink'
|
|
180
|
-
| 'slack'
|
|
181
|
-
| 'sliders-horizontal'
|
|
182
|
-
| 'sliders'
|
|
183
|
-
| 'slideshow-outline'
|
|
184
|
-
| 'smartphone'
|
|
185
|
-
| 'sparkles'
|
|
186
|
-
| 'square'
|
|
187
|
-
| 'squircle'
|
|
188
|
-
| 'star-filled'
|
|
189
|
-
| 'star-half-filled'
|
|
190
|
-
| 'star'
|
|
191
|
-
| 'store'
|
|
192
|
-
| 'stretch-vertical'
|
|
193
|
-
| 'sun'
|
|
194
|
-
| 'tag'
|
|
195
|
-
| 'tags'
|
|
196
|
-
| 'terminal'
|
|
197
|
-
| 'text-cursor-input'
|
|
198
|
-
| 'timer'
|
|
199
|
-
| 'trash'
|
|
200
|
-
| 'truck'
|
|
201
|
-
| 'twitter'
|
|
202
|
-
| 'type'
|
|
203
|
-
| 'undo-2'
|
|
204
|
-
| 'undo'
|
|
205
|
-
| 'upload-cloud'
|
|
206
|
-
| 'upload'
|
|
207
|
-
| 'user'
|
|
208
|
-
| 'users'
|
|
209
|
-
| 'video'
|
|
210
|
-
| 'wand-2'
|
|
211
|
-
| 'wand-sparkles'
|
|
212
|
-
| 'x-logo'
|
|
213
|
-
| 'x-octagon'
|
|
214
|
-
| 'x'
|
|
215
|
-
| 'youtube'
|
|
216
|
-
| 'zap'
|
|
217
|
-
|
|
218
|
-
type ToolbarAction = 'general-settings' | 'settings-level-2' | 'duplicate' | 'delete' | 'global-sections';
|
|
219
|
-
type AdvancedGroupType = 'border' | 'alignment' | 'background' | 'dimensions' | 'spacing' | 'typography' | 'visibility' | 'shadows-and-effects' | 'layout-background';
|
|
220
|
-
type PositionInputValue = 'top left' | 'top center' | 'top right' | 'center left' | 'center center' | 'center right' | 'bottom left' | 'bottom center' | 'bottom right';
|
|
221
|
-
type InputType = 'blog' | 'collection' | 'collection-list' | 'color' | 'datepicker' | 'image' | 'video' | 'map-autocomplete' | 'position' | 'product' | 'product-list' | 'range' | 'richtext' | 'select' | 'switch' | 'text' | 'textarea' | 'toggle-group' | 'metaobject' | 'url';
|
|
222
|
-
type WeaverseCSSProperties = CSSProperties;
|
|
223
|
-
type ChildElementCSS = Partial<{
|
|
224
|
-
[selector: string]: WeaverseCSSProperties & ChildElementCSS;
|
|
225
|
-
}>;
|
|
226
|
-
type WeaverseResourcePickerData = {
|
|
227
|
-
id: number;
|
|
228
|
-
handle: string;
|
|
229
|
-
};
|
|
230
|
-
type WeaverseImage = {
|
|
231
|
-
id: string;
|
|
232
|
-
url: string;
|
|
233
|
-
altText: string;
|
|
234
|
-
width: number;
|
|
235
|
-
height: number;
|
|
236
|
-
previewSrc: string;
|
|
237
|
-
};
|
|
238
|
-
type WeaverseVideo = {
|
|
239
|
-
id: string;
|
|
240
|
-
url: string;
|
|
241
|
-
altText: string;
|
|
242
|
-
width: number;
|
|
243
|
-
height: number;
|
|
244
|
-
previewSrc: string;
|
|
245
|
-
};
|
|
246
|
-
type AdditionalInputConfigs = SelectInputConfigs | ToggleGroupConfigs | RangeInputConfigs;
|
|
247
|
-
type ElementCSS = {
|
|
248
|
-
'@desktop'?: WeaverseCSSProperties | ChildElementCSS;
|
|
249
|
-
'@mobile'?: WeaverseCSSProperties | ChildElementCSS;
|
|
250
|
-
};
|
|
251
|
-
type ElementData = {
|
|
252
|
-
id: string;
|
|
253
|
-
type: string;
|
|
254
|
-
[key: string]: any;
|
|
255
|
-
};
|
|
256
|
-
type WeaverseElement = {
|
|
257
|
-
Component: ForwardRefExoticComponent<any>;
|
|
258
|
-
type: string;
|
|
259
|
-
'data-wv-id': string;
|
|
260
|
-
'data-wv-type': string;
|
|
261
|
-
};
|
|
262
|
-
type ElementSchema = {
|
|
263
|
-
title: string;
|
|
264
|
-
type: string;
|
|
265
|
-
};
|
|
266
|
-
type BreakPoints = {
|
|
267
|
-
mobile: string;
|
|
268
|
-
desktop: string;
|
|
269
|
-
};
|
|
270
|
-
type WeaverseProjectDataType = {
|
|
271
|
-
id?: string;
|
|
272
|
-
items: ElementData[];
|
|
273
|
-
rootId: string;
|
|
274
|
-
};
|
|
275
|
-
type WeaverseCoreParams = {
|
|
276
|
-
mediaBreakPoints?: BreakPoints;
|
|
277
|
-
weaverseHost?: string;
|
|
278
|
-
weaverseVersion?: string;
|
|
279
|
-
projectId: string;
|
|
280
|
-
data: WeaverseProjectDataType;
|
|
281
|
-
isDesignMode?: boolean;
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* BasicInput interface
|
|
285
|
-
*
|
|
286
|
-
* @property {InputType} type - The type of the input
|
|
287
|
-
* @property {string} name - The key of the value of the element data or styles
|
|
288
|
-
* @property {string} [label] - The label of the input
|
|
289
|
-
* @property {ConfigsType} [configs] - Additional options for inputs that require more configuration
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* // Bind to `element.data.title`
|
|
293
|
-
* name: "title"
|
|
294
|
-
* // Bind to `element.css["@desktop"].backgroundColor`
|
|
295
|
-
* name: "backgroundColor"
|
|
296
|
-
*/
|
|
297
|
-
type BasicInput<ConfigsType = AdditionalInputConfigs> = {
|
|
298
|
-
type: InputType;
|
|
299
|
-
name: string;
|
|
300
|
-
label?: string;
|
|
301
|
-
configs?: ConfigsType;
|
|
302
|
-
condition?: string;
|
|
303
|
-
defaultValue?: string | number | boolean | Partial<WeaverseImage> | {
|
|
304
|
-
[x: string]: any;
|
|
305
|
-
};
|
|
306
|
-
placeholder?: string;
|
|
307
|
-
helpText?: string;
|
|
308
|
-
};
|
|
309
|
-
type SelectInputConfigs = {
|
|
310
|
-
options?: {
|
|
311
|
-
value: string;
|
|
312
|
-
label: string;
|
|
313
|
-
}[];
|
|
314
|
-
};
|
|
315
|
-
type ToggleGroupConfigs = {
|
|
316
|
-
options?: {
|
|
317
|
-
value: string;
|
|
318
|
-
label: string;
|
|
319
|
-
icon?: IconName;
|
|
320
|
-
}[];
|
|
321
|
-
};
|
|
322
|
-
type RangeInputConfigs = {
|
|
323
|
-
min?: number;
|
|
324
|
-
max?: number;
|
|
325
|
-
step?: number;
|
|
326
|
-
unit?: string;
|
|
327
|
-
};
|
|
328
|
-
declare global {
|
|
329
|
-
interface Window {
|
|
330
|
-
weaverseStudio: any;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
type AnyFunction = (...args: any[]) => any;
|
|
335
|
-
declare class EventEmitter {
|
|
336
|
-
listeners: Set<AnyFunction>;
|
|
337
|
-
constructor();
|
|
338
|
-
subscribe: (fn: AnyFunction) => () => void;
|
|
339
|
-
unsubscribe: (fn: AnyFunction) => void;
|
|
340
|
-
emit: (data: any) => void;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
declare class WeaverseItemStore extends EventEmitter {
|
|
344
|
-
weaverse: Weaverse;
|
|
345
|
-
ref: RefObject<HTMLElement | null>;
|
|
346
|
-
_store: ElementData;
|
|
347
|
-
constructor(initialData: ElementData, weaverse: Weaverse);
|
|
348
|
-
get _id(): string;
|
|
349
|
-
get _element(): HTMLElement | null;
|
|
350
|
-
get Element(): any;
|
|
351
|
-
getDefaultCss: () => ElementCSS;
|
|
352
|
-
get data(): ElementData;
|
|
353
|
-
set data(update: Omit<ElementData, 'id' | 'type'>);
|
|
354
|
-
setData: (update: Omit<ElementData, "id" | "type">) => ElementData;
|
|
355
|
-
getSnapShot: () => ElementData;
|
|
356
|
-
triggerUpdate: () => void;
|
|
357
|
-
}
|
|
358
|
-
declare class Weaverse extends EventEmitter {
|
|
359
|
-
contentRootElement: HTMLElement | null;
|
|
360
|
-
static itemInstances: Map<any, any>;
|
|
361
|
-
weaverseHost: string;
|
|
362
|
-
weaverseVersion: string;
|
|
363
|
-
sdkVersion: string;
|
|
364
|
-
projectId: string;
|
|
365
|
-
isDesignMode: boolean;
|
|
366
|
-
isPreviewMode: boolean;
|
|
367
|
-
studioBridge?: any;
|
|
368
|
-
static ItemConstructor: typeof WeaverseItemStore;
|
|
369
|
-
data: WeaverseProjectDataType;
|
|
370
|
-
dataContext: Record<string, unknown> | null;
|
|
371
|
-
static elementRegistry: Map<any, any>;
|
|
372
|
-
static mediaBreakPoints: BreakPoints;
|
|
373
|
-
constructor(params: WeaverseCoreParams);
|
|
374
|
-
getSnapShot: () => WeaverseProjectDataType;
|
|
375
|
-
/**
|
|
376
|
-
* Create new `WeaverseItemStore` instance for each item in the project.
|
|
377
|
-
*/
|
|
378
|
-
initProject: () => void;
|
|
379
|
-
get itemInstances(): Map<any, any>;
|
|
380
|
-
createItemInstance: (data: ElementData) => WeaverseItemStore;
|
|
381
|
-
/**
|
|
382
|
-
* Register the custom React Component to Weaverse, store it into Weaverse.elementRegistry
|
|
383
|
-
*/
|
|
384
|
-
static registerElement: typeof registerElement;
|
|
385
|
-
get elementRegistry(): Map<any, any>;
|
|
386
|
-
triggerUpdate: () => void;
|
|
387
|
-
refreshAllItems(): void;
|
|
388
|
-
/**
|
|
389
|
-
* Reset the project data and re-initialize all items.
|
|
390
|
-
* Used when we need to re-render the project with new data (like applying new template)
|
|
391
|
-
* @param data {WeaverseProjectDataType}
|
|
392
|
-
*/
|
|
393
|
-
setProjectData: (data: WeaverseProjectDataType) => void;
|
|
394
|
-
}
|
|
395
|
-
declare function registerElement(element: {
|
|
396
|
-
type: string;
|
|
397
|
-
[x: string]: any;
|
|
398
|
-
}): void;
|
|
399
|
-
|
|
400
|
-
declare let isReactNative: boolean;
|
|
401
|
-
declare let isBrowser: boolean;
|
|
402
|
-
declare let isIframe: boolean;
|
|
403
|
-
/**
|
|
404
|
-
* Deep merge two objects.
|
|
405
|
-
* @param target
|
|
406
|
-
* @param source
|
|
407
|
-
*/
|
|
408
|
-
declare function merge(target: Record<string, any>, source: Record<string, any>): {
|
|
409
|
-
[x: string]: any;
|
|
410
|
-
};
|
|
411
|
-
declare function loadScript(src: string): Promise<unknown>;
|
|
412
|
-
|
|
413
|
-
export { type AdditionalInputConfigs, type AdvancedGroupType, type BasicInput, type BreakPoints, type ChildElementCSS, type ElementCSS, type ElementData, type ElementSchema, EventEmitter, type InputType, type PositionInputValue, type RangeInputConfigs, type SelectInputConfigs, type ToggleGroupConfigs, type ToolbarAction, Weaverse, type WeaverseCSSProperties, type WeaverseCoreParams, type WeaverseElement, type WeaverseImage, WeaverseItemStore, type WeaverseProjectDataType, type WeaverseResourcePickerData, type WeaverseVideo, isBrowser, isIframe, isReactNative, loadScript, merge, registerElement };
|