jinrai 1.1.4 → 1.1.6
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/index.ts +4 -0
- package/lib/bin/bin.js +14 -8
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/src/bin/config/userConfig.d.ts +1 -0
- package/lib/src/front/server-state/DataProxy.js +3 -1
- package/lib/src/front/server-state/orig.js +3 -0
- package/lib/src/front/server-state/serverStates.js +5 -3
- package/lib/src/front/url/JinraiContext.d.ts +2 -1
- package/lib/src/front/url/JinraiContext.js +0 -1
- package/lib/src/front/url/JinraiDebug.d.ts +6 -0
- package/lib/src/front/url/JinraiDebug.js +8 -0
- package/package.json +2 -2
- package/src/bin/bin.ts +1 -0
- package/src/bin/build/build.ts +2 -2
- package/src/bin/config/define.ts +1 -3
- package/src/bin/config/userConfig.ts +1 -0
- package/src/bin/playwright/templates.ts +1 -1
- package/src/bin/server/vitePreview.ts +14 -5
- package/src/front/server-state/DataProxy.ts +4 -2
- package/src/front/server-state/orig.ts +3 -0
- package/src/front/server-state/serverStates.ts +5 -3
- package/src/front/url/JinraiContext.tsx +2 -2
- package/src/front/url/JinraiDebug.tsx +12 -0
- package/tests/parse/custom.test.ts +2 -1
package/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export { JinraiContext } from "./src/front/url/JinraiContext"
|
|
2
|
+
|
|
3
|
+
export { JinraiDebug } from "./src/front/url/JinraiDebug"
|
|
4
|
+
|
|
1
5
|
export type { ServerKey } from "./src/front/server-state/useServerState"
|
|
2
6
|
|
|
3
7
|
export { useServerState } from "./src/front/server-state/useServerState"
|
package/lib/bin/bin.js
CHANGED
|
@@ -9,7 +9,7 @@ import ora, { spinners } from 'ora';
|
|
|
9
9
|
import { stdout, stdin } from 'node:process';
|
|
10
10
|
import readline from 'node:readline/promises';
|
|
11
11
|
import path from 'node:path';
|
|
12
|
-
import {
|
|
12
|
+
import { createServer } from 'vite';
|
|
13
13
|
|
|
14
14
|
const getUserConfig = async (configName) => {
|
|
15
15
|
const jiti = createJiti(import.meta.url, {
|
|
@@ -271,7 +271,7 @@ const getRawPageData = async (url, pages, test = false, debug = false) => {
|
|
|
271
271
|
const path = mask.replaceAll("{", "").replaceAll("}", "").replace("\/*", "");
|
|
272
272
|
await page.goto(url + path);
|
|
273
273
|
await page.waitForLoadState("networkidle");
|
|
274
|
-
await page.waitForTimeout(
|
|
274
|
+
await page.waitForTimeout(2000);
|
|
275
275
|
const { state, root, lang } = await pageCollector(page);
|
|
276
276
|
if (defaultLang == undefined) {
|
|
277
277
|
defaultLang = lang;
|
|
@@ -304,11 +304,17 @@ const getRawPageData = async (url, pages, test = false, debug = false) => {
|
|
|
304
304
|
};
|
|
305
305
|
|
|
306
306
|
const vitePreview = async () => {
|
|
307
|
-
const previewServer = await preview({
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
307
|
+
// const previewServer = await preview({
|
|
308
|
+
// preview: {
|
|
309
|
+
// port: 8084,
|
|
310
|
+
// },
|
|
311
|
+
// })
|
|
312
|
+
const previewServer = await createServer({
|
|
313
|
+
server: {
|
|
314
|
+
port: 8084
|
|
315
|
+
}
|
|
311
316
|
});
|
|
317
|
+
await previewServer.listen();
|
|
312
318
|
if (!previewServer.resolvedUrls?.local?.length)
|
|
313
319
|
throw new Error("vite is not defined");
|
|
314
320
|
return [previewServer.resolvedUrls?.local[0].slice(0, -1), () => previewServer.close()];
|
|
@@ -322,7 +328,7 @@ const runBuild = async (options) => {
|
|
|
322
328
|
task.success();
|
|
323
329
|
const [serverUrl, close] = await vitePreview();
|
|
324
330
|
const { pages, lang } = await getRawPageData(serverUrl, config.pages, config.test, options.debug);
|
|
325
|
-
console.log({ lang })
|
|
331
|
+
// console.log({ lang })
|
|
326
332
|
close();
|
|
327
333
|
const outputcashe = path.join(config.dist ?? "dist", ".cached");
|
|
328
334
|
task.do("Format");
|
|
@@ -330,7 +336,7 @@ const runBuild = async (options) => {
|
|
|
330
336
|
task.next(`Export: (${templates.length})`);
|
|
331
337
|
await mkdir(outputcashe, { recursive: true });
|
|
332
338
|
console.log("dev");
|
|
333
|
-
const exportConfig = { routes, proxy: config.proxy, meta: config.meta, lang };
|
|
339
|
+
const exportConfig = { routes, proxy: config.proxy, meta: config.meta, lang, cacheablePaths: config.cacheablePaths };
|
|
334
340
|
await writeFile(path.join(outputcashe, "config.json"), JSON.stringify(exportConfig, null, 2));
|
|
335
341
|
// await writeFile(
|
|
336
342
|
// path.join(outputcashe, "index.html"),
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { JinraiContext } from "./src/front/url/JinraiContext";
|
|
2
|
+
export { JinraiDebug } from "./src/front/url/JinraiDebug";
|
|
1
3
|
export type { ServerKey } from "./src/front/server-state/useServerState";
|
|
2
4
|
export { useServerState } from "./src/front/server-state/useServerState";
|
|
3
5
|
export { orig, original } from "./src/front/server-state/orig";
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { JinraiContext } from './src/front/url/JinraiContext.js';
|
|
2
|
+
export { JinraiDebug } from './src/front/url/JinraiDebug.js';
|
|
1
3
|
export { useServerState } from './src/front/server-state/useServerState.js';
|
|
2
4
|
export { orig, original } from './src/front/server-state/orig.js';
|
|
3
5
|
export { useParamsIndex } from './src/front/url/params/useParamsIndex.js';
|
|
@@ -19,8 +19,10 @@ const getTarget = (data, path) => {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
function createDataProxy(data, path = "") {
|
|
22
|
-
if (path.endsWith("@"))
|
|
22
|
+
if (path.endsWith("@")) {
|
|
23
|
+
console.log("set to source >>>> ", path);
|
|
23
24
|
sources.set(path.slice(0, -1), data);
|
|
25
|
+
}
|
|
24
26
|
return new Proxy(getTarget(data, path), {
|
|
25
27
|
get: (_target, prop) => {
|
|
26
28
|
if (ssr.exportToJV) {
|
|
@@ -21,17 +21,18 @@ const getIdent = (key) => {
|
|
|
21
21
|
return Array.isArray(key) ? key.join("-") : key;
|
|
22
22
|
};
|
|
23
23
|
const getServerValue = (key, def, options) => {
|
|
24
|
+
console.log("KKKey", key);
|
|
24
25
|
if (key == undefined) {
|
|
25
26
|
return [def, false];
|
|
26
27
|
}
|
|
27
28
|
const ident = getIdent(key);
|
|
28
29
|
serverStates.set(ident, { options, value: !options?.source ? def : undefined, key });
|
|
29
|
-
console.log("CHECK", ident)
|
|
30
|
+
// console.log("CHECK", ident)
|
|
30
31
|
if (ident in initialState) {
|
|
31
32
|
const result = initialState[ident];
|
|
32
33
|
// delete initialState[ident]
|
|
33
|
-
console.log("HAS", ident, result)
|
|
34
|
-
if (result != null && typeof result ==
|
|
34
|
+
// console.log("HAS", ident, result)
|
|
35
|
+
if (result != null && typeof result == "object" && "data" in result) {
|
|
35
36
|
return [result.data, true];
|
|
36
37
|
}
|
|
37
38
|
return [result, true];
|
|
@@ -39,6 +40,7 @@ const getServerValue = (key, def, options) => {
|
|
|
39
40
|
return [def, false];
|
|
40
41
|
};
|
|
41
42
|
const setServerValue = (key, value, options) => {
|
|
43
|
+
console.log("KKK>>", key);
|
|
42
44
|
const ident = getIdent(key);
|
|
43
45
|
serverStates.set(ident, { options, value: !options?.source ? value : undefined, key });
|
|
44
46
|
return createDataProxy(value, `${ident}@`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jinrai",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "A powerful library that analyzes your modern web application and automatically generates a perfectly rendered, static snapshot of its pages. Experience unparalleled loading speed and SEO clarity without the complexity of traditional SSR setups. Simply point Jinrai at your SPA and witness divine speed.",
|
|
5
5
|
"main": "lib/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"import": "./lib/src/front/url/adapter/rrd7.js"
|
|
65
65
|
},
|
|
66
66
|
"./config": {
|
|
67
|
-
"types": "./lib/config
|
|
67
|
+
"types": "./lib/config.d.ts",
|
|
68
68
|
"import": "./lib/config/config.js"
|
|
69
69
|
},
|
|
70
70
|
"./vite": {
|
package/src/bin/bin.ts
CHANGED
package/src/bin/build/build.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const runBuild = async (options: buildArgs) => {
|
|
|
30
30
|
|
|
31
31
|
const { pages, lang } = await getRawPageData(serverUrl, config.pages, config.test, options.debug)
|
|
32
32
|
|
|
33
|
-
console.log({ lang })
|
|
33
|
+
// console.log({ lang })
|
|
34
34
|
|
|
35
35
|
close()
|
|
36
36
|
|
|
@@ -44,7 +44,7 @@ export const runBuild = async (options: buildArgs) => {
|
|
|
44
44
|
|
|
45
45
|
console.log("dev")
|
|
46
46
|
|
|
47
|
-
const exportConfig = { routes, proxy: config.proxy, meta: config.meta, lang }
|
|
47
|
+
const exportConfig = { routes, proxy: config.proxy, meta: config.meta, lang, cacheablePaths: config.cacheablePaths }
|
|
48
48
|
|
|
49
49
|
await writeFile(path.join(outputcashe, "config.json"), JSON.stringify(exportConfig, null, 2))
|
|
50
50
|
// await writeFile(
|
package/src/bin/config/define.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { preview } from "vite"
|
|
1
|
+
import { createServer, preview } from "vite"
|
|
2
2
|
|
|
3
3
|
export const vitePreview = async () => {
|
|
4
|
-
const previewServer = await preview({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
// const previewServer = await preview({
|
|
5
|
+
// preview: {
|
|
6
|
+
// port: 8084,
|
|
7
|
+
// },
|
|
8
|
+
// })
|
|
9
|
+
|
|
10
|
+
const previewServer = await createServer({
|
|
11
|
+
server: {
|
|
12
|
+
port: 8084
|
|
13
|
+
}
|
|
8
14
|
})
|
|
9
15
|
|
|
16
|
+
await previewServer.listen()
|
|
17
|
+
|
|
18
|
+
|
|
10
19
|
if (!previewServer.resolvedUrls?.local?.length) throw new Error("vite is not defined")
|
|
11
20
|
|
|
12
21
|
return [previewServer.resolvedUrls?.local[0].slice(0, -1), () => previewServer.close()] as [string, () => void]
|
|
@@ -31,8 +31,10 @@ const getTarget = (data: any, path: string) => {
|
|
|
31
31
|
|
|
32
32
|
type WithDataProxy<T> = T & DataProxy
|
|
33
33
|
function createDataProxy<T>(data: T, path: string = ""): WithDataProxy<T> {
|
|
34
|
-
if (path.endsWith("@"))
|
|
35
|
-
|
|
34
|
+
if (path.endsWith("@")) {
|
|
35
|
+
console.log("set to source >>>> ", path)
|
|
36
|
+
sources.set(path.slice(0, -1), data)
|
|
37
|
+
}
|
|
36
38
|
return new Proxy(getTarget(data, path), {
|
|
37
39
|
get: (_target: any, prop: PropertyKey) => {
|
|
38
40
|
if (ssr.exportToJV) {
|
|
@@ -45,21 +45,22 @@ export const getIdent = (key: ServerKey): string => {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export const getServerValue = (key?: ServerKey, def?: ServerValue["value"], options?: ServerValue["options"]) => {
|
|
48
|
+
// console.log("KKKey", key)
|
|
48
49
|
if (key == undefined) {
|
|
49
50
|
return [def, false]
|
|
50
51
|
}
|
|
51
52
|
const ident = getIdent(key)
|
|
52
53
|
serverStates.set(ident, { options, value: !options?.source ? def : undefined, key })
|
|
53
54
|
|
|
54
|
-
console.log("CHECK", ident)
|
|
55
|
+
// console.log("CHECK", ident)
|
|
55
56
|
|
|
56
57
|
if (ident in initialState) {
|
|
57
58
|
const result = initialState[ident]
|
|
58
59
|
// delete initialState[ident]
|
|
59
60
|
|
|
60
|
-
console.log("HAS", ident, result)
|
|
61
|
+
// console.log("HAS", ident, result)
|
|
61
62
|
|
|
62
|
-
if (result != null && typeof result ==
|
|
63
|
+
if (result != null && typeof result == "object" && "data" in result) {
|
|
63
64
|
return [result.data, true]
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -70,6 +71,7 @@ export const getServerValue = (key?: ServerKey, def?: ServerValue["value"], opti
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
export const setServerValue = (key: ServerKey, value: ServerValue["value"], options?: ServerValue["options"]) => {
|
|
74
|
+
// console.log("KKK>>", key)
|
|
73
75
|
const ident = getIdent(key)
|
|
74
76
|
serverStates.set(ident, { options, value: !options?.source ? value : undefined, key })
|
|
75
77
|
return createDataProxy(value, `${ident}@`)
|
|
@@ -3,10 +3,10 @@ import { createContext, DependencyList, ReactNode } from "react"
|
|
|
3
3
|
export interface JinraiProps {
|
|
4
4
|
deps?: DependencyList
|
|
5
5
|
children?: ReactNode
|
|
6
|
-
search
|
|
6
|
+
search?: string
|
|
7
|
+
debug?: string
|
|
7
8
|
}
|
|
8
9
|
export const JinraiContext = createContext<JinraiProps>({
|
|
9
10
|
deps: [],
|
|
10
11
|
children: undefined,
|
|
11
|
-
search: ""
|
|
12
12
|
})
|
|
@@ -9,7 +9,8 @@ describe("test custom component", async () => {
|
|
|
9
9
|
|
|
10
10
|
it("parse custom.html", async () => {
|
|
11
11
|
const html = await readFile("./tests/parse/content/custom.html", "utf-8")
|
|
12
|
-
|
|
12
|
+
const result = parsr.parse(html)
|
|
13
|
+
// expect(JSON.stringify(result)).toEqual("")
|
|
13
14
|
|
|
14
15
|
expect(parsr.parse(html)).toEqual(custom)
|
|
15
16
|
})
|