@weaverse/core 0.6.19 → 0.6.20
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 +62 -49
- package/dist/index.js +8 -5
- package/dist/index.mjs +8 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -40,89 +40,102 @@ declare const stichesUtils: {
|
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
declare type TODO = any;
|
|
43
44
|
interface ProjectDataType {
|
|
44
|
-
items:
|
|
45
|
+
items: ElementData[];
|
|
45
46
|
rootId: string;
|
|
46
47
|
script: {
|
|
47
48
|
css: string;
|
|
48
49
|
js: string;
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
+
interface WeaverseType {
|
|
52
53
|
mediaBreakPoints?: any;
|
|
53
54
|
appUrl?: string;
|
|
54
55
|
projectKey?: string;
|
|
55
56
|
projectData?: ProjectDataType;
|
|
56
57
|
isDesignMode?: boolean;
|
|
57
58
|
ssrMode?: boolean;
|
|
58
|
-
}
|
|
59
|
-
declare type TODO = any;
|
|
60
|
-
declare type WeaverseElementMap = {
|
|
61
|
-
[key: string]: WeaverseElement;
|
|
62
|
-
};
|
|
59
|
+
}
|
|
63
60
|
declare type WeaverseElement = {
|
|
64
61
|
Component: ForwardRefExoticComponent<any>;
|
|
65
62
|
type: string;
|
|
66
|
-
schema?:
|
|
63
|
+
schema?: ElementSchema;
|
|
67
64
|
};
|
|
65
|
+
interface ElementsMap {
|
|
66
|
+
[key: string]: WeaverseElement;
|
|
67
|
+
}
|
|
68
68
|
declare type CatalogGroup = "essential" | "composition" | "other";
|
|
69
|
-
|
|
69
|
+
interface ElementCatalog {
|
|
70
70
|
name: string;
|
|
71
71
|
icon?: string;
|
|
72
72
|
group?: CatalogGroup;
|
|
73
|
-
}
|
|
74
|
-
declare type
|
|
75
|
-
declare type
|
|
76
|
-
[key in ElementFlags]?: boolean;
|
|
77
|
-
};
|
|
73
|
+
}
|
|
74
|
+
declare type FlagType = "draggable" | "resizable" | "sortable";
|
|
75
|
+
declare type ElementFlags = Partial<Record<FlagType, boolean>>;
|
|
78
76
|
declare type ToolbarAction = "duplicate" | "delete" | "edit-button" | "insert-link" | "select-template" | "copy-styles" | "paste-styles";
|
|
79
|
-
|
|
77
|
+
interface ChildElement {
|
|
80
78
|
label: string;
|
|
81
79
|
selector: string;
|
|
82
|
-
}
|
|
83
|
-
declare type
|
|
84
|
-
declare type
|
|
80
|
+
}
|
|
81
|
+
declare type ParentType = "container" | "layout" | "root";
|
|
82
|
+
declare type GridSize = {
|
|
85
83
|
rowSpan: number;
|
|
86
84
|
colSpan: number;
|
|
87
85
|
};
|
|
88
|
-
|
|
89
|
-
type: string;
|
|
90
|
-
parentType: ElementParentType;
|
|
91
|
-
gridSize?: ElementGridSize;
|
|
86
|
+
interface ElementSchema {
|
|
92
87
|
title: string;
|
|
88
|
+
type: string;
|
|
89
|
+
parentType: ParentType;
|
|
90
|
+
gridSize?: GridSize;
|
|
93
91
|
inspector?: ElementInspector;
|
|
94
92
|
toolbar?: (ToolbarAction | ToolbarAction[])[];
|
|
95
|
-
subElements?:
|
|
96
|
-
catalog?:
|
|
97
|
-
flags?:
|
|
98
|
-
}
|
|
99
|
-
|
|
93
|
+
subElements?: ChildElement[];
|
|
94
|
+
catalog?: ElementCatalog;
|
|
95
|
+
flags?: ElementFlags;
|
|
96
|
+
}
|
|
97
|
+
interface ElementData {
|
|
100
98
|
id: string;
|
|
101
99
|
type: string;
|
|
102
|
-
childIds?: (string | number)[]
|
|
103
|
-
css?:
|
|
100
|
+
childIds?: (string | number)[];
|
|
101
|
+
css?: ElementCSS;
|
|
104
102
|
[key: string]: any;
|
|
105
|
-
}
|
|
103
|
+
}
|
|
106
104
|
declare type WeaverseCSSProperties = Stitches.CSS & Partial<Record<keyof typeof stichesUtils, string | number>>;
|
|
107
105
|
declare type ChildElementCSS = Partial<{
|
|
108
106
|
[selector: string]: WeaverseCSSProperties & ChildElementCSS;
|
|
109
107
|
}>;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
interface ElementCSS {
|
|
109
|
+
"@desktop"?: WeaverseCSSProperties | ChildElementCSS;
|
|
110
|
+
"@mobile"?: WeaverseCSSProperties | ChildElementCSS;
|
|
111
|
+
}
|
|
112
|
+
interface ElementInspector {
|
|
113
|
+
settings?: (AdvancedGroup | BasicGroup)[];
|
|
114
|
+
styles?: (AdvancedGroup | BasicGroup)[];
|
|
115
|
+
}
|
|
116
|
+
declare type AdvancedGroup = {
|
|
117
|
+
type: AdvancedInput;
|
|
114
118
|
};
|
|
115
|
-
declare type
|
|
119
|
+
declare type BasicGroup = {
|
|
120
|
+
type: "basic";
|
|
121
|
+
label: string;
|
|
122
|
+
inputs: BasicInput[];
|
|
123
|
+
};
|
|
124
|
+
declare type AdvancedInput = "alignment" | "background" | "border" | "countdown" | "dimensions" | "form" | "instagram" | "product" | "spacing" | "visibility";
|
|
125
|
+
interface BasicInput {
|
|
116
126
|
type: InputType;
|
|
117
|
-
label
|
|
118
|
-
name
|
|
127
|
+
label: string;
|
|
128
|
+
name: string;
|
|
119
129
|
defaultValue?: string;
|
|
130
|
+
placeholder?: string;
|
|
120
131
|
helpText?: string;
|
|
121
|
-
options?:
|
|
132
|
+
options?: {
|
|
133
|
+
value: string;
|
|
134
|
+
label: string;
|
|
135
|
+
}[];
|
|
122
136
|
conditions?: TODO[];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
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";
|
|
137
|
+
}
|
|
138
|
+
declare type InputType = "select" | "radio" | "range" | "button" | "image" | "color" | "input" | "switch" | "textarea";
|
|
126
139
|
declare global {
|
|
127
140
|
interface Window {
|
|
128
141
|
WeaverseStudioBridge: TODO;
|
|
@@ -132,7 +145,7 @@ declare global {
|
|
|
132
145
|
|
|
133
146
|
/**
|
|
134
147
|
* WeaverseItemStore is a store for Weaverse item, it can be used to subscribe/update the item data
|
|
135
|
-
* @param itemData {
|
|
148
|
+
* @param itemData {ElementData} Weaverse item data
|
|
136
149
|
* @param weaverse {Weaverse} Weaverse instance
|
|
137
150
|
* @example
|
|
138
151
|
* useEffect(() => {
|
|
@@ -150,15 +163,15 @@ declare class WeaverseItemStore {
|
|
|
150
163
|
ref: RefObject<HTMLElement>;
|
|
151
164
|
weaverse: Weaverse;
|
|
152
165
|
stitchesClass: string;
|
|
153
|
-
_data:
|
|
154
|
-
_flags:
|
|
155
|
-
constructor(itemData:
|
|
166
|
+
_data: ElementData;
|
|
167
|
+
_flags: ElementFlags;
|
|
168
|
+
constructor(itemData: ElementData, weaverse: Weaverse);
|
|
156
169
|
get _id(): string;
|
|
157
170
|
get _element(): HTMLElement | null;
|
|
158
171
|
get Element(): WeaverseElement | undefined;
|
|
159
|
-
set data(data: Omit<
|
|
160
|
-
get data():
|
|
161
|
-
setData: (data: Omit<
|
|
172
|
+
set data(data: Omit<ElementData, "id" | "type">);
|
|
173
|
+
get data(): ElementData;
|
|
174
|
+
setData: (data: Omit<ElementData, "id" | "type">) => ElementData;
|
|
162
175
|
subscribe: (fn: any) => void;
|
|
163
176
|
unsubscribe: (fn: any) => void;
|
|
164
177
|
triggerUpdate: () => void;
|
|
@@ -261,4 +274,4 @@ declare const isReactNative: boolean;
|
|
|
261
274
|
declare const isBrowser: boolean;
|
|
262
275
|
declare const isIframe: boolean;
|
|
263
276
|
|
|
264
|
-
export {
|
|
277
|
+
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) {
|
|
@@ -193,6 +193,9 @@ var _Weaverse = class {
|
|
|
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");
|
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) {
|
|
@@ -164,6 +164,9 @@ var _Weaverse = class {
|
|
|
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");
|
package/package.json
CHANGED