honox 0.1.55 → 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.
package/dist/client/client.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CreateChildren, CreateElement, Hydrate, TriggerHydration } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/client/client.d.ts
|
|
4
|
-
type ClientOptions = {
|
|
5
|
-
hydrate?: Hydrate
|
|
6
|
-
createElement?: CreateElement
|
|
4
|
+
type ClientOptions<E = Node> = {
|
|
5
|
+
hydrate?: Hydrate<E>;
|
|
6
|
+
createElement?: CreateElement<E>;
|
|
7
7
|
/**
|
|
8
8
|
* Create "children" attribute of a component from a list of child nodes
|
|
9
9
|
*/
|
|
10
|
-
createChildren?: CreateChildren
|
|
10
|
+
createChildren?: CreateChildren<E>;
|
|
11
11
|
/**
|
|
12
12
|
* Trigger hydration on your own
|
|
13
13
|
*/
|
|
@@ -18,6 +18,6 @@ type ClientOptions = {
|
|
|
18
18
|
*/
|
|
19
19
|
island_root?: string;
|
|
20
20
|
};
|
|
21
|
-
declare const createClient: (options?: ClientOptions) => Promise<void>;
|
|
21
|
+
declare const createClient: <E = Node>(options?: ClientOptions<E>) => Promise<void>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { ClientOptions, createClient };
|
package/dist/client/runtime.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CreateChildren, CreateElement, HydrateComponent } from "../types.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/client/runtime.d.ts
|
|
4
4
|
type ImportComponent = (name: string) => Promise<Function | undefined>;
|
|
5
|
-
declare const buildCreateChildrenFn: (createElement: CreateElement
|
|
5
|
+
declare const buildCreateChildrenFn: <E = Node>(createElement: CreateElement<E>, importComponent: ImportComponent) => CreateChildren<E>;
|
|
6
6
|
declare const hydrateComponentHonoSuspense: (hydrateComponent: HydrateComponent) => Promise<void>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { buildCreateChildrenFn, hydrateComponentHonoSuspense };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
/** JSX */
|
|
3
|
-
type CreateElement = (type: any, props: any) =>
|
|
4
|
-
type Hydrate = (children:
|
|
5
|
-
type CreateChildren = (childNodes: NodeListOf<ChildNode>) =>
|
|
3
|
+
type CreateElement<E = Node> = (type: any, props: any) => E | Promise<E>;
|
|
4
|
+
type Hydrate<E = Node> = (children: E, parent: Element) => void | Promise<void>;
|
|
5
|
+
type CreateChildren<E = Node> = (childNodes: NodeListOf<ChildNode>) => E[] | Promise<E[]>;
|
|
6
6
|
type HydrateComponent = (doc: {
|
|
7
7
|
querySelectorAll: typeof document.querySelectorAll;
|
|
8
8
|
}) => Promise<void>;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { IMPORTING_ISLANDS_ID } from "../constants.js";
|
|
2
2
|
import { matchIslandComponentId } from "./utils/path.js";
|
|
3
|
-
import
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
4
|
import { parse } from "@babel/parser";
|
|
5
|
+
import { booleanLiteral, exportNamedDeclaration, identifier, variableDeclaration, variableDeclarator } from "@babel/types";
|
|
5
6
|
import { readFile } from "fs/promises";
|
|
6
7
|
import path from "path";
|
|
7
8
|
import precinct from "precinct";
|
|
8
9
|
import { normalizePath } from "vite";
|
|
9
10
|
|
|
10
11
|
//#region src/vite/inject-importing-islands.ts
|
|
11
|
-
const generate =
|
|
12
|
+
const generate = createRequire(import.meta.url)("@babel/generator").default;
|
|
12
13
|
async function injectImportingIslands(options) {
|
|
13
14
|
let appPath = "";
|
|
14
15
|
const islandDir = options?.islandDir ?? "/app/islands";
|
|
@@ -53,24 +54,7 @@ async function injectImportingIslands(options) {
|
|
|
53
54
|
sourceType: "module",
|
|
54
55
|
plugins: ["jsx", "typescript"]
|
|
55
56
|
});
|
|
56
|
-
const hasIslandsNode =
|
|
57
|
-
type: "ExportNamedDeclaration",
|
|
58
|
-
declaration: {
|
|
59
|
-
type: "VariableDeclaration",
|
|
60
|
-
declarations: [{
|
|
61
|
-
type: "VariableDeclarator",
|
|
62
|
-
id: {
|
|
63
|
-
type: "Identifier",
|
|
64
|
-
name: IMPORTING_ISLANDS_ID
|
|
65
|
-
},
|
|
66
|
-
init: {
|
|
67
|
-
type: "BooleanLiteral",
|
|
68
|
-
value: true
|
|
69
|
-
}
|
|
70
|
-
}],
|
|
71
|
-
kind: "const"
|
|
72
|
-
}
|
|
73
|
-
};
|
|
57
|
+
const hasIslandsNode = exportNamedDeclaration(variableDeclaration("const", [variableDeclarator(identifier(IMPORTING_ISLANDS_ID), booleanLiteral(true))]));
|
|
74
58
|
ast.program.body.push(hasIslandsNode);
|
|
75
59
|
const output = generate(ast, {}, sourceCode);
|
|
76
60
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
|
|
3
3
|
//#region src/vite/island-components.d.ts
|
|
4
|
-
declare const transformJsxTags: (contents: string, componentName: string) =>
|
|
4
|
+
declare const transformJsxTags: (contents: string, componentName: string) => string | undefined;
|
|
5
5
|
type IsIsland = (id: string) => boolean;
|
|
6
6
|
type IslandComponentsOptions = {
|
|
7
7
|
/**
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { isComponentName, matchIslandComponentId } from "./utils/path.js";
|
|
2
|
-
import
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
3
|
import { parse } from "@babel/parser";
|
|
4
|
-
import
|
|
5
|
-
import { blockStatement, conditionalExpression, exportDefaultDeclaration, exportNamedDeclaration, exportSpecifier, functionExpression, identifier, importDeclaration, importSpecifier, jsxAttribute, jsxClosingElement, jsxElement, jsxExpressionContainer, jsxIdentifier, jsxOpeningElement, jsxSpreadAttribute, memberExpression, returnStatement, stringLiteral, variableDeclaration, variableDeclarator } from "@babel/types";
|
|
4
|
+
import { blockStatement, conditionalExpression, exportDefaultDeclaration, exportNamedDeclaration, exportSpecifier, functionExpression, identifier, importDeclaration, importSpecifier, jsxAttribute, jsxClosingElement, jsxElement, jsxExpressionContainer, jsxIdentifier, jsxOpeningElement, jsxSpreadAttribute, memberExpression, metaProperty, returnStatement, stringLiteral, variableDeclaration, variableDeclarator } from "@babel/types";
|
|
6
5
|
import { parse as parse$1 } from "jsonc-parser";
|
|
7
6
|
import fs from "fs/promises";
|
|
8
7
|
import path from "path";
|
|
9
8
|
|
|
10
9
|
//#region src/vite/island-components.ts
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const generate = require("@babel/generator").default;
|
|
12
|
+
const traverse = require("@babel/traverse").default;
|
|
13
13
|
function addSSRCheck(funcName, componentName, componentExport) {
|
|
14
|
-
const isSSR = memberExpression(memberExpression(identifier("import"), identifier("meta")), identifier("env
|
|
14
|
+
const isSSR = memberExpression(memberExpression(metaProperty(identifier("import"), identifier("meta")), identifier("env")), identifier("SSR"));
|
|
15
15
|
const props = [
|
|
16
16
|
jsxAttribute(jsxIdentifier("componentName"), stringLiteral(componentName)),
|
|
17
17
|
jsxAttribute(jsxIdentifier("Component"), jsxExpressionContainer(identifier(funcName))),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "honox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "tsdown",
|
|
@@ -94,10 +94,10 @@
|
|
|
94
94
|
},
|
|
95
95
|
"homepage": "https://hono.dev",
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@babel/generator": "7.
|
|
98
|
-
"@babel/parser": "7.
|
|
99
|
-
"@babel/traverse": "7.
|
|
100
|
-
"@babel/types": "7.
|
|
97
|
+
"@babel/generator": "7.29.1",
|
|
98
|
+
"@babel/parser": "7.29.3",
|
|
99
|
+
"@babel/traverse": "7.29.0",
|
|
100
|
+
"@babel/types": "7.29.0",
|
|
101
101
|
"@hono/vite-dev-server": "^0.25.1",
|
|
102
102
|
"jsonc-parser": "3.3.1",
|
|
103
103
|
"precinct": "12.2.0"
|
|
@@ -115,6 +115,8 @@
|
|
|
115
115
|
"@hono/eslint-config": "^1.1.1",
|
|
116
116
|
"@mdx-js/rollup": "^3.0.0",
|
|
117
117
|
"@playwright/test": "^1.42.0",
|
|
118
|
+
"@types/babel__generator": "7.27.0",
|
|
119
|
+
"@types/babel__traverse": "7.28.0",
|
|
118
120
|
"@types/node": "^20.10.5",
|
|
119
121
|
"eslint": "^9.23.0",
|
|
120
122
|
"glob": "^10.3.10",
|