honox 0.1.54 → 0.1.56

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.
Files changed (58) hide show
  1. package/README.md +1 -1
  2. package/dist/client/client.d.ts +21 -20
  3. package/dist/client/client.js +56 -77
  4. package/dist/client/index.d.ts +2 -2
  5. package/dist/client/index.js +2 -3
  6. package/dist/client/runtime.d.ts +5 -4
  7. package/dist/client/runtime.js +110 -141
  8. package/dist/client/utils/filter.d.ts +3 -2
  9. package/dist/client/utils/filter.js +5 -6
  10. package/dist/constants.d.ts +3 -2
  11. package/dist/constants.js +4 -7
  12. package/dist/factory/factory.d.ts +8 -7
  13. package/dist/factory/factory.js +6 -5
  14. package/dist/factory/index.d.ts +2 -4
  15. package/dist/factory/index.js +3 -5
  16. package/dist/index.d.ts +1 -2
  17. package/dist/index.js +1 -0
  18. package/dist/server/base.d.ts +2 -4
  19. package/dist/server/base.js +2 -3
  20. package/dist/server/components/has-islands.d.ts +7 -4
  21. package/dist/server/components/has-islands.js +9 -9
  22. package/dist/server/components/index.d.ts +4 -6
  23. package/dist/server/components/index.js +2 -5
  24. package/dist/server/components/link.d.ts +8 -7
  25. package/dist/server/components/link.js +34 -39
  26. package/dist/server/components/script.d.ts +9 -8
  27. package/dist/server/components/script.js +33 -37
  28. package/dist/server/context-storage.d.ts +5 -4
  29. package/dist/server/context-storage.js +5 -3
  30. package/dist/server/index.d.ts +7 -11
  31. package/dist/server/index.js +6 -4
  32. package/dist/server/server.d.ts +27 -30
  33. package/dist/server/server.js +227 -275
  34. package/dist/server/utils/file.d.ts +3 -2
  35. package/dist/server/utils/file.js +38 -66
  36. package/dist/server/utils/path.d.ts +3 -2
  37. package/dist/server/utils/path.js +5 -4
  38. package/dist/server/with-defaults.d.ts +8 -8
  39. package/dist/server/with-defaults.js +26 -40
  40. package/dist/types.d.ts +7 -6
  41. package/dist/types.js +1 -0
  42. package/dist/vite/client.d.ts +7 -6
  43. package/dist/vite/client.js +24 -30
  44. package/dist/vite/components/honox-island.d.ts +15 -9
  45. package/dist/vite/components/honox-island.js +39 -50
  46. package/dist/vite/components/index.d.ts +2 -2
  47. package/dist/vite/components/index.js +2 -3
  48. package/dist/vite/index.d.ts +20 -20
  49. package/dist/vite/index.js +37 -52
  50. package/dist/vite/inject-importing-islands.d.ts +6 -5
  51. package/dist/vite/inject-importing-islands.js +64 -91
  52. package/dist/vite/island-components.d.ts +11 -10
  53. package/dist/vite/island-components.js +128 -209
  54. package/dist/vite/restart-on-add-unlink.d.ts +4 -3
  55. package/dist/vite/restart-on-add-unlink.js +16 -15
  56. package/dist/vite/utils/path.d.ts +3 -2
  57. package/dist/vite/utils/path.js +25 -9
  58. package/package.json +41 -54
@@ -1,13 +1,13 @@
1
- import { Fragment, jsx } from "hono/jsx/jsx-runtime";
2
1
  import { IMPORTING_ISLANDS_ID } from "../../constants.js";
3
2
  import { contextStorage } from "../context-storage.js";
3
+ import { Fragment, jsx } from "hono/jsx/jsx-runtime";
4
+
5
+ //#region src/server/components/has-islands.tsx
4
6
  const HasIslands = ({ children }) => {
5
- const c = contextStorage.getStore();
6
- if (!c) {
7
- throw new Error("No context found");
8
- }
9
- return /* @__PURE__ */ jsx(Fragment, { children: c.get(IMPORTING_ISLANDS_ID) && children });
10
- };
11
- export {
12
- HasIslands
7
+ const c = contextStorage.getStore();
8
+ if (!c) throw new Error("No context found");
9
+ return /* @__PURE__ */ jsx(Fragment, { children: c.get(IMPORTING_ISLANDS_ID) && children });
13
10
  };
