weifuwu 0.19.5 → 0.19.7
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.js +8 -4
- package/dist/stream.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5212,10 +5212,11 @@ function getPublicEnv() {
|
|
|
5212
5212
|
return _publicEnv;
|
|
5213
5213
|
}
|
|
5214
5214
|
function buildHeadPayload(opts) {
|
|
5215
|
-
const { ctx,
|
|
5215
|
+
const { ctx, compiledTailwindCss, isDev: isDev2 } = opts;
|
|
5216
|
+
const rb = opts.rootBase || "";
|
|
5216
5217
|
let result = "";
|
|
5217
5218
|
if (isDev2) {
|
|
5218
|
-
const vUrl = `${
|
|
5219
|
+
const vUrl = `${rb}/__wfw/v/bundle`;
|
|
5219
5220
|
result += `<script type="importmap">{
|
|
5220
5221
|
"imports": {
|
|
5221
5222
|
"react": "${vUrl}",
|
|
@@ -5314,8 +5315,9 @@ function streamResponse(reactStream, opts) {
|
|
|
5314
5315
|
const body = buildBodyScripts(opts);
|
|
5315
5316
|
if (body) controller.enqueue(encoder2.encode("\n" + body));
|
|
5316
5317
|
if (opts.isDev) {
|
|
5317
|
-
const
|
|
5318
|
-
const
|
|
5318
|
+
const rb = opts.rootBase || "";
|
|
5319
|
+
const wsUrl = `${rb}/__weifuwu/livereload`;
|
|
5320
|
+
const hbUrl = `${rb}/__wfw/h/`;
|
|
5319
5321
|
controller.enqueue(encoder2.encode(
|
|
5320
5322
|
`
|
|
5321
5323
|
<script>(function(){var ws=new WebSocket((location.protocol==='https:'?'wss:':'ws:')+'//'+location.host+'${wsUrl}');var t=0;ws.onmessage=function(e){try{var m=JSON.parse(e.data);if(m.type==='component'){if(m.entry&&m.entry!==window.__WFW_ENTRY)return;import('${hbUrl}'+m.hash+'?'+Date.now()).catch(function(){location.reload()});if(m.css){var s=document.querySelector('style[data-lr]')||function(){var x=document.createElement('style');x.setAttribute('data-lr','');document.head.appendChild(x);return x}();s.textContent=m.css}return}if(m.type==='css'){var s=document.querySelector('style[data-lr]')||function(){var x=document.createElement('style');x.setAttribute('data-lr','');document.head.appendChild(x);return x}();s.textContent=m.css;return}}catch(_){}if(e.data==='reload'&&Date.now()-t>1e3){t=Date.now();location.reload()}};ws.onclose=function(){if(Date.now()-t>1e3){t=Date.now();setTimeout(function(){location.reload()},500)}}})()</script>`
|
|
@@ -5484,6 +5486,7 @@ function ssr(path2) {
|
|
|
5484
5486
|
return streamResponse(stream, {
|
|
5485
5487
|
ctx,
|
|
5486
5488
|
base,
|
|
5489
|
+
rootBase: ctx.rootLayoutBase || "",
|
|
5487
5490
|
isDev,
|
|
5488
5491
|
bundle,
|
|
5489
5492
|
loaderData,
|
|
@@ -5678,6 +5681,7 @@ function rootLayout(dir) {
|
|
|
5678
5681
|
r.use(async (req, ctx, next) => {
|
|
5679
5682
|
const mod = await compile(layoutPath);
|
|
5680
5683
|
if (mod?.default) ctx.layoutStack = [{ path: layoutPath, component: mod.default }];
|
|
5684
|
+
ctx.rootLayoutBase = (ctx.mountPath || "").replace(/\/$/, "");
|
|
5681
5685
|
return next(req, ctx);
|
|
5682
5686
|
});
|
|
5683
5687
|
if (existsSync5(join5(resolved, "app.css"))) {
|
package/dist/stream.d.ts
CHANGED