@weaverse/core 0.7.34 → 0.7.37
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 +0 -0
- package/dist/index.js +1 -360
- package/dist/index.mjs +1 -320
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1,360 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
-
|
|
26
|
-
// src/index.ts
|
|
27
|
-
var src_exports = {};
|
|
28
|
-
__export(src_exports, {
|
|
29
|
-
Weaverse: () => Weaverse,
|
|
30
|
-
WeaverseItemStore: () => WeaverseItemStore,
|
|
31
|
-
createGlobalStyles: () => createGlobalStyles,
|
|
32
|
-
isBrowser: () => isBrowser,
|
|
33
|
-
isIframe: () => isIframe,
|
|
34
|
-
isReactNative: () => isReactNative,
|
|
35
|
-
loadScript: () => loadScript,
|
|
36
|
-
stichesUtils: () => stichesUtils
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(src_exports);
|
|
39
|
-
|
|
40
|
-
// src/core.ts
|
|
41
|
-
var stitches = __toESM(require("@stitches/core"));
|
|
42
|
-
|
|
43
|
-
// src/utils/load-script.ts
|
|
44
|
-
function loadScript(url) {
|
|
45
|
-
return new Promise(function(resolve) {
|
|
46
|
-
const script = document.createElement("script");
|
|
47
|
-
script.src = url;
|
|
48
|
-
script.addEventListener("load", function() {
|
|
49
|
-
resolve(true);
|
|
50
|
-
});
|
|
51
|
-
document.head.appendChild(script);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// src/utils/styles.ts
|
|
56
|
-
var stichesUtils = {
|
|
57
|
-
m: (value) => ({
|
|
58
|
-
margin: value
|
|
59
|
-
}),
|
|
60
|
-
mt: (value) => ({
|
|
61
|
-
marginTop: value
|
|
62
|
-
}),
|
|
63
|
-
mr: (value) => ({
|
|
64
|
-
marginRight: value
|
|
65
|
-
}),
|
|
66
|
-
mb: (value) => ({
|
|
67
|
-
marginBottom: value
|
|
68
|
-
}),
|
|
69
|
-
ml: (value) => ({
|
|
70
|
-
marginLeft: value
|
|
71
|
-
}),
|
|
72
|
-
mx: (value) => ({
|
|
73
|
-
marginLeft: value,
|
|
74
|
-
marginRight: value
|
|
75
|
-
}),
|
|
76
|
-
my: (value) => ({
|
|
77
|
-
marginTop: value,
|
|
78
|
-
marginBottom: value
|
|
79
|
-
}),
|
|
80
|
-
size: (value) => ({
|
|
81
|
-
width: value,
|
|
82
|
-
height: value
|
|
83
|
-
}),
|
|
84
|
-
px: (value) => ({
|
|
85
|
-
paddingLeft: value,
|
|
86
|
-
paddingRight: value
|
|
87
|
-
}),
|
|
88
|
-
py: (value) => ({
|
|
89
|
-
paddingTop: value,
|
|
90
|
-
paddingBottom: value
|
|
91
|
-
})
|
|
92
|
-
};
|
|
93
|
-
function createGlobalStyles(stitches2) {
|
|
94
|
-
let globalStyles = stitches2.globalCss({
|
|
95
|
-
"@keyframes spin": {
|
|
96
|
-
from: { transform: "rotate(0deg)" },
|
|
97
|
-
to: { transform: "rotate(360deg)" }
|
|
98
|
-
},
|
|
99
|
-
"@keyframes pulse": {
|
|
100
|
-
"0%, 100%": { opacity: 1 },
|
|
101
|
-
"50%": { opacity: 0.5 }
|
|
102
|
-
},
|
|
103
|
-
".weaverse-content-root": {
|
|
104
|
-
"*": {
|
|
105
|
-
WebkitFontSmoothing: "antialiased",
|
|
106
|
-
MozOsxFontSmoothing: "auto",
|
|
107
|
-
textRendering: "optimizeLegibility",
|
|
108
|
-
boxSizing: "border-box"
|
|
109
|
-
},
|
|
110
|
-
input: {
|
|
111
|
-
"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button": {
|
|
112
|
-
"-webkit-appearance": "none",
|
|
113
|
-
margin: 0
|
|
114
|
-
},
|
|
115
|
-
"&[type=number]": {
|
|
116
|
-
"-moz-appearance": "textfield"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
select: {
|
|
120
|
-
WebkitAppearance: "none",
|
|
121
|
-
MozAppearance: "none",
|
|
122
|
-
appearance: "none",
|
|
123
|
-
outline: "none",
|
|
124
|
-
boxShadow: "none",
|
|
125
|
-
color: "currentColor",
|
|
126
|
-
verticalAlign: "middle",
|
|
127
|
-
backgroundColor: "transparent",
|
|
128
|
-
backgroundPosition: "center",
|
|
129
|
-
backgroundRepeat: "no-repeat",
|
|
130
|
-
backgroundImage: "url(https://ucarecdn.com/4bb6a6e7-1ce8-4201-8f2d-da00a50105f3/)",
|
|
131
|
-
backgroundSize: "10px",
|
|
132
|
-
backgroundPositionX: "calc(100% - 12px)",
|
|
133
|
-
paddingLeft: "12px",
|
|
134
|
-
paddingRight: "35px !important",
|
|
135
|
-
cursor: "pointer"
|
|
136
|
-
},
|
|
137
|
-
button: {
|
|
138
|
-
outline: "none",
|
|
139
|
-
boxShadow: "none",
|
|
140
|
-
cursor: "pointer",
|
|
141
|
-
border: "none",
|
|
142
|
-
"&:focus": {
|
|
143
|
-
outline: "none",
|
|
144
|
-
boxShadow: "none"
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
".animate-pulse": {
|
|
148
|
-
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
".wv-spinner-wrapper": {
|
|
152
|
-
position: "absolute",
|
|
153
|
-
inset: "0px",
|
|
154
|
-
display: "flex",
|
|
155
|
-
alignItems: "center",
|
|
156
|
-
justifyContent: "center",
|
|
157
|
-
backgroundColor: "inherit",
|
|
158
|
-
".wv-spinner": {
|
|
159
|
-
width: "20px",
|
|
160
|
-
height: "20px",
|
|
161
|
-
animation: "spin .75s linear infinite"
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
"[data-wv-placeholder]": {
|
|
165
|
-
height: "100%",
|
|
166
|
-
display: "flex",
|
|
167
|
-
flexDirection: "column",
|
|
168
|
-
alignItems: "center",
|
|
169
|
-
justifyContent: "center",
|
|
170
|
-
backgroundColor: "rgba(236, 236, 236, 0.5)",
|
|
171
|
-
backgroundClip: "content-box",
|
|
172
|
-
padding: "10px"
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
globalStyles();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/utils/index.ts
|
|
179
|
-
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
180
|
-
var isBrowser = typeof window !== "undefined" && !isReactNative;
|
|
181
|
-
var isIframe = isBrowser && window.top !== window.self;
|
|
182
|
-
|
|
183
|
-
// src/core.ts
|
|
184
|
-
var WeaverseItemStore = class {
|
|
185
|
-
constructor(itemData, weaverse) {
|
|
186
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
187
|
-
this.ref = {
|
|
188
|
-
current: null
|
|
189
|
-
};
|
|
190
|
-
this.stitchesClass = "";
|
|
191
|
-
this._data = { id: "", type: "" };
|
|
192
|
-
this._flags = {};
|
|
193
|
-
this.setData = (data) => {
|
|
194
|
-
this.data = Object.assign(this.data, data);
|
|
195
|
-
this.triggerUpdate();
|
|
196
|
-
return this.data;
|
|
197
|
-
};
|
|
198
|
-
this.subscribe = (fn) => {
|
|
199
|
-
this.listeners.add(fn);
|
|
200
|
-
};
|
|
201
|
-
this.unsubscribe = (fn) => {
|
|
202
|
-
this.listeners.delete(fn);
|
|
203
|
-
};
|
|
204
|
-
this.triggerUpdate = () => {
|
|
205
|
-
this.listeners.forEach((fn) => {
|
|
206
|
-
return fn(this.data);
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
let { type, id } = itemData;
|
|
210
|
-
this.weaverse = weaverse;
|
|
211
|
-
if (id && type) {
|
|
212
|
-
weaverse.itemInstances.set(id, this);
|
|
213
|
-
this.data = { ...itemData };
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
get _id() {
|
|
217
|
-
return this._data.id;
|
|
218
|
-
}
|
|
219
|
-
get _element() {
|
|
220
|
-
return this.ref.current;
|
|
221
|
-
}
|
|
222
|
-
get Element() {
|
|
223
|
-
return this.weaverse.elementInstances.get(this._data.type);
|
|
224
|
-
}
|
|
225
|
-
set data(data) {
|
|
226
|
-
this._data = { ...this.data, ...data };
|
|
227
|
-
}
|
|
228
|
-
get data() {
|
|
229
|
-
let css = this.Element?.defaultCss;
|
|
230
|
-
let defaultData = { ...this.Element?.Component?.defaultProps, ...css && { css } };
|
|
231
|
-
return { ...defaultData, ...this._data };
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
var Weaverse = class {
|
|
235
|
-
constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode } = {}) {
|
|
236
|
-
this.elementInstances = /* @__PURE__ */ new Map();
|
|
237
|
-
this.itemInstances = /* @__PURE__ */ new Map();
|
|
238
|
-
this.appUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://studio.weaverse.io";
|
|
239
|
-
this.projectKey = "";
|
|
240
|
-
this.projectData = {
|
|
241
|
-
rootId: "",
|
|
242
|
-
items: [],
|
|
243
|
-
script: { css: "", js: "" }
|
|
244
|
-
};
|
|
245
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
246
|
-
this.isDesignMode = false;
|
|
247
|
-
this.ssrMode = false;
|
|
248
|
-
this.mediaBreakPoints = {
|
|
249
|
-
desktop: "all",
|
|
250
|
-
mobile: "(max-width: 767.98px)"
|
|
251
|
-
};
|
|
252
|
-
this.initialized = false;
|
|
253
|
-
this.initializeData = (data) => {
|
|
254
|
-
if (!this.initialized) {
|
|
255
|
-
let { data: pageData, published, id, projectKey, studioUrl } = data;
|
|
256
|
-
this.projectKey = projectKey || this.projectKey;
|
|
257
|
-
this.appUrl = studioUrl || this.appUrl;
|
|
258
|
-
this.projectData = { ...pageData, pageId: id };
|
|
259
|
-
this.isDesignMode = !published;
|
|
260
|
-
this.initProjectItemData();
|
|
261
|
-
if (this.isDesignMode) {
|
|
262
|
-
this.triggerUpdate();
|
|
263
|
-
this.loadStudio();
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
this.initialized = true;
|
|
267
|
-
};
|
|
268
|
-
this.initStitches = () => {
|
|
269
|
-
this.stitchesInstance = this.stitchesInstance || stitches.createStitches({
|
|
270
|
-
prefix: "weaverse",
|
|
271
|
-
media: this.mediaBreakPoints,
|
|
272
|
-
utils: stichesUtils
|
|
273
|
-
});
|
|
274
|
-
createGlobalStyles(this.stitchesInstance);
|
|
275
|
-
};
|
|
276
|
-
this.init({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode });
|
|
277
|
-
}
|
|
278
|
-
init({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode } = {}) {
|
|
279
|
-
this.appUrl = appUrl || this.appUrl;
|
|
280
|
-
this.projectKey = projectKey || this.projectKey;
|
|
281
|
-
this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
|
|
282
|
-
this.isDesignMode = isDesignMode || this.isDesignMode;
|
|
283
|
-
this.ssrMode = ssrMode || this.ssrMode;
|
|
284
|
-
this.projectData = projectData || this.projectData;
|
|
285
|
-
this.initStitches();
|
|
286
|
-
this.initProjectItemData();
|
|
287
|
-
}
|
|
288
|
-
loadStudio() {
|
|
289
|
-
setTimeout(() => {
|
|
290
|
-
if (isIframe && this.isDesignMode && !this.studioBridge) {
|
|
291
|
-
const initStudio = () => {
|
|
292
|
-
this.studioBridge = new window.WeaverseStudioBridge(this);
|
|
293
|
-
this.triggerUpdate();
|
|
294
|
-
};
|
|
295
|
-
if (!window.WeaverseStudioBridge) {
|
|
296
|
-
const studioBridgeScript = document.createElement("script");
|
|
297
|
-
studioBridgeScript.src = `${this.appUrl}/assets/studio/studio-bridge.js`;
|
|
298
|
-
studioBridgeScript.type = "module";
|
|
299
|
-
studioBridgeScript.onload = initStudio;
|
|
300
|
-
document.body.appendChild(studioBridgeScript);
|
|
301
|
-
} else {
|
|
302
|
-
initStudio();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}, 2e3);
|
|
306
|
-
}
|
|
307
|
-
registerElement(element) {
|
|
308
|
-
if (element?.type) {
|
|
309
|
-
if (this.elementInstances.has(element.type)) {
|
|
310
|
-
throw new Error(`Weaverse: Element '${element.type}' already registered`);
|
|
311
|
-
}
|
|
312
|
-
this.elementInstances.set(element?.type, element);
|
|
313
|
-
} else {
|
|
314
|
-
throw new Error("Weaverse: registerElement: `type` is required");
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
subscribe(fn) {
|
|
318
|
-
this.listeners.add(fn);
|
|
319
|
-
}
|
|
320
|
-
unsubscribe(fn) {
|
|
321
|
-
this.listeners.delete(fn);
|
|
322
|
-
}
|
|
323
|
-
triggerUpdate() {
|
|
324
|
-
this.listeners.forEach((fn) => fn());
|
|
325
|
-
}
|
|
326
|
-
static fetchProjectData({
|
|
327
|
-
fetch = globalThis.fetch,
|
|
328
|
-
appUrl,
|
|
329
|
-
projectKey
|
|
330
|
-
}) {
|
|
331
|
-
return fetch(appUrl + `/api/public/project/${projectKey}`).then((r) => r.json()).catch(console.error);
|
|
332
|
-
}
|
|
333
|
-
setProjectData(projectData) {
|
|
334
|
-
this.projectData = projectData;
|
|
335
|
-
this.initProjectItemData();
|
|
336
|
-
this.triggerUpdate();
|
|
337
|
-
}
|
|
338
|
-
initProjectItemData() {
|
|
339
|
-
const data = this.projectData;
|
|
340
|
-
if (data?.items) {
|
|
341
|
-
data.items.forEach((item) => {
|
|
342
|
-
if (!this.itemInstances.get(item.id)) {
|
|
343
|
-
new WeaverseItemStore(item, this);
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
Weaverse.WeaverseItemStore = WeaverseItemStore;
|
|
350
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
351
|
-
0 && (module.exports = {
|
|
352
|
-
Weaverse,
|
|
353
|
-
WeaverseItemStore,
|
|
354
|
-
createGlobalStyles,
|
|
355
|
-
isBrowser,
|
|
356
|
-
isIframe,
|
|
357
|
-
isReactNative,
|
|
358
|
-
loadScript,
|
|
359
|
-
stichesUtils
|
|
360
|
-
});
|
|
1
|
+
"use strict";var y=Object.create;var p=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var i in t)p(e,i,{get:t[i],enumerable:!0})},m=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of w(t))!D.call(e,s)&&s!==i&&p(e,s,{get:()=>t[s],enumerable:!(n=b(t,s))||n.enumerable});return e};var S=(e,t,i)=>(i=e!=null?y(x(e)):{},m(t||!e||!e.__esModule?p(i,"default",{value:e,enumerable:!0}):i,e)),E=e=>m(p({},"__esModule",{value:!0}),e);var v={};j(v,{Weaverse:()=>c,WeaverseItemStore:()=>o,createGlobalStyles:()=>l,isBrowser:()=>u,isIframe:()=>h,isReactNative:()=>g,loadScript:()=>I,stichesUtils:()=>d});module.exports=E(v);var f=S(require("@stitches/core"));function I(e){return new Promise(function(t){let i=document.createElement("script");i.src=e,i.addEventListener("load",function(){t(!0)}),document.head.appendChild(i)})}var d={m:e=>({margin:e}),mt:e=>({marginTop:e}),mr:e=>({marginRight:e}),mb:e=>({marginBottom:e}),ml:e=>({marginLeft:e}),mx:e=>({marginLeft:e,marginRight:e}),my:e=>({marginTop:e,marginBottom:e}),size:e=>({width:e,height:e}),px:e=>({paddingLeft:e,paddingRight:e}),py:e=>({paddingTop:e,paddingBottom:e})};function l(e){e.globalCss({"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}},"@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}},".wv-spinner-wrapper":{position:"absolute",inset:"0px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"inherit",".wv-spinner":{width:"20px",height:"20px",animation:"spin .75s linear infinite"}},"[data-wv-placeholder]":{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(236, 236, 236, 0.5)",backgroundClip:"content-box",padding:"10px"},body:{"&.wv-modal-open":{".weaverse-content-root":{zIndex:9999}}},".weaverse-content-root":{position:"relative",zIndex:0,"*":{WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"auto",textRendering:"optimizeLegibility",boxSizing:"border-box"},input:{"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button":{"-webkit-appearance":"none",margin:0},"&[type=number]":{"-moz-appearance":"textfield"}},select:{WebkitAppearance:"none",MozAppearance:"none",appearance:"none",outline:"none",boxShadow:"none",color:"currentColor",verticalAlign:"middle",backgroundColor:"transparent",backgroundPosition:"center",backgroundRepeat:"no-repeat",backgroundImage:"url(https://ucarecdn.com/4bb6a6e7-1ce8-4201-8f2d-da00a50105f3/)",backgroundSize:"10px",backgroundPositionX:"calc(100% - 12px)",paddingLeft:"12px",paddingRight:"35px !important",cursor:"pointer"},button:{outline:"none",boxShadow:"none",cursor:"pointer",border:"none","&:focus":{outline:"none",boxShadow:"none"}},".animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}})()}var g=typeof navigator=="object"&&navigator.product==="ReactNative",u=typeof window<"u"&&!g,h=u&&window.top!==window.self;var o=class{constructor(t,i){this.listeners=new Set;this.ref={current:null};this.stitchesClass="";this._data={id:"",type:""};this._flags={};this.setData=t=>(this.data=Object.assign(this.data,t),this.triggerUpdate(),this.data);this.subscribe=t=>{this.listeners.add(t)};this.unsubscribe=t=>{this.listeners.delete(t)};this.triggerUpdate=()=>{this.listeners.forEach(t=>t(this.data))};let{type:n,id:s}=t;this.weaverse=i,s&&n&&(i.itemInstances.set(s,this),this.data={...t})}get _id(){return this._data.id}get _element(){return this.ref.current}get Element(){return this.weaverse.elementInstances.get(this._data.type)}set data(t){this._data={...this.data,...t}}get data(){let t=this.Element?.defaultCss;return{...{...this.Element?.Component?.defaultProps,...t&&{css:t}},...this._data}}},c=class{constructor({appUrl:t,projectKey:i,projectData:n,mediaBreakPoints:s,isDesignMode:r,ssrMode:a}={}){this.elementInstances=new Map;this.itemInstances=new Map;this.appUrl=process.env.NODE_ENV==="development"?"http://localhost:3000":"https://studio.weaverse.io";this.projectKey="";this.projectData={rootId:"",items:[],script:{css:"",js:""}};this.listeners=new Set;this.isDesignMode=!1;this.ssrMode=!1;this.mediaBreakPoints={desktop:"all",mobile:"(max-width: 767.98px)"};this.initialized=!1;this.initializeData=t=>{if(!this.initialized){let{data:i,published:n,id:s,projectKey:r,studioUrl:a}=t;this.projectKey=r||this.projectKey,this.appUrl=a||this.appUrl,this.projectData={...i,pageId:s},this.isDesignMode=!n,this.initProjectItemData(),this.isDesignMode&&(this.triggerUpdate(),this.loadStudio())}this.initialized=!0};this.initStitches=()=>{this.stitchesInstance=this.stitchesInstance||f.createStitches({prefix:"weaverse",media:this.mediaBreakPoints,utils:d}),l(this.stitchesInstance)};this.init({appUrl:t,projectKey:i,projectData:n,mediaBreakPoints:s,isDesignMode:r,ssrMode:a})}init({appUrl:t,projectKey:i,projectData:n,mediaBreakPoints:s,isDesignMode:r,ssrMode:a}={}){this.appUrl=t||this.appUrl,this.projectKey=i||this.projectKey,this.mediaBreakPoints=s||this.mediaBreakPoints,this.isDesignMode=r||this.isDesignMode,this.ssrMode=a||this.ssrMode,this.projectData=n||this.projectData,this.initStitches(),this.initProjectItemData()}loadStudio(){setTimeout(()=>{if(h&&this.isDesignMode&&!this.studioBridge){let t=()=>{this.studioBridge=new window.WeaverseStudioBridge(this),this.triggerUpdate()};if(window.WeaverseStudioBridge)t();else{let i=document.createElement("script");i.src=`${this.appUrl}/assets/studio/studio-bridge.js`,i.type="module",i.onload=t,document.body.appendChild(i)}}},2e3)}registerElement(t){if(t?.type){if(this.elementInstances.has(t.type))throw new Error(`Weaverse: Element '${t.type}' already registered`);this.elementInstances.set(t?.type,t)}else throw new Error("Weaverse: registerElement: `type` is required")}subscribe(t){this.listeners.add(t)}unsubscribe(t){this.listeners.delete(t)}triggerUpdate(){this.listeners.forEach(t=>t())}static fetchProjectData({fetch:t=globalThis.fetch,appUrl:i,projectKey:n}){return t(i+`/api/public/project/${n}`).then(s=>s.json()).catch(console.error)}setProjectData(t){this.projectData=t,this.initProjectItemData(),this.triggerUpdate()}initProjectItemData(){let t=this.projectData;t?.items&&t.items.forEach(i=>{this.itemInstances.get(i.id)||new o(i,this)})}};c.WeaverseItemStore=o;0&&(module.exports={Weaverse,WeaverseItemStore,createGlobalStyles,isBrowser,isIframe,isReactNative,loadScript,stichesUtils});
|
package/dist/index.mjs
CHANGED
|
@@ -1,320 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as stitches from "@stitches/core";
|
|
3
|
-
|
|
4
|
-
// src/utils/load-script.ts
|
|
5
|
-
function loadScript(url) {
|
|
6
|
-
return new Promise(function(resolve) {
|
|
7
|
-
const script = document.createElement("script");
|
|
8
|
-
script.src = url;
|
|
9
|
-
script.addEventListener("load", function() {
|
|
10
|
-
resolve(true);
|
|
11
|
-
});
|
|
12
|
-
document.head.appendChild(script);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// src/utils/styles.ts
|
|
17
|
-
var stichesUtils = {
|
|
18
|
-
m: (value) => ({
|
|
19
|
-
margin: value
|
|
20
|
-
}),
|
|
21
|
-
mt: (value) => ({
|
|
22
|
-
marginTop: value
|
|
23
|
-
}),
|
|
24
|
-
mr: (value) => ({
|
|
25
|
-
marginRight: value
|
|
26
|
-
}),
|
|
27
|
-
mb: (value) => ({
|
|
28
|
-
marginBottom: value
|
|
29
|
-
}),
|
|
30
|
-
ml: (value) => ({
|
|
31
|
-
marginLeft: value
|
|
32
|
-
}),
|
|
33
|
-
mx: (value) => ({
|
|
34
|
-
marginLeft: value,
|
|
35
|
-
marginRight: value
|
|
36
|
-
}),
|
|
37
|
-
my: (value) => ({
|
|
38
|
-
marginTop: value,
|
|
39
|
-
marginBottom: value
|
|
40
|
-
}),
|
|
41
|
-
size: (value) => ({
|
|
42
|
-
width: value,
|
|
43
|
-
height: value
|
|
44
|
-
}),
|
|
45
|
-
px: (value) => ({
|
|
46
|
-
paddingLeft: value,
|
|
47
|
-
paddingRight: value
|
|
48
|
-
}),
|
|
49
|
-
py: (value) => ({
|
|
50
|
-
paddingTop: value,
|
|
51
|
-
paddingBottom: value
|
|
52
|
-
})
|
|
53
|
-
};
|
|
54
|
-
function createGlobalStyles(stitches2) {
|
|
55
|
-
let globalStyles = stitches2.globalCss({
|
|
56
|
-
"@keyframes spin": {
|
|
57
|
-
from: { transform: "rotate(0deg)" },
|
|
58
|
-
to: { transform: "rotate(360deg)" }
|
|
59
|
-
},
|
|
60
|
-
"@keyframes pulse": {
|
|
61
|
-
"0%, 100%": { opacity: 1 },
|
|
62
|
-
"50%": { opacity: 0.5 }
|
|
63
|
-
},
|
|
64
|
-
".weaverse-content-root": {
|
|
65
|
-
"*": {
|
|
66
|
-
WebkitFontSmoothing: "antialiased",
|
|
67
|
-
MozOsxFontSmoothing: "auto",
|
|
68
|
-
textRendering: "optimizeLegibility",
|
|
69
|
-
boxSizing: "border-box"
|
|
70
|
-
},
|
|
71
|
-
input: {
|
|
72
|
-
"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button": {
|
|
73
|
-
"-webkit-appearance": "none",
|
|
74
|
-
margin: 0
|
|
75
|
-
},
|
|
76
|
-
"&[type=number]": {
|
|
77
|
-
"-moz-appearance": "textfield"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
select: {
|
|
81
|
-
WebkitAppearance: "none",
|
|
82
|
-
MozAppearance: "none",
|
|
83
|
-
appearance: "none",
|
|
84
|
-
outline: "none",
|
|
85
|
-
boxShadow: "none",
|
|
86
|
-
color: "currentColor",
|
|
87
|
-
verticalAlign: "middle",
|
|
88
|
-
backgroundColor: "transparent",
|
|
89
|
-
backgroundPosition: "center",
|
|
90
|
-
backgroundRepeat: "no-repeat",
|
|
91
|
-
backgroundImage: "url(https://ucarecdn.com/4bb6a6e7-1ce8-4201-8f2d-da00a50105f3/)",
|
|
92
|
-
backgroundSize: "10px",
|
|
93
|
-
backgroundPositionX: "calc(100% - 12px)",
|
|
94
|
-
paddingLeft: "12px",
|
|
95
|
-
paddingRight: "35px !important",
|
|
96
|
-
cursor: "pointer"
|
|
97
|
-
},
|
|
98
|
-
button: {
|
|
99
|
-
outline: "none",
|
|
100
|
-
boxShadow: "none",
|
|
101
|
-
cursor: "pointer",
|
|
102
|
-
border: "none",
|
|
103
|
-
"&:focus": {
|
|
104
|
-
outline: "none",
|
|
105
|
-
boxShadow: "none"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
".animate-pulse": {
|
|
109
|
-
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
".wv-spinner-wrapper": {
|
|
113
|
-
position: "absolute",
|
|
114
|
-
inset: "0px",
|
|
115
|
-
display: "flex",
|
|
116
|
-
alignItems: "center",
|
|
117
|
-
justifyContent: "center",
|
|
118
|
-
backgroundColor: "inherit",
|
|
119
|
-
".wv-spinner": {
|
|
120
|
-
width: "20px",
|
|
121
|
-
height: "20px",
|
|
122
|
-
animation: "spin .75s linear infinite"
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
"[data-wv-placeholder]": {
|
|
126
|
-
height: "100%",
|
|
127
|
-
display: "flex",
|
|
128
|
-
flexDirection: "column",
|
|
129
|
-
alignItems: "center",
|
|
130
|
-
justifyContent: "center",
|
|
131
|
-
backgroundColor: "rgba(236, 236, 236, 0.5)",
|
|
132
|
-
backgroundClip: "content-box",
|
|
133
|
-
padding: "10px"
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
globalStyles();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/utils/index.ts
|
|
140
|
-
var isReactNative = typeof navigator === "object" && navigator.product === "ReactNative";
|
|
141
|
-
var isBrowser = typeof window !== "undefined" && !isReactNative;
|
|
142
|
-
var isIframe = isBrowser && window.top !== window.self;
|
|
143
|
-
|
|
144
|
-
// src/core.ts
|
|
145
|
-
var WeaverseItemStore = class {
|
|
146
|
-
constructor(itemData, weaverse) {
|
|
147
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
148
|
-
this.ref = {
|
|
149
|
-
current: null
|
|
150
|
-
};
|
|
151
|
-
this.stitchesClass = "";
|
|
152
|
-
this._data = { id: "", type: "" };
|
|
153
|
-
this._flags = {};
|
|
154
|
-
this.setData = (data) => {
|
|
155
|
-
this.data = Object.assign(this.data, data);
|
|
156
|
-
this.triggerUpdate();
|
|
157
|
-
return this.data;
|
|
158
|
-
};
|
|
159
|
-
this.subscribe = (fn) => {
|
|
160
|
-
this.listeners.add(fn);
|
|
161
|
-
};
|
|
162
|
-
this.unsubscribe = (fn) => {
|
|
163
|
-
this.listeners.delete(fn);
|
|
164
|
-
};
|
|
165
|
-
this.triggerUpdate = () => {
|
|
166
|
-
this.listeners.forEach((fn) => {
|
|
167
|
-
return fn(this.data);
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
let { type, id } = itemData;
|
|
171
|
-
this.weaverse = weaverse;
|
|
172
|
-
if (id && type) {
|
|
173
|
-
weaverse.itemInstances.set(id, this);
|
|
174
|
-
this.data = { ...itemData };
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
get _id() {
|
|
178
|
-
return this._data.id;
|
|
179
|
-
}
|
|
180
|
-
get _element() {
|
|
181
|
-
return this.ref.current;
|
|
182
|
-
}
|
|
183
|
-
get Element() {
|
|
184
|
-
return this.weaverse.elementInstances.get(this._data.type);
|
|
185
|
-
}
|
|
186
|
-
set data(data) {
|
|
187
|
-
this._data = { ...this.data, ...data };
|
|
188
|
-
}
|
|
189
|
-
get data() {
|
|
190
|
-
let css = this.Element?.defaultCss;
|
|
191
|
-
let defaultData = { ...this.Element?.Component?.defaultProps, ...css && { css } };
|
|
192
|
-
return { ...defaultData, ...this._data };
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
var Weaverse = class {
|
|
196
|
-
constructor({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode } = {}) {
|
|
197
|
-
this.elementInstances = /* @__PURE__ */ new Map();
|
|
198
|
-
this.itemInstances = /* @__PURE__ */ new Map();
|
|
199
|
-
this.appUrl = process.env.NODE_ENV === "development" ? "http://localhost:3000" : "https://studio.weaverse.io";
|
|
200
|
-
this.projectKey = "";
|
|
201
|
-
this.projectData = {
|
|
202
|
-
rootId: "",
|
|
203
|
-
items: [],
|
|
204
|
-
script: { css: "", js: "" }
|
|
205
|
-
};
|
|
206
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
207
|
-
this.isDesignMode = false;
|
|
208
|
-
this.ssrMode = false;
|
|
209
|
-
this.mediaBreakPoints = {
|
|
210
|
-
desktop: "all",
|
|
211
|
-
mobile: "(max-width: 767.98px)"
|
|
212
|
-
};
|
|
213
|
-
this.initialized = false;
|
|
214
|
-
this.initializeData = (data) => {
|
|
215
|
-
if (!this.initialized) {
|
|
216
|
-
let { data: pageData, published, id, projectKey, studioUrl } = data;
|
|
217
|
-
this.projectKey = projectKey || this.projectKey;
|
|
218
|
-
this.appUrl = studioUrl || this.appUrl;
|
|
219
|
-
this.projectData = { ...pageData, pageId: id };
|
|
220
|
-
this.isDesignMode = !published;
|
|
221
|
-
this.initProjectItemData();
|
|
222
|
-
if (this.isDesignMode) {
|
|
223
|
-
this.triggerUpdate();
|
|
224
|
-
this.loadStudio();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
this.initialized = true;
|
|
228
|
-
};
|
|
229
|
-
this.initStitches = () => {
|
|
230
|
-
this.stitchesInstance = this.stitchesInstance || stitches.createStitches({
|
|
231
|
-
prefix: "weaverse",
|
|
232
|
-
media: this.mediaBreakPoints,
|
|
233
|
-
utils: stichesUtils
|
|
234
|
-
});
|
|
235
|
-
createGlobalStyles(this.stitchesInstance);
|
|
236
|
-
};
|
|
237
|
-
this.init({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode });
|
|
238
|
-
}
|
|
239
|
-
init({ appUrl, projectKey, projectData, mediaBreakPoints, isDesignMode, ssrMode } = {}) {
|
|
240
|
-
this.appUrl = appUrl || this.appUrl;
|
|
241
|
-
this.projectKey = projectKey || this.projectKey;
|
|
242
|
-
this.mediaBreakPoints = mediaBreakPoints || this.mediaBreakPoints;
|
|
243
|
-
this.isDesignMode = isDesignMode || this.isDesignMode;
|
|
244
|
-
this.ssrMode = ssrMode || this.ssrMode;
|
|
245
|
-
this.projectData = projectData || this.projectData;
|
|
246
|
-
this.initStitches();
|
|
247
|
-
this.initProjectItemData();
|
|
248
|
-
}
|
|
249
|
-
loadStudio() {
|
|
250
|
-
setTimeout(() => {
|
|
251
|
-
if (isIframe && this.isDesignMode && !this.studioBridge) {
|
|
252
|
-
const initStudio = () => {
|
|
253
|
-
this.studioBridge = new window.WeaverseStudioBridge(this);
|
|
254
|
-
this.triggerUpdate();
|
|
255
|
-
};
|
|
256
|
-
if (!window.WeaverseStudioBridge) {
|
|
257
|
-
const studioBridgeScript = document.createElement("script");
|
|
258
|
-
studioBridgeScript.src = `${this.appUrl}/assets/studio/studio-bridge.js`;
|
|
259
|
-
studioBridgeScript.type = "module";
|
|
260
|
-
studioBridgeScript.onload = initStudio;
|
|
261
|
-
document.body.appendChild(studioBridgeScript);
|
|
262
|
-
} else {
|
|
263
|
-
initStudio();
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}, 2e3);
|
|
267
|
-
}
|
|
268
|
-
registerElement(element) {
|
|
269
|
-
if (element?.type) {
|
|
270
|
-
if (this.elementInstances.has(element.type)) {
|
|
271
|
-
throw new Error(`Weaverse: Element '${element.type}' already registered`);
|
|
272
|
-
}
|
|
273
|
-
this.elementInstances.set(element?.type, element);
|
|
274
|
-
} else {
|
|
275
|
-
throw new Error("Weaverse: registerElement: `type` is required");
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
subscribe(fn) {
|
|
279
|
-
this.listeners.add(fn);
|
|
280
|
-
}
|
|
281
|
-
unsubscribe(fn) {
|
|
282
|
-
this.listeners.delete(fn);
|
|
283
|
-
}
|
|
284
|
-
triggerUpdate() {
|
|
285
|
-
this.listeners.forEach((fn) => fn());
|
|
286
|
-
}
|
|
287
|
-
static fetchProjectData({
|
|
288
|
-
fetch = globalThis.fetch,
|
|
289
|
-
appUrl,
|
|
290
|
-
projectKey
|
|
291
|
-
}) {
|
|
292
|
-
return fetch(appUrl + `/api/public/project/${projectKey}`).then((r) => r.json()).catch(console.error);
|
|
293
|
-
}
|
|
294
|
-
setProjectData(projectData) {
|
|
295
|
-
this.projectData = projectData;
|
|
296
|
-
this.initProjectItemData();
|
|
297
|
-
this.triggerUpdate();
|
|
298
|
-
}
|
|
299
|
-
initProjectItemData() {
|
|
300
|
-
const data = this.projectData;
|
|
301
|
-
if (data?.items) {
|
|
302
|
-
data.items.forEach((item) => {
|
|
303
|
-
if (!this.itemInstances.get(item.id)) {
|
|
304
|
-
new WeaverseItemStore(item, this);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
Weaverse.WeaverseItemStore = WeaverseItemStore;
|
|
311
|
-
export {
|
|
312
|
-
Weaverse,
|
|
313
|
-
WeaverseItemStore,
|
|
314
|
-
createGlobalStyles,
|
|
315
|
-
isBrowser,
|
|
316
|
-
isIframe,
|
|
317
|
-
isReactNative,
|
|
318
|
-
loadScript,
|
|
319
|
-
stichesUtils
|
|
320
|
-
};
|
|
1
|
+
import*as h from"@stitches/core";function u(e){return new Promise(function(t){let i=document.createElement("script");i.src=e,i.addEventListener("load",function(){t(!0)}),document.head.appendChild(i)})}var c={m:e=>({margin:e}),mt:e=>({marginTop:e}),mr:e=>({marginRight:e}),mb:e=>({marginBottom:e}),ml:e=>({marginLeft:e}),mx:e=>({marginLeft:e,marginRight:e}),my:e=>({marginTop:e,marginBottom:e}),size:e=>({width:e,height:e}),px:e=>({paddingLeft:e,paddingRight:e}),py:e=>({paddingTop:e,paddingBottom:e})};function d(e){e.globalCss({"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}},"@keyframes pulse":{"0%, 100%":{opacity:1},"50%":{opacity:.5}},".wv-spinner-wrapper":{position:"absolute",inset:"0px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"inherit",".wv-spinner":{width:"20px",height:"20px",animation:"spin .75s linear infinite"}},"[data-wv-placeholder]":{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(236, 236, 236, 0.5)",backgroundClip:"content-box",padding:"10px"},body:{"&.wv-modal-open":{".weaverse-content-root":{zIndex:9999}}},".weaverse-content-root":{position:"relative",zIndex:0,"*":{WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"auto",textRendering:"optimizeLegibility",boxSizing:"border-box"},input:{"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button":{"-webkit-appearance":"none",margin:0},"&[type=number]":{"-moz-appearance":"textfield"}},select:{WebkitAppearance:"none",MozAppearance:"none",appearance:"none",outline:"none",boxShadow:"none",color:"currentColor",verticalAlign:"middle",backgroundColor:"transparent",backgroundPosition:"center",backgroundRepeat:"no-repeat",backgroundImage:"url(https://ucarecdn.com/4bb6a6e7-1ce8-4201-8f2d-da00a50105f3/)",backgroundSize:"10px",backgroundPositionX:"calc(100% - 12px)",paddingLeft:"12px",paddingRight:"35px !important",cursor:"pointer"},button:{outline:"none",boxShadow:"none",cursor:"pointer",border:"none","&:focus":{outline:"none",boxShadow:"none"}},".animate-pulse":{animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}})()}var m=typeof navigator=="object"&&navigator.product==="ReactNative",g=typeof window<"u"&&!m,l=g&&window.top!==window.self;var o=class{constructor(t,i){this.listeners=new Set;this.ref={current:null};this.stitchesClass="";this._data={id:"",type:""};this._flags={};this.setData=t=>(this.data=Object.assign(this.data,t),this.triggerUpdate(),this.data);this.subscribe=t=>{this.listeners.add(t)};this.unsubscribe=t=>{this.listeners.delete(t)};this.triggerUpdate=()=>{this.listeners.forEach(t=>t(this.data))};let{type:n,id:s}=t;this.weaverse=i,s&&n&&(i.itemInstances.set(s,this),this.data={...t})}get _id(){return this._data.id}get _element(){return this.ref.current}get Element(){return this.weaverse.elementInstances.get(this._data.type)}set data(t){this._data={...this.data,...t}}get data(){let t=this.Element?.defaultCss;return{...{...this.Element?.Component?.defaultProps,...t&&{css:t}},...this._data}}},p=class{constructor({appUrl:t,projectKey:i,projectData:n,mediaBreakPoints:s,isDesignMode:r,ssrMode:a}={}){this.elementInstances=new Map;this.itemInstances=new Map;this.appUrl=process.env.NODE_ENV==="development"?"http://localhost:3000":"https://studio.weaverse.io";this.projectKey="";this.projectData={rootId:"",items:[],script:{css:"",js:""}};this.listeners=new Set;this.isDesignMode=!1;this.ssrMode=!1;this.mediaBreakPoints={desktop:"all",mobile:"(max-width: 767.98px)"};this.initialized=!1;this.initializeData=t=>{if(!this.initialized){let{data:i,published:n,id:s,projectKey:r,studioUrl:a}=t;this.projectKey=r||this.projectKey,this.appUrl=a||this.appUrl,this.projectData={...i,pageId:s},this.isDesignMode=!n,this.initProjectItemData(),this.isDesignMode&&(this.triggerUpdate(),this.loadStudio())}this.initialized=!0};this.initStitches=()=>{this.stitchesInstance=this.stitchesInstance||h.createStitches({prefix:"weaverse",media:this.mediaBreakPoints,utils:c}),d(this.stitchesInstance)};this.init({appUrl:t,projectKey:i,projectData:n,mediaBreakPoints:s,isDesignMode:r,ssrMode:a})}init({appUrl:t,projectKey:i,projectData:n,mediaBreakPoints:s,isDesignMode:r,ssrMode:a}={}){this.appUrl=t||this.appUrl,this.projectKey=i||this.projectKey,this.mediaBreakPoints=s||this.mediaBreakPoints,this.isDesignMode=r||this.isDesignMode,this.ssrMode=a||this.ssrMode,this.projectData=n||this.projectData,this.initStitches(),this.initProjectItemData()}loadStudio(){setTimeout(()=>{if(l&&this.isDesignMode&&!this.studioBridge){let t=()=>{this.studioBridge=new window.WeaverseStudioBridge(this),this.triggerUpdate()};if(window.WeaverseStudioBridge)t();else{let i=document.createElement("script");i.src=`${this.appUrl}/assets/studio/studio-bridge.js`,i.type="module",i.onload=t,document.body.appendChild(i)}}},2e3)}registerElement(t){if(t?.type){if(this.elementInstances.has(t.type))throw new Error(`Weaverse: Element '${t.type}' already registered`);this.elementInstances.set(t?.type,t)}else throw new Error("Weaverse: registerElement: `type` is required")}subscribe(t){this.listeners.add(t)}unsubscribe(t){this.listeners.delete(t)}triggerUpdate(){this.listeners.forEach(t=>t())}static fetchProjectData({fetch:t=globalThis.fetch,appUrl:i,projectKey:n}){return t(i+`/api/public/project/${n}`).then(s=>s.json()).catch(console.error)}setProjectData(t){this.projectData=t,this.initProjectItemData(),this.triggerUpdate()}initProjectItemData(){let t=this.projectData;t?.items&&t.items.forEach(i=>{this.itemInstances.get(i.id)||new o(i,this)})}};p.WeaverseItemStore=o;export{p as Weaverse,o as WeaverseItemStore,d as createGlobalStyles,g as isBrowser,l as isIframe,m as isReactNative,u as loadScript,c as stichesUtils};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.
|
|
2
|
+
"version": "0.7.37",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"start": "npm run dev",
|
|
18
|
-
"dev": "tsup src/index.ts --format esm,cjs --dts --outDir dist --watch",
|
|
19
|
-
"build": "tsup src/index.ts --format esm,cjs --dts --outDir dist",
|
|
18
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --outDir dist --watch --sourcemap",
|
|
19
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --outDir dist --minify",
|
|
20
|
+
"clean": "rimraf dist",
|
|
20
21
|
"prepublish": "npm run build"
|
|
21
22
|
},
|
|
22
23
|
"name": "@weaverse/core",
|