11
+
12
+ //#endregion
13
+ export { HasIslands };
@@ -1,6 +1,4 @@
1
- export { HasIslands } from './has-islands.js';
2
- export { Script } from './script.js';
3
- export { Link } from './link.js';
4
- import 'vite';
5
- import 'hono/jsx';
6
- import 'hono/jsx/jsx-runtime';
1
+ import { HasIslands } from "./has-islands.js";
2
+ import { Script } from "./script.js";
3
+ import { Link } from "./link.js";
4
+ export { HasIslands, Link, Script };
@@ -1,8 +1,5 @@
1
1
  import { HasIslands } from "./has-islands.js";
2
2
  import { Script } from "./script.js";
3
3
  import { Link } from "./link.js";
4
- export {
5
- HasIslands,
6
- Link,
7
- Script
8
- };
4
+
5
+ export { HasIslands, Link, Script };
@@ -1,11 +1,12 @@
1
- import { FC } from 'hono/jsx';
2
- import { JSX } from 'hono/jsx/jsx-runtime';
3
- import { Manifest } from 'vite';
1
+ import { Manifest } from "vite";
2
+ import { FC } from "hono/jsx";
3
+ import { JSX } from "hono/jsx/jsx-runtime";
4
4
 
5
+ //#region src/server/components/link.d.ts
5
6
  type Options = {
6
- manifest?: Manifest;
7
- prod?: boolean;
7
+ manifest?: Manifest;
8
+ prod?: boolean;
8
9
  } & JSX.IntrinsicElements['link'];
9
10
  declare const Link: FC<Options>;
10
-
11
- export { Link };
11
+ //#endregion
12
+ export { Link };
@@ -1,42 +1,37 @@
1
- import { Fragment, jsx } from "hono/jsx/jsx-runtime";
2
1
  import { ensureTrailngSlash } from "../utils/path.js";
