miqro 6.3.0 → 7.0.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/README.md +9 -17
- package/build/editor.bundle.js +11601 -10129
- package/build/esm/src/bin/types.js +10 -5
- package/build/esm/src/cluster.js +1 -1
- package/build/esm/src/common/arguments.d.ts +1 -1
- package/build/esm/src/common/arguments.js +28 -14
- package/build/esm/src/common/assets.d.ts +1 -1
- package/build/esm/src/common/assets.js +34 -13
- package/build/esm/src/common/esbuild.d.ts +4 -1
- package/build/esm/src/common/esbuild.js +31 -26
- package/build/esm/src/common/exit.js +4 -4
- package/build/esm/src/common/help.d.ts +1 -1
- package/build/esm/src/common/help.js +0 -1
- package/build/esm/src/common/jsx.d.ts +2 -3
- package/build/esm/src/common/jsx.js +70 -75
- package/build/esm/src/common/paths.d.ts +0 -1
- package/build/esm/src/common/paths.js +3 -3
- package/build/esm/src/common/watch.d.ts +0 -1
- package/build/esm/src/common/watch.js +1 -1
- package/build/esm/src/inflate/inflate-sea.js +35 -24
- package/build/esm/src/inflate/inflate.js +4 -4
- package/build/esm/src/inflate/setup-auth.js +1 -1
- package/build/esm/src/inflate/setup-cors.js +1 -1
- package/build/esm/src/inflate/setup-db.js +2 -2
- package/build/esm/src/inflate/setup-error.js +1 -1
- package/build/esm/src/inflate/setup-http.js +16 -16
- package/build/esm/src/inflate/setup-log.js +1 -1
- package/build/esm/src/inflate/setup-middleware.js +1 -1
- package/build/esm/src/inflate/setup-server-config.js +1 -1
- package/build/esm/src/inflate/setup-ws.js +1 -1
- package/build/esm/src/inflate/setup.doc.d.ts +2 -2
- package/build/esm/src/inflate/setup.doc.js +23 -2
- package/build/esm/src/inflate/utils/sea-utils.js +2 -2
- package/build/esm/src/lib.d.ts +10 -1
- package/build/esm/src/lib.js +16 -1
- package/build/esm/src/main.js +1 -1
- package/build/esm/src/services/app.js +3 -4
- package/build/esm/src/services/migrations.js +2 -2
- package/build/esm/src/services/utils/jwt.d.ts +2 -0
- package/build/esm/src/services/utils/jwt.js +23 -0
- package/build/esm/src/services/utils/middleware.d.ts +9 -0
- package/build/esm/src/services/utils/middleware.js +9 -0
- package/build/esm/src/services/utils/server-interface.js +33 -4
- package/build/esm/src/types.d.ts +50 -83
- package/build/lib.cjs +15684 -15612
- package/package.json +6 -8
- package/sea/basic-compile.base64.sh +1 -1
- package/sea/basic-compile.sh +1 -1
- package/sea/install-nodejs.sh +1 -1
- package/sea/node.version.tag +1 -1
- package/.eslintrc +0 -15
- package/build/esm/editor/auth.d.ts +0 -6
- package/build/esm/editor/auth.js +0 -41
- package/build/esm/editor/common/admin-interface.d.ts +0 -36
- package/build/esm/editor/common/admin-interface.js +0 -44
- package/build/esm/editor/common/constants.d.ts +0 -4
- package/build/esm/editor/common/constants.js +0 -20
- package/build/esm/editor/common/constants.server.d.ts +0 -2
- package/build/esm/editor/common/constants.server.js +0 -4
- package/build/esm/editor/common/editor-index.d.ts +0 -2
- package/build/esm/editor/common/editor-index.js +0 -14
- package/build/esm/editor/common/html-encode.d.ts +0 -1
- package/build/esm/editor/common/html-encode.js +0 -14
- package/build/esm/editor/common/log-socket.d.ts +0 -15
- package/build/esm/editor/common/log-socket.js +0 -70
- package/build/esm/editor/common/templates.d.ts +0 -11
- package/build/esm/editor/common/templates.js +0 -477
- package/build/esm/editor/components/api-preview.d.ts +0 -11
- package/build/esm/editor/components/api-preview.js +0 -90
- package/build/esm/editor/components/editor.d.ts +0 -16
- package/build/esm/editor/components/editor.js +0 -365
- package/build/esm/editor/components/file-browser.d.ts +0 -37
- package/build/esm/editor/components/file-browser.js +0 -126
- package/build/esm/editor/components/file-editor-toolbar.d.ts +0 -22
- package/build/esm/editor/components/file-editor-toolbar.js +0 -93
- package/build/esm/editor/components/file-editor.d.ts +0 -32
- package/build/esm/editor/components/file-editor.js +0 -59
- package/build/esm/editor/components/filter-query.d.ts +0 -1
- package/build/esm/editor/components/filter-query.js +0 -22
- package/build/esm/editor/components/highlight-text-area.d.ts +0 -11
- package/build/esm/editor/components/highlight-text-area.js +0 -125
- package/build/esm/editor/components/log-viewer.d.ts +0 -6
- package/build/esm/editor/components/log-viewer.js +0 -69
- package/build/esm/editor/components/new-file.d.ts +0 -10
- package/build/esm/editor/components/new-file.js +0 -117
- package/build/esm/editor/components/scroll-query.d.ts +0 -7
- package/build/esm/editor/components/scroll-query.js +0 -21
- package/build/esm/editor/components/start-page.d.ts +0 -13
- package/build/esm/editor/components/start-page.js +0 -30
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/delete.api.js +0 -29
- package/build/esm/editor/http/admin/editor/api/fs/read.api.d.ts +0 -5
- package/build/esm/editor/http/admin/editor/api/fs/read.api.js +0 -49
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.d.ts +0 -4
- package/build/esm/editor/http/admin/editor/api/fs/rename.api.js +0 -39
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.d.ts +0 -26
- package/build/esm/editor/http/admin/editor/api/fs/scan.api.js +0 -149
- package/build/esm/editor/http/admin/editor/api/fs/write.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/api/fs/write.api.js +0 -38
- package/build/esm/editor/http/admin/editor/api/server/reload.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/reload.api.js +0 -46
- package/build/esm/editor/http/admin/editor/api/server/restart.api.d.ts +0 -10
- package/build/esm/editor/http/admin/editor/api/server/restart.api.js +0 -45
- package/build/esm/editor/http/admin/editor/editor.d.ts +0 -1
- package/build/esm/editor/http/admin/editor/editor.js +0 -7
- package/build/esm/editor/http/admin/editor/index.api.d.ts +0 -3
- package/build/esm/editor/http/admin/editor/index.api.js +0 -21
- package/build/esm/editor/server.d.ts +0 -3
- package/build/esm/editor/server.js +0 -49
- package/build/esm/editor/ws.d.ts +0 -3
- package/build/esm/editor/ws.js +0 -11
- package/build/esm/src/services/globals.d.ts +0 -3
- package/build/esm/src/services/globals.js +0 -182
- package/build/jsx.dom.js +0 -1587
- package/build/postject.base64.cjs +0 -1
- package/editor/auth.ts +0 -51
- package/editor/common/admin-interface.ts +0 -84
- package/editor/common/constants.server.ts +0 -5
- package/editor/common/constants.ts +0 -21
- package/editor/common/editor-index.tsx +0 -17
- package/editor/common/html-encode.ts +0 -14
- package/editor/common/log-socket.tsx +0 -85
- package/editor/common/templates.ts +0 -481
- package/editor/components/api-preview.tsx +0 -116
- package/editor/components/editor.tsx +0 -494
- package/editor/components/file-browser.tsx +0 -308
- package/editor/components/file-editor-toolbar.tsx +0 -191
- package/editor/components/file-editor.tsx +0 -122
- package/editor/components/filter-query.tsx +0 -22
- package/editor/components/highlight-text-area.tsx +0 -145
- package/editor/components/log-viewer.tsx +0 -110
- package/editor/components/new-file.tsx +0 -169
- package/editor/components/scroll-query.tsx +0 -22
- package/editor/components/start-page.tsx +0 -49
- package/editor/http/admin/editor/api/fs/delete.api.tsx +0 -32
- package/editor/http/admin/editor/api/fs/read.api.tsx +0 -55
- package/editor/http/admin/editor/api/fs/rename.api.tsx +0 -41
- package/editor/http/admin/editor/api/fs/scan.api.tsx +0 -181
- package/editor/http/admin/editor/api/fs/write.api.tsx +0 -41
- package/editor/http/admin/editor/api/server/reload.api.ts +0 -53
- package/editor/http/admin/editor/api/server/restart.api.tsx +0 -52
- package/editor/http/admin/editor/editor.tsx +0 -8
- package/editor/http/admin/editor/index.api.tsx +0 -39
- package/editor/server.ts +0 -57
- package/editor/ws.ts +0 -15
- package/sea/types.json +0 -1
- package/src/bin/compile.ts +0 -35
- package/src/bin/doc-md.ts +0 -210
- package/src/bin/generate-doc.ts +0 -64
- package/src/bin/test.ts +0 -92
- package/src/bin/types.ts +0 -29
- package/src/cluster.ts +0 -27
- package/src/common/arguments.ts +0 -745
- package/src/common/assets.ts +0 -128
- package/src/common/checksum.ts +0 -58
- package/src/common/constants.ts +0 -18
- package/src/common/content-type.ts +0 -84
- package/src/common/esbuild.ts +0 -94
- package/src/common/exit.ts +0 -91
- package/src/common/fs.ts +0 -82
- package/src/common/help.ts +0 -61
- package/src/common/jsx.ts +0 -547
- package/src/common/jwt.ts +0 -85
- package/src/common/paths.ts +0 -107
- package/src/common/watch.ts +0 -88
- package/src/inflate/inflate-sea.ts +0 -226
- package/src/inflate/inflate.ts +0 -101
- package/src/inflate/md.ts +0 -25
- package/src/inflate/setup-auth.ts +0 -41
- package/src/inflate/setup-cors.ts +0 -41
- package/src/inflate/setup-db.ts +0 -117
- package/src/inflate/setup-error.ts +0 -44
- package/src/inflate/setup-http.ts +0 -704
- package/src/inflate/setup-log.ts +0 -45
- package/src/inflate/setup-middleware.ts +0 -47
- package/src/inflate/setup-server-config.ts +0 -48
- package/src/inflate/setup-test.ts +0 -23
- package/src/inflate/setup-ws.ts +0 -50
- package/src/inflate/setup.doc.ts +0 -68
- package/src/inflate/utils/sea-utils.ts +0 -14
- package/src/lib.ts +0 -19
- package/src/main.ts +0 -101
- package/src/services/app.ts +0 -699
- package/src/services/editor.tsx +0 -101
- package/src/services/globals.ts +0 -186
- package/src/services/hot-reload.ts +0 -51
- package/src/services/migrations.ts +0 -68
- package/src/services/utils/admin-interface.ts +0 -37
- package/src/services/utils/cache.ts +0 -88
- package/src/services/utils/cluster-cache.ts +0 -230
- package/src/services/utils/cluster-ws.ts +0 -202
- package/src/services/utils/db-manager.ts +0 -92
- package/src/services/utils/get-route.ts +0 -70
- package/src/services/utils/log-transport.ts +0 -81
- package/src/services/utils/log.ts +0 -92
- package/src/services/utils/server-interface.ts +0 -92
- package/src/services/utils/websocketmanager.ts +0 -157
- package/src/types/@esbuild.d.ts +0 -1
- package/src/types/@miqro/core.d.ts +0 -2
- package/src/types/@miqro/jsx.d.ts +0 -2
- package/src/types/@miqro/parser.d.ts +0 -2
- package/src/types/@miqro/query.d.ts +0 -2
- package/src/types/@miqro/request.d.ts +0 -2
- package/src/types/@miqro/test.d.ts +0 -2
- package/src/types/@miqro.d.ts +0 -1
- package/src/types/@types.d.ts +0 -1
- package/src/types/browser.globals.d.ts +0 -1
- package/src/types/cookie.d.ts +0 -2
- package/src/types/globals.d.ts +0 -2
- package/src/types/jose.d.ts +0 -2
- package/src/types/jsx.globals.d.ts +0 -38
- package/src/types/miqro.d.ts +0 -228
- package/src/types/postject.d.ts +0 -1
- package/src/types/server.globals.d.ts +0 -47
- package/src/types.ts +0 -304
- package/tsconfig.json +0 -35
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { initTypes } from "../common/assets.js";
|
|
1
|
+
// import { initTypes } from "../common/assets.js";
|
|
2
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { TEMPLATES } from "../../editor/common/templates.js";
|
|
4
4
|
import { EXIT_CODES } from "../common/constants.js";
|
|
5
|
+
import { installAsset } from "../common/assets.js";
|
|
5
6
|
export async function installTypings(args, logger) {
|
|
6
|
-
if (args.installTypes) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/*if (args.installTypes) {
|
|
8
|
+
logger.debug("writing types");
|
|
9
|
+
// install typing for typescript only if argument --install-types is set
|
|
10
|
+
await initTypes(logger);
|
|
11
|
+
}*/
|
|
12
|
+
if (args.install) {
|
|
13
|
+
logger.debug("writing node_modules");
|
|
14
|
+
await installAsset(logger, ["node_modules/"]);
|
|
10
15
|
}
|
|
11
16
|
if (args.installTSConfig && !existsSync("tsconfig.json")) {
|
|
12
17
|
logger.info("writing tsconfig.json");
|
package/build/esm/src/cluster.js
CHANGED
|
@@ -10,7 +10,7 @@ const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import
|
|
|
10
10
|
//const usage = "CLUSTER_COUNT=os.cpus().length [CLUSTER_AUTO_BROADCAST=true|false] [CLUSTER_DISABLE_RESTART=true|false]";
|
|
11
11
|
const CLUSTER_COUNT = checkEnvVariable("CLUSTER_COUNT", String(cpus().length));
|
|
12
12
|
const args = parseArguments();
|
|
13
|
-
if (args.inflate || args.test || args.compile || args.installTSConfig || args.installTypes || args.migrateDown || args.migrateUp) {
|
|
13
|
+
if (args.inflate || args.test || args.compile || args.installTSConfig /* || args.installTypes */ || args.migrateDown || args.migrateUp) {
|
|
14
14
|
await import("./main.js");
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
@@ -18,9 +18,9 @@ export interface Arguments {
|
|
|
18
18
|
name?: string;
|
|
19
19
|
browser?: string | boolean;
|
|
20
20
|
logFile?: string | boolean;
|
|
21
|
-
installTypes: boolean;
|
|
22
21
|
installMiqroJSON: boolean;
|
|
23
22
|
installTSConfig: boolean;
|
|
23
|
+
install: boolean;
|
|
24
24
|
test: boolean;
|
|
25
25
|
port: string;
|
|
26
26
|
inflate: boolean;
|
|
@@ -59,8 +59,9 @@ export function parseArguments() {
|
|
|
59
59
|
watch: null,
|
|
60
60
|
miqroJSONPath: null,
|
|
61
61
|
installMiqroJSON: null,
|
|
62
|
+
install: null,
|
|
62
63
|
disableMiqroJSON: null,
|
|
63
|
-
installTypes: null,
|
|
64
|
+
// installTypes: null,
|
|
64
65
|
port: null,
|
|
65
66
|
installTSConfig: null,
|
|
66
67
|
migrateUp: null,
|
|
@@ -133,6 +134,14 @@ export function parseArguments() {
|
|
|
133
134
|
}
|
|
134
135
|
flags.installTSConfig = true;
|
|
135
136
|
continue;
|
|
137
|
+
case "--install":
|
|
138
|
+
if (flags.inflate !== null || flags.installTSConfig !== null) {
|
|
139
|
+
console.error("bad arguments.");
|
|
140
|
+
console.error(usage);
|
|
141
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
142
|
+
}
|
|
143
|
+
flags.install = true;
|
|
144
|
+
continue;
|
|
136
145
|
case "--watch":
|
|
137
146
|
if (flags.watch !== null) {
|
|
138
147
|
console.error("bad arguments.");
|
|
@@ -328,14 +337,14 @@ export function parseArguments() {
|
|
|
328
337
|
flags.inflateSEA = true;
|
|
329
338
|
flags.inflate = true;
|
|
330
339
|
continue;
|
|
331
|
-
case "--install-types":
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
340
|
+
/*case "--install-types":
|
|
341
|
+
if (flags.inflate !== null || flags.installTypes !== null) {
|
|
342
|
+
console.error("bad arguments.");
|
|
343
|
+
console.error(usage);
|
|
344
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
345
|
+
}
|
|
346
|
+
flags.installTypes = true;
|
|
347
|
+
continue;*/
|
|
339
348
|
case "--editor":
|
|
340
349
|
if (flags.editor !== null) {
|
|
341
350
|
console.error("bad arguments.");
|
|
@@ -531,7 +540,7 @@ export function parseArguments() {
|
|
|
531
540
|
}
|
|
532
541
|
}
|
|
533
542
|
flags.editor = flags.editor ? flags.editor : false;
|
|
534
|
-
if (services.length === 0 && (!flags.installTSConfig && !flags.installTypes && !flags.installMiqroJSON)) {
|
|
543
|
+
if (services.length === 0 && (!flags.installTSConfig /* && !flags.installTypes*/ && !flags.installMiqroJSON)) {
|
|
535
544
|
flags.inflateDir = flags.inflateDir ? flags.inflateDir : undefined;
|
|
536
545
|
console.error(`bad arguments. missing --service argument`);
|
|
537
546
|
console.error(usage);
|
|
@@ -557,19 +566,23 @@ export function parseArguments() {
|
|
|
557
566
|
console.error("for ts");
|
|
558
567
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
559
568
|
}
|
|
569
|
+
if (flags.install && flags.inflate) {
|
|
570
|
+
console.error("bad arguments. cannot use --install with --inflate");
|
|
571
|
+
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
572
|
+
}
|
|
560
573
|
if (flags.inflate && flags.editor) {
|
|
561
574
|
console.error("bad arguments. cannot use --inflate with --editor");
|
|
562
575
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
563
576
|
}
|
|
564
|
-
if (flags.inflate && (flags.installTypes || flags.installTSConfig || flags.installMiqroJSON)) {
|
|
565
|
-
console.error("bad arguments. cannot use --inflate with --install
|
|
577
|
+
if (flags.inflate && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON || flags.install)) {
|
|
578
|
+
console.error("bad arguments. cannot use --inflate with --install, --install-tsconfig or --install-miqrojson");
|
|
566
579
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
567
580
|
}
|
|
568
581
|
if (flags.inflateSEA && !flags.inflate) {
|
|
569
582
|
console.error("bad arguments. cannot use --inflate-sea without --inflate");
|
|
570
583
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
571
584
|
}
|
|
572
|
-
if (flags.editor && (flags.installTypes || flags.installTSConfig || flags.installMiqroJSON)) {
|
|
585
|
+
if (flags.editor && ( /*flags.installTypes || */flags.installTSConfig || flags.installMiqroJSON)) {
|
|
573
586
|
console.error("bad arguments. cannot use --editor with--install-types, --install-tsconfig or --install-miqrojson");
|
|
574
587
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
575
588
|
}
|
|
@@ -616,9 +629,10 @@ export function parseArguments() {
|
|
|
616
629
|
watch: flags.watch ? true : false,
|
|
617
630
|
disableMiqroJSON: flags.disableMiqroJSON !== null ? flags.disableMiqroJSON : false,
|
|
618
631
|
miqroJSONPath: miqroJSONPath ? miqroJSONPath : false,
|
|
619
|
-
installTypes: flags.installTypes ? true : false,
|
|
632
|
+
// installTypes: flags.installTypes ? true : false,
|
|
620
633
|
installMiqroJSON: flags.installMiqroJSON ? true : false,
|
|
621
634
|
installTSConfig: flags.installTSConfig ? true : false,
|
|
635
|
+
install: flags.install,
|
|
622
636
|
inflate: flags.inflate,
|
|
623
637
|
port: flags.port ? flags.port : getPORT(),
|
|
624
638
|
migrateUp: flags.migrateUp ? true : false,
|
|
@@ -7,6 +7,6 @@ export declare function getVersion(): {
|
|
|
7
7
|
ESBUILD_VERSION: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function initAssets(logger: Logger): Promise<void>;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function installAsset(logger: MinimalLogger, include: string[]): Promise<void>;
|
|
11
11
|
export declare function validateAsset(logger: MinimalLogger | undefined, path: string, internalChecksum: string): Promise<boolean>;
|
|
12
12
|
export declare function initAsset(logger: MinimalLogger, path: string, buffer: Buffer, executable?: boolean, checksum?: Promise<string>, logInstallasInfo?: boolean): Promise<void>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { chmodSync, constants, existsSync, mkdirSync, readFileSync,
|
|
1
|
+
import { chmodSync, constants, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { getAsset as seaGetAsset, isSea } from "node:sea";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { calculateChecksum, calculateChecksumFromBuffer } from "./checksum.js";
|
|
5
5
|
import { arch, cwd, platform } from "node:process";
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { initESBuild } from "./esbuild.js";
|
|
8
|
-
import {
|
|
8
|
+
import { mkdirASync, unlinkASync, writeFileASync } from "./fs.js";
|
|
9
|
+
// import { initJSXJS } from "./jsx.js";
|
|
9
10
|
//const require = createRequire(import.meta.url);
|
|
10
11
|
export const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..") : null;
|
|
11
12
|
const ASSETS_ROUTER = {
|
|
@@ -13,7 +14,7 @@ const ASSETS_ROUTER = {
|
|
|
13
14
|
"version.tag": "sea/version.tag",
|
|
14
15
|
"node.version.tag": "sea/node.version.tag",
|
|
15
16
|
"esbuild.version.tag": "sea/esbuild.version.tag",
|
|
16
|
-
"postject.base64.cjs": "build/postject.base64.cjs",
|
|
17
|
+
// "postject.base64.cjs": "build/postject.base64.cjs",
|
|
17
18
|
"sea.basic.config.json": "sea/basic-config.json",
|
|
18
19
|
"node.sh": "sea/node.sh",
|
|
19
20
|
"install-nodejs.sh": "sea/install-nodejs.sh",
|
|
@@ -21,8 +22,9 @@ const ASSETS_ROUTER = {
|
|
|
21
22
|
"sign-remove.sh": "sea/sign-remove.sh",
|
|
22
23
|
"sign-add.sh": "sea/sign-add.sh",
|
|
23
24
|
"app.sh": "sea/app.sh",
|
|
24
|
-
"jsx.dom.js": "build/jsx.dom.js",
|
|
25
|
-
"types.json": "sea/types.json",
|
|
25
|
+
// "jsx.dom.js": "build/jsx.dom.js",
|
|
26
|
+
// "types.json": "sea/types.json",
|
|
27
|
+
"assets.base64.json": "sea/assets.base64.json",
|
|
26
28
|
"editor-assets/editor.bundle.js": "build/editor.bundle.js",
|
|
27
29
|
"editor-assets/style.css": "build/style.css",
|
|
28
30
|
"editor-assets/font.ttf": "build/font.ttf"
|
|
@@ -68,11 +70,25 @@ export async function initAssets(logger) {
|
|
|
68
70
|
logger.debug("esbuild version [%s]", ESBUILD_VERSION);
|
|
69
71
|
}
|
|
70
72
|
logger.debug("platform [%s-%s]", platform, arch);
|
|
71
|
-
await Promise.all([initJSXJS(logger), initESBuild(logger)]);
|
|
73
|
+
// await Promise.all([initJSXJS(logger), initESBuild(logger)]);
|
|
74
|
+
await Promise.all([initESBuild(logger)]);
|
|
72
75
|
}
|
|
73
|
-
export async function initTypes(logger) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
/*export async function initTypes(logger: MinimalLogger) {
|
|
77
|
+
const typesJSON = JSON.parse(Buffer.from(getAsset("types.json")).toString("utf-8"));
|
|
78
|
+
await Promise.all(Object.keys(typesJSON).map(typeFile =>
|
|
79
|
+
initAsset(logger, resolve(cwd(), "." + typeFile), Buffer.from(typesJSON[typeFile], "base64"))
|
|
80
|
+
));
|
|
81
|
+
}*/
|
|
82
|
+
export async function installAsset(logger, include) {
|
|
83
|
+
const assetsJSON = JSON.parse(Buffer.from(getAsset("assets.base64.json")).toString("utf-8"));
|
|
84
|
+
await Promise.all(assetsJSON.map(asset => {
|
|
85
|
+
for (const i of include) {
|
|
86
|
+
if (asset.path.indexOf(i) === 0) {
|
|
87
|
+
return initAsset(logger, join(cwd(), asset.path), Buffer.from(asset.content, "base64"));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return Promise.resolve();
|
|
91
|
+
}));
|
|
76
92
|
}
|
|
77
93
|
export async function validateAsset(logger, path, internalChecksum) {
|
|
78
94
|
mkdirSync(dirname(path), {
|
|
@@ -101,8 +117,13 @@ export async function initAsset(logger, path, buffer, executable, checksum, logI
|
|
|
101
117
|
if (existsSync(path)) {
|
|
102
118
|
if (!valid) {
|
|
103
119
|
logger.info("updating [%s]", path);
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
await unlinkASync(path);
|
|
121
|
+
if (!statSync(dirname(path)).isDirectory()) {
|
|
122
|
+
await mkdirASync(dirname(path), {
|
|
123
|
+
recursive: true
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
await writeFileASync(path, buffer);
|
|
106
127
|
if (executable) {
|
|
107
128
|
chmodSync(path, constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
|
|
108
129
|
}
|
|
@@ -115,7 +136,7 @@ export async function initAsset(logger, path, buffer, executable, checksum, logI
|
|
|
115
136
|
else {
|
|
116
137
|
logger.info("installing [%s]", path);
|
|
117
138
|
}
|
|
118
|
-
|
|
139
|
+
await writeFileASync(path, buffer);
|
|
119
140
|
if (executable) {
|
|
120
141
|
chmodSync(path, constants.S_IXUSR | constants.S_IRUSR | constants.S_IWUSR);
|
|
121
142
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Logger } from "@miqro/core";
|
|
2
2
|
export declare function validateESBuild(logger?: Logger): Promise<boolean>;
|
|
3
3
|
export declare function initESBuild(logger: Logger): Promise<void>;
|
|
4
|
+
export declare const NODEJS_EXTERNAL: string[];
|
|
4
5
|
export declare function esBuild(options: {
|
|
5
|
-
platform?: string;
|
|
6
|
+
platform?: string | false;
|
|
6
7
|
entryPoints: [string];
|
|
8
|
+
mainFields?: string;
|
|
7
9
|
bundle?: boolean;
|
|
8
10
|
jsxFactory?: string;
|
|
9
11
|
jsxFragment?: string;
|
|
10
12
|
minify?: boolean;
|
|
11
13
|
outfile?: string;
|
|
14
|
+
external?: string[];
|
|
12
15
|
}, logger?: Logger): Promise<{
|
|
13
16
|
outputFiles: {
|
|
14
17
|
path: string;
|
|
@@ -13,39 +13,44 @@ export async function initESBuild(logger) {
|
|
|
13
13
|
esbuildBinaryChecksumPromise = esbuildBinaryChecksumPromise ? esbuildBinaryChecksumPromise : calculateChecksumFromBuffer(esbuildBinaryBuffer);
|
|
14
14
|
return initAsset(logger, getESBuildBinaryPath(), esbuildBinaryBuffer, true, esbuildBinaryChecksumPromise, false);
|
|
15
15
|
}
|
|
16
|
-
const NODEJS_EXTERNAL = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
16
|
+
/*const NODEJS_EXTERNAL = [
|
|
17
|
+
"node:cluster",
|
|
18
|
+
"node:assert",
|
|
19
|
+
"node:util",
|
|
20
|
+
"node:path",
|
|
21
|
+
"node:fs",
|
|
22
|
+
"node:crypto",
|
|
23
|
+
"node:http",
|
|
24
|
+
"node:https",
|
|
25
|
+
"node:os",
|
|
26
|
+
"node:dns",
|
|
27
|
+
"node:string_decoder",
|
|
28
|
+
"node:stream",
|
|
29
|
+
"node:http2",
|
|
30
|
+
"node:net",
|
|
31
|
+
"node:worker_threads",
|
|
32
|
+
"node:process",
|
|
33
|
+
"child_process",
|
|
34
|
+
"node:child_process",
|
|
35
|
+
"core",
|
|
36
|
+
"globals",
|
|
37
|
+
"jsx.globals",
|
|
38
|
+
"server.globals",
|
|
39
|
+
"browser.globals",
|
|
40
|
+
"sqlite3",
|
|
41
|
+
"pg"
|
|
42
|
+
];*/
|
|
43
|
+
export const NODEJS_EXTERNAL = [
|
|
40
44
|
"sqlite3",
|
|
41
|
-
"pg"
|
|
45
|
+
"pg",
|
|
46
|
+
"node:*"
|
|
42
47
|
];
|
|
43
48
|
export async function esBuild(options, logger) {
|
|
44
49
|
return new Promise(async (resolve, reject) => {
|
|
45
50
|
try {
|
|
46
51
|
//const logger = getLogger(`${SERVER_IDENTIFIER}_ESBUILD`);
|
|
47
52
|
const valid = await validateESBuild(logger);
|
|
48
|
-
const esBuildCMD = `${getESBuildBinaryPath()} "${options.entryPoints[0]}" ${NODEJS_EXTERNAL.map(e => `--external:${e}`).join(" ")} --loader:.js=jsx --jsx-factory=${options.jsxFactory} --jsx-fragment=${options.jsxFragment} ${options.bundle ? " --bundle" : ""}${options.minify ? " --minify" : ""}${options.outfile ? ` --outfile="${options.outfile}"` : ""}${options.platform ? ` --platform=${options.platform}` : ""}`;
|
|
53
|
+
const esBuildCMD = `${getESBuildBinaryPath()} "${options.entryPoints[0]}" ${(options.external ? options.external : NODEJS_EXTERNAL).map(e => `--external:${e}`).join(" ")} --loader:.js=jsx --jsx-factory=${options.jsxFactory} --jsx-fragment=${options.jsxFragment} ${options.bundle ? " --bundle" : ""}${options.minify ? " --minify" : ""}${options.outfile ? ` --outfile="${options.outfile}"` : ""}${options.platform ? ` --platform=${options.platform}` : ""}${options.mainFields ? ` --main-fields=${options.mainFields}` : ""}`;
|
|
49
54
|
logger?.trace(esBuildCMD);
|
|
50
55
|
if (!valid) {
|
|
51
56
|
const err = new Error(`esbuild installation at [${getESBuildBinaryPath()}] tampered`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, rmdirSync, unlinkSync } from "node:fs";
|
|
2
2
|
//import { notifiyServerStop, notifiyServerUnLoad } from "../services/server.js";
|
|
3
|
-
import { getESBuildBinaryPath
|
|
3
|
+
import { getESBuildBinaryPath /*, getJSXJSPath*/, JSX_TMP_DIR } from "./paths.js";
|
|
4
4
|
import { CLEAR_JSX_CACHE } from "./constants.js";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { EXIT_CODES } from "./constants.js";
|
|
@@ -10,10 +10,10 @@ function cleanJSX(app) {
|
|
|
10
10
|
unlinkSync(getESBuildBinaryPath());
|
|
11
11
|
}
|
|
12
12
|
if (CLEAR_JSX_CACHE) {
|
|
13
|
-
app.logger?.trace("trying to clean up jsx.js installation at [%s]", getJSXJSPath());
|
|
13
|
+
/*app.logger?.trace("trying to clean up jsx.js installation at [%s]", getJSXJSPath());
|
|
14
14
|
if (existsSync(getJSXJSPath())) {
|
|
15
|
-
|
|
16
|
-
}
|
|
15
|
+
unlinkSync(getJSXJSPath());
|
|
16
|
+
}*/
|
|
17
17
|
const buildParendDir = resolve(JSX_TMP_DIR, String(process.pid));
|
|
18
18
|
app.logger?.trace("trying to clean up jsx build/import folders at [%s]", buildParendDir);
|
|
19
19
|
const buildDir = resolve(buildParendDir, "build");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const BIN_NAME = "miqro";
|
|
2
2
|
export declare const usage = "usage: miqro [...FLAGS] --service app/\n\n==examples==\n\nmiqro --watch --service front/\nPORT=8181 miqro --service api/ --service front/\nmiqro --test --service front/\nmiqro --inflate --service front/\nmiqro --generate-doc --generate-doc-out API.md --service front/\nCLUSTER_COUNT=10 miqro-cluster --service api/";
|
|
3
|
-
export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--watch\n\tuse to auto reload the server when files change.\n--hot-reload\n\tenables the hot-reload functionality use with --watch.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\n\truns the application with a built-in editor.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-
|
|
3
|
+
export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--watch\n\tuse to auto reload the server when files change.\n--hot-reload\n\tenables the hot-reload functionality use with --watch.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\n\truns the application with a built-in editor.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-miqrojson\n\tcreates a default miqro.json file.\n--disable-miqrojson\n\tdisables the load of miqro.json file.\n--log-file\n\toverrides the default log file from LOG_FILE.\n--browser\n\toverrides the default browser from BROWSER.\n--config\n\toverrides the default miqro.json path.\n--port\n\toverrides the default port from PORT.\n--name\n\toverrides the default name of the server.\n--https\n\tserves the server in https instead of http\n--https-key\n\tpoint to a server.key file for https.\n--https-cert\n\tpoint to a server.cert file for https.\n--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.\n--inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.\n\n==environment variables==\n\nPORT\n\toverride the default 8080 port.\nBROWSER\n\toverride the default browser. change to none to disable.\".\nLOG_FILE\n\toverride the default ./server.log file\nDB\n\tenable the server.db features\nDB_STORAGE\n\toverride the default local db location ./db.sqlite3\nDB_DIALECT\n\toverride the default node:sqlite\nDB_CONNECTION\n\toverride the default connection url\nCLEAR_JSX_CACHE\n\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\n\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
|
|
@@ -30,7 +30,6 @@ export const help = `
|
|
|
30
30
|
--compile\n\tinflates the application and tries to create a NODE SEA binary.
|
|
31
31
|
--inflate-sea\n\tinflates the application with sea compilation scripts.
|
|
32
32
|
--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.
|
|
33
|
-
--install-types\n\tcreates and updates the .types/ folder use together with --install-tsconfig.
|
|
34
33
|
--install-miqrojson\n\tcreates a default miqro.json file.
|
|
35
34
|
--disable-miqrojson\n\tdisables the load of miqro.json file.
|
|
36
35
|
--log-file\n\toverrides the default log file from LOG_FILE.
|
|
@@ -3,8 +3,6 @@ import { Request, Response, CORSOptions, Logger, APIRoute } from "@miqro/core";
|
|
|
3
3
|
import { Schema } from "@miqro/parser";
|
|
4
4
|
import { APIOptions, ServerConfig, WSConfig, AuthConfig, DBConfig, LogConfig, MiddlewareConfig, ErrorConfig, DocConfig } from "../types.js";
|
|
5
5
|
import { Migration } from "@miqro/query";
|
|
6
|
-
export declare function initJSXJS(logger: Logger): Promise<void>;
|
|
7
|
-
export declare function validateJSXJS(logger: Logger): Promise<boolean>;
|
|
8
6
|
export interface Dict<T> {
|
|
9
7
|
[key: string]: T | Dict<T>;
|
|
10
8
|
}
|
|
@@ -13,10 +11,11 @@ export interface InflateError {
|
|
|
13
11
|
error: Error;
|
|
14
12
|
}
|
|
15
13
|
export interface InflateOptions {
|
|
16
|
-
embemedJSX: boolean;
|
|
17
14
|
minify: boolean;
|
|
18
15
|
useExport: boolean;
|
|
19
16
|
platform?: string;
|
|
17
|
+
mainFields?: string;
|
|
18
|
+
external?: string[];
|
|
20
19
|
logger?: Logger | Console;
|
|
21
20
|
}
|
|
22
21
|
export declare function inflateJSX(inFile: string, options: InflateOptions): Promise<string>;
|
|
@@ -5,99 +5,93 @@ import { Parser } from "@miqro/parser";
|
|
|
5
5
|
import { APIRouteSchema, SessionHandlerOptionsSchema } from "@miqro/core";
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
7
|
import { esBuild } from "./esbuild.js";
|
|
8
|
-
import {
|
|
9
|
-
import { getJSXJSPath, JSX_TMP_DIR } from "./paths.js";
|
|
8
|
+
import { JSX_TMP_DIR } from "./paths.js";
|
|
10
9
|
import { CLEAR_JSX_CACHE } from "./constants.js";
|
|
11
|
-
import { getAsset, initAsset, validateAsset } from "./assets.js";
|
|
12
|
-
import { calculateChecksumFromBuffer } from "./checksum.js";
|
|
13
10
|
import { HandlerWithOptionsSchema, RouteOptionsSchema } from "@miqro/core/build/types.js";
|
|
14
11
|
import { mkdirASync, rmdirASync, unlinkASync, writeFileASync } from "./fs.js";
|
|
15
12
|
let jsxJSBuffer = null; // Buffer.from(getAsset("jsx.dom.js"));
|
|
16
13
|
let jsxJSBufferChecksumPromise = null; // calculateChecksumFromBuffer(jsxJSBuffer);
|
|
17
|
-
export async function initJSXJS(logger) {
|
|
18
|
-
jsxJSBuffer = jsxJSBuffer ? jsxJSBuffer : Buffer.from(getAsset("jsx.dom.js"));
|
|
19
|
-
jsxJSBufferChecksumPromise = jsxJSBufferChecksumPromise ? jsxJSBufferChecksumPromise : calculateChecksumFromBuffer(jsxJSBuffer);
|
|
20
|
-
return initAsset(logger, getJSXJSPath(), jsxJSBuffer, true, jsxJSBufferChecksumPromise, false);
|
|
21
|
-
}
|
|
22
|
-
export async function validateJSXJS(logger) {
|
|
23
|
-
const checksum = await jsxJSBufferChecksumPromise;
|
|
24
|
-
if (!checksum) {
|
|
25
|
-
throw new Error("error calculating checksum");
|
|
26
|
-
}
|
|
27
|
-
return validateAsset(logger, getJSXJSPath(), checksum);
|
|
28
|
-
}
|
|
29
14
|
const parser = new Parser();
|
|
30
15
|
const DEFAULT_ESOPTION = {
|
|
31
16
|
platform: "neutral",
|
|
17
|
+
mainFields: "module,main",
|
|
18
|
+
// platform: "node",
|
|
32
19
|
bundle: true,
|
|
33
20
|
jsxFactory: "JSX.createElement",
|
|
34
21
|
jsxFragment: "JSX.Fragment"
|
|
35
22
|
};
|
|
23
|
+
function JSXTemplate(inFile /*, jsxPath: string | false = false*/, useExport = true) {
|
|
24
|
+
// const PRE = ``;
|
|
25
|
+
// return `${jsxPath ? PRE : ""}\n${useExport ? `export * from "${inFile}";import * as lib from "${inFile}";export default lib.default;` : `import * as lib from "${inFile}"`}`;
|
|
26
|
+
return `${useExport ? `export * from "${inFile}";import * as lib from "${inFile}";export default lib.default;` : `import * as lib from "${inFile}"`}`;
|
|
27
|
+
}
|
|
36
28
|
export async function inflateJSX(inFile, options) {
|
|
37
29
|
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "build", Date.now() + "-" + randomUUID());
|
|
38
30
|
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
39
|
-
const jsxJSPath = getJSXJSPath()
|
|
31
|
+
//const jsxJSPath = getJSXJSPath();//resolve(tmpBuildDir, "jsx.js");
|
|
40
32
|
const logger = options.logger; //getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
41
33
|
try {
|
|
42
|
-
if (!options.embemedJSX) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
await mkdirASync(tmpBuildDir, {
|
|
64
|
-
recursive: true
|
|
65
|
-
});
|
|
66
|
-
//await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
|
|
67
|
-
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
|
|
68
|
-
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
|
|
69
|
-
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
70
|
-
const { outputFiles: [{ contents }] } = await esBuild({
|
|
71
|
-
...DEFAULT_ESOPTION,
|
|
72
|
-
entryPoints: [inFileTmp],
|
|
73
|
-
minify: options.minify,
|
|
74
|
-
platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
|
|
75
|
-
});
|
|
76
|
-
if (CLEAR_JSX_CACHE) {
|
|
77
|
-
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
78
|
-
await unlinkASync(inFileTmp);
|
|
79
|
-
//await unlinkASync(jsxJSPath);
|
|
80
|
-
await rmdirASync(tmpBuildDir);
|
|
81
|
-
}
|
|
82
|
-
return contents;
|
|
34
|
+
// if (!options.embemedJSX) {
|
|
35
|
+
await mkdirASync(tmpBuildDir, {
|
|
36
|
+
recursive: true
|
|
37
|
+
});
|
|
38
|
+
await writeFileASync(inFileTmp, JSXTemplate(inFile /*, false*/, options.useExport));
|
|
39
|
+
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), false));
|
|
40
|
+
logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
41
|
+
const { outputFiles: [{ contents }] } = await esBuild({
|
|
42
|
+
...DEFAULT_ESOPTION,
|
|
43
|
+
entryPoints: [inFileTmp],
|
|
44
|
+
minify: options.minify,
|
|
45
|
+
platform: options.platform !== undefined ? options.platform : DEFAULT_ESOPTION.platform,
|
|
46
|
+
mainFields: options.mainFields !== undefined ? options.mainFields : DEFAULT_ESOPTION.mainFields,
|
|
47
|
+
external: options.external ? options.external : undefined,
|
|
48
|
+
});
|
|
49
|
+
if (CLEAR_JSX_CACHE) {
|
|
50
|
+
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
51
|
+
await unlinkASync(inFileTmp);
|
|
52
|
+
await rmdirASync(tmpBuildDir);
|
|
83
53
|
}
|
|
54
|
+
return contents;
|
|
55
|
+
/*} else {
|
|
56
|
+
await mkdirASync(tmpBuildDir, {
|
|
57
|
+
recursive: true
|
|
58
|
+
});
|
|
59
|
+
//await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
|
|
60
|
+
await writeFileASync(inFileTmp, browserJSXGlobals(inFile, false));
|
|
61
|
+
//await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
|
|
62
|
+
logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
63
|
+
const { outputFiles: [{ contents }] } = await esBuild({
|
|
64
|
+
...DEFAULT_ESOPTION,
|
|
65
|
+
entryPoints: [inFileTmp],
|
|
66
|
+
minify: options.minify,
|
|
67
|
+
platform: options.platform !== undefined ? options.platform : DEFAULT_ESOPTION.platform,
|
|
68
|
+
mainFields: options.mainFields !== undefined ? options.mainFields : DEFAULT_ESOPTION.mainFields,
|
|
69
|
+
external: options.external ? options.external : undefined
|
|
70
|
+
});
|
|
71
|
+
if (CLEAR_JSX_CACHE) {
|
|
72
|
+
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
73
|
+
await unlinkASync(inFileTmp);
|
|
74
|
+
//await unlinkASync(jsxJSPath);
|
|
75
|
+
await rmdirASync(tmpBuildDir);
|
|
76
|
+
}
|
|
77
|
+
return contents;
|
|
78
|
+
}*/
|
|
84
79
|
}
|
|
85
80
|
catch (e) {
|
|
86
81
|
logger?.error("error with: " + inFile);
|
|
87
82
|
logger?.error(e);
|
|
88
|
-
if (options.embemedJSX) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
83
|
+
/*if (options.embemedJSX) {
|
|
84
|
+
if (CLEAR_JSX_CACHE) {
|
|
85
|
+
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
86
|
+
await unlinkASync(inFileTmp);
|
|
87
|
+
//await unlinkASync(jsxJSPath);
|
|
88
|
+
await rmdirASync(tmpBuildDir);
|
|
89
|
+
} else {
|
|
90
|
+
//console.error("errors on: " + tmpBuildDir);
|
|
91
|
+
logger?.error("error with: %s", inFileTmp);
|
|
92
|
+
logger?.trace("NOT clearing cache. to change this behaivor set CLEAR_JSX_CACHE to 1", tmpBuildDir);
|
|
93
|
+
}
|
|
94
|
+
}*/
|
|
101
95
|
throw e;
|
|
102
96
|
}
|
|
103
97
|
}
|
|
@@ -417,14 +411,14 @@ export async function importServerConfigModule(inFile, logger) {
|
|
|
417
411
|
}
|
|
418
412
|
export async function importJSXFile(inFile, logger) {
|
|
419
413
|
const inflatedCode = await inflateJSX(inFile, {
|
|
420
|
-
embemedJSX: false,
|
|
414
|
+
// embemedJSX: false,
|
|
421
415
|
minify: false,
|
|
422
416
|
useExport: true,
|
|
423
417
|
platform: "node",
|
|
424
418
|
logger
|
|
425
419
|
});
|
|
426
420
|
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + randomUUID());
|
|
427
|
-
//const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
421
|
+
// const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
428
422
|
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
|
|
429
423
|
//const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
430
424
|
await mkdirASync(tmpBuildDir, {
|
|
@@ -432,11 +426,12 @@ export async function importJSXFile(inFile, logger) {
|
|
|
432
426
|
});
|
|
433
427
|
try {
|
|
434
428
|
await writeFileASync(inFileTmp, inflatedCode);
|
|
435
|
-
assertGlobalTampered();
|
|
429
|
+
// assertGlobalTampered();
|
|
436
430
|
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
437
431
|
logger?.debug("importing [%s]", relative(cwd(), inFile));
|
|
438
432
|
const module = await import(resolve(inFileTmp));
|
|
439
|
-
|
|
433
|
+
// console.dir(module);
|
|
434
|
+
// assertGlobalTampered();
|
|
440
435
|
if (CLEAR_JSX_CACHE) {
|
|
441
436
|
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
442
437
|
await unlinkASync(inFileTmp);
|
|
@@ -15,4 +15,3 @@ export declare function getAuthConfigPath(servicePath: string): string | false;
|
|
|
15
15
|
export declare function getHTTPRouterPath(servicePath: string): string | false;
|
|
16
16
|
export declare function getMigrationsPath(servicePath: string): string | false;
|
|
17
17
|
export declare function getESBuildBinaryPath(): string;
|
|
18
|
-
export declare function getJSXJSPath(): string;
|
|
@@ -82,6 +82,6 @@ export function getESBuildBinaryPath() {
|
|
|
82
82
|
return resolve(JSX_TMP_DIR, String(process.pid), "esbuild");
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
export function getJSXJSPath() {
|
|
86
|
-
|
|
87
|
-
}
|
|
85
|
+
/*export function getJSXJSPath() {
|
|
86
|
+
return resolve(JSX_TMP_DIR, String(process.pid), "jsx.js");
|
|
87
|
+
}*/
|