rwsdk 0.1.20 → 0.1.21
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/runtime/entries/auth.d.ts +1 -0
- package/dist/runtime/entries/auth.js +1 -0
- package/dist/runtime/entries/client.d.ts +1 -0
- package/dist/runtime/entries/client.js +1 -0
- package/dist/runtime/entries/clientSSR.d.ts +1 -0
- package/dist/runtime/entries/clientSSR.js +1 -0
- package/dist/runtime/entries/router.d.ts +1 -0
- package/dist/runtime/entries/router.js +1 -0
- package/dist/runtime/entries/ssr.d.ts +1 -0
- package/dist/runtime/entries/ssr.js +1 -0
- package/dist/runtime/entries/types/client.d.ts +1 -0
- package/dist/runtime/entries/types/client.js +1 -0
- package/dist/runtime/entries/types/shared.d.ts +7 -0
- package/dist/runtime/entries/types/shared.js +1 -0
- package/dist/runtime/entries/types/ssr.d.ts +1 -0
- package/dist/runtime/entries/types/ssr.js +1 -0
- package/dist/runtime/entries/types/worker.d.ts +1 -0
- package/dist/runtime/entries/types/worker.js +1 -0
- package/dist/runtime/entries/worker.d.ts +1 -0
- package/dist/runtime/entries/worker.js +1 -0
- package/dist/runtime/imports/client.js +1 -1
- package/dist/runtime/lib/auth/session.js +3 -2
- package/dist/runtime/lib/turnstile/useTurnstile.js +3 -2
- package/dist/runtime/register/worker.js +1 -2
- package/dist/runtime/worker.js +3 -3
- package/dist/vite/devServerConstant.d.mts +9 -0
- package/dist/vite/devServerConstant.mjs +11 -0
- package/dist/vite/redwoodPlugin.mjs +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./shared";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./shared";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./shared";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./shared";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./shared";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./shared";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import memoize from "lodash/memoize";
|
|
3
3
|
export const loadModule = memoize(async (id) => {
|
|
4
|
-
if (import.meta.env.
|
|
4
|
+
if (import.meta.env.VITE_IS_DEV_SERVER) {
|
|
5
5
|
return await import(/* @vite-ignore */ id);
|
|
6
6
|
}
|
|
7
7
|
else {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ErrorResponse } from "../../error";
|
|
2
|
-
import { IS_DEV } from "../../constants";
|
|
3
2
|
import { env } from "cloudflare:workers";
|
|
4
3
|
const AUTH_SECRET_KEY = env.AUTH_SECRET_KEY ??
|
|
5
|
-
(
|
|
4
|
+
(import.meta.env.VITE_IS_DEV_SERVER
|
|
5
|
+
? "development-secret-key-do-not-use-in-production"
|
|
6
|
+
: undefined);
|
|
6
7
|
if (AUTH_SECRET_KEY === "") {
|
|
7
8
|
console.warn("AUTH_SECRET_KEY is set but empty. Please provide a non-empty secret key for session store security.");
|
|
8
9
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useRef, useCallback } from "react";
|
|
3
|
-
import { IS_DEV } from "../../constants";
|
|
4
3
|
export function useTurnstile(siteKey) {
|
|
5
4
|
const containerRef = useRef(null);
|
|
6
5
|
const resolverRef = useRef(Promise.withResolvers());
|
|
@@ -10,7 +9,9 @@ export function useTurnstile(siteKey) {
|
|
|
10
9
|
containerRef.current &&
|
|
11
10
|
window.turnstile) {
|
|
12
11
|
widgetIdRef.current = window.turnstile.render(containerRef.current, {
|
|
13
|
-
sitekey:
|
|
12
|
+
sitekey: import.meta.env.VITE_IS_DEV_SERVER
|
|
13
|
+
? "1x00000000000000000000AA"
|
|
14
|
+
: siteKey,
|
|
14
15
|
callback: (token) => resolverRef.current.resolve(token),
|
|
15
16
|
});
|
|
16
17
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { registerServerReference as baseRegisterServerReference, registerClientReference as baseRegisterClientReference, decodeReply, } from "react-server-dom-webpack/server.edge";
|
|
2
2
|
import { getServerModuleExport } from "../imports/worker.js";
|
|
3
|
-
import { IS_DEV } from "../constants";
|
|
4
3
|
export function registerServerReference(action, id, name) {
|
|
5
4
|
if (typeof action !== "function") {
|
|
6
5
|
return action;
|
|
@@ -31,7 +30,7 @@ export async function rscActionHandler(req) {
|
|
|
31
30
|
: await req.text();
|
|
32
31
|
const args = (await decodeReply(data, null));
|
|
33
32
|
const actionId = url.searchParams.get("__rsc_action_id");
|
|
34
|
-
if (
|
|
33
|
+
if (import.meta.env.VITE_IS_DEV_SERVER && actionId === "__rsc_hot_update") {
|
|
35
34
|
return null;
|
|
36
35
|
}
|
|
37
36
|
const action = await getServerModuleExport(actionId);
|
package/dist/runtime/worker.js
CHANGED
|
@@ -7,7 +7,6 @@ import { ErrorResponse } from "./error";
|
|
|
7
7
|
import { getRequestInfo, runWithRequestInfo, runWithRequestInfoOverrides, } from "./requestInfo/worker";
|
|
8
8
|
import { defineRoutes } from "./lib/router";
|
|
9
9
|
import { generateNonce } from "./lib/utils";
|
|
10
|
-
import { IS_DEV } from "./constants";
|
|
11
10
|
import { ssrWebpackRequire } from "./imports/worker";
|
|
12
11
|
export const defineApp = (routes) => {
|
|
13
12
|
return {
|
|
@@ -22,7 +21,8 @@ export const defineApp = (routes) => {
|
|
|
22
21
|
url.pathname = url.pathname.slice("/assets/".length);
|
|
23
22
|
return env.ASSETS.fetch(new Request(url.toString(), request));
|
|
24
23
|
}
|
|
25
|
-
else if (
|
|
24
|
+
else if (import.meta.env.VITE_IS_DEV_SERVER &&
|
|
25
|
+
request.url.includes("/__vite_preamble__")) {
|
|
26
26
|
return new Response('import RefreshRuntime from "/@react-refresh"; RefreshRuntime.injectIntoGlobalHook(window); window.$RefreshReg$ = () => {}; window.$RefreshSig$ = () => (type) => type; window.__vite_plugin_react_preamble_installed__ = true;', {
|
|
27
27
|
headers: {
|
|
28
28
|
"content-type": "text/javascript",
|
|
@@ -76,7 +76,7 @@ export const defineApp = (routes) => {
|
|
|
76
76
|
};
|
|
77
77
|
const renderPage = async (requestInfo, Page, onError) => {
|
|
78
78
|
if (isClientReference(requestInfo.rw.Document)) {
|
|
79
|
-
if (
|
|
79
|
+
if (import.meta.env.DEV) {
|
|
80
80
|
console.error("Document cannot be a client component");
|
|
81
81
|
}
|
|
82
82
|
return new Response(null, {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const devServerConstantPlugin = () => {
|
|
2
|
+
return {
|
|
3
|
+
name: "rwsdk:dev-server-constant",
|
|
4
|
+
config(_, { command, isPreview }) {
|
|
5
|
+
if (command === "serve" && isPreview) {
|
|
6
|
+
// context(justinvdm, 21 Jul 2025): Vite forwards this as `import.meta.env.DEV_IS_DEV_SERVER`
|
|
7
|
+
process.env.VITE_IS_DEV_SERVER = "1";
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { unstable_readConfig } from "wrangler";
|
|
3
3
|
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
4
|
+
import { devServerConstantPlugin } from "./devServerConstant.mjs";
|
|
4
5
|
import { hasOwnCloudflareVitePlugin } from "./hasOwnCloudflareVitePlugin.mjs";
|
|
5
6
|
import reactPlugin from "@vitejs/plugin-react";
|
|
6
7
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
@@ -54,6 +55,7 @@ export const redwoodPlugin = async (options = {}) => {
|
|
|
54
55
|
}
|
|
55
56
|
return [
|
|
56
57
|
devServerTimingPlugin(),
|
|
58
|
+
devServerConstantPlugin(),
|
|
57
59
|
configPlugin({
|
|
58
60
|
silent: options.silent ?? false,
|
|
59
61
|
projectRootDir,
|