@antelopejs/core 0.3.2 → 1.1.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 +5 -15
- 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 +208 -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 +79 -85
- 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 +231 -0
- package/dist/core/cli/common.js.map +1 -0
- package/dist/core/cli/git-operations.d.ts +30 -0
- 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 +66 -0
- package/dist/core/module-manager.js +343 -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/interface-resolution.d.ts +14 -0
- package/dist/core/resolution/interface-resolution.js +34 -0
- package/dist/core/resolution/interface-resolution.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 +333 -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 +143 -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 +50 -38
- 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.d.ts +0 -51
- 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
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare namespace Logging {
|
|
2
|
-
enum Level {
|
|
3
|
-
ERROR = 40,
|
|
4
|
-
WARN = 30,
|
|
5
|
-
INFO = 20,
|
|
6
|
-
DEBUG = 10,
|
|
7
|
-
TRACE = 0,
|
|
8
|
-
NO_PREFIX = -1
|
|
9
|
-
}
|
|
10
|
-
class Channel {
|
|
11
|
-
readonly channel: string;
|
|
12
|
-
constructor(channel: string);
|
|
13
|
-
Error(...args: any[]): void;
|
|
14
|
-
Warn(...args: any[]): void;
|
|
15
|
-
Info(...args: any[]): void;
|
|
16
|
-
Debug(...args: any[]): void;
|
|
17
|
-
Trace(...args: any[]): void;
|
|
18
|
-
Write(levelId: number, ...args: any[]): void;
|
|
19
|
-
}
|
|
20
|
-
const Error: (...args: any[]) => void;
|
|
21
|
-
const Warn: (...args: any[]) => void;
|
|
22
|
-
const Info: (...args: any[]) => void;
|
|
23
|
-
const Debug: (...args: any[]) => void;
|
|
24
|
-
const Trace: (...args: any[]) => void;
|
|
25
|
-
function Write(levelId: number, channel: string, ...args: any[]): void;
|
|
26
|
-
}
|
|
27
|
-
export default Logging;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Logging = void 0;
|
|
7
|
-
const listener_1 = __importDefault(require("./listener"));
|
|
8
|
-
var Logging;
|
|
9
|
-
(function (Logging) {
|
|
10
|
-
let Level;
|
|
11
|
-
(function (Level) {
|
|
12
|
-
Level[Level["ERROR"] = 40] = "ERROR";
|
|
13
|
-
Level[Level["WARN"] = 30] = "WARN";
|
|
14
|
-
Level[Level["INFO"] = 20] = "INFO";
|
|
15
|
-
Level[Level["DEBUG"] = 10] = "DEBUG";
|
|
16
|
-
Level[Level["TRACE"] = 0] = "TRACE";
|
|
17
|
-
Level[Level["NO_PREFIX"] = -1] = "NO_PREFIX";
|
|
18
|
-
})(Level = Logging.Level || (Logging.Level = {}));
|
|
19
|
-
class Channel {
|
|
20
|
-
channel;
|
|
21
|
-
constructor(channel) {
|
|
22
|
-
this.channel = channel;
|
|
23
|
-
}
|
|
24
|
-
Error(...args) {
|
|
25
|
-
Write(Level.ERROR, this.channel, ...args);
|
|
26
|
-
}
|
|
27
|
-
Warn(...args) {
|
|
28
|
-
Write(Level.WARN, this.channel, ...args);
|
|
29
|
-
}
|
|
30
|
-
Info(...args) {
|
|
31
|
-
Write(Level.INFO, this.channel, ...args);
|
|
32
|
-
}
|
|
33
|
-
Debug(...args) {
|
|
34
|
-
Write(Level.DEBUG, this.channel, ...args);
|
|
35
|
-
}
|
|
36
|
-
Trace(...args) {
|
|
37
|
-
Write(Level.TRACE, this.channel, ...args);
|
|
38
|
-
}
|
|
39
|
-
Write(levelId, ...args) {
|
|
40
|
-
Write(levelId, this.channel, ...args);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
Logging.Channel = Channel;
|
|
44
|
-
const MainChannel = new Channel('main');
|
|
45
|
-
Logging.Error = MainChannel.Error.bind(MainChannel);
|
|
46
|
-
Logging.Warn = MainChannel.Warn.bind(MainChannel);
|
|
47
|
-
Logging.Info = MainChannel.Info.bind(MainChannel);
|
|
48
|
-
Logging.Debug = MainChannel.Debug.bind(MainChannel);
|
|
49
|
-
Logging.Trace = MainChannel.Trace.bind(MainChannel);
|
|
50
|
-
function Write(levelId, channel, ...args) {
|
|
51
|
-
listener_1.default.emit({
|
|
52
|
-
time: Date.now(),
|
|
53
|
-
channel,
|
|
54
|
-
levelId,
|
|
55
|
-
args,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
Logging.Write = Write;
|
|
59
|
-
})(Logging || (exports.Logging = Logging = {}));
|
|
60
|
-
exports.default = Logging;
|
|
61
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interfaces/logging/beta/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AASlC,IAAiB,OAAO,CAuKvB;AAvKD,WAAiB,OAAO;IAKtB,IAAY,KAaX;IAbD,WAAY,KAAK;QAEf,oCAAU,CAAA;QAEV,kCAAS,CAAA;QAET,kCAAS,CAAA;QAET,oCAAU,CAAA;QAEV,mCAAS,CAAA;QAET,4CAAc,CAAA;IAChB,CAAC,EAbW,KAAK,GAAL,aAAK,KAAL,aAAK,QAahB;IAED,MAAa,OAAO;QACF,OAAO,CAAS;QAEhC,YAAmB,OAAe;YAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC;QASM,KAAK,CAAC,GAAG,IAAW;YACzB,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;QAUM,IAAI,CAAC,GAAG,IAAW;YACxB,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3C,CAAC;QAUM,IAAI,CAAC,GAAG,IAAW;YACxB,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC3C,CAAC;QASM,KAAK,CAAC,GAAG,IAAW;YACzB,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;QAUM,KAAK,CAAC,GAAG,IAAW;YACzB,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;QAWM,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;YAC1C,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACxC,CAAC;KACF;IA7EY,eAAO,UA6EnB,CAAA;IAED,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAS3B,aAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAU5C,YAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAU1C,YAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAS1C,aAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAU5C,aAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAYzD,SAAgB,KAAK,CAAC,OAAe,EAAE,OAAe,EAAE,GAAG,IAAW;QACpE,kBAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;YAChB,OAAO;YACP,OAAO;YACP,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAPe,aAAK,QAOpB,CAAA;AACH,CAAC,EAvKgB,OAAO,uBAAP,OAAO,QAuKvB;AACD,kBAAe,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../../../src/interfaces/logging/beta/listener.ts"],"names":[],"mappings":";;AAAA,0CAA6C;AA6B7C,kBAAe,IAAI,iBAAU,EAAsB,CAAC"}
|
package/dist/loader/index.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Module } from './module';
|
|
2
|
-
import { ModuleSource } from '../common/downloader';
|
|
3
|
-
import '../common/downloader/local';
|
|
4
|
-
import '../common/downloader/package';
|
|
5
|
-
import '../common/downloader/git';
|
|
6
|
-
type LoadedModule = {
|
|
7
|
-
ref: Module;
|
|
8
|
-
config: LegacyModuleConfig;
|
|
9
|
-
};
|
|
10
|
-
interface InterfaceConnection {
|
|
11
|
-
id?: string;
|
|
12
|
-
module: string;
|
|
13
|
-
}
|
|
14
|
-
export interface LegacyModuleList {
|
|
15
|
-
sources: (ModuleSource & {
|
|
16
|
-
id: string;
|
|
17
|
-
})[];
|
|
18
|
-
configs: Record<string, LegacyModuleConfig>;
|
|
19
|
-
}
|
|
20
|
-
export interface LegacyModuleConfig {
|
|
21
|
-
importOverrides: Map<string, InterfaceConnection[]>;
|
|
22
|
-
disabledExports: Set<string>;
|
|
23
|
-
config: any;
|
|
24
|
-
}
|
|
25
|
-
export declare class ModuleManager {
|
|
26
|
-
private projectFolder;
|
|
27
|
-
private cache;
|
|
28
|
-
private interfaceSources;
|
|
29
|
-
readonly loadedModules: Map<string, LoadedModule>;
|
|
30
|
-
private resolverDetour;
|
|
31
|
-
private core;
|
|
32
|
-
private concurrency;
|
|
33
|
-
constructor(projectFolder: string, antelopeFolder: string, cacheFolder: string, concurrency?: number);
|
|
34
|
-
private updateConnectionList;
|
|
35
|
-
private createAssociations;
|
|
36
|
-
private rebuildInterfaceSources;
|
|
37
|
-
private rebuildModuleAssociations;
|
|
38
|
-
init(manifest: LegacyModuleList): Promise<void>;
|
|
39
|
-
startModules(): void;
|
|
40
|
-
shutdown(): Promise<void>;
|
|
41
|
-
unrequireModuleFiles(module: LoadedModule): void;
|
|
42
|
-
reloadModule(id: string, config?: LegacyModuleConfig): Promise<void>;
|
|
43
|
-
startWatcher(): Promise<void>;
|
|
44
|
-
}
|
|
45
|
-
export {};
|
package/dist/loader/index.js
DELETED
|
@@ -1,490 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ModuleManager = void 0;
|
|
40
|
-
const cache_1 = require("../common/cache");
|
|
41
|
-
const module_1 = require("./module");
|
|
42
|
-
const coreInterfaceBeta = __importStar(require("../interfaces/core/beta"));
|
|
43
|
-
const moduleInterfaceBeta = __importStar(require("../interfaces/core/beta/modules"));
|
|
44
|
-
const downloader_1 = __importDefault(require("../common/downloader"));
|
|
45
|
-
require("../common/downloader/local");
|
|
46
|
-
require("../common/downloader/package");
|
|
47
|
-
require("../common/downloader/git");
|
|
48
|
-
const path_1 = __importDefault(require("path"));
|
|
49
|
-
const promises_1 = require("fs/promises");
|
|
50
|
-
const fs_1 = require("fs");
|
|
51
|
-
const crypto_1 = require("crypto");
|
|
52
|
-
const assert_1 = __importDefault(require("assert"));
|
|
53
|
-
const manifest_1 = require("../common/manifest");
|
|
54
|
-
const beta_1 = require("../interfaces/logging/beta");
|
|
55
|
-
const events_1 = __importDefault(require("events"));
|
|
56
|
-
const terminal_display_1 = require("../logging/terminal-display");
|
|
57
|
-
const Logger = new beta_1.Logging.Channel('loader');
|
|
58
|
-
class ModuleResolverDetour {
|
|
59
|
-
modulesRef;
|
|
60
|
-
oldResolver;
|
|
61
|
-
_M;
|
|
62
|
-
moduleByFolder = new Map();
|
|
63
|
-
moduleAssociations = new Map();
|
|
64
|
-
constructor(modulesRef) {
|
|
65
|
-
this.modulesRef = modulesRef;
|
|
66
|
-
this._M = module.constructor.length > 1 ? module.constructor : require('module');
|
|
67
|
-
}
|
|
68
|
-
attach() {
|
|
69
|
-
if (!this.oldResolver) {
|
|
70
|
-
this.oldResolver = this._M._resolveFilename;
|
|
71
|
-
this._M._resolveFilename = (request, parent, isMain, options) => {
|
|
72
|
-
const newRequest = this.resolve(request, parent) ?? request;
|
|
73
|
-
return this.oldResolver(newRequest, parent, isMain, options);
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
detach() {
|
|
78
|
-
this._M._resolveFilename = this.oldResolver;
|
|
79
|
-
this.oldResolver = undefined;
|
|
80
|
-
}
|
|
81
|
-
static exists(path) {
|
|
82
|
-
try {
|
|
83
|
-
(0, fs_1.accessSync)(path, fs_1.constants.R_OK);
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
resolve(request, parent) {
|
|
91
|
-
let matchingFolder = '';
|
|
92
|
-
let matchingLength = 0;
|
|
93
|
-
if (parent && parent.filename) {
|
|
94
|
-
for (const folder of this.moduleByFolder.keys()) {
|
|
95
|
-
if (parent.filename.startsWith(folder) && matchingLength < folder.length) {
|
|
96
|
-
matchingFolder = folder;
|
|
97
|
-
matchingLength = folder.length;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (matchingLength > 0) {
|
|
102
|
-
const module = this.moduleByFolder.get(matchingFolder);
|
|
103
|
-
if (request.startsWith('@ajs.local/')) {
|
|
104
|
-
return path_1.default.join(module.manifest.exportsPath, request.substring(11));
|
|
105
|
-
}
|
|
106
|
-
else if (request.startsWith('@ajs/')) {
|
|
107
|
-
const ifMatch = request.match(/^@ajs\/([^\/]+)\/([^\/]+)/);
|
|
108
|
-
if (ifMatch) {
|
|
109
|
-
const [, name, version] = ifMatch;
|
|
110
|
-
const target = this.moduleAssociations.get(module.id).get(`${name}@${version}`);
|
|
111
|
-
(0, assert_1.default)(target, `Module ${module.id} tried to use un-imported interface ${name}@${version}`);
|
|
112
|
-
return path_1.default.join(target.manifest.exportsPath, request.substring(5));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else if (module.manifest.srcAliases) {
|
|
116
|
-
for (const { alias, replace } of module.manifest.srcAliases) {
|
|
117
|
-
if (request.startsWith(alias)) {
|
|
118
|
-
return request.length > alias.length ? path_1.default.join(replace, request.substring(alias.length)) : replace;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
for (const entry of module.manifest.paths) {
|
|
124
|
-
if (request.startsWith(entry.key)) {
|
|
125
|
-
const part = request.substring(entry.key.length);
|
|
126
|
-
for (const testPathPart of entry.values) {
|
|
127
|
-
const testPath = path_1.default.join(testPathPart, part);
|
|
128
|
-
if (ModuleResolverDetour.exists(testPath + '.js') ||
|
|
129
|
-
ModuleResolverDetour.exists(testPath + '/index.js')) {
|
|
130
|
-
return testPath;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (request.startsWith('@ajs.raw/')) {
|
|
138
|
-
const ifMatch = request.match(/^@ajs.raw\/([^\/]+)\/([^@]+)@([^\/]+)(.*)/);
|
|
139
|
-
if (ifMatch) {
|
|
140
|
-
const [, id, name, version, file] = ifMatch;
|
|
141
|
-
const target = this.modulesRef.get(id).ref;
|
|
142
|
-
return path_1.default.join(target.manifest.exportsPath, name, version, file);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
class ModuleManager {
|
|
148
|
-
projectFolder;
|
|
149
|
-
cache;
|
|
150
|
-
interfaceSources = new Map();
|
|
151
|
-
loadedModules = new Map();
|
|
152
|
-
resolverDetour = new ModuleResolverDetour(this.loadedModules);
|
|
153
|
-
core;
|
|
154
|
-
concurrency;
|
|
155
|
-
constructor(projectFolder, antelopeFolder, cacheFolder, concurrency = events_1.default.defaultMaxListeners) {
|
|
156
|
-
this.projectFolder = projectFolder;
|
|
157
|
-
this.cache = new cache_1.ModuleCache(cacheFolder);
|
|
158
|
-
this.core = {
|
|
159
|
-
ref: new module_1.Module(new manifest_1.ModuleManifest(antelopeFolder, { id: 'antelopejs', type: 'none' }, 'antelopejs')),
|
|
160
|
-
config: { disabledExports: new Set(), importOverrides: new Map(), config: undefined },
|
|
161
|
-
};
|
|
162
|
-
this.loadedModules.set('antelopejs', this.core);
|
|
163
|
-
this.concurrency = concurrency;
|
|
164
|
-
}
|
|
165
|
-
updateConnectionList(ref, connections) {
|
|
166
|
-
const connectionIDs = {};
|
|
167
|
-
for (const [interfaceName, modules] of connections) {
|
|
168
|
-
connectionIDs[interfaceName] = modules.map(({ id, module }) => ({
|
|
169
|
-
path: `@ajs.raw/${module}/${interfaceName}`,
|
|
170
|
-
id,
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
coreInterfaceBeta.internal.interfaceConnections[ref.id] = connectionIDs;
|
|
174
|
-
}
|
|
175
|
-
createAssociations(ref, config) {
|
|
176
|
-
const associations = new Map();
|
|
177
|
-
const connections = new Map();
|
|
178
|
-
for (const iface of ref.manifest.imports) {
|
|
179
|
-
if (this.interfaceSources.has(iface)) {
|
|
180
|
-
associations.set(iface, this.interfaceSources.get(iface).ref);
|
|
181
|
-
connections.set(iface, [{ module: this.interfaceSources.get(iface).ref.id }]);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (config.importOverrides) {
|
|
185
|
-
for (const [iface, overrides] of config.importOverrides) {
|
|
186
|
-
const useable = overrides.filter(({ module }) => this.loadedModules.has(module));
|
|
187
|
-
connections.set(iface, useable);
|
|
188
|
-
if (useable.length > 0) {
|
|
189
|
-
associations.set(iface, this.loadedModules.get(useable[0].module).ref);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
this.updateConnectionList(ref, connections);
|
|
194
|
-
return associations;
|
|
195
|
-
}
|
|
196
|
-
rebuildInterfaceSources(moduleList) {
|
|
197
|
-
this.resolverDetour.moduleByFolder.clear();
|
|
198
|
-
coreInterfaceBeta.internal.moduleByFolder.splice(0, coreInterfaceBeta.internal.moduleByFolder.length);
|
|
199
|
-
this.interfaceSources.clear();
|
|
200
|
-
for (const module of moduleList) {
|
|
201
|
-
const { ref, config } = module;
|
|
202
|
-
this.resolverDetour.moduleByFolder.set(ref.manifest.folder, ref);
|
|
203
|
-
coreInterfaceBeta.internal.moduleByFolder.push({
|
|
204
|
-
dir: ref.manifest.folder,
|
|
205
|
-
id: ref.id,
|
|
206
|
-
interfaceDir: ref.manifest.exportsPath,
|
|
207
|
-
});
|
|
208
|
-
for (const [nameVersion] of Object.entries(ref.manifest.exports)) {
|
|
209
|
-
if (!config.disabledExports?.has(nameVersion)) {
|
|
210
|
-
this.interfaceSources.set(nameVersion, module);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
for (const [nameVersion] of Object.entries(this.core.ref.manifest.exports)) {
|
|
215
|
-
this.interfaceSources.set(nameVersion, this.core);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
rebuildModuleAssociations(moduleList) {
|
|
219
|
-
this.resolverDetour.moduleAssociations.clear();
|
|
220
|
-
for (const { ref: info, config } of moduleList) {
|
|
221
|
-
this.resolverDetour.moduleAssociations.set(info.id, this.createAssociations(info, config));
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
async init(manifest) {
|
|
225
|
-
await this.cache.load();
|
|
226
|
-
coreInterfaceBeta.ImplementInterface(moduleInterfaceBeta, {
|
|
227
|
-
ListModules: async () => [...this.loadedModules.keys()],
|
|
228
|
-
GetModuleInfo: async (module) => {
|
|
229
|
-
const loaded = this.loadedModules.get(module);
|
|
230
|
-
(0, assert_1.default)(loaded);
|
|
231
|
-
const importOverrides = {};
|
|
232
|
-
for (const [intf, connections] of loaded.config.importOverrides.entries()) {
|
|
233
|
-
importOverrides[intf] = connections.map((c) => c.module);
|
|
234
|
-
}
|
|
235
|
-
return {
|
|
236
|
-
source: loaded.ref.manifest.source,
|
|
237
|
-
config: loaded.config.config,
|
|
238
|
-
disabledExports: [...loaded.config.disabledExports],
|
|
239
|
-
importOverrides,
|
|
240
|
-
localPath: loaded.ref.manifest.folder,
|
|
241
|
-
status: loaded.ref.stateStr,
|
|
242
|
-
};
|
|
243
|
-
},
|
|
244
|
-
LoadModule: async (moduleId, declaration, autostart = false) => {
|
|
245
|
-
const moduleManifests = await (0, downloader_1.default)(this.projectFolder, this.cache, {
|
|
246
|
-
...declaration.source,
|
|
247
|
-
id: moduleId,
|
|
248
|
-
});
|
|
249
|
-
manifest.configs[moduleId] = {
|
|
250
|
-
config: declaration.config,
|
|
251
|
-
disabledExports: new Set(declaration.disabledExports),
|
|
252
|
-
importOverrides: new Map(Object.entries(declaration.importOverrides || {}).map(([key, vals]) => {
|
|
253
|
-
return [key, vals.map((module) => ({ module }))];
|
|
254
|
-
})),
|
|
255
|
-
};
|
|
256
|
-
const modules = moduleManifests.map((moduleManifest) => {
|
|
257
|
-
const module = new module_1.Module(moduleManifest);
|
|
258
|
-
manifest.configs[module.id] = manifest.configs[moduleId];
|
|
259
|
-
const entry = { ref: module, config: manifest.configs[module.id] || {} };
|
|
260
|
-
entry.ref.manifest.loadExports();
|
|
261
|
-
this.loadedModules.set(entry.ref.id, entry);
|
|
262
|
-
return entry;
|
|
263
|
-
});
|
|
264
|
-
this.rebuildInterfaceSources([...this.loadedModules.values()]);
|
|
265
|
-
for (const entry of modules) {
|
|
266
|
-
this.resolverDetour.moduleAssociations.set(module.id, this.createAssociations(entry.ref, entry.config));
|
|
267
|
-
}
|
|
268
|
-
for (const entry of modules) {
|
|
269
|
-
await entry.ref.construct(entry.config);
|
|
270
|
-
}
|
|
271
|
-
if (autostart) {
|
|
272
|
-
for (const entry of modules) {
|
|
273
|
-
entry.ref.start();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return modules.map((entry) => entry.ref.id);
|
|
277
|
-
},
|
|
278
|
-
StartModule: async (moduleId) => {
|
|
279
|
-
this.loadedModules.get(moduleId)?.ref.start();
|
|
280
|
-
},
|
|
281
|
-
StopModule: async (moduleId) => {
|
|
282
|
-
this.loadedModules.get(moduleId)?.ref.stop();
|
|
283
|
-
},
|
|
284
|
-
DestroyModule: async (moduleId) => {
|
|
285
|
-
await this.loadedModules.get(moduleId)?.ref.destroy();
|
|
286
|
-
},
|
|
287
|
-
ReloadModule: async (moduleId) => {
|
|
288
|
-
await this.reloadModule(moduleId);
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
events_1.default.defaultMaxListeners = this.concurrency;
|
|
292
|
-
await terminal_display_1.terminalDisplay.startSpinner(`Loading modules`);
|
|
293
|
-
const modulePromises = manifest.sources.map(async (source) => {
|
|
294
|
-
Logger.Debug(`Loading module ${source.id}`);
|
|
295
|
-
try {
|
|
296
|
-
Logger.Trace(`Starting LoadModule for ${source.id}`);
|
|
297
|
-
const createdModules = await (0, downloader_1.default)(this.projectFolder, this.cache, source)
|
|
298
|
-
.then((modulesManifest) => {
|
|
299
|
-
Logger.Trace(`Module manifest loaded for ${source.id}`);
|
|
300
|
-
return modulesManifest.map((moduleManifest) => new module_1.Module(moduleManifest));
|
|
301
|
-
})
|
|
302
|
-
.then((modules) => {
|
|
303
|
-
Logger.Trace(`Modules created for ${source.id}`);
|
|
304
|
-
for (const module of modules) {
|
|
305
|
-
manifest.configs[module.id] = manifest.configs[source.id];
|
|
306
|
-
}
|
|
307
|
-
return modules;
|
|
308
|
-
})
|
|
309
|
-
.catch(async (err) => {
|
|
310
|
-
await terminal_display_1.terminalDisplay.failSpinner(`Failed to load module ${source.id}`);
|
|
311
|
-
await terminal_display_1.terminalDisplay.cleanSpinner();
|
|
312
|
-
Logger.Error(err);
|
|
313
|
-
process.exit(1);
|
|
314
|
-
});
|
|
315
|
-
return createdModules.map((ref) => ({ ref, config: manifest.configs[ref.id] || {} }));
|
|
316
|
-
}
|
|
317
|
-
catch (err) {
|
|
318
|
-
Logger.Error(`Unexpected error while loading module ${source.id}:`);
|
|
319
|
-
Logger.Error(err);
|
|
320
|
-
throw err;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
const moduleResults = await Promise.all(modulePromises);
|
|
324
|
-
const moduleList = moduleResults.flat();
|
|
325
|
-
await terminal_display_1.terminalDisplay.stopSpinner(`Modules loaded`);
|
|
326
|
-
await terminal_display_1.terminalDisplay.startSpinner(`Loading exports`);
|
|
327
|
-
Logger.Trace(`Loading exports`);
|
|
328
|
-
await this.core.ref.manifest.loadExports();
|
|
329
|
-
await Promise.all(moduleList.map((module) => module.ref.manifest.loadExports()));
|
|
330
|
-
moduleList.reduce((map, entry) => {
|
|
331
|
-
if (map.has(entry.ref.id)) {
|
|
332
|
-
Logger.Error(`Detected module id collision (name in package.json): ${entry.ref.id}`);
|
|
333
|
-
}
|
|
334
|
-
return map.set(entry.ref.id, entry);
|
|
335
|
-
}, this.loadedModules);
|
|
336
|
-
await terminal_display_1.terminalDisplay.stopSpinner(`Exports loaded`);
|
|
337
|
-
events_1.default.defaultMaxListeners = 10;
|
|
338
|
-
this.rebuildInterfaceSources(moduleList);
|
|
339
|
-
this.rebuildModuleAssociations(moduleList);
|
|
340
|
-
await terminal_display_1.terminalDisplay.startSpinner(`Constructing modules`);
|
|
341
|
-
Logger.Trace(`Constructing modules`);
|
|
342
|
-
this.resolverDetour.attach();
|
|
343
|
-
await Promise.all(moduleList.map(({ ref, config }) => ref.construct(config.config).catch((err) => {
|
|
344
|
-
Logger.Error(`Failed to construct module:`);
|
|
345
|
-
Logger.Error(` - ID: ${ref.id}`);
|
|
346
|
-
Logger.Error(` - Version: ${ref.version}`);
|
|
347
|
-
Logger.Error(` - Error: ${err.message}`);
|
|
348
|
-
throw err;
|
|
349
|
-
})));
|
|
350
|
-
await terminal_display_1.terminalDisplay.stopSpinner(`Done loading`);
|
|
351
|
-
}
|
|
352
|
-
startModules() {
|
|
353
|
-
for (const module of this.loadedModules.values()) {
|
|
354
|
-
module.ref.start();
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
async shutdown() {
|
|
358
|
-
await Promise.all([...this.loadedModules.values()].map(({ ref }) => ref.destroy()));
|
|
359
|
-
this.resolverDetour.detach();
|
|
360
|
-
this.resolverDetour.moduleAssociations.clear();
|
|
361
|
-
this.resolverDetour.moduleByFolder.clear();
|
|
362
|
-
this.loadedModules.clear();
|
|
363
|
-
this.interfaceSources.clear();
|
|
364
|
-
}
|
|
365
|
-
unrequireModuleFiles(module) {
|
|
366
|
-
const moduleFolder = module.ref.manifest.folder;
|
|
367
|
-
const avoidedFolders = [module.ref.manifest.exportsPath];
|
|
368
|
-
for (const otherModule of this.loadedModules.values()) {
|
|
369
|
-
if (otherModule !== module && otherModule.ref.manifest.folder.startsWith(moduleFolder)) {
|
|
370
|
-
avoidedFolders.push(otherModule.ref.manifest.folder);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
for (const filePath of Object.keys(require.cache)) {
|
|
374
|
-
if (filePath.startsWith(moduleFolder)) {
|
|
375
|
-
let deleteCache = true;
|
|
376
|
-
for (const folder of avoidedFolders) {
|
|
377
|
-
if (filePath.startsWith(folder)) {
|
|
378
|
-
deleteCache = false;
|
|
379
|
-
break;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
if (deleteCache) {
|
|
383
|
-
delete require.cache[filePath];
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
async reloadModule(id, config) {
|
|
389
|
-
const module = this.loadedModules.get(id);
|
|
390
|
-
if (!module) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
await module.ref.destroy();
|
|
394
|
-
this.unrequireModuleFiles(module);
|
|
395
|
-
module.ref = new module_1.Module((await (0, downloader_1.default)(this.projectFolder, this.cache, module.ref.manifest.source))[0]);
|
|
396
|
-
if (config) {
|
|
397
|
-
module.config = config;
|
|
398
|
-
this.rebuildInterfaceSources([...this.loadedModules.values()]);
|
|
399
|
-
this.resolverDetour.moduleAssociations.set(id, this.createAssociations(module.ref, module.config));
|
|
400
|
-
}
|
|
401
|
-
await module.ref.construct(module.config.config);
|
|
402
|
-
module.ref.start();
|
|
403
|
-
}
|
|
404
|
-
async startWatcher() {
|
|
405
|
-
async function getFileHash(path) {
|
|
406
|
-
return (0, crypto_1.createHash)('sha256')
|
|
407
|
-
.update(await (0, promises_1.readFile)(path))
|
|
408
|
-
.digest('hex');
|
|
409
|
-
}
|
|
410
|
-
const filesHash = new Map();
|
|
411
|
-
const watchedDirs = [];
|
|
412
|
-
const excludedDirs = new Set(['.git', 'node_modules']);
|
|
413
|
-
async function exploreDir(id, dirPath) {
|
|
414
|
-
watchedDirs.push(dirPath);
|
|
415
|
-
const files = await (0, promises_1.readdir)(dirPath);
|
|
416
|
-
for (const file of files) {
|
|
417
|
-
const filePath = path_1.default.join(dirPath, file);
|
|
418
|
-
if ((await (0, promises_1.stat)(filePath)).isDirectory()) {
|
|
419
|
-
if (excludedDirs.has(file)) {
|
|
420
|
-
continue;
|
|
421
|
-
}
|
|
422
|
-
await exploreDir(id, filePath);
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
filesHash.set(filePath, [id, await getFileHash(filePath)]);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
let timer;
|
|
430
|
-
const toRefresh = new Set();
|
|
431
|
-
const fileChange = async (filePath) => {
|
|
432
|
-
try {
|
|
433
|
-
(0, fs_1.accessSync)(filePath);
|
|
434
|
-
}
|
|
435
|
-
catch {
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
if ((await (0, promises_1.stat)(filePath)).isDirectory())
|
|
439
|
-
return;
|
|
440
|
-
const newHash = await getFileHash(filePath);
|
|
441
|
-
const [module, prevHash] = filesHash.get(filePath);
|
|
442
|
-
if (newHash === prevHash)
|
|
443
|
-
return;
|
|
444
|
-
filesHash.set(filePath, [module, newHash]);
|
|
445
|
-
if (!timer) {
|
|
446
|
-
timer = setTimeout(async () => {
|
|
447
|
-
if (toRefresh.size === 0)
|
|
448
|
-
return;
|
|
449
|
-
try {
|
|
450
|
-
for (const id of toRefresh) {
|
|
451
|
-
await this.reloadModule(id);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
catch (err) {
|
|
455
|
-
Logger.Error(err);
|
|
456
|
-
}
|
|
457
|
-
timer = undefined;
|
|
458
|
-
toRefresh.clear();
|
|
459
|
-
}, 500);
|
|
460
|
-
}
|
|
461
|
-
toRefresh.add(module);
|
|
462
|
-
};
|
|
463
|
-
for (const module of this.loadedModules.values()) {
|
|
464
|
-
if (module.ref.manifest.source.type === 'local') {
|
|
465
|
-
const source = module.ref.manifest.source;
|
|
466
|
-
let watchDirs = [''];
|
|
467
|
-
if (source.watchDir) {
|
|
468
|
-
if (Array.isArray(source.watchDir)) {
|
|
469
|
-
watchDirs = source.watchDir;
|
|
470
|
-
}
|
|
471
|
-
else {
|
|
472
|
-
watchDirs = [source.watchDir];
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
for (const dir of watchDirs) {
|
|
476
|
-
const filePath = path_1.default.join(module.ref.manifest.folder, dir);
|
|
477
|
-
await exploreDir(module.ref.id, filePath);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
for (const filePath of watchedDirs) {
|
|
482
|
-
(0, fs_1.watch)(filePath, (eventType, filename) => {
|
|
483
|
-
if (eventType === 'change' && filename)
|
|
484
|
-
fileChange(path_1.default.join(filePath, filename)).catch((err) => Logger.Error(err));
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
exports.ModuleManager = ModuleManager;
|
|
490
|
-
//# sourceMappingURL=index.js.map
|