rwsdk 0.3.5 → 0.3.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/runtime/client/client.js +1 -0
- package/dist/runtime/entries/worker.d.ts +1 -0
- package/dist/runtime/entries/worker.js +1 -0
- package/dist/runtime/imports/resolveSSRValue.d.ts +1 -0
- package/dist/runtime/imports/resolveSSRValue.js +8 -0
- package/dist/runtime/register/worker.js +1 -0
- package/dist/vite/transformClientComponents.mjs +3 -0
- package/dist/vite/transformClientComponents.test.mjs +57 -0
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ export const fetchTransport = (transportContext) => {
|
|
|
20
20
|
}
|
|
21
21
|
const fetchPromise = fetch(url, {
|
|
22
22
|
method: "POST",
|
|
23
|
+
redirect: "manual",
|
|
23
24
|
body: args != null ? await encodeReply(args) : null,
|
|
24
25
|
});
|
|
25
26
|
// If there's a response handler, check the response first
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveSSRValue: <Value>(clientReference: Value) => Promise<Value>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ssrGetModuleExport } from "rwsdk/__ssr_bridge";
|
|
2
|
+
export const resolveSSRValue = (clientReference) => {
|
|
3
|
+
const id = clientReference.__rwsdk_clientReferenceId;
|
|
4
|
+
if (!id) {
|
|
5
|
+
throw new Error("RWSDK: Client reference is not a client reference");
|
|
6
|
+
}
|
|
7
|
+
return ssrGetModuleExport(id);
|
|
8
|
+
};
|
|
@@ -13,6 +13,7 @@ export function registerClientReference(id, exportName, value) {
|
|
|
13
13
|
? value
|
|
14
14
|
: () => null;
|
|
15
15
|
const reference = baseRegisterClientReference({}, id, exportName);
|
|
16
|
+
reference.__rwsdk_clientReferenceId = `${id}#${exportName}`;
|
|
16
17
|
const finalDescriptors = Object.getOwnPropertyDescriptors(reference);
|
|
17
18
|
const idDescriptor = finalDescriptors.$$id;
|
|
18
19
|
if (idDescriptor && idDescriptor.hasOwnProperty("value")) {
|
|
@@ -32,6 +32,9 @@ export async function transformClientComponents(code, normalizedId, ctx) {
|
|
|
32
32
|
// - local: "MyComponent" (the original name)
|
|
33
33
|
// - exported: "CustomName" (the alias name)
|
|
34
34
|
// - alias: "CustomName" (to generate MyComponent_CustomName)
|
|
35
|
+
if (!exportInfo.name) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
35
38
|
const hasAlias = exportInfo.alias && exportInfo.originalName;
|
|
36
39
|
processedExports.push({
|
|
37
40
|
local: exportInfo.originalName || exportInfo.name, // Use originalName if available
|
|
@@ -243,6 +243,63 @@ export { Slot, Slot as Root }
|
|
|
243
243
|
const Slot = registerClientReference("/test/file.tsx", "Slot");
|
|
244
244
|
const Slot_Root = registerClientReference("/test/file.tsx", "Root");
|
|
245
245
|
export { Slot, Slot_Root as Root };
|
|
246
|
+
`);
|
|
247
|
+
});
|
|
248
|
+
it("handles a large number of named exports from a single module", async () => {
|
|
249
|
+
const code = `"use client";
|
|
250
|
+
import * as React from "react";
|
|
251
|
+
const SidebarContext = React.createContext(null);
|
|
252
|
+
function SidebarProvider() { return jsx("div", {}); }
|
|
253
|
+
function useSidebar() {}
|
|
254
|
+
function Sidebar() { return jsx("div", {}); }
|
|
255
|
+
function SidebarTrigger() { return jsx("div", {}); }
|
|
256
|
+
function SidebarRail() { return jsx("div", {}); }
|
|
257
|
+
function SidebarInset() { return jsx("div", {}); }
|
|
258
|
+
function SidebarInput() { return jsx("div", {}); }
|
|
259
|
+
function SidebarHeader() { return jsx("div", {}); }
|
|
260
|
+
function SidebarFooter() { return jsx("div", {}); }
|
|
261
|
+
function SidebarSeparator() { return jsx("div", {}); }
|
|
262
|
+
function SidebarContent() { return jsx("div", {}); }
|
|
263
|
+
function SidebarGroup() { return jsx("div", {}); }
|
|
264
|
+
function SidebarGroupLabel() { return jsx("div", {}); }
|
|
265
|
+
function SidebarGroupAction() { return jsx("div", {}); }
|
|
266
|
+
function SidebarGroupContent() { return jsx("div", {}); }
|
|
267
|
+
function SidebarMenu() { return jsx("div", {}); }
|
|
268
|
+
function SidebarMenuItem() { return jsx("div", {}); }
|
|
269
|
+
function SidebarMenuButton() { return jsx("div", {}); }
|
|
270
|
+
function SidebarMenuAction() { return jsx("div", {}); }
|
|
271
|
+
function SidebarMenuBadge() { return jsx("div", {}); }
|
|
272
|
+
function SidebarMenuSkeleton() { return jsx("div", {}); }
|
|
273
|
+
function SidebarMenuSub() { return jsx("div", {}); }
|
|
274
|
+
function SidebarMenuSubItem() { return jsx("div", {}); }
|
|
275
|
+
function SidebarMenuSubButton() { return jsx("div", {}); }
|
|
276
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };`;
|
|
277
|
+
expect((await transform(code)) ?? "").toEqual(`import { registerClientReference } from "rwsdk/worker";
|
|
278
|
+
const Sidebar = registerClientReference("/test/file.tsx", "Sidebar");
|
|
279
|
+
const SidebarContent = registerClientReference("/test/file.tsx", "SidebarContent");
|
|
280
|
+
const SidebarFooter = registerClientReference("/test/file.tsx", "SidebarFooter");
|
|
281
|
+
const SidebarGroup = registerClientReference("/test/file.tsx", "SidebarGroup");
|
|
282
|
+
const SidebarGroupAction = registerClientReference("/test/file.tsx", "SidebarGroupAction");
|
|
283
|
+
const SidebarGroupContent = registerClientReference("/test/file.tsx", "SidebarGroupContent");
|
|
284
|
+
const SidebarGroupLabel = registerClientReference("/test/file.tsx", "SidebarGroupLabel");
|
|
285
|
+
const SidebarHeader = registerClientReference("/test/file.tsx", "SidebarHeader");
|
|
286
|
+
const SidebarInput = registerClientReference("/test/file.tsx", "SidebarInput");
|
|
287
|
+
const SidebarInset = registerClientReference("/test/file.tsx", "SidebarInset");
|
|
288
|
+
const SidebarMenu = registerClientReference("/test/file.tsx", "SidebarMenu");
|
|
289
|
+
const SidebarMenuAction = registerClientReference("/test/file.tsx", "SidebarMenuAction");
|
|
290
|
+
const SidebarMenuBadge = registerClientReference("/test/file.tsx", "SidebarMenuBadge");
|
|
291
|
+
const SidebarMenuButton = registerClientReference("/test/file.tsx", "SidebarMenuButton");
|
|
292
|
+
const SidebarMenuItem = registerClientReference("/test/file.tsx", "SidebarMenuItem");
|
|
293
|
+
const SidebarMenuSkeleton = registerClientReference("/test/file.tsx", "SidebarMenuSkeleton");
|
|
294
|
+
const SidebarMenuSub = registerClientReference("/test/file.tsx", "SidebarMenuSub");
|
|
295
|
+
const SidebarMenuSubButton = registerClientReference("/test/file.tsx", "SidebarMenuSubButton");
|
|
296
|
+
const SidebarMenuSubItem = registerClientReference("/test/file.tsx", "SidebarMenuSubItem");
|
|
297
|
+
const SidebarProvider = registerClientReference("/test/file.tsx", "SidebarProvider");
|
|
298
|
+
const SidebarRail = registerClientReference("/test/file.tsx", "SidebarRail");
|
|
299
|
+
const SidebarSeparator = registerClientReference("/test/file.tsx", "SidebarSeparator");
|
|
300
|
+
const SidebarTrigger = registerClientReference("/test/file.tsx", "SidebarTrigger");
|
|
301
|
+
const useSidebar = registerClientReference("/test/file.tsx", "useSidebar");
|
|
302
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|
|
246
303
|
`);
|
|
247
304
|
});
|
|
248
305
|
});
|