@qwik.dev/react 2.0.0-beta.4 → 2.0.0-beta.41
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/lib/assets/BqrDAOEV-bundle-graph.json +1 -0
- package/lib/index.qwik.mjs +390 -251
- package/lib/q-manifest.json +51 -0
- package/lib/types/index.qwik.d.ts +1 -0
- package/lib/types/react/reactify.d.ts +55 -0
- package/lib/types/react/slot.d.ts +21 -6
- package/lib/types/react/types.d.ts +2 -0
- package/lib/vite.mjs +19 -28
- package/package.json +13 -14
- package/lib/index.qwik.cjs +0 -264
- package/lib/vite.cjs +0 -30
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,264 +1,403 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { jsx, jsxs, Fragment } from "@qwik.dev/core/jsx-runtime";
|
|
5
|
-
import { useSignal, $, isServer, useOn, useOnDocument, Slot, implicit$FirstArg, component$, useStylesScoped$, useStore, useTask$, isBrowser, noSerialize, RenderOnce, SkipRender } from "@qwik.dev/core";
|
|
1
|
+
import { RenderOnce, SkipRender, Slot, _captures, _jsxSorted, _jsxSplit, _wrapProp, componentQrl, implicit$FirstArg, inlinedQrl, isBrowser, isServer, jsx, noSerialize, useOn, useOnDocument, useSignal, useStore, useStylesScopedQrl, useTaskQrl } from "@qwik.dev/core";
|
|
2
|
+
import { Fragment } from "@qwik.dev/core/jsx-runtime";
|
|
3
|
+
import { SSRComment, SSRRaw, SSRStream, _addProjection, _getContextContainer, _getContextHostElement, _removeProjection, _setProjectionTarget, _updateProjectionProps } from "@qwik.dev/core/internal";
|
|
6
4
|
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
7
5
|
import { flushSync } from "react-dom";
|
|
8
|
-
import { SSRStream, SSRComment, SSRRaw } from "@qwik.dev/core/internal";
|
|
9
6
|
import { renderToString } from "react-dom/server";
|
|
10
|
-
import { createContext, createElement,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import { Component, createContext, createElement, createRef } from "react";
|
|
8
|
+
function _typeof(o) {
|
|
9
|
+
"@babel/helpers - typeof";
|
|
10
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
11
|
+
return typeof o;
|
|
12
|
+
} : function(o) {
|
|
13
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
14
|
+
}, _typeof(o);
|
|
17
15
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
children: createElement(SlotElement, null)
|
|
28
|
-
})
|
|
29
|
-
});
|
|
16
|
+
function toPrimitive(t, r) {
|
|
17
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
18
|
+
var e = t[Symbol.toPrimitive];
|
|
19
|
+
if (void 0 !== e) {
|
|
20
|
+
var i = e.call(t, r || "default");
|
|
21
|
+
if ("object" != _typeof(i)) return i;
|
|
22
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
23
|
+
}
|
|
24
|
+
return ("string" === r ? String : Number)(t);
|
|
30
25
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
__publicField(this, "slotC", createRef());
|
|
35
|
-
}
|
|
36
|
-
shouldComponentUpdate() {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
componentDidMount() {
|
|
40
|
-
const slotC = this.slotC.current;
|
|
41
|
-
if (slotC) {
|
|
42
|
-
const { attachedEl, el } = this.context;
|
|
43
|
-
if (el) {
|
|
44
|
-
if (!attachedEl) {
|
|
45
|
-
slotC.appendChild(el);
|
|
46
|
-
} else if (attachedEl !== slotC) {
|
|
47
|
-
throw new Error("already attached");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
render() {
|
|
53
|
-
return createElement("q-slotc", {
|
|
54
|
-
class: this.context.scopeId,
|
|
55
|
-
suppressHydrationWarning: true,
|
|
56
|
-
dangerouslySetInnerHTML: {
|
|
57
|
-
__html: "<!--SLOT-->"
|
|
58
|
-
},
|
|
59
|
-
ref: this.slotC
|
|
60
|
-
});
|
|
61
|
-
}
|
|
26
|
+
function toPropertyKey(t) {
|
|
27
|
+
var i = toPrimitive(t, "string");
|
|
28
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
62
29
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
30
|
+
function _defineProperty(e, r, t) {
|
|
31
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
32
|
+
value: t,
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
configurable: !0,
|
|
35
|
+
writable: !0
|
|
36
|
+
}) : e[r] = t, e;
|
|
37
|
+
}
|
|
38
|
+
var SlotCtx = createContext({ scopeId: "" });
|
|
39
|
+
var QwikProjectionCtx = createContext(null);
|
|
40
|
+
var SlotElement = class extends Component {
|
|
41
|
+
constructor(..._args) {
|
|
42
|
+
super(..._args);
|
|
43
|
+
_defineProperty(this, "slotC", createRef());
|
|
44
|
+
}
|
|
45
|
+
shouldComponentUpdate() {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
componentDidMount() {
|
|
49
|
+
const slotC = this.slotC.current;
|
|
50
|
+
if (slotC) {
|
|
51
|
+
const { attachedEl, el } = this.context;
|
|
52
|
+
if (el) {
|
|
53
|
+
if (!attachedEl) slotC.appendChild(el);
|
|
54
|
+
else if (attachedEl !== slotC) throw new Error("already attached");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
return createElement("q-slotc", {
|
|
60
|
+
class: this.context.scopeId,
|
|
61
|
+
suppressHydrationWarning: true,
|
|
62
|
+
dangerouslySetInnerHTML: { __html: "<!--SLOT-->" },
|
|
63
|
+
ref: this.slotC
|
|
64
|
+
});
|
|
65
|
+
}
|
|
73
66
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
_defineProperty(SlotElement, "contextType", SlotCtx);
|
|
68
|
+
function mainExactProps(slotEl, scopeId, RootCmp, props, projectionState) {
|
|
69
|
+
let tree = createElement(SlotCtx.Provider, {
|
|
70
|
+
value: {
|
|
71
|
+
el: slotEl,
|
|
72
|
+
scopeId,
|
|
73
|
+
attachedEl: void 0
|
|
74
|
+
},
|
|
75
|
+
children: createElement(RootCmp, {
|
|
76
|
+
...props,
|
|
77
|
+
children: createElement(SlotElement, null)
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
if (projectionState) tree = createElement(QwikProjectionCtx.Provider, {
|
|
81
|
+
value: projectionState,
|
|
82
|
+
children: tree
|
|
83
|
+
});
|
|
84
|
+
return tree;
|
|
85
|
+
}
|
|
86
|
+
var useWakeupSignal = (props, opts = {}) => {
|
|
87
|
+
const signal = useSignal(false);
|
|
88
|
+
const activate = /*#__PURE__*/ inlinedQrl(() => {
|
|
89
|
+
const signal = _captures[0];
|
|
90
|
+
return signal.value = true;
|
|
91
|
+
}, "useWakeupSignal_activate_bbwdFkXhIMU", [signal]);
|
|
92
|
+
const clientOnly = !!(props["client:only"] || props["qwik:only"] || opts?.clientOnly);
|
|
93
|
+
const clientVisible = props["client:visible"] || props["qwik:visible"] || opts?.eagerness === "visible";
|
|
94
|
+
const clientIdle = props["client:idle"] || props["qwik:idle"] || opts?.eagerness === "idle";
|
|
95
|
+
const clientLoad = props["client:load"] || props["qwik:load"] || clientOnly || opts?.eagerness === "load";
|
|
96
|
+
const clientHover = props["client:hover"] || props["qwik:hover"] || opts?.eagerness === "hover";
|
|
97
|
+
const clientEvent = props["client:event"] || props["qwik:event"];
|
|
98
|
+
if (isServer) {
|
|
99
|
+
if (clientVisible) useOn("qvisible", activate);
|
|
100
|
+
if (clientIdle) useOnDocument("qidle", activate);
|
|
101
|
+
if (clientLoad) useOnDocument("qinit", activate);
|
|
102
|
+
if (clientHover) useOn("mouseover", activate);
|
|
103
|
+
if (clientEvent) useOn(clientEvent, activate);
|
|
104
|
+
if (opts?.event) useOn(opts?.event, activate);
|
|
105
|
+
}
|
|
106
|
+
return [
|
|
107
|
+
signal,
|
|
108
|
+
clientOnly,
|
|
109
|
+
activate
|
|
110
|
+
];
|
|
82
111
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (clientVisible) {
|
|
94
|
-
useOn("qvisible", activate);
|
|
95
|
-
}
|
|
96
|
-
if (clientIdle) {
|
|
97
|
-
useOnDocument("qidle", activate);
|
|
98
|
-
}
|
|
99
|
-
if (clientLoad) {
|
|
100
|
-
useOnDocument("qinit", activate);
|
|
101
|
-
}
|
|
102
|
-
if (clientHover) {
|
|
103
|
-
useOn("mouseover", activate);
|
|
104
|
-
}
|
|
105
|
-
if (clientEvent) {
|
|
106
|
-
useOn(clientEvent, activate);
|
|
107
|
-
}
|
|
108
|
-
if (opts?.event) {
|
|
109
|
-
useOn(opts?.event, activate);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return [
|
|
113
|
-
signal,
|
|
114
|
-
clientOnly,
|
|
115
|
-
activate
|
|
116
|
-
];
|
|
112
|
+
var HOST_PREFIX = "host:";
|
|
113
|
+
var getReactProps = (props) => {
|
|
114
|
+
const obj = {};
|
|
115
|
+
Object.keys(props).forEach((key) => {
|
|
116
|
+
if (!key.startsWith("client:") && !key.startsWith("qwik:") && !key.startsWith(HOST_PREFIX)) {
|
|
117
|
+
const normalizedKey = key.endsWith("$") ? key.slice(0, -1) : key;
|
|
118
|
+
obj[normalizedKey] = props[key];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return obj;
|
|
117
122
|
};
|
|
118
|
-
|
|
123
|
+
function main(slotEl, scopeId, RootCmp, props, projectionState) {
|
|
124
|
+
return mainExactProps(slotEl, scopeId, RootCmp, getReactProps(props), projectionState);
|
|
125
|
+
}
|
|
126
|
+
var getHostProps = (props) => {
|
|
127
|
+
const obj = {};
|
|
128
|
+
Object.keys(props).forEach((key) => {
|
|
129
|
+
if (key.startsWith(HOST_PREFIX)) obj[key.slice(5)] = props[key];
|
|
130
|
+
});
|
|
131
|
+
return obj;
|
|
132
|
+
};
|
|
133
|
+
var _ssrProjectionRegistry = null;
|
|
134
|
+
function setSSRProjectionRegistry(registry) {
|
|
135
|
+
_ssrProjectionRegistry = registry;
|
|
136
|
+
}
|
|
137
|
+
function getSSRProjectionRegistry() {
|
|
138
|
+
return _ssrProjectionRegistry;
|
|
139
|
+
}
|
|
140
|
+
var SLOT_MARKER = "<!--SLOT-->";
|
|
141
|
+
function splitHtmlAtMarkers(html) {
|
|
142
|
+
const MARKER_RE = /<!--(?:SLOT|QWIK-PROJ:(.*?))-->/g;
|
|
143
|
+
const segments = [];
|
|
144
|
+
let lastIndex = 0;
|
|
145
|
+
let match;
|
|
146
|
+
while ((match = MARKER_RE.exec(html)) !== null) {
|
|
147
|
+
if (match.index > lastIndex) segments.push({
|
|
148
|
+
type: "html",
|
|
149
|
+
content: html.slice(lastIndex, match.index)
|
|
150
|
+
});
|
|
151
|
+
if (match[1] !== void 0) segments.push({
|
|
152
|
+
type: "proj",
|
|
153
|
+
slotName: match[1]
|
|
154
|
+
});
|
|
155
|
+
else segments.push({ type: "slot" });
|
|
156
|
+
lastIndex = match.index + match[0].length;
|
|
157
|
+
}
|
|
158
|
+
if (lastIndex < html.length) segments.push({
|
|
159
|
+
type: "html",
|
|
160
|
+
content: html.slice(lastIndex)
|
|
161
|
+
});
|
|
162
|
+
return segments;
|
|
163
|
+
}
|
|
119
164
|
async function renderFromServer(Host, reactCmp$, scopeId, props, ref, slotRef, hydrationProps) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
161
|
-
children: [
|
|
162
|
-
/* @__PURE__ */ jsxs(Host, {
|
|
163
|
-
ref,
|
|
164
|
-
children: [
|
|
165
|
-
/* @__PURE__ */ jsx(SSRComment, {
|
|
166
|
-
data: "q:container=html"
|
|
167
|
-
}),
|
|
168
|
-
/* @__PURE__ */ jsx(SSRRaw, {
|
|
169
|
-
data: html
|
|
170
|
-
}),
|
|
171
|
-
/* @__PURE__ */ jsx(SSRComment, {
|
|
172
|
-
data: "/q:container"
|
|
173
|
-
})
|
|
174
|
-
]
|
|
175
|
-
}),
|
|
176
|
-
/* @__PURE__ */ jsx("q-slot", {
|
|
177
|
-
ref: slotRef,
|
|
178
|
-
children: /* @__PURE__ */ jsx(Slot, {})
|
|
179
|
-
})
|
|
180
|
-
]
|
|
181
|
-
});
|
|
182
|
-
}
|
|
165
|
+
if (isServer) {
|
|
166
|
+
const Cmp = await reactCmp$.resolve();
|
|
167
|
+
const newProps = getReactProps(props);
|
|
168
|
+
Object.assign(hydrationProps, newProps);
|
|
169
|
+
const registry = { entries: /* @__PURE__ */ new Map() };
|
|
170
|
+
setSSRProjectionRegistry(registry);
|
|
171
|
+
const html = renderToString(mainExactProps(void 0, scopeId, Cmp, newProps));
|
|
172
|
+
setSSRProjectionRegistry(null);
|
|
173
|
+
const hasSlot = html.includes(SLOT_MARKER);
|
|
174
|
+
const hasProj = registry.entries.size > 0;
|
|
175
|
+
if (hasSlot || hasProj) {
|
|
176
|
+
const segments = splitHtmlAtMarkers(html);
|
|
177
|
+
return /*#__PURE__*/ _jsxSorted(Fragment, null, null, [/*#__PURE__*/ _jsxSplit(Host, {
|
|
178
|
+
ref,
|
|
179
|
+
...getHostProps(props)
|
|
180
|
+
}, null, /*#__PURE__*/ _jsxSorted(SSRStream, null, null, async function* () {
|
|
181
|
+
yield /*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "q:ignore" }, null, 3, "cl_0");
|
|
182
|
+
for (const segment of segments) if (segment.type === "html") yield /*#__PURE__*/ _jsxSorted(SSRRaw, { data: _wrapProp(segment, "content") }, null, null, 3, "cl_1");
|
|
183
|
+
else if (segment.type === "slot") {
|
|
184
|
+
yield /*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "q:container-island" }, null, 3, "cl_2");
|
|
185
|
+
yield /*#__PURE__*/ _jsxSorted("q-slot", { ref: slotRef }, null, /*#__PURE__*/ _jsxSorted(Slot, null, null, null, 3, "cl_3"), 1, "cl_4");
|
|
186
|
+
yield /*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "/q:container-island" }, null, 3, "cl_5");
|
|
187
|
+
} else if (segment.type === "proj") {
|
|
188
|
+
const entry = registry.entries.get(segment.slotName);
|
|
189
|
+
if (entry) {
|
|
190
|
+
yield /*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "q:container-island" }, null, 3, "cl_6");
|
|
191
|
+
const QwikComp = await entry.qrl.resolve();
|
|
192
|
+
yield jsx(QwikComp, entry.props);
|
|
193
|
+
yield /*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "/q:container-island" }, null, 3, "cl_7");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
yield /*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "/q:ignore" }, null, 3, "cl_8");
|
|
197
|
+
}, 1, "cl_9"), 0, "cl_10"), !hasSlot && /*#__PURE__*/ _jsxSorted("q-slot", { ref: slotRef }, null, /*#__PURE__*/ _jsxSorted(Slot, null, null, null, 3, "cl_11"), 1, "cl_12")], 1, "cl_13");
|
|
198
|
+
}
|
|
199
|
+
return /*#__PURE__*/ _jsxSorted(Fragment, null, null, [/*#__PURE__*/ _jsxSorted(Host, { ref }, null, [
|
|
200
|
+
/*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "q:container=html" }, null, 3, "cl_14"),
|
|
201
|
+
/*#__PURE__*/ _jsxSorted(SSRRaw, { data: html }, null, null, 3, "cl_15"),
|
|
202
|
+
/*#__PURE__*/ _jsxSorted(SSRComment, null, { data: "/q:container" }, null, 3, "cl_16")
|
|
203
|
+
], 1, "cl_17"), /*#__PURE__*/ _jsxSorted("q-slot", { ref: slotRef }, null, /*#__PURE__*/ _jsxSorted(Slot, null, null, null, 3, "cl_18"), 1, null)], 1, "cl_19");
|
|
204
|
+
}
|
|
183
205
|
}
|
|
184
206
|
function qwikifyQrl(reactCmp$, opts) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
]
|
|
257
|
-
});
|
|
258
|
-
});
|
|
207
|
+
return /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl((props) => {
|
|
208
|
+
const opts = _captures[0], reactCmp$ = _captures[1];
|
|
209
|
+
const stylesscoped$ = useStylesScopedQrl(/*#__PURE__*/ inlinedQrl(`q-slot{display:none} q-slotc,q-slotc>q-slot{display:contents}`, "qwikifyQrl_component_stylesscoped_useStylesScoped_5NfcSvFabPo"));
|
|
210
|
+
const hostRef = useSignal();
|
|
211
|
+
const slotRef = useSignal();
|
|
212
|
+
const internalState = useSignal();
|
|
213
|
+
const [signal, isClientOnly] = useWakeupSignal(props, opts);
|
|
214
|
+
const hydrationKeys = useStore({});
|
|
215
|
+
const TagName = opts?.tagName ?? "qwik-react";
|
|
216
|
+
useTaskQrl(/*#__PURE__*/ inlinedQrl(async ({ track }) => {
|
|
217
|
+
const hostRef = _captures[0], hydrationKeys = _captures[1], internalState = _captures[2], isClientOnly = _captures[3], props = _captures[4], reactCmp$ = _captures[5], signal = _captures[6], slotRef = _captures[7], stylesscoped$ = _captures[8];
|
|
218
|
+
const trackedProps = track(() => ({ ...props }));
|
|
219
|
+
track(signal);
|
|
220
|
+
if (!isBrowser) return;
|
|
221
|
+
let projectionState = null;
|
|
222
|
+
const container = _getContextContainer();
|
|
223
|
+
const hostVNode = _getContextHostElement();
|
|
224
|
+
if (container && hostVNode) projectionState = {
|
|
225
|
+
parentVNode: hostVNode,
|
|
226
|
+
container
|
|
227
|
+
};
|
|
228
|
+
if (internalState.value) {
|
|
229
|
+
if (internalState.value.root) internalState.value.root.render(main(slotRef.value, stylesscoped$.scopeId, internalState.value.cmp, trackedProps, internalState.value.projectionState));
|
|
230
|
+
} else {
|
|
231
|
+
let root = void 0;
|
|
232
|
+
const Cmp = await reactCmp$.resolve();
|
|
233
|
+
const hostElement = hostRef.value;
|
|
234
|
+
if (hostElement) {
|
|
235
|
+
if (isClientOnly) root = createRoot(hostElement);
|
|
236
|
+
else root = flushSync(() => {
|
|
237
|
+
return hydrateRoot(hostElement, mainExactProps(slotRef.value, stylesscoped$.scopeId, Cmp, hydrationKeys, projectionState));
|
|
238
|
+
});
|
|
239
|
+
if (isClientOnly || signal.value === false) root.render(main(slotRef.value, stylesscoped$.scopeId, Cmp, trackedProps, projectionState));
|
|
240
|
+
}
|
|
241
|
+
internalState.value = noSerialize({
|
|
242
|
+
cmp: Cmp,
|
|
243
|
+
root,
|
|
244
|
+
projectionState
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}, "qwikifyQrl_component_useTask_JuFeaMCL0P0", [
|
|
248
|
+
hostRef,
|
|
249
|
+
hydrationKeys,
|
|
250
|
+
internalState,
|
|
251
|
+
isClientOnly,
|
|
252
|
+
props,
|
|
253
|
+
reactCmp$,
|
|
254
|
+
signal,
|
|
255
|
+
slotRef,
|
|
256
|
+
stylesscoped$
|
|
257
|
+
]));
|
|
258
|
+
useTaskQrl(/*#__PURE__*/ inlinedQrl(({ track, cleanup }) => {
|
|
259
|
+
const internalState = _captures[0], signal = _captures[1];
|
|
260
|
+
track(signal);
|
|
261
|
+
if (isBrowser) cleanup(() => {
|
|
262
|
+
const root = internalState.value?.root;
|
|
263
|
+
if (root) queueMicrotask(() => root.unmount());
|
|
264
|
+
});
|
|
265
|
+
}, "qwikifyQrl_component_useTask_1_mwaGrLCLc2w", [internalState, signal]));
|
|
266
|
+
if (isServer && !isClientOnly) {
|
|
267
|
+
const jsx = renderFromServer(TagName, reactCmp$, stylesscoped$.scopeId, props, hostRef, slotRef, hydrationKeys);
|
|
268
|
+
return /*#__PURE__*/ _jsxSorted(RenderOnce, null, null, jsx, 1, 2);
|
|
269
|
+
}
|
|
270
|
+
return /*#__PURE__*/ _jsxSorted(Fragment, null, null, [/*#__PURE__*/ _jsxSplit(TagName, { ...getHostProps(props) }, { ref: (el) => {
|
|
271
|
+
if (isBrowser) queueMicrotask(() => {
|
|
272
|
+
const internalData = internalState.value;
|
|
273
|
+
if (internalData && !internalData.root) (internalData.root = createRoot(el)).render(main(slotRef.value, stylesscoped$.scopeId, internalData.cmp, props, internalData.projectionState));
|
|
274
|
+
});
|
|
275
|
+
else hostRef.value = el;
|
|
276
|
+
} }, SkipRender, 0, "sV_0"), /*#__PURE__*/ _jsxSorted("q-slot", { ref: slotRef }, null, /*#__PURE__*/ _jsxSorted(Slot, null, null, null, 3, "sV_1"), 1, null)], 1, "sV_2");
|
|
277
|
+
}, "qwikifyQrl_component_5bB3apdeFTY", [opts, reactCmp$]));
|
|
259
278
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
279
|
+
var qwikify$ = /*#__PURE__*/ implicit$FirstArg(qwikifyQrl);
|
|
280
|
+
var slotCounter = 0;
|
|
281
|
+
/**
|
|
282
|
+
* Creates a React component that renders a Qwik component inside a qwikify$ React tree.
|
|
283
|
+
*
|
|
284
|
+
* This is the QRL form. Use `reactify$` for the convenience form with automatic `$()` wrapping.
|
|
285
|
+
*
|
|
286
|
+
* The returned React component must be rendered inside a `qwikify$()` React tree. It creates a div
|
|
287
|
+
* that Qwik renders into, while React ignores its contents.
|
|
288
|
+
*
|
|
289
|
+
* During SSR, a marker is emitted so that server-render.tsx can render the Qwik component inline
|
|
290
|
+
* inside `q:container-island` comments. On the client, Qwik resumes the SSR content naturally
|
|
291
|
+
* (events, signals, state are all serialized). For pure CSR, `_addProjection` renders from
|
|
292
|
+
* scratch.
|
|
293
|
+
*
|
|
294
|
+
* @param qwikCompQrl - A QRL wrapping a Qwik component (created with `component$`)
|
|
295
|
+
* @returns A React component that renders the Qwik component
|
|
296
|
+
*/ function reactifyQrl(qwikCompQrl) {
|
|
297
|
+
class QwikInReact extends Component {
|
|
298
|
+
constructor(..._args) {
|
|
299
|
+
super(..._args);
|
|
300
|
+
_defineProperty(this, "slotName", `_rq:${slotCounter++}`);
|
|
301
|
+
_defineProperty(this, "vnode", null);
|
|
302
|
+
_defineProperty(this, "divRef", createRef());
|
|
303
|
+
_defineProperty(this, "mounted", false);
|
|
304
|
+
_defineProperty(this, "pendingProps", null);
|
|
305
|
+
}
|
|
306
|
+
componentDidMount() {
|
|
307
|
+
this.mounted = true;
|
|
308
|
+
const projectionState = this.context;
|
|
309
|
+
if (!projectionState) {
|
|
310
|
+
if (typeof console !== "undefined") console.warn("reactify$: component must be rendered inside a qwikify$() React tree.");
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const div = this.divRef.current;
|
|
314
|
+
if (!div) return;
|
|
315
|
+
if (div.firstElementChild) return;
|
|
316
|
+
qwikCompQrl.resolve().then((QwikComp) => {
|
|
317
|
+
if (!this.mounted) return;
|
|
318
|
+
const name = QwikComp.displayName || QwikComp.name || "QwikComponent";
|
|
319
|
+
QwikInReact.displayName = `reactify$(${name})`;
|
|
320
|
+
const { parentVNode, container } = projectionState;
|
|
321
|
+
const reactProps = getReactProps(this.pendingProps || this.props);
|
|
322
|
+
this.vnode = _addProjection(container, parentVNode, qwikCompQrl, reactProps, this.slotName);
|
|
323
|
+
div.replaceChildren();
|
|
324
|
+
_setProjectionTarget(this.vnode, div);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
componentWillUnmount() {
|
|
328
|
+
this.mounted = false;
|
|
329
|
+
if (this.vnode && this.context) {
|
|
330
|
+
_removeProjection(this.context.container, this.context.parentVNode, this.vnode, this.slotName);
|
|
331
|
+
this.vnode = null;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
shouldComponentUpdate(nextProps) {
|
|
335
|
+
if (this.vnode && this.context) {
|
|
336
|
+
const reactProps = getReactProps(nextProps);
|
|
337
|
+
_updateProjectionProps(this.context.container, this.vnode, reactProps);
|
|
338
|
+
} else this.pendingProps = nextProps;
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
render() {
|
|
342
|
+
const registry = getSSRProjectionRegistry();
|
|
343
|
+
if (registry) {
|
|
344
|
+
const reactProps = getReactProps(this.props);
|
|
345
|
+
registry.entries.set(this.slotName, {
|
|
346
|
+
qrl: qwikCompQrl,
|
|
347
|
+
props: reactProps
|
|
348
|
+
});
|
|
349
|
+
return createElement("div", {
|
|
350
|
+
"data-qwik-projection": this.slotName,
|
|
351
|
+
suppressHydrationWarning: true,
|
|
352
|
+
dangerouslySetInnerHTML: { __html: `<!--QWIK-PROJ:${this.slotName}-->` }
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
return createElement("div", {
|
|
356
|
+
ref: this.divRef,
|
|
357
|
+
suppressHydrationWarning: true,
|
|
358
|
+
dangerouslySetInnerHTML: { __html: `<!--QWIK-PROJ:${this.slotName}-->` },
|
|
359
|
+
"data-qwik-projection": this.slotName
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
_defineProperty(QwikInReact, "contextType", QwikProjectionCtx);
|
|
364
|
+
QwikInReact.displayName = `reactify$(...)`;
|
|
365
|
+
return QwikInReact;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Creates a React component that renders a Qwik component inside a qwikify$ React tree.
|
|
369
|
+
*
|
|
370
|
+
* The returned React component must be rendered inside a `qwikify$()` React tree. It creates a div
|
|
371
|
+
* that Qwik renders into, while React ignores its contents.
|
|
372
|
+
*
|
|
373
|
+
* During SSR, the Qwik component is rendered as HTML inside `q:container-island` comments. On the
|
|
374
|
+
* client, the component re-renders via the external projection API.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
*
|
|
378
|
+
* ```tsx
|
|
379
|
+
* import { component$ } from '@qwik.dev/core';
|
|
380
|
+
* import { qwikify$, reactify$ } from '@qwik.dev/react';
|
|
381
|
+
*
|
|
382
|
+
* const QwikCounter = component$(() => {
|
|
383
|
+
* const count = useSignal(0);
|
|
384
|
+
* return <button onClick$={() => count.value++}>{count.value}</button>;
|
|
385
|
+
* });
|
|
386
|
+
*
|
|
387
|
+
* const ReactCounter = reactify$(QwikCounter);
|
|
388
|
+
*
|
|
389
|
+
* const ReactApp = ({ children }) => (
|
|
390
|
+
* <div>
|
|
391
|
+
* <h1>React App</h1>
|
|
392
|
+
* <ReactCounter />
|
|
393
|
+
* {children}
|
|
394
|
+
* </div>
|
|
395
|
+
* );
|
|
396
|
+
*
|
|
397
|
+
* export const QwikifiedApp = qwikify$(ReactApp);
|
|
398
|
+
* ```
|
|
399
|
+
*
|
|
400
|
+
* @param qwikComp - A Qwik component (created with `component$`)
|
|
401
|
+
* @returns A React component that renders the Qwik component
|
|
402
|
+
*/ var reactify$ = /*#__PURE__*/ implicit$FirstArg(reactifyQrl);
|
|
403
|
+
export { qwikify$, qwikifyQrl, reactify$, reactifyQrl };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1",
|
|
3
|
+
"manifestHash": "4qq332",
|
|
4
|
+
"options": {
|
|
5
|
+
"target": "lib",
|
|
6
|
+
"buildMode": "development",
|
|
7
|
+
"entryStrategy": {
|
|
8
|
+
"type": "inline"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"bundleGraphAsset": "assets/BqrDAOEV-bundle-graph.json",
|
|
12
|
+
"injections": [],
|
|
13
|
+
"mapping": {},
|
|
14
|
+
"bundles": {
|
|
15
|
+
"../index.qwik.mjs": {
|
|
16
|
+
"size": 16446,
|
|
17
|
+
"total": 16446,
|
|
18
|
+
"origins": [
|
|
19
|
+
"src/index.qwik.ts",
|
|
20
|
+
"src/react/client.tsx",
|
|
21
|
+
"src/react/qwikify.tsx",
|
|
22
|
+
"src/react/reactify.ts",
|
|
23
|
+
"src/react/server-render.tsx",
|
|
24
|
+
"src/react/slot.ts"
|
|
25
|
+
],
|
|
26
|
+
"interactivity": 0
|
|
27
|
+
},
|
|
28
|
+
"../vite.mjs": {
|
|
29
|
+
"size": 396,
|
|
30
|
+
"total": 396,
|
|
31
|
+
"origins": [
|
|
32
|
+
"src/vite.ts"
|
|
33
|
+
],
|
|
34
|
+
"interactivity": 0
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"assets": {
|
|
38
|
+
"assets/BqrDAOEV-bundle-graph.json": {
|
|
39
|
+
"name": "bundle-graph.json",
|
|
40
|
+
"size": 0
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"symbols": {},
|
|
44
|
+
"platform": {
|
|
45
|
+
"vite": "",
|
|
46
|
+
"rollup": "4.23.0",
|
|
47
|
+
"env": "node",
|
|
48
|
+
"os": "linux",
|
|
49
|
+
"node": "24.15.0"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type QRL } from '@qwik.dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a React component that renders a Qwik component inside a qwikify$ React tree.
|
|
4
|
+
*
|
|
5
|
+
* This is the QRL form. Use `reactify$` for the convenience form with automatic `$()` wrapping.
|
|
6
|
+
*
|
|
7
|
+
* The returned React component must be rendered inside a `qwikify$()` React tree. It creates a div
|
|
8
|
+
* that Qwik renders into, while React ignores its contents.
|
|
9
|
+
*
|
|
10
|
+
* During SSR, a marker is emitted so that server-render.tsx can render the Qwik component inline
|
|
11
|
+
* inside `q:container-island` comments. On the client, Qwik resumes the SSR content naturally
|
|
12
|
+
* (events, signals, state are all serialized). For pure CSR, `_addProjection` renders from
|
|
13
|
+
* scratch.
|
|
14
|
+
*
|
|
15
|
+
* @param qwikCompQrl - A QRL wrapping a Qwik component (created with `component$`)
|
|
16
|
+
* @returns A React component that renders the Qwik component
|
|
17
|
+
*/
|
|
18
|
+
export declare function reactifyQrl(qwikCompQrl: QRL<any>): any;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a React component that renders a Qwik component inside a qwikify$ React tree.
|
|
21
|
+
*
|
|
22
|
+
* The returned React component must be rendered inside a `qwikify$()` React tree. It creates a div
|
|
23
|
+
* that Qwik renders into, while React ignores its contents.
|
|
24
|
+
*
|
|
25
|
+
* During SSR, the Qwik component is rendered as HTML inside `q:container-island` comments. On the
|
|
26
|
+
* client, the component re-renders via the external projection API.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { component$ } from '@qwik.dev/core';
|
|
32
|
+
* import { qwikify$, reactify$ } from '@qwik.dev/react';
|
|
33
|
+
*
|
|
34
|
+
* const QwikCounter = component$(() => {
|
|
35
|
+
* const count = useSignal(0);
|
|
36
|
+
* return <button onClick$={() => count.value++}>{count.value}</button>;
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const ReactCounter = reactify$(QwikCounter);
|
|
40
|
+
*
|
|
41
|
+
* const ReactApp = ({ children }) => (
|
|
42
|
+
* <div>
|
|
43
|
+
* <h1>React App</h1>
|
|
44
|
+
* <ReactCounter />
|
|
45
|
+
* {children}
|
|
46
|
+
* </div>
|
|
47
|
+
* );
|
|
48
|
+
*
|
|
49
|
+
* export const QwikifiedApp = qwikify$(ReactApp);
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param qwikComp - A Qwik component (created with `component$`)
|
|
53
|
+
* @returns A React component that renders the Qwik component
|
|
54
|
+
*/
|
|
55
|
+
export declare const reactify$: (qrl: any) => any;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type QRL } from '@qwik.dev/core';
|
|
2
|
+
import { Component, type ReactElement } from 'react';
|
|
2
3
|
import type { QwikifyOptions, QwikifyProps } from './types';
|
|
3
4
|
interface SlotState {
|
|
4
5
|
el?: Element;
|
|
@@ -6,12 +7,17 @@ interface SlotState {
|
|
|
6
7
|
attachedEl?: Element;
|
|
7
8
|
}
|
|
8
9
|
declare const SlotCtx: import("react").Context<SlotState>;
|
|
9
|
-
export
|
|
10
|
-
|
|
10
|
+
export interface QwikProjectionState {
|
|
11
|
+
parentVNode: any;
|
|
12
|
+
container: any;
|
|
13
|
+
}
|
|
14
|
+
export declare const QwikProjectionCtx: import("react").Context<QwikProjectionState | null>;
|
|
15
|
+
export declare function main(slotEl: Element | undefined, scopeId: string, RootCmp: any, props: any, projectionState?: QwikProjectionState | null): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
export declare function mainExactProps(slotEl: Element | undefined, scopeId: string, RootCmp: any, props: any, projectionState?: QwikProjectionState | null): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
11
17
|
export declare class SlotElement extends Component {
|
|
12
18
|
static contextType: import("react").Context<SlotState>;
|
|
13
19
|
context: React.ContextType<typeof SlotCtx>;
|
|
14
|
-
slotC: import("react").RefObject<Element>;
|
|
20
|
+
slotC: import("react").RefObject<Element | null>;
|
|
15
21
|
shouldComponentUpdate(): boolean;
|
|
16
22
|
componentDidMount(): void;
|
|
17
23
|
render(): import("react").DOMElement<{
|
|
@@ -20,10 +26,19 @@ export declare class SlotElement extends Component {
|
|
|
20
26
|
dangerouslySetInnerHTML: {
|
|
21
27
|
__html: string;
|
|
22
28
|
};
|
|
23
|
-
ref: import("react").RefObject<Element>;
|
|
29
|
+
ref: import("react").RefObject<Element | null>;
|
|
24
30
|
}, Element>;
|
|
25
31
|
}
|
|
26
32
|
export declare const getReactProps: (props: Record<string, any>) => Record<string, any>;
|
|
27
33
|
export declare const getHostProps: (props: Record<string, any>) => Record<string, any>;
|
|
28
|
-
export declare const useWakeupSignal: (props: QwikifyProps<{}>, opts?: QwikifyOptions) => readonly [import("@qwik.dev/core").Signal<boolean>, boolean,
|
|
34
|
+
export declare const useWakeupSignal: (props: QwikifyProps<{}>, opts?: QwikifyOptions) => readonly [import("@qwik.dev/core").Signal<boolean>, boolean, QRL<() => true>];
|
|
35
|
+
export interface SSRProjectionEntry {
|
|
36
|
+
qrl: QRL<any>;
|
|
37
|
+
props: Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
export interface SSRProjectionRegistry {
|
|
40
|
+
entries: Map<string, SSRProjectionEntry>;
|
|
41
|
+
}
|
|
42
|
+
export declare function setSSRProjectionRegistry(registry: SSRProjectionRegistry | null): void;
|
|
43
|
+
export declare function getSSRProjectionRegistry(): SSRProjectionRegistry | null;
|
|
29
44
|
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { QRL, Signal } from '@qwik.dev/core';
|
|
2
2
|
import type { FunctionComponent as ReactFC } from 'react';
|
|
3
3
|
import type { Root } from 'react-dom/client';
|
|
4
|
+
import type { QwikProjectionState } from './slot';
|
|
4
5
|
export interface Internal<PROPS> {
|
|
5
6
|
root: Root | undefined;
|
|
6
7
|
cmp: ReactFC<PROPS>;
|
|
8
|
+
projectionState: QwikProjectionState | null;
|
|
7
9
|
}
|
|
8
10
|
export interface QwikifyBase {
|
|
9
11
|
/**
|
package/lib/vite.mjs
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
function qwikReact() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
optimizeDeps: {
|
|
22
|
-
include: OPTIMIZE_DEPS
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
};
|
|
2
|
+
const OPTIMIZE_DEPS = [
|
|
3
|
+
"react",
|
|
4
|
+
"react-dom",
|
|
5
|
+
"react-dom/client",
|
|
6
|
+
"react-dom/server",
|
|
7
|
+
"react/jsx-runtime",
|
|
8
|
+
"react/jsx-dev-runtime"
|
|
9
|
+
];
|
|
10
|
+
const DEDUPE = ["react", "react-dom"];
|
|
11
|
+
return {
|
|
12
|
+
name: "vite-plugin-qwik-react",
|
|
13
|
+
config() {
|
|
14
|
+
return {
|
|
15
|
+
resolve: { dedupe: DEDUPE },
|
|
16
|
+
optimizeDeps: { include: OPTIMIZE_DEPS }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
27
20
|
}
|
|
28
|
-
export {
|
|
29
|
-
qwikReact
|
|
30
|
-
};
|
|
21
|
+
export { qwikReact };
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/react",
|
|
3
3
|
"description": "Qwik React allows adding React components into existing Qwik application",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.41",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@types/react": "
|
|
8
|
-
"@types/react-dom": "
|
|
9
|
-
"react": "
|
|
10
|
-
"react-dom": "
|
|
11
|
-
"typescript": "5.
|
|
12
|
-
"vite": "
|
|
13
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
7
|
+
"@types/react": "19.2.14",
|
|
8
|
+
"@types/react-dom": "19.2.3",
|
|
9
|
+
"react": "19.2.4",
|
|
10
|
+
"react-dom": "19.2.4",
|
|
11
|
+
"typescript": "5.9.3",
|
|
12
|
+
"vite": "8.2.1",
|
|
13
|
+
"@qwik.dev/core": "2.0.0-beta.41"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
@@ -18,13 +18,11 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
20
|
"types": "./lib/types/index.qwik.d.ts",
|
|
21
|
-
"import": "./lib/index.qwik.mjs"
|
|
22
|
-
"require": "./lib/index.qwik.cjs"
|
|
21
|
+
"import": "./lib/index.qwik.mjs"
|
|
23
22
|
},
|
|
24
23
|
"./vite": {
|
|
25
24
|
"types": "./lib/types/vite.d.ts",
|
|
26
|
-
"import": "./lib/vite.mjs"
|
|
27
|
-
"require": "./lib/vite.cjs"
|
|
25
|
+
"import": "./lib/vite.mjs"
|
|
28
26
|
}
|
|
29
27
|
},
|
|
30
28
|
"files": [
|
|
@@ -39,8 +37,8 @@
|
|
|
39
37
|
"@types/react-dom": "^18",
|
|
40
38
|
"react": "^18",
|
|
41
39
|
"react-dom": "^18",
|
|
42
|
-
"vite": ">=
|
|
43
|
-
"@qwik.dev/core": "
|
|
40
|
+
"vite": ">=8 <9",
|
|
41
|
+
"@qwik.dev/core": "2.0.0-beta.41"
|
|
44
42
|
},
|
|
45
43
|
"publishConfig": {
|
|
46
44
|
"access": "public"
|
|
@@ -51,6 +49,7 @@
|
|
|
51
49
|
"url": "https://github.com/QwikDev/qwik.git",
|
|
52
50
|
"directory": "packages/qwik-react"
|
|
53
51
|
},
|
|
52
|
+
"sideEffects": false,
|
|
54
53
|
"type": "module",
|
|
55
54
|
"types": "./lib/types/index.qwik.d.ts",
|
|
56
55
|
"scripts": {
|
package/lib/index.qwik.cjs
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
const jsxRuntime = require("@qwik.dev/core/jsx-runtime");
|
|
7
|
-
const core = require("@qwik.dev/core");
|
|
8
|
-
const client = require("react-dom/client");
|
|
9
|
-
const reactDom = require("react-dom");
|
|
10
|
-
const internal = require("@qwik.dev/core/internal");
|
|
11
|
-
const server = require("react-dom/server");
|
|
12
|
-
const react = require("react");
|
|
13
|
-
const SlotCtx = react.createContext({
|
|
14
|
-
scopeId: ""
|
|
15
|
-
});
|
|
16
|
-
function main(slotEl, scopeId, RootCmp, props) {
|
|
17
|
-
const newProps = getReactProps(props);
|
|
18
|
-
return mainExactProps(slotEl, scopeId, RootCmp, newProps);
|
|
19
|
-
}
|
|
20
|
-
function mainExactProps(slotEl, scopeId, RootCmp, props) {
|
|
21
|
-
return react.createElement(SlotCtx.Provider, {
|
|
22
|
-
value: {
|
|
23
|
-
el: slotEl,
|
|
24
|
-
scopeId,
|
|
25
|
-
attachedEl: void 0
|
|
26
|
-
},
|
|
27
|
-
children: react.createElement(RootCmp, {
|
|
28
|
-
...props,
|
|
29
|
-
children: react.createElement(SlotElement, null)
|
|
30
|
-
})
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
class SlotElement extends react.Component {
|
|
34
|
-
constructor() {
|
|
35
|
-
super(...arguments);
|
|
36
|
-
__publicField(this, "slotC", react.createRef());
|
|
37
|
-
}
|
|
38
|
-
shouldComponentUpdate() {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
componentDidMount() {
|
|
42
|
-
const slotC = this.slotC.current;
|
|
43
|
-
if (slotC) {
|
|
44
|
-
const { attachedEl, el } = this.context;
|
|
45
|
-
if (el) {
|
|
46
|
-
if (!attachedEl) {
|
|
47
|
-
slotC.appendChild(el);
|
|
48
|
-
} else if (attachedEl !== slotC) {
|
|
49
|
-
throw new Error("already attached");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
render() {
|
|
55
|
-
return react.createElement("q-slotc", {
|
|
56
|
-
class: this.context.scopeId,
|
|
57
|
-
suppressHydrationWarning: true,
|
|
58
|
-
dangerouslySetInnerHTML: {
|
|
59
|
-
__html: "<!--SLOT-->"
|
|
60
|
-
},
|
|
61
|
-
ref: this.slotC
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
__publicField(SlotElement, "contextType", SlotCtx);
|
|
66
|
-
const getReactProps = (props) => {
|
|
67
|
-
const obj = {};
|
|
68
|
-
Object.keys(props).forEach((key) => {
|
|
69
|
-
if (!key.startsWith("client:") && !key.startsWith("qwik:") && !key.startsWith(HOST_PREFIX)) {
|
|
70
|
-
const normalizedKey = key.endsWith("$") ? key.slice(0, -1) : key;
|
|
71
|
-
obj[normalizedKey] = props[key];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return obj;
|
|
75
|
-
};
|
|
76
|
-
const getHostProps = (props) => {
|
|
77
|
-
const obj = {};
|
|
78
|
-
Object.keys(props).forEach((key) => {
|
|
79
|
-
if (key.startsWith(HOST_PREFIX)) {
|
|
80
|
-
obj[key.slice(HOST_PREFIX.length)] = props[key];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return obj;
|
|
84
|
-
};
|
|
85
|
-
const useWakeupSignal = (props, opts = {}) => {
|
|
86
|
-
const signal = core.useSignal(false);
|
|
87
|
-
const activate = core.$(() => signal.value = true);
|
|
88
|
-
const clientOnly = !!(props["client:only"] || props["qwik:only"] || opts?.clientOnly);
|
|
89
|
-
const clientVisible = props["client:visible"] || props["qwik:visible"] || opts?.eagerness === "visible";
|
|
90
|
-
const clientIdle = props["client:idle"] || props["qwik:idle"] || opts?.eagerness === "idle";
|
|
91
|
-
const clientLoad = props["client:load"] || props["qwik:load"] || clientOnly || opts?.eagerness === "load";
|
|
92
|
-
const clientHover = props["client:hover"] || props["qwik:hover"] || opts?.eagerness === "hover";
|
|
93
|
-
const clientEvent = props["client:event"] || props["qwik:event"];
|
|
94
|
-
if (core.isServer) {
|
|
95
|
-
if (clientVisible) {
|
|
96
|
-
core.useOn("qvisible", activate);
|
|
97
|
-
}
|
|
98
|
-
if (clientIdle) {
|
|
99
|
-
core.useOnDocument("qidle", activate);
|
|
100
|
-
}
|
|
101
|
-
if (clientLoad) {
|
|
102
|
-
core.useOnDocument("qinit", activate);
|
|
103
|
-
}
|
|
104
|
-
if (clientHover) {
|
|
105
|
-
core.useOn("mouseover", activate);
|
|
106
|
-
}
|
|
107
|
-
if (clientEvent) {
|
|
108
|
-
core.useOn(clientEvent, activate);
|
|
109
|
-
}
|
|
110
|
-
if (opts?.event) {
|
|
111
|
-
core.useOn(opts?.event, activate);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return [
|
|
115
|
-
signal,
|
|
116
|
-
clientOnly,
|
|
117
|
-
activate
|
|
118
|
-
];
|
|
119
|
-
};
|
|
120
|
-
const HOST_PREFIX = "host:";
|
|
121
|
-
async function renderFromServer(Host, reactCmp$, scopeId, props, ref, slotRef, hydrationProps) {
|
|
122
|
-
if (core.isServer) {
|
|
123
|
-
const Cmp = await reactCmp$.resolve();
|
|
124
|
-
const newProps = getReactProps(props);
|
|
125
|
-
Object.assign(hydrationProps, newProps);
|
|
126
|
-
const html = server.renderToString(mainExactProps(void 0, scopeId, Cmp, newProps));
|
|
127
|
-
const index = html.indexOf("<!--SLOT-->");
|
|
128
|
-
if (index > 0) {
|
|
129
|
-
const part1 = html.slice(0, index);
|
|
130
|
-
const part2 = html.slice(index + "<!--SLOT-->".length);
|
|
131
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Host, {
|
|
132
|
-
ref,
|
|
133
|
-
...getHostProps(props),
|
|
134
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(internal.SSRStream, {
|
|
135
|
-
children: async function* () {
|
|
136
|
-
yield /* @__PURE__ */ jsxRuntime.jsx(internal.SSRComment, {
|
|
137
|
-
data: "q:ignore"
|
|
138
|
-
});
|
|
139
|
-
yield /* @__PURE__ */ jsxRuntime.jsx(internal.SSRRaw, {
|
|
140
|
-
data: part1
|
|
141
|
-
});
|
|
142
|
-
yield /* @__PURE__ */ jsxRuntime.jsx(internal.SSRComment, {
|
|
143
|
-
data: "q:container-island"
|
|
144
|
-
});
|
|
145
|
-
yield /* @__PURE__ */ jsxRuntime.jsx("q-slot", {
|
|
146
|
-
ref: slotRef,
|
|
147
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {})
|
|
148
|
-
});
|
|
149
|
-
yield /* @__PURE__ */ jsxRuntime.jsx(internal.SSRComment, {
|
|
150
|
-
data: "/q:container-island"
|
|
151
|
-
});
|
|
152
|
-
yield /* @__PURE__ */ jsxRuntime.jsx(internal.SSRRaw, {
|
|
153
|
-
data: part2
|
|
154
|
-
});
|
|
155
|
-
yield /* @__PURE__ */ jsxRuntime.jsx(internal.SSRComment, {
|
|
156
|
-
data: "/q:ignore"
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
163
|
-
children: [
|
|
164
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Host, {
|
|
165
|
-
ref,
|
|
166
|
-
children: [
|
|
167
|
-
/* @__PURE__ */ jsxRuntime.jsx(internal.SSRComment, {
|
|
168
|
-
data: "q:container=html"
|
|
169
|
-
}),
|
|
170
|
-
/* @__PURE__ */ jsxRuntime.jsx(internal.SSRRaw, {
|
|
171
|
-
data: html
|
|
172
|
-
}),
|
|
173
|
-
/* @__PURE__ */ jsxRuntime.jsx(internal.SSRComment, {
|
|
174
|
-
data: "/q:container"
|
|
175
|
-
})
|
|
176
|
-
]
|
|
177
|
-
}),
|
|
178
|
-
/* @__PURE__ */ jsxRuntime.jsx("q-slot", {
|
|
179
|
-
ref: slotRef,
|
|
180
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {})
|
|
181
|
-
})
|
|
182
|
-
]
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function qwikifyQrl(reactCmp$, opts) {
|
|
187
|
-
return core.component$((props) => {
|
|
188
|
-
const { scopeId } = core.useStylesScoped$(`q-slot{display:none} q-slotc,q-slotc>q-slot{display:contents}`);
|
|
189
|
-
const hostRef = core.useSignal();
|
|
190
|
-
const slotRef = core.useSignal();
|
|
191
|
-
const internalState = core.useSignal();
|
|
192
|
-
const [signal, isClientOnly] = useWakeupSignal(props, opts);
|
|
193
|
-
const hydrationKeys = core.useStore({});
|
|
194
|
-
const TagName = opts?.tagName ?? "qwik-react";
|
|
195
|
-
core.useTask$(async ({ track }) => {
|
|
196
|
-
const trackedProps = track(() => ({
|
|
197
|
-
...props
|
|
198
|
-
}));
|
|
199
|
-
track(signal);
|
|
200
|
-
if (!core.isBrowser) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (internalState.value) {
|
|
204
|
-
if (internalState.value.root) {
|
|
205
|
-
internalState.value.root.render(main(slotRef.value, scopeId, internalState.value.cmp, trackedProps));
|
|
206
|
-
}
|
|
207
|
-
} else {
|
|
208
|
-
let root = void 0;
|
|
209
|
-
const Cmp = await reactCmp$.resolve();
|
|
210
|
-
const hostElement = hostRef.value;
|
|
211
|
-
if (hostElement) {
|
|
212
|
-
if (isClientOnly) {
|
|
213
|
-
root = client.createRoot(hostElement);
|
|
214
|
-
} else {
|
|
215
|
-
root = reactDom.flushSync(() => {
|
|
216
|
-
return client.hydrateRoot(hostElement, mainExactProps(slotRef.value, scopeId, Cmp, hydrationKeys));
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
if (isClientOnly || signal.value === false) {
|
|
220
|
-
root.render(main(slotRef.value, scopeId, Cmp, trackedProps));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
internalState.value = core.noSerialize({
|
|
224
|
-
cmp: Cmp,
|
|
225
|
-
root
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
if (core.isServer && !isClientOnly) {
|
|
230
|
-
const jsx = renderFromServer(TagName, reactCmp$, scopeId, props, hostRef, slotRef, hydrationKeys);
|
|
231
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.RenderOnce, {
|
|
232
|
-
children: jsx
|
|
233
|
-
}, 2);
|
|
234
|
-
}
|
|
235
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
236
|
-
children: [
|
|
237
|
-
/* @__PURE__ */ jsxRuntime.jsx(TagName, {
|
|
238
|
-
...getHostProps(props),
|
|
239
|
-
ref: (el) => {
|
|
240
|
-
if (core.isBrowser) {
|
|
241
|
-
queueMicrotask(() => {
|
|
242
|
-
const internalData = internalState.value;
|
|
243
|
-
if (internalData && !internalData.root) {
|
|
244
|
-
const root = internalData.root = client.createRoot(el);
|
|
245
|
-
root.render(main(slotRef.value, scopeId, internalData.cmp, props));
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
} else {
|
|
249
|
-
hostRef.value = el;
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
children: core.SkipRender
|
|
253
|
-
}),
|
|
254
|
-
/* @__PURE__ */ jsxRuntime.jsx("q-slot", {
|
|
255
|
-
ref: slotRef,
|
|
256
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {})
|
|
257
|
-
})
|
|
258
|
-
]
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
const qwikify$ = /* @__PURE__ */ core.implicit$FirstArg(qwikifyQrl);
|
|
263
|
-
exports.qwikify$ = qwikify$;
|
|
264
|
-
exports.qwikifyQrl = qwikifyQrl;
|
package/lib/vite.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function qwikReact() {
|
|
4
|
-
const OPTIMIZE_DEPS = [
|
|
5
|
-
"react",
|
|
6
|
-
"react-dom",
|
|
7
|
-
"react-dom/client",
|
|
8
|
-
"react-dom/server",
|
|
9
|
-
"react/jsx-runtime",
|
|
10
|
-
"react/jsx-dev-runtime"
|
|
11
|
-
];
|
|
12
|
-
const DEDUPE = [
|
|
13
|
-
"react",
|
|
14
|
-
"react-dom"
|
|
15
|
-
];
|
|
16
|
-
return {
|
|
17
|
-
name: "vite-plugin-qwik-react",
|
|
18
|
-
config() {
|
|
19
|
-
return {
|
|
20
|
-
resolve: {
|
|
21
|
-
dedupe: DEDUPE
|
|
22
|
-
},
|
|
23
|
-
optimizeDeps: {
|
|
24
|
-
include: OPTIMIZE_DEPS
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.qwikReact = qwikReact;
|