@punkestu/react-html 0.1.0 → 0.1.1
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/cli/docs-content.d.ts +8 -0
- package/dist/cli/docs-content.d.ts.map +1 -0
- package/dist/cli/docs-content.js +261 -0
- package/dist/cli/docs-content.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +113 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/tui-docs.d.ts +5 -0
- package/dist/cli/tui-docs.d.ts.map +1 -0
- package/dist/cli/tui-docs.js +191 -0
- package/dist/cli/tui-docs.js.map +1 -0
- package/dist/client/hydrate.d.ts +4 -0
- package/dist/client/hydrate.d.ts.map +1 -0
- package/dist/client/hydrate.js +80 -0
- package/dist/client/hydrate.js.map +1 -0
- package/dist/core/bundler.d.ts +7 -0
- package/dist/core/bundler.d.ts.map +1 -0
- package/dist/core/bundler.js +103 -0
- package/dist/core/bundler.js.map +1 -0
- package/dist/core/formatter.d.ts +6 -0
- package/dist/core/formatter.d.ts.map +1 -0
- package/dist/core/formatter.js +74 -0
- package/dist/core/formatter.js.map +1 -0
- package/dist/core/island-client.d.ts +9 -0
- package/dist/core/island-client.d.ts.map +1 -0
- package/dist/core/island-client.js +8 -0
- package/dist/core/island-client.js.map +1 -0
- package/dist/core/island-registry.d.ts +15 -0
- package/dist/core/island-registry.d.ts.map +1 -0
- package/dist/core/island-registry.js +17 -0
- package/dist/core/island-registry.js.map +1 -0
- package/dist/core/island.d.ts +32 -0
- package/dist/core/island.d.ts.map +1 -0
- package/dist/core/island.js +47 -0
- package/dist/core/island.js.map +1 -0
- package/dist/core/loader.d.ts +11 -0
- package/dist/core/loader.d.ts.map +1 -0
- package/dist/core/loader.js +73 -0
- package/dist/core/loader.js.map +1 -0
- package/dist/core/renderer.d.ts +20 -0
- package/dist/core/renderer.d.ts.map +1 -0
- package/dist/core/renderer.js +53 -0
- package/dist/core/renderer.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/dist/server/dev-server.d.ts +8 -0
- package/dist/server/dev-server.d.ts.map +1 -0
- package/dist/server/dev-server.js +112 -0
- package/dist/server/dev-server.js.map +1 -0
- package/dist/server/engine.d.ts +46 -0
- package/dist/server/engine.d.ts.map +1 -0
- package/dist/server/engine.js +222 -0
- package/dist/server/engine.js.map +1 -0
- package/{src/server/index.ts → dist/server/index.d.ts} +1 -1
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/package.json +4 -1
- package/.react-html/cache/page-fefe905ae5d2.mjs +0 -9
- package/DOCS.md +0 -317
- package/example/public/styles.css +0 -184
- package/example/src/components/Card.tsx +0 -17
- package/example/src/components/Counter.island.tsx +0 -35
- package/example/src/components/Footer.tsx +0 -13
- package/example/src/components/Header.tsx +0 -20
- package/example/src/components/Layout.tsx +0 -39
- package/example/src/components/Tabs.island.tsx +0 -59
- package/example/src/pages/index.tsx +0 -49
- package/example/src/pages/pure.tsx +0 -56
- package/src/cli/docs-content.ts +0 -268
- package/src/cli/index.ts +0 -113
- package/src/cli/tui-docs.ts +0 -214
- package/src/client/hydrate.ts +0 -84
- package/src/core/bundler.ts +0 -122
- package/src/core/formatter.ts +0 -92
- package/src/core/island-client.ts +0 -23
- package/src/core/island-registry.ts +0 -35
- package/src/core/island.tsx +0 -110
- package/src/core/loader.ts +0 -89
- package/src/core/renderer.ts +0 -80
- package/src/index.ts +0 -138
- package/src/server/dev-server.ts +0 -125
- package/src/server/engine.ts +0 -270
- package/tests/engine.test.mjs +0 -288
- package/tsconfig.json +0 -21
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
3
|
+
import { runWithRenderContext } from './island-registry.js';
|
|
4
|
+
import { formatHtml } from './formatter.js';
|
|
5
|
+
export function renderPageToHtml(options) {
|
|
6
|
+
const { pagePath, Component, props = {}, metadata = {}, basePath = '' } = options;
|
|
7
|
+
const islands = [];
|
|
8
|
+
const rawMarkup = runWithRenderContext({ pagePath, islands }, () => renderToStaticMarkup(React.createElement(Component, props)));
|
|
9
|
+
let finalHtml = rawMarkup;
|
|
10
|
+
const hasHtmlTag = /<html[^>]*>/i.test(finalHtml);
|
|
11
|
+
const hasDoctype = /<!DOCTYPE html>/i.test(finalHtml);
|
|
12
|
+
// If component returned only body contents / fragments, wrap in standard HTML shell
|
|
13
|
+
if (!hasHtmlTag) {
|
|
14
|
+
const lang = metadata.lang || 'en';
|
|
15
|
+
const titleTag = metadata.title ? `<title>${metadata.title}</title>` : '';
|
|
16
|
+
const descTag = metadata.description ? `<meta name="description" content="${metadata.description}">` : '';
|
|
17
|
+
finalHtml = `<!DOCTYPE html>
|
|
18
|
+
<html lang="${lang}">
|
|
19
|
+
<head>
|
|
20
|
+
<meta charset="UTF-8">
|
|
21
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
22
|
+
${titleTag}
|
|
23
|
+
${descTag}
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
${finalHtml}
|
|
27
|
+
</body>
|
|
28
|
+
</html>`;
|
|
29
|
+
}
|
|
30
|
+
else if (!hasDoctype) {
|
|
31
|
+
finalHtml = `<!DOCTYPE html>\n${finalHtml}`;
|
|
32
|
+
}
|
|
33
|
+
// If there are islands, inject script tags before </body> or at the end of the file
|
|
34
|
+
if (islands.length > 0) {
|
|
35
|
+
// Collect unique island names
|
|
36
|
+
const uniqueIslands = Array.from(new Set(islands.map(i => i.name)));
|
|
37
|
+
const assetPrefix = basePath ? (basePath.endsWith('/') ? basePath : `${basePath}/`) : '/';
|
|
38
|
+
const scriptTags = uniqueIslands
|
|
39
|
+
.map(name => `<script type="module" src="${assetPrefix}assets/islands/${name}.js"></script>`)
|
|
40
|
+
.join('\n');
|
|
41
|
+
if (/<\/body>/i.test(finalHtml)) {
|
|
42
|
+
finalHtml = finalHtml.replace(/<\/body>/i, `${scriptTags}\n</body>`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
finalHtml = `${finalHtml}\n${scriptTags}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
html: formatHtml(finalHtml),
|
|
50
|
+
islands
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/core/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAkB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAoB5C,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAClF,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,MAAM,SAAS,GAAG,oBAAoB,CACpC,EAAE,QAAQ,EAAE,OAAO,EAAE,EACrB,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAClE,CAAC;IAEF,IAAI,SAAS,GAAG,SAAS,CAAC;IAC1B,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEtD,oFAAoF;IACpF,IAAI,CAAC,UA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AW,CAAC,CAAC;QACvE,CAAC;aAAM,CAAC;YACN,SAAS,GAAG,GAAG,SAAS,KAAK,UAAU,EAAE,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC;QAC3B,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { Island, island } from './core/island.js';
|
|
2
|
+
export type { IslandProps } from './core/island.js';
|
|
3
|
+
export { hydrateIsland } from './client/hydrate.js';
|
|
4
|
+
export { renderPageToHtml } from './core/renderer.js';
|
|
5
|
+
export { createEngine, ReactHtmlEngine } from './server/engine.js';
|
|
6
|
+
export type { EngineOptions } from './server/engine.js';
|
|
7
|
+
export interface BuildConfig {
|
|
8
|
+
root?: string;
|
|
9
|
+
pagesDir?: string;
|
|
10
|
+
outDir?: string;
|
|
11
|
+
publicDir?: string;
|
|
12
|
+
minify?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface BuildResult {
|
|
15
|
+
pages: {
|
|
16
|
+
input: string;
|
|
17
|
+
output: string;
|
|
18
|
+
}[];
|
|
19
|
+
islands: string[];
|
|
20
|
+
outDir: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function build(config?: BuildConfig): Promise<BuildResult>;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAqBD,wBAAsB,KAAK,CAAC,MAAM,GAAE,WAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAyF1E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { loadPageModule, clearCache } from './core/loader.js';
|
|
4
|
+
import { renderPageToHtml } from './core/renderer.js';
|
|
5
|
+
import { bundleIslands } from './core/bundler.js';
|
|
6
|
+
export { Island, island } from './core/island.js';
|
|
7
|
+
export { hydrateIsland } from './client/hydrate.js';
|
|
8
|
+
export { renderPageToHtml } from './core/renderer.js';
|
|
9
|
+
export { createEngine, ReactHtmlEngine } from './server/engine.js';
|
|
10
|
+
async function findFilesRecursively(dir, extensions) {
|
|
11
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
12
|
+
const files = [];
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const fullPath = path.join(dir, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
files.push(...(await findFilesRecursively(fullPath, extensions)));
|
|
17
|
+
}
|
|
18
|
+
else if (entry.isFile()) {
|
|
19
|
+
const ext = path.extname(entry.name);
|
|
20
|
+
if (extensions.includes(ext) && !entry.name.startsWith('_') && !entry.name.includes('.test.')) {
|
|
21
|
+
files.push(fullPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return files;
|
|
26
|
+
}
|
|
27
|
+
export async function build(config = {}) {
|
|
28
|
+
const root = path.resolve(config.root || process.cwd());
|
|
29
|
+
const outDir = path.resolve(root, config.outDir || 'dist');
|
|
30
|
+
const minify = config.minify ?? true;
|
|
31
|
+
// Locate pages directory
|
|
32
|
+
let pagesDir = config.pagesDir ? path.resolve(root, config.pagesDir) : '';
|
|
33
|
+
if (!pagesDir) {
|
|
34
|
+
const candidateDirs = ['src/pages', 'pages'];
|
|
35
|
+
for (const cand of candidateDirs) {
|
|
36
|
+
const p = path.join(root, cand);
|
|
37
|
+
try {
|
|
38
|
+
const stat = await fs.stat(p);
|
|
39
|
+
if (stat.isDirectory()) {
|
|
40
|
+
pagesDir = p;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Continue checking
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!pagesDir) {
|
|
50
|
+
throw new Error(`Pages directory not found. Please create 'src/pages' or specify 'pagesDir'.`);
|
|
51
|
+
}
|
|
52
|
+
// Ensure output directory exists and is clean
|
|
53
|
+
await fs.mkdir(outDir, { recursive: true });
|
|
54
|
+
// Copy public static directory if present
|
|
55
|
+
const publicDir = path.resolve(root, config.publicDir || 'public');
|
|
56
|
+
try {
|
|
57
|
+
const publicStat = await fs.stat(publicDir);
|
|
58
|
+
if (publicStat.isDirectory()) {
|
|
59
|
+
await fs.cp(publicDir, outDir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Public directory optional
|
|
64
|
+
}
|
|
65
|
+
const pageFiles = await findFilesRecursively(pagesDir, ['.tsx', '.jsx', '.ts', '.js']);
|
|
66
|
+
if (pageFiles.length === 0) {
|
|
67
|
+
console.warn(`[react-html] No pages found in ${pagesDir}`);
|
|
68
|
+
}
|
|
69
|
+
const allDiscoveredIslands = [];
|
|
70
|
+
const processedPages = [];
|
|
71
|
+
for (const pageFile of pageFiles) {
|
|
72
|
+
const relativePage = path.relative(pagesDir, pageFile);
|
|
73
|
+
const parsed = path.parse(relativePage);
|
|
74
|
+
// Compute destination path: index.tsx -> index.html, about.tsx -> about.html
|
|
75
|
+
const outHtmlFile = path.join(outDir, parsed.dir, `${parsed.name}.html`);
|
|
76
|
+
await fs.mkdir(path.dirname(outHtmlFile), { recursive: true });
|
|
77
|
+
// Load page module
|
|
78
|
+
const { Component, metadata } = await loadPageModule(pageFile);
|
|
79
|
+
// Render to pure HTML and extract islands
|
|
80
|
+
const { html, islands } = renderPageToHtml({
|
|
81
|
+
pagePath: pageFile,
|
|
82
|
+
Component,
|
|
83
|
+
metadata
|
|
84
|
+
});
|
|
85
|
+
await fs.writeFile(outHtmlFile, html, 'utf8');
|
|
86
|
+
processedPages.push({ input: pageFile, output: outHtmlFile });
|
|
87
|
+
if (islands.length > 0) {
|
|
88
|
+
allDiscoveredIslands.push(...islands);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Bundle reactive islands
|
|
92
|
+
let bundledIslands = [];
|
|
93
|
+
if (allDiscoveredIslands.length > 0) {
|
|
94
|
+
bundledIslands = await bundleIslands(allDiscoveredIslands, { outDir, minify });
|
|
95
|
+
}
|
|
96
|
+
// Cleanup compile cache
|
|
97
|
+
await clearCache();
|
|
98
|
+
return {
|
|
99
|
+
pages: processedPages,
|
|
100
|
+
islands: bundledIslands,
|
|
101
|
+
outDir
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,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AAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE/D,mBAAmB;QACnB,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;QAE/D,0CAA0C;QAC1C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;YACzC,QAAQ,EAAE,QAAQ;YAClB,SAAS;YACT,QAAQ;SACT,CAAC,CAAC;QAEH,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,cAAc,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;QAE9D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,oBAAoB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,0BAA0B;IAC1B,IAAI,cAAc,GAAa,EAAE,CAAC;IAClC,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,cAAc,GAAG,MAAM,aAAa,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,wBAAwB;IACxB,MAAM,UAAU,EAAE,CAAC;IAEnB,OAAO;QACL,KAAK,EAAE,cAAc;QACrB,OAAO,EAAE,cAAc;QACvB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { BuildConfig } from '../index.js';
|
|
3
|
+
export interface DevServerOptions extends BuildConfig {
|
|
4
|
+
port?: number;
|
|
5
|
+
host?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createDevServer(options?: DevServerOptions): Promise<http.Server>;
|
|
8
|
+
//# sourceMappingURL=dev-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/server/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAS,WAAW,EAAE,MAAM,aAAa,CAAC;AAiBjD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAiG1F"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import { existsSync, watch } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { build } from '../index.js';
|
|
6
|
+
const MIME_TYPES = {
|
|
7
|
+
'.html': 'text/html; charset=utf-8',
|
|
8
|
+
'.js': 'application/javascript; charset=utf-8',
|
|
9
|
+
'.mjs': 'application/javascript; charset=utf-8',
|
|
10
|
+
'.css': 'text/css; charset=utf-8',
|
|
11
|
+
'.json': 'application/json; charset=utf-8',
|
|
12
|
+
'.png': 'image/png',
|
|
13
|
+
'.jpg': 'image/jpeg',
|
|
14
|
+
'.jpeg': 'image/jpeg',
|
|
15
|
+
'.gif': 'image/gif',
|
|
16
|
+
'.svg': 'image/svg+xml',
|
|
17
|
+
'.ico': 'image/x-icon',
|
|
18
|
+
'.woff2': 'font/woff2'
|
|
19
|
+
};
|
|
20
|
+
export async function createDevServer(options = {}) {
|
|
21
|
+
const port = options.port || 3000;
|
|
22
|
+
const host = options.host || 'localhost';
|
|
23
|
+
const root = path.resolve(options.root || process.cwd());
|
|
24
|
+
const outDir = path.resolve(root, options.outDir || 'dist');
|
|
25
|
+
console.log(`[react-html] Performing initial build...`);
|
|
26
|
+
await build({ ...options, minify: false });
|
|
27
|
+
console.log(`[react-html] Build completed.`);
|
|
28
|
+
// Setup file watcher with debounce
|
|
29
|
+
let isRebuilding = false;
|
|
30
|
+
let rebuildTimeout = null;
|
|
31
|
+
const triggerRebuild = () => {
|
|
32
|
+
if (rebuildTimeout)
|
|
33
|
+
clearTimeout(rebuildTimeout);
|
|
34
|
+
rebuildTimeout = setTimeout(async () => {
|
|
35
|
+
if (isRebuilding)
|
|
36
|
+
return;
|
|
37
|
+
isRebuilding = true;
|
|
38
|
+
try {
|
|
39
|
+
console.log(`[react-html] Change detected, rebuilding...`);
|
|
40
|
+
const startTime = Date.now();
|
|
41
|
+
await build({ ...options, minify: false });
|
|
42
|
+
console.log(`[react-html] Rebuild finished in ${Date.now() - startTime}ms`);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.error(`[react-html] Rebuild error:`, err);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
isRebuilding = false;
|
|
49
|
+
}
|
|
50
|
+
}, 100);
|
|
51
|
+
};
|
|
52
|
+
const watchDirs = ['src', 'pages', 'public'].map(d => path.join(root, d)).filter(existsSync);
|
|
53
|
+
for (const dir of watchDirs) {
|
|
54
|
+
try {
|
|
55
|
+
watch(dir, { recursive: true }, (event, filename) => {
|
|
56
|
+
if (filename && !filename.includes('.react-html') && !filename.includes('dist')) {
|
|
57
|
+
triggerRebuild();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Fallback
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const server = http.createServer(async (req, res) => {
|
|
66
|
+
try {
|
|
67
|
+
const url = new URL(req.url || '/', `http://${host}:${port}`);
|
|
68
|
+
let pathname = decodeURIComponent(url.pathname);
|
|
69
|
+
if (pathname.endsWith('/')) {
|
|
70
|
+
pathname += 'index.html';
|
|
71
|
+
}
|
|
72
|
+
let filePath = path.join(outDir, pathname);
|
|
73
|
+
// If no extension, check if an .html file exists
|
|
74
|
+
if (!path.extname(filePath)) {
|
|
75
|
+
if (existsSync(`${filePath}.html`)) {
|
|
76
|
+
filePath = `${filePath}.html`;
|
|
77
|
+
}
|
|
78
|
+
else if (existsSync(path.join(filePath, 'index.html'))) {
|
|
79
|
+
filePath = path.join(filePath, 'index.html');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!existsSync(filePath)) {
|
|
83
|
+
res.writeHead(404, { 'Content-Type': 'text/html' });
|
|
84
|
+
res.end(`<h1>404 Not Found</h1><p>File not found: ${pathname}</p>`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const stat = await fs.stat(filePath);
|
|
88
|
+
if (stat.isDirectory()) {
|
|
89
|
+
filePath = path.join(filePath, 'index.html');
|
|
90
|
+
}
|
|
91
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
92
|
+
const contentType = MIME_TYPES[ext] || 'application/octet-stream';
|
|
93
|
+
const content = await fs.readFile(filePath);
|
|
94
|
+
res.writeHead(200, {
|
|
95
|
+
'Content-Type': contentType,
|
|
96
|
+
'Content-Length': content.length
|
|
97
|
+
});
|
|
98
|
+
res.end(content);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
102
|
+
res.end(`500 Internal Server Error: ${err?.message || err}`);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return new Promise((resolve) => {
|
|
106
|
+
server.listen(port, host, () => {
|
|
107
|
+
console.log(`[react-html] Dev server running at http://${host}:${port}/`);
|
|
108
|
+
resolve(server);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=dev-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../src/server/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,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export interface EngineOptions {
|
|
3
|
+
/** Project root directory (default: process.cwd()) */
|
|
4
|
+
root?: string;
|
|
5
|
+
/** Source pages directory (default: 'src/pages' or 'pages') */
|
|
6
|
+
pagesDir?: string;
|
|
7
|
+
/** Production build output directory (default: 'dist') */
|
|
8
|
+
distDir?: string;
|
|
9
|
+
/** Static public directory (default: 'public') */
|
|
10
|
+
publicDir?: string;
|
|
11
|
+
/** Force production mode. If omitted, checks process.env.NODE_ENV === 'production' */
|
|
12
|
+
isProduction?: boolean;
|
|
13
|
+
/** Base asset URL prefix (default: '/') */
|
|
14
|
+
basePath?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class ReactHtmlEngine {
|
|
17
|
+
readonly root: string;
|
|
18
|
+
readonly pagesDir: string;
|
|
19
|
+
readonly distDir: string;
|
|
20
|
+
readonly publicDir: string;
|
|
21
|
+
readonly isProduction: boolean;
|
|
22
|
+
readonly basePath: string;
|
|
23
|
+
constructor(options?: EngineOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Render a page by name or route.
|
|
26
|
+
* - In production: checks for pre-built static HTML in dist/ first.
|
|
27
|
+
* - In development: recompiles the TSX page on the fly and bundles any needed reactive islands.
|
|
28
|
+
*/
|
|
29
|
+
render(pageRoute: string, props?: Record<string, unknown>, metadata?: Record<string, unknown>): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Universal Connect / Express / Node.js HTTP middleware.
|
|
32
|
+
* Handles page routes and static assets according to environment mode.
|
|
33
|
+
*/
|
|
34
|
+
middleware: (req: IncomingMessage, res: ServerResponse, next?: () => void) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Standalone HTTP request handler suitable for http.createServer(engine.handle)
|
|
37
|
+
*/
|
|
38
|
+
handle: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
39
|
+
private resolveSourcePage;
|
|
40
|
+
private tryServeStaticAsset;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Factory function to create a new ReactHtmlEngine instance
|
|
44
|
+
*/
|
|
45
|
+
export declare function createEngine(options?: EngineOptions): ReactHtmlEngine;
|
|
46
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/server/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMjE,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAiBD,qBAAa,eAAe;IAC1B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,YAAY,EAAE,OAAO,CAAC;IACtC,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,OAAO,GAAE,aAAkB;IA6BvC;;;;OAIG;IACU,MAAM,CACjB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACnC,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,OAAO,CAAC,MAAM,CAAC;IAgDlB;;;OAGG;IACI,UAAU,GACf,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,OAAO,MAAM,IAAI,KAChB,OAAO,CAAC,IAAI,CAAC,CAoEd;IAEF;;OAEG;IACI,MAAM,GAAI,KAAK,eAAe,EAAE,KAAK,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC,CAExE;YAEY,iBAAiB;YAejB,mBAAmB;CA4BlC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,eAAe,CAEzE"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { loadPageModule } from '../core/loader.js';
|
|
5
|
+
import { renderPageToHtml } from '../core/renderer.js';
|
|
6
|
+
import { bundleIslands } from '../core/bundler.js';
|
|
7
|
+
const MIME_TYPES = {
|
|
8
|
+
'.html': 'text/html; charset=utf-8',
|
|
9
|
+
'.js': 'application/javascript; charset=utf-8',
|
|
10
|
+
'.mjs': 'application/javascript; charset=utf-8',
|
|
11
|
+
'.css': 'text/css; charset=utf-8',
|
|
12
|
+
'.json': 'application/json; charset=utf-8',
|
|
13
|
+
'.png': 'image/png',
|
|
14
|
+
'.jpg': 'image/jpeg',
|
|
15
|
+
'.jpeg': 'image/jpeg',
|
|
16
|
+
'.gif': 'image/gif',
|
|
17
|
+
'.svg': 'image/svg+xml',
|
|
18
|
+
'.ico': 'image/x-icon',
|
|
19
|
+
'.woff2': 'font/woff2'
|
|
20
|
+
};
|
|
21
|
+
export class ReactHtmlEngine {
|
|
22
|
+
root;
|
|
23
|
+
pagesDir;
|
|
24
|
+
distDir;
|
|
25
|
+
publicDir;
|
|
26
|
+
isProduction;
|
|
27
|
+
basePath;
|
|
28
|
+
constructor(options = {}) {
|
|
29
|
+
this.root = path.resolve(options.root || process.cwd());
|
|
30
|
+
this.isProduction =
|
|
31
|
+
options.isProduction !== undefined
|
|
32
|
+
? options.isProduction
|
|
33
|
+
: process.env.NODE_ENV === 'production';
|
|
34
|
+
this.basePath = options.basePath || '/';
|
|
35
|
+
// Resolve distDir
|
|
36
|
+
this.distDir = path.resolve(this.root, options.distDir || 'dist');
|
|
37
|
+
this.publicDir = path.resolve(this.root, options.publicDir || 'public');
|
|
38
|
+
// Resolve pagesDir
|
|
39
|
+
if (options.pagesDir) {
|
|
40
|
+
this.pagesDir = path.resolve(this.root, options.pagesDir);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const candidates = ['src/pages', 'pages'];
|
|
44
|
+
let found = path.join(this.root, 'src/pages');
|
|
45
|
+
for (const cand of candidates) {
|
|
46
|
+
const p = path.join(this.root, cand);
|
|
47
|
+
if (existsSync(p)) {
|
|
48
|
+
found = p;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this.pagesDir = found;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Render a page by name or route.
|
|
57
|
+
* - In production: checks for pre-built static HTML in dist/ first.
|
|
58
|
+
* - In development: recompiles the TSX page on the fly and bundles any needed reactive islands.
|
|
59
|
+
*/
|
|
60
|
+
async render(pageRoute, props = {}, metadata = {}) {
|
|
61
|
+
const cleanRoute = pageRoute.replace(/^\/+/, '').replace(/\.html$/, '');
|
|
62
|
+
const normalizedName = cleanRoute === '' ? 'index' : cleanRoute;
|
|
63
|
+
// In production, check for pre-built static HTML
|
|
64
|
+
if (this.isProduction) {
|
|
65
|
+
const candidatePaths = [
|
|
66
|
+
path.join(this.distDir, `${normalizedName}.html`),
|
|
67
|
+
path.join(this.distDir, normalizedName, 'index.html')
|
|
68
|
+
];
|
|
69
|
+
for (const candidate of candidatePaths) {
|
|
70
|
+
if (existsSync(candidate)) {
|
|
71
|
+
return await fs.readFile(candidate, 'utf8');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// In development (or if production pre-build not found), compile on-the-fly
|
|
76
|
+
const sourceFilePath = await this.resolveSourcePage(normalizedName);
|
|
77
|
+
if (!sourceFilePath) {
|
|
78
|
+
throw new Error(`[react-html] Page "${pageRoute}" not found in "${this.pagesDir}".`);
|
|
79
|
+
}
|
|
80
|
+
const { Component, metadata: pageMeta } = await loadPageModule(sourceFilePath);
|
|
81
|
+
const mergedMetadata = { ...pageMeta, ...metadata };
|
|
82
|
+
const { html, islands } = renderPageToHtml({
|
|
83
|
+
pagePath: sourceFilePath,
|
|
84
|
+
Component,
|
|
85
|
+
props,
|
|
86
|
+
metadata: mergedMetadata,
|
|
87
|
+
basePath: this.basePath
|
|
88
|
+
});
|
|
89
|
+
// In development, bundle reactive islands on-the-fly into distDir/assets/islands
|
|
90
|
+
if (islands.length > 0) {
|
|
91
|
+
await bundleIslands(islands, {
|
|
92
|
+
outDir: this.distDir,
|
|
93
|
+
minify: this.isProduction
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return html;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Universal Connect / Express / Node.js HTTP middleware.
|
|
100
|
+
* Handles page routes and static assets according to environment mode.
|
|
101
|
+
*/
|
|
102
|
+
middleware = async (req, res, next) => {
|
|
103
|
+
const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
|
|
104
|
+
let pathname = decodeURIComponent(url.pathname);
|
|
105
|
+
// 1. Check if request matches an asset in dist/ or public/
|
|
106
|
+
const assetResponse = await this.tryServeStaticAsset(pathname);
|
|
107
|
+
if (assetResponse) {
|
|
108
|
+
res.writeHead(200, {
|
|
109
|
+
'Content-Type': assetResponse.contentType,
|
|
110
|
+
'Content-Length': assetResponse.content.length
|
|
111
|
+
});
|
|
112
|
+
res.end(assetResponse.content);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// 2. Normalize page route
|
|
116
|
+
let route = pathname.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
117
|
+
if (route === '' || route.endsWith('.html')) {
|
|
118
|
+
route = route.replace(/\.html$/, '') || 'index';
|
|
119
|
+
}
|
|
120
|
+
// 3. Try rendering the page
|
|
121
|
+
try {
|
|
122
|
+
// In production: check if dist HTML exists
|
|
123
|
+
if (this.isProduction) {
|
|
124
|
+
const candidatePaths = [
|
|
125
|
+
path.join(this.distDir, `${route}.html`),
|
|
126
|
+
path.join(this.distDir, route, 'index.html')
|
|
127
|
+
];
|
|
128
|
+
for (const candidate of candidatePaths) {
|
|
129
|
+
if (existsSync(candidate)) {
|
|
130
|
+
const content = await fs.readFile(candidate);
|
|
131
|
+
res.writeHead(200, {
|
|
132
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
133
|
+
'Content-Length': content.length
|
|
134
|
+
});
|
|
135
|
+
res.end(content);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// In development: check if source page exists
|
|
142
|
+
const sourcePath = await this.resolveSourcePage(route);
|
|
143
|
+
if (sourcePath) {
|
|
144
|
+
const html = await this.render(route);
|
|
145
|
+
const buffer = Buffer.from(html, 'utf8');
|
|
146
|
+
res.writeHead(200, {
|
|
147
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
148
|
+
'Content-Length': buffer.length
|
|
149
|
+
});
|
|
150
|
+
res.end(buffer);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
console.error(`[react-html] Engine rendering error for route "${pathname}":`, err);
|
|
157
|
+
res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
158
|
+
res.end(`500 Internal Server Error: ${err?.message || err}`);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// If not handled, pass to next middleware if available
|
|
162
|
+
if (typeof next === 'function') {
|
|
163
|
+
next();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
res.writeHead(404, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
167
|
+
res.end(`<h1>404 Not Found</h1><p>Route "${pathname}" not found.</p>`);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Standalone HTTP request handler suitable for http.createServer(engine.handle)
|
|
172
|
+
*/
|
|
173
|
+
handle = (req, res) => {
|
|
174
|
+
return this.middleware(req, res);
|
|
175
|
+
};
|
|
176
|
+
async resolveSourcePage(normalizedName) {
|
|
177
|
+
const extensions = ['.tsx', '.jsx', '.ts', '.js'];
|
|
178
|
+
const candidates = [
|
|
179
|
+
...extensions.map(ext => path.join(this.pagesDir, `${normalizedName}${ext}`)),
|
|
180
|
+
...extensions.map(ext => path.join(this.pagesDir, normalizedName, `index${ext}`))
|
|
181
|
+
];
|
|
182
|
+
for (const cand of candidates) {
|
|
183
|
+
if (existsSync(cand)) {
|
|
184
|
+
return cand;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
async tryServeStaticAsset(pathname) {
|
|
190
|
+
const ext = path.extname(pathname).toLowerCase();
|
|
191
|
+
if (!ext || ext === '.html')
|
|
192
|
+
return null;
|
|
193
|
+
const cleanPath = pathname.replace(/^\/+/, '');
|
|
194
|
+
const candidateFiles = [
|
|
195
|
+
path.join(this.distDir, cleanPath),
|
|
196
|
+
path.join(this.publicDir, cleanPath)
|
|
197
|
+
];
|
|
198
|
+
for (const filePath of candidateFiles) {
|
|
199
|
+
if (existsSync(filePath)) {
|
|
200
|
+
try {
|
|
201
|
+
const stat = await fs.stat(filePath);
|
|
202
|
+
if (stat.isFile()) {
|
|
203
|
+
const content = await fs.readFile(filePath);
|
|
204
|
+
const contentType = MIME_TYPES[ext] || 'application/octet-stream';
|
|
205
|
+
return { content, contentType };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// Continue searching
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Factory function to create a new ReactHtmlEngine instance
|
|
218
|
+
*/
|
|
219
|
+
export function createEngine(options = {}) {
|
|
220
|
+
return new ReactHtmlEngine(options);
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/server/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAkBnD,MAAM,UAAU,GAA2B;IACzC,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,uCAAuC;IAC9C,MAAM,EAAE,uCAAuC;IAC/C,MAAM,EAAE,yBAAyB;IACjC,OAAO,EAAE,iCAAiC;IAC1C,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,cAAc;IACtB,QAAQ,EAAE,YAAY;CACvB,CAAC;AAEF,MAAM,OAAO,eAAe;IACV,IAAI,CAAS;IACb,QAAQ,CAAS;IACjB,OAAO,CAAS;IAChB,SAAS,CAAS;IAClB,YAAY,CAAU;IACtB,QAAQ,CAAS;IAEjC,YAAY,UAAyB,EAAE;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,YAAY;YACf,OAAO,CAAC,YAAY,KAAK,SAAS;gBAChC,CAAC,CAAC,OAAO,CAAC,YAAY;gBACtB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;QAC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"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|