jinrai 1.0.2 → 1.0.3

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.html CHANGED
@@ -1,15 +1,12 @@
1
1
  <!doctype html>
2
2
  <html lang="ru">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
- @META
9
- @DATA
10
- @ASSETS
11
- </head>
12
-
13
- <body>
14
- <div id="root">@ROOT</div>
15
- </body>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <!--app-head-->
8
+ </head>
9
+ <body>
10
+ <div id="root"><!--app-html--></div>
11
+ </body>
12
+ </html>
package/lib/bin.js CHANGED
@@ -12,11 +12,11 @@ import { writeFile } from "node:fs/promises";
12
12
  import { createJiti } from "jiti";
13
13
  import { pathToFileURL } from "url";
14
14
  import { resolve } from "path";
15
- var getUserConfig = async () => {
15
+ var getUserConfig = async (configName2) => {
16
16
  const jiti = createJiti(import.meta.url, {
17
17
  debug: false
18
18
  });
19
- const configPath = pathToFileURL(resolve(process.cwd(), "jinrai.config")).href;
19
+ const configPath = pathToFileURL(resolve(process.cwd(), configName2)).href;
20
20
  const configModule = await jiti.import(configPath);
21
21
  return configModule.default;
22
22
  };
@@ -3278,10 +3278,10 @@ var getRawPageData = async (url, pages, debug = false) => {
3278
3278
  await page.goto(url + path2);
3279
3279
  await page.waitForLoadState("networkidle");
3280
3280
  await page.waitForTimeout(1e3);
3281
- const requests = await page.evaluate(() => {
3282
- return window.__ssr_preload;
3281
+ const input2 = await page.evaluate(() => {
3282
+ return window.__page_requests;
3283
3283
  });
3284
- const input2 = requests ? JSON.parse(requests) : [];
3284
+ if (debug) console.log({ input: input2 });
3285
3285
  const root = await page.locator("#root").innerHTML();
3286
3286
  if (debug) {
3287
3287
  await task2.ask("continue?");
@@ -3323,10 +3323,11 @@ var defaultIndexHtml = `
3323
3323
 
3324
3324
  // src/bin.ts
3325
3325
  var task = new Task();
3326
- task.do("Load config");
3327
- var config = await getUserConfig();
3326
+ var configName = process.argv[2] ? process.argv[2] : "jinrai.config";
3327
+ task.do("Init: " + configName);
3328
+ var config = await getUserConfig(configName);
3328
3329
  task.success();
3329
- var data = await getRawPageData(config.url, config.pages, config.dev);
3330
+ var data = await getRawPageData(config.url, config.pages, config.debug);
3330
3331
  task.do("Format");
3331
3332
  var { routes, templates } = getRoutesAndTemplates(data.pages);
3332
3333
  task.next(`Export: ${config.outDir} (${templates.length})`);
@@ -1,9 +1,7 @@
1
1
  export interface Config {
2
2
  url: string;
3
3
  pages: string[];
4
- api: string;
5
- dev?: boolean;
6
- meta: string;
4
+ debug?: boolean;
7
5
  outDir: string;
8
6
  }
9
- export declare const getUserConfig: () => Promise<Config>;
7
+ export declare const getUserConfig: (configName: string) => Promise<Config>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinrai",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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": {
package/src/bin.ts CHANGED
@@ -12,11 +12,12 @@ import { defaultIndexHtml } from "./config/defaultIndexHtml"
12
12
 
13
13
  const task = new Task()
14
14
 
15
- task.do("Load config")
16
- const config: Config = await getUserConfig()
15
+ const configName = process.argv[2] ? process.argv[2] : "jinrai.config"
16
+ task.do("Init: " + configName)
17
+ const config: Config = await getUserConfig(configName)
17
18
  task.success()
18
19
 
19
- const data = await getRawPageData(config.url, config.pages, config.dev)
20
+ const data = await getRawPageData(config.url, config.pages, config.debug)
20
21
 
21
22
  task.do("Format")
22
23
  const { routes, templates } = getRoutesAndTemplates(data.pages)
@@ -5,18 +5,16 @@ import { resolve } from "path"
5
5
  export interface Config {
6
6
  url: string
7
7
  pages: string[]
8
- api: string
9
- dev?: boolean
10
- meta: string
8
+ debug?: boolean
11
9
  outDir: string
12
10
  }
13
11
 
14
- export const getUserConfig = async (): Promise<Config> => {
12
+ export const getUserConfig = async (configName: string): Promise<Config> => {
15
13
  const jiti = createJiti(import.meta.url, {
16
14
  debug: false,
17
15
  })
18
16
 
19
- const configPath = pathToFileURL(resolve(process.cwd(), "jinrai.config")).href
17
+ const configPath = pathToFileURL(resolve(process.cwd(), configName)).href
20
18
 
21
19
  const configModule = (await jiti.import(configPath)) as { default: Config }
22
20
 
package/src/templates.ts CHANGED
@@ -51,12 +51,11 @@ export const getRawPageData = async (
51
51
 
52
52
  await page.waitForTimeout(1000)
53
53
 
54
- const requests = await page.evaluate(() => {
55
- return (window as any).__ssr_preload
54
+ const input = await page.evaluate(() => {
55
+ return (window as any).__page_requests
56
56
  })
57
57
 
58
- const input = requests ? (JSON.parse(requests) as input[]) : []
59
-
58
+ if (debug) console.log({ input })
60
59
  const root = await page.locator("#root").innerHTML()
61
60
 
62
61
  if (debug) {
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from "../src/config/define"
2
+
3
+ export default defineConfig({
4
+ url: "https://fld.ru",
5
+ pages: [
6
+ "/",
7
+ "/products",
8
+ "/products/{klapany}",
9
+ "/product/{krany_sharovye_serii_105_prohodnoj_2h_hodovoj}",
10
+ "/{CMC-8M-4N}",
11
+ ],
12
+ outDir: "fld",
13
+ })
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from "../src/config/define"
2
+
3
+ export default defineConfig({
4
+ url: "http://localhost:3580",
5
+ pages: ["/", "/{courses}"],
6
+ outDir: "export",
7
+ // debug: true,
8
+ })
@@ -1,20 +0,0 @@
1
- import { defineConfig } from "../src/config/define";
2
-
3
- export default defineConfig({
4
- url: "https://fld.ru",
5
- dev: true,
6
- pages: [
7
- "/",
8
- "/products",
9
- "/products/{klapany}",
10
- "/product/{krany_sharovye_serii_105_prohodnoj_2h_hodovoj}",
11
- "/{CMC-8M-4N}",
12
- ],
13
- // dev: true,
14
- api: "http://nginx",
15
- meta: "http://nginx/Api/Meta/GetTags",
16
- export: {
17
- outDir: "export",
18
- index: "index.html",
19
- },
20
- });