@resenty/widget 0.0.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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/chunks/chat-CJ6R7eoG.js +592 -0
- package/dist/chunks/chat-CZS20945.js +54622 -0
- package/dist/chunks/core-Cpyk9a29.js +214 -0
- package/dist/chunks/index-Df7cNTmq.js +348 -0
- package/dist/chunks/query-common-D_G8O-M_.js +7754 -0
- package/dist/chunks/react-dom-B4CdVWWC.js +1176 -0
- package/dist/chunks/react-root-BBU2MuNT.js +5 -0
- package/dist/chunks/react-root-ChAKSfvh.js +18956 -0
- package/dist/chunks/rolldown-runtime-B_fQOXul.js +11 -0
- package/dist/chunks/schemas-B2StEWw-.js +4326 -0
- package/dist/chunks/ui-common-DfZ7eP4u.js +2372 -0
- package/dist/chunks/ui-f9sPMhJV.js +135 -0
- package/dist/chunks/vendor-CAJw9nfJ.js +68985 -0
- package/dist/resenty.js +676 -0
- package/dist/styles/resenty.css +2 -0
- package/package.json +94 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { i as __toESM, n as require_react, t as require_react_dom } from "./react-dom-B4CdVWWC.js";
|
|
2
|
+
import { a as QueryClientProvider, s as require_jsx_runtime, t as CoreContext } from "./core-Cpyk9a29.js";
|
|
3
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
4
|
+
const noop = (...e) => {}, createDeferredPromise = () => {
|
|
5
|
+
let e = noop, y = noop;
|
|
6
|
+
return {
|
|
7
|
+
promise: new Promise((b, x) => {
|
|
8
|
+
e = b, y = x;
|
|
9
|
+
}),
|
|
10
|
+
resolve: e,
|
|
11
|
+
reject: y
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
var componentImportPaths = { chat: () => import("./chat-CZS20945.js") };
|
|
15
|
+
const Components = { chat: (0, import_react.lazy)(() => componentImportPaths.chat().then((e) => ({ default: e.Chat }))) }, preloadComponent = async (e) => componentImportPaths[e]?.();
|
|
16
|
+
var import_react_dom$1 = /* @__PURE__ */ __toESM(require_react_dom(), 1);
|
|
17
|
+
const Portal = (e) => {
|
|
18
|
+
let { node: y, component: b, props: x } = e;
|
|
19
|
+
return import_react_dom$1.createPortal((0, import_react.createElement)(b, x), y);
|
|
20
|
+
};
|
|
21
|
+
var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom()), import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime()), ROOT_ELEMENT_ID = "resenty-components", useSafeLayoutEffect = typeof window < "u" ? import_react.useLayoutEffect : import_react.useEffect;
|
|
22
|
+
const mountComponentRenderer = (e) => {
|
|
23
|
+
let y = document.getElementById(ROOT_ELEMENT_ID);
|
|
24
|
+
y || (y = document.createElement("div"), y.id = ROOT_ELEMENT_ID, document.body.appendChild(y));
|
|
25
|
+
let b;
|
|
26
|
+
return { ensureMounted: async (S) => {
|
|
27
|
+
let { preloadHint: C } = S || {};
|
|
28
|
+
if (!b) {
|
|
29
|
+
let S = createDeferredPromise();
|
|
30
|
+
C && preloadComponent(C), b = import("./react-root-ChAKSfvh.js").then(({ createRoot: b }) => (b(y, {
|
|
31
|
+
onCaughtError(e, y) {
|
|
32
|
+
console.error(e, y);
|
|
33
|
+
},
|
|
34
|
+
onRecoverableError(e, y) {
|
|
35
|
+
console.error(e, y);
|
|
36
|
+
},
|
|
37
|
+
onUncaughtError(e, y) {
|
|
38
|
+
console.error(e, y);
|
|
39
|
+
}
|
|
40
|
+
}).render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(QueryClientProvider, {
|
|
41
|
+
client: e.queryClient,
|
|
42
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ComponentRenderer, {
|
|
43
|
+
core: e,
|
|
44
|
+
root: y,
|
|
45
|
+
onComponentsMounted: S.resolve
|
|
46
|
+
})
|
|
47
|
+
})), S.promise.then(() => componentsControls)));
|
|
48
|
+
}
|
|
49
|
+
return b.then((e) => e);
|
|
50
|
+
} };
|
|
51
|
+
};
|
|
52
|
+
function assertDOMElement(e) {
|
|
53
|
+
if (!e) throw Error("DOM element not found");
|
|
54
|
+
}
|
|
55
|
+
var portalCt = 0, componentsControls = {}, ComponentRenderer = (e) => {
|
|
56
|
+
let { core: y, onComponentsMounted: b } = e, [x, S] = import_react.useState({
|
|
57
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
58
|
+
appearance: void 0,
|
|
59
|
+
options: void 0,
|
|
60
|
+
chat: {
|
|
61
|
+
shown: !1,
|
|
62
|
+
props: void 0
|
|
63
|
+
}
|
|
64
|
+
}), { nodes: w } = x;
|
|
65
|
+
return useSafeLayoutEffect(() => {
|
|
66
|
+
componentsControls.mountComponent = (e) => {
|
|
67
|
+
let { node: y, name: b, props: x } = e;
|
|
68
|
+
assertDOMElement(y), S((e) => {
|
|
69
|
+
let S = new Map(e.nodes);
|
|
70
|
+
return S.set(y, {
|
|
71
|
+
key: `p${++portalCt}`,
|
|
72
|
+
name: b,
|
|
73
|
+
props: x
|
|
74
|
+
}), {
|
|
75
|
+
...e,
|
|
76
|
+
nodes: S
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
}, componentsControls.unmountComponent = (e) => {
|
|
80
|
+
let { node: y } = e;
|
|
81
|
+
S((e) => {
|
|
82
|
+
let b = new Map(e.nodes);
|
|
83
|
+
return b.delete(y), {
|
|
84
|
+
...e,
|
|
85
|
+
nodes: b
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}, componentsControls.updateProps = ({ node: e, props: y,...b }) => {
|
|
89
|
+
if (e && y && typeof y == "object") {
|
|
90
|
+
let b = x.nodes.get(e);
|
|
91
|
+
if (b) {
|
|
92
|
+
b.props = { ...y }, S((e) => ({ ...e }));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
S((e) => ({
|
|
97
|
+
...e,
|
|
98
|
+
...b
|
|
99
|
+
}));
|
|
100
|
+
}, b();
|
|
101
|
+
}, []), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CoreContext.Provider, {
|
|
102
|
+
value: { value: y },
|
|
103
|
+
children: [[...w].map(([e, y]) => {
|
|
104
|
+
let b = e.querySelector(".resenty-namespace");
|
|
105
|
+
b || (b = document.createElement("div"), b.classList.add("resenty-namespace"), b.id = buildName(y.name), e.appendChild(b));
|
|
106
|
+
let x = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
|
|
107
|
+
fallback: "",
|
|
108
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Portal, {
|
|
109
|
+
node: b,
|
|
110
|
+
component: Components[y.name],
|
|
111
|
+
props: y.props,
|
|
112
|
+
componentName: y.name
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
return import_react_dom.createPortal(x, e);
|
|
116
|
+
}), x.chat.shown && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, {
|
|
117
|
+
fallback: "",
|
|
118
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
119
|
+
id: buildName("chat"),
|
|
120
|
+
className: "resenty-namespace",
|
|
121
|
+
children: import_react.createElement(Components.chat, x.chat.props)
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
124
|
+
});
|
|
125
|
+
}, buildName = (e) => `resenty-${e}`, ResentyUI = class {
|
|
126
|
+
#e;
|
|
127
|
+
#t;
|
|
128
|
+
constructor(e) {
|
|
129
|
+
this.#t = e, this.#e = mountComponentRenderer(this.#t);
|
|
130
|
+
}
|
|
131
|
+
async ensureMounted(e) {
|
|
132
|
+
return this.#e.ensureMounted(e);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
export { ResentyUI };
|