@metamask/utils 8.1.0 → 8.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -1
- package/dist/assert.js +16 -0
- package/dist/assert.js.map +1 -0
- package/dist/assert.mjs +16 -0
- package/dist/assert.mjs.map +1 -0
- package/dist/base64.js +11 -0
- package/dist/base64.js.map +1 -0
- package/dist/base64.mjs +11 -0
- package/dist/base64.mjs.map +1 -0
- package/dist/bytes.js +43 -0
- package/dist/bytes.js.map +1 -0
- package/dist/bytes.mjs +43 -0
- package/dist/bytes.mjs.map +1 -0
- package/dist/caip-types.js +40 -0
- package/dist/caip-types.js.map +1 -0
- package/dist/caip-types.mjs +40 -0
- package/dist/caip-types.mjs.map +1 -0
- package/dist/checksum.js +12 -0
- package/dist/checksum.js.map +1 -0
- package/dist/checksum.mjs +12 -0
- package/dist/checksum.mjs.map +1 -0
- package/dist/chunk-2LBGT4GH.js +15 -0
- package/dist/chunk-2LBGT4GH.js.map +1 -0
- package/dist/chunk-2TBCL6EF.js +1 -0
- package/dist/chunk-2TBCL6EF.js.map +1 -0
- package/dist/chunk-3W5G4CYI.js +25 -0
- package/dist/chunk-3W5G4CYI.js.map +1 -0
- package/dist/chunk-4D6XQBHA.js +69 -0
- package/dist/chunk-4D6XQBHA.js.map +1 -0
- package/dist/chunk-4RMX5YWE.js +34 -0
- package/dist/chunk-4RMX5YWE.js.map +1 -0
- package/dist/chunk-52OU772R.mjs +122 -0
- package/dist/chunk-52OU772R.mjs.map +1 -0
- package/dist/chunk-6C35XQOF.mjs +257 -0
- package/dist/chunk-6C35XQOF.mjs.map +1 -0
- package/dist/chunk-6NZW4WK4.js +35 -0
- package/dist/chunk-6NZW4WK4.js.map +1 -0
- package/dist/chunk-6ZDHSOUV.js +59 -0
- package/dist/chunk-6ZDHSOUV.js.map +1 -0
- package/dist/chunk-74DGVJVE.mjs +59 -0
- package/dist/chunk-74DGVJVE.mjs.map +1 -0
- package/dist/chunk-AY6FDCBT.mjs +1 -0
- package/dist/chunk-AY6FDCBT.mjs.map +1 -0
- package/dist/chunk-BFQDMI3M.js +122 -0
- package/dist/chunk-BFQDMI3M.js.map +1 -0
- package/dist/chunk-DHVKFDHQ.js +95 -0
- package/dist/chunk-DHVKFDHQ.js.map +1 -0
- package/dist/chunk-DYMCEQIV.mjs +1 -0
- package/dist/chunk-DYMCEQIV.mjs.map +1 -0
- package/dist/chunk-E4C7EW4R.js +16 -0
- package/dist/chunk-E4C7EW4R.js.map +1 -0
- package/dist/chunk-EQMZL4XU.js +1 -0
- package/dist/chunk-EQMZL4XU.js.map +1 -0
- package/dist/chunk-GZS3IQBZ.mjs +16 -0
- package/dist/chunk-GZS3IQBZ.mjs.map +1 -0
- package/dist/chunk-H4YFDLB7.mjs +70 -0
- package/dist/chunk-H4YFDLB7.mjs.map +1 -0
- package/dist/chunk-I575FZFH.mjs +1 -0
- package/dist/chunk-I575FZFH.mjs.map +1 -0
- package/dist/chunk-IZC266HS.js +55 -0
- package/dist/chunk-IZC266HS.js.map +1 -0
- package/dist/chunk-JPAL7Q5S.mjs +90 -0
- package/dist/chunk-JPAL7Q5S.mjs.map +1 -0
- package/dist/chunk-LC2CRSWD.js +1 -0
- package/dist/chunk-LC2CRSWD.js.map +1 -0
- package/dist/chunk-NQMRFZHB.mjs +35 -0
- package/dist/chunk-NQMRFZHB.mjs.map +1 -0
- package/dist/chunk-O3EIM33O.mjs +95 -0
- package/dist/chunk-O3EIM33O.mjs.map +1 -0
- package/dist/chunk-OLLG4H35.js +257 -0
- package/dist/chunk-OLLG4H35.js.map +1 -0
- package/dist/chunk-QEPVHEP7.js +273 -0
- package/dist/chunk-QEPVHEP7.js.map +1 -0
- package/dist/chunk-QVEKZRZ2.js +70 -0
- package/dist/chunk-QVEKZRZ2.js.map +1 -0
- package/dist/chunk-RIRDOQPX.mjs +15 -0
- package/dist/chunk-RIRDOQPX.mjs.map +1 -0
- package/dist/chunk-RKRGAFXY.js +1 -0
- package/dist/chunk-RKRGAFXY.js.map +1 -0
- package/dist/chunk-ROQSKDP5.mjs +69 -0
- package/dist/chunk-ROQSKDP5.mjs.map +1 -0
- package/dist/chunk-RRYOWRCV.mjs +1 -0
- package/dist/chunk-RRYOWRCV.mjs.map +1 -0
- package/dist/chunk-S3UHBN2Z.mjs +44 -0
- package/dist/chunk-S3UHBN2Z.mjs.map +1 -0
- package/dist/chunk-TGOMTREC.mjs +75 -0
- package/dist/chunk-TGOMTREC.mjs.map +1 -0
- package/dist/chunk-THNLGEXV.mjs +34 -0
- package/dist/chunk-THNLGEXV.mjs.map +1 -0
- package/dist/chunk-U7ZUGCE7.js +75 -0
- package/dist/chunk-U7ZUGCE7.js.map +1 -0
- package/dist/chunk-UOTVU7OQ.js +1 -0
- package/dist/chunk-UOTVU7OQ.js.map +1 -0
- package/dist/chunk-VA2DRBDE.mjs +273 -0
- package/dist/chunk-VA2DRBDE.mjs.map +1 -0
- package/dist/chunk-VFXTVNXN.js +44 -0
- package/dist/chunk-VFXTVNXN.js.map +1 -0
- package/dist/chunk-WA4DHIND.mjs +1 -0
- package/dist/chunk-WA4DHIND.mjs.map +1 -0
- package/dist/chunk-X66SUIEF.mjs +25 -0
- package/dist/chunk-X66SUIEF.mjs.map +1 -0
- package/dist/chunk-XYGUOY6N.mjs +55 -0
- package/dist/chunk-XYGUOY6N.mjs.map +1 -0
- package/dist/chunk-Z2RGWDD7.js +90 -0
- package/dist/chunk-Z2RGWDD7.js.map +1 -0
- package/dist/coercers.js +18 -0
- package/dist/coercers.js.map +1 -0
- package/dist/coercers.mjs +18 -0
- package/dist/coercers.mjs.map +1 -0
- package/dist/collections.js +10 -0
- package/dist/collections.js.map +1 -0
- package/dist/collections.mjs +10 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/encryption-types.js +2 -0
- package/dist/encryption-types.js.map +1 -0
- package/dist/encryption-types.mjs +2 -0
- package/dist/encryption-types.mjs.map +1 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +17 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/fs.js +26 -0
- package/dist/fs.js.map +1 -0
- package/dist/fs.mjs +26 -0
- package/dist/fs.mjs.map +1 -0
- package/dist/hex.js +35 -0
- package/dist/hex.js.map +1 -0
- package/dist/hex.mjs +35 -0
- package/dist/hex.mjs.map +1 -0
- package/dist/index.js +289 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +289 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json.js +75 -0
- package/dist/json.js.map +1 -0
- package/dist/json.mjs +75 -0
- package/dist/json.mjs.map +1 -0
- package/dist/keyring.js +2 -0
- package/dist/keyring.js.map +1 -0
- package/dist/keyring.mjs +2 -0
- package/dist/keyring.mjs.map +1 -0
- package/dist/logging.js +10 -0
- package/dist/logging.js.map +1 -0
- package/dist/logging.mjs +10 -0
- package/dist/logging.mjs.map +1 -0
- package/dist/misc.js +28 -0
- package/dist/misc.js.map +1 -0
- package/dist/misc.mjs +28 -0
- package/dist/misc.mjs.map +1 -0
- package/dist/node.js +309 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +309 -0
- package/dist/node.mjs.map +1 -0
- package/dist/number.js +18 -0
- package/dist/number.js.map +1 -0
- package/dist/number.mjs +18 -0
- package/dist/number.mjs.map +1 -0
- package/dist/opaque.js +2 -0
- package/dist/opaque.js.map +1 -0
- package/dist/opaque.mjs +2 -0
- package/dist/opaque.mjs.map +1 -0
- package/dist/time.js +12 -0
- package/dist/time.js.map +1 -0
- package/dist/time.mjs +12 -0
- package/dist/time.mjs.map +1 -0
- package/dist/transaction-types.js +2 -0
- package/dist/transaction-types.js.map +1 -0
- package/dist/transaction-types.mjs +2 -0
- package/dist/transaction-types.mjs.map +1 -0
- package/dist/types/assert.d.ts.map +1 -1
- package/dist/types/bytes.d.ts +14 -0
- package/dist/types/bytes.d.ts.map +1 -1
- package/dist/types/errors.d.ts +58 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/fs.d.ts +133 -0
- package/dist/types/fs.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/json.d.ts +83 -44
- package/dist/types/json.d.ts.map +1 -1
- package/dist/types/node.d.ts +3 -0
- package/dist/types/node.d.ts.map +1 -0
- package/dist/versions.js +27 -0
- package/dist/versions.js.map +1 -0
- package/dist/versions.mjs +27 -0
- package/dist/versions.mjs.map +1 -0
- package/package.json +22 -21
- package/dist/cjs/assert.js +0 -116
- package/dist/cjs/assert.js.map +0 -1
- package/dist/cjs/base64.js +0 -32
- package/dist/cjs/base64.js.map +0 -1
- package/dist/cjs/bytes.js +0 -255
- package/dist/cjs/bytes.js.map +0 -1
- package/dist/cjs/caip-types.js +0 -115
- package/dist/cjs/caip-types.js.map +0 -1
- package/dist/cjs/checksum.js +0 -17
- package/dist/cjs/checksum.js.map +0 -1
- package/dist/cjs/coercers.js +0 -96
- package/dist/cjs/coercers.js.map +0 -1
- package/dist/cjs/collections.js +0 -157
- package/dist/cjs/collections.js.map +0 -1
- package/dist/cjs/encryption-types.js +0 -6
- package/dist/cjs/encryption-types.js.map +0 -1
- package/dist/cjs/hex.js +0 -107
- package/dist/cjs/hex.js.map +0 -1
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json.js +0 -265
- package/dist/cjs/json.js.map +0 -1
- package/dist/cjs/keyring.js +0 -6
- package/dist/cjs/keyring.js.map +0 -1
- package/dist/cjs/logging.js +0 -33
- package/dist/cjs/logging.js.map +0 -1
- package/dist/cjs/misc.js +0 -111
- package/dist/cjs/misc.js.map +0 -1
- package/dist/cjs/number.js +0 -52
- package/dist/cjs/number.js.map +0 -1
- package/dist/cjs/opaque.js +0 -8
- package/dist/cjs/opaque.js.map +0 -1
- package/dist/cjs/time.js +0 -63
- package/dist/cjs/time.js.map +0 -1
- package/dist/cjs/transaction-types.js +0 -6
- package/dist/cjs/transaction-types.js.map +0 -1
- package/dist/cjs/versions.js +0 -79
- package/dist/cjs/versions.js.map +0 -1
- package/dist/esm/assert.js +0 -133
- package/dist/esm/assert.js.map +0 -1
- package/dist/esm/base64.js +0 -28
- package/dist/esm/base64.js.map +0 -1
- package/dist/esm/bytes.js +0 -334
- package/dist/esm/bytes.js.map +0 -1
- package/dist/esm/caip-types.js +0 -99
- package/dist/esm/caip-types.js.map +0 -1
- package/dist/esm/checksum.js +0 -7
- package/dist/esm/checksum.js.map +0 -1
- package/dist/esm/coercers.js +0 -153
- package/dist/esm/coercers.js.map +0 -1
- package/dist/esm/collections.js +0 -140
- package/dist/esm/collections.js.map +0 -1
- package/dist/esm/encryption-types.js +0 -3
- package/dist/esm/encryption-types.js.map +0 -1
- package/dist/esm/hex.js +0 -108
- package/dist/esm/hex.js.map +0 -1
- package/dist/esm/index.js +0 -20
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json.js +0 -303
- package/dist/esm/json.js.map +0 -1
- package/dist/esm/keyring.js +0 -3
- package/dist/esm/keyring.js.map +0 -1
- package/dist/esm/logging.js +0 -34
- package/dist/esm/logging.js.map +0 -1
- package/dist/esm/misc.js +0 -129
- package/dist/esm/misc.js.map +0 -1
- package/dist/esm/number.js +0 -92
- package/dist/esm/number.js.map +0 -1
- package/dist/esm/opaque.js +0 -5
- package/dist/esm/opaque.js.map +0 -1
- package/dist/esm/package.json +0 -1
- package/dist/esm/time.js +0 -53
- package/dist/esm/time.js.map +0 -1
- package/dist/esm/transaction-types.js +0 -3
- package/dist/esm/transaction-types.js.map +0 -1
- package/dist/esm/versions.js +0 -78
- package/dist/esm/versions.js.map +0 -1
- package/dist/types/caip-types.test-d.d.ts +0 -2
- package/dist/types/caip-types.test-d.d.ts.map +0 -1
- package/dist/types/hex.test-d.d.ts +0 -2
- package/dist/types/hex.test-d.d.ts.map +0 -1
- package/dist/types/json.test-d.d.ts +0 -2
- package/dist/types/json.test-d.d.ts.map +0 -1
- package/dist/types/misc.test-d.d.ts +0 -2
- package/dist/types/misc.test-d.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [8.2.1]
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fix issue with source maps where line numbers were incorrect for src/error.ts ([#156](https://github.com/MetaMask/utils/pull/156))
|
|
12
|
+
|
|
13
|
+
## [8.2.0]
|
|
14
|
+
### Added
|
|
15
|
+
- Add struct utils for validating JSON objects with optional values ([#136](https://github.com/MetaMask/utils/pull/136))
|
|
16
|
+
- Add filesystem utils ([#148](https://github.com/MetaMask/utils/pull/148))
|
|
17
|
+
- Add error utils ([#146](https://github.com/MetaMask/utils/pull/146), [#151](https://github.com/MetaMask/utils/pull/151))
|
|
18
|
+
- Add base64 encoding and decoding functions ([#145](https://github.com/MetaMask/utils/pull/145))
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Use `tsup` for bundling ([#144](https://github.com/MetaMask/utils/pull/144))
|
|
22
|
+
- This makes the package fully compliant with ES modules.
|
|
23
|
+
- Bump `@ethereumjs/tx` from `4.1.2` to `4.2.0` ([#133](https://github.com/MetaMask/utils/pull/133))
|
|
24
|
+
|
|
9
25
|
## [8.1.0]
|
|
10
26
|
### Changed
|
|
11
27
|
- Make types for JSON-RPC-related structs more accurate ([#134](https://github.com/MetaMask/utils/pull/134))
|
|
@@ -192,7 +208,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
192
208
|
### Added
|
|
193
209
|
- Initial release
|
|
194
210
|
|
|
195
|
-
[Unreleased]: https://github.com/MetaMask/utils/compare/v8.1
|
|
211
|
+
[Unreleased]: https://github.com/MetaMask/utils/compare/v8.2.1...HEAD
|
|
212
|
+
[8.2.1]: https://github.com/MetaMask/utils/compare/v8.2.0...v8.2.1
|
|
213
|
+
[8.2.0]: https://github.com/MetaMask/utils/compare/v8.1.0...v8.2.0
|
|
196
214
|
[8.1.0]: https://github.com/MetaMask/utils/compare/v8.0.0...v8.1.0
|
|
197
215
|
[8.0.0]: https://github.com/MetaMask/utils/compare/v7.1.0...v8.0.0
|
|
198
216
|
[7.1.0]: https://github.com/MetaMask/utils/compare/v7.0.0...v7.1.0
|
package/dist/assert.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunk6ZDHSOUVjs = require('./chunk-6ZDHSOUV.js');
|
|
7
|
+
require('./chunk-IZC266HS.js');
|
|
8
|
+
require('./chunk-QVEKZRZ2.js');
|
|
9
|
+
require('./chunk-3W5G4CYI.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.AssertionError = _chunk6ZDHSOUVjs.AssertionError; exports.assert = _chunk6ZDHSOUVjs.assert; exports.assertExhaustive = _chunk6ZDHSOUVjs.assertExhaustive; exports.assertStruct = _chunk6ZDHSOUVjs.assertStruct;
|
|
16
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/assert.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssertionError,
|
|
3
|
+
assert,
|
|
4
|
+
assertExhaustive,
|
|
5
|
+
assertStruct
|
|
6
|
+
} from "./chunk-74DGVJVE.mjs";
|
|
7
|
+
import "./chunk-XYGUOY6N.mjs";
|
|
8
|
+
import "./chunk-H4YFDLB7.mjs";
|
|
9
|
+
import "./chunk-X66SUIEF.mjs";
|
|
10
|
+
export {
|
|
11
|
+
AssertionError,
|
|
12
|
+
assert,
|
|
13
|
+
assertExhaustive,
|
|
14
|
+
assertStruct
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=assert.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/base64.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk6NZW4WK4js = require('./chunk-6NZW4WK4.js');
|
|
4
|
+
require('./chunk-6ZDHSOUV.js');
|
|
5
|
+
require('./chunk-IZC266HS.js');
|
|
6
|
+
require('./chunk-QVEKZRZ2.js');
|
|
7
|
+
require('./chunk-3W5G4CYI.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.base64 = _chunk6NZW4WK4js.base64;
|
|
11
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/base64.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkQEPVHEP7js = require('./chunk-QEPVHEP7.js');
|
|
20
|
+
require('./chunk-6ZDHSOUV.js');
|
|
21
|
+
require('./chunk-IZC266HS.js');
|
|
22
|
+
require('./chunk-QVEKZRZ2.js');
|
|
23
|
+
require('./chunk-3W5G4CYI.js');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
exports.assertIsBytes = _chunkQEPVHEP7js.assertIsBytes; exports.base64ToBytes = _chunkQEPVHEP7js.base64ToBytes; exports.bigIntToBytes = _chunkQEPVHEP7js.bigIntToBytes; exports.bytesToBase64 = _chunkQEPVHEP7js.bytesToBase64; exports.bytesToBigInt = _chunkQEPVHEP7js.bytesToBigInt; exports.bytesToHex = _chunkQEPVHEP7js.bytesToHex; exports.bytesToNumber = _chunkQEPVHEP7js.bytesToNumber; exports.bytesToSignedBigInt = _chunkQEPVHEP7js.bytesToSignedBigInt; exports.bytesToString = _chunkQEPVHEP7js.bytesToString; exports.concatBytes = _chunkQEPVHEP7js.concatBytes; exports.createDataView = _chunkQEPVHEP7js.createDataView; exports.hexToBytes = _chunkQEPVHEP7js.hexToBytes; exports.isBytes = _chunkQEPVHEP7js.isBytes; exports.numberToBytes = _chunkQEPVHEP7js.numberToBytes; exports.signedBigIntToBytes = _chunkQEPVHEP7js.signedBigIntToBytes; exports.stringToBytes = _chunkQEPVHEP7js.stringToBytes; exports.valueToBytes = _chunkQEPVHEP7js.valueToBytes;
|
|
43
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/bytes.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertIsBytes,
|
|
3
|
+
base64ToBytes,
|
|
4
|
+
bigIntToBytes,
|
|
5
|
+
bytesToBase64,
|
|
6
|
+
bytesToBigInt,
|
|
7
|
+
bytesToHex,
|
|
8
|
+
bytesToNumber,
|
|
9
|
+
bytesToSignedBigInt,
|
|
10
|
+
bytesToString,
|
|
11
|
+
concatBytes,
|
|
12
|
+
createDataView,
|
|
13
|
+
hexToBytes,
|
|
14
|
+
isBytes,
|
|
15
|
+
numberToBytes,
|
|
16
|
+
signedBigIntToBytes,
|
|
17
|
+
stringToBytes,
|
|
18
|
+
valueToBytes
|
|
19
|
+
} from "./chunk-VA2DRBDE.mjs";
|
|
20
|
+
import "./chunk-74DGVJVE.mjs";
|
|
21
|
+
import "./chunk-XYGUOY6N.mjs";
|
|
22
|
+
import "./chunk-H4YFDLB7.mjs";
|
|
23
|
+
import "./chunk-X66SUIEF.mjs";
|
|
24
|
+
export {
|
|
25
|
+
assertIsBytes,
|
|
26
|
+
base64ToBytes,
|
|
27
|
+
bigIntToBytes,
|
|
28
|
+
bytesToBase64,
|
|
29
|
+
bytesToBigInt,
|
|
30
|
+
bytesToHex,
|
|
31
|
+
bytesToNumber,
|
|
32
|
+
bytesToSignedBigInt,
|
|
33
|
+
bytesToString,
|
|
34
|
+
concatBytes,
|
|
35
|
+
createDataView,
|
|
36
|
+
hexToBytes,
|
|
37
|
+
isBytes,
|
|
38
|
+
numberToBytes,
|
|
39
|
+
signedBigIntToBytes,
|
|
40
|
+
stringToBytes,
|
|
41
|
+
valueToBytes
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=bytes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkU7ZUGCE7js = require('./chunk-U7ZUGCE7.js');
|
|
20
|
+
require('./chunk-3W5G4CYI.js');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
exports.CAIP_ACCOUNT_ADDRESS_REGEX = _chunkU7ZUGCE7js.CAIP_ACCOUNT_ADDRESS_REGEX; exports.CAIP_ACCOUNT_ID_REGEX = _chunkU7ZUGCE7js.CAIP_ACCOUNT_ID_REGEX; exports.CAIP_CHAIN_ID_REGEX = _chunkU7ZUGCE7js.CAIP_CHAIN_ID_REGEX; exports.CAIP_NAMESPACE_REGEX = _chunkU7ZUGCE7js.CAIP_NAMESPACE_REGEX; exports.CAIP_REFERENCE_REGEX = _chunkU7ZUGCE7js.CAIP_REFERENCE_REGEX; exports.CaipAccountAddressStruct = _chunkU7ZUGCE7js.CaipAccountAddressStruct; exports.CaipAccountIdStruct = _chunkU7ZUGCE7js.CaipAccountIdStruct; exports.CaipChainIdStruct = _chunkU7ZUGCE7js.CaipChainIdStruct; exports.CaipNamespaceStruct = _chunkU7ZUGCE7js.CaipNamespaceStruct; exports.CaipReferenceStruct = _chunkU7ZUGCE7js.CaipReferenceStruct; exports.isCaipAccountAddress = _chunkU7ZUGCE7js.isCaipAccountAddress; exports.isCaipAccountId = _chunkU7ZUGCE7js.isCaipAccountId; exports.isCaipChainId = _chunkU7ZUGCE7js.isCaipChainId; exports.isCaipNamespace = _chunkU7ZUGCE7js.isCaipNamespace; exports.isCaipReference = _chunkU7ZUGCE7js.isCaipReference; exports.parseCaipAccountId = _chunkU7ZUGCE7js.parseCaipAccountId; exports.parseCaipChainId = _chunkU7ZUGCE7js.parseCaipChainId;
|
|
40
|
+
//# sourceMappingURL=caip-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CAIP_ACCOUNT_ADDRESS_REGEX,
|
|
3
|
+
CAIP_ACCOUNT_ID_REGEX,
|
|
4
|
+
CAIP_CHAIN_ID_REGEX,
|
|
5
|
+
CAIP_NAMESPACE_REGEX,
|
|
6
|
+
CAIP_REFERENCE_REGEX,
|
|
7
|
+
CaipAccountAddressStruct,
|
|
8
|
+
CaipAccountIdStruct,
|
|
9
|
+
CaipChainIdStruct,
|
|
10
|
+
CaipNamespaceStruct,
|
|
11
|
+
CaipReferenceStruct,
|
|
12
|
+
isCaipAccountAddress,
|
|
13
|
+
isCaipAccountId,
|
|
14
|
+
isCaipChainId,
|
|
15
|
+
isCaipNamespace,
|
|
16
|
+
isCaipReference,
|
|
17
|
+
parseCaipAccountId,
|
|
18
|
+
parseCaipChainId
|
|
19
|
+
} from "./chunk-TGOMTREC.mjs";
|
|
20
|
+
import "./chunk-X66SUIEF.mjs";
|
|
21
|
+
export {
|
|
22
|
+
CAIP_ACCOUNT_ADDRESS_REGEX,
|
|
23
|
+
CAIP_ACCOUNT_ID_REGEX,
|
|
24
|
+
CAIP_CHAIN_ID_REGEX,
|
|
25
|
+
CAIP_NAMESPACE_REGEX,
|
|
26
|
+
CAIP_REFERENCE_REGEX,
|
|
27
|
+
CaipAccountAddressStruct,
|
|
28
|
+
CaipAccountIdStruct,
|
|
29
|
+
CaipChainIdStruct,
|
|
30
|
+
CaipNamespaceStruct,
|
|
31
|
+
CaipReferenceStruct,
|
|
32
|
+
isCaipAccountAddress,
|
|
33
|
+
isCaipAccountId,
|
|
34
|
+
isCaipChainId,
|
|
35
|
+
isCaipNamespace,
|
|
36
|
+
isCaipReference,
|
|
37
|
+
parseCaipAccountId,
|
|
38
|
+
parseCaipChainId
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=caip-types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/checksum.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkE4C7EW4Rjs = require('./chunk-E4C7EW4R.js');
|
|
4
|
+
require('./chunk-6NZW4WK4.js');
|
|
5
|
+
require('./chunk-6ZDHSOUV.js');
|
|
6
|
+
require('./chunk-IZC266HS.js');
|
|
7
|
+
require('./chunk-QVEKZRZ2.js');
|
|
8
|
+
require('./chunk-3W5G4CYI.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.ChecksumStruct = _chunkE4C7EW4Rjs.ChecksumStruct;
|
|
12
|
+
//# sourceMappingURL=checksum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChecksumStruct
|
|
3
|
+
} from "./chunk-GZS3IQBZ.mjs";
|
|
4
|
+
import "./chunk-NQMRFZHB.mjs";
|
|
5
|
+
import "./chunk-74DGVJVE.mjs";
|
|
6
|
+
import "./chunk-XYGUOY6N.mjs";
|
|
7
|
+
import "./chunk-H4YFDLB7.mjs";
|
|
8
|
+
import "./chunk-X66SUIEF.mjs";
|
|
9
|
+
export {
|
|
10
|
+
ChecksumStruct
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=checksum.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/logging.ts
|
|
2
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
3
|
+
var globalLogger = _debug2.default.call(void 0, "metamask");
|
|
4
|
+
function createProjectLogger(projectName) {
|
|
5
|
+
return globalLogger.extend(projectName);
|
|
6
|
+
}
|
|
7
|
+
function createModuleLogger(projectLogger, moduleName) {
|
|
8
|
+
return projectLogger.extend(moduleName);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.createProjectLogger = createProjectLogger; exports.createModuleLogger = createModuleLogger;
|
|
15
|
+
//# sourceMappingURL=chunk-2LBGT4GH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/logging.ts"],"names":[],"mappings":";AACA,OAAO,WAAW;AAElB,IAAM,eAAe,MAAM,UAAU;AAc9B,SAAS,oBAAoB,aAA+B;AACjE,SAAO,aAAa,OAAO,WAAW;AACxC;AAgBO,SAAS,mBACd,eACA,YACU;AACV,SAAO,cAAc,OAAO,UAAU;AACxC","sourcesContent":["import type { Debugger } from 'debug';\nimport debug from 'debug';\n\nconst globalLogger = debug('metamask');\n\n/**\n * Creates a logger via the `debug` library whose log messages will be tagged\n * using the name of your project. By default, such messages will be\n * suppressed, but you can reveal them by setting the `DEBUG` environment\n * variable to `metamask:<projectName>`. You can also set this variable to\n * `metamask:*` if you want to see log messages from all MetaMask projects that\n * are also using this function to create their loggers.\n *\n * @param projectName - The name of your project. This should be the name of\n * your NPM package if you're developing one.\n * @returns An instance of `debug`.\n */\nexport function createProjectLogger(projectName: string): Debugger {\n return globalLogger.extend(projectName);\n}\n\n/**\n * Creates a logger via the `debug` library which is derived from the logger for\n * the whole project whose log messages will be tagged using the name of your\n * module. By default, such messages will be suppressed, but you can reveal them\n * by setting the `DEBUG` environment variable to\n * `metamask:<projectName>:<moduleName>`. You can also set this variable to\n * `metamask:<projectName>:*` if you want to see log messages from the project,\n * or `metamask:*` if you want to see log messages from all MetaMask projects.\n *\n * @param projectLogger - The logger created via {@link createProjectLogger}.\n * @param moduleName - The name of your module. You could use the name of the\n * file where you're using this logger or some other name.\n * @returns An instance of `debug`.\n */\nexport function createModuleLogger(\n projectLogger: Debugger,\n moduleName: string,\n): Debugger {\n return projectLogger.extend(moduleName);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-2TBCL6EF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet;
|
|
25
|
+
//# sourceMappingURL=chunk-3W5G4CYI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunk6ZDHSOUVjs = require('./chunk-6ZDHSOUV.js');
|
|
4
|
+
|
|
5
|
+
// src/versions.ts
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _semver = require('semver');
|
|
13
|
+
var _superstruct = require('superstruct');
|
|
14
|
+
var VersionStruct = _superstruct.refine.call(void 0,
|
|
15
|
+
_superstruct.string.call(void 0, ),
|
|
16
|
+
"Version",
|
|
17
|
+
(value) => {
|
|
18
|
+
if (_semver.valid.call(void 0, value) === null) {
|
|
19
|
+
return `Expected SemVer version, got "${value}"`;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
var VersionRangeStruct = _superstruct.refine.call(void 0,
|
|
25
|
+
_superstruct.string.call(void 0, ),
|
|
26
|
+
"Version range",
|
|
27
|
+
(value) => {
|
|
28
|
+
if (_semver.validRange.call(void 0, value) === null) {
|
|
29
|
+
return `Expected SemVer range, got "${value}"`;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
function isValidSemVerVersion(version) {
|
|
35
|
+
return _superstruct.is.call(void 0, version, VersionStruct);
|
|
36
|
+
}
|
|
37
|
+
function isValidSemVerRange(versionRange) {
|
|
38
|
+
return _superstruct.is.call(void 0, versionRange, VersionRangeStruct);
|
|
39
|
+
}
|
|
40
|
+
function assertIsSemVerVersion(version) {
|
|
41
|
+
_chunk6ZDHSOUVjs.assertStruct.call(void 0, version, VersionStruct);
|
|
42
|
+
}
|
|
43
|
+
function assertIsSemVerRange(range) {
|
|
44
|
+
_chunk6ZDHSOUVjs.assertStruct.call(void 0, range, VersionRangeStruct);
|
|
45
|
+
}
|
|
46
|
+
function gtVersion(version1, version2) {
|
|
47
|
+
return _semver.gt.call(void 0, version1, version2);
|
|
48
|
+
}
|
|
49
|
+
function gtRange(version, range) {
|
|
50
|
+
return _semver.gtr.call(void 0, version, range);
|
|
51
|
+
}
|
|
52
|
+
function satisfiesVersionRange(version, versionRange) {
|
|
53
|
+
return _semver.satisfies.call(void 0, version, versionRange, {
|
|
54
|
+
includePrerelease: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
exports.VersionStruct = VersionStruct; exports.VersionRangeStruct = VersionRangeStruct; exports.isValidSemVerVersion = isValidSemVerVersion; exports.isValidSemVerRange = isValidSemVerRange; exports.assertIsSemVerVersion = assertIsSemVerVersion; exports.assertIsSemVerRange = assertIsSemVerRange; exports.gtVersion = gtVersion; exports.gtRange = gtRange; exports.satisfiesVersionRange = satisfiesVersionRange;
|
|
69
|
+
//# sourceMappingURL=chunk-4D6XQBHA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/versions.ts"],"names":[],"mappings":";;;;;AAAA;AAAA,EACE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,SAAS;AAAA,EACT,cAAc;AAAA,OACT;AAEP,SAAS,IAAI,QAAQ,cAAc;AAoD5B,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP;AAAA,EACA,CAAC,UAAU;AACT,QAAI,mBAAmB,KAAK,MAAM,MAAM;AACtC,aAAO,iCAAiC,KAAK;AAAA,IAC/C;AACA,WAAO;AAAA,EACT;AACF;AAEO,IAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,EACP;AAAA,EACA,CAAC,UAAU;AACT,QAAI,iBAAiB,KAAK,MAAM,MAAM;AACpC,aAAO,+BAA+B,KAAK;AAAA,IAC7C;AACA,WAAO;AAAA,EACT;AACF;AAQO,SAAS,qBACd,SAC0B;AAC1B,SAAO,GAAG,SAAS,aAAa;AAClC;AAQO,SAAS,mBACd,cAC6B;AAC7B,SAAO,GAAG,cAAc,kBAAkB;AAC5C;AAOO,SAAS,sBACd,SACkC;AAClC,eAAa,SAAS,aAAa;AACrC;AAOO,SAAS,oBACd,OAC8B;AAC9B,eAAa,OAAO,kBAAkB;AACxC;AASO,SAAS,UACd,UACA,UACS;AACT,SAAO,SAAS,UAAU,QAAQ;AACpC;AASO,SAAS,QAAQ,SAAwB,OAA6B;AAC3E,SAAO,UAAU,SAAS,KAAK;AACjC;AASO,SAAS,sBACd,SACA,cACS;AACT,SAAO,gBAAgB,SAAS,cAAc;AAAA,IAC5C,mBAAmB;AAAA,EACrB,CAAC;AACH","sourcesContent":["import {\n gt as gtSemver,\n gtr as gtrSemver,\n satisfies as satisfiesSemver,\n valid as validSemVerVersion,\n validRange as validSemVerRange,\n} from 'semver';\nimport type { Struct } from 'superstruct';\nimport { is, refine, string } from 'superstruct';\n\nimport { assertStruct } from './assert';\nimport type { Opaque } from './opaque';\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for SemVer ranges.\n *\n * @example Use {@link assertIsSemVerRange} and {@link isValidSemVerRange} to cast to proper type.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * assertIsSemVerRange(unsafeRange);\n * unsafeRange\n * // ^? SemVerRange\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeRange: string = dataFromUser();\n * unsafeRange as SemVerRange;\n * // ^? SemVerRange\n * ```\n * @see {@link assertIsSemVerRange}\n * @see {@link isValidSemVerRange}\n */\nexport type SemVerRange = Opaque<string, typeof semVerRange>;\ndeclare const semVerRange: unique symbol;\n\n/**\n * {@link https://codemix.com/opaque-types-in-javascript/ Opaque} type for singular SemVer version.\n *\n * @example Use {@link assertIsSemVerVersion} and {@link isValidSemVerVersion} to cast to proper type.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * assertIsSemVerVersion(unsafeRange);\n * unsafeVersion\n * // ^? SemVerVersion\n * ```\n * @example If you know what you're doing and want to side-step type safety, casting from a string works correctly.\n * ```typescript\n * const unsafeVersion: string = dataFromUser();\n * unsafeRange as SemVerVersion;\n * // ^? SemVerVersion\n * ```\n * @see {@link assertIsSemVerVersion}\n * @see {@link isValidSemVerVersion}\n */\nexport type SemVerVersion = Opaque<string, typeof semVerVersion>;\ndeclare const semVerVersion: unique symbol;\n\n/**\n * A struct for validating a version string.\n */\nexport const VersionStruct = refine<SemVerVersion, null>(\n string() as unknown as Struct<SemVerVersion, null>,\n 'Version',\n (value) => {\n if (validSemVerVersion(value) === null) {\n return `Expected SemVer version, got \"${value}\"`;\n }\n return true;\n },\n);\n\nexport const VersionRangeStruct = refine<SemVerRange, null>(\n string() as unknown as Struct<SemVerRange, null>,\n 'Version range',\n (value) => {\n if (validSemVerRange(value) === null) {\n return `Expected SemVer range, got \"${value}\"`;\n }\n return true;\n },\n);\n\n/**\n * Checks whether a SemVer version is valid.\n *\n * @param version - A potential version.\n * @returns `true` if the version is valid, and `false` otherwise.\n */\nexport function isValidSemVerVersion(\n version: unknown,\n): version is SemVerVersion {\n return is(version, VersionStruct);\n}\n\n/**\n * Checks whether a SemVer version range is valid.\n *\n * @param versionRange - A potential version range.\n * @returns `true` if the version range is valid, and `false` otherwise.\n */\nexport function isValidSemVerRange(\n versionRange: unknown,\n): versionRange is SemVerRange {\n return is(versionRange, VersionRangeStruct);\n}\n\n/**\n * Asserts that a value is a valid concrete SemVer version.\n *\n * @param version - A potential SemVer concrete version.\n */\nexport function assertIsSemVerVersion(\n version: unknown,\n): asserts version is SemVerVersion {\n assertStruct(version, VersionStruct);\n}\n\n/**\n * Asserts that a value is a valid SemVer range.\n *\n * @param range - A potential SemVer range.\n */\nexport function assertIsSemVerRange(\n range: unknown,\n): asserts range is SemVerRange {\n assertStruct(range, VersionRangeStruct);\n}\n\n/**\n * Checks whether a SemVer version is greater than another.\n *\n * @param version1 - The left-hand version.\n * @param version2 - The right-hand version.\n * @returns `version1 > version2`.\n */\nexport function gtVersion(\n version1: SemVerVersion,\n version2: SemVerVersion,\n): boolean {\n return gtSemver(version1, version2);\n}\n\n/**\n * Checks whether a SemVer version is greater than all possibilities in a range.\n *\n * @param version - A SemvVer version.\n * @param range - The range to check against.\n * @returns `version > range`.\n */\nexport function gtRange(version: SemVerVersion, range: SemVerRange): boolean {\n return gtrSemver(version, range);\n}\n\n/**\n * Returns whether a SemVer version satisfies a SemVer range.\n *\n * @param version - The SemVer version to check.\n * @param versionRange - The SemVer version range to check against.\n * @returns Whether the version satisfied the version range.\n */\nexport function satisfiesVersionRange(\n version: SemVerVersion,\n versionRange: SemVerRange,\n): boolean {\n return satisfiesSemver(version, versionRange, {\n includePrerelease: true,\n });\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/time.ts
|
|
2
|
+
var Duration = /* @__PURE__ */ ((Duration2) => {
|
|
3
|
+
Duration2[Duration2["Millisecond"] = 1] = "Millisecond";
|
|
4
|
+
Duration2[Duration2["Second"] = 1e3] = "Second";
|
|
5
|
+
Duration2[Duration2["Minute"] = 6e4] = "Minute";
|
|
6
|
+
Duration2[Duration2["Hour"] = 36e5] = "Hour";
|
|
7
|
+
Duration2[Duration2["Day"] = 864e5] = "Day";
|
|
8
|
+
Duration2[Duration2["Week"] = 6048e5] = "Week";
|
|
9
|
+
Duration2[Duration2["Year"] = 31536e6] = "Year";
|
|
10
|
+
return Duration2;
|
|
11
|
+
})(Duration || {});
|
|
12
|
+
var isNonNegativeInteger = (number) => Number.isInteger(number) && number >= 0;
|
|
13
|
+
var assertIsNonNegativeInteger = (number, name) => {
|
|
14
|
+
if (!isNonNegativeInteger(number)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`"${name}" must be a non-negative integer. Received: "${number}".`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function inMilliseconds(count, duration) {
|
|
21
|
+
assertIsNonNegativeInteger(count, "count");
|
|
22
|
+
return count * duration;
|
|
23
|
+
}
|
|
24
|
+
function timeSince(timestamp) {
|
|
25
|
+
assertIsNonNegativeInteger(timestamp, "timestamp");
|
|
26
|
+
return Date.now() - timestamp;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.Duration = Duration; exports.inMilliseconds = inMilliseconds; exports.timeSince = timeSince;
|
|
34
|
+
//# sourceMappingURL=chunk-4RMX5YWE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/time.ts"],"names":["Duration"],"mappings":";AAGO,IAAK,WAAL,kBAAKA,cAAL;AAIL,EAAAA,oBAAA,iBAAc,KAAd;AAKA,EAAAA,oBAAA,YAAS,OAAT;AAKA,EAAAA,oBAAA,YAAS,OAAT;AAKA,EAAAA,oBAAA,UAAO,QAAP;AAKA,EAAAA,oBAAA,SAAM,SAAN;AAKA,EAAAA,oBAAA,UAAO,UAAP;AAKA,EAAAA,oBAAA,UAAO,WAAP;AAlCU,SAAAA;AAAA,GAAA;AAqCZ,IAAM,uBAAuB,CAAC,WAC5B,OAAO,UAAU,MAAM,KAAK,UAAU;AAExC,IAAM,6BAA6B,CAAC,QAAgB,SAAiB;AACnE,MAAI,CAAC,qBAAqB,MAAM,GAAG;AACjC,UAAM,IAAI;AAAA,MACR,IAAI,IAAI,gDAAgD,MAAM;AAAA,IAChE;AAAA,EACF;AACF;AASO,SAAS,eAAe,OAAe,UAA4B;AACxE,6BAA2B,OAAO,OAAO;AACzC,SAAO,QAAQ;AACjB;AAQO,SAAS,UAAU,WAA2B;AACnD,6BAA2B,WAAW,WAAW;AACjD,SAAO,KAAK,IAAI,IAAI;AACtB","sourcesContent":["/**\n * Common duration constants, in milliseconds.\n */\nexport enum Duration {\n /**\n * A millisecond.\n */\n Millisecond = 1,\n\n /**\n * A second, in milliseconds.\n */\n Second = 1000, // Millisecond * 1000\n\n /**\n * A minute, in milliseconds.\n */\n Minute = 60_000, // Second * 60\n\n /**\n * An hour, in milliseconds.\n */\n Hour = 3_600_000, // Minute * 60\n\n /**\n * A day, in milliseconds.\n */\n Day = 86_400_000, // Hour * 24\n\n /**\n * A week, in milliseconds.\n */\n Week = 604_800_000, // Day * 7\n\n /**\n * A year, in milliseconds.\n */\n Year = 31_536_000_000, // Day * 365\n}\n\nconst isNonNegativeInteger = (number: number) =>\n Number.isInteger(number) && number >= 0;\n\nconst assertIsNonNegativeInteger = (number: number, name: string) => {\n if (!isNonNegativeInteger(number)) {\n throw new Error(\n `\"${name}\" must be a non-negative integer. Received: \"${number}\".`,\n );\n }\n};\n\n/**\n * Calculates the millisecond value of the specified number of units of time.\n *\n * @param count - The number of units of time.\n * @param duration - The unit of time to count.\n * @returns The count multiplied by the specified duration.\n */\nexport function inMilliseconds(count: number, duration: Duration): number {\n assertIsNonNegativeInteger(count, 'count');\n return count * duration;\n}\n\n/**\n * Gets the milliseconds since a particular Unix epoch timestamp.\n *\n * @param timestamp - A Unix millisecond timestamp.\n * @returns The number of milliseconds elapsed since the specified timestamp.\n */\nexport function timeSince(timestamp: number): number {\n assertIsNonNegativeInteger(timestamp, 'timestamp');\n return Date.now() - timestamp;\n}\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isErrorWithCode,
|
|
3
|
+
wrapError
|
|
4
|
+
} from "./chunk-XYGUOY6N.mjs";
|
|
5
|
+
|
|
6
|
+
// src/fs.ts
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import os from "os";
|
|
9
|
+
import path from "path";
|
|
10
|
+
async function readFile(filePath) {
|
|
11
|
+
try {
|
|
12
|
+
return await fs.promises.readFile(filePath, "utf8");
|
|
13
|
+
} catch (error) {
|
|
14
|
+
throw wrapError(error, `Could not read file '${filePath}'`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function writeFile(filePath, content) {
|
|
18
|
+
try {
|
|
19
|
+
await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
20
|
+
await fs.promises.writeFile(filePath, content);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw wrapError(error, `Could not write file '${filePath}'`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function readJsonFile(filePath, {
|
|
26
|
+
parser = JSON
|
|
27
|
+
} = {}) {
|
|
28
|
+
try {
|
|
29
|
+
const content = await fs.promises.readFile(filePath, "utf8");
|
|
30
|
+
return parser.parse(content);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw wrapError(error, `Could not read JSON file '${filePath}'`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function writeJsonFile(filePath, jsonValue, {
|
|
36
|
+
stringifier = JSON,
|
|
37
|
+
prettify = false
|
|
38
|
+
} = {}) {
|
|
39
|
+
try {
|
|
40
|
+
await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
|
|
41
|
+
const json = prettify ? stringifier.stringify(jsonValue, null, " ") : stringifier.stringify(jsonValue);
|
|
42
|
+
await fs.promises.writeFile(filePath, json);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw wrapError(error, `Could not write JSON file '${filePath}'`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function fileExists(filePath) {
|
|
48
|
+
try {
|
|
49
|
+
const stats = await fs.promises.stat(filePath);
|
|
50
|
+
return stats.isFile();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (isErrorWithCode(error) && error.code === "ENOENT") {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
throw wrapError(error, `Could not determine if file exists '${filePath}'`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function directoryExists(directoryPath) {
|
|
59
|
+
try {
|
|
60
|
+
const stats = await fs.promises.stat(directoryPath);
|
|
61
|
+
return stats.isDirectory();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (isErrorWithCode(error) && error.code === "ENOENT") {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
throw wrapError(
|
|
67
|
+
error,
|
|
68
|
+
`Could not determine if directory exists '${directoryPath}'`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function ensureDirectoryStructureExists(directoryPath) {
|
|
73
|
+
try {
|
|
74
|
+
await fs.promises.mkdir(directoryPath, { recursive: true });
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw wrapError(
|
|
77
|
+
error,
|
|
78
|
+
`Could not create directory structure '${directoryPath}'`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function forceRemove(entryPath) {
|
|
83
|
+
try {
|
|
84
|
+
return await fs.promises.rm(entryPath, {
|
|
85
|
+
recursive: true,
|
|
86
|
+
force: true
|
|
87
|
+
});
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw wrapError(error, `Could not remove file or directory '${entryPath}'`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function createSandbox(projectName) {
|
|
93
|
+
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
|
94
|
+
const directoryPath = path.join(os.tmpdir(), `${projectName}--${timestamp}`);
|
|
95
|
+
return {
|
|
96
|
+
directoryPath,
|
|
97
|
+
async withinSandbox(test) {
|
|
98
|
+
if (await directoryExists(directoryPath)) {
|
|
99
|
+
throw new Error(`${directoryPath} already exists. Cannot continue.`);
|
|
100
|
+
}
|
|
101
|
+
await ensureDirectoryStructureExists(directoryPath);
|
|
102
|
+
try {
|
|
103
|
+
await test({ directoryPath });
|
|
104
|
+
} finally {
|
|
105
|
+
await forceRemove(directoryPath);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
readFile,
|
|
113
|
+
writeFile,
|
|
114
|
+
readJsonFile,
|
|
115
|
+
writeJsonFile,
|
|
116
|
+
fileExists,
|
|
117
|
+
directoryExists,
|
|
118
|
+
ensureDirectoryStructureExists,
|
|
119
|
+
forceRemove,
|
|
120
|
+
createSandbox
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=chunk-52OU772R.mjs.map
|