@anaemia/core 0.0.1 → 0.1.0
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/config.d.ts +3 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/plugins/lightningcss.d.ts.map +1 -1
- package/dist/plugins/lightningcss.js +1 -2
- package/dist/runtime/context.browser.d.ts.map +1 -1
- package/dist/runtime/context.browser.js +3 -1
- package/dist/runtime/context.d.ts +5 -4
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/entry-client.jsx +1 -1
- package/dist/runtime/entry-server.d.ts.map +1 -1
- package/dist/runtime/entry-server.jsx +18 -29
- package/dist/runtime/resources.d.ts +1 -1
- package/dist/runtime/resources.d.ts.map +1 -1
- package/dist/runtime/resources.js +5 -3
- package/dist/runtime/route-data.d.ts +7 -6
- package/dist/runtime/route-data.d.ts.map +1 -1
- package/dist/runtime/route-data.js +5 -8
- package/dist/runtime/route-request.d.ts +1 -1
- package/dist/runtime/route-request.d.ts.map +1 -1
- package/dist/runtime/route-request.js +2 -1
- package/dist/runtime/rpc-client.d.ts +2 -2
- package/dist/runtime/rpc-client.d.ts.map +1 -1
- package/dist/runtime/rpc-client.js +12 -11
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/config.ts +3 -2
- package/src/index.ts +1 -6
- package/src/plugins/lightningcss.ts +7 -3
- package/src/runtime/context.browser.ts +3 -2
- package/src/runtime/context.ts +8 -13
- package/src/runtime/entry-client.tsx +1 -1
- package/src/runtime/entry-server.tsx +47 -47
- package/src/runtime/resources.ts +28 -16
- package/src/runtime/route-data.ts +24 -36
- package/src/runtime/route-request.ts +5 -4
- package/src/runtime/rpc-client.ts +44 -24
- package/src/runtime/webpack.d.ts +1 -1
- package/src/types.ts +7 -2
- package/test/integration/hmr.test.mjs +16 -22
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import type { Configuration } from "@rspack/core";
|
|
3
|
+
import type { PluginItem } from "@babel/core";
|
|
3
4
|
export interface AnaemiaPlugin {
|
|
4
5
|
/**
|
|
5
6
|
* unique identifier for the plugin.
|
|
@@ -17,8 +18,8 @@ export interface AnaemiaPlugin {
|
|
|
17
18
|
* add additional babel plugins to the client transform pipeline.
|
|
18
19
|
*/
|
|
19
20
|
babelPlugins?: {
|
|
20
|
-
client?:
|
|
21
|
-
server?:
|
|
21
|
+
client?: PluginItem[];
|
|
22
|
+
server?: PluginItem[];
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
24
25
|
* hook into the Hono app instance to register additional routes or middleware.
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,aAAa,CAAC;IAE9D;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,aAAa,CAAC;IAE9D;;OAEG;IACH,YAAY,CAAC,EAAE;QACb,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;QACtB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;KACvB,CAAC;IAEF;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;IAEtC;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,YAAY,CAAC,EAAE;QACb,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC;IAEF;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAE1B;;;;;;;;MAQE;IACF,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC,CAAC;CACH;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAEjE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,5 @@ export { runOnServer } from "./runtime/context.js";
|
|
|
3
3
|
export { RouteDataController, useRouteData } from "./runtime/route-data.js";
|
|
4
4
|
export { $$executeClientRpc } from "./runtime/rpc-client.js";
|
|
5
5
|
export { createServerResource } from "./runtime/resources.js";
|
|
6
|
-
export type
|
|
7
|
-
id?: string;
|
|
8
|
-
urlId?: string;
|
|
9
|
-
};
|
|
10
|
-
export type { LoaderArgs, LoaderFunction, InferServerData, GuardContext, GuardResult, GuardFn } from "./types.js";
|
|
6
|
+
export type { LoaderArgs, LoaderFunction, InferServerData, GuardContext, GuardResult, GuardFn, ServerFunction } from "./types.js";
|
|
11
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightningcss.d.ts","sourceRoot":"","sources":["../../src/plugins/lightningcss.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"lightningcss.d.ts","sourceRoot":"","sources":["../../src/plugins/lightningcss.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOlD,wBAAgB,yBAAyB,CAAC,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG,aAAa,CA6ElG"}
|
|
@@ -6,7 +6,7 @@ export function anaemiaLightningCssPlugin(options = {}) {
|
|
|
6
6
|
try {
|
|
7
7
|
rspackModule = localRequire("@rspack/core");
|
|
8
8
|
}
|
|
9
|
-
catch
|
|
9
|
+
catch {
|
|
10
10
|
throw new Error("[anaemia] The LightningCSS plugin requires '@rspack/core' to be available in the execution workspace.");
|
|
11
11
|
}
|
|
12
12
|
return {
|
|
@@ -36,7 +36,6 @@ export function anaemiaLightningCssPlugin(options = {}) {
|
|
|
36
36
|
minimize: true,
|
|
37
37
|
minimizer: [
|
|
38
38
|
...(config.optimization?.minimizer ?? []),
|
|
39
|
-
// Native Rust CSS minification engine
|
|
40
39
|
new rspackModule.LightningCssMinimizerRspackPlugin({
|
|
41
40
|
minimizerOptions: { targets },
|
|
42
41
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.browser.d.ts","sourceRoot":"","sources":["../../src/runtime/context.browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.browser.d.ts","sourceRoot":"","sources":["../../src/runtime/context.browser.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,EAAW,GAAG,CAAC;AAEtC,eAAO,MAAM,uBAAuB,uBAA8B,CAAC;AAEnE,eAAO,MAAM,WAAW,EAAW,GAAG,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1
2
|
export const ssrStorage = null;
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2
4
|
export const serverFunctionsRegistry = new Map();
|
|
3
|
-
//
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
6
|
export const runOnServer = null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare
|
|
5
|
-
|
|
2
|
+
type AnyFn = (...args: unknown[]) => unknown;
|
|
3
|
+
export declare const serverFunctionsRegistry: Map<string, AnyFn>;
|
|
4
|
+
export declare const ssrStorage: AsyncLocalStorage<Map<string, unknown>>;
|
|
5
|
+
export declare function runOnServer<T extends AnyFn>(backendFn: T, id?: string): T & {
|
|
6
6
|
id: string;
|
|
7
7
|
};
|
|
8
|
+
export {};
|
|
8
9
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/runtime/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,KAAK,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAE7C,eAAO,MAAM,uBAAuB,oBAA2B,CAAC;AAChE,eAAO,MAAM,UAAU,yCAAgD,CAAC;AAGxE,wBAAgB,WAAW,CAAC,CAAC,SAAS,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAoB1F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hydrate, render } from "solid-js/web";
|
|
2
2
|
import { Router } from "@solidjs/router";
|
|
3
|
-
// @ts-
|
|
3
|
+
// @ts-expect-error - resolved by Rspack
|
|
4
4
|
import App, { preloadActiveClientRoute } from "anaemia-user-app";
|
|
5
5
|
const mountTarget = document.querySelector("[anaemia-entry]");
|
|
6
6
|
if (!mountTarget) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-server.d.ts","sourceRoot":"","sources":["../../src/runtime/entry-server.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"entry-server.d.ts","sourceRoot":"","sources":["../../src/runtime/entry-server.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA2C5B,QAAA,MAAM,GAAG,4EAAa,CAAC;AA6VvB,eAAe,GAAG,CAAC"}
|
|
@@ -7,18 +7,18 @@ import { Router } from "@solidjs/router";
|
|
|
7
7
|
import { ssrStorage, serverFunctionsRegistry } from "./context.js";
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import path from "path";
|
|
10
|
-
// @ts-
|
|
10
|
+
// @ts-expect-error - resolved by Rspack
|
|
11
11
|
import App from "anaemia-user-app";
|
|
12
|
-
// @ts-
|
|
12
|
+
// @ts-expect-error - resolved by Rspack
|
|
13
13
|
import { preloadActiveClientRoute, serverLoaderRegistry, serverGuardRegistry } from "anaemia-user-app";
|
|
14
|
-
// @ts-
|
|
14
|
+
// @ts-expect-error - resolved by Rspack
|
|
15
15
|
import { registerServerRoutes } from "__anaemia_server_routes__";
|
|
16
16
|
const port = Number(process.env.PORT) || 3000;
|
|
17
17
|
const isDev = process.env.NODE_ENV !== "production";
|
|
18
18
|
const devPort = Number(process.env.RSPACK_DEV_PORT) || 4445;
|
|
19
19
|
const devServerUrl = `http://localhost:${devPort}`;
|
|
20
20
|
let sortedRoutes = null;
|
|
21
|
-
const ENTRY_TAG_REGEX = /(<([a-zA-Z0-9
|
|
21
|
+
const ENTRY_TAG_REGEX = /(<([a-zA-Z0-9-]+)[^>]*anaemia-entry[^>]*>)(.*?)(<\/\2>)/is;
|
|
22
22
|
const app = new Hono();
|
|
23
23
|
app.use("*", compress());
|
|
24
24
|
app.use("*", async (c, next) => {
|
|
@@ -41,7 +41,7 @@ if (isDev) {
|
|
|
41
41
|
c.header("Expires", "0");
|
|
42
42
|
return c.body(await response.arrayBuffer());
|
|
43
43
|
}
|
|
44
|
-
catch
|
|
44
|
+
catch {
|
|
45
45
|
return c.text("failed to connect to Rspack dev server asset bridge", 500);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
@@ -81,7 +81,8 @@ app.post("/_rpc", async (c) => {
|
|
|
81
81
|
return c.json(result);
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
84
|
-
|
|
84
|
+
const message = error instanceof Error ? error.message : "Internal server error";
|
|
85
|
+
return c.json({ error: message }, 500);
|
|
85
86
|
}
|
|
86
87
|
});
|
|
87
88
|
app.use(async (c, next) => {
|
|
@@ -142,7 +143,7 @@ const loadManifestAndTemplate = async () => {
|
|
|
142
143
|
if (fs.existsSync(manifestPath))
|
|
143
144
|
memoizedManifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
144
145
|
}
|
|
145
|
-
catch
|
|
146
|
+
catch {
|
|
146
147
|
console.warn("build assets not fully initialized during bootstrapping cycle.");
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -202,7 +203,6 @@ function matchRoute(manifest, reqPath) {
|
|
|
202
203
|
params: {},
|
|
203
204
|
};
|
|
204
205
|
}
|
|
205
|
-
// Look at your app.get("*") loop and update the processing logic:
|
|
206
206
|
app.get("*", async (c) => {
|
|
207
207
|
if (isDev)
|
|
208
208
|
await loadManifestAndTemplate();
|
|
@@ -215,9 +215,8 @@ app.get("*", async (c) => {
|
|
|
215
215
|
const { activeChunk, targetPattern, statusCode: matchedStatus, params } = matchRoute(manifest, reqPath);
|
|
216
216
|
let statusCode = matchedStatus;
|
|
217
217
|
const loaderArgs = { params, request: c.req.raw };
|
|
218
|
-
// Re-verify and isolate our store reference map instance
|
|
219
218
|
const store = ssrStorage.getStore() || new Map();
|
|
220
|
-
let htmlPayload
|
|
219
|
+
let htmlPayload;
|
|
221
220
|
if (targetPattern) {
|
|
222
221
|
try {
|
|
223
222
|
const guardResult = await runGuards(targetPattern, { params, request: c.req.raw, url: reqPath });
|
|
@@ -233,9 +232,6 @@ app.get("*", async (c) => {
|
|
|
233
232
|
return c.text("Internal Server Error", 500);
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
|
-
// ─── THE ARCHITECTURE WRAPPER FIX ───
|
|
237
|
-
// We force both the awaitable loader execution AND the Solid rendering cycle
|
|
238
|
-
// to run explicitly inside a fresh execution slice of the tracking store.
|
|
239
235
|
try {
|
|
240
236
|
htmlPayload = await ssrStorage.run(store, async () => {
|
|
241
237
|
if (targetPattern) {
|
|
@@ -246,7 +242,6 @@ app.get("*", async (c) => {
|
|
|
246
242
|
}
|
|
247
243
|
}
|
|
248
244
|
await preloadActiveClientRoute(reqPath);
|
|
249
|
-
// Now when Solid calls $$executeClientRpc, the store is 100% active and tracked!
|
|
250
245
|
return await renderToStringAsync(() => (<Router url={reqPath}>
|
|
251
246
|
<App />
|
|
252
247
|
</Router>));
|
|
@@ -258,7 +253,9 @@ app.get("*", async (c) => {
|
|
|
258
253
|
const error500Pattern = manifest.errors?.["500"];
|
|
259
254
|
const error500Loader = error500Pattern ? serverLoaderRegistry.get(error500Pattern) : null;
|
|
260
255
|
if (error500Loader) {
|
|
261
|
-
const
|
|
256
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
257
|
+
const stack = err instanceof Error ? err.stack : undefined;
|
|
258
|
+
const runtimeContextPayload = { message, stack: isDev ? stack : undefined };
|
|
262
259
|
store.set("__LOADER_DATA__", runtimeContextPayload);
|
|
263
260
|
try {
|
|
264
261
|
htmlPayload = await ssrStorage.run(store, async () => {
|
|
@@ -272,10 +269,10 @@ app.get("*", async (c) => {
|
|
|
272
269
|
}
|
|
273
270
|
}
|
|
274
271
|
else {
|
|
275
|
-
|
|
272
|
+
const stack = err instanceof Error ? err.stack : String(err);
|
|
273
|
+
htmlPayload = `<h1>500 Internal Server Error</h1><pre>${isDev ? stack : ""}</pre>`;
|
|
276
274
|
}
|
|
277
275
|
}
|
|
278
|
-
// ─── THE REMAINING INJECTIONS (Keep this exactly as you had it) ───
|
|
279
276
|
let assetScripts = "";
|
|
280
277
|
let assetStyles = "";
|
|
281
278
|
if (manifest.chunks) {
|
|
@@ -307,22 +304,14 @@ app.get("*", async (c) => {
|
|
|
307
304
|
const rawStorePayload = Object.fromEntries(store);
|
|
308
305
|
const finalHydrationStatePayload = {
|
|
309
306
|
__LOADER_DATA__: rawStorePayload.__LOADER_DATA__ || {},
|
|
310
|
-
__SERVER_FUNCTION_DATA__: rawStorePayload.__SERVER_FUNCTION_DATA__ || {}
|
|
307
|
+
__SERVER_FUNCTION_DATA__: rawStorePayload.__SERVER_FUNCTION_DATA__ || {},
|
|
311
308
|
};
|
|
312
|
-
const serializedData = JSON.stringify(finalHydrationStatePayload)
|
|
313
|
-
.replace(/&/g, "\\u0026")
|
|
314
|
-
.replace(/</g, "\\u003c")
|
|
315
|
-
.replace(/>/g, "\\u003e")
|
|
316
|
-
.replace(/\//g, "\\u002f");
|
|
309
|
+
const serializedData = JSON.stringify(finalHydrationStatePayload).replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\//g, "\\u002f");
|
|
317
310
|
const dataScript = `<script id="__ANAEMIA_DATA__" type="application/json">${serializedData}</script>\n`;
|
|
318
|
-
const devNoCacheTag = isDev
|
|
319
|
-
? `<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">\n<meta http-equiv="Pragma" content="no-cache">\n<meta http-equiv="Expires" content="0">\n`
|
|
320
|
-
: "";
|
|
311
|
+
const devNoCacheTag = isDev ? `<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">\n<meta http-equiv="Pragma" content="no-cache">\n<meta http-equiv="Expires" content="0">\n` : "";
|
|
321
312
|
const combinedHeadInjections = `${devNoCacheTag}${assetStyles}${dataScript}${hydrationScript}`;
|
|
322
313
|
const sanitizedPayload = htmlPayload.trim();
|
|
323
|
-
let completeHtmlOutput = ENTRY_TAG_REGEX.test(template)
|
|
324
|
-
? template.replace(ENTRY_TAG_REGEX, (_, open, _tag, _inner, close) => `${open}${sanitizedPayload}${close}`)
|
|
325
|
-
: template.replace("</body>", () => `<div anaemia-entry>${sanitizedPayload}</div></body>`);
|
|
314
|
+
let completeHtmlOutput = ENTRY_TAG_REGEX.test(template) ? template.replace(ENTRY_TAG_REGEX, (_, open, _tag, _inner, close) => `${open}${sanitizedPayload}${close}`) : template.replace("</body>", () => `<div anaemia-entry>${sanitizedPayload}</div></body>`);
|
|
326
315
|
completeHtmlOutput = completeHtmlOutput.replace("<head>", `<head>${combinedHeadInjections}`);
|
|
327
316
|
completeHtmlOutput = completeHtmlOutput.replace("</body>", `${assetScripts}</body>`);
|
|
328
317
|
if (isDev) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ResourceOptions, type ResourceReturn } from "solid-js";
|
|
2
2
|
export declare function createServerResource<Source, Return>(source: () => Source, serverFn: ((sourceData: Source) => Promise<Return>) & {
|
|
3
|
-
readHydrationCache?: (s:
|
|
3
|
+
readHydrationCache?: (s: Source) => Return | undefined;
|
|
4
4
|
id?: string;
|
|
5
5
|
}, options?: ResourceOptions<Return, Source>): ResourceReturn<Return, unknown>;
|
|
6
6
|
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/runtime/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/runtime/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAcrF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EACjD,MAAM,EAAE,MAAM,MAAM,EACpB,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG;IACpD,kBAAkB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACvD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,EACD,OAAO,CAAC,EAAE,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,GACxC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAuCjC"}
|
|
@@ -5,9 +5,11 @@ export function createServerResource(source, serverFn, options) {
|
|
|
5
5
|
let ssrInitialValue = undefined;
|
|
6
6
|
const store = globalThis.__ANAEMIA_SERVER_STORAGE__?.getStore?.();
|
|
7
7
|
if (store && serverFn.id) {
|
|
8
|
-
const
|
|
8
|
+
const fnData = store.get("__SERVER_FUNCTION_DATA__");
|
|
9
|
+
const fnCache = fnData?.[serverFn.id];
|
|
9
10
|
if (fnCache) {
|
|
10
|
-
const
|
|
11
|
+
const sourceValue = source();
|
|
12
|
+
const key = sourceValue === undefined ? JSON.stringify([]) : JSON.stringify([sourceValue]);
|
|
11
13
|
if (fnCache[key] !== undefined)
|
|
12
14
|
ssrInitialValue = fnCache[key];
|
|
13
15
|
}
|
|
@@ -28,7 +30,7 @@ export function createServerResource(source, serverFn, options) {
|
|
|
28
30
|
return Promise.resolve(cached);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
return serverFn(s);
|
|
33
|
+
return s === undefined ? serverFn() : serverFn(s);
|
|
32
34
|
};
|
|
33
35
|
wrappedFetcher.id = serverFn.id;
|
|
34
36
|
wrappedFetcher.readHydrationCache = serverFn.readHydrationCache;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { type JSX } from "solid-js";
|
|
2
2
|
import { type Params } from "@solidjs/router";
|
|
3
3
|
import type { Location } from "@solidjs/router";
|
|
4
|
+
type LoaderArgs<TParams extends Params> = {
|
|
5
|
+
params: TParams;
|
|
6
|
+
location: Location;
|
|
7
|
+
request: Request;
|
|
8
|
+
};
|
|
4
9
|
type RouteDataControllerProps<TParams extends Params = Params> = {
|
|
5
|
-
loader: (args:
|
|
6
|
-
params: TParams;
|
|
7
|
-
location: Location;
|
|
8
|
-
request: Request;
|
|
9
|
-
}) => any | Promise<any>;
|
|
10
|
+
loader: (args: LoaderArgs<TParams>) => unknown | Promise<unknown>;
|
|
10
11
|
children: JSX.Element;
|
|
11
12
|
};
|
|
12
13
|
export declare function RouteDataController<TParams extends Params = Params>(props: RouteDataControllerProps<TParams>): JSX.Element;
|
|
13
|
-
export declare function useRouteData<T =
|
|
14
|
+
export declare function useRouteData<T = unknown>(): () => T;
|
|
14
15
|
export {};
|
|
15
16
|
//# sourceMappingURL=route-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-data.d.ts","sourceRoot":"","sources":["../../src/runtime/route-data.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"route-data.d.ts","sourceRoot":"","sources":["../../src/runtime/route-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8D,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAEhG,OAAO,EAA0B,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,KAAK,UAAU,CAAC,OAAO,SAAS,MAAM,IAAI;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,wBAAwB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI;IAC/D,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB,CAAC;AA6BF,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,wBAAwB,CAAC,OAAO,CAAC,eA2B5G;AAED,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,CAMnD"}
|
|
@@ -27,25 +27,22 @@ export function RouteDataController(props) {
|
|
|
27
27
|
const location = useLocation();
|
|
28
28
|
const ssrData = readSSRData();
|
|
29
29
|
const [resource] = createResource(() => location.pathname, () => {
|
|
30
|
-
if (isServer && ssrData !== undefined)
|
|
30
|
+
if (isServer && ssrData !== undefined)
|
|
31
31
|
return ssrData;
|
|
32
|
-
}
|
|
33
32
|
return props.loader({
|
|
34
33
|
params,
|
|
35
34
|
location,
|
|
36
|
-
request: createRouteRequest(location.pathname)
|
|
35
|
+
request: createRouteRequest(location.pathname),
|
|
37
36
|
});
|
|
38
37
|
}, {
|
|
39
38
|
initialValue: ssrData,
|
|
40
|
-
ssrLoadFrom: "initial"
|
|
39
|
+
ssrLoadFrom: "initial",
|
|
41
40
|
});
|
|
42
41
|
return createComponent(RouteDataContext.Provider, {
|
|
43
|
-
value: {
|
|
44
|
-
data: resource
|
|
45
|
-
},
|
|
42
|
+
value: { data: resource },
|
|
46
43
|
get children() {
|
|
47
44
|
return props.children;
|
|
48
|
-
}
|
|
45
|
+
},
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
48
|
export function useRouteData() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function createRouteRequest(pathname: string):
|
|
1
|
+
export declare function createRouteRequest(pathname: string): Request;
|
|
2
2
|
//# sourceMappingURL=route-request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-request.d.ts","sourceRoot":"","sources":["../../src/runtime/route-request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-request.d.ts","sourceRoot":"","sources":["../../src/runtime/route-request.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQ5D"}
|
|
@@ -2,7 +2,8 @@ import { isServer } from "solid-js/web";
|
|
|
2
2
|
import { ssrStorage } from "./context.js";
|
|
3
3
|
export function createRouteRequest(pathname) {
|
|
4
4
|
if (isServer) {
|
|
5
|
-
const
|
|
5
|
+
const honoContext = ssrStorage.getStore()?.get("honoContext");
|
|
6
|
+
const request = honoContext?.req?.raw;
|
|
6
7
|
if (request)
|
|
7
8
|
return request;
|
|
8
9
|
return new Request(new URL(pathname, "http://localhost").toString());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function $$executeClientRpc(hashId: string): {
|
|
2
|
-
(...args: unknown[]): Promise<
|
|
2
|
+
(...args: unknown[]): Promise<unknown>;
|
|
3
3
|
id: string;
|
|
4
|
-
readHydrationCache(...args: unknown[]):
|
|
4
|
+
readHydrationCache(...args: unknown[]): unknown;
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=rpc-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../src/runtime/rpc-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../src/runtime/rpc-client.ts"],"names":[],"mappings":"AAqDA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM;cACD,OAAO,EAAE;;gCAgCF,OAAO,EAAE;EAoB/D"}
|
|
@@ -19,17 +19,19 @@ function findLooseCacheMatch(serverFunctionData, targetArg) {
|
|
|
19
19
|
return { matchingKey: strictKey, data: serverFunctionData[strictKey] };
|
|
20
20
|
}
|
|
21
21
|
const lookUpString = `["${targetArg}"`;
|
|
22
|
-
const matchedKey = Object.keys(serverFunctionData).find(key => key.startsWith(lookUpString));
|
|
22
|
+
const matchedKey = Object.keys(serverFunctionData).find((key) => key.startsWith(lookUpString));
|
|
23
23
|
return matchedKey ? { matchingKey: matchedKey, data: serverFunctionData[matchedKey] } : undefined;
|
|
24
24
|
}
|
|
25
|
+
function getServerStore() {
|
|
26
|
+
return globalThis.__ANAEMIA_SERVER_STORAGE__?.getStore?.();
|
|
27
|
+
}
|
|
25
28
|
export function $$executeClientRpc(hashId) {
|
|
26
29
|
const asyncRpcCall = async function (...args) {
|
|
27
30
|
if (isServer) {
|
|
28
|
-
const
|
|
29
|
-
const store = globalStorage?.getStore();
|
|
31
|
+
const store = getServerStore();
|
|
30
32
|
if (store) {
|
|
31
33
|
const functionCache = store.get("__SERVER_FUNCTION_DATA__");
|
|
32
|
-
if (functionCache
|
|
34
|
+
if (functionCache?.[hashId]) {
|
|
33
35
|
const match = findLooseCacheMatch(functionCache[hashId], args[0]);
|
|
34
36
|
if (match)
|
|
35
37
|
return match.data;
|
|
@@ -38,8 +40,8 @@ export function $$executeClientRpc(hashId) {
|
|
|
38
40
|
return undefined;
|
|
39
41
|
}
|
|
40
42
|
ensureCacheInitialized();
|
|
41
|
-
const serverFunctionData = _clientCache
|
|
42
|
-
const match = findLooseCacheMatch(serverFunctionData, args[0]);
|
|
43
|
+
const serverFunctionData = _clientCache?.__SERVER_FUNCTION_DATA__?.[hashId];
|
|
44
|
+
const match = findLooseCacheMatch(serverFunctionData ?? {}, args[0]);
|
|
43
45
|
if (match) {
|
|
44
46
|
const { matchingKey, data } = match;
|
|
45
47
|
delete serverFunctionData[matchingKey];
|
|
@@ -57,11 +59,10 @@ export function $$executeClientRpc(hashId) {
|
|
|
57
59
|
asyncRpcCall.id = hashId;
|
|
58
60
|
asyncRpcCall.readHydrationCache = function (...args) {
|
|
59
61
|
if (isServer) {
|
|
60
|
-
const
|
|
61
|
-
const store = globalStorage?.getStore();
|
|
62
|
+
const store = getServerStore();
|
|
62
63
|
if (store) {
|
|
63
64
|
const functionCache = store.get("__SERVER_FUNCTION_DATA__");
|
|
64
|
-
if (functionCache
|
|
65
|
+
if (functionCache?.[hashId]) {
|
|
65
66
|
const match = findLooseCacheMatch(functionCache[hashId], args[0]);
|
|
66
67
|
if (match)
|
|
67
68
|
return match.data;
|
|
@@ -70,8 +71,8 @@ export function $$executeClientRpc(hashId) {
|
|
|
70
71
|
return undefined;
|
|
71
72
|
}
|
|
72
73
|
ensureCacheInitialized();
|
|
73
|
-
const serverFunctionData = _clientCache
|
|
74
|
-
const match = findLooseCacheMatch(serverFunctionData, args[0]);
|
|
74
|
+
const serverFunctionData = _clientCache?.__SERVER_FUNCTION_DATA__?.[hashId];
|
|
75
|
+
const match = findLooseCacheMatch(serverFunctionData ?? {}, args[0]);
|
|
75
76
|
return match ? match.data : undefined;
|
|
76
77
|
};
|
|
77
78
|
return asyncRpcCall;
|
package/dist/types.d.ts
CHANGED
|
@@ -11,12 +11,12 @@ export interface LoaderArgs<Params extends Record<string, string> = Record<strin
|
|
|
11
11
|
/**
|
|
12
12
|
* represents an application page loader function.
|
|
13
13
|
*/
|
|
14
|
-
export type LoaderFunction<ResponseData =
|
|
14
|
+
export type LoaderFunction<ResponseData = unknown, Params extends Record<string, string> = Record<string, string>> = (args: LoaderArgs<Params>) => Promise<ResponseData> | ResponseData;
|
|
15
15
|
/**
|
|
16
16
|
* extracts and unwraps the true data structure returned by a server function or loader.
|
|
17
17
|
* essential for typing useRouteData() effortlessly in user-space.
|
|
18
18
|
*/
|
|
19
|
-
export type InferServerData<T extends (...args:
|
|
19
|
+
export type InferServerData<T extends (...args: unknown[]) => unknown> = Awaited<ReturnType<T>>;
|
|
20
20
|
export type GuardContext = {
|
|
21
21
|
params: Record<string, string>;
|
|
22
22
|
request: Request;
|
|
@@ -46,4 +46,8 @@ export type GuardFn = (ctx: {
|
|
|
46
46
|
status: number;
|
|
47
47
|
body?: string;
|
|
48
48
|
}>;
|
|
49
|
+
export type ServerFunction<Args extends unknown[], Return> = ((...args: Args) => Promise<Return>) & {
|
|
50
|
+
id?: string;
|
|
51
|
+
urlId?: string;
|
|
52
|
+
};
|
|
49
53
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACxF,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACxF,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,YAAY,GAAG,OAAO,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAExL;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErJ,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,GAAG,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/T,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG;IAClG,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anaemia/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"./package.json": "./package.json"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@babel/core": "^7.29.7",
|
|
34
35
|
"@hono/node-server": "^2.0.4",
|
|
35
36
|
"@solidjs/router": "^0.16.1",
|
|
36
37
|
"hono": "^4.12.23"
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
53
|
+
"@types/babel__core": "^7.20.5",
|
|
52
54
|
"@types/node": "^25.9.1",
|
|
53
55
|
"jiti": "^2.7.0",
|
|
54
56
|
"playwright": "^1.60.0"
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import type { Configuration } from "@rspack/core";
|
|
3
|
+
import type { PluginItem } from "@babel/core";
|
|
3
4
|
|
|
4
5
|
export interface AnaemiaPlugin {
|
|
5
6
|
/**
|
|
@@ -21,8 +22,8 @@ export interface AnaemiaPlugin {
|
|
|
21
22
|
* add additional babel plugins to the client transform pipeline.
|
|
22
23
|
*/
|
|
23
24
|
babelPlugins?: {
|
|
24
|
-
client?:
|
|
25
|
-
server?:
|
|
25
|
+
client?: PluginItem[];
|
|
26
|
+
server?: PluginItem[];
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
/**
|
package/src/index.ts
CHANGED
|
@@ -5,9 +5,4 @@ export { RouteDataController, useRouteData } from "./runtime/route-data.js";
|
|
|
5
5
|
export { $$executeClientRpc } from "./runtime/rpc-client.js";
|
|
6
6
|
export { createServerResource } from "./runtime/resources.js";
|
|
7
7
|
|
|
8
|
-
export type
|
|
9
|
-
id?: string;
|
|
10
|
-
urlId?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type { LoaderArgs, LoaderFunction, InferServerData, GuardContext, GuardResult, GuardFn } from "./types.js";
|
|
8
|
+
export type { LoaderArgs, LoaderFunction, InferServerData, GuardContext, GuardResult, GuardFn, ServerFunction } from "./types.js";
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import type { AnaemiaPlugin } from "../config.js";
|
|
3
|
+
import type { LightningCssMinimizerRspackPlugin as LightningCssType } from "@rspack/core";
|
|
4
|
+
|
|
5
|
+
interface RspackModule {
|
|
6
|
+
LightningCssMinimizerRspackPlugin: typeof LightningCssType;
|
|
7
|
+
}
|
|
3
8
|
|
|
4
9
|
export function anaemiaLightningCssPlugin(options: { browserslist?: string[] } = {}): AnaemiaPlugin {
|
|
5
10
|
const targets = options.browserslist ?? ["defaults", "not IE 11"];
|
|
6
11
|
|
|
7
12
|
const localRequire = createRequire(import.meta.url);
|
|
8
|
-
let rspackModule:
|
|
13
|
+
let rspackModule: RspackModule;
|
|
9
14
|
|
|
10
15
|
try {
|
|
11
16
|
rspackModule = localRequire("@rspack/core");
|
|
12
|
-
} catch
|
|
17
|
+
} catch {
|
|
13
18
|
throw new Error(
|
|
14
19
|
"[anaemia] The LightningCSS plugin requires '@rspack/core' to be available in the execution workspace."
|
|
15
20
|
);
|
|
@@ -46,7 +51,6 @@ export function anaemiaLightningCssPlugin(options: { browserslist?: string[] } =
|
|
|
46
51
|
minimize: true,
|
|
47
52
|
minimizer: [
|
|
48
53
|
...(config.optimization?.minimizer ?? []),
|
|
49
|
-
// Native Rust CSS minification engine
|
|
50
54
|
new rspackModule.LightningCssMinimizerRspackPlugin({
|
|
51
55
|
minimizerOptions: { targets },
|
|
52
56
|
}),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1
2
|
export const ssrStorage = null as any;
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
2
4
|
export const serverFunctionsRegistry = new Map<string, Function>();
|
|
3
|
-
|
|
4
|
-
// runOnServer calls are compiled away by babel-transform-server
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
export const runOnServer = null as any;
|