weifuwu 0.23.0 → 0.23.1
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ui/app/page.tsx
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useWebsocket, useLoaderData, useLocale, useTheme } from "weifuwu/react";
|
|
4
4
|
|
|
5
|
-
//
|
|
5
|
+
// ui/components/Greeting.tsx
|
|
6
6
|
import { jsxs } from "react/jsx-runtime";
|
|
7
7
|
function Greeting({ name }) {
|
|
8
8
|
return /* @__PURE__ */ jsxs("span", { className: "text-red-500 font-bold", children: [
|
|
@@ -11,7 +11,7 @@ function Greeting({ name }) {
|
|
|
11
11
|
] });
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// ui/app/page.tsx
|
|
15
15
|
import { jsx, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
16
16
|
function Home() {
|
|
17
17
|
const [input, setInput] = useState("");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// ui/app/layout.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
function RootLayout({ children }) {
|
|
4
|
+
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
5
|
+
/* @__PURE__ */ jsxs("head", { children: [
|
|
6
|
+
/* @__PURE__ */ jsx("meta", { charSet: "utf-8" }),
|
|
7
|
+
/* @__PURE__ */ jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" })
|
|
8
|
+
] }),
|
|
9
|
+
/* @__PURE__ */ jsx("body", { children: /* @__PURE__ */ jsx("main", { children }) })
|
|
10
|
+
] });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
RootLayout as default
|
|
14
|
+
};
|
package/dist/client-theme.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -851,7 +851,7 @@ function sendHttpResponseOnSocket(socket, response) {
|
|
|
851
851
|
|
|
852
852
|
// tsx-context.ts
|
|
853
853
|
import { useSyncExternalStore, createContext } from "react";
|
|
854
|
-
var DEFAULT_CTX = { params: {}, query: {}, parsed: {}, loaderData: {}, env: {}, user: {} };
|
|
854
|
+
var DEFAULT_CTX = { params: {}, query: {}, parsed: {}, loaderData: {}, env: {}, user: {}, flash: {} };
|
|
855
855
|
var KEY = "__WEIFUWU_CTX_STORE";
|
|
856
856
|
function getStore() {
|
|
857
857
|
if (typeof globalThis !== "undefined" && globalThis[KEY]) {
|
|
@@ -7400,12 +7400,28 @@ async function init() {
|
|
|
7400
7400
|
const app = createElement(TsxContext.Provider, { value: _ctx },
|
|
7401
7401
|
createElement(Page));
|
|
7402
7402
|
${isDev2 ? `
|
|
7403
|
+
// Stable proxy \u2014 same function ref = React preserves fiber + useState state across HMR
|
|
7404
|
+
const _pageImpl = { current: Page };
|
|
7405
|
+
const _pageProxy = new Proxy(function __wfw_page(){}, {
|
|
7406
|
+
apply(_target, _thisArg, args) {
|
|
7407
|
+
return Reflect.apply(_pageImpl.current, _thisArg, args);
|
|
7408
|
+
},
|
|
7409
|
+
});
|
|
7410
|
+
|
|
7403
7411
|
const reactRoot = createRoot(_root);
|
|
7404
|
-
|
|
7412
|
+
let _tick = 0;
|
|
7413
|
+
function renderPage() {
|
|
7414
|
+
reactRoot.render(createElement(TsxContext.Provider, { value: _ctx },
|
|
7415
|
+
createElement(_pageProxy, { __t: _tick })));
|
|
7416
|
+
}
|
|
7417
|
+
renderPage();
|
|
7418
|
+
|
|
7405
7419
|
window.__WFW_REFRESH = async (NewComponent) => {
|
|
7406
7420
|
const store = globalThis.__WEIFUWU_CTX_STORE?._ctx || _ctx;
|
|
7421
|
+
_pageImpl.current = NewComponent;
|
|
7422
|
+
_tick++;
|
|
7407
7423
|
reactRoot.render(createElement(TsxContext.Provider, { value: store },
|
|
7408
|
-
createElement(
|
|
7424
|
+
createElement(_pageProxy, { __t: _tick })));
|
|
7409
7425
|
};
|
|
7410
7426
|
` : `
|
|
7411
7427
|
hydrateRoot(_root, app);
|
package/dist/react.js
CHANGED
|
@@ -155,7 +155,7 @@ async function runInterceptors(url) {
|
|
|
155
155
|
|
|
156
156
|
// tsx-context.ts
|
|
157
157
|
import { useSyncExternalStore, createContext } from "react";
|
|
158
|
-
var DEFAULT_CTX = { params: {}, query: {}, parsed: {}, loaderData: {}, env: {}, user: {} };
|
|
158
|
+
var DEFAULT_CTX = { params: {}, query: {}, parsed: {}, loaderData: {}, env: {}, user: {}, flash: {} };
|
|
159
159
|
var KEY = "__WEIFUWU_CTX_STORE";
|
|
160
160
|
function getStore() {
|
|
161
161
|
if (typeof globalThis !== "undefined" && globalThis[KEY]) {
|
package/dist/tsx-context.d.ts
CHANGED
|
@@ -5,11 +5,19 @@ export interface PageContext {
|
|
|
5
5
|
id?: string;
|
|
6
6
|
};
|
|
7
7
|
parsed: Record<string, unknown>;
|
|
8
|
-
theme?:
|
|
8
|
+
theme?: {
|
|
9
|
+
value: string;
|
|
10
|
+
set?: (value: string, loc?: string) => Response;
|
|
11
|
+
};
|
|
9
12
|
i18n?: {
|
|
10
13
|
locale: string;
|
|
14
|
+
messages?: Record<string, unknown>;
|
|
11
15
|
t: (key: string, params?: Record<string, string>, fallback?: string) => string;
|
|
12
16
|
};
|
|
17
|
+
flash?: {
|
|
18
|
+
value?: string;
|
|
19
|
+
set?: (data: any, loc?: string) => Response;
|
|
20
|
+
};
|
|
13
21
|
loaderData: Record<string, unknown>;
|
|
14
22
|
env: Record<string, string>;
|
|
15
23
|
}
|