@sealcode/sealgen 0.17.1 → 0.17.2
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/@types/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
1
2
|
export * as Controls from "./forms/controls/controls.js";
|
|
2
3
|
export * from "./forms/fields/field.js";
|
|
3
4
|
export * as Fields from "./forms/fields/fields.js";
|
|
@@ -16,3 +17,29 @@ export * from "./forms/multiform.js";
|
|
|
16
17
|
export * as Components from "./components/components.js";
|
|
17
18
|
export * from "./mount.js";
|
|
18
19
|
export * from "./page/default-list-filters.js";
|
|
20
|
+
import { Context } from "koa";
|
|
21
|
+
import { Readable } from "node:stream";
|
|
22
|
+
export interface HTMLOptions {
|
|
23
|
+
morphing?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface HTMLHeadOptions {
|
|
26
|
+
ctx: Context;
|
|
27
|
+
title: string | Promise<string | Readable>;
|
|
28
|
+
options: Partial<HTMLOptions>;
|
|
29
|
+
metaImage?: string;
|
|
30
|
+
canonicalPath?: string;
|
|
31
|
+
css_clumps: string[];
|
|
32
|
+
description: string;
|
|
33
|
+
}
|
|
34
|
+
export interface htmlArgs {
|
|
35
|
+
ctx: Context;
|
|
36
|
+
title: string | Promise<string>;
|
|
37
|
+
body: string | Promise<string>;
|
|
38
|
+
htmlOptions?: Partial<HTMLOptions>;
|
|
39
|
+
makeHead?: (args: HTMLHeadOptions) => string | Promise<string> | Readable | Promise<Readable>;
|
|
40
|
+
metaImage?: string;
|
|
41
|
+
canonicalPath?: string;
|
|
42
|
+
css_clumps?: string[];
|
|
43
|
+
description: string;
|
|
44
|
+
hideNavigation?: boolean;
|
|
45
|
+
}
|
|
@@ -18,16 +18,17 @@ const rewrite_asset_imports_plugin = (project_dir) => ({
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
const regex_import = new RegExp(
|
|
21
|
-
`^import (\\w+|{[^}]+}) from "([^"]+)";`,
|
|
21
|
+
`^import ([^ ]+, )?(\\w+|{[^}]+}) from "([^"]+)";`,
|
|
22
22
|
"gm"
|
|
23
23
|
);
|
|
24
24
|
contents = contents.replaceAll(
|
|
25
25
|
regex_import,
|
|
26
26
|
(line, _, original_path) => {
|
|
27
|
-
|
|
27
|
+
const replaced = line.replace(
|
|
28
28
|
`"src/`,
|
|
29
29
|
`"` + resolve(project_dir, "./dist") + "/"
|
|
30
30
|
);
|
|
31
|
+
return replaced;
|
|
31
32
|
}
|
|
32
33
|
);
|
|
33
34
|
contents = removeNamedImports(contents);
|
package/lib/generate-routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
2
|
import * as prettier from "prettier";
|
|
3
|
-
import { relative } from "path";
|
|
3
|
+
import { relative, resolve, basename } from "path";
|
|
4
4
|
import _locreq from "locreq";
|
|
5
5
|
import { walkDir } from "./utils/walk.js";
|
|
6
6
|
import { importPath } from "./utils/import-path.js";
|
|
@@ -45,7 +45,10 @@ async function generateRoutes() {
|
|
|
45
45
|
url: unescape_url_params(
|
|
46
46
|
"/" + relative(
|
|
47
47
|
target_locreq.resolve("src/back/routes"),
|
|
48
|
-
|
|
48
|
+
resolve(
|
|
49
|
+
fullpath,
|
|
50
|
+
basename(fullpath).startsWith("index.") ? "../" : ""
|
|
51
|
+
)
|
|
49
52
|
).replace(/\..+/, "") + "/"
|
|
50
53
|
// trailing slash is important here, as it enables to use the entire path while building relative URLs. For example, while visiting /users/123, the path ./add-photo leads to /users/add-photo. While visiting /users/123/ (note the trailing slash), the path ./add-photo leads to /users/123/add-photo
|
|
51
54
|
)
|
package/package.json
CHANGED
|
@@ -20,21 +20,21 @@ export const rewrite_asset_imports_plugin = (project_dir: string) => ({
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
const regex_import = new RegExp(
|
|
23
|
-
`^import (\\w+|{[^}]+}) from "([^"]+)";`,
|
|
23
|
+
`^import ([^ ]+, )?(\\w+|{[^}]+}) from "([^"]+)";`,
|
|
24
24
|
"gm"
|
|
25
25
|
);
|
|
26
26
|
contents = contents.replaceAll(
|
|
27
27
|
regex_import,
|
|
28
28
|
(line, _: string, original_path: string) => {
|
|
29
|
-
|
|
29
|
+
const replaced = line.replace(
|
|
30
30
|
`"src/`,
|
|
31
31
|
`"` + resolve(project_dir, "./dist") + "/"
|
|
32
32
|
);
|
|
33
|
+
return replaced;
|
|
33
34
|
}
|
|
34
35
|
);
|
|
35
36
|
|
|
36
37
|
contents = removeNamedImports(contents) as string;
|
|
37
|
-
|
|
38
38
|
return {
|
|
39
39
|
contents,
|
|
40
40
|
loader: extname(args.path) === ".tsx" ? "tsx" : "ts",
|
package/src/generate-routes.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
2
|
import * as prettier from "prettier";
|
|
3
|
-
import { relative } from "path";
|
|
3
|
+
import { relative, resolve, basename } from "path";
|
|
4
4
|
import _locreq from "locreq";
|
|
5
5
|
import { walkDir } from "./utils/walk.js";
|
|
6
6
|
import { importPath } from "./utils/import-path.js";
|
|
@@ -65,7 +65,12 @@ export async function generateRoutes(): Promise<void> {
|
|
|
65
65
|
"/" +
|
|
66
66
|
relative(
|
|
67
67
|
target_locreq.resolve("src/back/routes"),
|
|
68
|
-
|
|
68
|
+
resolve(
|
|
69
|
+
fullpath,
|
|
70
|
+
basename(fullpath).startsWith("index.")
|
|
71
|
+
? "../"
|
|
72
|
+
: ""
|
|
73
|
+
)
|
|
69
74
|
).replace(/\..+/, "") +
|
|
70
75
|
"/" // trailing slash is important here, as it enables to use the entire path while building relative URLs. For example, while visiting /users/123, the path ./add-photo leads to /users/add-photo. While visiting /users/123/ (note the trailing slash), the path ./add-photo leads to /users/123/add-photo
|
|
71
76
|
),
|
package/src/index.ts
CHANGED
|
@@ -16,3 +16,35 @@ export * from "./forms/multiform.js";
|
|
|
16
16
|
export * as Components from "./components/components.js";
|
|
17
17
|
export * from "./mount.js";
|
|
18
18
|
export * from "./page/default-list-filters.js";
|
|
19
|
+
|
|
20
|
+
import { Context } from "koa";
|
|
21
|
+
import { Readable } from "node:stream";
|
|
22
|
+
|
|
23
|
+
export interface HTMLOptions {
|
|
24
|
+
morphing?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface HTMLHeadOptions {
|
|
28
|
+
ctx: Context;
|
|
29
|
+
title: string | Promise<string | Readable>;
|
|
30
|
+
options: Partial<HTMLOptions>;
|
|
31
|
+
metaImage?: string;
|
|
32
|
+
canonicalPath?: string;
|
|
33
|
+
css_clumps: string[];
|
|
34
|
+
description: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface htmlArgs {
|
|
38
|
+
ctx: Context;
|
|
39
|
+
title: string | Promise<string>;
|
|
40
|
+
body: string | Promise<string>;
|
|
41
|
+
htmlOptions?: Partial<HTMLOptions>;
|
|
42
|
+
makeHead?: (
|
|
43
|
+
args: HTMLHeadOptions
|
|
44
|
+
) => string | Promise<string> | Readable | Promise<Readable>;
|
|
45
|
+
metaImage?: string;
|
|
46
|
+
canonicalPath?: string;
|
|
47
|
+
css_clumps?: string[];
|
|
48
|
+
description: string;
|
|
49
|
+
hideNavigation?: boolean;
|
|
50
|
+
}
|