- support ESM #42, #38

- types index.d.ts to package.json #32
This commit is contained in:
Yi-Cyuan Chen
2026-07-17 16:28:36 +08:00
parent 83e468af79
commit 951408a3aa
9 changed files with 655 additions and 304 deletions
+5
View File
@@ -1,5 +1,10 @@
# Change Log
## v0.10.0 / 2026-07-17
### Added
- support ESM #42, #38
- types index.d.ts to package.json #32
## v0.9.3 / 2023-12-16
### Fixed
- Fix error in arrayBuffer when there are extra bytes #37
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.9.3
* @version 0.10.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2023
* @license MIT
File diff suppressed because one or more lines are too long
+41 -19
View File
@@ -1,11 +1,15 @@
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var sha3 = {exports: {}};
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var sha3$1 = {exports: {}};
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.9.3
* @version 0.10.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2023
* @license MIT
@@ -659,22 +663,40 @@ var sha3 = {exports: {}};
}
}
})();
} (sha3));
} (sha3$1));
var sha3Exports = sha3.exports;
var sha3Exports = sha3$1.exports;
var sha3 = /*@__PURE__*/getDefaultExportFromCjs(sha3Exports);
var cshake_128 = sha3Exports.cshake_128;
var cshake_256 = sha3Exports.cshake_256;
var keccak_224 = sha3Exports.keccak_224;
var keccak_256 = sha3Exports.keccak_256;
var keccak_384 = sha3Exports.keccak_384;
var keccak_512 = sha3Exports.keccak_512;
var kmac_128 = sha3Exports.kmac_128;
var kmac_256 = sha3Exports.kmac_256;
var sha3_224 = sha3Exports.sha3_224;
var sha3_256 = sha3Exports.sha3_256;
var sha3_384 = sha3Exports.sha3_384;
var sha3_512 = sha3Exports.sha3_512;
var shake_128 = sha3Exports.shake_128;
var shake_256 = sha3Exports.shake_256;
export { cshake_128, cshake_256, keccak_224, keccak_256, keccak_384, keccak_512, kmac_128, kmac_256, sha3_224, sha3_256, sha3_384, sha3_512, shake_128, shake_256 };
const {
sha3_224,
sha3_256,
sha3_384,
sha3_512,
keccak_224,
keccak_256,
keccak_384,
keccak_512,
keccak224,
keccak256,
keccak384,
keccak512,
shake_128,
shake_256,
shake128,
shake256,
cshake_128,
cshake_256,
cshake128,
cshake256,
kmac_128,
kmac_256,
kmac128,
kmac256
} = sha3;
export { cshake128, cshake256, cshake_128, cshake_256, sha3 as default, keccak224, keccak256, keccak384, keccak512, keccak_224, keccak_256, keccak_384, keccak_512, kmac128, kmac256, kmac_128, kmac_256, sha3_224, sha3_256, sha3_384, sha3_512, shake128, shake256, shake_128, shake_256 };
+526 -270
View File
File diff suppressed because it is too large Load Diff
+18 -3
View File
@@ -1,13 +1,28 @@
{
"name": "js-sha3",
"version": "0.9.3",
"version": "0.10.0",
"description": "A simple SHA-3 / Keccak / Shake hash function for JavaScript supports UTF-8 encoding.",
"main": "src/sha3.js",
"module": "build/sha3.mjs",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./build/sha3.mjs",
"require": "./src/sha3.js",
"default": "./src/sha3.js"
},
"./src/sha3.js": "./src/sha3.js",
"./build/sha3.min.js": "./build/sha3.min.js",
"./build/sha3.mjs": "./build/sha3.mjs",
"./build/sha3.min.mjs": "./build/sha3.min.mjs",
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"devDependencies": {
"@rollup/plugin-commonjs": "^28.0.5",
"@rollup/plugin-terser": "^1.0.0",
"expect.js": "~0.3.1",
"mocha": "~10.2.0",
"mocha": "^11.7.6",
"nyc": "^15.1.0",
"rollup": "^4.43.0",
"tiny-worker": "^2.3.0",
@@ -17,7 +32,7 @@
"test": "nyc mocha tests/node-test.js",
"report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"build": "npx rollup -c && uglifyjs src/sha3.js -c -m --comments --output build/sha3.min.js"
"build": "rollup -c && uglifyjs src/sha3.js -c -m --comments --output build/sha3.min.js"
},
"repository": {
"type": "git",
+20 -9
View File
@@ -1,12 +1,23 @@
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
export default {
input: 'src/sha3.mjs',
output: {
file: 'build/sha3.mjs',
format: 'esm'
export default [
{
input: 'src/sha3.mjs',
output: {
file: 'build/sha3.mjs',
format: 'es'
},
plugins: [commonjs({
strictRequires: false
})]
},
plugins: [commonjs({
strictRequires: false,
})]
};
{
input: 'build/sha3.mjs',
output: {
file: 'build/sha3.min.mjs',
format: 'es'
},
plugins: [terser()]
}
];
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.9.3
* @version 0.10.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2023
* @license MIT
+34 -1
View File
@@ -1 +1,34 @@
export {sha3_224, sha3_256, sha3_384, sha3_512, keccak_224, keccak_256, keccak_384, keccak_512, kmac_128, kmac_256, shake_128, shake_256, cshake_128, cshake_256} from './sha3.js'
import sha3 from './sha3.js';
export const {
sha3_224,
sha3_256,
sha3_384,
sha3_512,
keccak_224,
keccak_256,
keccak_384,
keccak_512,
keccak224,
keccak256,
keccak384,
keccak512,
shake_128,
shake_256,
shake128,
shake256,
cshake_128,
cshake_256,
cshake128,
cshake256,
kmac_128,
kmac_256,
kmac128,
kmac256
} = sha3;
export default sha3;