@weaverse/core 0.6.21 → 0.6.22
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 +108 -55
- package/dist/index.js +8 -5
- package/dist/index.mjs +8 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,88 +1,141 @@
|
|
|
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
|
-
declare type
|
|
37
|
-
declare type
|
|
38
|
-
[key in ElementFlags]?: boolean;
|
|
39
|
-
};
|
|
73
|
+
}
|
|
74
|
+
declare type FlagType = "draggable" | "resizable" | "sortable";
|
|
75
|
+
declare type ElementFlags = Partial<Record<FlagType, boolean>>;
|
|
40
76
|
declare type ToolbarAction = "duplicate" | "delete" | "edit-button" | "insert-link" | "select-template" | "copy-styles" | "paste-styles";
|
|
41
|
-
|
|
77
|
+
interface ChildElement {
|
|
42
78
|
label: string;
|
|
43
79
|
selector: string;
|
|
80
|
+
}
|
|
81
|
+
declare type ParentType = "container" | "layout" | "root";
|
|
82
|
+
declare type GridSize = {
|
|
83
|
+
rowSpan: number;
|
|
84
|
+
colSpan: number;
|
|
44
85
|
};
|
|
45
|
-
|
|
46
|
-
declare type WeaverseElementSchema = {
|
|
47
|
-
type: string;
|
|
48
|
-
parentType: ElementParentType;
|
|
86
|
+
interface ElementSchema {
|
|
49
87
|
title: string;
|
|
88
|
+
type: string;
|
|
89
|
+
parentType: ParentType;
|
|
90
|
+
gridSize?: GridSize;
|
|
50
91
|
inspector?: ElementInspector;
|
|
51
92
|
toolbar?: (ToolbarAction | ToolbarAction[])[];
|
|
52
|
-
subElements?:
|
|
53
|
-
catalog?:
|
|
54
|
-
flags?:
|
|
55
|
-
}
|
|
56
|
-
|
|
93
|
+
subElements?: ChildElement[];
|
|
94
|
+
catalog?: ElementCatalog;
|
|
95
|
+
flags?: ElementFlags;
|
|
96
|
+
}
|
|
97
|
+
interface ElementData {
|
|
57
98
|
id: string;
|
|
58
99
|
type: string;
|
|
59
|
-
childIds?: (string | number)[]
|
|
60
|
-
css?:
|
|
100
|
+
childIds?: (string | number)[];
|
|
101
|
+
css?: ElementCSS;
|
|
61
102
|
[key: string]: any;
|
|
103
|
+
}
|
|
104
|
+
declare type WeaverseCSSProperties = Stitches.CSS & Partial<Record<keyof typeof stichesUtils, string | number>>;
|
|
105
|
+
declare type ChildElementCSS = Partial<{
|
|
106
|
+
[selector: string]: WeaverseCSSProperties & ChildElementCSS;
|
|
107
|
+
}>;
|
|
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;
|
|
62
118
|
};
|
|
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[];
|
|
119
|
+
declare type BasicGroup = {
|
|
120
|
+
type: "basic";
|
|
121
|
+
label: string;
|
|
122
|
+
inputs: BasicInput[];
|
|
74
123
|
};
|
|
75
|
-
declare type
|
|
124
|
+
declare type AdvancedInput = "alignment" | "background" | "border" | "countdown" | "dimensions" | "form" | "instagram" | "product" | "spacing" | "visibility";
|
|
125
|
+
interface BasicInput {
|
|
76
126
|
type: InputType;
|
|
77
|
-
label
|
|
78
|
-
name
|
|
127
|
+
label: string;
|
|
128
|
+
name: string;
|
|
79
129
|
defaultValue?: string;
|
|
130
|
+
placeholder?: string;
|
|
80
131
|
helpText?: string;
|
|
81
|
-
options?:
|
|
132
|
+
options?: {
|
|
133
|
+
value: string;
|
|
134
|
+
label: string;
|
|
135
|
+
}[];
|
|
82
136
|
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";
|
|
137
|
+
}
|
|
138
|
+
declare type InputType = "select" | "radio" | "range" | "button" | "image" | "color" | "input" | "switch" | "textarea";
|
|
86
139
|
declare global {
|
|
87
140
|
interface Window {
|
|
88
141
|
WeaverseStudioBridge: TODO;
|
|
@@ -92,7 +145,7 @@ declare global {
|
|
|
92
145
|
|
|
93
146
|
/**
|
|
94
147
|
* WeaverseItemStore is a store for Weaverse item, it can be used to subscribe/update the item data
|
|
95
|
-
* @param itemData {
|
|
148
|
+
* @param itemData {ElementData} Weaverse item data
|
|
96
149
|
* @param weaverse {Weaverse} Weaverse instance
|
|
97
150
|
* @example
|
|
98
151
|
* useEffect(() => {
|
|
@@ -110,15 +163,15 @@ declare class WeaverseItemStore {
|
|
|
110
163
|
ref: RefObject<HTMLElement>;
|
|
111
164
|
weaverse: Weaverse;
|
|
112
165
|
stitchesClass: string;
|
|
113
|
-
_data:
|
|
114
|
-
_flags:
|
|
115
|
-
constructor(itemData:
|
|
166
|
+
_data: ElementData;
|
|
167
|
+
_flags: ElementFlags;
|
|
168
|
+
constructor(itemData: ElementData, weaverse: Weaverse);
|
|
116
169
|
get _id(): string;
|
|
117
170
|
get _element(): HTMLElement | null;
|
|
118
171
|
get Element(): WeaverseElement | undefined;
|
|
119
|
-
set data(data: Omit<
|
|
120
|
-
get data():
|
|
121
|
-
setData: (data: Omit<
|
|
172
|
+
set data(data: Omit<ElementData, "id" | "type">);
|
|
173
|
+
get data(): ElementData;
|
|
174
|
+
setData: (data: Omit<ElementData, "id" | "type">) => ElementData;
|
|
122
175
|
subscribe: (fn: any) => void;
|
|
123
176
|
unsubscribe: (fn: any) => void;
|
|
124
177
|
triggerUpdate: () => void;
|
|
@@ -171,7 +224,7 @@ declare class Weaverse {
|
|
|
171
224
|
/**
|
|
172
225
|
* stitches instance for handling CSS stylesheet, media, theme for Weaverse project
|
|
173
226
|
*/
|
|
174
|
-
stitchesInstance: Stitches | any;
|
|
227
|
+
stitchesInstance: Stitches$1 | any;
|
|
175
228
|
studioBridge?: any;
|
|
176
229
|
static WeaverseItemStore: typeof WeaverseItemStore;
|
|
177
230
|
mediaBreakPoints: {
|
|
@@ -222,4 +275,4 @@ declare const isReactNative: boolean;
|
|
|
222
275
|
declare const isBrowser: boolean;
|
|
223
276
|
declare const isIframe: boolean;
|
|
224
277
|
|
|
225
|
-
export { CatalogGroup,
|
|
278
|
+
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