honox 0.1.0 → 0.1.2
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/README.md +7 -7
- package/dist/client/client.d.ts +5 -1
- package/dist/client/client.js +13 -2
- package/dist/client/runtime.d.ts +5 -0
- package/dist/client/runtime.js +81 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +2 -0
- package/dist/factory/factory.d.ts +10 -10
- package/dist/server/components/script.d.ts +1 -0
- package/dist/server/components/script.js +9 -2
- package/dist/server/server.js +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/utils/file.js +1 -1
- package/dist/vite/index.js +2 -0
- package/dist/vite/island-components.js +29 -2
- package/dist/vite/restart-on-add-unlink.d.ts +5 -0
- package/dist/vite/restart-on-add-unlink.js +17 -0
- package/dist/vite/watch-reload.d.ts +5 -0
- package/dist/vite/watch-reload.js +17 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**HonoX** is a simple and fast - _supersonic_ - meta framework for creating full-stack websites or Web APIs - (formerly _[Sonik](https://github.com/sonikjs/sonik)_). It stands on the shoulders of giants; built on [Hono](https://hono.dev/), [Vite](https://hono.dev/), and UI libraries.
|
|
4
4
|
|
|
5
|
-
**Note**: _HonoX is currently in a "
|
|
5
|
+
**Note**: _HonoX is currently in a "alpha stage". Breaking changes are introduced without following semantic versioning._
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -157,7 +157,7 @@ export default app
|
|
|
157
157
|
Or simply, you can just return JSX.
|
|
158
158
|
|
|
159
159
|
```tsx
|
|
160
|
-
export default function Home() {
|
|
160
|
+
export default function Home(_c: Context) {
|
|
161
161
|
return <h1>Welcome!</h1>
|
|
162
162
|
}
|
|
163
163
|
```
|
|
@@ -207,7 +207,7 @@ The `_renderer.tsx` is applied under each directory, and the `app/routes/posts/_
|
|
|
207
207
|
|
|
208
208
|
### Not Found page
|
|
209
209
|
|
|
210
|
-
You can write a custom Not Found page in `_404.
|
|
210
|
+
You can write a custom Not Found page in `_404.tsx`.
|
|
211
211
|
|
|
212
212
|
```tsx
|
|
213
213
|
// app/routes/_404.tsx
|
|
@@ -222,10 +222,10 @@ export default handler
|
|
|
222
222
|
|
|
223
223
|
### Error Page
|
|
224
224
|
|
|
225
|
-
You can write a custom Error page in `_error.
|
|
225
|
+
You can write a custom Error page in `_error.tsx`.
|
|
226
226
|
|
|
227
227
|
```tsx
|
|
228
|
-
// app/routes/_error.
|
|
228
|
+
// app/routes/_error.tsx
|
|
229
229
|
import { ErrorHandler } from 'hono'
|
|
230
230
|
|
|
231
231
|
const handler: ErrorHandler = (e, c) => {
|
|
@@ -419,9 +419,9 @@ createClient({
|
|
|
419
419
|
const { hydrateRoot } = await import('react-dom/client')
|
|
420
420
|
hydrateRoot(root, elem)
|
|
421
421
|
},
|
|
422
|
-
createElement: async (type: any, props: any
|
|
422
|
+
createElement: async (type: any, props: any) => {
|
|
423
423
|
const { createElement } = await import('react')
|
|
424
|
-
return createElement(type, props
|
|
424
|
+
return createElement(type, props)
|
|
425
425
|
},
|
|
426
426
|
})
|
|
427
427
|
```
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { Hydrate, CreateElement } from '../types.js';
|
|
1
|
+
import { Hydrate, CreateElement, CreateChildren } from '../types.js';
|
|
2
2
|
|
|
3
3
|
type ClientOptions = {
|
|
4
4
|
hydrate?: Hydrate;
|
|
5
5
|
createElement?: CreateElement;
|
|
6
|
+
/**
|
|
7
|
+
* Create "children" attribute of a component from a list of child nodes
|
|
8
|
+
*/
|
|
9
|
+
createChildren?: CreateChildren;
|
|
6
10
|
ISLAND_FILES?: Record<string, () => Promise<unknown>>;
|
|
7
11
|
island_root?: string;
|
|
8
12
|
};
|
package/dist/client/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as jsxFn } from "hono/jsx";
|
|
2
1
|
import { render } from "hono/jsx/dom";
|
|
3
|
-
import {
|
|
2
|
+
import { jsx as jsxFn } from "hono/jsx/dom/jsx-runtime";
|
|
3
|
+
import { COMPONENT_NAME, DATA_HONO_TEMPLATE, DATA_SERIALIZED_PROPS } from "../constants.js";
|
|
4
4
|
const createClient = async (options) => {
|
|
5
5
|
const FILES = options?.ISLAND_FILES ?? import.meta.glob("/app/islands/**/[a-zA-Z0-9[-]+.(tsx|ts)");
|
|
6
6
|
const root = options?.island_root ?? "/app/islands/";
|
|
@@ -17,6 +17,17 @@ const createClient = async (options) => {
|
|
|
17
17
|
const props = JSON.parse(serializedProps ?? "{}");
|
|
18
18
|
const hydrate = options?.hydrate ?? render;
|
|
19
19
|
const createElement = options?.createElement ?? jsxFn;
|
|
20
|
+
const maybeTemplate = element.childNodes[element.childNodes.length - 1];
|
|
21
|
+
if (maybeTemplate?.nodeName === "TEMPLATE" && maybeTemplate?.attributes.getNamedItem(DATA_HONO_TEMPLATE) !== null) {
|
|
22
|
+
let createChildren = options?.createChildren;
|
|
23
|
+
if (!createChildren) {
|
|
24
|
+
const { buildCreateChildrenFn } = await import("./runtime");
|
|
25
|
+
createChildren = buildCreateChildrenFn(createElement);
|
|
26
|
+
}
|
|
27
|
+
props.children = await createChildren(
|
|
28
|
+
maybeTemplate.content.childNodes
|
|
29
|
+
);
|
|
30
|
+
}
|
|
20
31
|
const newElem = await createElement(Component, props);
|
|
21
32
|
await hydrate(newElem, element);
|
|
22
33
|
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Suspense, use } from "hono/jsx/dom";
|
|
2
|
+
const buildCreateChildrenFn = (createElement) => {
|
|
3
|
+
const createChildren = async (childNodes) => {
|
|
4
|
+
const children = [];
|
|
5
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
6
|
+
const child = childNodes[i];
|
|
7
|
+
if (child.nodeType === 8) {
|
|
8
|
+
continue;
|
|
9
|
+
} else if (child.nodeType === 3) {
|
|
10
|
+
children.push(child.textContent);
|
|
11
|
+
} else if (child.nodeName === "TEMPLATE" && child.id.match(/(?:H|E):\d+/)) {
|
|
12
|
+
const placeholderElement = document.createElement("hono-placeholder");
|
|
13
|
+
placeholderElement.style.display = "none";
|
|
14
|
+
let resolve;
|
|
15
|
+
const promise = new Promise((r) => resolve = r);
|
|
16
|
+
child.replaceWith = (node) => {
|
|
17
|
+
createChildren(node.childNodes).then(resolve);
|
|
18
|
+
placeholderElement.remove();
|
|
19
|
+
};
|
|
20
|
+
let fallback = [];
|
|
21
|
+
for (
|
|
22
|
+
// equivalent to i++
|
|
23
|
+
placeholderElement.appendChild(child);
|
|
24
|
+
i < childNodes.length;
|
|
25
|
+
i++
|
|
26
|
+
) {
|
|
27
|
+
const child2 = childNodes[i];
|
|
28
|
+
if (child2.nodeType === 8) {
|
|
29
|
+
placeholderElement.appendChild(child2);
|
|
30
|
+
i--;
|
|
31
|
+
break;
|
|
32
|
+
} else if (child2.nodeType === 3) {
|
|
33
|
+
fallback.push(child2.textContent);
|
|
34
|
+
} else {
|
|
35
|
+
fallback.push(
|
|
36
|
+
await createElement(child2.nodeName, {
|
|
37
|
+
children: await createChildren(child2.childNodes)
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const fallbackTemplates = document.querySelectorAll(
|
|
43
|
+
`[data-hono-target="${child.id}"]`
|
|
44
|
+
);
|
|
45
|
+
if (fallbackTemplates.length > 0) {
|
|
46
|
+
const fallbackTemplate = fallbackTemplates[fallbackTemplates.length - 1];
|
|
47
|
+
fallback = await createChildren(fallbackTemplate.content.childNodes);
|
|
48
|
+
}
|
|
49
|
+
if (fallback.length === 0 && child.id.startsWith("E:")) {
|
|
50
|
+
let resolve2;
|
|
51
|
+
const promise2 = new Promise((r) => resolve2 = r);
|
|
52
|
+
fallback = await createElement(Suspense, {
|
|
53
|
+
fallback: [],
|
|
54
|
+
children: [await createElement(() => use(promise2), {})]
|
|
55
|
+
});
|
|
56
|
+
placeholderElement.insertBefore = (node) => {
|
|
57
|
+
createChildren(node.childNodes).then(resolve2);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
document.body.appendChild(placeholderElement);
|
|
61
|
+
children.push(
|
|
62
|
+
await createElement(Suspense, {
|
|
63
|
+
fallback,
|
|
64
|
+
children: [await createElement(() => use(promise), {})]
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
children.push(
|
|
69
|
+
await createElement(child.nodeName, {
|
|
70
|
+
children: await createChildren(child.childNodes)
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return children;
|
|
76
|
+
};
|
|
77
|
+
return createChildren;
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
buildCreateChildrenFn
|
|
81
|
+
};
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const COMPONENT_NAME = "component-name";
|
|
2
2
|
declare const DATA_SERIALIZED_PROPS = "data-serialized-props";
|
|
3
|
+
declare const DATA_HONO_TEMPLATE = "data-hono-template";
|
|
3
4
|
declare const IMPORTING_ISLANDS_ID: "__importing_islands";
|
|
4
5
|
|
|
5
|
-
export { COMPONENT_NAME, DATA_SERIALIZED_PROPS, IMPORTING_ISLANDS_ID };
|
|
6
|
+
export { COMPONENT_NAME, DATA_HONO_TEMPLATE, DATA_SERIALIZED_PROPS, IMPORTING_ISLANDS_ID };
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const COMPONENT_NAME = "component-name";
|
|
2
2
|
const DATA_SERIALIZED_PROPS = "data-serialized-props";
|
|
3
|
+
const DATA_HONO_TEMPLATE = "data-hono-template";
|
|
3
4
|
const IMPORTING_ISLANDS_ID = "__importing_islands";
|
|
4
5
|
export {
|
|
5
6
|
COMPONENT_NAME,
|
|
7
|
+
DATA_HONO_TEMPLATE,
|
|
6
8
|
DATA_SERIALIZED_PROPS,
|
|
7
9
|
IMPORTING_ISLANDS_ID
|
|
8
10
|
};
|
|
@@ -3,16 +3,16 @@ import * as hono from 'hono';
|
|
|
3
3
|
import { Env, Hono } from 'hono';
|
|
4
4
|
|
|
5
5
|
declare const createRoute: {
|
|
6
|
-
<I extends hono.Input = {}>(handler1: hono_types.H<Env, any, I>): [hono_types.H<Env, any, I>];
|
|
7
|
-
<I_1 extends hono.Input = {}, I2 extends hono.Input = I_1,
|
|
8
|
-
<I_2 extends hono.Input = {}, I2_1 extends hono.Input = I_2, I3 extends hono.Input = I_2 & I2_1,
|
|
9
|
-
<I_3 extends hono.Input = {}, I2_2 extends hono.Input = I_3, I3_1 extends hono.Input = I_3 & I2_2, I4 extends hono.Input = I_3 & I2_2 & I3_1,
|
|
10
|
-
<I_4 extends hono.Input = {}, I2_3 extends hono.Input = I_4, I3_2 extends hono.Input = I_4 & I2_3, I4_1 extends hono.Input = I_4 & I2_3 & I3_2, I5 extends hono.Input = I_4 & I2_3 & I3_2 & I4_1,
|
|
11
|
-
<I_5 extends hono.Input = {}, I2_4 extends hono.Input = I_5, I3_3 extends hono.Input = I_5 & I2_4, I4_2 extends hono.Input = I_5 & I2_4 & I3_3, I5_1 extends hono.Input = I_5 & I2_4 & I3_3 & I4_2, I6 extends hono.Input = I_5 & I2_4 & I3_3 & I4_2 & I5_1,
|
|
12
|
-
<I_6 extends hono.Input = {}, I2_5 extends hono.Input = I_6, I3_4 extends hono.Input = I_6 & I2_5, I4_3 extends hono.Input = I_6 & I2_5 & I3_4, I5_2 extends hono.Input = I_6 & I2_5 & I3_4 & I4_3, I6_1 extends hono.Input = I_6 & I2_5 & I3_4 & I4_3 & I5_2, I7 extends hono.Input = I_6 & I2_5 & I3_4 & I4_3 & I5_2 & I6_1,
|
|
13
|
-
<I_7 extends hono.Input = {}, I2_6 extends hono.Input = I_7, I3_5 extends hono.Input = I_7 & I2_6, I4_4 extends hono.Input = I_7 & I2_6 & I3_5, I5_3 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4, I6_2 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4 & I5_3, I7_1 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4 & I5_3 & I6_2, I8 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4 & I5_3 & I6_2 & I7_1,
|
|
14
|
-
<I_8 extends hono.Input = {}, I2_7 extends hono.Input = I_8, I3_6 extends hono.Input = I_8 & I2_7, I4_5 extends hono.Input = I_8 & I2_7 & I3_6, I5_4 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5, I6_3 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4, I7_2 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4 & I6_3, I8_1 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4 & I6_3 & I7_2, I9 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4 & I6_3 & I7_2 & I8_1,
|
|
15
|
-
<I_9 extends hono.Input = {}, I2_8 extends hono.Input = I_9, I3_7 extends hono.Input = I_9 & I2_8, I4_6 extends hono.Input = I_9 & I2_8 & I3_7, I5_5 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6, I6_4 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5, I7_3 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4, I8_2 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4 & I7_3, I9_1 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4 & I7_3 & I8_2, I10 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4 & I7_3 & I8_2 & I9_1,
|
|
6
|
+
<I extends hono.Input = {}, R extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I, R>): [hono_types.H<Env, any, I, R>];
|
|
7
|
+
<I_1 extends hono.Input = {}, I2 extends hono.Input = I_1, R_1 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_1, R_1>, handler2: hono_types.H<Env, any, I2, R_1>): [hono_types.H<Env, any, I_1, R_1>, hono_types.H<Env, any, I2, R_1>];
|
|
8
|
+
<I_2 extends hono.Input = {}, I2_1 extends hono.Input = I_2, I3 extends hono.Input = I_2 & I2_1, R_2 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_2, R_2>, handler2: hono_types.H<Env, any, I2_1, R_2>, handler3: hono_types.H<Env, any, I3, R_2>): [hono_types.H<Env, any, I_2, R_2>, hono_types.H<Env, any, I2_1, R_2>, hono_types.H<Env, any, I3, R_2>];
|
|
9
|
+
<I_3 extends hono.Input = {}, I2_2 extends hono.Input = I_3, I3_1 extends hono.Input = I_3 & I2_2, I4 extends hono.Input = I_3 & I2_2 & I3_1, R_3 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_3, R_3>, handler2: hono_types.H<Env, any, I2_2, R_3>, handler3: hono_types.H<Env, any, I3_1, R_3>, handler4: hono_types.H<Env, any, I4, R_3>): [hono_types.H<Env, any, I_3, R_3>, hono_types.H<Env, any, I2_2, R_3>, hono_types.H<Env, any, I3_1, R_3>, hono_types.H<Env, any, I4, R_3>];
|
|
10
|
+
<I_4 extends hono.Input = {}, I2_3 extends hono.Input = I_4, I3_2 extends hono.Input = I_4 & I2_3, I4_1 extends hono.Input = I_4 & I2_3 & I3_2, I5 extends hono.Input = I_4 & I2_3 & I3_2 & I4_1, R_4 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_4, R_4>, handler2: hono_types.H<Env, any, I2_3, R_4>, handler3: hono_types.H<Env, any, I3_2, R_4>, handler4: hono_types.H<Env, any, I4_1, R_4>, handler5: hono_types.H<Env, any, I5, R_4>): [hono_types.H<Env, any, I_4, R_4>, hono_types.H<Env, any, I2_3, R_4>, hono_types.H<Env, any, I3_2, R_4>, hono_types.H<Env, any, I4_1, R_4>, hono_types.H<Env, any, I5, R_4>];
|
|
11
|
+
<I_5 extends hono.Input = {}, I2_4 extends hono.Input = I_5, I3_3 extends hono.Input = I_5 & I2_4, I4_2 extends hono.Input = I_5 & I2_4 & I3_3, I5_1 extends hono.Input = I_5 & I2_4 & I3_3 & I4_2, I6 extends hono.Input = I_5 & I2_4 & I3_3 & I4_2 & I5_1, R_5 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_5, R_5>, handler2: hono_types.H<Env, any, I2_4, R_5>, handler3: hono_types.H<Env, any, I3_3, R_5>, handler4: hono_types.H<Env, any, I4_2, R_5>, handler5: hono_types.H<Env, any, I5_1, R_5>, handler6: hono_types.H<Env, any, I6, R_5>): [hono_types.H<Env, any, I_5, R_5>, hono_types.H<Env, any, I2_4, R_5>, hono_types.H<Env, any, I3_3, R_5>, hono_types.H<Env, any, I4_2, R_5>, hono_types.H<Env, any, I5_1, R_5>, hono_types.H<Env, any, I6, R_5>];
|
|
12
|
+
<I_6 extends hono.Input = {}, I2_5 extends hono.Input = I_6, I3_4 extends hono.Input = I_6 & I2_5, I4_3 extends hono.Input = I_6 & I2_5 & I3_4, I5_2 extends hono.Input = I_6 & I2_5 & I3_4 & I4_3, I6_1 extends hono.Input = I_6 & I2_5 & I3_4 & I4_3 & I5_2, I7 extends hono.Input = I_6 & I2_5 & I3_4 & I4_3 & I5_2 & I6_1, R_6 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_6, R_6>, handler2: hono_types.H<Env, any, I2_5, R_6>, handler3: hono_types.H<Env, any, I3_4, R_6>, handler4: hono_types.H<Env, any, I4_3, R_6>, handler5: hono_types.H<Env, any, I5_2, R_6>, handler6: hono_types.H<Env, any, I6_1, R_6>, handler7: hono_types.H<Env, any, I7, R_6>): [hono_types.H<Env, any, I_6, R_6>, hono_types.H<Env, any, I2_5, R_6>, hono_types.H<Env, any, I3_4, R_6>, hono_types.H<Env, any, I4_3, R_6>, hono_types.H<Env, any, I5_2, R_6>, hono_types.H<Env, any, I6_1, R_6>, hono_types.H<Env, any, I7, R_6>];
|
|
13
|
+
<I_7 extends hono.Input = {}, I2_6 extends hono.Input = I_7, I3_5 extends hono.Input = I_7 & I2_6, I4_4 extends hono.Input = I_7 & I2_6 & I3_5, I5_3 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4, I6_2 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4 & I5_3, I7_1 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4 & I5_3 & I6_2, I8 extends hono.Input = I_7 & I2_6 & I3_5 & I4_4 & I5_3 & I6_2 & I7_1, R_7 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_7, R_7>, handler2: hono_types.H<Env, any, I2_6, R_7>, handler3: hono_types.H<Env, any, I3_5, R_7>, handler4: hono_types.H<Env, any, I4_4, R_7>, handler5: hono_types.H<Env, any, I5_3, R_7>, handler6: hono_types.H<Env, any, I6_2, R_7>, handler7: hono_types.H<Env, any, I7_1, R_7>, handler8: hono_types.H<Env, any, I8, R_7>): [hono_types.H<Env, any, I_7, R_7>, hono_types.H<Env, any, I2_6, R_7>, hono_types.H<Env, any, I3_5, R_7>, hono_types.H<Env, any, I4_4, R_7>, hono_types.H<Env, any, I5_3, R_7>, hono_types.H<Env, any, I6_2, R_7>, hono_types.H<Env, any, I7_1, R_7>, hono_types.H<Env, any, I8, R_7>];
|
|
14
|
+
<I_8 extends hono.Input = {}, I2_7 extends hono.Input = I_8, I3_6 extends hono.Input = I_8 & I2_7, I4_5 extends hono.Input = I_8 & I2_7 & I3_6, I5_4 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5, I6_3 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4, I7_2 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4 & I6_3, I8_1 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4 & I6_3 & I7_2, I9 extends hono.Input = I_8 & I2_7 & I3_6 & I4_5 & I5_4 & I6_3 & I7_2 & I8_1, R_8 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_8, R_8>, handler2: hono_types.H<Env, any, I2_7, R_8>, handler3: hono_types.H<Env, any, I3_6, R_8>, handler4: hono_types.H<Env, any, I4_5, R_8>, handler5: hono_types.H<Env, any, I5_4, R_8>, handler6: hono_types.H<Env, any, I6_3, R_8>, handler7: hono_types.H<Env, any, I7_2, R_8>, handler8: hono_types.H<Env, any, I8_1, R_8>, handler9: hono_types.H<Env, any, I9, R_8>): [hono_types.H<Env, any, I_8, R_8>, hono_types.H<Env, any, I2_7, R_8>, hono_types.H<Env, any, I3_6, R_8>, hono_types.H<Env, any, I4_5, R_8>, hono_types.H<Env, any, I5_4, R_8>, hono_types.H<Env, any, I6_3, R_8>, hono_types.H<Env, any, I7_2, R_8>, hono_types.H<Env, any, I8_1, R_8>, hono_types.H<Env, any, I9, R_8>];
|
|
15
|
+
<I_9 extends hono.Input = {}, I2_8 extends hono.Input = I_9, I3_7 extends hono.Input = I_9 & I2_8, I4_6 extends hono.Input = I_9 & I2_8 & I3_7, I5_5 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6, I6_4 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5, I7_3 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4, I8_2 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4 & I7_3, I9_1 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4 & I7_3 & I8_2, I10 extends hono.Input = I_9 & I2_8 & I3_7 & I4_6 & I5_5 & I6_4 & I7_3 & I8_2 & I9_1, R_9 extends hono_types.HandlerResponse<any> = any>(handler1: hono_types.H<Env, any, I_9, R_9>, handler2: hono_types.H<Env, any, I2_8, R_9>, handler3: hono_types.H<Env, any, I3_7, R_9>, handler4: hono_types.H<Env, any, I4_6, R_9>, handler5: hono_types.H<Env, any, I5_5, R_9>, handler6: hono_types.H<Env, any, I6_4, R_9>, handler7: hono_types.H<Env, any, I7_3, R_9>, handler8: hono_types.H<Env, any, I8_2, R_9>, handler9: hono_types.H<Env, any, I9_1, R_9>, handler10: hono_types.H<Env, any, I10, R_9>): [hono_types.H<Env, any, I_9, R_9>, hono_types.H<Env, any, I2_8, R_9>, hono_types.H<Env, any, I3_7, R_9>, hono_types.H<Env, any, I4_6, R_9>, hono_types.H<Env, any, I5_5, R_9>, hono_types.H<Env, any, I6_4, R_9>, hono_types.H<Env, any, I7_3, R_9>, hono_types.H<Env, any, I8_2, R_9>, hono_types.H<Env, any, I9_1, R_9>, hono_types.H<Env, any, I10, R_9>];
|
|
16
16
|
};
|
|
17
17
|
declare const createHono: () => Hono<Env, hono_types.BlankSchema, "/">;
|
|
18
18
|
|
|
@@ -18,12 +18,19 @@ const Script = async (options) => {
|
|
|
18
18
|
if (manifest) {
|
|
19
19
|
const scriptInManifest = manifest[src.replace(/^\//, "")];
|
|
20
20
|
if (scriptInManifest) {
|
|
21
|
-
return /* @__PURE__ */ jsx(HasIslands, { children: /* @__PURE__ */ jsx(
|
|
21
|
+
return /* @__PURE__ */ jsx(HasIslands, { children: /* @__PURE__ */ jsx(
|
|
22
|
+
"script",
|
|
23
|
+
{
|
|
24
|
+
type: "module",
|
|
25
|
+
async: !!options.async,
|
|
26
|
+
src: `/${scriptInManifest.file}`
|
|
27
|
+
}
|
|
28
|
+
) });
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
return /* @__PURE__ */ jsx(Fragment, {});
|
|
25
32
|
} else {
|
|
26
|
-
return /* @__PURE__ */ jsx("script", { type: "module", src });
|
|
33
|
+
return /* @__PURE__ */ jsx("script", { type: "module", async: !!options.async, src });
|
|
27
34
|
}
|
|
28
35
|
};
|
|
29
36
|
export {
|
package/dist/server/server.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** JSX */
|
|
2
|
-
type CreateElement = (type: any, props: any
|
|
2
|
+
type CreateElement = (type: any, props: any) => Node | Promise<Node>;
|
|
3
3
|
type Hydrate = (children: Node, parent: Element) => void | Promise<void>;
|
|
4
|
+
type CreateChildren = (childNodes: NodeListOf<ChildNode>) => Node[] | Promise<Node[]>;
|
|
4
5
|
|
|
5
|
-
export type { CreateElement, Hydrate };
|
|
6
|
+
export type { CreateChildren, CreateElement, Hydrate };
|
package/dist/utils/file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const filePathToPath = (filePath) => {
|
|
2
|
-
filePath = filePath.replace(/\.tsx?$/g, "").replace(/\.mdx$/g, "").replace(/^\/?index
|
|
2
|
+
filePath = filePath.replace(/\.tsx?$/g, "").replace(/\.mdx$/g, "").replace(/^\/?index$/, "/").replace(/\/index$/, "").replace(/\[\.{3}.+\]/, "*").replace(/\[(.+?)\]/g, ":$1");
|
|
3
3
|
return /^\//.test(filePath) ? filePath : "/" + filePath;
|
|
4
4
|
};
|
|
5
5
|
const groupByDirectory = (files) => {
|
package/dist/vite/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import path from "path";
|
|
|
2
2
|
import devServer, { defaultOptions as devServerDefaultOptions } from "@hono/vite-dev-server";
|
|
3
3
|
import { injectImportingIslands } from "./inject-importing-islands.js";
|
|
4
4
|
import { islandComponents } from "./island-components.js";
|
|
5
|
+
import { restartOnAddUnlink } from "./restart-on-add-unlink.js";
|
|
5
6
|
const defaultOptions = {
|
|
6
7
|
islands: true,
|
|
7
8
|
entry: path.join(process.cwd(), "./app/server.ts")
|
|
@@ -25,6 +26,7 @@ function honox(options) {
|
|
|
25
26
|
plugins.push(islandComponents());
|
|
26
27
|
}
|
|
27
28
|
plugins.push(injectImportingIslands());
|
|
29
|
+
plugins.push(restartOnAddUnlink());
|
|
28
30
|
return [
|
|
29
31
|
{
|
|
30
32
|
name: "honox-vite-config",
|
|
@@ -24,13 +24,25 @@ import {
|
|
|
24
24
|
conditionalExpression,
|
|
25
25
|
memberExpression
|
|
26
26
|
} from "@babel/types";
|
|
27
|
-
import { COMPONENT_NAME, DATA_SERIALIZED_PROPS } from "../constants.js";
|
|
27
|
+
import { COMPONENT_NAME, DATA_HONO_TEMPLATE, DATA_SERIALIZED_PROPS } from "../constants.js";
|
|
28
28
|
function addSSRCheck(funcName, componentName, isAsync = false) {
|
|
29
29
|
const isSSR = memberExpression(
|
|
30
30
|
memberExpression(identifier("import"), identifier("meta")),
|
|
31
31
|
identifier("env.SSR")
|
|
32
32
|
);
|
|
33
|
-
const serializedProps = callExpression(identifier("JSON.stringify"), [
|
|
33
|
+
const serializedProps = callExpression(identifier("JSON.stringify"), [
|
|
34
|
+
callExpression(memberExpression(identifier("Object"), identifier("fromEntries")), [
|
|
35
|
+
callExpression(
|
|
36
|
+
memberExpression(
|
|
37
|
+
callExpression(memberExpression(identifier("Object"), identifier("entries")), [
|
|
38
|
+
identifier("props")
|
|
39
|
+
]),
|
|
40
|
+
identifier("filter")
|
|
41
|
+
),
|
|
42
|
+
[identifier('([key]) => key !== "children"')]
|
|
43
|
+
)
|
|
44
|
+
])
|
|
45
|
+
]);
|
|
34
46
|
const ssrElement = jsxElement(
|
|
35
47
|
jsxOpeningElement(
|
|
36
48
|
jsxIdentifier("honox-island"),
|
|
@@ -50,6 +62,21 @@ function addSSRCheck(funcName, componentName, isAsync = false) {
|
|
|
50
62
|
),
|
|
51
63
|
jsxClosingElement(jsxIdentifier(funcName)),
|
|
52
64
|
[]
|
|
65
|
+
),
|
|
66
|
+
jsxExpressionContainer(
|
|
67
|
+
conditionalExpression(
|
|
68
|
+
memberExpression(identifier("props"), identifier("children")),
|
|
69
|
+
jsxElement(
|
|
70
|
+
jsxOpeningElement(
|
|
71
|
+
jsxIdentifier("template"),
|
|
72
|
+
[jsxAttribute(jsxIdentifier(DATA_HONO_TEMPLATE), stringLiteral(""))],
|
|
73
|
+
false
|
|
74
|
+
),
|
|
75
|
+
jsxClosingElement(jsxIdentifier("template")),
|
|
76
|
+
[jsxExpressionContainer(memberExpression(identifier("props"), identifier("children")))]
|
|
77
|
+
),
|
|
78
|
+
identifier("null")
|
|
79
|
+
)
|
|
53
80
|
)
|
|
54
81
|
]
|
|
55
82
|
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function restartOnAddUnlink() {
|
|
2
|
+
return {
|
|
3
|
+
name: "restart-on-add-unlink",
|
|
4
|
+
configureServer(server) {
|
|
5
|
+
server.watcher.add("/app/**");
|
|
6
|
+
server.watcher.on("add", async () => {
|
|
7
|
+
await server.restart();
|
|
8
|
+
});
|
|
9
|
+
server.watcher.on("unlink", async () => {
|
|
10
|
+
await server.restart();
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
restartOnAddUnlink
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function restartOnAddUnlink() {
|
|
2
|
+
return {
|
|
3
|
+
name: "restart-on-add-unlink",
|
|
4
|
+
configureServer(server) {
|
|
5
|
+
server.watcher.add("/app/**");
|
|
6
|
+
server.watcher.on("add", async () => {
|
|
7
|
+
await server.restart();
|
|
8
|
+
});
|
|
9
|
+
server.watcher.on("unlink", async () => {
|
|
10
|
+
await server.restart();
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
restartOnAddUnlink
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "honox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -101,6 +101,9 @@
|
|
|
101
101
|
"@babel/types": "^7.23.6",
|
|
102
102
|
"@hono/vite-dev-server": "^0.5.0"
|
|
103
103
|
},
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"hono": ">=4.*"
|
|
106
|
+
},
|
|
104
107
|
"devDependencies": {
|
|
105
108
|
"@hono/eslint-config": "^0.0.4",
|
|
106
109
|
"@mdx-js/rollup": "^3.0.0",
|
|
@@ -110,7 +113,7 @@
|
|
|
110
113
|
"@types/node": "^20.10.5",
|
|
111
114
|
"eslint": "^8.56.0",
|
|
112
115
|
"glob": "^10.3.10",
|
|
113
|
-
"hono": "4.0.
|
|
116
|
+
"hono": "^4.0.3",
|
|
114
117
|
"np": "7.7.0",
|
|
115
118
|
"prettier": "^3.1.1",
|
|
116
119
|
"publint": "^0.2.7",
|