@latticexyz/world-module-erc20 2.2.13-main-23e6a6c97d94f85e163378148c51f51c900b3f8a
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/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/_esm-DCAC27XZ.js +10 -0
- package/dist/_esm-DCAC27XZ.js.map +1 -0
- package/dist/ccip-GJX6Z7AD.js +2 -0
- package/dist/ccip-GJX6Z7AD.js.map +1 -0
- package/dist/chunk-AU25RBDM.js +30 -0
- package/dist/chunk-AU25RBDM.js.map +1 -0
- package/dist/chunk-QBDELX7C.js +7 -0
- package/dist/chunk-QBDELX7C.js.map +1 -0
- package/dist/chunk-SYRP7SJ5.js +2 -0
- package/dist/chunk-SYRP7SJ5.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/mud.config.d.ts +415 -0
- package/dist/mud.config.js +2 -0
- package/dist/mud.config.js.map +1 -0
- package/dist/secp256k1-QYN2SJD6.js +22 -0
- package/dist/secp256k1-QYN2SJD6.js.map +1 -0
- package/out/AccessControl.sol/AccessControl.abi.json +1 -0
- package/out/AccessControl.sol/AccessControl.json +1 -0
- package/out/AccessManagementSystem.sol/AccessManagementSystem.abi.json +256 -0
- package/out/AccessManagementSystem.sol/AccessManagementSystem.abi.json.d.ts +256 -0
- package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -0
- package/out/Allowances.sol/Allowances.abi.json +1 -0
- package/out/Allowances.sol/Allowances.json +1 -0
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.abi.json +361 -0
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.abi.json.d.ts +361 -0
- package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -0
- package/out/Balances.sol/Balances.abi.json +1 -0
- package/out/Balances.sol/Balances.json +1 -0
- package/out/Base.sol/CommonBase.abi.json +1 -0
- package/out/Base.sol/CommonBase.json +1 -0
- package/out/Base.sol/ScriptBase.abi.json +1 -0
- package/out/Base.sol/ScriptBase.json +1 -0
- package/out/Base.sol/TestBase.abi.json +1 -0
- package/out/Base.sol/TestBase.json +1 -0
- package/out/BatchCallSystem.sol/BatchCallSystem.abi.json +132 -0
- package/out/BatchCallSystem.sol/BatchCallSystem.abi.json.d.ts +132 -0
- package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -0
- package/out/Bytes.sol/Bytes.abi.json +1 -0
- package/out/Bytes.sol/Bytes.json +1 -0
- package/out/Constants.sol/ERC20TableNames.abi.json +1 -0
- package/out/Constants.sol/ERC20TableNames.json +1 -0
- package/out/Constants.sol/ModuleConstants.abi.json +1 -0
- package/out/Constants.sol/ModuleConstants.json +1 -0
- package/out/Constants.sol/OwnableTableNames.abi.json +1 -0
- package/out/Constants.sol/OwnableTableNames.json +1 -0
- package/out/Constants.sol/PausableTableNames.abi.json +1 -0
- package/out/Constants.sol/PausableTableNames.json +1 -0
- package/out/Context.sol/Context.abi.json +1 -0
- package/out/Context.sol/Context.json +1 -0
- package/out/DecodeSlice.sol/DecodeSlice.abi.json +1 -0
- package/out/DecodeSlice.sol/DecodeSlice.json +1 -0
- package/out/Delegation.sol/Delegation.abi.json +1 -0
- package/out/Delegation.sol/Delegation.json +1 -0
- package/out/ERC165Checker.sol/ERC165Checker.abi.json +1 -0
- package/out/ERC165Checker.sol/ERC165Checker.json +1 -0
- package/out/ERC20BaseTest.sol/ERC20BehaviorTest.abi.json +949 -0
- package/out/ERC20BaseTest.sol/ERC20BehaviorTest.abi.json.d.ts +949 -0
- package/out/ERC20BaseTest.sol/ERC20BehaviorTest.json +1 -0
- package/out/ERC20BaseTest.sol/ERC20WithInternalStoreBehaviorTest.abi.json +949 -0
- package/out/ERC20BaseTest.sol/ERC20WithInternalStoreBehaviorTest.abi.json.d.ts +949 -0
- package/out/ERC20BaseTest.sol/ERC20WithInternalStoreBehaviorTest.json +1 -0
- package/out/ERC20BaseTest.sol/ERC20WithInternalStoreTest.abi.json +949 -0
- package/out/ERC20BaseTest.sol/ERC20WithInternalStoreTest.abi.json.d.ts +949 -0
- package/out/ERC20BaseTest.sol/ERC20WithInternalStoreTest.json +1 -0
- package/out/ERC20BaseTest.sol/ERC20WithWorldBehaviorTest.abi.json +956 -0
- package/out/ERC20BaseTest.sol/ERC20WithWorldBehaviorTest.abi.json.d.ts +956 -0
- package/out/ERC20BaseTest.sol/ERC20WithWorldBehaviorTest.json +1 -0
- package/out/ERC20BaseTest.sol/ERC20WithWorldTest.abi.json +956 -0
- package/out/ERC20BaseTest.sol/ERC20WithWorldTest.abi.json.d.ts +956 -0
- package/out/ERC20BaseTest.sol/ERC20WithWorldTest.json +1 -0
- package/out/ERC20BaseTest.sol/MockERC20Base.abi.json +683 -0
- package/out/ERC20BaseTest.sol/MockERC20Base.abi.json.d.ts +683 -0
- package/out/ERC20BaseTest.sol/MockERC20Base.json +1 -0
- package/out/ERC20BaseTest.sol/MockERC20WithInternalStore.abi.json +683 -0
- package/out/ERC20BaseTest.sol/MockERC20WithInternalStore.abi.json.d.ts +683 -0
- package/out/ERC20BaseTest.sol/MockERC20WithInternalStore.json +1 -0
- package/out/ERC20BaseTest.sol/MockERC20WithWorld.abi.json +719 -0
- package/out/ERC20BaseTest.sol/MockERC20WithWorld.abi.json.d.ts +719 -0
- package/out/ERC20BaseTest.sol/MockERC20WithWorld.json +1 -0
- package/out/ERC20BaseTest.sol/TestConstants.abi.json +1 -0
- package/out/ERC20BaseTest.sol/TestConstants.json +1 -0
- package/out/ERC20Burnable.sol/ERC20Burnable.abi.json +678 -0
- package/out/ERC20Burnable.sol/ERC20Burnable.abi.json.d.ts +678 -0
- package/out/ERC20Burnable.sol/ERC20Burnable.json +1 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableTest.abi.json +956 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableTest.abi.json.d.ts +956 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableTest.json +1 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.abi.json +956 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.abi.json.d.ts +956 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.json +1 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.abi.json +963 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.abi.json.d.ts +963 -0
- package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.json +1 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.abi.json +714 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.abi.json.d.ts +714 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.json +1 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.abi.json +745 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.abi.json.d.ts +745 -0
- package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.json +1 -0
- package/out/ERC20Metadata.sol/ERC20Metadata.abi.json +1 -0
- package/out/ERC20Metadata.sol/ERC20Metadata.json +1 -0
- package/out/ERC20Module.sol/ERC20Module.abi.json +147 -0
- package/out/ERC20Module.sol/ERC20Module.abi.json.d.ts +147 -0
- package/out/ERC20Module.sol/ERC20Module.json +1 -0
- package/out/ERC20Module.sol/ERC20RegistryLib.abi.json +349 -0
- package/out/ERC20Module.sol/ERC20RegistryLib.abi.json.d.ts +349 -0
- package/out/ERC20Module.sol/ERC20RegistryLib.json +1 -0
- package/out/ERC20Module.t.sol/ERC20ModuleTest.abi.json +541 -0
- package/out/ERC20Module.t.sol/ERC20ModuleTest.abi.json.d.ts +541 -0
- package/out/ERC20Module.t.sol/ERC20ModuleTest.json +1 -0
- package/out/ERC20Module.t.sol/TestConstants.abi.json +1 -0
- package/out/ERC20Module.t.sol/TestConstants.json +1 -0
- package/out/ERC20Pausable.sol/ERC20Pausable.abi.json +696 -0
- package/out/ERC20Pausable.sol/ERC20Pausable.abi.json.d.ts +696 -0
- package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.abi.json +956 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.abi.json.d.ts +956 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.json +1 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.abi.json +956 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.abi.json.d.ts +956 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.json +1 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.abi.json +963 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.abi.json.d.ts +963 -0
- package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.json +1 -0
- package/out/ERC20Pausable.t.sol/MockERC20Pausable.abi.json +710 -0
- package/out/ERC20Pausable.t.sol/MockERC20Pausable.abi.json.d.ts +710 -0
- package/out/ERC20Pausable.t.sol/MockERC20Pausable.json +1 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.abi.json +746 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.abi.json.d.ts +746 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.json +1 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.abi.json +777 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.abi.json.d.ts +777 -0
- package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.json +1 -0
- package/out/ERC20Registry.sol/ERC20Registry.abi.json +1 -0
- package/out/ERC20Registry.sol/ERC20Registry.json +1 -0
- package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.abi.json +838 -0
- package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.abi.json.d.ts +838 -0
- package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.json +1 -0
- package/out/ERC20WithWorld.sol/ERC20WithWorld.abi.json +816 -0
- package/out/ERC20WithWorld.sol/ERC20WithWorld.abi.json.d.ts +816 -0
- package/out/ERC20WithWorld.sol/ERC20WithWorld.json +1 -0
- package/out/EncodeArray.sol/EncodeArray.abi.json +1 -0
- package/out/EncodeArray.sol/EncodeArray.json +1 -0
- package/out/EncodedLengths.sol/EncodedLengthsInstance.abi.json +1 -0
- package/out/EncodedLengths.sol/EncodedLengthsInstance.json +1 -0
- package/out/EncodedLengths.sol/EncodedLengthsLib.abi.json +1 -0
- package/out/EncodedLengths.sol/EncodedLengthsLib.json +1 -0
- package/out/FieldLayout.sol/FieldLayoutInstance.abi.json +1 -0
- package/out/FieldLayout.sol/FieldLayoutInstance.json +1 -0
- package/out/FieldLayout.sol/FieldLayoutLib.abi.json +1 -0
- package/out/FieldLayout.sol/FieldLayoutLib.json +1 -0
- package/out/FunctionSelectors.sol/FunctionSelectors.abi.json +1 -0
- package/out/FunctionSelectors.sol/FunctionSelectors.json +1 -0
- package/out/FunctionSignatures.sol/FunctionSignatures.abi.json +1 -0
- package/out/FunctionSignatures.sol/FunctionSignatures.json +1 -0
- package/out/GasReporter.sol/GasReporter.abi.json +520 -0
- package/out/GasReporter.sol/GasReporter.abi.json.d.ts +520 -0
- package/out/GasReporter.sol/GasReporter.json +1 -0
- package/out/Hook.sol/HookInstance.abi.json +1 -0
- package/out/Hook.sol/HookInstance.json +1 -0
- package/out/Hook.sol/HookLib.abi.json +1 -0
- package/out/Hook.sol/HookLib.json +1 -0
- package/out/Hooks.sol/Hooks.abi.json +1 -0
- package/out/Hooks.sol/Hooks.json +1 -0
- package/out/IAccessManagementSystem.sol/IAccessManagementSystem.abi.json +69 -0
- package/out/IAccessManagementSystem.sol/IAccessManagementSystem.abi.json.d.ts +69 -0
- package/out/IAccessManagementSystem.sol/IAccessManagementSystem.json +1 -0
- package/out/IBalanceTransferSystem.sol/IBalanceTransferSystem.abi.json +48 -0
- package/out/IBalanceTransferSystem.sol/IBalanceTransferSystem.abi.json.d.ts +48 -0
- package/out/IBalanceTransferSystem.sol/IBalanceTransferSystem.json +1 -0
- package/out/IBaseWorld.sol/IBaseWorld.abi.json +2008 -0
- package/out/IBaseWorld.sol/IBaseWorld.abi.json.d.ts +2008 -0
- package/out/IBaseWorld.sol/IBaseWorld.json +1 -0
- package/out/IBatchCallSystem.sol/IBatchCallSystem.abi.json +69 -0
- package/out/IBatchCallSystem.sol/IBatchCallSystem.abi.json.d.ts +69 -0
- package/out/IBatchCallSystem.sol/IBatchCallSystem.json +1 -0
- package/out/IDelegationControl.sol/IDelegationControl.abi.json +89 -0
- package/out/IDelegationControl.sol/IDelegationControl.abi.json.d.ts +89 -0
- package/out/IDelegationControl.sol/IDelegationControl.json +1 -0
- package/out/IERC165.sol/IERC165.abi.json +21 -0
- package/out/IERC165.sol/IERC165.abi.json.d.ts +21 -0
- package/out/IERC165.sol/IERC165.json +1 -0
- package/out/IERC20.sol/IERC20.abi.json +185 -0
- package/out/IERC20.sol/IERC20.abi.json.d.ts +185 -0
- package/out/IERC20.sol/IERC20.json +1 -0
- package/out/IERC20Errors.sol/IERC20Errors.abi.json +88 -0
- package/out/IERC20Errors.sol/IERC20Errors.abi.json.d.ts +88 -0
- package/out/IERC20Errors.sol/IERC20Errors.json +1 -0
- package/out/IERC20Events.sol/IERC20Events.abi.json +52 -0
- package/out/IERC20Events.sol/IERC20Events.abi.json.d.ts +52 -0
- package/out/IERC20Events.sol/IERC20Events.json +1 -0
- package/out/IERC20Metadata.sol/IERC20Metadata.abi.json +224 -0
- package/out/IERC20Metadata.sol/IERC20Metadata.abi.json.d.ts +224 -0
- package/out/IERC20Metadata.sol/IERC20Metadata.json +1 -0
- package/out/IEncodedLengthsErrors.sol/IEncodedLengthsErrors.abi.json +13 -0
- package/out/IEncodedLengthsErrors.sol/IEncodedLengthsErrors.abi.json.d.ts +13 -0
- package/out/IEncodedLengthsErrors.sol/IEncodedLengthsErrors.json +1 -0
- package/out/IFieldLayoutErrors.sol/IFieldLayoutErrors.abi.json +88 -0
- package/out/IFieldLayoutErrors.sol/IFieldLayoutErrors.abi.json.d.ts +88 -0
- package/out/IFieldLayoutErrors.sol/IFieldLayoutErrors.json +1 -0
- package/out/IModule.sol/IModule.abi.json +73 -0
- package/out/IModule.sol/IModule.abi.json.d.ts +73 -0
- package/out/IModule.sol/IModule.json +1 -0
- package/out/IModuleErrors.sol/IModuleErrors.abi.json +28 -0
- package/out/IModuleErrors.sol/IModuleErrors.abi.json.d.ts +28 -0
- package/out/IModuleErrors.sol/IModuleErrors.json +1 -0
- package/out/IModuleInstallationSystem.sol/IModuleInstallationSystem.abi.json +20 -0
- package/out/IModuleInstallationSystem.sol/IModuleInstallationSystem.abi.json.d.ts +20 -0
- package/out/IModuleInstallationSystem.sol/IModuleInstallationSystem.json +1 -0
- package/out/IMulticall3.sol/IMulticall3.abi.json +440 -0
- package/out/IMulticall3.sol/IMulticall3.abi.json.d.ts +440 -0
- package/out/IMulticall3.sol/IMulticall3.json +1 -0
- package/out/IRegistrationSystem.sol/IRegistrationSystem.abi.json +1 -0
- package/out/IRegistrationSystem.sol/IRegistrationSystem.json +1 -0
- package/out/ISchemaErrors.sol/ISchemaErrors.abi.json +18 -0
- package/out/ISchemaErrors.sol/ISchemaErrors.abi.json.d.ts +18 -0
- package/out/ISchemaErrors.sol/ISchemaErrors.json +1 -0
- package/out/ISliceErrors.sol/ISliceErrors.abi.json +23 -0
- package/out/ISliceErrors.sol/ISliceErrors.abi.json.d.ts +23 -0
- package/out/ISliceErrors.sol/ISliceErrors.json +1 -0
- package/out/IStore.sol/IStore.abi.json +1261 -0
- package/out/IStore.sol/IStore.abi.json.d.ts +1261 -0
- package/out/IStore.sol/IStore.json +1 -0
- package/out/IStoreErrors.sol/IStoreErrors.abi.json +204 -0
- package/out/IStoreErrors.sol/IStoreErrors.abi.json.d.ts +204 -0
- package/out/IStoreErrors.sol/IStoreErrors.json +1 -0
- package/out/IStoreEvents.sol/IStoreEvents.abi.json +151 -0
- package/out/IStoreEvents.sol/IStoreEvents.abi.json.d.ts +151 -0
- package/out/IStoreEvents.sol/IStoreEvents.json +1 -0
- package/out/IStoreHook.sol/IStoreHook.abi.json +290 -0
- package/out/IStoreHook.sol/IStoreHook.abi.json.d.ts +290 -0
- package/out/IStoreHook.sol/IStoreHook.json +1 -0
- package/out/IStoreKernel.sol/IStoreKernel.abi.json +1182 -0
- package/out/IStoreKernel.sol/IStoreKernel.abi.json.d.ts +1182 -0
- package/out/IStoreKernel.sol/IStoreKernel.json +1 -0
- package/out/IStoreRead.sol/IStoreRead.abi.json +389 -0
- package/out/IStoreRead.sol/IStoreRead.abi.json.d.ts +389 -0
- package/out/IStoreRead.sol/IStoreRead.json +1 -0
- package/out/IStoreRegistration.sol/IStoreRegistration.abi.json +81 -0
- package/out/IStoreRegistration.sol/IStoreRegistration.abi.json.d.ts +81 -0
- package/out/IStoreRegistration.sol/IStoreRegistration.json +1 -0
- package/out/IStoreWrite.sol/IStoreWrite.abi.json +446 -0
- package/out/IStoreWrite.sol/IStoreWrite.abi.json.d.ts +446 -0
- package/out/IStoreWrite.sol/IStoreWrite.json +1 -0
- package/out/ISystemHook.sol/ISystemHook.abi.json +67 -0
- package/out/ISystemHook.sol/ISystemHook.abi.json.d.ts +67 -0
- package/out/ISystemHook.sol/ISystemHook.json +1 -0
- package/out/IWorldContextConsumer.sol/IWorldContextConsumer.abi.json +60 -0
- package/out/IWorldContextConsumer.sol/IWorldContextConsumer.abi.json.d.ts +60 -0
- package/out/IWorldContextConsumer.sol/IWorldContextConsumer.json +1 -0
- package/out/IWorldErrors.sol/IWorldErrors.abi.json +200 -0
- package/out/IWorldErrors.sol/IWorldErrors.abi.json.d.ts +200 -0
- package/out/IWorldErrors.sol/IWorldErrors.json +1 -0
- package/out/IWorldEvents.sol/IWorldEvents.abi.json +15 -0
- package/out/IWorldEvents.sol/IWorldEvents.abi.json.d.ts +15 -0
- package/out/IWorldEvents.sol/IWorldEvents.json +1 -0
- package/out/IWorldKernel.sol/IWorldCall.abi.json +55 -0
- package/out/IWorldKernel.sol/IWorldCall.abi.json.d.ts +55 -0
- package/out/IWorldKernel.sol/IWorldCall.json +1 -0
- package/out/IWorldKernel.sol/IWorldKernel.abi.json +349 -0
- package/out/IWorldKernel.sol/IWorldKernel.abi.json.d.ts +349 -0
- package/out/IWorldKernel.sol/IWorldKernel.json +1 -0
- package/out/IWorldKernel.sol/IWorldModuleInstallation.abi.json +20 -0
- package/out/IWorldKernel.sol/IWorldModuleInstallation.abi.json.d.ts +20 -0
- package/out/IWorldKernel.sol/IWorldModuleInstallation.json +1 -0
- package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.abi.json +204 -0
- package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.abi.json.d.ts +204 -0
- package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -0
- package/out/InitModule.sol/InitModule.abi.json +462 -0
- package/out/InitModule.sol/InitModule.abi.json.d.ts +462 -0
- package/out/InitModule.sol/InitModule.json +1 -0
- package/out/InitModuleAddress.sol/InitModuleAddress.abi.json +1 -0
- package/out/InitModuleAddress.sol/InitModuleAddress.json +1 -0
- package/out/InstalledModules.sol/InstalledModules.abi.json +1 -0
- package/out/InstalledModules.sol/InstalledModules.json +1 -0
- package/out/LimitedCallContext.sol/LimitedCallContext.abi.json +7 -0
- package/out/LimitedCallContext.sol/LimitedCallContext.abi.json.d.ts +7 -0
- package/out/LimitedCallContext.sol/LimitedCallContext.json +1 -0
- package/out/MUDERC20.sol/MUDERC20.abi.json +647 -0
- package/out/MUDERC20.sol/MUDERC20.abi.json.d.ts +647 -0
- package/out/MUDERC20.sol/MUDERC20.json +1 -0
- package/out/Memory.sol/Memory.abi.json +1 -0
- package/out/Memory.sol/Memory.json +1 -0
- package/out/Module.sol/Module.abi.json +112 -0
- package/out/Module.sol/Module.abi.json.d.ts +112 -0
- package/out/Module.sol/Module.json +1 -0
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json +151 -0
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json.d.ts +151 -0
- package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -0
- package/out/NamespaceDelegationControl.sol/NamespaceDelegationControl.abi.json +1 -0
- package/out/NamespaceDelegationControl.sol/NamespaceDelegationControl.json +1 -0
- package/out/NamespaceOwner.sol/NamespaceOwner.abi.json +1 -0
- package/out/NamespaceOwner.sol/NamespaceOwner.json +1 -0
- package/out/Ownable.sol/Ownable.abi.json +413 -0
- package/out/Ownable.sol/Ownable.abi.json.d.ts +413 -0
- package/out/Ownable.sol/Ownable.json +1 -0
- package/out/Owner.sol/Owner.abi.json +1 -0
- package/out/Owner.sol/Owner.json +1 -0
- package/out/Pausable.sol/Pausable.abi.json +388 -0
- package/out/Pausable.sol/Pausable.abi.json.d.ts +388 -0
- package/out/Pausable.sol/Pausable.json +1 -0
- package/out/Paused.sol/Paused.abi.json +1 -0
- package/out/Paused.sol/Paused.json +1 -0
- package/out/RegistrationSystem.sol/RegistrationSystem.abi.json +1018 -0
- package/out/RegistrationSystem.sol/RegistrationSystem.abi.json.d.ts +1018 -0
- package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -0
- package/out/ResourceAccess.sol/ResourceAccess.abi.json +1 -0
- package/out/ResourceAccess.sol/ResourceAccess.json +1 -0
- package/out/ResourceId.sol/ResourceIdInstance.abi.json +1 -0
- package/out/ResourceId.sol/ResourceIdInstance.json +1 -0
- package/out/ResourceId.sol/ResourceIdLib.abi.json +1 -0
- package/out/ResourceId.sol/ResourceIdLib.json +1 -0
- package/out/ResourceIds.sol/ResourceIds.abi.json +1 -0
- package/out/ResourceIds.sol/ResourceIds.json +1 -0
- package/out/Schema.sol/SchemaInstance.abi.json +1 -0
- package/out/Schema.sol/SchemaInstance.json +1 -0
- package/out/Schema.sol/SchemaLib.abi.json +1 -0
- package/out/Schema.sol/SchemaLib.json +1 -0
- package/out/Slice.sol/SliceInstance.abi.json +1 -0
- package/out/Slice.sol/SliceInstance.json +1 -0
- package/out/Slice.sol/SliceLib.abi.json +1 -0
- package/out/Slice.sol/SliceLib.json +1 -0
- package/out/StdAssertions.sol/StdAssertions.abi.json +392 -0
- package/out/StdAssertions.sol/StdAssertions.abi.json.d.ts +392 -0
- package/out/StdAssertions.sol/StdAssertions.json +1 -0
- package/out/StdChains.sol/StdChains.abi.json +1 -0
- package/out/StdChains.sol/StdChains.json +1 -0
- package/out/StdCheats.sol/StdCheats.abi.json +1 -0
- package/out/StdCheats.sol/StdCheats.json +1 -0
- package/out/StdCheats.sol/StdCheatsSafe.abi.json +1 -0
- package/out/StdCheats.sol/StdCheatsSafe.json +1 -0
- package/out/StdError.sol/stdError.abi.json +119 -0
- package/out/StdError.sol/stdError.abi.json.d.ts +119 -0
- package/out/StdError.sol/stdError.json +1 -0
- package/out/StdInvariant.sol/StdInvariant.abi.json +130 -0
- package/out/StdInvariant.sol/StdInvariant.abi.json.d.ts +130 -0
- package/out/StdInvariant.sol/StdInvariant.json +1 -0
- package/out/StdJson.sol/stdJson.abi.json +1 -0
- package/out/StdJson.sol/stdJson.json +1 -0
- package/out/StdMath.sol/stdMath.abi.json +1 -0
- package/out/StdMath.sol/stdMath.json +1 -0
- package/out/StdStorage.sol/stdStorage.abi.json +1 -0
- package/out/StdStorage.sol/stdStorage.json +1 -0
- package/out/StdStorage.sol/stdStorageSafe.abi.json +52 -0
- package/out/StdStorage.sol/stdStorageSafe.abi.json.d.ts +52 -0
- package/out/StdStorage.sol/stdStorageSafe.json +1 -0
- package/out/StdStyle.sol/StdStyle.abi.json +1 -0
- package/out/StdStyle.sol/StdStyle.json +1 -0
- package/out/StdUtils.sol/StdUtils.abi.json +1 -0
- package/out/StdUtils.sol/StdUtils.json +1 -0
- package/out/Storage.sol/Storage.abi.json +1 -0
- package/out/Storage.sol/Storage.json +1 -0
- package/out/Store.sol/Store.abi.json +1261 -0
- package/out/Store.sol/Store.abi.json.d.ts +1261 -0
- package/out/Store.sol/Store.json +1 -0
- package/out/StoreConsumer.sol/StoreConsumer.abi.json +15 -0
- package/out/StoreConsumer.sol/StoreConsumer.abi.json.d.ts +15 -0
- package/out/StoreConsumer.sol/StoreConsumer.json +1 -0
- package/out/StoreConsumer.t.sol/MockStoreConsumer.abi.json +52 -0
- package/out/StoreConsumer.t.sol/MockStoreConsumer.abi.json.d.ts +52 -0
- package/out/StoreConsumer.t.sol/MockStoreConsumer.json +1 -0
- package/out/StoreConsumer.t.sol/MockWithInternalStore.abi.json +376 -0
- package/out/StoreConsumer.t.sol/MockWithInternalStore.abi.json.d.ts +376 -0
- package/out/StoreConsumer.t.sol/MockWithInternalStore.json +1 -0
- package/out/StoreConsumer.t.sol/MockWithStore.abi.json +387 -0
- package/out/StoreConsumer.t.sol/MockWithStore.abi.json.d.ts +387 -0
- package/out/StoreConsumer.t.sol/MockWithStore.json +1 -0
- package/out/StoreConsumer.t.sol/MockWithWorld.abi.json +430 -0
- package/out/StoreConsumer.t.sol/MockWithWorld.abi.json.d.ts +430 -0
- package/out/StoreConsumer.t.sol/MockWithWorld.json +1 -0
- package/out/StoreConsumer.t.sol/StoreConsumerTest.abi.json +548 -0
- package/out/StoreConsumer.t.sol/StoreConsumerTest.abi.json.d.ts +548 -0
- package/out/StoreConsumer.t.sol/StoreConsumerTest.json +1 -0
- package/out/StoreCore.sol/StoreCore.abi.json +1 -0
- package/out/StoreCore.sol/StoreCore.json +1 -0
- package/out/StoreCore.sol/StoreCoreInternal.abi.json +1 -0
- package/out/StoreCore.sol/StoreCoreInternal.json +1 -0
- package/out/StoreHooks.sol/StoreHooks.abi.json +1 -0
- package/out/StoreHooks.sol/StoreHooks.json +1 -0
- package/out/StoreKernel.sol/StoreKernel.abi.json +1182 -0
- package/out/StoreKernel.sol/StoreKernel.abi.json.d.ts +1182 -0
- package/out/StoreKernel.sol/StoreKernel.json +1 -0
- package/out/StoreRead.sol/StoreRead.abi.json +437 -0
- package/out/StoreRead.sol/StoreRead.abi.json.d.ts +437 -0
- package/out/StoreRead.sol/StoreRead.json +1 -0
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.abi.json +779 -0
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.abi.json.d.ts +779 -0
- package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -0
- package/out/StoreSwitch.sol/StoreSwitch.abi.json +1 -0
- package/out/StoreSwitch.sol/StoreSwitch.json +1 -0
- package/out/System.sol/System.abi.json +60 -0
- package/out/System.sol/System.abi.json.d.ts +60 -0
- package/out/System.sol/System.json +1 -0
- package/out/SystemCall.sol/SystemCall.abi.json +1 -0
- package/out/SystemCall.sol/SystemCall.json +1 -0
- package/out/SystemHooks.sol/SystemHooks.abi.json +1 -0
- package/out/SystemHooks.sol/SystemHooks.json +1 -0
- package/out/SystemRegistry.sol/SystemRegistry.abi.json +1 -0
- package/out/SystemRegistry.sol/SystemRegistry.json +1 -0
- package/out/Systems.sol/Systems.abi.json +1 -0
- package/out/Systems.sol/Systems.json +1 -0
- package/out/Tables.sol/Tables.abi.json +1 -0
- package/out/Tables.sol/Tables.json +1 -0
- package/out/Test.sol/Test.abi.json +520 -0
- package/out/Test.sol/Test.abi.json.d.ts +520 -0
- package/out/Test.sol/Test.json +1 -0
- package/out/TightCoder.sol/TightCoder.abi.json +1 -0
- package/out/TightCoder.sol/TightCoder.json +1 -0
- package/out/TotalSupply.sol/TotalSupply.abi.json +1 -0
- package/out/TotalSupply.sol/TotalSupply.json +1 -0
- package/out/UserDelegationControl.sol/UserDelegationControl.abi.json +1 -0
- package/out/UserDelegationControl.sol/UserDelegationControl.json +1 -0
- package/out/Vm.sol/Vm.abi.json +3878 -0
- package/out/Vm.sol/Vm.abi.json.d.ts +3878 -0
- package/out/Vm.sol/Vm.json +1 -0
- package/out/Vm.sol/VmSafe.abi.json +2678 -0
- package/out/Vm.sol/VmSafe.abi.json.d.ts +2678 -0
- package/out/Vm.sol/VmSafe.json +1 -0
- package/out/WithStore.sol/WithStore.abi.json +339 -0
- package/out/WithStore.sol/WithStore.abi.json.d.ts +339 -0
- package/out/WithStore.sol/WithStore.json +1 -0
- package/out/WithWorld.sol/WithWorld.abi.json +370 -0
- package/out/WithWorld.sol/WithWorld.abi.json.d.ts +370 -0
- package/out/WithWorld.sol/WithWorld.json +1 -0
- package/out/World.sol/World.abi.json +1542 -0
- package/out/World.sol/World.abi.json.d.ts +1542 -0
- package/out/World.sol/World.json +1 -0
- package/out/WorldContext.sol/WorldContextConsumer.abi.json +60 -0
- package/out/WorldContext.sol/WorldContextConsumer.abi.json.d.ts +60 -0
- package/out/WorldContext.sol/WorldContextConsumer.json +1 -0
- package/out/WorldContext.sol/WorldContextConsumerLib.abi.json +1 -0
- package/out/WorldContext.sol/WorldContextConsumerLib.json +1 -0
- package/out/WorldContext.sol/WorldContextProviderLib.abi.json +1 -0
- package/out/WorldContext.sol/WorldContextProviderLib.json +1 -0
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.abi.json +691 -0
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.abi.json.d.ts +691 -0
- package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -0
- package/out/WorldResourceId.sol/WorldResourceIdInstance.abi.json +1 -0
- package/out/WorldResourceId.sol/WorldResourceIdInstance.json +1 -0
- package/out/WorldResourceId.sol/WorldResourceIdLib.abi.json +1 -0
- package/out/WorldResourceId.sol/WorldResourceIdLib.json +1 -0
- package/out/build-info/bc3a1525415111591c1321f8462fa438.json +1 -0
- package/out/console.sol/console.abi.json +1 -0
- package/out/console.sol/console.json +1 -0
- package/out/console2.sol/console2.abi.json +1 -0
- package/out/console2.sol/console2.json +1 -0
- package/out/constants.sol/LayoutOffsets.abi.json +1 -0
- package/out/constants.sol/LayoutOffsets.json +1 -0
- package/out/safeconsole.sol/safeconsole.abi.json +1 -0
- package/out/safeconsole.sol/safeconsole.json +1 -0
- package/out/src/IERC165.sol/IERC165.abi.json +21 -0
- package/out/src/IERC165.sol/IERC165.abi.json.d.ts +21 -0
- package/out/src/IERC165.sol/IERC165.json +1 -0
- package/out/tables/Balances.sol/Balances.abi.json +1 -0
- package/out/tables/Balances.sol/Balances.json +1 -0
- package/out/test.sol/DSTest.abi.json +296 -0
- package/out/test.sol/DSTest.abi.json.d.ts +296 -0
- package/out/test.sol/DSTest.json +1 -0
- package/package.json +67 -0
- package/src/Constants.sol +36 -0
- package/src/Context.sol +10 -0
- package/src/ERC20Burnable.sol +16 -0
- package/src/ERC20Module.sol +74 -0
- package/src/ERC20Pausable.sol +12 -0
- package/src/MUDERC20.sol +326 -0
- package/src/Ownable.sol +110 -0
- package/src/Pausable.sol +125 -0
- package/src/StoreConsumer.sol +24 -0
- package/src/WithStore.sol +22 -0
- package/src/WithWorld.sol +40 -0
- package/src/codegen/index.sol +12 -0
- package/src/codegen/tables/Allowances.sol +208 -0
- package/src/codegen/tables/Balances.sol +196 -0
- package/src/codegen/tables/ERC20Metadata.sol +604 -0
- package/src/codegen/tables/ERC20Registry.sol +199 -0
- package/src/codegen/tables/Owner.sol +184 -0
- package/src/codegen/tables/Paused.sol +196 -0
- package/src/codegen/tables/TotalSupply.sol +184 -0
- package/src/examples/ERC20WithInternalStore.sol +32 -0
- package/src/examples/ERC20WithWorld.sol +40 -0
- package/src/interfaces/IERC20.sol +67 -0
- package/src/interfaces/IERC20Errors.sol +49 -0
- package/src/interfaces/IERC20Events.sol +18 -0
- package/src/interfaces/IERC20Metadata.sol +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present Lattice Labs Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# ERC20 World Module
|
|
2
|
+
|
|
3
|
+
> :warning: **Important note: this module has not been audited yet, so any production use is discouraged for now.**
|
|
4
|
+
|
|
5
|
+
## ERC20 contracts
|
|
6
|
+
|
|
7
|
+
In order to achieve a similar level of composability to [`OpenZeppelin` ERC20 contract extensions](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20), we provide a way to abstract the underlying Store being used. This allows developers to easily create ERC20 tokens that can either use its own storage as the Store, or attach themselves to an existing World.
|
|
8
|
+
|
|
9
|
+
- `StoreConsumer`: all contracts inherit from `StoreConsumer`, which abstracts the way in which `ResourceId`s are encoded. This allows us to have composable contracts whose implementations don't depend on the type of Store being used.
|
|
10
|
+
- `WithStore(address) is StoreConsumer`: this contract initializes the store, using the contract's internal storage or the provided external `Store`. It encodes `ResourceId`s using `ResourceIdLib` from the `@latticexyz/store` package.
|
|
11
|
+
- `WithWorld(IBaseWorld, bytes14) is WithStore`: initializes the store and also registers the provided namespace in the provided World. It encodes `ResourceId`s using `WorldResourceIdLib` (using the namespace). It also provides an `onlyNamespace` modifier, which can be used to restrict access to certain functions, only allowing calls from addresses that have access to the namespace.
|
|
12
|
+
|
|
13
|
+
- `MUDERC20`: base ERC20 implementation adapted from Openzeppelin's ERC20. Contains the ERC20 logic, reads/writes to the store through MUD's codegen libraries and initializes the tables it needs. As these libraries use `StoreSwitch` internally, this contract doesn't need to know about the store it's interacting with (it can be internal storage, an external `Store` or a `World`).
|
|
14
|
+
|
|
15
|
+
- Extensions and other contracts: contracts like `Ownable`, `Pausable`, `ERC20Burnable`, etc are adapted from `OpenZeppelin` contracts to use MUD's codegen libraries to read and write from a `Store`. They inherit from `StoreConsumer`, so they can obtain the `ResourceId` for the tables they use using `_encodeResourceId()`.
|
|
16
|
+
|
|
17
|
+
### Example 1: Using the contract's storage
|
|
18
|
+
|
|
19
|
+
By using `WithStore(address(this))` as the first contract that the implementation inherits from, it allows all the other contracts in the inheritance list to use the contract's storage as a `Store`.
|
|
20
|
+
|
|
21
|
+
```solidity
|
|
22
|
+
contract ERC20WithInternalStore is WithStore(address(this)), MUDERC20, ERC20Pausable, ERC20Burnable, Ownable {
|
|
23
|
+
constructor() MUDERC20("MyERC20", "MTK") Ownable(_msgSender()) {}
|
|
24
|
+
|
|
25
|
+
function mint() public onlyOwner {
|
|
26
|
+
_mint(to, value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function pause() public onlyOwner {
|
|
30
|
+
_pause();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function unpause() public onlyOwner {
|
|
34
|
+
_unpause();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The following functions are overrides required by Solidity.
|
|
38
|
+
|
|
39
|
+
function _update(address from, address to, uint256 value) internal override(MUDERC20, ERC20Pausable) {
|
|
40
|
+
super._update(from, to, value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Example 2: Using a World as an external Store and registering a new Namespace
|
|
46
|
+
|
|
47
|
+
The `WithWorld` contract internally points the `StoreSwitch` to the provided World and attempts to register the provided namespace. It allows the other contracts in the inheritance list to use the external World as a `Store`, using the provided namespace for all operations. Additionally, all functions that use the `onlyNamespace` modifier can only be called by addresses that have access to the namespace.
|
|
48
|
+
|
|
49
|
+
```solidity
|
|
50
|
+
contract ERC20WithWorld is WithWorld, MUDERC20, ERC20Pausable, ERC20Burnable {
|
|
51
|
+
constructor(
|
|
52
|
+
IBaseWorld world,
|
|
53
|
+
bytes14 namespace,
|
|
54
|
+
string memory name,
|
|
55
|
+
string memory symbol
|
|
56
|
+
) WithWorld(world, namespace) MUDERC20(name, symbol) {
|
|
57
|
+
// transfer namespace ownership to the creator
|
|
58
|
+
world.transferOwnership(getNamespaceId(), _msgSender());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function mint(address to, uint256 value) public onlyNamespace {
|
|
62
|
+
_mint(to, value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function pause() public onlyNamespace {
|
|
66
|
+
_pause();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function unpause() public onlyNamespace {
|
|
70
|
+
_unpause();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The following functions are overrides required by Solidity.
|
|
74
|
+
|
|
75
|
+
function _update(address from, address to, uint256 value) internal override(MUDERC20, ERC20Pausable) {
|
|
76
|
+
super._update(from, to, value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
# Module usage
|
|
82
|
+
|
|
83
|
+
The ERC20Module receives the namespace, name and symbol of the token as parameters, and deploys the new token. Currently it installs a default ERC20 (`examples/ERC20WithWorld.sol`) with the following features:
|
|
84
|
+
|
|
85
|
+
- ERC20Burnable: Allows users to burn their tokens (or the ones approved to them) using the `burn` and `burnFrom` function.
|
|
86
|
+
- ERC20Pausable: Supports pausing and unpausing token operations. This is combined with the `pause` and `unpause` public functions that can be called by addresses with access to the token's namespace.
|
|
87
|
+
- Minting: Addresses with namespace access can call the `mint` function to mint tokens to any address.
|
|
88
|
+
|
|
89
|
+
## Installation
|
|
90
|
+
|
|
91
|
+
In your MUD config:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { defineWorld } from "@latticexyz/world";
|
|
95
|
+
import { defineERC20Config } from "@latticexyz/world-module-erc20";
|
|
96
|
+
|
|
97
|
+
export default defineWorld({
|
|
98
|
+
namespace: "app",
|
|
99
|
+
tables: {
|
|
100
|
+
Counter: {
|
|
101
|
+
schema: {
|
|
102
|
+
value: "uint32",
|
|
103
|
+
},
|
|
104
|
+
key: [],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
modules: [
|
|
108
|
+
defineERC20Config({
|
|
109
|
+
namespace: "erc20Namespace",
|
|
110
|
+
name: "MyToken",
|
|
111
|
+
symbol: "MTK",
|
|
112
|
+
}),
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This will deploy the token and register the provided namespace.
|
|
118
|
+
|
|
119
|
+
In order to get the token's address in a script or system:
|
|
120
|
+
|
|
121
|
+
```solidity
|
|
122
|
+
// Table Id of the ERC20Registry, under the `erc20-module` namespace
|
|
123
|
+
ResourceId erc20RegistryResource = WorldResourceIdLib.encode(RESOURCE_TABLE, "erc20-module", "ERC20_REGISTRY");
|
|
124
|
+
|
|
125
|
+
// Namespace where the token was installed
|
|
126
|
+
ResourceId namespaceResource = WorldResourceIdLib.encodeNamespace(bytes14("erc20Namespace"));
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
// Get the ERC-20 token address
|
|
130
|
+
address tokenAddress = ERC20Registry.getTokenAddress(erc20RegistryResource, namespaceResource);
|
|
131
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as p,b as g,c as Ur,d as X}from"./chunk-SYRP7SJ5.js";var nt=g((li,it)=>{"use strict";var{Duplex:Ir}=p("stream");function rt(r){r.emit("close")}function Dr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function st(r){this.removeListener("error",st),this.destroy(),this.listenerCount("error")===0&&this.emit("error",r)}function Mr(r,e){let t=!0,s=new Ir({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return r.on("message",function(n,o){let f=!o&&s._readableState.objectMode?n.toString():n;s.push(f)||r.pause()}),r.once("error",function(n){s.destroyed||(t=!1,s.destroy(n))}),r.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(i,n){if(r.readyState===r.CLOSED){n(i),process.nextTick(rt,s);return}let o=!1;r.once("error",function(l){o=!0,n(l)}),r.once("close",function(){o||n(i),process.nextTick(rt,s)}),t&&r.terminate()},s._final=function(i){if(r.readyState===r.CONNECTING){r.once("open",function(){s._final(i)});return}r._socket!==null&&(r._socket._writableState.finished?(i(),s._readableState.endEmitted&&s.destroy()):(r._socket.once("finish",function(){i()}),r.close()))},s._read=function(){r.isPaused&&r.resume()},s._write=function(i,n,o){if(r.readyState===r.CONNECTING){r.once("open",function(){s._write(i,n,o)});return}r.send(i,o)},s.on("end",Dr),s.on("error",st),s}it.exports=Mr});var C=g((ci,ft)=>{"use strict";var ot=["nodebuffer","arraybuffer","fragments"],at=typeof Blob<"u";at&&ot.push("blob");ft.exports={BINARY_TYPES:ot,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:at,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var wt=g((hi,bt)=>{var ut=p("fs"),N=p("path"),dt=p("os"),_t=typeof __webpack_require__=="function"?__non_webpack_require__:p,Ar=process.config&&process.config.variables||{},Fr=!!process.env.PREBUILDS_ONLY,lt=process.versions.modules,ve=jr()?"electron":Wr()?"node-webkit":"node",Ee=process.env.npm_config_arch||dt.arch(),be=process.env.npm_config_platform||dt.platform(),pt=process.env.LIBC||(Gr(be)?"musl":"glibc"),we=process.env.ARM_VERSION||(Ee==="arm64"?"8":Ar.arm_version)||"",mt=(process.versions.uv||"").split(".")[0];bt.exports=O;function O(r){return _t(O.resolve(r))}O.resolve=O.path=function(r){r=N.resolve(r||".");try{var e=_t(N.join(r,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[e+"_PREBUILD"]&&(r=process.env[e+"_PREBUILD"])}catch{}if(!Fr){var t=ct(N.join(r,"build/Release"),ht);if(t)return t;var s=ct(N.join(r,"build/Debug"),ht);if(s)return s}var i=f(r);if(i)return i;var n=f(N.dirname(process.execPath));if(n)return n;var o=["platform="+be,"arch="+Ee,"runtime="+ve,"abi="+lt,"uv="+mt,we?"armv="+we:"","libc="+pt,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+o+`
|
|
2
|
+
loaded from: `+r+`
|
|
3
|
+
`);function f(l){var a=Oe(N.join(l,"prebuilds")).map(yt),h=a.filter(gt(be,Ee)).sort(xt)[0];if(h){var u=N.join(l,"prebuilds",h.name),_=Oe(u).map(St),y=_.filter(vt(ve,lt)),m=y.sort(Et(ve))[0];if(m)return N.join(u,m.file)}}};function Oe(r){try{return ut.readdirSync(r)}catch{return[]}}function ct(r,e){var t=Oe(r).filter(e);return t[0]&&N.join(r,t[0])}function ht(r){return/\.node$/.test(r)}function yt(r){var e=r.split("-");if(e.length===2){var t=e[0],s=e[1].split("+");if(t&&s.length&&s.every(Boolean))return{name:r,platform:t,architectures:s}}}function gt(r,e){return function(t){return t==null||t.platform!==r?!1:t.architectures.includes(e)}}function xt(r,e){return r.architectures.length-e.architectures.length}function St(r){var e=r.split("."),t=e.pop(),s={file:r,specificity:0};if(t==="node"){for(var i=0;i<e.length;i++){var n=e[i];if(n==="node"||n==="electron"||n==="node-webkit")s.runtime=n;else if(n==="napi")s.napi=!0;else if(n.slice(0,3)==="abi")s.abi=n.slice(3);else if(n.slice(0,2)==="uv")s.uv=n.slice(2);else if(n.slice(0,4)==="armv")s.armv=n.slice(4);else if(n==="glibc"||n==="musl")s.libc=n;else continue;s.specificity++}return s}}function vt(r,e){return function(t){return!(t==null||t.runtime&&t.runtime!==r&&!qr(t)||t.abi&&t.abi!==e&&!t.napi||t.uv&&t.uv!==mt||t.armv&&t.armv!==we||t.libc&&t.libc!==pt)}}function qr(r){return r.runtime==="node"&&r.napi}function Et(r){return function(e,t){return e.runtime!==t.runtime?e.runtime===r?-1:1:e.abi!==t.abi?e.abi?-1:1:e.specificity!==t.specificity?e.specificity>t.specificity?-1:1:0}}function Wr(){return!!(process.versions&&process.versions.nw)}function jr(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<"u"&&window.process&&window.process.type==="renderer"}function Gr(r){return r==="linux"&&ut.existsSync("/etc/alpine-release")}O.parseTags=St;O.matchTags=vt;O.compareTags=Et;O.parseTuple=yt;O.matchTuple=gt;O.compareTuples=xt});var Ce=g((di,ke)=>{var Te=typeof __webpack_require__=="function"?__non_webpack_require__:p;typeof Te.addon=="function"?ke.exports=Te.addon.bind(Te):ke.exports=wt()});var Tt=g((pi,Ot)=>{"use strict";var $r=(r,e,t,s,i)=>{for(var n=0;n<i;n++)t[s+n]=r[n]^e[n&3]},Vr=(r,e)=>{let t=r.length;for(var s=0;s<t;s++)r[s]^=e[s&3]};Ot.exports={mask:$r,unmask:Vr}});var kt=g((mi,Ne)=>{"use strict";try{Ne.exports=Ce()(__dirname)}catch{Ne.exports=Tt()}});var Z=g((yi,oe)=>{"use strict";var{EMPTY_BUFFER:zr}=C(),Le=Buffer[Symbol.species];function Hr(r,e){if(r.length===0)return zr;if(r.length===1)return r[0];let t=Buffer.allocUnsafe(e),s=0;for(let i=0;i<r.length;i++){let n=r[i];t.set(n,s),s+=n.length}return s<e?new Le(t.buffer,t.byteOffset,s):t}function Ct(r,e,t,s,i){for(let n=0;n<i;n++)t[s+n]=r[n]^e[n&3]}function Nt(r,e){for(let t=0;t<r.length;t++)r[t]^=e[t&3]}function Yr(r){return r.length===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.length)}function Pe(r){if(Pe.readOnly=!0,Buffer.isBuffer(r))return r;let e;return r instanceof ArrayBuffer?e=new Le(r):ArrayBuffer.isView(r)?e=new Le(r.buffer,r.byteOffset,r.byteLength):(e=Buffer.from(r),Pe.readOnly=!1),e}oe.exports={concat:Hr,mask:Ct,toArrayBuffer:Yr,toBuffer:Pe,unmask:Nt};if(!process.env.WS_NO_BUFFER_UTIL)try{let r=kt();oe.exports.mask=function(e,t,s,i,n){n<48?Ct(e,t,s,i,n):r.mask(e,t,s,i,n)},oe.exports.unmask=function(e,t){e.length<32?Nt(e,t):r.unmask(e,t)}}catch{}});var Bt=g((gi,Pt)=>{"use strict";var Lt=Symbol("kDone"),Be=Symbol("kRun"),Re=class{constructor(e){this[Lt]=()=>{this.pending--,this[Be]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Be]()}[Be](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Lt])}}};Pt.exports=Re});var ee=g((xi,Dt)=>{"use strict";var Q=p("zlib"),Rt=Z(),Kr=Bt(),{kStatusCode:Ut}=C(),Xr=Buffer[Symbol.species],Zr=Buffer.from([0,0,255,255]),le=Symbol("permessage-deflate"),L=Symbol("total-length"),J=Symbol("callback"),R=Symbol("buffers"),fe=Symbol("error"),ae,Ue=class{constructor(e,t,s){if(this._maxPayload=s|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!ae){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ae=new Kr(i)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[J];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,s=e.find(i=>!(t.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>i.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(s.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?s.client_max_window_bits=t.clientMaxWindowBits:(s.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(s=>{let i=t[s];if(i.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(i=i[0],s==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else if(s==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${s}": ${i}`);i=n}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${i}`)}else throw new Error(`Unknown parameter "${s}"`);t[s]=i})}),e}decompress(e,t,s){ae.add(i=>{this._decompress(e,t,(n,o)=>{i(),s(n,o)})})}compress(e,t,s){ae.add(i=>{this._compress(e,t,(n,o)=>{i(),s(n,o)})})}_decompress(e,t,s){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Q.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Q.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[le]=this,this._inflate[L]=0,this._inflate[R]=[],this._inflate.on("error",Jr),this._inflate.on("data",It)}this._inflate[J]=s,this._inflate.write(e),t&&this._inflate.write(Zr),this._inflate.flush(()=>{let n=this._inflate[fe];if(n){this._inflate.close(),this._inflate=null,s(n);return}let o=Rt.concat(this._inflate[R],this._inflate[L]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[L]=0,this._inflate[R]=[],t&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),s(null,o)})}_compress(e,t,s){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Q.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Q.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[L]=0,this._deflate[R]=[],this._deflate.on("data",Qr)}this._deflate[J]=s,this._deflate.write(e),this._deflate.flush(Q.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Rt.concat(this._deflate[R],this._deflate[L]);t&&(n=new Xr(n.buffer,n.byteOffset,n.length-4)),this._deflate[J]=null,this._deflate[L]=0,this._deflate[R]=[],t&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),s(null,n)})}};Dt.exports=Ue;function Qr(r){this[R].push(r),this[L]+=r.length}function It(r){if(this[L]+=r.length,this[le]._maxPayload<1||this[L]<=this[le]._maxPayload){this[R].push(r);return}this[fe]=new RangeError("Max payload size exceeded"),this[fe].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[fe][Ut]=1009,this.removeListener("data",It),this.reset()}function Jr(r){this[le]._inflate=null,r[Ut]=1007,this[J](r)}});var At=g((Si,Mt)=>{"use strict";function es(r){let e=r.length,t=0;for(;t<e;)if(!(r[t]&128))t++;else if((r[t]&224)===192){if(t+1===e||(r[t+1]&192)!==128||(r[t]&254)===192)return!1;t+=2}else if((r[t]&240)===224){if(t+2>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||r[t]===224&&(r[t+1]&224)===128||r[t]===237&&(r[t+1]&224)===160)return!1;t+=3}else if((r[t]&248)===240){if(t+3>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||(r[t+3]&192)!==128||r[t]===240&&(r[t+1]&240)===128||r[t]===244&&r[t+1]>143||r[t]>244)return!1;t+=4}else return!1;return!0}Mt.exports=es});var Ft=g((vi,Ie)=>{"use strict";try{Ie.exports=Ce()(__dirname)}catch{Ie.exports=At()}});var j=g((Ei,ce)=>{"use strict";var{isUtf8:qt}=p("buffer"),{hasBlob:ts}=C(),rs=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function ss(r){return r>=1e3&&r<=1014&&r!==1004&&r!==1005&&r!==1006||r>=3e3&&r<=4999}function De(r){let e=r.length,t=0;for(;t<e;)if(!(r[t]&128))t++;else if((r[t]&224)===192){if(t+1===e||(r[t+1]&192)!==128||(r[t]&254)===192)return!1;t+=2}else if((r[t]&240)===224){if(t+2>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||r[t]===224&&(r[t+1]&224)===128||r[t]===237&&(r[t+1]&224)===160)return!1;t+=3}else if((r[t]&248)===240){if(t+3>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||(r[t+3]&192)!==128||r[t]===240&&(r[t+1]&240)===128||r[t]===244&&r[t+1]>143||r[t]>244)return!1;t+=4}else return!1;return!0}function is(r){return ts&&typeof r=="object"&&typeof r.arrayBuffer=="function"&&typeof r.type=="string"&&typeof r.stream=="function"&&(r[Symbol.toStringTag]==="Blob"||r[Symbol.toStringTag]==="File")}ce.exports={isBlob:is,isValidStatusCode:ss,isValidUTF8:De,tokenChars:rs};if(qt)ce.exports.isValidUTF8=function(r){return r.length<24?De(r):qt(r)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let r=Ft();ce.exports.isValidUTF8=function(e){return e.length<32?De(e):r(e)}}catch{}});var We=g((bi,Ht)=>{"use strict";var{Writable:ns}=p("stream"),Wt=ee(),{BINARY_TYPES:os,EMPTY_BUFFER:jt,kStatusCode:as,kWebSocket:fs}=C(),{concat:Me,toArrayBuffer:ls,unmask:cs}=Z(),{isValidStatusCode:hs,isValidUTF8:Gt}=j(),he=Buffer[Symbol.species],E=0,$t=1,Vt=2,zt=3,Ae=4,Fe=5,ue=6,qe=class extends ns{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||os[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[fs]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=E}_write(e,t,s){if(this._opcode===8&&this._state==E)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new he(s.buffer,s.byteOffset+e,s.length-e),new he(s.buffer,s.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let s=this._buffers[0],i=t.length-e;e>=s.length?t.set(this._buffers.shift(),i):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),i),this._buffers[0]=new he(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case E:this.getInfo(e);break;case $t:this.getPayloadLength16(e);break;case Vt:this.getPayloadLength64(e);break;case zt:this.getMask();break;case Ae:this.getData(e);break;case Fe:case ue:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let s=(t[0]&64)===64;if(s&&!this._extensions[Wt.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(s){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=$t:this._payloadLength===127?this._state=Vt:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),s=t.readUInt32BE(0);if(s>Math.pow(2,53-32)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=s*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=zt:this._state=Ae}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ae}getData(e){let t=jt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&cs(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=Fe,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[Wt.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return t(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(o);return}this._fragments.push(n)}this.dataMessage(t),this._state===E&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=E;return}let t=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Me(s,t):this._binaryType==="arraybuffer"?i=ls(Me(s,t)):this._binaryType==="blob"?i=new Blob(s):i=s,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=E):(this._state=ue,setImmediate(()=>{this.emit("message",i,!0),this._state=E,this.startLoop(e)}))}else{let i=Me(s,t);if(!this._skipUTF8Validation&&!Gt(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===Fe||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=E):(this._state=ue,setImmediate(()=>{this.emit("message",i,!1),this._state=E,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,jt),this.end();else{let s=e.readUInt16BE(0);if(!hs(s)){let n=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(n);return}let i=new he(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Gt(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(n);return}this._loop=!1,this.emit("conclude",s,i),this.end()}this._state=E;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=E):(this._state=ue,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=E,this.startLoop(t)}))}createError(e,t,s,i,n){this._loop=!1,this._errored=!0;let o=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(o,this.createError),o.code=n,o[as]=i,o}};Ht.exports=qe});var Ge=g((Oi,Xt)=>{"use strict";var{Duplex:wi}=p("stream"),{randomFillSync:us}=p("crypto"),Yt=ee(),{EMPTY_BUFFER:ds,kWebSocket:_s,NOOP:ps}=C(),{isBlob:G,isValidStatusCode:ms}=j(),{mask:Kt,toBuffer:I}=Z(),b=Symbol("kByteLength"),ys=Buffer.alloc(4),de=8*1024,D,$=de,w=0,gs=1,xs=2,T=class{constructor(e,t,s){this._extensions=t||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=ps,this[_s]=void 0}static frame(e,t){let s,i=!1,n=2,o=!1;t.mask&&(s=t.maskBuffer||ys,t.generateMask?t.generateMask(s):($===de&&(D===void 0&&(D=Buffer.alloc(de)),us(D,0,de),$=0),s[0]=D[$++],s[1]=D[$++],s[2]=D[$++],s[3]=D[$++]),o=(s[0]|s[1]|s[2]|s[3])===0,n=6);let f;typeof e=="string"?(!t.mask||o)&&t[b]!==void 0?f=t[b]:(e=Buffer.from(e),f=e.length):(f=e.length,i=t.mask&&t.readOnly&&!o);let l=f;f>=65536?(n+=8,l=127):f>125&&(n+=2,l=126);let a=Buffer.allocUnsafe(i?f+n:n);return a[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(a[0]|=64),a[1]=l,l===126?a.writeUInt16BE(f,2):l===127&&(a[2]=a[3]=0,a.writeUIntBE(f,4,6)),t.mask?(a[1]|=128,a[n-4]=s[0],a[n-3]=s[1],a[n-2]=s[2],a[n-1]=s[3],o?[a,e]:i?(Kt(e,s,a,n,f),[a]):(Kt(e,s,e,0,f),[a,e])):[a,e]}close(e,t,s,i){let n;if(e===void 0)n=ds;else{if(typeof e!="number"||!ms(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let f=Buffer.byteLength(t);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");n=Buffer.allocUnsafe(2+f),n.writeUInt16BE(e,0),typeof t=="string"?n.write(t,2):n.set(t,2)}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(T.frame(n,o),i)}ping(e,t,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):G(e)?(i=e.size,n=!1):(e=I(e),i=e.length,n=I.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};G(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==w?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(T.frame(e,o),s)}pong(e,t,s){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):G(e)?(i=e.size,n=!1):(e=I(e),i=e.length,n=I.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};G(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,s]):this.getBlobData(e,!1,o,s):this._state!==w?this.enqueue([this.dispatch,e,!1,o,s]):this.sendFrame(T.frame(e,o),s)}send(e,t,s){let i=this._extensions[Yt.extensionName],n=t.binary?2:1,o=t.compress,f,l;typeof e=="string"?(f=Buffer.byteLength(e),l=!1):G(e)?(f=e.size,l=!1):(e=I(e),f=e.length,l=I.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=f>=i._threshold),this._compress=o):(o=!1,n=0),t.fin&&(this._firstFragment=!0);let a={[b]:f,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};G(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,a,s]):this.getBlobData(e,this._compress,a,s):this._state!==w?this.enqueue([this.dispatch,e,this._compress,a,s]):this.dispatch(e,this._compress,a,s)}getBlobData(e,t,s,i){this._bufferedBytes+=s[b],this._state=xs,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(je,this,f,i);return}this._bufferedBytes-=s[b];let o=I(n);t?this.dispatch(o,t,s,i):(this._state=w,this.sendFrame(T.frame(o,s),i),this.dequeue())}).catch(n=>{process.nextTick(Ss,this,n,i)})}dispatch(e,t,s,i){if(!t){this.sendFrame(T.frame(e,s),i);return}let n=this._extensions[Yt.extensionName];this._bufferedBytes+=s[b],this._state=gs,n.compress(e,s.fin,(o,f)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");je(this,l,i);return}this._bufferedBytes-=s[b],this._state=w,s.readOnly=!1,this.sendFrame(T.frame(f,s),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};Xt.exports=T;function je(r,e,t){typeof t=="function"&&t(e);for(let s=0;s<r._queue.length;s++){let i=r._queue[s],n=i[i.length-1];typeof n=="function"&&n(e)}}function Ss(r,e,t){je(r,e,t),r.onerror(e)}});var nr=g((Ti,ir)=>{"use strict";var{kForOnEventAttribute:te,kListener:$e}=C(),Zt=Symbol("kCode"),Qt=Symbol("kData"),Jt=Symbol("kError"),er=Symbol("kMessage"),tr=Symbol("kReason"),V=Symbol("kTarget"),rr=Symbol("kType"),sr=Symbol("kWasClean"),P=class{constructor(e){this[V]=null,this[rr]=e}get target(){return this[V]}get type(){return this[rr]}};Object.defineProperty(P.prototype,"target",{enumerable:!0});Object.defineProperty(P.prototype,"type",{enumerable:!0});var M=class extends P{constructor(e,t={}){super(e),this[Zt]=t.code===void 0?0:t.code,this[tr]=t.reason===void 0?"":t.reason,this[sr]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Zt]}get reason(){return this[tr]}get wasClean(){return this[sr]}};Object.defineProperty(M.prototype,"code",{enumerable:!0});Object.defineProperty(M.prototype,"reason",{enumerable:!0});Object.defineProperty(M.prototype,"wasClean",{enumerable:!0});var z=class extends P{constructor(e,t={}){super(e),this[Jt]=t.error===void 0?null:t.error,this[er]=t.message===void 0?"":t.message}get error(){return this[Jt]}get message(){return this[er]}};Object.defineProperty(z.prototype,"error",{enumerable:!0});Object.defineProperty(z.prototype,"message",{enumerable:!0});var re=class extends P{constructor(e,t={}){super(e),this[Qt]=t.data===void 0?null:t.data}get data(){return this[Qt]}};Object.defineProperty(re.prototype,"data",{enumerable:!0});var vs={addEventListener(r,e,t={}){for(let i of this.listeners(r))if(!t[te]&&i[$e]===e&&!i[te])return;let s;if(r==="message")s=function(n,o){let f=new re("message",{data:o?n:n.toString()});f[V]=this,_e(e,this,f)};else if(r==="close")s=function(n,o){let f=new M("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[V]=this,_e(e,this,f)};else if(r==="error")s=function(n){let o=new z("error",{error:n,message:n.message});o[V]=this,_e(e,this,o)};else if(r==="open")s=function(){let n=new P("open");n[V]=this,_e(e,this,n)};else return;s[te]=!!t[te],s[$e]=e,t.once?this.once(r,s):this.on(r,s)},removeEventListener(r,e){for(let t of this.listeners(r))if(t[$e]===e&&!t[te]){this.removeListener(r,t);break}}};ir.exports={CloseEvent:M,ErrorEvent:z,Event:P,EventTarget:vs,MessageEvent:re};function _e(r,e,t){typeof r=="object"&&r.handleEvent?r.handleEvent.call(r,t):r.call(e,t)}});var Ve=g((ki,or)=>{"use strict";var{tokenChars:se}=j();function k(r,e,t){r[e]===void 0?r[e]=[t]:r[e].push(t)}function Es(r){let e=Object.create(null),t=Object.create(null),s=!1,i=!1,n=!1,o,f,l=-1,a=-1,h=-1,u=0;for(;u<r.length;u++)if(a=r.charCodeAt(u),o===void 0)if(h===-1&&se[a]===1)l===-1&&(l=u);else if(u!==0&&(a===32||a===9))h===-1&&l!==-1&&(h=u);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${u}`);h===-1&&(h=u);let y=r.slice(l,h);a===44?(k(e,y,t),t=Object.create(null)):o=y,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${u}`);else if(f===void 0)if(h===-1&&se[a]===1)l===-1&&(l=u);else if(a===32||a===9)h===-1&&l!==-1&&(h=u);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${u}`);h===-1&&(h=u),k(t,r.slice(l,h),!0),a===44&&(k(e,o,t),t=Object.create(null),o=void 0),l=h=-1}else if(a===61&&l!==-1&&h===-1)f=r.slice(l,u),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${u}`);else if(i){if(se[a]!==1)throw new SyntaxError(`Unexpected character at index ${u}`);l===-1?l=u:s||(s=!0),i=!1}else if(n)if(se[a]===1)l===-1&&(l=u);else if(a===34&&l!==-1)n=!1,h=u;else if(a===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${u}`);else if(a===34&&r.charCodeAt(u-1)===61)n=!0;else if(h===-1&&se[a]===1)l===-1&&(l=u);else if(l!==-1&&(a===32||a===9))h===-1&&(h=u);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${u}`);h===-1&&(h=u);let y=r.slice(l,h);s&&(y=y.replace(/\\/g,""),s=!1),k(t,f,y),a===44&&(k(e,o,t),t=Object.create(null),o=void 0),f=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${u}`);if(l===-1||n||a===32||a===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=u);let _=r.slice(l,h);return o===void 0?k(e,_,t):(f===void 0?k(t,_,!0):s?k(t,f,_.replace(/\\/g,"")):k(t,f,_),k(e,o,t)),e}function bs(r){return Object.keys(r).map(e=>{let t=r[e];return Array.isArray(t)||(t=[t]),t.map(s=>[e].concat(Object.keys(s).map(i=>{let n=s[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}or.exports={format:bs,parse:Es}});var Xe=g((Li,gr)=>{"use strict";var ws=p("events"),Os=p("https"),Ts=p("http"),lr=p("net"),ks=p("tls"),{randomBytes:Cs,createHash:Ns}=p("crypto"),{Duplex:Ci,Readable:Ni}=p("stream"),{URL:ze}=p("url"),U=ee(),Ls=We(),Ps=Ge(),{isBlob:Bs}=j(),{BINARY_TYPES:ar,EMPTY_BUFFER:pe,GUID:Rs,kForOnEventAttribute:He,kListener:Us,kStatusCode:Is,kWebSocket:x,NOOP:cr}=C(),{EventTarget:{addEventListener:Ds,removeEventListener:Ms}}=nr(),{format:As,parse:Fs}=Ve(),{toBuffer:qs}=Z(),Ws=30*1e3,hr=Symbol("kAborted"),Ye=[8,13],B=["CONNECTING","OPEN","CLOSING","CLOSED"],js=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,c=class extends ws{constructor(e,t,s){super(),this._binaryType=ar[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pe,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=c.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(s=t,t=[]):t=[t]),ur(this,e,t,s)):(this._autoPong=s.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){ar.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){let i=new Ls({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),n=new Ps(e,this._extensions,s.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[x]=this,n[x]=this,e[x]=this,i.on("conclude",Vs),i.on("drain",zs),i.on("error",Hs),i.on("message",Ys),i.on("ping",Ks),i.on("pong",Xs),n.onerror=Zs,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",pr),e.on("data",ye),e.on("end",mr),e.on("error",yr),this._readyState=c.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=c.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[U.extensionName]&&this._extensions[U.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=c.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==c.CLOSED){if(this.readyState===c.CONNECTING){let s="WebSocket was closed before the connection was established";v(this,this._req,s);return}if(this.readyState===c.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=c.CLOSING,this._sender.close(e,t,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),_r(this)}}pause(){this.readyState===c.CONNECTING||this.readyState===c.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,s){if(this.readyState===c.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=t=void 0):typeof t=="function"&&(s=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==c.OPEN){Ke(this,e,s);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||pe,t,s)}pong(e,t,s){if(this.readyState===c.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=t=void 0):typeof t=="function"&&(s=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==c.OPEN){Ke(this,e,s);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||pe,t,s)}resume(){this.readyState===c.CONNECTING||this.readyState===c.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,s){if(this.readyState===c.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(s=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==c.OPEN){Ke(this,e,s);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[U.extensionName]||(i.compress=!1),this._sender.send(e||pe,i,s)}terminate(){if(this.readyState!==c.CLOSED){if(this.readyState===c.CONNECTING){let e="WebSocket was closed before the connection was established";v(this,this._req,e);return}this._socket&&(this._readyState=c.CLOSING,this._socket.destroy())}}};Object.defineProperty(c,"CONNECTING",{enumerable:!0,value:B.indexOf("CONNECTING")});Object.defineProperty(c.prototype,"CONNECTING",{enumerable:!0,value:B.indexOf("CONNECTING")});Object.defineProperty(c,"OPEN",{enumerable:!0,value:B.indexOf("OPEN")});Object.defineProperty(c.prototype,"OPEN",{enumerable:!0,value:B.indexOf("OPEN")});Object.defineProperty(c,"CLOSING",{enumerable:!0,value:B.indexOf("CLOSING")});Object.defineProperty(c.prototype,"CLOSING",{enumerable:!0,value:B.indexOf("CLOSING")});Object.defineProperty(c,"CLOSED",{enumerable:!0,value:B.indexOf("CLOSED")});Object.defineProperty(c.prototype,"CLOSED",{enumerable:!0,value:B.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(r=>{Object.defineProperty(c.prototype,r,{enumerable:!0})});["open","error","close","message"].forEach(r=>{Object.defineProperty(c.prototype,`on${r}`,{enumerable:!0,get(){for(let e of this.listeners(r))if(e[He])return e[Us];return null},set(e){for(let t of this.listeners(r))if(t[He]){this.removeListener(r,t);break}typeof e=="function"&&this.addEventListener(r,e,{[He]:!0})}})});c.prototype.addEventListener=Ds;c.prototype.removeEventListener=Ms;gr.exports=c;function ur(r,e,t,s){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Ye[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(r._autoPong=i.autoPong,!Ye.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Ye.join(", ")})`);let n;if(e instanceof ze)n=e;else try{n=new ze(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),r._url=n.href;let o=n.protocol==="wss:",f=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!f?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`:f&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let d=new SyntaxError(l);if(r._redirects===0)throw d;me(r,d);return}let a=o?443:80,h=Cs(16).toString("base64"),u=o?Os.request:Ts.request,_=new Set,y;if(i.createConnection=i.createConnection||(o?$s:Gs),i.defaultPort=i.defaultPort||a,i.port=n.port||a,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(y=new U(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=As({[U.extensionName]:y.offer()})),t.length){for(let d of t){if(typeof d!="string"||!js.test(d)||_.has(d))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(d)}i.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),f){let d=i.path.split(":");i.socketPath=d[0],i.path=d[1]}let m;if(i.followRedirects){if(r._redirects===0){r._originalIpc=f,r._originalSecure=o,r._originalHostOrSocketPath=f?i.socketPath:n.host;let d=s&&s.headers;if(s={...s,headers:{}},d)for(let[S,q]of Object.entries(d))s.headers[S.toLowerCase()]=q}else if(r.listenerCount("redirect")===0){let d=f?r._originalIpc?i.socketPath===r._originalHostOrSocketPath:!1:r._originalIpc?!1:n.host===r._originalHostOrSocketPath;(!d||r._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,d||delete i.headers.host,i.auth=void 0)}i.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=r._req=u(i),r._redirects&&r.emit("redirect",r.url,m)}else m=r._req=u(i);i.timeout&&m.on("timeout",()=>{v(r,m,"Opening handshake has timed out")}),m.on("error",d=>{m===null||m[hr]||(m=r._req=null,me(r,d))}),m.on("response",d=>{let S=d.headers.location,q=d.statusCode;if(S&&i.followRedirects&&q>=300&&q<400){if(++r._redirects>i.maxRedirects){v(r,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new ze(S,e)}catch{let W=new SyntaxError(`Invalid URL: ${S}`);me(r,W);return}ur(r,Y,t,s)}else r.emit("unexpected-response",m,d)||v(r,m,`Unexpected server response: ${d.statusCode}`)}),m.on("upgrade",(d,S,q)=>{if(r.emit("upgrade",d),r.readyState!==c.CONNECTING)return;m=r._req=null;let Y=d.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){v(r,S,"Invalid Upgrade header");return}let Je=Ns("sha1").update(h+Rs).digest("base64");if(d.headers["sec-websocket-accept"]!==Je){v(r,S,"Invalid Sec-WebSocket-Accept header");return}let W=d.headers["sec-websocket-protocol"],K;if(W!==void 0?_.size?_.has(W)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){v(r,S,K);return}W&&(r._protocol=W);let et=d.headers["sec-websocket-extensions"];if(et!==void 0){if(!y){v(r,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let xe;try{xe=Fs(et)}catch{v(r,S,"Invalid Sec-WebSocket-Extensions header");return}let tt=Object.keys(xe);if(tt.length!==1||tt[0]!==U.extensionName){v(r,S,"Server indicated an extension that was not requested");return}try{y.accept(xe[U.extensionName])}catch{v(r,S,"Invalid Sec-WebSocket-Extensions header");return}r._extensions[U.extensionName]=y}r.setSocket(S,q,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,r):m.end()}function me(r,e){r._readyState=c.CLOSING,r._errorEmitted=!0,r.emit("error",e),r.emitClose()}function Gs(r){return r.path=r.socketPath,lr.connect(r)}function $s(r){return r.path=void 0,!r.servername&&r.servername!==""&&(r.servername=lr.isIP(r.host)?"":r.host),ks.connect(r)}function v(r,e,t){r._readyState=c.CLOSING;let s=new Error(t);Error.captureStackTrace(s,v),e.setHeader?(e[hr]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(me,r,s)):(e.destroy(s),e.once("error",r.emit.bind(r,"error")),e.once("close",r.emitClose.bind(r)))}function Ke(r,e,t){if(e){let s=Bs(e)?e.size:qs(e).length;r._socket?r._sender._bufferedBytes+=s:r._bufferedAmount+=s}if(t){let s=new Error(`WebSocket is not open: readyState ${r.readyState} (${B[r.readyState]})`);process.nextTick(t,s)}}function Vs(r,e){let t=this[x];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=r,t._socket[x]!==void 0&&(t._socket.removeListener("data",ye),process.nextTick(dr,t._socket),r===1005?t.close():t.close(r,e))}function zs(){let r=this[x];r.isPaused||r._socket.resume()}function Hs(r){let e=this[x];e._socket[x]!==void 0&&(e._socket.removeListener("data",ye),process.nextTick(dr,e._socket),e.close(r[Is])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",r))}function fr(){this[x].emitClose()}function Ys(r,e){this[x].emit("message",r,e)}function Ks(r){let e=this[x];e._autoPong&&e.pong(r,!this._isServer,cr),e.emit("ping",r)}function Xs(r){this[x].emit("pong",r)}function dr(r){r.resume()}function Zs(r){let e=this[x];e.readyState!==c.CLOSED&&(e.readyState===c.OPEN&&(e._readyState=c.CLOSING,_r(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",r)))}function _r(r){r._closeTimer=setTimeout(r._socket.destroy.bind(r._socket),Ws)}function pr(){let r=this[x];this.removeListener("close",pr),this.removeListener("data",ye),this.removeListener("end",mr),r._readyState=c.CLOSING;let e;!this._readableState.endEmitted&&!r._closeFrameReceived&&!r._receiver._writableState.errorEmitted&&(e=r._socket.read())!==null&&r._receiver.write(e),r._receiver.end(),this[x]=void 0,clearTimeout(r._closeTimer),r._receiver._writableState.finished||r._receiver._writableState.errorEmitted?r.emitClose():(r._receiver.on("error",fr),r._receiver.on("finish",fr))}function ye(r){this[x]._receiver.write(r)||this.pause()}function mr(){let r=this[x];r._readyState=c.CLOSING,r._receiver.end(),this.end()}function yr(){let r=this[x];this.removeListener("error",yr),this.on("error",cr),r&&(r._readyState=c.CLOSING,this.destroy())}});var Sr=g((Pi,xr)=>{"use strict";var{tokenChars:Qs}=j();function Js(r){let e=new Set,t=-1,s=-1,i=0;for(i;i<r.length;i++){let o=r.charCodeAt(i);if(s===-1&&Qs[o]===1)t===-1&&(t=i);else if(i!==0&&(o===32||o===9))s===-1&&t!==-1&&(s=i);else if(o===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${i}`);s===-1&&(s=i);let f=r.slice(t,s);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),t=s=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(t===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let n=r.slice(t,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}xr.exports={parse:Js}});var kr=g((Ri,Tr)=>{"use strict";var ei=p("events"),ge=p("http"),{Duplex:Bi}=p("stream"),{createHash:ti}=p("crypto"),vr=Ve(),A=ee(),ri=Sr(),si=Xe(),{GUID:ii,kWebSocket:ni}=C(),oi=/^[+/0-9A-Za-z]{22}==$/,Er=0,br=1,Or=2,Ze=class extends ei{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:si,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=ge.createServer((s,i)=>{let n=ge.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=ai(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Er}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Or){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ie,this);return}if(e&&this.once("close",e),this._state!==br)if(this._state=br,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(ie,this):process.nextTick(ie,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ie(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,i){t.on("error",wr);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){F(this,e,t,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){F(this,e,t,400,"Invalid Upgrade header");return}if(n===void 0||!oi.test(n)){F(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==8&&f!==13){F(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){ne(t,400);return}let l=e.headers["sec-websocket-protocol"],a=new Set;if(l!==void 0)try{a=ri.parse(l)}catch{F(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],u={};if(this.options.perMessageDeflate&&h!==void 0){let _=new A(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let y=vr.parse(h);y[A.extensionName]&&(_.accept(y[A.extensionName]),u[A.extensionName]=_)}catch{F(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(y,m,d,S)=>{if(!y)return ne(t,m||401,d,S);this.completeUpgrade(u,n,a,e,t,s,i)});return}if(!this.options.verifyClient(_))return ne(t,401)}this.completeUpgrade(u,n,a,e,t,s,i)}completeUpgrade(e,t,s,i,n,o,f){if(!n.readable||!n.writable)return n.destroy();if(n[ni])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Er)return ne(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ti("sha1").update(t+ii).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(s.size){let u=this.options.handleProtocols?this.options.handleProtocols(s,i):s.values().next().value;u&&(a.push(`Sec-WebSocket-Protocol: ${u}`),h._protocol=u)}if(e[A.extensionName]){let u=e[A.extensionName].params,_=vr.format({[A.extensionName]:[u]});a.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
4
|
+
`).join(`\r
|
|
5
|
+
`)),n.removeListener("error",wr),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ie,this)})),f(h,i)}};Tr.exports=Ze;function ai(r,e){for(let t of Object.keys(e))r.on(t,e[t]);return function(){for(let s of Object.keys(e))r.removeListener(s,e[s])}}function ie(r){r._state=Or,r.emit("close")}function wr(){this.destroy()}function ne(r,e,t,s){t=t||ge.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...s},r.once("finish",r.destroy),r.end(`HTTP/1.1 ${e} ${ge.STATUS_CODES[e]}\r
|
|
6
|
+
`+Object.keys(s).map(i=>`${i}: ${s[i]}`).join(`\r
|
|
7
|
+
`)+`\r
|
|
8
|
+
\r
|
|
9
|
+
`+t)}function F(r,e,t,s,i){if(r.listenerCount("wsClientError")){let n=new Error(i);Error.captureStackTrace(n,F),r.emit("wsClientError",n,t,e)}else ne(t,s,i)}});var Qe={};Ur(Qe,{Receiver:()=>Nr.default,Sender:()=>Lr.default,WebSocket:()=>H.default,WebSocketServer:()=>Pr.default,createWebSocketStream:()=>Cr.default,default:()=>fi});var Cr=X(nt(),1),Nr=X(We(),1),Lr=X(Ge(),1),H=X(Xe(),1),Pr=X(kr(),1);var fi=H.default;function Br(){if(typeof WebSocket<"u")return WebSocket;if(typeof global.WebSocket<"u")return global.WebSocket;if(typeof window.WebSocket<"u")return window.WebSocket;if(typeof self.WebSocket<"u")return self.WebSocket;throw new Error("`WebSocket` is not supported in this environment")}var Di=(()=>{try{return Br()}catch{return H.default?H.default:Qe}})();export{Di as WebSocket};
|
|
10
|
+
//# sourceMappingURL=_esm-DCAC27XZ.js.map
|