jinrai 1.0.4 → 1.0.7
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/config.ts +1 -0
- package/front.config.json +24 -0
- package/index.ts +6 -1
- package/lib/bin/bin.js +12 -0
- package/lib/config/config.d.ts +1 -0
- package/lib/config/config.js +1 -0
- package/lib/{src → config/src/bin}/config/userConfig.d.ts +0 -2
- package/lib/index.d.ts +6 -1
- package/lib/index.js +2 -1
- package/lib/src/front/server-state/DataProxy.d.ts +8 -0
- package/lib/src/front/server-state/DataProxy.js +104 -0
- package/lib/src/front/server-state/SSR.d.ts +4 -0
- package/lib/src/front/server-state/SSR.js +6 -0
- package/lib/src/front/server-state/real.d.ts +1 -0
- package/lib/src/front/server-state/real.js +36 -0
- package/lib/src/front/server-state/serverStates.d.ts +5 -0
- package/lib/src/front/server-state/serverStates.js +29 -0
- package/lib/src/front/server-state/useServerState.d.ts +14 -0
- package/lib/src/front/server-state/useServerState.js +28 -0
- package/lib/src/front/url/JinraiContext.d.ts +6 -0
- package/lib/src/front/url/JinraiContext.js +8 -0
- package/lib/src/front/url/adapter/def.d.ts +2 -0
- package/lib/src/front/url/adapter/def.js +9 -0
- package/lib/src/front/url/adapter/rrd6.d.ts +2 -0
- package/lib/src/front/url/adapter/rrd6.js +12 -0
- package/lib/src/front/url/adapter/rrd7.d.ts +2 -0
- package/lib/src/front/url/adapter/rrd7.js +11 -0
- package/lib/src/front/url/params/useParamsIndex.d.ts +1 -0
- package/lib/src/front/url/params/useParamsIndex.js +15 -0
- package/lib/src/front/url/search/useSearch.d.ts +1 -0
- package/lib/src/front/url/search/useSearch.js +15 -0
- package/lib/src/front/url/search/useSearchValue.d.ts +16 -0
- package/lib/src/front/url/search/useSearchValue.js +49 -0
- package/lib/src/front/wrapper/Custom.d.ts +8 -0
- package/lib/src/front/wrapper/Custom.js +9 -0
- package/lib/vite/plugin.js +1 -0
- package/package.json +39 -7
- package/readme.md +11 -0
- package/rollup.front.config.mjs +57 -0
- package/src/bin/bin.ts +10 -0
- package/src/bin/build/build.ts +69 -0
- package/src/{config → bin/config}/userConfig.ts +0 -2
- package/src/bin/playwright/pageCollector.ts +11 -0
- package/src/{templates.ts → bin/playwright/templates.ts} +20 -29
- package/src/{routes → bin/routes}/Parser.ts +3 -3
- package/src/{routes → bin/routes}/getRoutes.ts +4 -4
- package/src/front/server-state/DataProxy.ts +120 -0
- package/src/front/server-state/SSR.ts +4 -0
- package/src/front/server-state/real.ts +41 -0
- package/src/front/server-state/serverStates.ts +36 -0
- package/src/front/server-state/useServerState.ts +48 -0
- package/src/front/url/JinraiContext.tsx +10 -0
- package/src/front/url/adapter/def.tsx +10 -0
- package/src/front/url/adapter/rrd6.tsx +16 -0
- package/src/front/url/adapter/rrd7.tsx +15 -0
- package/src/front/url/params/useParamsIndex.ts +16 -0
- package/src/front/url/search/useSearch.ts +15 -0
- package/src/front/url/search/useSearchValue.ts +72 -0
- package/src/front/wrapper/Custom.tsx +14 -0
- package/tests/custom.test.ts +2 -2
- package/tests/parse.test.ts +3 -3
- package/tsconfig.json +2 -2
- package/vite/plugin.ts +83 -0
- package/lib/bin.js +0 -12
- package/lib/generate.js +0 -26
- package/src/bin.ts +0 -66
- /package/lib/{src → config/src/bin}/config/define.d.ts +0 -0
- /package/src/{config → bin/config}/defaultIndexHtml.ts +0 -0
- /package/src/{config → bin/config}/define.ts +0 -0
- /package/src/{content/normolizeContent.ts → bin/content/normalizeContent.ts} +0 -0
- /package/src/{routes → bin/routes}/replaceDevScripts.ts +0 -0
- /package/src/{server → bin/server}/vitePreview.ts +0 -0
- /package/src/{types → bin/types}/shims.d.ts +0 -0
- /package/src/{ui → bin/ui}/task.tsx +0 -0
package/lib/generate.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/config/userConfig.ts
|
|
4
|
-
import { createJiti } from "jiti";
|
|
5
|
-
import { pathToFileURL } from "url";
|
|
6
|
-
import { resolve } from "path";
|
|
7
|
-
var getUserConfig = async () => {
|
|
8
|
-
const jiti = createJiti(import.meta.url, {
|
|
9
|
-
debug: false
|
|
10
|
-
});
|
|
11
|
-
const configPath = pathToFileURL(resolve(process.cwd(), ".ssr.config")).href;
|
|
12
|
-
console.log("#######", { configPath });
|
|
13
|
-
const configModule = await jiti.import(configPath);
|
|
14
|
-
return configModule.default;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/generate.ts
|
|
18
|
-
import ReactDOMServer from "react-dom/server";
|
|
19
|
-
console.log(">>");
|
|
20
|
-
var config = await getUserConfig();
|
|
21
|
-
for (const mask of config.pages) {
|
|
22
|
-
console.log(" - ", mask);
|
|
23
|
-
const url = mask.replaceAll("{", "").replaceAll("}", "");
|
|
24
|
-
const html = ReactDOMServer.renderToString(config.renderPage(url));
|
|
25
|
-
console.log(html);
|
|
26
|
-
}
|
package/src/bin.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { writeFile } from "node:fs/promises"
|
|
4
|
-
import { Config, getUserConfig, IndexProps } from "./config/userConfig"
|
|
5
|
-
import { getRoutesAndTemplates } from "./routes/getRoutes"
|
|
6
|
-
import { getRawPageData } from "./templates"
|
|
7
|
-
import path from "node:path"
|
|
8
|
-
import { mkdir } from "node:fs/promises"
|
|
9
|
-
import Task from "./ui/task"
|
|
10
|
-
import { defaultIndexHtml } from "./config/defaultIndexHtml"
|
|
11
|
-
import { removeDevScripts } from "./routes/replaceDevScripts"
|
|
12
|
-
import { normalizeHtmlWhitespace } from "./content/normolizeContent"
|
|
13
|
-
import { vitePreview } from "./server/vitePreview"
|
|
14
|
-
|
|
15
|
-
const indexProps: IndexProps = {
|
|
16
|
-
html: "<!--app-html-->",
|
|
17
|
-
head: "<!--app-head-->",
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const task = new Task()
|
|
21
|
-
|
|
22
|
-
const configName = process.argv[2] ? process.argv[2] : "jinrai.config"
|
|
23
|
-
task.do("Init")
|
|
24
|
-
const config: Config = await getUserConfig(configName)
|
|
25
|
-
task.success()
|
|
26
|
-
|
|
27
|
-
const [serverUrl, close] = await vitePreview()
|
|
28
|
-
|
|
29
|
-
const data = await getRawPageData(serverUrl, config.pages, config.test, config.debug)
|
|
30
|
-
|
|
31
|
-
close()
|
|
32
|
-
|
|
33
|
-
const outputcashe = path.join(config.dist ?? "dist", ".cached")
|
|
34
|
-
|
|
35
|
-
task.do("Format")
|
|
36
|
-
const { routes, templates } = getRoutesAndTemplates(data.pages)
|
|
37
|
-
|
|
38
|
-
task.next(`Export: (${templates.length})`)
|
|
39
|
-
await mkdir(outputcashe, { recursive: true })
|
|
40
|
-
|
|
41
|
-
console.log("dev")
|
|
42
|
-
|
|
43
|
-
const exportConfig = { routes, proxy: config.proxy, meta: config.meta }
|
|
44
|
-
|
|
45
|
-
await writeFile(path.join(outputcashe, "config.json"), JSON.stringify(exportConfig, null, 2))
|
|
46
|
-
// await writeFile(
|
|
47
|
-
// path.join(outputcashe, "index.html"),
|
|
48
|
-
// config.index ? config.index(indexProps) : removeDevScripts(data.indexHtml ?? defaultIndexHtml),
|
|
49
|
-
// )
|
|
50
|
-
|
|
51
|
-
for await (const [template, name] of Object.entries(templates)) {
|
|
52
|
-
await writeFile(path.join(outputcashe, `${name}.html`), template)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (config.test) {
|
|
56
|
-
task.next(`Tests`)
|
|
57
|
-
for await (const page of data.pages) {
|
|
58
|
-
if (!page.test) {
|
|
59
|
-
continue
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
await writeFile(path.join(outputcashe, `test_${page.id}.html`), normalizeHtmlWhitespace(page.test))
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
task.success()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|