rwsdk 0.2.0 → 0.3.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.
- package/dist/lib/constants.d.mts +6 -1
- package/dist/lib/constants.mjs +6 -1
- package/dist/lib/smokeTests/browser.mjs +5 -21
- package/dist/lib/smokeTests/codeUpdates.d.mts +1 -1
- package/dist/lib/smokeTests/codeUpdates.mjs +41 -5
- package/dist/lib/smokeTests/development.d.mts +1 -1
- package/dist/lib/smokeTests/development.mjs +4 -10
- package/dist/lib/smokeTests/release.d.mts +1 -1
- package/dist/lib/smokeTests/release.mjs +4 -9
- package/dist/lib/smokeTests/runSmokeTests.mjs +2 -2
- package/dist/lib/smokeTests/templates/SmokeTest.template.js +3 -2
- package/dist/lib/testUtils/stubEnvVars.d.mts +2 -0
- package/dist/lib/testUtils/stubEnvVars.mjs +11 -0
- package/dist/runtime/imports/client.js +4 -9
- package/dist/runtime/imports/worker.js +2 -1
- package/dist/runtime/register/ssr.js +2 -1
- package/dist/runtime/requestInfo/worker.js +9 -1
- package/dist/runtime/worker.d.ts +0 -3
- package/dist/runtime/worker.js +1 -10
- package/dist/scripts/debug-sync.mjs +0 -23
- package/dist/scripts/smoke-test.mjs +0 -10
- package/dist/vite/buildApp.d.mts +15 -0
- package/dist/vite/buildApp.mjs +53 -0
- package/dist/vite/configPlugin.d.mts +4 -4
- package/dist/vite/configPlugin.mjs +70 -76
- package/dist/vite/constants.d.mts +2 -0
- package/dist/vite/constants.mjs +12 -0
- package/dist/vite/createDirectiveLookupPlugin.d.mts +0 -6
- package/dist/vite/createDirectiveLookupPlugin.mjs +69 -145
- package/dist/vite/createViteAwareResolver.d.mts +4 -0
- package/dist/vite/createViteAwareResolver.mjs +208 -0
- package/dist/vite/directiveModulesDevPlugin.d.mts +8 -0
- package/dist/vite/directiveModulesDevPlugin.mjs +87 -0
- package/dist/vite/directivesFilteringPlugin.d.mts +6 -0
- package/dist/vite/directivesFilteringPlugin.mjs +31 -0
- package/dist/vite/directivesPlugin.mjs +32 -42
- package/dist/vite/getViteEsbuild.d.mts +1 -0
- package/dist/vite/getViteEsbuild.mjs +12 -0
- package/dist/vite/injectVitePreamblePlugin.d.mts +3 -2
- package/dist/vite/injectVitePreamblePlugin.mjs +8 -2
- package/dist/vite/linkerPlugin.d.mts +4 -0
- package/dist/vite/linkerPlugin.mjs +41 -0
- package/dist/vite/manifestPlugin.d.mts +2 -2
- package/dist/vite/manifestPlugin.mjs +20 -37
- package/dist/vite/moveStaticAssetsPlugin.mjs +2 -1
- package/dist/vite/prismaPlugin.mjs +1 -1
- package/dist/vite/reactConditionsResolverPlugin.mjs +15 -16
- package/dist/vite/redwoodPlugin.d.mts +0 -1
- package/dist/vite/redwoodPlugin.mjs +27 -9
- package/dist/vite/runDirectivesScan.d.mts +7 -0
- package/dist/vite/runDirectivesScan.mjs +156 -0
- package/dist/vite/ssrBridgePlugin.mjs +21 -14
- package/dist/vite/transformClientComponents.d.mts +0 -1
- package/dist/vite/transformClientComponents.mjs +1 -9
- package/dist/vite/transformJsxScriptTagsPlugin.d.mts +4 -3
- package/dist/vite/transformJsxScriptTagsPlugin.mjs +66 -84
- package/dist/vite/transformJsxScriptTagsPlugin.test.mjs +67 -41
- package/dist/vite/transformServerFunctions.d.mts +1 -1
- package/dist/vite/transformServerFunctions.mjs +11 -12
- package/dist/vite/virtualPlugin.mjs +8 -0
- package/package.json +7 -1
- package/dist/runtime/clientNavigation.d.ts +0 -9
- package/dist/runtime/clientNavigation.js +0 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rwsdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
"types": "./dist/runtime/ssrBridge.d.ts",
|
|
46
46
|
"default": "./dist/runtime/ssrBridge.js"
|
|
47
47
|
},
|
|
48
|
+
"./__client_barrel": {
|
|
49
|
+
"default": "./dist/__intermediate_builds/rwsdk-client-barrel.js"
|
|
50
|
+
},
|
|
51
|
+
"./__server_barrel": {
|
|
52
|
+
"default": "./dist/__intermediate_builds/rwsdk-server-barrel.js"
|
|
53
|
+
},
|
|
48
54
|
"./router": {
|
|
49
55
|
"types": "./dist/runtime/entries/router.d.ts",
|
|
50
56
|
"default": "./dist/runtime/entries/router.js"
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface ClientNavigationOptions {
|
|
2
|
-
onNavigate?: () => void;
|
|
3
|
-
scrollToTop?: boolean;
|
|
4
|
-
scrollBehavior?: "auto" | "smooth" | "instant";
|
|
5
|
-
}
|
|
6
|
-
export declare function validateClickEvent(event: MouseEvent, target: HTMLElement): boolean;
|
|
7
|
-
export declare function initClientNavigation(opts?: ClientNavigationOptions): {
|
|
8
|
-
handleResponse: (response: Response) => boolean;
|
|
9
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
function saveScrollPosition(x, y) {
|
|
2
|
-
window.history.replaceState({
|
|
3
|
-
...window.history.state,
|
|
4
|
-
scrollX: x,
|
|
5
|
-
scrollY: y,
|
|
6
|
-
}, "", window.location.href);
|
|
7
|
-
}
|
|
8
|
-
export function validateClickEvent(event, target) {
|
|
9
|
-
// should this only work for left click?
|
|
10
|
-
if (event.button !== 0) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
const link = target.closest("a");
|
|
17
|
-
if (!link) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
const href = link.getAttribute("href");
|
|
21
|
-
if (!href) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (href.includes("#")) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
// Skip if target="_blank" or similar
|
|
28
|
-
if (link.target && link.target !== "_self") {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
if (href.startsWith("http")) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
// Skip if download attribute
|
|
35
|
-
if (link.hasAttribute("download")) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
export function initClientNavigation(opts = {}) {
|
|
41
|
-
const options = {
|
|
42
|
-
onNavigate: async function onNavigate() {
|
|
43
|
-
// @ts-expect-error
|
|
44
|
-
await globalThis.__rsc_callServer();
|
|
45
|
-
},
|
|
46
|
-
scrollToTop: true,
|
|
47
|
-
scrollBehavior: "instant",
|
|
48
|
-
...opts,
|
|
49
|
-
};
|
|
50
|
-
history.scrollRestoration = "auto";
|
|
51
|
-
document.addEventListener("click", async function handleClickEvent(event) {
|
|
52
|
-
// Prevent default navigation
|
|
53
|
-
if (!validateClickEvent(event, event.target)) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
const el = event.target;
|
|
58
|
-
const a = el.closest("a");
|
|
59
|
-
const href = a?.getAttribute("href");
|
|
60
|
-
saveScrollPosition(window.scrollX, window.scrollY);
|
|
61
|
-
window.history.pushState({ path: href }, "", window.location.origin + href);
|
|
62
|
-
await options.onNavigate();
|
|
63
|
-
if (options.scrollToTop && history.scrollRestoration === "auto") {
|
|
64
|
-
window.scrollTo({
|
|
65
|
-
top: 0,
|
|
66
|
-
left: 0,
|
|
67
|
-
behavior: options.scrollBehavior,
|
|
68
|
-
});
|
|
69
|
-
saveScrollPosition(0, 0);
|
|
70
|
-
}
|
|
71
|
-
history.scrollRestoration = "auto";
|
|
72
|
-
}, true);
|
|
73
|
-
window.addEventListener("popstate", async function handlePopState() {
|
|
74
|
-
saveScrollPosition(window.scrollX, window.scrollY);
|
|
75
|
-
await options.onNavigate();
|
|
76
|
-
});
|
|
77
|
-
// Return a handleResponse function for use with initClient
|
|
78
|
-
return {
|
|
79
|
-
handleResponse: function handleResponse(response) {
|
|
80
|
-
if (!response.ok) {
|
|
81
|
-
// Redirect to the current page (window.location) to show the error
|
|
82
|
-
window.location.href = window.location.href;
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return true;
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|