@antelopejs/core 0.3.2 → 1.0.0
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/dist/core/build/build-artifact.d.ts +59 -0
- package/dist/core/build/build-artifact.js +72 -0
- package/dist/core/build/build-artifact.js.map +1 -0
- package/dist/{utils → core/cli}/cli-ui.d.ts +4 -14
- package/dist/core/cli/cli-ui.js +154 -0
- package/dist/core/cli/cli-ui.js.map +1 -0
- package/dist/{utils → core/cli}/command.d.ts +1 -1
- package/dist/core/cli/command.js +25 -0
- package/dist/core/cli/command.js.map +1 -0
- package/dist/{cli → core/cli/commands}/config/get.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/config/get.js +11 -10
- package/dist/core/cli/commands/config/get.js.map +1 -0
- package/dist/{cli → core/cli/commands}/config/index.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/config/index.js +5 -4
- package/dist/core/cli/commands/config/index.js.map +1 -0
- package/dist/{cli → core/cli/commands}/config/reset.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/config/reset.js +17 -16
- package/dist/core/cli/commands/config/reset.js.map +1 -0
- package/dist/{cli/module/exports → core/cli/commands/config}/set.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/config/set.js +15 -11
- package/dist/core/cli/commands/config/set.js.map +1 -0
- package/dist/{cli → core/cli/commands}/config/show.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/config/show.js +13 -11
- package/dist/core/cli/commands/config/show.js.map +1 -0
- package/dist/{cli/module/exports → core/cli/commands/module}/index.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/module/index.js +3 -7
- package/dist/core/cli/commands/module/index.js.map +1 -0
- package/dist/{cli → core/cli/commands}/module/init.d.ts +1 -1
- package/dist/core/cli/commands/module/init.js +176 -0
- package/dist/core/cli/commands/module/init.js.map +1 -0
- package/dist/{cli → core/cli/commands}/module/test.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/module/test.js +13 -15
- package/dist/core/cli/commands/module/test.js.map +1 -0
- package/dist/{cli/config/set.d.ts → core/cli/commands/project/build.d.ts} +1 -1
- package/dist/core/cli/commands/project/build.js +71 -0
- package/dist/core/cli/commands/project/build.js.map +1 -0
- package/dist/core/cli/commands/project/dev.d.ts +20 -0
- package/dist/core/cli/commands/project/dev.js +262 -0
- package/dist/core/cli/commands/project/dev.js.map +1 -0
- package/dist/{cli/module/imports → core/cli/commands/project}/index.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/index.js +10 -3
- package/dist/core/cli/commands/project/index.js.map +1 -0
- package/dist/{cli → core/cli/commands}/project/init.d.ts +1 -1
- package/dist/core/cli/commands/project/init.js +118 -0
- package/dist/core/cli/commands/project/init.js.map +1 -0
- package/dist/{cli/module → core/cli/commands/project/logging}/index.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/logging/index.js +4 -3
- package/dist/core/cli/commands/project/logging/index.js.map +1 -0
- package/dist/{cli → core/cli/commands}/project/logging/set.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/logging/set.js +99 -89
- package/dist/core/cli/commands/project/logging/set.js.map +1 -0
- package/dist/{cli → core/cli/commands}/project/logging/show.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/logging/show.js +37 -34
- package/dist/core/cli/commands/project/logging/show.js.map +1 -0
- package/dist/{cli → core/cli/commands}/project/modules/add.d.ts +3 -3
- package/dist/core/cli/commands/project/modules/add.js +237 -0
- package/dist/core/cli/commands/project/modules/add.js.map +1 -0
- package/dist/core/cli/commands/project/modules/index.d.ts +2 -0
- package/dist/{cli → core/cli/commands}/project/modules/index.js +5 -4
- package/dist/core/cli/commands/project/modules/index.js.map +1 -0
- package/dist/{cli/module/imports → core/cli/commands/project/modules}/install.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/modules/install.js +83 -84
- package/dist/core/cli/commands/project/modules/install.js.map +1 -0
- package/dist/{cli/module/imports → core/cli/commands/project/modules}/list.d.ts +1 -1
- package/dist/core/cli/commands/project/modules/list.js +123 -0
- package/dist/core/cli/commands/project/modules/list.js.map +1 -0
- package/dist/{cli → core/cli/commands}/project/modules/remove.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/modules/remove.js +31 -28
- package/dist/core/cli/commands/project/modules/remove.js.map +1 -0
- package/dist/{cli/module/imports → core/cli/commands/project/modules}/update.d.ts +1 -1
- package/dist/{cli → core/cli/commands}/project/modules/update.js +26 -22
- package/dist/core/cli/commands/project/modules/update.js.map +1 -0
- package/dist/core/cli/commands/project/run.d.ts +1 -0
- package/dist/core/cli/commands/project/run.js +12 -0
- package/dist/core/cli/commands/project/run.js.map +1 -0
- package/dist/core/cli/commands/project/start.d.ts +2 -0
- package/dist/core/cli/commands/project/start.js +57 -0
- package/dist/core/cli/commands/project/start.js.map +1 -0
- package/dist/core/cli/commands/shared/project-command.d.ts +8 -0
- package/dist/core/cli/commands/shared/project-command.js +32 -0
- package/dist/core/cli/commands/shared/project-command.js.map +1 -0
- package/dist/core/cli/common.d.ts +23 -0
- package/dist/core/cli/common.js +203 -0
- package/dist/core/cli/common.js.map +1 -0
- package/dist/{cli/git.d.ts → core/cli/git-operations.d.ts} +1 -20
- package/dist/core/cli/git-operations.js +159 -0
- package/dist/core/cli/git-operations.js.map +1 -0
- package/dist/core/cli/index.d.ts +4 -0
- package/dist/core/cli/index.js +81 -0
- package/dist/core/cli/index.js.map +1 -0
- package/dist/core/cli/logging-utils.d.ts +17 -0
- package/dist/{logging/utils.js → core/cli/logging-utils.js} +49 -43
- package/dist/core/cli/logging-utils.js.map +1 -0
- package/dist/{utils → core/cli}/package-manager.d.ts +4 -3
- package/dist/core/cli/package-manager.js +106 -0
- package/dist/core/cli/package-manager.js.map +1 -0
- package/dist/{logging → core/cli}/terminal-display.d.ts +1 -3
- package/dist/{logging → core/cli}/terminal-display.js +6 -7
- package/dist/core/cli/terminal-display.js.map +1 -0
- package/dist/core/cli/version-check.d.ts +2 -0
- package/dist/{cli → core/cli}/version-check.js +9 -5
- package/dist/core/cli/version-check.js.map +1 -0
- package/dist/core/config/config-loader.d.ts +20 -0
- package/dist/core/config/config-loader.js +98 -0
- package/dist/core/config/config-loader.js.map +1 -0
- package/dist/core/config/config-parser.d.ts +16 -0
- package/dist/core/config/config-parser.js +134 -0
- package/dist/core/config/config-parser.js.map +1 -0
- package/dist/core/config/config-paths.d.ts +7 -0
- package/dist/core/config/config-paths.js +32 -0
- package/dist/core/config/config-paths.js.map +1 -0
- package/dist/core/config/index.d.ts +3 -0
- package/dist/core/config/index.js +20 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/downloaders/git.d.ts +8 -0
- package/dist/core/downloaders/git.js +96 -0
- package/dist/core/downloaders/git.js.map +1 -0
- package/dist/core/downloaders/local-folder.d.ts +8 -0
- package/dist/core/downloaders/local-folder.js +70 -0
- package/dist/core/downloaders/local-folder.js.map +1 -0
- package/dist/core/downloaders/local.d.ts +8 -0
- package/dist/core/downloaders/local.js +59 -0
- package/dist/core/downloaders/local.js.map +1 -0
- package/dist/core/downloaders/package.d.ts +11 -0
- package/dist/core/downloaders/package.js +99 -0
- package/dist/core/downloaders/package.js.map +1 -0
- package/dist/core/downloaders/registry.d.ts +11 -0
- package/dist/core/downloaders/registry.js +85 -0
- package/dist/core/downloaders/registry.js.map +1 -0
- package/dist/core/downloaders/types.d.ts +11 -0
- package/dist/core/downloaders/types.js +3 -0
- package/dist/core/downloaders/types.js.map +1 -0
- package/dist/core/downloaders/utils.d.ts +5 -0
- package/dist/core/downloaders/utils.js +77 -0
- package/dist/core/downloaders/utils.js.map +1 -0
- package/dist/core/filesystem.d.ts +20 -0
- package/dist/core/filesystem.js +80 -0
- package/dist/core/filesystem.js.map +1 -0
- package/dist/core/interface-registry.d.ts +7 -0
- package/dist/core/interface-registry.js +23 -0
- package/dist/core/interface-registry.js.map +1 -0
- package/dist/{common/cache.d.ts → core/module-cache.d.ts} +8 -4
- package/dist/{common/cache.js → core/module-cache.js} +52 -32
- package/dist/core/module-cache.js.map +1 -0
- package/dist/core/module-lifecycle.d.ts +13 -0
- package/dist/core/module-lifecycle.js +62 -0
- package/dist/core/module-lifecycle.js.map +1 -0
- package/dist/core/module-manager.d.ts +65 -0
- package/dist/core/module-manager.js +340 -0
- package/dist/core/module-manager.js.map +1 -0
- package/dist/core/module-manifest.d.ts +45 -0
- package/dist/core/module-manifest.js +180 -0
- package/dist/core/module-manifest.js.map +1 -0
- package/dist/core/module-registry.d.ts +7 -0
- package/dist/core/module-registry.js +17 -0
- package/dist/core/module-registry.js.map +1 -0
- package/dist/core/module-tracker.d.ts +8 -0
- package/dist/core/module-tracker.js +14 -0
- package/dist/core/module-tracker.js.map +1 -0
- package/dist/core/module.d.ts +19 -0
- package/dist/core/module.js +106 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/repl/repl-session.d.ts +10 -0
- package/dist/core/repl/repl-session.js +26 -0
- package/dist/core/repl/repl-session.js.map +1 -0
- package/dist/core/resolution/path-mapper.d.ts +7 -0
- package/dist/core/resolution/path-mapper.js +79 -0
- package/dist/core/resolution/path-mapper.js.map +1 -0
- package/dist/core/resolution/resolver-detour.d.ts +8 -0
- package/dist/core/resolution/resolver-detour.js +42 -0
- package/dist/core/resolution/resolver-detour.js.map +1 -0
- package/dist/core/resolution/resolver.d.ts +23 -0
- package/dist/core/resolution/resolver.js +55 -0
- package/dist/core/resolution/resolver.js.map +1 -0
- package/dist/core/runtime/build-runtime.d.ts +8 -0
- package/dist/core/runtime/build-runtime.js +129 -0
- package/dist/core/runtime/build-runtime.js.map +1 -0
- package/dist/core/runtime/module-loading.d.ts +16 -0
- package/dist/core/runtime/module-loading.js +310 -0
- package/dist/core/runtime/module-loading.js.map +1 -0
- package/dist/core/runtime/runtime-bootstrap.d.ts +9 -0
- package/dist/core/runtime/runtime-bootstrap.js +92 -0
- package/dist/core/runtime/runtime-bootstrap.js.map +1 -0
- package/dist/core/runtime/runtime-types.d.ts +34 -0
- package/dist/core/runtime/runtime-types.js +3 -0
- package/dist/core/runtime/runtime-types.js.map +1 -0
- package/dist/core/shutdown/index.d.ts +1 -0
- package/dist/core/shutdown/index.js +18 -0
- package/dist/core/shutdown/index.js.map +1 -0
- package/dist/core/shutdown/shutdown-manager.d.ts +23 -0
- package/dist/core/shutdown/shutdown-manager.js +108 -0
- package/dist/core/shutdown/shutdown-manager.js.map +1 -0
- package/dist/core/test/stub-interface.d.ts +3 -0
- package/dist/core/test/stub-interface.js +40 -0
- package/dist/core/test/stub-interface.js.map +1 -0
- package/dist/core/test/test-context.d.ts +18 -0
- package/dist/core/test/test-context.js +34 -0
- package/dist/core/test/test-context.js.map +1 -0
- package/dist/core/test/test-module.d.ts +15 -0
- package/dist/core/test/test-module.js +234 -0
- package/dist/core/test/test-module.js.map +1 -0
- package/dist/core/test/test-runner.d.ts +8 -0
- package/dist/core/test/test-runner.js +33 -0
- package/dist/core/test/test-runner.js.map +1 -0
- package/dist/core/watch/file-hasher.d.ts +6 -0
- package/dist/core/watch/file-hasher.js +16 -0
- package/dist/core/watch/file-hasher.js.map +1 -0
- package/dist/core/watch/file-watcher.d.ts +24 -0
- package/dist/core/watch/file-watcher.js +179 -0
- package/dist/core/watch/file-watcher.js.map +1 -0
- package/dist/core/watch/hot-reload.d.ts +10 -0
- package/dist/core/watch/hot-reload.js +36 -0
- package/dist/core/watch/hot-reload.js.map +1 -0
- package/dist/index.d.ts +17 -8
- package/dist/index.js +142 -150
- package/dist/index.js.map +1 -1
- package/dist/logging/index.d.ts +13 -3
- package/dist/logging/index.js +213 -9
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/log-filter.d.ts +16 -0
- package/dist/logging/log-filter.js +68 -0
- package/dist/logging/log-filter.js.map +1 -0
- package/dist/logging/log-formatter.d.ts +24 -0
- package/dist/logging/log-formatter.js +76 -0
- package/dist/logging/log-formatter.js.map +1 -0
- package/dist/logging/logger.d.ts +36 -6
- package/dist/logging/logger.js +87 -113
- package/dist/logging/logger.js.map +1 -1
- package/dist/types/config.types.d.ts +7 -0
- package/dist/types/config.types.js +3 -0
- package/dist/types/config.types.js.map +1 -0
- package/dist/types/filesystem.types.d.ts +19 -0
- package/dist/types/filesystem.types.js +3 -0
- package/dist/types/filesystem.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/module.types.d.ts +11 -0
- package/dist/types/module.types.js +10 -0
- package/dist/types/module.types.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lock.js +15 -10
- package/dist/utils/lock.js.map +1 -1
- package/dist/utils/object.d.ts +3 -2
- package/dist/utils/object.js +28 -13
- package/dist/utils/object.js.map +1 -1
- package/dist/utils/promise.d.ts +5 -3
- package/dist/utils/promise.js +15 -15
- package/dist/utils/promise.js.map +1 -1
- package/package.json +44 -32
- package/dist/cli/common.d.ts +0 -22
- package/dist/cli/common.js +0 -105
- package/dist/cli/common.js.map +0 -1
- package/dist/cli/config/get.js.map +0 -1
- package/dist/cli/config/index.js.map +0 -1
- package/dist/cli/config/reset.js.map +0 -1
- package/dist/cli/config/set.js.map +0 -1
- package/dist/cli/config/show.js.map +0 -1
- package/dist/cli/git.js +0 -349
- package/dist/cli/git.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -68
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/module/exports/generate.d.ts +0 -2
- package/dist/cli/module/exports/generate.js +0 -153
- package/dist/cli/module/exports/generate.js.map +0 -1
- package/dist/cli/module/exports/index.js +0 -16
- package/dist/cli/module/exports/index.js.map +0 -1
- package/dist/cli/module/exports/set.js +0 -47
- package/dist/cli/module/exports/set.js.map +0 -1
- package/dist/cli/module/imports/add.d.ts +0 -10
- package/dist/cli/module/imports/add.js +0 -175
- package/dist/cli/module/imports/add.js.map +0 -1
- package/dist/cli/module/imports/index.js +0 -22
- package/dist/cli/module/imports/index.js.map +0 -1
- package/dist/cli/module/imports/install.js +0 -132
- package/dist/cli/module/imports/install.js.map +0 -1
- package/dist/cli/module/imports/list.js +0 -93
- package/dist/cli/module/imports/list.js.map +0 -1
- package/dist/cli/module/imports/remove.d.ts +0 -2
- package/dist/cli/module/imports/remove.js +0 -100
- package/dist/cli/module/imports/remove.js.map +0 -1
- package/dist/cli/module/imports/update.js +0 -161
- package/dist/cli/module/imports/update.js.map +0 -1
- package/dist/cli/module/index.js.map +0 -1
- package/dist/cli/module/init.js +0 -194
- package/dist/cli/module/init.js.map +0 -1
- package/dist/cli/module/test.js.map +0 -1
- package/dist/cli/project/index.d.ts +0 -2
- package/dist/cli/project/index.js.map +0 -1
- package/dist/cli/project/init.js +0 -120
- package/dist/cli/project/init.js.map +0 -1
- package/dist/cli/project/logging/index.d.ts +0 -2
- package/dist/cli/project/logging/index.js.map +0 -1
- package/dist/cli/project/logging/set.js.map +0 -1
- package/dist/cli/project/logging/show.js.map +0 -1
- package/dist/cli/project/modules/add.js +0 -239
- package/dist/cli/project/modules/add.js.map +0 -1
- package/dist/cli/project/modules/index.d.ts +0 -2
- package/dist/cli/project/modules/index.js.map +0 -1
- package/dist/cli/project/modules/install.d.ts +0 -2
- package/dist/cli/project/modules/install.js.map +0 -1
- package/dist/cli/project/modules/list.d.ts +0 -2
- package/dist/cli/project/modules/list.js +0 -92
- package/dist/cli/project/modules/list.js.map +0 -1
- package/dist/cli/project/modules/remove.js.map +0 -1
- package/dist/cli/project/modules/update.d.ts +0 -2
- package/dist/cli/project/modules/update.js.map +0 -1
- package/dist/cli/project/run.d.ts +0 -2
- package/dist/cli/project/run.js +0 -147
- package/dist/cli/project/run.js.map +0 -1
- package/dist/cli/version-check.d.ts +0 -1
- package/dist/cli/version-check.js.map +0 -1
- package/dist/common/cache.js.map +0 -1
- package/dist/common/config.d.ts +0 -55
- package/dist/common/config.js +0 -168
- package/dist/common/config.js.map +0 -1
- package/dist/common/downloader/git.d.ts +0 -8
- package/dist/common/downloader/git.js +0 -97
- package/dist/common/downloader/git.js.map +0 -1
- package/dist/common/downloader/index.d.ts +0 -13
- package/dist/common/downloader/index.js +0 -58
- package/dist/common/downloader/index.js.map +0 -1
- package/dist/common/downloader/local.d.ts +0 -12
- package/dist/common/downloader/local.js +0 -70
- package/dist/common/downloader/local.js.map +0 -1
- package/dist/common/downloader/package.d.ts +0 -6
- package/dist/common/downloader/package.js +0 -58
- package/dist/common/downloader/package.js.map +0 -1
- package/dist/common/manifest.d.ts +0 -48
- package/dist/common/manifest.js +0 -126
- package/dist/common/manifest.js.map +0 -1
- package/dist/interfaces/core/beta/decorators.d.ts +0 -29
- package/dist/interfaces/core/beta/decorators.js +0 -72
- package/dist/interfaces/core/beta/decorators.js.map +0 -1
- package/dist/interfaces/core/beta/index.d.ts +0 -58
- package/dist/interfaces/core/beta/index.js +0 -266
- package/dist/interfaces/core/beta/index.js.map +0 -1
- package/dist/interfaces/core/beta/modules.d.ts +0 -26
- package/dist/interfaces/core/beta/modules.js +0 -31
- package/dist/interfaces/core/beta/modules.js.map +0 -1
- package/dist/interfaces/logging/beta/index.d.ts +0 -27
- package/dist/interfaces/logging/beta/index.js +0 -61
- package/dist/interfaces/logging/beta/index.js.map +0 -1
- package/dist/interfaces/logging/beta/listener.d.ts +0 -9
- package/dist/interfaces/logging/beta/listener.js +0 -5
- package/dist/interfaces/logging/beta/listener.js.map +0 -1
- package/dist/loader/index.d.ts +0 -45
- package/dist/loader/index.js +0 -490
- package/dist/loader/index.js.map +0 -1
- package/dist/loader/module.d.ts +0 -29
- package/dist/loader/module.js +0 -142
- package/dist/loader/module.js.map +0 -1
- package/dist/logging/terminal-display.js.map +0 -1
- package/dist/logging/utils.d.ts +0 -21
- package/dist/logging/utils.js.map +0 -1
- package/dist/utils/cli-ui.js +0 -245
- package/dist/utils/cli-ui.js.map +0 -1
- package/dist/utils/command.js +0 -23
- package/dist/utils/command.js.map +0 -1
- package/dist/utils/package-manager.js +0 -99
- package/dist/utils/package-manager.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileHasher = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
class FileHasher {
|
|
6
|
+
fs;
|
|
7
|
+
constructor(fs) {
|
|
8
|
+
this.fs = fs;
|
|
9
|
+
}
|
|
10
|
+
async hashFile(filePath) {
|
|
11
|
+
const content = await this.fs.readFile(filePath);
|
|
12
|
+
return (0, node_crypto_1.createHash)("sha256").update(content).digest("hex");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.FileHasher = FileHasher;
|
|
16
|
+
//# sourceMappingURL=file-hasher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-hasher.js","sourceRoot":"","sources":["../../../src/core/watch/file-hasher.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC,MAAa,UAAU;IACD;IAApB,YAAoB,EAAe;QAAf,OAAE,GAAF,EAAE,CAAa;IAAG,CAAC;IAEvC,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC7B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;CACF;AAPD,gCAOC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IFileSystem } from "../../types";
|
|
2
|
+
import { FileHasher } from "./file-hasher";
|
|
3
|
+
export type ModuleChangeListener = (moduleId: string) => void;
|
|
4
|
+
export declare class FileWatcher {
|
|
5
|
+
private fs;
|
|
6
|
+
private hasher;
|
|
7
|
+
private filesHash;
|
|
8
|
+
private listeners;
|
|
9
|
+
private excludedDirs;
|
|
10
|
+
private watchers;
|
|
11
|
+
private watchedDirs;
|
|
12
|
+
private watchedDirModules;
|
|
13
|
+
constructor(fs: IFileSystem, hasher?: FileHasher);
|
|
14
|
+
onModuleChanged(listener: ModuleChangeListener): void;
|
|
15
|
+
scanModule(moduleId: string, rootDir: string, watchDirs?: string[]): Promise<void>;
|
|
16
|
+
startWatching(): void;
|
|
17
|
+
stopWatching(): void;
|
|
18
|
+
handleFileChange(filePath: string): Promise<void>;
|
|
19
|
+
private exploreDir;
|
|
20
|
+
private trackWatchedDir;
|
|
21
|
+
private getModuleIdForPath;
|
|
22
|
+
private notifyModuleChange;
|
|
23
|
+
private isExcludedPath;
|
|
24
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FileWatcher = void 0;
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const file_hasher_1 = require("./file-hasher");
|
|
40
|
+
const EXCLUDED_WATCH_DIRS = [".git", "node_modules"];
|
|
41
|
+
class FileWatcher {
|
|
42
|
+
fs;
|
|
43
|
+
hasher;
|
|
44
|
+
filesHash = new Map();
|
|
45
|
+
listeners = [];
|
|
46
|
+
excludedDirs = new Set(EXCLUDED_WATCH_DIRS);
|
|
47
|
+
watchers = new Map();
|
|
48
|
+
watchedDirs = new Set();
|
|
49
|
+
watchedDirModules = new Map();
|
|
50
|
+
constructor(fs, hasher = new file_hasher_1.FileHasher(fs)) {
|
|
51
|
+
this.fs = fs;
|
|
52
|
+
this.hasher = hasher;
|
|
53
|
+
}
|
|
54
|
+
onModuleChanged(listener) {
|
|
55
|
+
this.listeners.push(listener);
|
|
56
|
+
}
|
|
57
|
+
async scanModule(moduleId, rootDir, watchDirs = [""]) {
|
|
58
|
+
for (const dir of watchDirs) {
|
|
59
|
+
await this.exploreDir(moduleId, path.join(rootDir, dir));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
startWatching() {
|
|
63
|
+
for (const dir of this.watchedDirs) {
|
|
64
|
+
if (this.watchers.has(dir)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const watcher = (0, node_fs_1.watch)(dir, (event, filename) => {
|
|
69
|
+
if (!filename || (event !== "change" && event !== "rename")) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const fileName = Buffer.isBuffer(filename)
|
|
73
|
+
? filename.toString()
|
|
74
|
+
: filename;
|
|
75
|
+
const filePath = path.join(dir, fileName);
|
|
76
|
+
void this.handleFileChange(filePath);
|
|
77
|
+
});
|
|
78
|
+
watcher.on("error", (err) => {
|
|
79
|
+
console.error(`FileWatcher error for ${dir}:`, err);
|
|
80
|
+
});
|
|
81
|
+
this.watchers.set(dir, watcher);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error(`Failed to watch directory ${dir}:`, err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
stopWatching() {
|
|
89
|
+
for (const watcher of this.watchers.values()) {
|
|
90
|
+
watcher.close();
|
|
91
|
+
}
|
|
92
|
+
this.watchers.clear();
|
|
93
|
+
}
|
|
94
|
+
async handleFileChange(filePath) {
|
|
95
|
+
if (this.isExcludedPath(filePath)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const entry = this.filesHash.get(filePath);
|
|
99
|
+
if (!(await this.fs.exists(filePath))) {
|
|
100
|
+
if (entry) {
|
|
101
|
+
this.filesHash.delete(filePath);
|
|
102
|
+
this.notifyModuleChange(entry.moduleId);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const stat = await this.fs.stat(filePath);
|
|
107
|
+
if (stat.isDirectory()) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const newHash = await this.hasher.hashFile(filePath);
|
|
111
|
+
if (!entry) {
|
|
112
|
+
const moduleId = this.getModuleIdForPath(filePath);
|
|
113
|
+
if (!moduleId) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.filesHash.set(filePath, { moduleId, hash: newHash });
|
|
117
|
+
this.notifyModuleChange(moduleId);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (newHash !== entry.hash) {
|
|
121
|
+
this.filesHash.set(filePath, { moduleId: entry.moduleId, hash: newHash });
|
|
122
|
+
this.notifyModuleChange(entry.moduleId);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async exploreDir(moduleId, dirPath) {
|
|
126
|
+
this.trackWatchedDir(dirPath, moduleId);
|
|
127
|
+
const entries = await this.fs.readdir(dirPath);
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
const fullPath = path.join(dirPath, entry);
|
|
130
|
+
const stat = await this.fs.stat(fullPath);
|
|
131
|
+
if (stat.isDirectory()) {
|
|
132
|
+
if (this.excludedDirs.has(entry)) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
await this.exploreDir(moduleId, fullPath);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const hash = await this.hasher.hashFile(fullPath);
|
|
139
|
+
this.filesHash.set(fullPath, { moduleId, hash });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
trackWatchedDir(dirPath, moduleId) {
|
|
144
|
+
this.watchedDirs.add(dirPath);
|
|
145
|
+
const existing = this.watchedDirModules.get(dirPath);
|
|
146
|
+
if (existing) {
|
|
147
|
+
existing.add(moduleId);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.watchedDirModules.set(dirPath, new Set([moduleId]));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
getModuleIdForPath(filePath) {
|
|
154
|
+
let current = path.dirname(path.resolve(filePath));
|
|
155
|
+
while (true) {
|
|
156
|
+
const entry = this.watchedDirModules.get(current);
|
|
157
|
+
if (entry && entry.size > 0) {
|
|
158
|
+
return entry.values().next().value;
|
|
159
|
+
}
|
|
160
|
+
const parent = path.dirname(current);
|
|
161
|
+
if (parent === current) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
current = parent;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
notifyModuleChange(moduleId) {
|
|
168
|
+
for (const listener of this.listeners) {
|
|
169
|
+
listener(moduleId);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
isExcludedPath(filePath) {
|
|
173
|
+
const normalized = path.normalize(filePath);
|
|
174
|
+
const parts = normalized.split(path.sep);
|
|
175
|
+
return parts.some((part) => this.excludedDirs.has(part));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.FileWatcher = FileWatcher;
|
|
179
|
+
//# sourceMappingURL=file-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../../src/core/watch/file-watcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAgD;AAChD,gDAAkC;AAElC,+CAA2C;AAI3C,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAErD,MAAa,WAAW;IASZ;IACA;IATF,SAAS,GAAG,IAAI,GAAG,EAA8C,CAAC;IAClE,SAAS,GAA2B,EAAE,CAAC;IACvC,YAAY,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC5C,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAC;IACxC,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,iBAAiB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE3D,YACU,EAAe,EACf,SAAqB,IAAI,wBAAU,CAAC,EAAE,CAAC;QADvC,OAAE,GAAF,EAAE,CAAa;QACf,WAAM,GAAN,MAAM,CAAiC;IAC9C,CAAC;IAEJ,eAAe,CAAC,QAA8B;QAC5C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,UAAU,CACd,QAAgB,EAChB,OAAe,EACf,YAAsB,CAAC,EAAE,CAAC;QAE1B,KAAK,MAAM,GAAG,IAAI,SAAS,EA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,CAAC;QAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAvJD,kCAuJC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ReloadHandler = (moduleId: string) => void | Promise<void>;
|
|
2
|
+
export declare class HotReload {
|
|
3
|
+
private reload;
|
|
4
|
+
private debounceMs;
|
|
5
|
+
private pending;
|
|
6
|
+
private timer?;
|
|
7
|
+
constructor(reload: ReloadHandler, debounceMs?: number);
|
|
8
|
+
queue(moduleId: string): void;
|
|
9
|
+
clear(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HotReload = void 0;
|
|
4
|
+
const DEFAULT_DEBOUNCE_MS = 500;
|
|
5
|
+
class HotReload {
|
|
6
|
+
reload;
|
|
7
|
+
debounceMs;
|
|
8
|
+
pending = new Set();
|
|
9
|
+
timer;
|
|
10
|
+
constructor(reload, debounceMs = DEFAULT_DEBOUNCE_MS) {
|
|
11
|
+
this.reload = reload;
|
|
12
|
+
this.debounceMs = debounceMs;
|
|
13
|
+
}
|
|
14
|
+
queue(moduleId) {
|
|
15
|
+
this.pending.add(moduleId);
|
|
16
|
+
if (!this.timer) {
|
|
17
|
+
this.timer = setTimeout(async () => {
|
|
18
|
+
const modules = Array.from(this.pending);
|
|
19
|
+
this.pending.clear();
|
|
20
|
+
this.timer = undefined;
|
|
21
|
+
for (const id of modules) {
|
|
22
|
+
await this.reload(id);
|
|
23
|
+
}
|
|
24
|
+
}, this.debounceMs);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
clear() {
|
|
28
|
+
if (this.timer) {
|
|
29
|
+
clearTimeout(this.timer);
|
|
30
|
+
this.timer = undefined;
|
|
31
|
+
}
|
|
32
|
+
this.pending.clear();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.HotReload = HotReload;
|
|
36
|
+
//# sourceMappingURL=hot-reload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hot-reload.js","sourceRoot":"","sources":["../../../src/core/watch/hot-reload.ts"],"names":[],"mappings":";;;AAEA,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,MAAa,SAAS;IAKV;IACA;IALF,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5B,KAAK,CAAkB;IAE/B,YACU,MAAqB,EACrB,aAAqB,mBAAmB;QADxC,WAAM,GAAN,MAAM,CAAe;QACrB,eAAU,GAAV,UAAU,CAA8B;IAC/C,CAAC;IAEJ,KAAK,CAAC,QAAgB;QACpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE;gBACjC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACzC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACrB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;gBACvB,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;oBACzB,MAAM,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACzB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AA9BD,8BA8BC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export
|
|
8
|
-
export
|
|
1
|
+
import { ModuleManager } from "./core/module-manager";
|
|
2
|
+
import type { BuildOptions } from "./core/runtime/runtime-types";
|
|
3
|
+
import type { LaunchOptions } from "./types";
|
|
4
|
+
export { ConfigLoader } from "./core/config/config-loader";
|
|
5
|
+
export { DEFAULT_ENV } from "./core/config/config-paths";
|
|
6
|
+
export { DownloaderRegistry } from "./core/downloaders/registry";
|
|
7
|
+
export { Module } from "./core/module";
|
|
8
|
+
export { ModuleCache } from "./core/module-cache";
|
|
9
|
+
export { ModuleManager } from "./core/module-manager";
|
|
10
|
+
export { ModuleManifest } from "./core/module-manifest";
|
|
11
|
+
export type { BuildOptions } from "./core/runtime/runtime-types";
|
|
12
|
+
export { TestModule } from "./core/test/test-module";
|
|
13
|
+
export { LaunchOptions } from "./types";
|
|
14
|
+
export declare function launch(projectFolder?: string, env?: string, options?: LaunchOptions): Promise<ModuleManager>;
|
|
15
|
+
export declare function build(projectFolder?: string, env?: string, options?: BuildOptions): Promise<void>;
|
|
16
|
+
export declare function launchFromBuild(projectFolder?: string, env?: string, options?: LaunchOptions): Promise<ModuleManager>;
|
|
17
|
+
export default launch;
|
package/dist/index.js
CHANGED
|
@@ -1,165 +1,157 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TestModule =
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
3
|
+
exports.TestModule = exports.ModuleManifest = exports.ModuleManager = exports.ModuleCache = exports.Module = exports.DownloaderRegistry = exports.DEFAULT_ENV = exports.ConfigLoader = void 0;
|
|
4
|
+
exports.launch = launch;
|
|
5
|
+
exports.build = build;
|
|
6
|
+
exports.launchFromBuild = launchFromBuild;
|
|
7
|
+
const node_stream_1 = require("node:stream");
|
|
8
|
+
const logging_1 = require("@antelopejs/interface-core/logging");
|
|
9
|
+
const config_paths_1 = require("./core/config/config-paths");
|
|
10
|
+
const filesystem_1 = require("./core/filesystem");
|
|
11
|
+
const module_manager_1 = require("./core/module-manager");
|
|
12
|
+
const repl_session_1 = require("./core/repl/repl-session");
|
|
13
|
+
const build_runtime_1 = require("./core/runtime/build-runtime");
|
|
14
|
+
const module_loading_1 = require("./core/runtime/module-loading");
|
|
15
|
+
const runtime_bootstrap_1 = require("./core/runtime/runtime-bootstrap");
|
|
16
|
+
const shutdown_1 = require("./core/shutdown");
|
|
17
|
+
const file_watcher_1 = require("./core/watch/file-watcher");
|
|
18
|
+
const hot_reload_1 = require("./core/watch/hot-reload");
|
|
19
|
+
const logging_2 = require("./logging");
|
|
20
|
+
var config_loader_1 = require("./core/config/config-loader");
|
|
21
|
+
Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return config_loader_1.ConfigLoader; } });
|
|
22
|
+
var config_paths_2 = require("./core/config/config-paths");
|
|
23
|
+
Object.defineProperty(exports, "DEFAULT_ENV", { enumerable: true, get: function () { return config_paths_2.DEFAULT_ENV; } });
|
|
24
|
+
var registry_1 = require("./core/downloaders/registry");
|
|
25
|
+
Object.defineProperty(exports, "DownloaderRegistry", { enumerable: true, get: function () { return registry_1.DownloaderRegistry; } });
|
|
26
|
+
var module_1 = require("./core/module");
|
|
27
|
+
Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return module_1.Module; } });
|
|
28
|
+
var module_cache_1 = require("./core/module-cache");
|
|
29
|
+
Object.defineProperty(exports, "ModuleCache", { enumerable: true, get: function () { return module_cache_1.ModuleCache; } });
|
|
30
|
+
var module_manager_2 = require("./core/module-manager");
|
|
31
|
+
Object.defineProperty(exports, "ModuleManager", { enumerable: true, get: function () { return module_manager_2.ModuleManager; } });
|
|
32
|
+
var module_manifest_1 = require("./core/module-manifest");
|
|
33
|
+
Object.defineProperty(exports, "ModuleManifest", { enumerable: true, get: function () { return module_manifest_1.ModuleManifest; } });
|
|
34
|
+
var test_module_1 = require("./core/test/test-module");
|
|
35
|
+
Object.defineProperty(exports, "TestModule", { enumerable: true, get: function () { return test_module_1.TestModule; } });
|
|
36
|
+
const Logger = new logging_1.Logging.Channel("loader");
|
|
37
|
+
const MAX_STREAM_LISTENERS = 20;
|
|
38
|
+
const INTERACTIVE_PROMPT = "> ";
|
|
39
|
+
const SHUTDOWN_PRIORITY_MODULES = 30;
|
|
40
|
+
const SHUTDOWN_PRIORITY_RESOURCES = 20;
|
|
41
|
+
const SHUTDOWN_PRIORITY_CLEANUP = 10;
|
|
42
|
+
node_stream_1.Writable.prototype.setMaxListeners(MAX_STREAM_LISTENERS);
|
|
43
|
+
let activeShutdownManager;
|
|
44
|
+
function setActiveShutdownManager(shutdownManager) {
|
|
45
|
+
activeShutdownManager?.removeSignalHandlers();
|
|
46
|
+
activeShutdownManager = shutdownManager;
|
|
47
|
+
shutdownManager.setupSignalHandlers();
|
|
43
48
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
process.on('unhandledRejection', (reason) => {
|
|
50
|
-
beta_1.Logging.Error(reason);
|
|
51
|
-
if (reason instanceof AggregateError && reason.errors) {
|
|
52
|
-
for (const err of reason.errors) {
|
|
53
|
-
beta_1.Logging.Error(' -', err);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
process.exit(1);
|
|
57
|
-
});
|
|
58
|
-
process.on('warning', (warning) => {
|
|
59
|
-
beta_1.Logging.Warn(warning.message);
|
|
60
|
-
});
|
|
49
|
+
function registerModuleShutdownHandler(shutdownManager, manager) {
|
|
50
|
+
shutdownManager.register(async () => {
|
|
51
|
+
await manager.stopAll();
|
|
52
|
+
await manager.destroyAll();
|
|
53
|
+
}, SHUTDOWN_PRIORITY_MODULES);
|
|
61
54
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
await addTestFolder(mocha, filePath, matcher);
|
|
68
|
-
}
|
|
69
|
-
else if (matcher.test(filePath)) {
|
|
70
|
-
beta_1.Logging.Debug('Adding test file', filePath);
|
|
71
|
-
mocha.addFile(filePath);
|
|
55
|
+
function registerShutdownCleanup(shutdownManager) {
|
|
56
|
+
shutdownManager.register(async () => {
|
|
57
|
+
shutdownManager.removeSignalHandlers();
|
|
58
|
+
if (activeShutdownManager === shutdownManager) {
|
|
59
|
+
activeShutdownManager = undefined;
|
|
72
60
|
}
|
|
73
|
-
}
|
|
61
|
+
}, SHUTDOWN_PRIORITY_CLEANUP);
|
|
74
62
|
}
|
|
75
|
-
async function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const rawconfig = require(testProject);
|
|
86
|
-
const config = 'setup' in rawconfig ? await rawconfig.setup() : rawconfig;
|
|
87
|
-
try {
|
|
88
|
-
(0, logging_1.setupAntelopeProjectLogging)(config.logging);
|
|
89
|
-
setupProcessHandlers();
|
|
90
|
-
const moduleManager = new loader_1.ModuleManager(moduleRoot, path_1.default.resolve(path_1.default.join(__dirname, '..')), config.cacheFolder);
|
|
91
|
-
const legacyModuleList = await ConvertConfig(config);
|
|
92
|
-
try {
|
|
93
|
-
await moduleManager.init(legacyModuleList);
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
beta_1.Logging.Error('Error during module manager initialization', err);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
moduleManager.startModules();
|
|
100
|
-
const testFolder = path_1.default.join(moduleRoot, testConfig.folder);
|
|
101
|
-
const mocha = new mocha_1.default();
|
|
102
|
-
if (files) {
|
|
103
|
-
for (const file of files) {
|
|
104
|
-
mocha.addFile(file);
|
|
63
|
+
async function setupPostLaunchFeatures(manager, fs, options, shutdownManager, loaderContext) {
|
|
64
|
+
registerModuleShutdownHandler(shutdownManager, manager);
|
|
65
|
+
registerShutdownCleanup(shutdownManager);
|
|
66
|
+
if (options.watch) {
|
|
67
|
+
const watcher = new file_watcher_1.FileWatcher(fs);
|
|
68
|
+
const hotReload = new hot_reload_1.HotReload(async (moduleId) => (0, module_loading_1.reloadWatchedModule)(manager, moduleId, loaderContext));
|
|
69
|
+
for (const { module } of manager.getLoadedModules()) {
|
|
70
|
+
if (module.manifest?.source?.type === "local") {
|
|
71
|
+
const watchDirs = (0, module_loading_1.getWatchDirs)(module.manifest.source);
|
|
72
|
+
await watcher.scanModule(module.id, module.manifest.folder, watchDirs);
|
|
105
73
|
}
|
|
106
74
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
beta_1.Logging.Error('Error during shutdown', err);
|
|
116
|
-
}
|
|
75
|
+
watcher.onModuleChanged((id) => hotReload.queue(id));
|
|
76
|
+
watcher.startWatching();
|
|
77
|
+
shutdownManager.register(async () => {
|
|
78
|
+
hotReload.clear();
|
|
79
|
+
watcher.stopWatching();
|
|
80
|
+
}, SHUTDOWN_PRIORITY_RESOURCES);
|
|
117
81
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
82
|
+
if (options.interactive) {
|
|
83
|
+
const repl = new repl_session_1.ReplSession({ moduleManager: manager });
|
|
84
|
+
repl.start(INTERACTIVE_PROMPT);
|
|
85
|
+
shutdownManager.register(async () => {
|
|
86
|
+
repl.close();
|
|
87
|
+
}, SHUTDOWN_PRIORITY_RESOURCES);
|
|
122
88
|
}
|
|
89
|
+
setActiveShutdownManager(shutdownManager);
|
|
123
90
|
}
|
|
124
|
-
async function
|
|
125
|
-
const
|
|
126
|
-
(0,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
91
|
+
async function initializeCore(projectFolder, env, options) {
|
|
92
|
+
const shutdownManager = new shutdown_1.ShutdownManager();
|
|
93
|
+
const runtimeConfig = await (0, runtime_bootstrap_1.loadProjectRuntimeConfig)(projectFolder, env, options, shutdownManager);
|
|
94
|
+
const loaderContext = await (0, module_loading_1.createLoaderContext)(runtimeConfig.normalizedConfig);
|
|
95
|
+
const manager = await (0, runtime_bootstrap_1.withRaisedMaxListeners)(async () => {
|
|
96
|
+
const moduleManager = new module_manager_1.ModuleManager();
|
|
97
|
+
await (0, module_loading_1.loadModuleEntriesForManager)(moduleManager, runtimeConfig.normalizedConfig, true, loaderContext);
|
|
98
|
+
await (0, module_loading_1.constructAndStartModules)(moduleManager);
|
|
99
|
+
return moduleManager;
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
manager,
|
|
103
|
+
fs: runtimeConfig.fs,
|
|
104
|
+
shutdownManager,
|
|
105
|
+
loaderContext,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async function launch(projectFolder = ".", env = config_paths_1.DEFAULT_ENV, options = {}) {
|
|
109
|
+
const initialized = await initializeCore(projectFolder, env, options);
|
|
110
|
+
await setupPostLaunchFeatures(initialized.manager, initialized.fs, options, initialized.shutdownManager, initialized.loaderContext);
|
|
111
|
+
return initialized.manager;
|
|
112
|
+
}
|
|
113
|
+
async function build(projectFolder = ".", env = config_paths_1.DEFAULT_ENV, options = {}) {
|
|
114
|
+
const runtimeConfig = await (0, runtime_bootstrap_1.loadProjectRuntimeConfig)(projectFolder, env, options);
|
|
115
|
+
await (0, runtime_bootstrap_1.withRaisedMaxListeners)(async () => {
|
|
116
|
+
const manager = new module_manager_1.ModuleManager();
|
|
117
|
+
const entries = await (0, module_loading_1.loadModuleEntriesForManager)(manager, runtimeConfig.normalizedConfig, false);
|
|
118
|
+
(0, module_loading_1.ensureGraphIsValid)(manager);
|
|
119
|
+
await (0, build_runtime_1.writeProjectBuildArtifact)(runtimeConfig.normalizedConfig, env, entries, runtimeConfig.fs);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function logEnvironmentMismatch(startEnv, buildEnv) {
|
|
123
|
+
if (startEnv === buildEnv) {
|
|
124
|
+
return;
|
|
152
125
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
126
|
+
Logger.Info(`Starting build created for environment '${buildEnv}' with runtime env '${startEnv}'`);
|
|
127
|
+
}
|
|
128
|
+
async function buildManagerFromArtifact(manager, artifactEntries) {
|
|
129
|
+
await (0, module_loading_1.registerCoreInterfaces)(manager);
|
|
130
|
+
manager.addModules(artifactEntries);
|
|
131
|
+
(0, module_loading_1.ensureGraphIsValid)(manager);
|
|
132
|
+
await (0, module_loading_1.constructAndStartModules)(manager);
|
|
133
|
+
}
|
|
134
|
+
async function launchFromBuild(projectFolder = ".", env = config_paths_1.DEFAULT_ENV, options = {}) {
|
|
135
|
+
const shutdownManager = new shutdown_1.ShutdownManager();
|
|
136
|
+
(0, runtime_bootstrap_1.setupProcessHandlers)(shutdownManager);
|
|
137
|
+
const fs = new filesystem_1.NodeFileSystem();
|
|
138
|
+
const artifact = await (0, build_runtime_1.readBuildArtifactOrThrow)(projectFolder, fs);
|
|
139
|
+
(0, logging_2.setupAntelopeProjectLogging)(artifact.config.logging);
|
|
140
|
+
(0, runtime_bootstrap_1.applyVerboseChannels)(options.verbose);
|
|
141
|
+
const startEnv = env || config_paths_1.DEFAULT_ENV;
|
|
142
|
+
logEnvironmentMismatch(startEnv, artifact.env);
|
|
143
|
+
await (0, build_runtime_1.warnIfBuildIsStale)(projectFolder, artifact, fs);
|
|
144
|
+
await (0, build_runtime_1.ensureBuildModulesExist)(artifact, fs);
|
|
145
|
+
const manager = await (0, runtime_bootstrap_1.withRaisedMaxListeners)(async () => {
|
|
146
|
+
const moduleManager = new module_manager_1.ModuleManager();
|
|
147
|
+
const artifactEntries = (0, build_runtime_1.mapArtifactModuleEntries)(artifact);
|
|
148
|
+
await buildManagerFromArtifact(moduleManager, artifactEntries);
|
|
149
|
+
return moduleManager;
|
|
163
150
|
});
|
|
151
|
+
registerModuleShutdownHandler(shutdownManager, manager);
|
|
152
|
+
registerShutdownCleanup(shutdownManager);
|
|
153
|
+
setActiveShutdownManager(shutdownManager);
|
|
154
|
+
return manager;
|
|
164
155
|
}
|
|
156
|
+
exports.default = launch;
|
|
165
157
|
//# sourceMappingURL=index.js.map
|