rwsdk 0.1.15 → 0.1.16
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/package.json +1 -1
- package/dist/lib/$.d.mts +0 -8
- package/dist/lib/$.mjs +0 -5
- package/dist/lib/constants.d.mts +0 -4
- package/dist/lib/constants.mjs +0 -6
- package/dist/lib/findWranglerConfig.d.mts +0 -1
- package/dist/lib/findWranglerConfig.mjs +0 -12
- package/dist/lib/getShortName.d.mts +0 -1
- package/dist/lib/getShortName.mjs +0 -2
- package/dist/lib/getSrcPaths.d.ts +0 -15
- package/dist/lib/getSrcPaths.js +0 -80
- package/dist/lib/hasPkgScript.d.mts +0 -1
- package/dist/lib/hasPkgScript.mjs +0 -9
- package/dist/lib/jsonUtils.d.mts +0 -28
- package/dist/lib/jsonUtils.mjs +0 -167
- package/dist/lib/setupEnvFiles.d.mts +0 -4
- package/dist/lib/setupEnvFiles.mjs +0 -31
- package/dist/lib/smokeTests/artifacts.d.mts +0 -10
- package/dist/lib/smokeTests/artifacts.mjs +0 -164
- package/dist/lib/smokeTests/browser.d.mts +0 -48
- package/dist/lib/smokeTests/browser.mjs +0 -1041
- package/dist/lib/smokeTests/cleanup.d.mts +0 -5
- package/dist/lib/smokeTests/cleanup.mjs +0 -214
- package/dist/lib/smokeTests/codeUpdates.d.mts +0 -8
- package/dist/lib/smokeTests/codeUpdates.mjs +0 -229
- package/dist/lib/smokeTests/constants.d.mts +0 -5
- package/dist/lib/smokeTests/constants.mjs +0 -10
- package/dist/lib/smokeTests/development.d.mts +0 -11
- package/dist/lib/smokeTests/development.mjs +0 -209
- package/dist/lib/smokeTests/environment.d.mts +0 -14
- package/dist/lib/smokeTests/environment.mjs +0 -163
- package/dist/lib/smokeTests/release.d.mts +0 -61
- package/dist/lib/smokeTests/release.mjs +0 -526
- package/dist/lib/smokeTests/reporting.d.mts +0 -13
- package/dist/lib/smokeTests/reporting.mjs +0 -355
- package/dist/lib/smokeTests/runSmokeTests.d.mts +0 -5
- package/dist/lib/smokeTests/runSmokeTests.mjs +0 -144
- package/dist/lib/smokeTests/state.d.mts +0 -48
- package/dist/lib/smokeTests/state.mjs +0 -57
- package/dist/lib/smokeTests/templates/SmokeTest.template.d.ts +0 -1
- package/dist/lib/smokeTests/templates/SmokeTest.template.js +0 -81
- package/dist/lib/smokeTests/templates/SmokeTestClient.template.d.ts +0 -1
- package/dist/lib/smokeTests/templates/SmokeTestClient.template.js +0 -159
- package/dist/lib/smokeTests/templates/smokeTestFunctions.template.d.ts +0 -1
- package/dist/lib/smokeTests/templates/smokeTestFunctions.template.js +0 -19
- package/dist/lib/smokeTests/types.d.mts +0 -75
- package/dist/lib/smokeTests/types.mjs +0 -1
- package/dist/lib/smokeTests/utils.d.mts +0 -15
- package/dist/lib/smokeTests/utils.mjs +0 -147
- package/dist/llms/index.d.ts +0 -3
- package/dist/llms/index.js +0 -35
- package/dist/llms/rules/interruptors.d.ts +0 -1
- package/dist/llms/rules/interruptors.js +0 -243
- package/dist/llms/rules/middleware.d.ts +0 -1
- package/dist/llms/rules/middleware.js +0 -71
- package/dist/llms/rules/react.d.ts +0 -1
- package/dist/llms/rules/react.js +0 -106
- package/dist/llms/rules/request-response.d.ts +0 -1
- package/dist/llms/rules/request-response.js +0 -209
- package/dist/runtime/client.d.ts +0 -17
- package/dist/runtime/client.js +0 -74
- package/dist/runtime/clientNavigation.d.ts +0 -4
- package/dist/runtime/clientNavigation.js +0 -53
- package/dist/runtime/clientNavigation.test.d.ts +0 -1
- package/dist/runtime/clientNavigation.test.js +0 -55
- package/dist/runtime/constants.d.ts +0 -1
- package/dist/runtime/constants.js +0 -1
- package/dist/runtime/entries/auth.d.ts +0 -1
- package/dist/runtime/entries/auth.js +0 -1
- package/dist/runtime/entries/client.d.ts +0 -4
- package/dist/runtime/entries/client.js +0 -4
- package/dist/runtime/entries/clientSSR.d.ts +0 -1
- package/dist/runtime/entries/clientSSR.js +0 -1
- package/dist/runtime/entries/no-react-server.d.ts +0 -0
- package/dist/runtime/entries/no-react-server.js +0 -2
- package/dist/runtime/entries/react-server-only.d.ts +0 -0
- package/dist/runtime/entries/react-server-only.js +0 -2
- package/dist/runtime/entries/router.d.ts +0 -2
- package/dist/runtime/entries/router.js +0 -2
- package/dist/runtime/entries/ssr.d.ts +0 -1
- package/dist/runtime/entries/ssr.js +0 -1
- package/dist/runtime/entries/worker.d.ts +0 -9
- package/dist/runtime/entries/worker.js +0 -9
- package/dist/runtime/error.d.ts +0 -6
- package/dist/runtime/error.js +0 -8
- package/dist/runtime/imports/ClientOnly.d.ts +0 -3
- package/dist/runtime/imports/ClientOnly.js +0 -8
- package/dist/runtime/imports/client.d.ts +0 -4
- package/dist/runtime/imports/client.js +0 -33
- package/dist/runtime/imports/ssr.d.ts +0 -5
- package/dist/runtime/imports/ssr.js +0 -20
- package/dist/runtime/imports/worker.d.ts +0 -5
- package/dist/runtime/imports/worker.js +0 -22
- package/dist/runtime/lib/auth/index.d.ts +0 -1
- package/dist/runtime/lib/auth/index.js +0 -1
- package/dist/runtime/lib/auth/session.d.ts +0 -50
- package/dist/runtime/lib/auth/session.js +0 -148
- package/dist/runtime/lib/db/DOWorkerDialect.d.ts +0 -29
- package/dist/runtime/lib/db/DOWorkerDialect.js +0 -66
- package/dist/runtime/lib/db/SqliteDurableObject.d.ts +0 -14
- package/dist/runtime/lib/db/SqliteDurableObject.js +0 -42
- package/dist/runtime/lib/db/createDb.d.ts +0 -2
- package/dist/runtime/lib/db/createDb.js +0 -33
- package/dist/runtime/lib/db/index.d.ts +0 -4
- package/dist/runtime/lib/db/index.js +0 -3
- package/dist/runtime/lib/db/migrations.d.ts +0 -23
- package/dist/runtime/lib/db/migrations.js +0 -34
- package/dist/runtime/lib/db/typeInference/assert.d.ts +0 -2
- package/dist/runtime/lib/db/typeInference/assert.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/alterColumn.d.ts +0 -27
- package/dist/runtime/lib/db/typeInference/builders/alterColumn.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +0 -53
- package/dist/runtime/lib/db/typeInference/builders/alterTable.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +0 -26
- package/dist/runtime/lib/db/typeInference/builders/columnDefinition.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +0 -49
- package/dist/runtime/lib/db/typeInference/builders/createTable.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/createView.d.ts +0 -17
- package/dist/runtime/lib/db/typeInference/builders/createView.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/dropTable.d.ts +0 -11
- package/dist/runtime/lib/db/typeInference/builders/dropTable.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/dropView.d.ts +0 -12
- package/dist/runtime/lib/db/typeInference/builders/dropView.js +0 -1
- package/dist/runtime/lib/db/typeInference/builders/schema.d.ts +0 -24
- package/dist/runtime/lib/db/typeInference/builders/schema.js +0 -1
- package/dist/runtime/lib/db/typeInference/database.d.ts +0 -27
- package/dist/runtime/lib/db/typeInference/database.js +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +0 -360
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +0 -33
- package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/dropTable.typetest.js +0 -143
- package/dist/runtime/lib/db/typeInference/typetests/print.d.ts +0 -3
- package/dist/runtime/lib/db/typeInference/typetests/print.js +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +0 -2
- package/dist/runtime/lib/db/typeInference/typetests/testUtils.js +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.d.ts +0 -1
- package/dist/runtime/lib/db/typeInference/typetests/typeInference.typetest.js +0 -17
- package/dist/runtime/lib/db/typeInference/utils.d.ts +0 -82
- package/dist/runtime/lib/db/typeInference/utils.js +0 -2
- package/dist/runtime/lib/debug.d.ts +0 -2
- package/dist/runtime/lib/debug.js +0 -36
- package/dist/runtime/lib/links.d.ts +0 -14
- package/dist/runtime/lib/links.js +0 -38
- package/dist/runtime/lib/realtime/client.d.ts +0 -7
- package/dist/runtime/lib/realtime/client.js +0 -166
- package/dist/runtime/lib/realtime/constants.d.ts +0 -1
- package/dist/runtime/lib/realtime/constants.js +0 -1
- package/dist/runtime/lib/realtime/durableObject.d.ts +0 -29
- package/dist/runtime/lib/realtime/durableObject.js +0 -187
- package/dist/runtime/lib/realtime/renderRealtimeClients.d.ts +0 -7
- package/dist/runtime/lib/realtime/renderRealtimeClients.js +0 -6
- package/dist/runtime/lib/realtime/shared.d.ts +0 -10
- package/dist/runtime/lib/realtime/shared.js +0 -10
- package/dist/runtime/lib/realtime/validateUpgradeRequest.d.ts +0 -6
- package/dist/runtime/lib/realtime/validateUpgradeRequest.js +0 -29
- package/dist/runtime/lib/realtime/worker.d.ts +0 -3
- package/dist/runtime/lib/realtime/worker.js +0 -16
- package/dist/runtime/lib/router.d.ts +0 -56
- package/dist/runtime/lib/router.js +0 -210
- package/dist/runtime/lib/router.test.d.ts +0 -1
- package/dist/runtime/lib/router.test.js +0 -58
- package/dist/runtime/lib/streams/consumeEventStream.d.ts +0 -4
- package/dist/runtime/lib/streams/consumeEventStream.js +0 -13
- package/dist/runtime/lib/turnstile/TurnstileScript.d.ts +0 -1
- package/dist/runtime/lib/turnstile/TurnstileScript.js +0 -2
- package/dist/runtime/lib/turnstile/turnstile.d.ts +0 -3
- package/dist/runtime/lib/turnstile/turnstile.js +0 -3
- package/dist/runtime/lib/turnstile/useTurnstile.d.ts +0 -4
- package/dist/runtime/lib/turnstile/useTurnstile.js +0 -23
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.d.ts +0 -4
- package/dist/runtime/lib/turnstile/verifyTurnstileToken.js +0 -15
- package/dist/runtime/lib/utils.d.ts +0 -1
- package/dist/runtime/lib/utils.js +0 -1
- package/dist/runtime/register/client.d.ts +0 -1
- package/dist/runtime/register/client.js +0 -5
- package/dist/runtime/register/ssr.d.ts +0 -3
- package/dist/runtime/register/ssr.js +0 -26
- package/dist/runtime/register/worker.d.ts +0 -4
- package/dist/runtime/register/worker.js +0 -42
- package/dist/runtime/render/createClientManifest.d.ts +0 -1
- package/dist/runtime/render/createClientManifest.js +0 -7
- package/dist/runtime/render/createModuleMap.d.ts +0 -1
- package/dist/runtime/render/createModuleMap.js +0 -13
- package/dist/runtime/render/renderRscThenableToHtmlStream.d.ts +0 -9
- package/dist/runtime/render/renderRscThenableToHtmlStream.js +0 -49
- package/dist/runtime/render/renderToRscStream.d.ts +0 -5
- package/dist/runtime/render/renderToRscStream.js +0 -46
- package/dist/runtime/render/renderToStream.d.ts +0 -9
- package/dist/runtime/render/renderToStream.js +0 -27
- package/dist/runtime/render/renderToString.d.ts +0 -7
- package/dist/runtime/render/renderToString.js +0 -26
- package/dist/runtime/render/transformRscToHtmlStream.d.ts +0 -8
- package/dist/runtime/render/transformRscToHtmlStream.js +0 -19
- package/dist/runtime/requestInfo/types.d.ts +0 -11
- package/dist/runtime/requestInfo/types.js +0 -1
- package/dist/runtime/requestInfo/worker.d.ts +0 -5
- package/dist/runtime/requestInfo/worker.js +0 -33
- package/dist/runtime/script.d.ts +0 -5
- package/dist/runtime/script.js +0 -8
- package/dist/runtime/ssrBridge.d.ts +0 -2
- package/dist/runtime/ssrBridge.js +0 -11
- package/dist/runtime/worker.d.ts +0 -18
- package/dist/runtime/worker.js +0 -173
- package/dist/scripts/__sdk.d.mts +0 -1
- package/dist/scripts/__sdk.mjs +0 -14
- package/dist/scripts/debug-sync.d.mts +0 -6
- package/dist/scripts/debug-sync.mjs +0 -224
- package/dist/scripts/dev-init.d.mts +0 -1
- package/dist/scripts/dev-init.mjs +0 -25
- package/dist/scripts/ensure-deploy-env.d.mts +0 -1
- package/dist/scripts/ensure-deploy-env.mjs +0 -271
- package/dist/scripts/ensure-env.d.mts +0 -1
- package/dist/scripts/ensure-env.mjs +0 -9
- package/dist/scripts/migrate-new.d.mts +0 -1
- package/dist/scripts/migrate-new.mjs +0 -51
- package/dist/scripts/smoke-test.d.mts +0 -1
- package/dist/scripts/smoke-test.mjs +0 -166
- package/dist/scripts/worker-run.d.mts +0 -1
- package/dist/scripts/worker-run.mjs +0 -82
- package/dist/vite/checkIsUsingPrisma.d.mts +0 -6
- package/dist/vite/checkIsUsingPrisma.mjs +0 -18
- package/dist/vite/configPlugin.d.mts +0 -9
- package/dist/vite/configPlugin.mjs +0 -169
- package/dist/vite/createDirectiveLookupPlugin.d.mts +0 -21
- package/dist/vite/createDirectiveLookupPlugin.mjs +0 -233
- package/dist/vite/devServerTimingPlugin.d.mts +0 -2
- package/dist/vite/devServerTimingPlugin.mjs +0 -24
- package/dist/vite/directivesPlugin.d.mts +0 -6
- package/dist/vite/directivesPlugin.mjs +0 -200
- package/dist/vite/ensureAliasArray.d.mts +0 -2
- package/dist/vite/ensureAliasArray.mjs +0 -17
- package/dist/vite/findSpecifiers.d.mts +0 -31
- package/dist/vite/findSpecifiers.mjs +0 -230
- package/dist/vite/findSsrSpecifiers.d.mts +0 -11
- package/dist/vite/findSsrSpecifiers.mjs +0 -51
- package/dist/vite/hasDirective.d.mts +0 -7
- package/dist/vite/hasDirective.mjs +0 -54
- package/dist/vite/hasOwnCloudflareVitePlugin.d.mts +0 -3
- package/dist/vite/hasOwnCloudflareVitePlugin.mjs +0 -14
- package/dist/vite/index.d.mts +0 -1
- package/dist/vite/index.mjs +0 -1
- package/dist/vite/injectVitePreamblePlugin.d.mts +0 -4
- package/dist/vite/injectVitePreamblePlugin.mjs +0 -23
- package/dist/vite/invalidateCacheIfPrismaClientChanged.d.mts +0 -3
- package/dist/vite/invalidateCacheIfPrismaClientChanged.mjs +0 -27
- package/dist/vite/invalidateModule.d.mts +0 -6
- package/dist/vite/invalidateModule.mjs +0 -30
- package/dist/vite/isJsFile.d.mts +0 -1
- package/dist/vite/isJsFile.mjs +0 -3
- package/dist/vite/miniflareHMRPlugin.d.mts +0 -10
- package/dist/vite/miniflareHMRPlugin.mjs +0 -171
- package/dist/vite/moveStaticAssetsPlugin.d.mts +0 -4
- package/dist/vite/moveStaticAssetsPlugin.mjs +0 -12
- package/dist/vite/normalizeModulePath.d.mts +0 -1
- package/dist/vite/normalizeModulePath.mjs +0 -13
- package/dist/vite/prismaPlugin.d.mts +0 -4
- package/dist/vite/prismaPlugin.mjs +0 -43
- package/dist/vite/reactConditionsResolverPlugin.d.mts +0 -16
- package/dist/vite/reactConditionsResolverPlugin.mjs +0 -179
- package/dist/vite/redwoodPlugin.d.mts +0 -12
- package/dist/vite/redwoodPlugin.mjs +0 -105
- package/dist/vite/ssrBridgePlugin.d.mts +0 -7
- package/dist/vite/ssrBridgePlugin.mjs +0 -124
- package/dist/vite/transformClientComponents.d.mts +0 -12
- package/dist/vite/transformClientComponents.mjs +0 -116
- package/dist/vite/transformClientComponents.test.d.mts +0 -1
- package/dist/vite/transformClientComponents.test.mjs +0 -264
- package/dist/vite/transformJsxScriptTagsPlugin.d.mts +0 -8
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +0 -315
- package/dist/vite/transformJsxScriptTagsPlugin.test.d.mts +0 -1
- package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +0 -334
- package/dist/vite/transformServerFunctions.d.mts +0 -16
- package/dist/vite/transformServerFunctions.mjs +0 -296
- package/dist/vite/transformServerFunctions.test.d.mts +0 -1
- package/dist/vite/transformServerFunctions.test.mjs +0 -124
- package/dist/vite/useClientLookupPlugin.d.mts +0 -5
- package/dist/vite/useClientLookupPlugin.mjs +0 -15
- package/dist/vite/useServerLookupPlugin.d.mts +0 -5
- package/dist/vite/useServerLookupPlugin.mjs +0 -15
- package/dist/vite/useServerPlugin.d.mts +0 -1
- package/dist/vite/useServerPlugin.mjs +0 -1
- package/dist/vite/virtualPlugin.d.mts +0 -2
- package/dist/vite/virtualPlugin.mjs +0 -18
- package/dist/vite/vitePreamblePlugin.d.mts +0 -1
- package/dist/vite/vitePreamblePlugin.mjs +0 -11
package/dist/runtime/client.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { clientWebpackRequire } from "./imports/client";
|
|
3
|
-
// NOTE: `react-server-dom-webpack` uses this global to load modules,
|
|
4
|
-
// so we need to define it here before importing "react-server-dom-webpack."
|
|
5
|
-
globalThis.__webpack_require__ = clientWebpackRequire;
|
|
6
|
-
export const fetchTransport = (transportContext) => {
|
|
7
|
-
const fetchCallServer = async (id, args) => {
|
|
8
|
-
const { createFromFetch, encodeReply } = await import("react-server-dom-webpack/client.browser");
|
|
9
|
-
const url = new URL(window.location.href);
|
|
10
|
-
url.searchParams.set("__rsc", "");
|
|
11
|
-
if (id != null) {
|
|
12
|
-
url.searchParams.set("__rsc_action_id", id);
|
|
13
|
-
}
|
|
14
|
-
const streamData = createFromFetch(fetch(url, {
|
|
15
|
-
method: "POST",
|
|
16
|
-
body: args != null ? await encodeReply(args) : null,
|
|
17
|
-
}), { callServer: fetchCallServer });
|
|
18
|
-
transportContext.setRscPayload(streamData);
|
|
19
|
-
const result = await streamData;
|
|
20
|
-
return result.actionResult;
|
|
21
|
-
};
|
|
22
|
-
return fetchCallServer;
|
|
23
|
-
};
|
|
24
|
-
export const initClient = async ({ transport = fetchTransport, hydrateRootOptions, } = {}) => {
|
|
25
|
-
const React = await import("react");
|
|
26
|
-
const { hydrateRoot } = await import("react-dom/client");
|
|
27
|
-
const transportContext = {
|
|
28
|
-
setRscPayload: () => { },
|
|
29
|
-
};
|
|
30
|
-
let transportCallServer = transport(transportContext);
|
|
31
|
-
const callServer = (id, args) => transportCallServer(id, args);
|
|
32
|
-
const upgradeToRealtime = async ({ key } = {}) => {
|
|
33
|
-
const { realtimeTransport } = await import("./lib/realtime/client");
|
|
34
|
-
const createRealtimeTransport = realtimeTransport({ key });
|
|
35
|
-
transportCallServer = createRealtimeTransport(transportContext);
|
|
36
|
-
};
|
|
37
|
-
globalThis.__rsc_callServer = callServer;
|
|
38
|
-
globalThis.__rw = {
|
|
39
|
-
callServer,
|
|
40
|
-
upgradeToRealtime,
|
|
41
|
-
};
|
|
42
|
-
const rootEl = document.getElementById("hydrate-root");
|
|
43
|
-
if (!rootEl) {
|
|
44
|
-
throw new Error('no element with id "hydrate-root"');
|
|
45
|
-
}
|
|
46
|
-
let rscPayload;
|
|
47
|
-
// context(justinvdm, 18 Jun 2025): We inject the RSC payload
|
|
48
|
-
// unless render(Document, [...], { rscPayload: false }) was used.
|
|
49
|
-
if (globalThis.__FLIGHT_DATA) {
|
|
50
|
-
const { createFromReadableStream } = await import("react-server-dom-webpack/client.browser");
|
|
51
|
-
const { rscStream } = await import("rsc-html-stream/client");
|
|
52
|
-
rscPayload = createFromReadableStream(rscStream, {
|
|
53
|
-
callServer,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function Content() {
|
|
57
|
-
const [streamData, setStreamData] = React.useState(rscPayload);
|
|
58
|
-
const [_isPending, startTransition] = React.useTransition();
|
|
59
|
-
transportContext.setRscPayload = (v) => startTransition(() => setStreamData(v));
|
|
60
|
-
return _jsx(_Fragment, { children: React.use(streamData).node });
|
|
61
|
-
}
|
|
62
|
-
hydrateRoot(rootEl, _jsx(Content, {}), {
|
|
63
|
-
onUncaughtError: (error, { componentStack }) => {
|
|
64
|
-
console.error("Uncaught error: %O\n\nComponent stack:%s", error, componentStack);
|
|
65
|
-
},
|
|
66
|
-
...hydrateRootOptions,
|
|
67
|
-
});
|
|
68
|
-
if (import.meta.hot) {
|
|
69
|
-
import.meta.hot.on("rsc:update", (e) => {
|
|
70
|
-
console.log("[rwsdk] hot update", e.file);
|
|
71
|
-
callServer("__rsc_hot_update", [e.file]);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export function validateClickEvent(event, target) {
|
|
2
|
-
// should this only work for left click?
|
|
3
|
-
if (event.button !== 0) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const link = target.closest("a");
|
|
10
|
-
if (!link) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
const href = link.getAttribute("href");
|
|
14
|
-
if (!href) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
// Skip if target="_blank" or similar
|
|
18
|
-
if (link.target && link.target !== "_self") {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
if (href.startsWith("http")) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
// Skip if download attribute
|
|
25
|
-
if (link.hasAttribute("download")) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
export function initClientNavigation(opts = {
|
|
31
|
-
onNavigate: async function onNavigate() {
|
|
32
|
-
// @ts-expect-error
|
|
33
|
-
await globalThis.__rsc_callServer();
|
|
34
|
-
},
|
|
35
|
-
}) {
|
|
36
|
-
// Intercept all anchor tag clicks
|
|
37
|
-
document.addEventListener("click", async function handleClickEvent(event) {
|
|
38
|
-
// Prevent default navigation
|
|
39
|
-
if (!validateClickEvent(event, event.target)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
const el = event.target;
|
|
44
|
-
const a = el.closest("a");
|
|
45
|
-
const href = a?.getAttribute("href");
|
|
46
|
-
window.history.pushState({ path: href }, "", window.location.origin + href);
|
|
47
|
-
await opts.onNavigate();
|
|
48
|
-
}, true);
|
|
49
|
-
// Handle browser back/forward buttons
|
|
50
|
-
window.addEventListener("popstate", async function handlePopState() {
|
|
51
|
-
await opts.onNavigate();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { validateClickEvent } from "./clientNavigation";
|
|
3
|
-
describe("clientNavigation", () => {
|
|
4
|
-
let mockEvent = {
|
|
5
|
-
button: 0, // right click
|
|
6
|
-
metaKey: false,
|
|
7
|
-
altKey: false,
|
|
8
|
-
shiftKey: false,
|
|
9
|
-
ctrlKey: false,
|
|
10
|
-
};
|
|
11
|
-
let mockTarget = {
|
|
12
|
-
closest: () => {
|
|
13
|
-
return {
|
|
14
|
-
getAttribute: () => "/test",
|
|
15
|
-
hasAttribute: () => false,
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
it("should return true", () => {
|
|
20
|
-
expect(validateClickEvent(mockEvent, mockTarget)).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
it("should return false if the event is not a left click", () => {
|
|
23
|
-
expect(validateClickEvent({ ...mockEvent, button: 1 }, mockTarget)).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
it("none of the modifier keys are pressed", () => {
|
|
26
|
-
expect(validateClickEvent({ ...mockEvent, metaKey: true }, mockTarget)).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
it("the target is not an anchor tag", () => {
|
|
29
|
-
expect(validateClickEvent(mockEvent, {
|
|
30
|
-
closest: () => undefined,
|
|
31
|
-
})).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
it("should have an href attribute", () => {
|
|
34
|
-
expect(validateClickEvent(mockEvent, {
|
|
35
|
-
closest: () => ({ getAttribute: () => undefined }),
|
|
36
|
-
})).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
it("should not have a target attribute", () => {
|
|
39
|
-
expect(validateClickEvent(mockEvent, {
|
|
40
|
-
closest: () => ({
|
|
41
|
-
target: "_blank",
|
|
42
|
-
getAttribute: () => "/test",
|
|
43
|
-
hasAttribute: () => false,
|
|
44
|
-
}),
|
|
45
|
-
})).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
it("should be a relative link", () => {
|
|
48
|
-
expect(validateClickEvent(mockEvent, {
|
|
49
|
-
closest: () => ({
|
|
50
|
-
getAttribute: () => "/test",
|
|
51
|
-
hasAttribute: () => false,
|
|
52
|
-
}),
|
|
53
|
-
})).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const IS_DEV: boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const IS_DEV = typeof import.meta.env !== "undefined" && import.meta.env.DEV;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../lib/auth";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../lib/auth";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../lib/streams/consumeEventStream";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../lib/streams/consumeEventStream";
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../register/ssr";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../register/ssr";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "../register/worker";
|
|
2
|
-
export * from "../worker";
|
|
3
|
-
export * from "../error";
|
|
4
|
-
export * from "../script";
|
|
5
|
-
export * from "../lib/utils";
|
|
6
|
-
export * from "../requestInfo/types";
|
|
7
|
-
export * from "../requestInfo/worker";
|
|
8
|
-
export * from "../render/renderToString";
|
|
9
|
-
export * from "../render/renderToStream";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "../register/worker";
|
|
2
|
-
export * from "../worker";
|
|
3
|
-
export * from "../error";
|
|
4
|
-
export * from "../script";
|
|
5
|
-
export * from "../lib/utils";
|
|
6
|
-
export * from "../requestInfo/types";
|
|
7
|
-
export * from "../requestInfo/worker";
|
|
8
|
-
export * from "../render/renderToString";
|
|
9
|
-
export * from "../render/renderToStream";
|
package/dist/runtime/error.d.ts
DELETED
package/dist/runtime/error.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import memoize from "lodash/memoize";
|
|
3
|
-
export const loadModule = memoize(async (id) => {
|
|
4
|
-
if (import.meta.env.DEV && !process.env.PREVIEW) {
|
|
5
|
-
return await import(/* @vite-ignore */ id);
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
const { useClientLookup } = await import("virtual:use-client-lookup");
|
|
9
|
-
const moduleFn = useClientLookup[id];
|
|
10
|
-
if (!moduleFn) {
|
|
11
|
-
throw new Error(`(client) No module found for '${id}' in module lookup for "use client" directive`);
|
|
12
|
-
}
|
|
13
|
-
return await moduleFn();
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
// context(justinvdm, 2 Dec 2024): re memoize(): React relies on the same promise instance being returned for the same id
|
|
17
|
-
export const clientWebpackRequire = memoize(async (id) => {
|
|
18
|
-
const [file, name] = id.split("#");
|
|
19
|
-
const promisedModule = loadModule(file);
|
|
20
|
-
const promisedComponent = promisedModule.then((module) => module[name]);
|
|
21
|
-
const didSSR = globalThis.__RWSDK_CONTEXT?.rw?.ssr;
|
|
22
|
-
if (didSSR) {
|
|
23
|
-
const awaitedComponent = await promisedComponent;
|
|
24
|
-
return { [id]: awaitedComponent };
|
|
25
|
-
}
|
|
26
|
-
const { ClientOnly } = await import("./ClientOnly");
|
|
27
|
-
const promisedDefault = promisedComponent.then((Component) => ({
|
|
28
|
-
default: Component,
|
|
29
|
-
}));
|
|
30
|
-
const Lazy = React.lazy(() => promisedDefault);
|
|
31
|
-
const Wrapped = () => React.createElement(ClientOnly, null, React.createElement(Lazy));
|
|
32
|
-
return { [id]: Wrapped };
|
|
33
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const ssrLoadModule: ((id: string) => Promise<any>) & import("lodash").MemoizedFunction;
|
|
2
|
-
export declare const ssrGetModuleExport: (id: string) => Promise<any>;
|
|
3
|
-
export declare const ssrWebpackRequire: ((id: string) => Promise<{
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
}>) & import("lodash").MemoizedFunction;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import memoize from "lodash/memoize";
|
|
2
|
-
export const ssrLoadModule = memoize(async (id) => {
|
|
3
|
-
const { useClientLookup } = await import("virtual:use-client-lookup");
|
|
4
|
-
const moduleFn = useClientLookup[id];
|
|
5
|
-
if (!moduleFn) {
|
|
6
|
-
throw new Error(`(ssr) No module found for '${id}' in module lookup for "use client" directive`);
|
|
7
|
-
}
|
|
8
|
-
return await moduleFn();
|
|
9
|
-
});
|
|
10
|
-
export const ssrGetModuleExport = async (id) => {
|
|
11
|
-
const [file, name] = id.split("#");
|
|
12
|
-
const module = await ssrLoadModule(file);
|
|
13
|
-
return module[name];
|
|
14
|
-
};
|
|
15
|
-
// context(justinvdm, 2 Dec 2024): re memoize(): React relies on the same promise instance being returned for the same id
|
|
16
|
-
export const ssrWebpackRequire = memoize(async (id) => {
|
|
17
|
-
const [file, name] = id.split("#");
|
|
18
|
-
const module = await ssrLoadModule(file);
|
|
19
|
-
return { [id]: module[name] };
|
|
20
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const loadServerModule: ((id: string) => Promise<any>) & import("lodash").MemoizedFunction;
|
|
2
|
-
export declare const getServerModuleExport: (id: string) => Promise<any>;
|
|
3
|
-
export declare const ssrWebpackRequire: ((id: string) => Promise<{
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
}>) & import("lodash").MemoizedFunction;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import memoize from "lodash/memoize";
|
|
2
|
-
import { requestInfo } from "../requestInfo/worker";
|
|
3
|
-
import { ssrWebpackRequire as baseSsrWebpackRequire } from "rwsdk/__ssr_bridge";
|
|
4
|
-
export const loadServerModule = memoize(async (id) => {
|
|
5
|
-
const { useServerLookup } = await import("virtual:use-server-lookup");
|
|
6
|
-
const moduleFn = useServerLookup[id];
|
|
7
|
-
if (!moduleFn) {
|
|
8
|
-
throw new Error(`(worker) No module found for '${id}' in module lookup for "use server" directive`);
|
|
9
|
-
}
|
|
10
|
-
return await moduleFn();
|
|
11
|
-
});
|
|
12
|
-
export const getServerModuleExport = async (id) => {
|
|
13
|
-
const [file, name] = id.split("#");
|
|
14
|
-
const module = await loadServerModule(file);
|
|
15
|
-
return module[name];
|
|
16
|
-
};
|
|
17
|
-
export const ssrWebpackRequire = memoize(async (id) => {
|
|
18
|
-
if (!requestInfo.rw.ssr) {
|
|
19
|
-
return { [id]: () => null };
|
|
20
|
-
}
|
|
21
|
-
return baseSsrWebpackRequire(id);
|
|
22
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./session";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./session";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export declare const MAX_SESSION_DURATION: number;
|
|
2
|
-
type GetSessionResult<Session> = {
|
|
3
|
-
value: Session;
|
|
4
|
-
} | {
|
|
5
|
-
error: string;
|
|
6
|
-
};
|
|
7
|
-
export interface DurableObjectMethods<Session, SessionInputData> extends Rpc.DurableObjectBranded {
|
|
8
|
-
getSession(): Promise<GetSessionResult<Session>>;
|
|
9
|
-
saveSession(data: SessionInputData): Promise<Session>;
|
|
10
|
-
revokeSession(): void;
|
|
11
|
-
}
|
|
12
|
-
export type SessionStore<Session, SessionInputData = Session> = ReturnType<typeof defineSessionStore<Session, SessionInputData>>;
|
|
13
|
-
export declare const createSessionCookie: ({ name, sessionId, maxAge, }: {
|
|
14
|
-
name: string;
|
|
15
|
-
sessionId: string;
|
|
16
|
-
maxAge?: number | true;
|
|
17
|
-
}) => string;
|
|
18
|
-
export declare const signSessionId: ({ unsignedSessionId, secretKey, }: {
|
|
19
|
-
unsignedSessionId: string;
|
|
20
|
-
secretKey: string;
|
|
21
|
-
}) => Promise<string>;
|
|
22
|
-
export declare const generateSessionId: ({ secretKey, }: {
|
|
23
|
-
secretKey: string;
|
|
24
|
-
}) => Promise<string>;
|
|
25
|
-
export declare const isValidSessionId: ({ sessionId, secretKey, }: {
|
|
26
|
-
sessionId: string;
|
|
27
|
-
secretKey: string;
|
|
28
|
-
}) => Promise<boolean>;
|
|
29
|
-
export declare const defineSessionStore: <Session, SessionInputData>({ cookieName, createCookie, secretKey, get, set, unset, }: {
|
|
30
|
-
cookieName?: string;
|
|
31
|
-
createCookie?: typeof createSessionCookie;
|
|
32
|
-
secretKey?: string;
|
|
33
|
-
get: (sessionId: string) => Promise<Session>;
|
|
34
|
-
set: (sessionId: string, sessionInputData: SessionInputData) => Promise<void>;
|
|
35
|
-
unset: (sessionId: string) => Promise<void>;
|
|
36
|
-
}) => {
|
|
37
|
-
load: (request: Request) => Promise<Session | null>;
|
|
38
|
-
save: (headers: Headers, sessionInputData: SessionInputData, { maxAge }?: {
|
|
39
|
-
maxAge?: number | true;
|
|
40
|
-
}) => Promise<void>;
|
|
41
|
-
remove: (request: Request, headers: Headers) => Promise<void>;
|
|
42
|
-
};
|
|
43
|
-
type SessionStoreFromDurableObject<SessionDurableObject> = SessionDurableObject extends DurableObjectMethods<infer Session, infer SessionInputData> ? SessionStore<Session, SessionInputData> : never;
|
|
44
|
-
export declare const defineDurableSession: <SessionDurableObject extends DurableObjectMethods<any, any>>({ cookieName, createCookie, secretKey, sessionDurableObject, }: {
|
|
45
|
-
cookieName?: string;
|
|
46
|
-
createCookie?: typeof createSessionCookie;
|
|
47
|
-
secretKey?: string;
|
|
48
|
-
sessionDurableObject: DurableObjectNamespace<SessionDurableObject>;
|
|
49
|
-
}) => SessionStoreFromDurableObject<SessionDurableObject>;
|
|
50
|
-
export {};
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from "../../error";
|
|
2
|
-
import { IS_DEV } from "../../constants";
|
|
3
|
-
import { env } from "cloudflare:workers";
|
|
4
|
-
const AUTH_SECRET_KEY = env.AUTH_SECRET_KEY ??
|
|
5
|
-
(IS_DEV ? "development-secret-key-do-not-use-in-production" : undefined);
|
|
6
|
-
if (AUTH_SECRET_KEY === "") {
|
|
7
|
-
console.warn("AUTH_SECRET_KEY is set but empty. Please provide a non-empty secret key for session store security.");
|
|
8
|
-
}
|
|
9
|
-
if (!AUTH_SECRET_KEY) {
|
|
10
|
-
console.warn("AUTH_SECRET_KEY not set. Please set this environment variable to a secure random key for session store security.");
|
|
11
|
-
}
|
|
12
|
-
export const MAX_SESSION_DURATION = 14 * 24 * 60 * 60 * 1000; // 14 days
|
|
13
|
-
const packSessionId = (parts) => {
|
|
14
|
-
return btoa([parts.unsignedSessionId, parts.signature].join(":"));
|
|
15
|
-
};
|
|
16
|
-
const unpackSessionId = (packed) => {
|
|
17
|
-
const [unsignedSessionId, signature] = atob(packed).split(":");
|
|
18
|
-
return { unsignedSessionId, signature };
|
|
19
|
-
};
|
|
20
|
-
const arrayBufferToHex = (buffer) => {
|
|
21
|
-
const array = new Uint8Array(buffer);
|
|
22
|
-
return Array.from(array)
|
|
23
|
-
.map((b) => b.toString(16).padStart(2, "0"))
|
|
24
|
-
.join("");
|
|
25
|
-
};
|
|
26
|
-
export const createSessionCookie = ({ name, sessionId, maxAge, }) => {
|
|
27
|
-
const isViteDev = typeof import.meta.env !== "undefined" && import.meta.env.DEV;
|
|
28
|
-
return `${name}=${sessionId}; Path=/; HttpOnly; ${isViteDev ? "" : "Secure; "}SameSite=Lax${maxAge != null
|
|
29
|
-
? `; Max-Age=${maxAge === true ? MAX_SESSION_DURATION / 1000 : maxAge}`
|
|
30
|
-
: ""}`;
|
|
31
|
-
};
|
|
32
|
-
export const signSessionId = async ({ unsignedSessionId, secretKey, }) => {
|
|
33
|
-
const encoder = new TextEncoder();
|
|
34
|
-
const key = await crypto.subtle.importKey("raw", encoder.encode(secretKey), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
35
|
-
const signatureArrayBuffer = await crypto.subtle.sign("HMAC", key, encoder.encode(unsignedSessionId));
|
|
36
|
-
return arrayBufferToHex(signatureArrayBuffer);
|
|
37
|
-
};
|
|
38
|
-
export const generateSessionId = async ({ secretKey, }) => {
|
|
39
|
-
const unsignedSessionId = crypto.randomUUID();
|
|
40
|
-
const signature = await signSessionId({ unsignedSessionId, secretKey });
|
|
41
|
-
return packSessionId({ unsignedSessionId, signature });
|
|
42
|
-
};
|
|
43
|
-
export const isValidSessionId = async ({ sessionId, secretKey, }) => {
|
|
44
|
-
try {
|
|
45
|
-
const { unsignedSessionId, signature } = unpackSessionId(sessionId);
|
|
46
|
-
const computedSignature = await signSessionId({
|
|
47
|
-
unsignedSessionId,
|
|
48
|
-
secretKey,
|
|
49
|
-
});
|
|
50
|
-
return computedSignature === signature;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
export const defineSessionStore = ({ cookieName = "session_id", createCookie = createSessionCookie, secretKey = AUTH_SECRET_KEY, get, set, unset, }) => {
|
|
57
|
-
if (!secretKey) {
|
|
58
|
-
throw new Error("No secret key provided for session store");
|
|
59
|
-
}
|
|
60
|
-
const getSessionIdFromCookie = (request) => {
|
|
61
|
-
const cookieHeader = request.headers.get("Cookie");
|
|
62
|
-
if (!cookieHeader)
|
|
63
|
-
return undefined;
|
|
64
|
-
for (const cookie of cookieHeader.split(";")) {
|
|
65
|
-
const trimmedCookie = cookie.trim();
|
|
66
|
-
const separatorIndex = trimmedCookie.indexOf("=");
|
|
67
|
-
if (separatorIndex === -1)
|
|
68
|
-
continue;
|
|
69
|
-
const key = trimmedCookie.slice(0, separatorIndex);
|
|
70
|
-
const value = trimmedCookie.slice(separatorIndex + 1);
|
|
71
|
-
if (key === cookieName) {
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const load = async (request) => {
|
|
77
|
-
const sessionId = getSessionIdFromCookie(request);
|
|
78
|
-
if (!sessionId) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
if (!(await isValidSessionId({ sessionId, secretKey }))) {
|
|
82
|
-
throw new ErrorResponse(401, "Invalid session id");
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
return await get(sessionId);
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
throw new ErrorResponse(401, "Invalid session id");
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const save = async (headers, sessionInputData, { maxAge } = {}) => {
|
|
92
|
-
const sessionId = await generateSessionId({ secretKey });
|
|
93
|
-
await set(sessionId, sessionInputData);
|
|
94
|
-
headers.set("Set-Cookie", createCookie({ name: cookieName, sessionId, maxAge }));
|
|
95
|
-
};
|
|
96
|
-
const remove = async (request, headers) => {
|
|
97
|
-
const sessionId = getSessionIdFromCookie(request);
|
|
98
|
-
if (sessionId) {
|
|
99
|
-
await unset(sessionId);
|
|
100
|
-
}
|
|
101
|
-
headers.set("Set-Cookie", createCookie({ name: cookieName, sessionId: "", maxAge: 0 }));
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
104
|
-
load,
|
|
105
|
-
save,
|
|
106
|
-
remove,
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
export const defineDurableSession = ({ cookieName, createCookie, secretKey = AUTH_SECRET_KEY, sessionDurableObject, }) => {
|
|
110
|
-
const get = async (sessionId) => {
|
|
111
|
-
const { unsignedSessionId } = unpackSessionId(sessionId);
|
|
112
|
-
const doId = sessionDurableObject.idFromName(unsignedSessionId);
|
|
113
|
-
const sessionStub = sessionDurableObject.get(doId);
|
|
114
|
-
const result = (await sessionStub.getSession());
|
|
115
|
-
if ("error" in result) {
|
|
116
|
-
throw new Error(result.error);
|
|
117
|
-
}
|
|
118
|
-
return result.value;
|
|
119
|
-
};
|
|
120
|
-
const set = async (sessionId, sessionInputData) => {
|
|
121
|
-
const { unsignedSessionId } = unpackSessionId(sessionId);
|
|
122
|
-
const doId = sessionDurableObject.idFromName(unsignedSessionId);
|
|
123
|
-
const sessionStub = sessionDurableObject.get(doId);
|
|
124
|
-
// todo(justinvdm, 2025-02-20): Fix this
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
await sessionStub.saveSession(sessionInputData);
|
|
127
|
-
};
|
|
128
|
-
const unset = async (sessionId) => {
|
|
129
|
-
let unsignedSessionId;
|
|
130
|
-
try {
|
|
131
|
-
unsignedSessionId = unpackSessionId(sessionId).unsignedSessionId;
|
|
132
|
-
}
|
|
133
|
-
catch {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const doId = sessionDurableObject.idFromName(unsignedSessionId);
|
|
137
|
-
const sessionStub = sessionDurableObject.get(doId);
|
|
138
|
-
await sessionStub.revokeSession();
|
|
139
|
-
};
|
|
140
|
-
return defineSessionStore({
|
|
141
|
-
cookieName,
|
|
142
|
-
createCookie,
|
|
143
|
-
secretKey,
|
|
144
|
-
get,
|
|
145
|
-
set,
|
|
146
|
-
unset,
|
|
147
|
-
});
|
|
148
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler, Driver, DatabaseConnection } from "kysely";
|
|
2
|
-
export declare class DOWorkerDialect {
|
|
3
|
-
config: {
|
|
4
|
-
stub: any;
|
|
5
|
-
};
|
|
6
|
-
constructor(config: {
|
|
7
|
-
stub: any;
|
|
8
|
-
});
|
|
9
|
-
createAdapter(): SqliteAdapter;
|
|
10
|
-
createDriver(): DOWorkerDriver;
|
|
11
|
-
createQueryCompiler(): SqliteQueryCompiler;
|
|
12
|
-
createIntrospector(db: any): SqliteIntrospector;
|
|
13
|
-
}
|
|
14
|
-
declare class DOWorkerDriver implements Driver {
|
|
15
|
-
config: {
|
|
16
|
-
stub: any;
|
|
17
|
-
};
|
|
18
|
-
constructor(config: {
|
|
19
|
-
stub: any;
|
|
20
|
-
});
|
|
21
|
-
init(): Promise<void>;
|
|
22
|
-
acquireConnection(): Promise<DatabaseConnection>;
|
|
23
|
-
beginTransaction(conn: any): Promise<any>;
|
|
24
|
-
commitTransaction(conn: any): Promise<any>;
|
|
25
|
-
rollbackTransaction(conn: any): Promise<any>;
|
|
26
|
-
releaseConnection(_conn: any): Promise<void>;
|
|
27
|
-
destroy(): Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
export {};
|