tunli 0.0.27 → 0.2.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/CHANGELOG.md +45 -0
- package/README.md +158 -67
- package/bin/tunli +4 -5
- package/dist/api-client/ApiClient.d.ts +18 -0
- package/dist/api-client/ApiClient.d.ts.map +1 -0
- package/dist/api-client/ApiClient.js +100 -0
- package/dist/api-client/ApiClient.js.map +1 -0
- package/dist/api-client/types.d.ts +26 -0
- package/dist/api-client/types.d.ts.map +1 -0
- package/dist/api-client/types.js +2 -0
- package/dist/api-client/types.js.map +1 -0
- package/dist/api-client/utils.d.ts +4 -0
- package/dist/api-client/utils.d.ts.map +1 -0
- package/dist/api-client/utils.js +13 -0
- package/dist/api-client/utils.js.map +1 -0
- package/dist/cli-app/AppEventEmitter.d.ts +57 -0
- package/dist/cli-app/AppEventEmitter.d.ts.map +1 -0
- package/dist/cli-app/AppEventEmitter.js +11 -0
- package/dist/cli-app/AppEventEmitter.js.map +1 -0
- package/dist/cli-app/Dashboard.d.ts +4 -0
- package/dist/cli-app/Dashboard.d.ts.map +1 -0
- package/dist/cli-app/Dashboard.js +241 -0
- package/dist/cli-app/Dashboard.js.map +1 -0
- package/dist/cli-app/LiveLog.d.ts +4 -0
- package/dist/cli-app/LiveLog.d.ts.map +1 -0
- package/dist/cli-app/LiveLog.js +28 -0
- package/dist/cli-app/LiveLog.js.map +1 -0
- package/dist/cli-app/types.d.ts +10 -0
- package/dist/cli-app/types.d.ts.map +1 -0
- package/dist/cli-app/types.js +2 -0
- package/dist/cli-app/types.js.map +1 -0
- package/dist/cli-app/versionCheck.d.ts +4 -0
- package/dist/cli-app/versionCheck.d.ts.map +1 -0
- package/dist/cli-app/versionCheck.js +46 -0
- package/dist/cli-app/versionCheck.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/commander/Argument.d.ts +19 -0
- package/dist/commander/Argument.d.ts.map +1 -0
- package/dist/commander/Argument.js +25 -0
- package/dist/commander/Argument.js.map +1 -0
- package/dist/commander/Command.d.ts +23 -0
- package/dist/commander/Command.d.ts.map +1 -0
- package/dist/commander/Command.js +159 -0
- package/dist/commander/Command.js.map +1 -0
- package/dist/commander/InvalidArgumentError.d.ts +5 -0
- package/dist/commander/InvalidArgumentError.d.ts.map +1 -0
- package/dist/commander/InvalidArgumentError.js +8 -0
- package/dist/commander/InvalidArgumentError.js.map +1 -0
- package/dist/commander/Option.d.ts +15 -0
- package/dist/commander/Option.d.ts.map +1 -0
- package/dist/commander/Option.js +43 -0
- package/dist/commander/Option.js.map +1 -0
- package/dist/commander/index.d.ts +7 -0
- package/dist/commander/index.d.ts.map +1 -0
- package/dist/commander/index.js +5 -0
- package/dist/commander/index.js.map +1 -0
- package/dist/commander/types.d.ts +2 -0
- package/dist/commander/types.d.ts.map +1 -0
- package/dist/commander/types.js +2 -0
- package/dist/commander/types.js.map +1 -0
- package/dist/commands/CommandAuth/CommandAuth.d.ts +4 -0
- package/dist/commands/CommandAuth/CommandAuth.d.ts.map +1 -0
- package/dist/commands/CommandAuth/CommandAuth.js +24 -0
- package/dist/commands/CommandAuth/CommandAuth.js.map +1 -0
- package/dist/commands/CommandConfig/CommandConfig.d.ts +4 -0
- package/dist/commands/CommandConfig/CommandConfig.d.ts.map +1 -0
- package/dist/commands/CommandConfig/CommandConfig.js +37 -0
- package/dist/commands/CommandConfig/CommandConfig.js.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.d.ts +4 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.d.ts.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.js +20 -0
- package/dist/commands/CommandConfig/sub-commands/configDeleteCommand.js.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.d.ts +5 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.d.ts.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.js +23 -0
- package/dist/commands/CommandConfig/sub-commands/configGetCommand.js.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.d.ts +4 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.d.ts.map +1 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.js +69 -0
- package/dist/commands/CommandConfig/sub-commands/configSetCommand.js.map +1 -0
- package/dist/commands/CommandConfig/types.d.ts +6 -0
- package/dist/commands/CommandConfig/types.d.ts.map +1 -0
- package/dist/commands/CommandConfig/types.js +2 -0
- package/dist/commands/CommandConfig/types.js.map +1 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.d.ts +3 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.d.ts.map +1 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.js +8 -0
- package/dist/commands/CommandConfig/utils/preparePrimaryOptions.js.map +1 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.d.ts +8 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.d.ts.map +1 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.js +33 -0
- package/dist/commands/CommandConfig/utils/resolveConfig.js.map +1 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.d.ts +3 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.d.ts.map +1 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.js +14 -0
- package/dist/commands/CommandConfig/utils/sharedOptions.js.map +1 -0
- package/dist/commands/CommandDaemon/CommandDaemon.d.ts +4 -0
- package/dist/commands/CommandDaemon/CommandDaemon.d.ts.map +1 -0
- package/dist/commands/CommandDaemon/CommandDaemon.js +57 -0
- package/dist/commands/CommandDaemon/CommandDaemon.js.map +1 -0
- package/dist/commands/CommandDashboard/CommandDashboard.d.ts +4 -0
- package/dist/commands/CommandDashboard/CommandDashboard.d.ts.map +1 -0
- package/dist/commands/CommandDashboard/CommandDashboard.js +54 -0
- package/dist/commands/CommandDashboard/CommandDashboard.js.map +1 -0
- package/dist/commands/CommandHTTP/CommandHttp.d.ts +4 -0
- package/dist/commands/CommandHTTP/CommandHttp.d.ts.map +1 -0
- package/dist/commands/CommandHTTP/CommandHttp.js +50 -0
- package/dist/commands/CommandHTTP/CommandHttp.js.map +1 -0
- package/dist/commands/CommandInit/CommandInit.d.ts +4 -0
- package/dist/commands/CommandInit/CommandInit.d.ts.map +1 -0
- package/dist/commands/CommandInit/CommandInit.js +36 -0
- package/dist/commands/CommandInit/CommandInit.js.map +1 -0
- package/dist/commands/CommandList/CommandList.d.ts +4 -0
- package/dist/commands/CommandList/CommandList.d.ts.map +1 -0
- package/dist/commands/CommandList/CommandList.js +54 -0
- package/dist/commands/CommandList/CommandList.js.map +1 -0
- package/dist/commands/CommandLogs/CommandLogs.d.ts +4 -0
- package/dist/commands/CommandLogs/CommandLogs.d.ts.map +1 -0
- package/dist/commands/CommandLogs/CommandLogs.js +33 -0
- package/dist/commands/CommandLogs/CommandLogs.js.map +1 -0
- package/dist/commands/CommandProfile/CommandProfile.d.ts +5 -0
- package/dist/commands/CommandProfile/CommandProfile.d.ts.map +1 -0
- package/dist/commands/CommandProfile/CommandProfile.js +64 -0
- package/dist/commands/CommandProfile/CommandProfile.js.map +1 -0
- package/dist/commands/CommandRegister/CommandRegister.d.ts +4 -0
- package/dist/commands/CommandRegister/CommandRegister.d.ts.map +1 -0
- package/dist/commands/CommandRegister/CommandRegister.js +43 -0
- package/dist/commands/CommandRegister/CommandRegister.js.map +1 -0
- package/dist/commands/CommandRestart/CommandRestart.d.ts +4 -0
- package/dist/commands/CommandRestart/CommandRestart.d.ts.map +1 -0
- package/dist/commands/CommandRestart/CommandRestart.js +62 -0
- package/dist/commands/CommandRestart/CommandRestart.js.map +1 -0
- package/dist/commands/CommandServer/CommandServer.d.ts +4 -0
- package/dist/commands/CommandServer/CommandServer.d.ts.map +1 -0
- package/dist/commands/CommandServer/CommandServer.js +24 -0
- package/dist/commands/CommandServer/CommandServer.js.map +1 -0
- package/dist/commands/CommandStop/CommandStop.d.ts +4 -0
- package/dist/commands/CommandStop/CommandStop.d.ts.map +1 -0
- package/dist/commands/CommandStop/CommandStop.js +25 -0
- package/dist/commands/CommandStop/CommandStop.js.map +1 -0
- package/dist/commands/CommandUpdate/CommandUpdate.d.ts +4 -0
- package/dist/commands/CommandUpdate/CommandUpdate.d.ts.map +1 -0
- package/dist/commands/CommandUpdate/CommandUpdate.js +38 -0
- package/dist/commands/CommandUpdate/CommandUpdate.js.map +1 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.d.ts +4 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.d.ts.map +1 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.js +63 -0
- package/dist/commands/CommandUseProfile/CommandUseProfile.js.map +1 -0
- package/dist/commands/helper/Help.d.ts +4 -0
- package/dist/commands/helper/Help.d.ts.map +1 -0
- package/dist/commands/helper/Help.js +134 -0
- package/dist/commands/helper/Help.js.map +1 -0
- package/dist/commands/helper/Parser.d.ts +55 -0
- package/dist/commands/helper/Parser.d.ts.map +1 -0
- package/dist/commands/helper/Parser.js +280 -0
- package/dist/commands/helper/Parser.js.map +1 -0
- package/dist/commands/shared/allowDenyCidrCommand.d.ts +3 -0
- package/dist/commands/shared/allowDenyCidrCommand.d.ts.map +1 -0
- package/dist/commands/shared/allowDenyCidrCommand.js +10 -0
- package/dist/commands/shared/allowDenyCidrCommand.js.map +1 -0
- package/dist/commands/shared/configServersCommand.d.ts +4 -0
- package/dist/commands/shared/configServersCommand.d.ts.map +1 -0
- package/dist/commands/shared/configServersCommand.js +19 -0
- package/dist/commands/shared/configServersCommand.js.map +1 -0
- package/dist/commands/utils.d.ts +3 -0
- package/dist/commands/utils.d.ts.map +1 -0
- package/dist/commands/utils.js +17 -0
- package/dist/commands/utils.js.map +1 -0
- package/dist/config/ParsedConfig.d.ts +31 -0
- package/dist/config/ParsedConfig.d.ts.map +1 -0
- package/dist/config/ParsedConfig.js +116 -0
- package/dist/config/ParsedConfig.js.map +1 -0
- package/dist/config/ParsedGlobalConfig.d.ts +5 -0
- package/dist/config/ParsedGlobalConfig.d.ts.map +1 -0
- package/dist/config/ParsedGlobalConfig.js +7 -0
- package/dist/config/ParsedGlobalConfig.js.map +1 -0
- package/dist/config/ParsedLocalConfig.d.ts +5 -0
- package/dist/config/ParsedLocalConfig.d.ts.map +1 -0
- package/dist/config/ParsedLocalConfig.js +7 -0
- package/dist/config/ParsedLocalConfig.js.map +1 -0
- package/dist/config/ParsedProfileConfig.d.ts +46 -0
- package/dist/config/ParsedProfileConfig.d.ts.map +1 -0
- package/dist/config/ParsedProfileConfig.js +120 -0
- package/dist/config/ParsedProfileConfig.js.map +1 -0
- package/dist/config/ParsedServerConfig.d.ts +20 -0
- package/dist/config/ParsedServerConfig.d.ts.map +1 -0
- package/dist/config/ParsedServerConfig.js +55 -0
- package/dist/config/ParsedServerConfig.js.map +1 -0
- package/dist/config/TempProfileConfig.d.ts +8 -0
- package/dist/config/TempProfileConfig.d.ts.map +1 -0
- package/dist/config/TempProfileConfig.js +13 -0
- package/dist/config/TempProfileConfig.js.map +1 -0
- package/dist/config/utils.d.ts +2 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +8 -0
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validations/validateProfileConfig.d.ts +4 -0
- package/dist/config/validations/validateProfileConfig.d.ts.map +1 -0
- package/dist/config/validations/validateProfileConfig.js +76 -0
- package/dist/config/validations/validateProfileConfig.js.map +1 -0
- package/dist/core/FS/utils.d.ts +12 -0
- package/dist/core/FS/utils.d.ts.map +1 -0
- package/dist/core/FS/utils.js +55 -0
- package/dist/core/FS/utils.js.map +1 -0
- package/dist/daemon/DaemonClient.d.ts +16 -0
- package/dist/daemon/DaemonClient.d.ts.map +1 -0
- package/dist/daemon/DaemonClient.js +158 -0
- package/dist/daemon/DaemonClient.js.map +1 -0
- package/dist/daemon/DaemonServer.d.ts +8 -0
- package/dist/daemon/DaemonServer.d.ts.map +1 -0
- package/dist/daemon/DaemonServer.js +201 -0
- package/dist/daemon/DaemonServer.js.map +1 -0
- package/dist/daemon/protocol.d.ts +101 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +2 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon-main.d.ts +2 -0
- package/dist/daemon-main.d.ts.map +1 -0
- package/dist/daemon-main.js +13 -0
- package/dist/daemon-main.js.map +1 -0
- package/dist/launcher-main.d.ts +2 -0
- package/dist/launcher-main.d.ts.map +1 -0
- package/dist/launcher-main.js +57 -0
- package/dist/launcher-main.js.map +1 -0
- package/dist/lib/Flow/applyUpdate.d.ts +3 -0
- package/dist/lib/Flow/applyUpdate.d.ts.map +1 -0
- package/dist/lib/Flow/applyUpdate.js +34 -0
- package/dist/lib/Flow/applyUpdate.js.map +1 -0
- package/dist/lib/Flow/downloadBinaryUpdate.d.ts +3 -0
- package/dist/lib/Flow/downloadBinaryUpdate.d.ts.map +1 -0
- package/dist/lib/Flow/downloadBinaryUpdate.js +54 -0
- package/dist/lib/Flow/downloadBinaryUpdate.js.map +1 -0
- package/dist/lib/Flow/getLatestVersion.d.ts +2 -0
- package/dist/lib/Flow/getLatestVersion.d.ts.map +1 -0
- package/dist/lib/Flow/getLatestVersion.js +13 -0
- package/dist/lib/Flow/getLatestVersion.js.map +1 -0
- package/dist/lib/defs.d.ts +18 -0
- package/dist/lib/defs.d.ts.map +1 -0
- package/dist/lib/defs.js +33 -0
- package/dist/lib/defs.js.map +1 -0
- package/dist/logger/logger.d.ts +6 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +34 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/output-formats/colors.d.ts +7 -0
- package/dist/output-formats/colors.d.ts.map +1 -0
- package/dist/output-formats/colors.js +8 -0
- package/dist/output-formats/colors.js.map +1 -0
- package/dist/output-formats/formatConfig.d.ts +3 -0
- package/dist/output-formats/formatConfig.d.ts.map +1 -0
- package/dist/output-formats/formatConfig.js +59 -0
- package/dist/output-formats/formatConfig.js.map +1 -0
- package/dist/output-formats/formatConfigPath.d.ts +4 -0
- package/dist/output-formats/formatConfigPath.d.ts.map +1 -0
- package/dist/output-formats/formatConfigPath.js +7 -0
- package/dist/output-formats/formatConfigPath.js.map +1 -0
- package/dist/output-formats/formatPath.d.ts +2 -0
- package/dist/output-formats/formatPath.d.ts.map +1 -0
- package/dist/output-formats/formatPath.js +6 -0
- package/dist/output-formats/formatPath.js.map +1 -0
- package/dist/output-formats/formatProfile.d.ts +3 -0
- package/dist/output-formats/formatProfile.d.ts.map +1 -0
- package/dist/output-formats/formatProfile.js +35 -0
- package/dist/output-formats/formatProfile.js.map +1 -0
- package/dist/output-formats/formatProfilesShort.d.ts +3 -0
- package/dist/output-formats/formatProfilesShort.d.ts.map +1 -0
- package/dist/output-formats/formatProfilesShort.js +19 -0
- package/dist/output-formats/formatProfilesShort.js.map +1 -0
- package/dist/output-formats/formatSaveResult.d.ts +4 -0
- package/dist/output-formats/formatSaveResult.d.ts.map +1 -0
- package/dist/output-formats/formatSaveResult.js +7 -0
- package/dist/output-formats/formatSaveResult.js.map +1 -0
- package/dist/output-formats/table.d.ts +8 -0
- package/dist/output-formats/table.d.ts.map +1 -0
- package/dist/output-formats/table.js +15 -0
- package/dist/output-formats/table.js.map +1 -0
- package/dist/package-json/packageJson.d.ts +6 -0
- package/dist/package-json/packageJson.d.ts.map +1 -0
- package/dist/package-json/packageJson.js +12 -0
- package/dist/package-json/packageJson.js.map +1 -0
- package/dist/proxy/Proxy.d.ts +6 -0
- package/dist/proxy/Proxy.d.ts.map +1 -0
- package/dist/proxy/Proxy.js +203 -0
- package/dist/proxy/Proxy.js.map +1 -0
- package/dist/sea-main.d.ts +2 -0
- package/dist/sea-main.d.ts.map +1 -0
- package/dist/sea-main.js +20 -0
- package/dist/sea-main.js.map +1 -0
- package/dist/types/types.d.ts +55 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/arrayFunctions.d.ts +24 -0
- package/dist/utils/arrayFunctions.d.ts.map +1 -0
- package/dist/utils/arrayFunctions.js +43 -0
- package/dist/utils/arrayFunctions.js.map +1 -0
- package/dist/utils/assertFunctions.d.ts +7 -0
- package/dist/utils/assertFunctions.d.ts.map +1 -0
- package/dist/utils/assertFunctions.js +20 -0
- package/dist/utils/assertFunctions.js.map +1 -0
- package/dist/utils/checkFunctions.d.ts +34 -0
- package/dist/utils/checkFunctions.d.ts.map +1 -0
- package/dist/utils/checkFunctions.js +87 -0
- package/dist/utils/checkFunctions.js.map +1 -0
- package/dist/utils/cliFunctions.d.ts +10 -0
- package/dist/utils/cliFunctions.d.ts.map +1 -0
- package/dist/utils/cliFunctions.js +68 -0
- package/dist/utils/cliFunctions.js.map +1 -0
- package/dist/utils/hashFunctions.d.ts +10 -0
- package/dist/utils/hashFunctions.d.ts.map +1 -0
- package/dist/utils/hashFunctions.js +11 -0
- package/dist/utils/hashFunctions.js.map +1 -0
- package/dist/utils/npmFunctions.d.ts +3 -0
- package/dist/utils/npmFunctions.d.ts.map +1 -0
- package/dist/utils/npmFunctions.js +28 -0
- package/dist/utils/npmFunctions.js.map +1 -0
- package/dist/utils/stringFunctions.d.ts +12 -0
- package/dist/utils/stringFunctions.d.ts.map +1 -0
- package/dist/utils/stringFunctions.js +37 -0
- package/dist/utils/stringFunctions.js.map +1 -0
- package/package.json +39 -16
- package/client.js +0 -33
- package/src/cli-app/Dashboard.js +0 -220
- package/src/cli-app/Screen/FullScreenModal.js +0 -63
- package/src/cli-app/Screen.js +0 -140
- package/src/cli-app/elements/ElementNode.js +0 -97
- package/src/cli-app/elements/Line.js +0 -21
- package/src/cli-app/elements/List/List.js +0 -227
- package/src/cli-app/elements/List/ListCell.js +0 -83
- package/src/cli-app/elements/List/ListColumn.js +0 -52
- package/src/cli-app/elements/List/ListRow.js +0 -118
- package/src/cli-app/elements/Row.js +0 -38
- package/src/cli-app/helper/utils.js +0 -42
- package/src/commands/Action/addDelValuesAction.js +0 -56
- package/src/commands/CommandAuth.js +0 -32
- package/src/commands/CommandClearAll.js +0 -27
- package/src/commands/CommandConfig.js +0 -59
- package/src/commands/CommandHTTP.js +0 -192
- package/src/commands/CommandInvite.js +0 -38
- package/src/commands/CommandRefresh.js +0 -35
- package/src/commands/CommandRegister.js +0 -48
- package/src/commands/Option/DeleteOption.js +0 -6
- package/src/commands/Option/ProfileListOption.js +0 -65
- package/src/commands/Option/SelectConfigOption.js +0 -52
- package/src/commands/SubCommand/AllowDenyCidrCommand.js +0 -28
- package/src/commands/SubCommand/HostCommand.js +0 -22
- package/src/commands/SubCommand/PortCommand.js +0 -20
- package/src/commands/SubCommand/ProtocolCommand.js +0 -21
- package/src/commands/helper/AliasResolver.js +0 -13
- package/src/commands/helper/BindArgs.js +0 -53
- package/src/commands/helper/SharedArg.js +0 -32
- package/src/commands/utils.js +0 -96
- package/src/config/ConfigAbstract.js +0 -353
- package/src/config/ConfigManager.js +0 -70
- package/src/config/GlobalConfig.js +0 -14
- package/src/config/GlobalLocalShardConfigAbstract.js +0 -98
- package/src/config/LocalConfig.js +0 -7
- package/src/config/PropertyConfig.js +0 -122
- package/src/config/SystemConfig.js +0 -31
- package/src/core/FS/utils.js +0 -60
- package/src/core/Ref.js +0 -70
- package/src/lib/Flow/getCurrentIp.js +0 -18
- package/src/lib/Flow/getLatestVersion.js +0 -13
- package/src/lib/Flow/proxyUrl.js +0 -35
- package/src/lib/Flow/validateAuthToken.js +0 -19
- package/src/lib/HttpClient.js +0 -61
- package/src/lib/Proxy.js +0 -42
- package/src/lib/defs.js +0 -13
- package/src/net/IPV4.js +0 -139
- package/src/net/http/IncomingMessage.js +0 -92
- package/src/net/http/ServerResponse.js +0 -126
- package/src/net/http/TunliRequest.js +0 -1
- package/src/net/http/TunliResponse.js +0 -1
- package/src/net/http/TunnelRequest.js +0 -229
- package/src/net/http/TunnelResponse.js +0 -119
- package/src/tunnel-client/TunnelClient.js +0 -144
- package/src/utils/arrayFunctions.js +0 -45
- package/src/utils/checkFunctions.js +0 -182
- package/src/utils/cliFunctions.js +0 -63
- package/src/utils/createRequest.js +0 -12
- package/src/utils/hashFunctions.js +0 -9
- package/src/utils/httpFunction.js +0 -23
- package/src/utils/npmFunctions.js +0 -27
- package/src/utils/stringFunctions.js +0 -59
- package/types/index.d.ts +0 -119
package/package.json
CHANGED
|
@@ -1,44 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tunli",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.0
|
|
3
|
+
"description": "Developer-first HTTP tunneling CLI with daemon-based tunnel management, profiles, and self-hosted server support.",
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"main": "bin/tunli",
|
|
6
6
|
"bin": {
|
|
7
7
|
"tunli": "bin/tunli"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
10
|
+
"prepublishOnly": "npm test",
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"build:sea": "npm run clean && tsc && scripts/build-main.sh && scripts/build-launcher.sh",
|
|
13
|
+
"build:main": "npm run clean && tsc && scripts/build-main.sh",
|
|
14
|
+
"build:launcher": "npm run clean && tsc && scripts/build-launcher.sh",
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"dev:dashboard": "tsx --tsconfig tsconfig.json dev/dashboard-dev.ts",
|
|
17
|
+
"test": "npm run build && node --test test/**",
|
|
18
|
+
"test:coverage": "npm run build && node --test --experimental-test-coverage --test-coverage-exclude='test/**'",
|
|
19
|
+
"test:coverage:c8": "npm run build && npx c8 node --test",
|
|
20
|
+
"test:coverage:lcov": "npm run build && npx c8 --src src node --enable-source-maps --test"
|
|
11
21
|
},
|
|
12
22
|
"keywords": [
|
|
13
|
-
"
|
|
23
|
+
"tunnel",
|
|
24
|
+
"http tunnel",
|
|
14
25
|
"reverse proxy",
|
|
15
|
-
"remote access",
|
|
16
26
|
"local development",
|
|
17
|
-
"
|
|
27
|
+
"websocket",
|
|
28
|
+
"daemon",
|
|
29
|
+
"self-hosted"
|
|
18
30
|
],
|
|
19
31
|
"author": "Pascal Pfeifer <pascal@tunli.app>",
|
|
20
32
|
"imports": {
|
|
21
|
-
"
|
|
22
|
-
"#commands/*": "./src/commands/*.js",
|
|
23
|
-
"#src/*": "./src/*.js"
|
|
33
|
+
"#*": "./dist/*.js"
|
|
24
34
|
},
|
|
35
|
+
"files": [
|
|
36
|
+
"bin/",
|
|
37
|
+
"dist/",
|
|
38
|
+
"README.md",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
25
42
|
"type": "module",
|
|
26
43
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
44
|
+
"@pfeiferio/ipv4": "^1.1.0",
|
|
45
|
+
"@pfeiferio/string-interpolate": "^1.0.0",
|
|
29
46
|
"chalk": "^5.5.0",
|
|
30
|
-
"
|
|
47
|
+
"ink": "^6.8.0",
|
|
31
48
|
"qrcode": "^1.5.4",
|
|
49
|
+
"react": "^19.2.4",
|
|
32
50
|
"socket.io-client": "^4.8.1"
|
|
33
51
|
},
|
|
34
52
|
"devDependencies": {
|
|
35
|
-
"
|
|
53
|
+
"@types/qrcode": "^1.5.6",
|
|
54
|
+
"@types/react": "^19.0.0",
|
|
55
|
+
"esbuild": "^0.27.4",
|
|
56
|
+
"nodemon": "^3.1.10",
|
|
57
|
+
"tsx": "^4.19.3",
|
|
58
|
+
"typescript": "^5.9.3"
|
|
36
59
|
},
|
|
37
60
|
"repository": {
|
|
38
61
|
"type": "git",
|
|
39
|
-
"url": "https://github.com/tunlijs/tunli-client"
|
|
62
|
+
"url": "git+https://github.com/tunlijs/tunli-client"
|
|
40
63
|
},
|
|
41
64
|
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
42
66
|
"registry": "https://registry.npmjs.org"
|
|
43
67
|
},
|
|
44
68
|
"homepage": "https://tunli.app",
|
|
@@ -47,8 +71,7 @@
|
|
|
47
71
|
"url": "https://github.com/tunlijs/tunli-client/issues"
|
|
48
72
|
},
|
|
49
73
|
"license": "GPL-3.0",
|
|
50
|
-
"readme": "README.md",
|
|
51
74
|
"engines": {
|
|
52
|
-
"node": ">=
|
|
75
|
+
"node": ">=22"
|
|
53
76
|
}
|
|
54
77
|
}
|
package/client.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {dirnameFromMeta, readJsonFile, searchFileInDirectoryTree} from "#src/core/FS/utils";
|
|
2
|
-
import {program} from 'commander';
|
|
3
|
-
import {createCommandHTTP} from "#commands/CommandHTTP";
|
|
4
|
-
import {createCommandAuth} from "#commands/CommandAuth";
|
|
5
|
-
import {createCommandConfig} from "#commands/CommandConfig";
|
|
6
|
-
import {createCommandRegister} from "#commands/CommandRegister";
|
|
7
|
-
import {createCommandRefresh} from "#commands/CommandRefresh";
|
|
8
|
-
import {argumentAliasResolver} from "#commands/helper/AliasResolver";
|
|
9
|
-
import {createCommandInvite} from "#commands/CommandInvite";
|
|
10
|
-
import {addExamples, addUsage} from "#commands/utils";
|
|
11
|
-
import {profileListOption} from "#commands/Option/ProfileListOption";
|
|
12
|
-
|
|
13
|
-
program
|
|
14
|
-
.name('tunli')
|
|
15
|
-
.description('HTTP tunnel client')
|
|
16
|
-
.option('-v, --version', 'version', () => {
|
|
17
|
-
const packageJson = readJsonFile(searchFileInDirectoryTree('package.json', dirnameFromMeta(import.meta)))
|
|
18
|
-
console.log(`tunli: ${packageJson.version}`)
|
|
19
|
-
process.exit()
|
|
20
|
-
})
|
|
21
|
-
.addOption(profileListOption())
|
|
22
|
-
|
|
23
|
-
program.addCommand(createCommandConfig(program))
|
|
24
|
-
program.addCommand(createCommandHTTP(program), {isDefault: true})
|
|
25
|
-
program.addCommand(createCommandRegister(program))
|
|
26
|
-
program.addCommand(createCommandRefresh(program))
|
|
27
|
-
program.addCommand(createCommandInvite(program))
|
|
28
|
-
program.addCommand(createCommandAuth(program))
|
|
29
|
-
|
|
30
|
-
addExamples(program)
|
|
31
|
-
addUsage(program)
|
|
32
|
-
|
|
33
|
-
await program.parseAsync(argumentAliasResolver());
|
package/src/cli-app/Dashboard.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import {concat, createScreen} from "#src/cli-app/helper/utils";
|
|
2
|
-
import {dirnameFromMeta, readJsonFile, searchFileInDirectoryTree} from "#src/core/FS/utils";
|
|
3
|
-
import {ref} from "#src/core/Ref";
|
|
4
|
-
import {trimEnd} from "#src/utils/stringFunctions";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import {getLatestVersion} from "#lib/Flow/getLatestVersion";
|
|
7
|
-
import {exec} from 'child_process'
|
|
8
|
-
import {checkGlobalInstallation, checkLocalInstallation} from "#src/utils/npmFunctions";
|
|
9
|
-
import QRCode from 'qrcode'
|
|
10
|
-
|
|
11
|
-
export class Dashboard {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @type {TunnelClient}
|
|
15
|
-
*/
|
|
16
|
-
#client
|
|
17
|
-
/**
|
|
18
|
-
* @type {tunnelClientOptions}
|
|
19
|
-
*/
|
|
20
|
-
#options
|
|
21
|
-
/**
|
|
22
|
-
* @type {AppConfig}
|
|
23
|
-
*/
|
|
24
|
-
#config
|
|
25
|
-
/**
|
|
26
|
-
* @type {Screen}
|
|
27
|
-
*/
|
|
28
|
-
#screen
|
|
29
|
-
/**
|
|
30
|
-
* @type {Ref}
|
|
31
|
-
*/
|
|
32
|
-
#forwardingUrl
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {TunnelClient} client
|
|
36
|
-
* @param {tunnelClientOptions} options
|
|
37
|
-
* @param {AppConfig} config
|
|
38
|
-
*/
|
|
39
|
-
constructor(client, options, config) {
|
|
40
|
-
this.#client = client
|
|
41
|
-
this.#options = options
|
|
42
|
-
this.#config = config
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @param {string} value
|
|
47
|
-
*/
|
|
48
|
-
set forwardingUrl(value) {
|
|
49
|
-
this.#forwardingUrl.value = value
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @return {Screen}
|
|
54
|
-
*/
|
|
55
|
-
get screen() {
|
|
56
|
-
return this.#screen
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
destroy() {
|
|
60
|
-
this.#screen.destroy()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
init() {
|
|
64
|
-
|
|
65
|
-
const options = this.#options
|
|
66
|
-
const config = this.#config
|
|
67
|
-
const client = this.#client
|
|
68
|
-
|
|
69
|
-
const screen = createScreen()
|
|
70
|
-
this.#screen = screen
|
|
71
|
-
const packageJson = readJsonFile(searchFileInDirectoryTree('package.json', dirnameFromMeta(import.meta)))
|
|
72
|
-
const connectionStatus = ref(chalk.yellow('offline'))
|
|
73
|
-
const requestCount = ref(0)
|
|
74
|
-
const connectionDetails = ref('')
|
|
75
|
-
const forwardingUrl = ref(trimEnd(options.server, '/'))
|
|
76
|
-
|
|
77
|
-
this.#forwardingUrl = forwardingUrl
|
|
78
|
-
|
|
79
|
-
const allowedCidr = options.allowCidr.join(', ')
|
|
80
|
-
const deniedCidr = options.denyCidr.join(', ')
|
|
81
|
-
|
|
82
|
-
const blockedCount = ref(0)
|
|
83
|
-
const lastBlockedIp = ref('')
|
|
84
|
-
const availableUpdate = ref('')
|
|
85
|
-
|
|
86
|
-
screen.key('C-q', () => {
|
|
87
|
-
QRCode.toString(forwardingUrl.value, {type: 'terminal'}, (err, url) => {
|
|
88
|
-
if (err) throw err
|
|
89
|
-
screen.newFullScreenModal(url)
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
getLatestVersion().then((version) => {
|
|
94
|
-
if (version && version !== packageJson.version) {
|
|
95
|
-
availableUpdate.value = chalk.yellow(`update available (version ${version}, Ctrl-U to update)`)
|
|
96
|
-
|
|
97
|
-
screen.onceKey('C-u', async (char, details) => {
|
|
98
|
-
availableUpdate.value = chalk.yellow('Updating...')
|
|
99
|
-
let modifier
|
|
100
|
-
if (await checkGlobalInstallation(packageJson.name)) {
|
|
101
|
-
modifier = ' -g'
|
|
102
|
-
} else if (!await checkLocalInstallation(packageJson.name)) {
|
|
103
|
-
availableUpdate.value = chalk.red('Update failed.')
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const npmUpdateCommand = `npm${modifier} update ${packageJson.name} --registry https://registry.npmjs.org`
|
|
108
|
-
|
|
109
|
-
exec(npmUpdateCommand, (error, stdout, stderr) => {
|
|
110
|
-
if (error || stderr) {
|
|
111
|
-
availableUpdate.value = chalk.red('Update failed. Reason 2.')
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
availableUpdate.value = chalk.green('Update done. Please restart tunli. (Ctrl+R to restart)')
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
screen.row(packageJson.name)
|
|
121
|
-
screen.row('(Ctrl+C to quit)', {
|
|
122
|
-
top: -1, right: 0
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
screen.row("")
|
|
126
|
-
|
|
127
|
-
const infoList = screen.list({minWidth: 30})
|
|
128
|
-
|
|
129
|
-
screen.row('HTTP Requests')
|
|
130
|
-
screen.line()
|
|
131
|
-
|
|
132
|
-
const accessLog = screen.list({
|
|
133
|
-
length: 30, reverse: true, minWidth: [undefined, 30], maxWidth: [undefined, screen.width - 35]
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
client.on('tunnel-connection-established', () => {
|
|
137
|
-
connectionStatus.value = chalk.bold(chalk.green('online'))
|
|
138
|
-
connectionDetails.value = ''
|
|
139
|
-
screen.render()
|
|
140
|
-
})
|
|
141
|
-
|
|
142
|
-
client.on('blocked', ip => {
|
|
143
|
-
blockedCount.value++
|
|
144
|
-
lastBlockedIp.value = ` (${ip})`
|
|
145
|
-
})
|
|
146
|
-
client.on('tunnel-connection-closed', () => {
|
|
147
|
-
connectionStatus.value = chalk.bold(chalk.red('offline'))
|
|
148
|
-
screen.render()
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
client.on('tunnel-connection-error', (error) => {
|
|
152
|
-
if (error.stopPropagation) {
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
connectionDetails.value = chalk.bold(chalk.red(` - ${error.message}`))
|
|
156
|
-
screen.render()
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
client.on('response', (res, req) => {
|
|
160
|
-
|
|
161
|
-
const code = res.statusCode
|
|
162
|
-
let rspMsg = `${res.statusCode} ${res.statusMessage}`
|
|
163
|
-
if (code >= 500) {
|
|
164
|
-
rspMsg = chalk.red(rspMsg)
|
|
165
|
-
} else if (code >= 400) {
|
|
166
|
-
rspMsg = chalk.blueBright(rspMsg)
|
|
167
|
-
} else {
|
|
168
|
-
rspMsg = chalk.green(rspMsg)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
rspMsg = chalk.bold(rspMsg)
|
|
172
|
-
|
|
173
|
-
requestCount.value++
|
|
174
|
-
accessLog.row(req.method, req.path, rspMsg)
|
|
175
|
-
screen.render()
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
screen.key('C-c', (char, details) => {
|
|
179
|
-
process.exit(0);
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
screen.key('C-r', (char, details) => {
|
|
183
|
-
process.send('restart')
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
const target = new URL(`${options.protocol}://${options.host}:${options.port}`)
|
|
187
|
-
|
|
188
|
-
infoList.row('Tunnel', concat(connectionStatus, connectionDetails))
|
|
189
|
-
infoList.row('Version', packageJson.version)
|
|
190
|
-
infoList.row(chalk.yellow('Update'), availableUpdate).if(() => availableUpdate)
|
|
191
|
-
infoList.row('Profile', config.profile)
|
|
192
|
-
infoList.row('Config', config.configPath)
|
|
193
|
-
infoList.row('QR-Code', 'Ctrl-Q')
|
|
194
|
-
|
|
195
|
-
if (allowedCidr || deniedCidr) infoList.row('')
|
|
196
|
-
if (allowedCidr) infoList.row('Allowed', allowedCidr)
|
|
197
|
-
if (deniedCidr) infoList.row('Denied', deniedCidr)
|
|
198
|
-
if (allowedCidr || deniedCidr) infoList.row('Blocked', concat(blockedCount, lastBlockedIp))
|
|
199
|
-
|
|
200
|
-
infoList.row('')
|
|
201
|
-
infoList.row('Latency', concat(client.latency, 'ms'))
|
|
202
|
-
infoList.row('Forwarding', concat(forwardingUrl, ` -> ${trimEnd(target.toString(), '/')}`))
|
|
203
|
-
infoList.row('Connections', requestCount)
|
|
204
|
-
|
|
205
|
-
screen.render();
|
|
206
|
-
|
|
207
|
-
return this
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @param {TunnelClient} client
|
|
213
|
-
* @param {tunnelClientOptions} options
|
|
214
|
-
* @param {AppConfig} config
|
|
215
|
-
*/
|
|
216
|
-
export const initDashboard = (client, options, config) => {
|
|
217
|
-
const dashboard = new Dashboard(client, options, config)
|
|
218
|
-
dashboard.init()
|
|
219
|
-
return dashboard
|
|
220
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import blessed from "blessed";
|
|
2
|
-
|
|
3
|
-
const centerContent = (text, boxWidth) => {
|
|
4
|
-
const lines = text.split('\n')
|
|
5
|
-
return lines.map(line => {
|
|
6
|
-
const pad = Math.floor((boxWidth - line.length) / 2)
|
|
7
|
-
return ' '.repeat(Math.max(pad, 0)) + line
|
|
8
|
-
}).join('\n')
|
|
9
|
-
}
|
|
10
|
-
export const newFullScreenModal = (screen, text) => {
|
|
11
|
-
// Backdrop zum Blocken von Inputs „unter“ dem Modal
|
|
12
|
-
const backdrop = blessed.box({
|
|
13
|
-
top: 0, left: 0, width: '100%', height: '100%',
|
|
14
|
-
style: {bg: 'black'},
|
|
15
|
-
mouse: true, clickable: true
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
// Größe anhand des Inhalts bestimmen (mit Padding & Border)
|
|
19
|
-
const lines = text.split('\n')
|
|
20
|
-
const contentWidth = Math.max(...lines.map(l => l.length))
|
|
21
|
-
const contentHeight = lines.length
|
|
22
|
-
const boxWidth = Math.min(contentWidth + 4, screen.width - 2)
|
|
23
|
-
//const centeredQr = centerContent(text, screen.width - 2) // -2 wegen Padding/Border
|
|
24
|
-
|
|
25
|
-
const qrBox = blessed.box({
|
|
26
|
-
top: 'center',
|
|
27
|
-
left: 'center',
|
|
28
|
-
width: boxWidth,
|
|
29
|
-
height: Math.min(contentHeight + 2, screen.height - 2),
|
|
30
|
-
padding: {left: 1, right: 1},
|
|
31
|
-
tags: false,
|
|
32
|
-
scrollable: true,
|
|
33
|
-
content: text,
|
|
34
|
-
border: 'line',
|
|
35
|
-
style: {
|
|
36
|
-
fg: 'white',
|
|
37
|
-
bg: 'black',
|
|
38
|
-
border: {fg: 'cyan'}
|
|
39
|
-
},
|
|
40
|
-
keys: true,
|
|
41
|
-
mouse: true,
|
|
42
|
-
alwaysScroll: true
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
// Einfügen und nach vorne bringen
|
|
46
|
-
screen.append(backdrop)
|
|
47
|
-
screen.append(qrBox)
|
|
48
|
-
qrBox.focus()
|
|
49
|
-
screen.render()
|
|
50
|
-
|
|
51
|
-
const close = () => {
|
|
52
|
-
backdrop.detach()
|
|
53
|
-
qrBox.detach()
|
|
54
|
-
screen.render()
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Schließen über Tastatur/Click
|
|
58
|
-
qrBox.key(['escape', 'q', 'C-q'], close)
|
|
59
|
-
backdrop.on('click', close)
|
|
60
|
-
|
|
61
|
-
// Bei Resize neu zentriert blessed automatisch; nur neu rendern
|
|
62
|
-
screen.on('resize', () => screen.render())
|
|
63
|
-
}
|
package/src/cli-app/Screen.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import {List} from "#src/cli-app/elements/List/List";
|
|
2
|
-
import EventEmitter from "node:events";
|
|
3
|
-
import {Row} from "#src/cli-app/elements/Row";
|
|
4
|
-
import {ElementNode} from "#src/cli-app/elements/ElementNode";
|
|
5
|
-
import {arrayRemoveEntry} from "#src/utils/arrayFunctions";
|
|
6
|
-
import {Line} from "#src/cli-app/elements/Line";
|
|
7
|
-
import {newFullScreenModal} from "#src/cli-app/Screen/FullScreenModal";
|
|
8
|
-
|
|
9
|
-
export class Screen extends EventEmitter {
|
|
10
|
-
|
|
11
|
-
#screen
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @type {ElementNode[]}
|
|
15
|
-
*/
|
|
16
|
-
#elements = []
|
|
17
|
-
|
|
18
|
-
constructor(screen) {
|
|
19
|
-
super()
|
|
20
|
-
this.#screen = screen
|
|
21
|
-
|
|
22
|
-
for (const proxyFn of ['append']) {
|
|
23
|
-
this[proxyFn] = (...arg) => {
|
|
24
|
-
screen[proxyFn](...arg)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const ele = new ElementNode(this)
|
|
29
|
-
ele._cached.height = ele.height
|
|
30
|
-
ele._cached.top = ele.positionTop
|
|
31
|
-
this.#elements.push(ele)
|
|
32
|
-
|
|
33
|
-
this.on('delete-element', (ele) => {
|
|
34
|
-
this.#elements = arrayRemoveEntry(this.#elements, ele)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
screen.on('keypress', (char, details) => this.emit('keypress', char, /** keypressEventDetails */ details))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get screen() {
|
|
41
|
-
return this.#screen
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get children() {
|
|
45
|
-
return this.#elements
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get width() {
|
|
49
|
-
return this.#screen.width
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get height() {
|
|
53
|
-
return this.#screen.height
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
newFullScreenModal(text) {
|
|
57
|
-
return newFullScreenModal(this, text)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @param {string|array} key
|
|
62
|
-
* @param {keypressEventListener} callback
|
|
63
|
-
*/
|
|
64
|
-
key(key, callback) {
|
|
65
|
-
this.#screen.key(key, callback)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @param {string|array} key
|
|
70
|
-
* @param {keypressEventListener} callback
|
|
71
|
-
*/
|
|
72
|
-
onceKey(key, callback) {
|
|
73
|
-
this.#screen.onceKey(key, callback)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
render() {
|
|
77
|
-
this.#screen.render()
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
destroy() {
|
|
81
|
-
this.#screen.destroy()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
* @param {ElementNode} ele
|
|
87
|
-
*/
|
|
88
|
-
updateElement(ele) {
|
|
89
|
-
|
|
90
|
-
const heightChanged = ele._cached.height === ele.height
|
|
91
|
-
const topChanged = ele._cached.top === ele.positionTop
|
|
92
|
-
|
|
93
|
-
ele._cached.height = ele.height
|
|
94
|
-
ele._cached.top = ele.positionTop
|
|
95
|
-
|
|
96
|
-
if (heightChanged || topChanged) {
|
|
97
|
-
ele.nextElementSibling?.emit('prev-resize', ele)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @param {...cliListOption} [options]
|
|
103
|
-
* @returns {List}
|
|
104
|
-
*/
|
|
105
|
-
list(options) {
|
|
106
|
-
const ele = new List(this)
|
|
107
|
-
ele.init(options)
|
|
108
|
-
|
|
109
|
-
ele._cached.height = ele.height
|
|
110
|
-
ele._cached.top = ele.positionTop
|
|
111
|
-
|
|
112
|
-
this.#elements.push(ele)
|
|
113
|
-
return ele
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @param content
|
|
118
|
-
* @param [top]
|
|
119
|
-
* @param [right]
|
|
120
|
-
* @returns {Row}
|
|
121
|
-
*/
|
|
122
|
-
row(content, {top, right} = {}) {
|
|
123
|
-
const ele = new Row(this)
|
|
124
|
-
ele.init(content, {top, right})
|
|
125
|
-
ele._cached.height = ele.height
|
|
126
|
-
ele._cached.top = ele.positionTop
|
|
127
|
-
|
|
128
|
-
this.#elements.push(ele)
|
|
129
|
-
return ele
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
line() {
|
|
133
|
-
const ele = new Line(this)
|
|
134
|
-
ele.init()
|
|
135
|
-
ele._cached.height = ele.height
|
|
136
|
-
ele._cached.top = ele.positionTop
|
|
137
|
-
this.#elements.push(ele)
|
|
138
|
-
return ele
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "node:events";
|
|
2
|
-
|
|
3
|
-
export class ElementNode extends EventEmitter {
|
|
4
|
-
|
|
5
|
-
_cached = {
|
|
6
|
-
top: null,
|
|
7
|
-
height: null
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @type {ElementNode}
|
|
12
|
-
*/
|
|
13
|
-
#nextElementSibling
|
|
14
|
-
/**
|
|
15
|
-
* @type {ElementNode}
|
|
16
|
-
*/
|
|
17
|
-
#prevElementSibling
|
|
18
|
-
/**
|
|
19
|
-
* @type {Screen}
|
|
20
|
-
*/
|
|
21
|
-
#screen
|
|
22
|
-
#height = 0
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
#detached = false
|
|
26
|
-
#offsetTop = 0;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {Screen} screen
|
|
30
|
-
*/
|
|
31
|
-
constructor(screen) {
|
|
32
|
-
super()
|
|
33
|
-
this.#screen = screen
|
|
34
|
-
|
|
35
|
-
if (screen.children.length) {
|
|
36
|
-
const before = screen.children[screen.children.length - 1]
|
|
37
|
-
before.#nextElementSibling = this
|
|
38
|
-
this.#prevElementSibling = before
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* prev element postop and height
|
|
43
|
-
*/
|
|
44
|
-
this.on('prev-resize', ({positionTop, height}) => {
|
|
45
|
-
this.emit('position-top', positionTop + height)
|
|
46
|
-
this.nextElementSibling?.emit('prev-resize', this)
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get detached() {
|
|
51
|
-
return this.#detached
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get nextElementSibling() {
|
|
55
|
-
return this.#nextElementSibling
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get positionTop() {
|
|
59
|
-
if (this.#prevElementSibling) {
|
|
60
|
-
return this.#prevElementSibling.positionTop + this.#prevElementSibling.height + this.#offsetTop
|
|
61
|
-
}
|
|
62
|
-
return this.#offsetTop
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
set offsetTop(offsetTop) {
|
|
66
|
-
this.#offsetTop = offsetTop ?? 0
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get screen() {
|
|
70
|
-
return this.#screen
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get height() {
|
|
74
|
-
return this.#height
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
set height(height) {
|
|
78
|
-
const update = this.#height !== height
|
|
79
|
-
this.#height = height
|
|
80
|
-
if (update) {
|
|
81
|
-
this.emit('height', height)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
delete() {
|
|
86
|
-
|
|
87
|
-
this.#screen.emit('delete-element', this)
|
|
88
|
-
this.emit('delete', this)
|
|
89
|
-
this.#detached = true
|
|
90
|
-
const next = this.#nextElementSibling
|
|
91
|
-
|
|
92
|
-
if (next) {
|
|
93
|
-
next.#prevElementSibling = this.#prevElementSibling
|
|
94
|
-
this.#nextElementSibling?.emit('prev-resize', this.#prevElementSibling)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {ElementNode} from "#src/cli-app/elements/ElementNode";
|
|
2
|
-
import blessed from "blessed";
|
|
3
|
-
|
|
4
|
-
export class Line extends ElementNode {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {("horizontal", "vertical")} orientation
|
|
8
|
-
*/
|
|
9
|
-
init(orientation = 'horizontal') {
|
|
10
|
-
|
|
11
|
-
const line = blessed.line({
|
|
12
|
-
orientation
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
this.height = 1
|
|
16
|
-
this.on('position-top', (val) => line.top = val)
|
|
17
|
-
this.on('height', (val) => line.height = val)
|
|
18
|
-
this.on('delete', (val) => line.detach())
|
|
19
|
-
this.screen.append(line)
|
|
20
|
-
}
|
|
21
|
-
}
|