2
+ import { Fragment, jsx } from "hono/jsx/jsx-runtime";
3
+
4
+ //#region src/server/components/link.tsx
3
5
  const Link = (options) => {
4
- let { href, prod, manifest, ...rest } = options;
5
- if (href) {
6
- if (prod ?? import.meta.env.PROD) {
7
- if (!manifest) {
8
- const MANIFEST = import.meta.glob("/dist/.vite/manifest.json", {
9
- eager: true
10
- });
11
- for (const [, manifestFile] of Object.entries(MANIFEST)) {
12
- if (manifestFile["default"]) {
13
- manifest = manifestFile["default"];
14
- break;
15
- }
16
- }
17
- }
18
- if (manifest) {
19
- const assetInManifest = manifest[href.replace(/^\//, "")];
20
- if (assetInManifest) {
21
- if (href.startsWith("/")) {
22
- return /* @__PURE__ */ jsx(
23
- "link",
24
- {
25
- href: `${ensureTrailngSlash(import.meta.env.BASE_URL)}${assetInManifest.file}`,
26
- ...rest
27
- }
28
- );
29
- }
30
- return /* @__PURE__ */ jsx("link", { href: assetInManifest.file, ...rest });
31
- }
32
- }
33
- return /* @__PURE__ */ jsx(Fragment, {});
34
- } else {
35
- return /* @__PURE__ */ jsx("link", { href, ...rest });
36
- }
37
- }
38
- return /* @__PURE__ */ jsx("link", { ...rest });
39
- };
40
- export {
41
- Link
6
+ let { href, prod, manifest, ...rest } = options;
7
+ if (href) if (prod ?? import.meta.env.PROD) {
8
+ if (!manifest) {
9
+ const MANIFEST = import.meta.glob("/dist/.vite/manifest.json", { eager: true });
10
+ for (const [, manifestFile] of Object.entries(MANIFEST)) if (manifestFile["default"]) {
11
+ manifest = manifestFile["default"];
12
+ break;
13
+ }
14
+ }
15
+ if (manifest) {
16
+ const assetInManifest = manifest[href.replace(/^\//, "")];
17
+ if (assetInManifest) {
18
+ if (href.startsWith("/")) return /* @__PURE__ */ jsx("link", {
19
+ href: `${ensureTrailngSlash(import.meta.env.BASE_URL)}${assetInManifest.file}`,
20
+ ...rest
21
+ });
22
+ return /* @__PURE__ */ jsx("link", {
23
+ href: assetInManifest.file,
24
+ ...rest
25
+ });
26
+ }
27
+ }
28
+ return /* @__PURE__ */ jsx(Fragment, {});
29
+ } else return /* @__PURE__ */ jsx("link", {
30
+ href,
31
+ ...rest
32
+ });
33
+ return /* @__PURE__ */ jsx("link", { ...rest });
42
34
  };
35
+
36
+ //#endregion
37
+ export { Link };
@@ -1,12 +1,13 @@
1
- import { Manifest } from 'vite';
1
+ import { Manifest } from "vite";
2
2
 
3
+ //#region src/server/components/script.d.ts
3
4
  type Options = {
4
- src: string;
5
- async?: boolean;
6
- prod?: boolean;
7
- manifest?: Manifest;
8
- nonce?: string;
5
+ src: string;
6
+ async?: boolean;
7
+ prod?: boolean;
8
+ manifest?: Manifest;
9
+ nonce?: string;
9
10
  };
10
11
  declare const Script: (options: Options) => any;
11
-
12
- export { Script };
12
+ //#endregion
13
+ export { Script };
@@ -1,40 +1,36 @@
1
- import { Fragment, jsx } from "hono/jsx/jsx-runtime";
2
- import { ensureTrailngSlash } from "../utils/path.js";
3
1
  import { HasIslands } from "./has-islands.js";
2
+ import { ensureTrailngSlash } from "../utils/path.js";
3
+ import { Fragment, jsx } from "hono/jsx/jsx-runtime";
4
+
5
+ //#region src/server/components/script.tsx
4
6
  const Script = (options) => {
5
- const src = options.src;
6
- if (options.prod ?? import.meta.env.PROD) {
7
- let manifest = options.manifest;
8
- if (!manifest) {
9
- const MANIFEST = import.meta.glob("/dist/.vite/manifest.json", {
10
- eager: true
11
- });
12
- for (const [, manifestFile] of Object.entries(MANIFEST)) {
13
- if (manifestFile["default"]) {
14
- manifest = manifestFile["default"];
15
- break;
16
- }
17
- }
18
- }
19
- if (manifest) {
20
- const scriptInManifest = manifest[src.replace(/^\//, "")];
21
- if (scriptInManifest) {
22
- return /* @__PURE__ */ jsx(HasIslands, { children: /* @__PURE__ */ jsx(
23
- "script",
24
- {
25
- type: "module",
26
- async: !!options.async,
27
- src: `${ensureTrailngSlash(import.meta.env.BASE_URL)}${scriptInManifest.file}`,
28
- nonce: options.nonce
29
- }
30
- ) });
31
- }
32
- }
33
- return /* @__PURE__ */ jsx(Fragment, {});
34
- } else {
35
- return /* @__PURE__ */ jsx("script", { type: "module", async: !!options.async, src, nonce: options.nonce });
36
- }
37
- };
38
- export {
39
- Script
7
+ const src = options.src;
8
+ if (options.prod ?? import.meta.env.PROD) {
9
+ let manifest = options.manifest;
10
+ if (!manifest) {
11
+ const MANIFEST = import.meta.glob("/dist/.vite/manifest.json", { eager: true });
12
+ for (const [, manifestFile] of Object.entries(MANIFEST)) if (manifestFile["default"]) {
13
+ manifest = manifestFile["default"];
14
+ break;
15
+ }
16
+ }
17
+ if (manifest) {
18
+ const scriptInManifest = manifest[src.replace(/^\//, "")];
19
+ if (scriptInManifest) return /* @__PURE__ */ jsx(HasIslands, { children: /* @__PURE__ */ jsx("script", {
20
+ type: "module",
21
+ async: !!options.async,
22
+ src: `${ensureTrailngSlash(import.meta.env.BASE_URL)}${scriptInManifest.file}`,
23
+ nonce: options.nonce
24
+ }) });
25
+ }
26
+ return /* @__PURE__ */ jsx(Fragment, {});
27
+ } else return /* @__PURE__ */ jsx("script", {
28
+ type: "module",
29
+ async: !!options.async,
30
+ src,
31
+ nonce: options.nonce
32
+ });
40
33
  };
34
+
35
+ //#endregion
36
+ export { Script };
@@ -1,6 +1,7 @@
1
- import { Context } from 'hono';
2
- import { AsyncLocalStorage } from 'node:async_hooks';
1
+ import { Context } from "hono";
2
+ import { AsyncLocalStorage } from "node:async_hooks";
3
3
 
4
+ //#region src/server/context-storage.d.ts
4
5
  declare const contextStorage: AsyncLocalStorage<Context<any, any, {}>>;
5
-
6
- export { contextStorage };
6
+ //#endregion
7
+ export { contextStorage };
@@ -1,5 +1,7 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
+
3
+ //#region src/server/context-storage.ts
2
4
  const contextStorage = new AsyncLocalStorage();
3
- export {
4
- contextStorage
5
- };
5
+
6
+ //#endregion
7
+ export { contextStorage };
@@ -1,11 +1,7 @@
1
- export { createApp } from './with-defaults.js';
2
- export { ServerOptions } from './server.js';
3
- export { HasIslands } from './components/has-islands.js';
4
- export { Script } from './components/script.js';
5
- export { Link } from './components/link.js';
6
- import 'hono';
7
- import 'hono/types';
8
- import '../constants.js';
9
- import 'vite';
10
- import 'hono/jsx';
11
- import 'hono/jsx/jsx-runtime';
1
+ import { ServerOptions } from "./server.js";
2
+ import { HasIslands } from "./components/has-islands.js";
3
+ import { Script } from "./components/script.js";
4
+ import { Link } from "./components/link.js";
5
+ import "./components/index.js";
6
+ import { createApp } from "./with-defaults.js";
7
+ export { HasIslands, Link, Script, type ServerOptions, createApp };
@@ -1,5 +1,7 @@
1
1
  import { createApp } from "./with-defaults.js";
2
- export * from "./components/index.js";
3
- export {
4
- createApp
5
- };
2
+ import { HasIslands } from "./components/has-islands.js";
3
+ import { Script } from "./components/script.js";
4
+ import { Link } from "./components/link.js";
5
+ import "./components/index.js";
6
+
7
+ export { HasIslands, Link, Script, createApp };
@@ -1,49 +1,46 @@
1
- import { Env, Hono, MiddlewareHandler, NotFoundHandler, ErrorHandler } from 'hono';
2
- import { H } from 'hono/types';
3
- import { IMPORTING_ISLANDS_ID } from '../constants.js';
1
+ import { IMPORTING_ISLANDS_ID } from "../constants.js";
2
+ import { Env, ErrorHandler, Hono, MiddlewareHandler, NotFoundHandler } from "hono";
3
+ import { H } from "hono/types";
4
4
 
5
+ //#region src/server/server.d.ts
5
6
  declare const METHODS: readonly ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"];
6
- type HasIslandFile = {
7
- [key in typeof IMPORTING_ISLANDS_ID]?: boolean;
8
- };
7
+ type HasIslandFile = { [key in typeof IMPORTING_ISLANDS_ID]?: boolean };
9
8
  type InnerMeta = {} & HasIslandFile;
10
9
  type AppFile = {
11
- default: Hono;
10
+ default: Hono;
12
11
  } & InnerMeta;
13
12
  type RouteFile = {
14
- default?: Function;
15
- } & {
16
- [M in (typeof METHODS)[number]]?: H[];
17
- } & InnerMeta;
13
+ default?: Function;
14
+ } & { [M in (typeof METHODS)[number]]?: H[] } & InnerMeta;
18
15
  type RendererFile = {
19
- default: MiddlewareHandler;
16
+ default: MiddlewareHandler;
20
17
  } & InnerMeta;
21
18
  type NotFoundFile = {
22
- default: NotFoundHandler;
19
+ default: NotFoundHandler;
23
20
  } & InnerMeta;
24
21
  type ErrorFile = {
25
- default: ErrorHandler;
22
+ default: ErrorHandler;
26
23
  } & InnerMeta;
27
24
  type MiddlewareFile = {
28
- default: MiddlewareHandler[];
25
+ default: MiddlewareHandler[];
29
26
  };
30
27
  type InitFunction<E extends Env = Env> = (app: Hono<E>) => void;
31
28
  type BaseServerOptions<E extends Env = Env> = {
32
- ROUTES: Record<string, RouteFile | AppFile>;
33
- RENDERER: Record<string, RendererFile>;
34
- NOT_FOUND: Record<string, NotFoundFile>;
35
- ERROR: Record<string, ErrorFile>;
36
- MIDDLEWARE: Record<string, MiddlewareFile>;
37
- root: string;
38
- app?: Hono<E>;
39
- init?: InitFunction<E>;
40
- /**
41
- * Appends a trailing slash to URL if the route file is an index file, e.g., `index.tsx` or `index.mdx`.
42
- * @default false
43
- */
44
- trailingSlash?: boolean;
29
+ ROUTES: Record<string, RouteFile | AppFile>;
30
+ RENDERER: Record<string, RendererFile>;
31
+ NOT_FOUND: Record<string, NotFoundFile>;
32
+ ERROR: Record<string, ErrorFile>;
33
+ MIDDLEWARE: Record<string, MiddlewareFile>;
34
+ root: string;
35
+ app?: Hono<E>;
36
+ init?: InitFunction<E>;
37
+ /**
38
+ * Appends a trailing slash to URL if the route file is an index file, e.g., `index.tsx` or `index.mdx`.
39
+ * @default false
40
+ */
41
+ trailingSlash?: boolean;
45
42
  };
46
43
  type ServerOptions<E extends Env = Env> = Partial<BaseServerOptions<E>>;
47
44
  declare const createApp: <E extends Env>(options: BaseServerOptions<E>) => Hono<E>;
48
-
49
- export { type ServerOptions, createApp };
45
+ //#endregion
46
+ export { ServerOptions, createApp };