coverage is properly working again

This commit is contained in:
Juanra Dikal 2022-10-03 19:57:08 +02:00
parent 3138bfa209
commit 2192825049
28 changed files with 854 additions and 742 deletions

View File

@ -1,6 +1,6 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Node.js CI](https://github.com/juanelas/bigint-crypto-utils/workflows/build/badge.svg)](https://github.com/juanelas/bigint-crypto-utils/actions?query=workflow%3A%22build%22)
[![Node.js CI](https://github.com/juanelas/bigint-crypto-utils/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/juanelas/bigint-crypto-utils/actions/workflows/build-and-test.yml)
[![Coverage Status](https://coveralls.io/repos/github/juanelas/bigint-crypto-utils/badge.svg?branch=master)](https://coveralls.io/github/juanelas/bigint-crypto-utils?branch=master)
# bigint-crypto-utils

166
build/bin/mocha-ts.cjs Normal file
View File

@ -0,0 +1,166 @@
#! /usr/bin/env node
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const minimatch = require('minimatch')
const rimraf = require('rimraf')
const runScript = require('../run-script.cjs')
const rootDir = path.join(__dirname, '../..')
const pkgJson = require(path.join(rootDir, 'package.json'))
const mochaTsRelativeDir = pkgJson.directories['mocha-ts']
const mochaTsDir = path.join(rootDir, mochaTsRelativeDir)
// clean .mocha-ts directory
rimraf.sync(mochaTsDir)
const semaphorePath = `${mochaTsRelativeDir}/semaphore`
const tempDir = mochaTsDir
fs.mkdirSync(tempDir, { recursive: true })
const usage = `Usage: mocha-ts [options] [spec]
mocha against ts tests and modules
Arguments:
spec One or more files, directories, or globs to test (default:
"{src/ts/**/*.spec.ts,test/**/*.ts}")
Options:
-w, --watch run in watch mode. Since mocha only supports CJS in watch
mode. This option implies -cjs as well (default: false)
-cjs, --commonjs run tests against the CJS bundle instead of the ESM one
(default: false)
-h, --help display help for command
`
function parse () {
const args = process.argv.slice(2)
const help = getBooleanOption(args, '--help', '-h')
if (help) {
console.log(usage)
process.exit()
}
const requiredFile = getOption(args, '--require')
const watch = getBooleanOption(args, '--watch', '-w')
const commonjs = getBooleanOption(args, '--commonjs', '-cjs')
if (commonjs === false && watch === true) {
console.log('ERROR: mocha in watch mode only supports commonjs')
console.log(usage)
process.exit(1)
}
let testsGlob = (args.pop() ?? '').replace(/^['"]/, '').replace(/['"]$/, '') // Let us remove surrounding quotes in string (it gives issues in windows)
if (testsGlob === '') {
testsGlob = '{src/ts/**/*.spec.ts,test/**/*.ts}'
}
const mochaArgs = []
if (requiredFile !== '') {
mochaArgs.push('--require')
mochaArgs.push(requiredFile)
}
mochaArgs.push('--require')
mochaArgs.push('build/testing/mocha/mocha-init.cjs')
if (watch) {
mochaArgs.push('-w')
mochaArgs.push('--watch-files')
mochaArgs.push(semaphorePath)
}
if (testsGlob.substring(0, 1) === '-') {
console.log(usage)
process.exit(9)
}
let filenames = []
try {
filenames = glob.sync(testsGlob, { cwd: rootDir, matchBase: true })
} catch (error) {}
if (filenames.length === 0) {
console.error('invalid or empty glob pattern: ' + testsGlob)
console.log()
console.log(usage)
process.exit(9)
}
const testFiles = []
const jsTestFiles = []
if (filenames.length > 0) {
filenames.forEach(file => {
const isTsTestFile = minimatch(file, '{test/**/*.ts,src/**/*.spec.ts}', { matchBase: true })
if (isTsTestFile) {
testFiles.push(file)
const extension = commonjs ? 'cjs' : 'js'
jsTestFiles.push(`${mochaTsRelativeDir}/${file.slice(0, -3)}.${extension}`)
}
})
}
mochaArgs.push(...jsTestFiles)
return {
mochaArgs,
testFiles,
commonjs
}
}
const processedArgs = parse()
const commonjs = processedArgs.commonjs
const testFiles = processedArgs.testFiles
const mochaArgs = processedArgs.mochaArgs
// prepare setup for mocha (it should be written to a JSON file that will be loaded by the mocha-init.cjs)
const mochaSetup = {
testFiles,
commonjs
}
fs.writeFileSync(path.join(tempDir, 'testSetup.json'), JSON.stringify(mochaSetup, undefined, 2), { encoding: 'utf-8' })
if (commonjs) {
console.log('\x1b[33m [mocha-ts] Running tests against the CommonJS module \x1b[0m\n')
} else {
console.log('\x1b[33m [mocha-ts] Running tests against the ESM module \x1b[0m\n')
}
const rollupBuilder = require('../testing/mocha/builders/RollupBuilder.cjs').rollupBuilder
rollupBuilder.start({ commonjs, watch: false }).then(() => {
rollupBuilder.close()
const testsBuilder = require('../testing/mocha/builders/TestsBuilder.cjs').testBuilder
testsBuilder.start({ commonjs, testFiles }).then(() => {
testsBuilder.close()
// Now run mocha
runScript(path.join(rootDir, 'node_modules/mocha/bin/mocha'), mochaArgs)
})
})
function getBooleanOption (args, ...optionNames) {
let found = false
optionNames.forEach((option) => {
const index = args.indexOf(option)
if (index > -1) {
found = true
args.splice(index, 1)
}
})
return found
}
function getOption (args, option) {
const index = args.indexOf(option)
if (index > -1 && index < args.length - 2) {
return args.splice(index, 2)[1]
}
return ''
}

View File

@ -1,79 +0,0 @@
#! /usr/bin/env node
import { join, resolve } from 'path'
import { fork } from 'child_process'
import minimatch from 'minimatch'
import glob from 'glob'
import { fileURLToPath } from 'url'
const { sync } = glob
const __dirname = resolve(fileURLToPath(import.meta.url), '../')
const rootDir = join(__dirname, '../..')
const mochaTsRelativeDir = '.mocha-ts'
// First let us prepare the args to pass to mocha.
// ts.files will be replaced by their js-transpiled counterparts
// a watch file to our semaphore will be added
const processedArgs = processArgs(process.argv.slice(2))
// Now we can run a script and invoke a callback when complete, e.g.
runScript(join(rootDir, 'node_modules/mocha/bin/mocha'), processedArgs)
function processArgs (args) {
args = process.argv.slice(2).map(arg => {
// Let us first remove surrounding quotes in string (it gives issues in windows)
arg = arg.replace(/^['"]/, '').replace(/['"]$/, '')
const filenames = sync(arg, { cwd: rootDir, matchBase: true })
if (filenames.length > 0) {
return filenames.map(file => {
const isTsTestFile = minimatch(file, '{test/**/*.ts,src/**/*.spec.ts}', { matchBase: true })
if (isTsTestFile) {
return `${mochaTsRelativeDir}/${file.slice(0, -3)}.js`
}
return file
})
}
return arg
})
const processedArgs = []
let addSemaphore = false
let semaphoreAdded = false
for (const arg of args) {
if (Array.isArray(arg)) {
processedArgs.push(...arg)
} else {
processedArgs.push(arg)
if (arg === '--watch' || arg === '-w') {
addSemaphore = true
} else if (arg === '--watch-files') {
processedArgs.push(`${mochaTsRelativeDir}/semaphore`)
semaphoreAdded = true
}
}
}
if (addSemaphore === true || semaphoreAdded === false) {
processedArgs.push('--watch-files')
processedArgs.push(`${mochaTsRelativeDir}/semaphore`)
}
return processedArgs
}
function runScript (scriptPath, args) {
const mochaCmd = fork(scriptPath, args, {
cwd: rootDir
})
mochaCmd.on('error', (error) => {
throw error
})
// execute the callback once the process has finished running
mochaCmd.on('exit', function (code) {
if (code !== 0) {
throw new Error('exit code ' + code)
}
})
}

View File

@ -3,7 +3,9 @@
const fs = require('fs')
const TypeDoc = require('typedoc')
const path = require('path')
const json5 = require('json5')
const pkgJson = require('../package.json')
const rimraf = require('rimraf')
const rootDir = path.join(__dirname, '..')
@ -14,15 +16,25 @@ function camelise (str) {
})
}
const tsConfigPath = path.join(rootDir, 'tsconfig.json')
const tempTsConfigPath = path.join(rootDir, '.tsconfig.json')
async function typedoc () {
const app = new TypeDoc.Application()
// prepare tsconfig
const tsConfig = json5.parse(fs.readFileSync(tsConfigPath, 'utf8'))
tsConfig.include = ['src/ts/**/*', 'build/typings/**/*.d.ts']
tsConfig.exclude = ['src/**/*.spec.ts']
fs.writeFileSync(tempTsConfigPath, JSON.stringify(tsConfig, undefined, 2))
// If you want TypeDoc to load tsconfig.json / typedoc.json files
app.options.addReader(new TypeDoc.TSConfigReader())
app.options.addReader(new TypeDoc.TypeDocReader())
app.bootstrap({
// typedoc options here
tsconfig: tempTsConfigPath,
entryPoints: ['src/ts/index.ts'],
plugin: ['typedoc-plugin-markdown'],
includeVersion: true,
@ -84,7 +96,7 @@ if (repoProvider) {
iifeBundle = `[IIFE bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${iifeBundlePath})`
esmBundle = `[ESM bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${esmBundlePath})`
umdBundle = `[UMD bundle](https://raw.githubusercontent.com/${repoUsername}/${repoName}/master/${umdBundlePath})`
workflowBadget = `[![Node.js CI](https://github.com/${repoUsername}/${repoName}/workflows/build/badge.svg)](https://github.com/${repoUsername}/${repoName}/actions?query=workflow%3A%22build%22)`
workflowBadget = `[![Node.js CI](https://github.com/${repoUsername}/${repoName}/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/${repoUsername}/${repoName}/actions/workflows/build-and-test.yml)`
coverallsBadge = `[![Coverage Status](https://coveralls.io/repos/github/${repoUsername}/${repoName}/badge.svg?branch=master)](https://coveralls.io/github/${repoUsername}/${repoName}?branch=master)`
break
@ -117,3 +129,5 @@ const readmeFile = path.join(rootDir, 'README.md')
fs.writeFileSync(readmeFile, template)
typedoc()
rimraf.sync(tempTsConfigPath)

View File

@ -52,7 +52,7 @@ function compileDts () {
}
export default [
{ // ESM for browsers and declarations
{ // Browser ESM bundle
input: input,
output: [
{
@ -102,11 +102,6 @@ export default [
}
],
plugins: [
replace({
'await import(': 'require(',
delimiters: ['', ''],
preventAssignment: true
}),
replace({
IS_BROWSER: true,
preventAssignment: true
@ -150,7 +145,7 @@ export default [
json()
]
},
{ // Node ESM
{ // Node ESM and type declarations
input: input,
output: [
{

26
build/run-script.cjs Normal file
View File

@ -0,0 +1,26 @@
const childProcess = require('child_process')
const rootDir = require('path').join(__dirname, '../')
function runScript (scriptPath, args) {
return new Promise((resolve, reject) => {
const cmd = childProcess.fork(scriptPath, args, {
cwd: rootDir
})
cmd.on('error', (error) => {
reject(error)
})
// execute the callback once the process has finished running
cmd.on('exit', function (code) {
if (code !== 0) {
const error = new Error('exit code ' + code)
reject(error)
}
resolve()
})
})
}
module.exports = runScript

View File

@ -29,11 +29,11 @@ const browserTests = async (
}
if (ignore) return
let text = (message.args().length > 0) ? message.args()[0]._remoteObject.value : message.text()
let text = (message.args().length > 0) ? message.args()[0].remoteObject().value : message.text()
const args = []
if (message.args() !== undefined && message.args().length > 1) {
for (let i = 1; i < message.args().length; i++) {
args.push(message.args()[i]._remoteObject.value)
args.push(message.args()[i].remoteObject().value)
}
}

View File

@ -13,6 +13,7 @@ const multi = require('@rollup/plugin-multi-entry')
const typescriptPlugin = require('@rollup/plugin-typescript')
const commonjs = require('@rollup/plugin-commonjs')
const json = require('@rollup/plugin-json')
const runScript = require('../../run-script.cjs')
const rootDir = path.join(__dirname, '..', '..', '..')
@ -40,10 +41,6 @@ const indexHtml = `<!DOCTYPE html>
timeout: 90000
})
</script>
<script type="module">
import * as _pkg from './${name}.esm.js'
self._pkg = _pkg
</script>
<script type="module">
import './tests.js'
window._mocha = mocha.run()
@ -62,6 +59,11 @@ async function buildTests (testFiles) {
input,
plugins: [
multi({ exports: true }),
replace({
'#pkg': `/${name}.esm.js`,
delimiters: ['', ''],
preventAssignment: true
}),
replace({
IS_BROWSER: true,
preventAssignment: true
@ -69,12 +71,12 @@ async function buildTests (testFiles) {
typescriptPlugin(tsBundleOptions),
resolve({
browser: true,
exportConditions: ['browser', 'module', 'import', 'default']
exportConditions: ['browser', 'default']
}),
commonjs(),
json()
],
external: [pkgJson.name]
external: [`/${name}.esm.js`]
}
const bundle = await rollup.rollup(inputOptions)
const { output } = await bundle.generate({ format: 'esm' })
@ -82,7 +84,8 @@ async function buildTests (testFiles) {
let bundledCode = output[0].code
const replacements = _getEnvVarsReplacements(bundledCode)
for (const replacement in replacements) {
bundledCode = bundledCode.replaceAll(replacement, replacements[replacement])
const regExp = new RegExp(replacement, 'g')
bundledCode = bundledCode.replace(regExp, replacements[replacement])
}
return bundledCode
}
@ -93,10 +96,15 @@ class TestServer {
}
async init (testFiles) {
/** Let us first check if the necessary files are built, and if not, build */
if (!fs.existsSync(pkgJson.exports['./esm-browser-bundle'])) {
await runScript(path.join(rootDir, 'node_modules', '.bin', 'rollup'), ['-c', 'build/rollup.config.js'])
}
const tests = await buildTests(testFiles)
this.server.on('request', function (req, res) {
if (req.url === `/${name}.esm.js`) {
fs.readFile(path.join(rootDir, pkgJson.directories.dist, 'bundles/esm.js'), function (err, data) {
fs.readFile(path.join(rootDir, pkgJson.exports['./esm-browser-bundle']), function (err, data) {
if (err) {
res.writeHead(404)
res.end(JSON.stringify(err))

View File

@ -1,15 +1,18 @@
import EventEmitter from 'events'
import { mkdirSync, writeFileSync, rmSync } from 'fs'
import { dirname } from 'path'
const EventEmitter = require('events')
const fs = require('fs')
const path = require('path')
export default class Builder extends EventEmitter {
module.exports = class Builder extends EventEmitter {
constructor (semaphoreFile, name = 'builder') {
super()
this.name = name
this.firstBuild = true
mkdirSync(dirname(semaphoreFile), { recursive: true })
fs.mkdirSync(path.dirname(semaphoreFile), { recursive: true })
this.semaphoreFile = semaphoreFile
if (!fs.existsSync(this.semaphoreFile)) {
fs.writeFileSync(this.semaphoreFile, '', { encoding: 'utf8' })
}
this._ready = false
this.on('message', (...message) => {
@ -24,12 +27,12 @@ export default class Builder extends EventEmitter {
}
})
this.on('ready', () => {
if (this.firstBuild === false) {
writeFileSync(this.semaphoreFile, '', 'utf-8')
} else {
this.firstBuild = false
this.on('ready', (updateSemaphore = true) => {
const now = Date.now()
if (updateSemaphore) {
fs.utimesSync(this.semaphoreFile, now, now)
}
this._ready = true
})
@ -54,6 +57,6 @@ export default class Builder extends EventEmitter {
async close () {}
clean () {
rmSync(this.semaphoreFile, { force: true })
fs.rmSync(this.semaphoreFile, { force: true })
}
}

View File

@ -0,0 +1,154 @@
const EventEmitter = require('events')
const fs = require('fs')
const path = require('path')
const rollup = require('rollup')
const loadAndParseConfigFile = require('rollup/dist/loadConfigFile')
const Builder = require('./Builder.cjs')
const rootDir = path.join(__dirname, '../../../../')
const pkgJson = require(path.join(rootDir, 'package.json'))
const mochaTsRelativeDir = pkgJson.directories['mocha-ts']
const mochaTsDir = path.join(rootDir, mochaTsRelativeDir)
class RollupBuilder extends Builder {
constructor ({ name, configPath, tempDir }) {
super(path.join(tempDir, 'semaphore'), name)
this.tempDir = tempDir
this.configPath = configPath
this.firstBuild = true
}
async start ({ watch = false, commonjs = false }) {
await super.start()
this.watch = watch
this.commonjs = commonjs
this.watchedModule = commonjs ? pkgJson.exports['.'].node.require : pkgJson.exports['.'].node.import
const { options } = await loadAndParseConfigFile(this.configPath)
// Instead of compiling all the outputs let us just take the one we are using with mocha (either cjs or esm)
const rollupOptions = options.filter(bundle => {
const file = (bundle.output[0].dir !== undefined)
? path.join(bundle.output[0].dir, bundle.output[0].entryFileNames)
: bundle.output[0].file
return file === path.join(rootDir, this.watchedModule)
})[0]
if (rollupOptions.output.length > 1) {
rollupOptions.output = rollupOptions.output[0]
}
this.builder = new RollupBundler({ rollupOptions, watch: this.watch, watchedModule: this.watchedModule })
this.builder.on('event', event => {
let updateSemaphore = true
switch (event.code) {
case 'START':
this.emit('busy')
if (this.firstBuild === true) {
this.emit('message', 'building your module...')
} else {
this.emit('message', 'file changes detected. Rebuilding module files...')
}
break
case 'BUNDLE_END':
if (event.result) event.result.close()
break
case 'END':
if (event.result) event.result.close()
// fs.mkdirSync(path.join(this.tempDir, path.dirname(this.watchedModule)), { recursive: true })
// // console.log(path.join(this.tempDir, path.dirname(this.watchedModule)))
// fs.copyFileSync(this.watchedModule, path.join(this.tempDir, this.watchedModule))
if (this.firstBuild) {
this.firstBuild = false
updateSemaphore = false
}
this.emit('ready', updateSemaphore)
break
case 'ERROR':
if (event.result) event.result.close()
this.emit('error', event.error)
fs.writeFileSync(path.join(rootDir, this.watchedModule), '', 'utf8')
// fs.writeFileSync(path.join(this.tempDir, this.watchedModule), '', 'utf8')
this.emit('ready')
break
default:
this.emit('busy')
break
}
})
this.builder.start()
return await this.ready()
}
async close () {
await super.close()
this.builder.close()
}
}
class RollupBundler extends EventEmitter {
constructor ({ rollupOptions, watchedModule, watch = false }) {
super()
this.rollupOptions = rollupOptions
this.watch = watch
this.watchedModule = watchedModule
}
async start () {
if (this.watch === true) {
this.watcher = rollup.watch(this.rollupOptions)
this.watcher.on('event', event => {
this.emit('event', event)
})
} else {
if (!fs.existsSync(path.join(rootDir, this.watchedModule))) {
await this._bundle()
} else {
this.emit('event', { code: 'END', noBuild: true })
}
}
}
async _bundle () {
this.emit('event', { code: 'START' })
for (const optionsObj of [].concat(this.rollupOptions)) {
try {
const bundle = await rollup.rollup(optionsObj)
try {
await Promise.all(optionsObj.output.map(bundle.write))
this.emit('event', { code: 'BUNDLE_END' })
} catch (error) {
this.emit('event', { code: 'ERROR', error })
}
} catch (error) {
this.emit('event', { code: 'ERROR', error })
}
}
this.emit('event', { code: 'END' })
}
close () {
if (this.watcher !== undefined) this.watcher.close()
}
}
exports.RollupBuilder = RollupBuilder
exports.rollupBuilder = new RollupBuilder({
name: 'rollup',
configPath: path.join(rootDir, pkgJson.directories.build, 'rollup.config.js'),
tempDir: mochaTsDir
})

View File

@ -1,129 +0,0 @@
import EventEmitter from 'events'
import { existsSync, readFileSync, writeFileSync } from 'fs'
import json5 from 'json5'
import { join, resolve } from 'path'
import { fileURLToPath } from 'url'
import { rollup as _rollup, watch as _watch } from 'rollup'
import loadAndParseConfigFile from 'rollup/dist/loadConfigFile.js'
import Builder from './Builder.js'
const __dirname = resolve(fileURLToPath(import.meta.url), '../')
const rootDir = join(__dirname, '../../../../')
const pkgJson = json5.parse(readFileSync(join(rootDir, 'package.json')))
export default class RollupBuilder extends Builder {
constructor ({ name = 'rollup', configPath = join(rootDir, 'rollup.config.js'), tempDir = join(rootDir, '.mocha-ts'), watch = false }) {
super(join(tempDir, 'semaphore'), name)
this.configPath = configPath
this.watch = watch
}
async start () {
await super.start()
const { options } = await loadAndParseConfigFile(this.configPath)
// Watch only the Node ESM module, that is the one we are going to use with mocha
const rollupOptions = options.filter(bundle => {
const file = (bundle.output[0].dir !== undefined)
? join(bundle.output[0].dir, bundle.output[0].entryFileNames)
: bundle.output[0].file
return file === join(rootDir, pkgJson.exports['.'].node.import)
})[0]
if (rollupOptions.output.length > 1) {
rollupOptions.output = rollupOptions.output[0]
}
this.builder = new RollupBundler(rollupOptions, this.watch)
this.builder.on('event', event => {
switch (event.code) {
case 'START':
this.emit('busy')
if (this.firstBuild === true) {
this.emit('message', 'building your module...')
} else {
this.emit('message', 'file changes detected. Rebuilding module files...')
}
break
case 'BUNDLE_END':
if (event.result) event.result.close()
break
case 'END':
if (event.result) event.result.close()
this.emit('ready')
break
case 'ERROR':
if (event.result) event.result.close()
this.emit('error', event.error)
writeFileSync(join(rootDir, pkgJson.exports['.'].node.import), '', 'utf8')
this.emit('ready')
break
default:
this.emit('busy')
break
}
})
this.builder.start()
return await this.ready()
}
async close () {
await super.close()
this.builder.close()
}
}
class RollupBundler extends EventEmitter {
constructor (rollupOptions, watch = false) {
super()
this.rollupOptions = rollupOptions
this.watch = watch
}
async start () {
if (this.watch === true) {
this.watcher = _watch(this.rollupOptions)
this.watcher.on('event', event => {
this.emit('event', event)
})
} else {
if (existsSync(join(rootDir, pkgJson.exports['.'].node.import)) === false) {
await this._bundle()
} else {
this.emit('event', { code: 'END', noBuild: true })
}
}
}
async _bundle () {
this.emit('event', { code: 'START' })
for (const optionsObj of [].concat(this.rollupOptions)) {
try {
const bundle = await _rollup(optionsObj)
try {
await Promise.all(optionsObj.output.map(bundle.write))
this.emit('event', { code: 'BUNDLE_END' })
} catch (error) {
this.emit('event', { code: 'ERROR', error })
}
} catch (error) {
this.emit('event', { code: 'ERROR', error })
}
}
this.emit('event', { code: 'END' })
}
close () {
if (this.watcher !== undefined) this.watcher.close()
}
}

View File

@ -0,0 +1,169 @@
const path = require('path')
const fs = require('fs')
const ts = require('typescript')
const json5 = require('json5')
const Builder = require('./Builder.cjs')
const rootDir = path.join(__dirname, '../../../../')
const pkgJson = require(path.join(rootDir, 'package.json'))
const mochaTsRelativeDir = pkgJson.directories['mocha-ts']
const mochaTsDir = path.join(rootDir, mochaTsRelativeDir)
const formatHost = {
getCanonicalFileName: path => path,
getCurrentDirectory: ts.sys.getCurrentDirectory,
getNewLine: () => ts.sys.newLine
}
function fileChecksum (filePath) {
return require('crypto')
.createHash('md5')
.update(fs.readFileSync(filePath, { encoding: 'utf-8' }), 'utf8')
.digest('hex')
}
function renameJsToCjs (dir, fileList = []) {
const files = fs.readdirSync(dir)
files.forEach(file => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
fileList = renameJsToCjs(path.join(dir, file), fileList)
} else {
const match = file.match(/(.*)\.js$/)
if (match !== null) {
const filename = match[1]
fs.renameSync(path.join(dir, file), path.join(dir, `${filename}.cjs`))
}
}
})
}
class TestsBuilder extends Builder {
constructor ({ name, configPath, tempDir }) {
super(path.join(tempDir, 'semaphore'), name)
this.tempDir = tempDir
if (fs.existsSync(configPath) !== true) throw new Error(`Couldn't find a tsconfig file at ${configPath}`)
this.tsConfigPath = configPath
this.testFilesChecksums = {}
}
async start ({ testFiles = [], commonjs = false }) {
await super.start()
this.commonjs = commonjs
const tsConfig = json5.parse(fs.readFileSync(this.tsConfigPath, 'utf8'))
if (testFiles.length > 0) {
delete tsConfig.files
tsConfig.include = ['build/typings/**/*.d.ts'].concat(testFiles)
for (let i = 0; i < testFiles.length; i++) {
this.testFilesChecksums[testFiles[i]] = fileChecksum(testFiles[i])
}
} else {
tsConfig.include = ['build/typings/**/*.d.ts', 'test/**/*', 'src/ts/**/*.spec.ts']
}
tsConfig.exclude = ['src/ts/**/!(.spec).ts']
if (this.commonjs) {
tsConfig.compilerOptions.module = 'commonjs'
}
// "noResolve": true
// tsConfig.compilerOptions.noResolve = true
// we don't need declaration files
tsConfig.compilerOptions.declaration = false
// we need to emit files
tsConfig.compilerOptions.noEmit = false
// source mapping eases debuging
tsConfig.compilerOptions.inlineSourceMap = true
tsConfig.compilerOptions.rootDir = '.'
// Removed typeroots (it causes issues)
tsConfig.compilerOptions.typeRoots = undefined
tsConfig.compilerOptions.outDir = path.isAbsolute(this.tempDir) ? path.relative(rootDir, this.tempDir) : this.tempDir
this.tempTsConfigPath = path.join(rootDir, '.tsconfig.json')
fs.writeFileSync(this.tempTsConfigPath, JSON.stringify(tsConfig, undefined, 2), { encoding: 'utf-8' })
const createProgram = ts.createSemanticDiagnosticsBuilderProgram
const reportDiagnostic = (diagnostic) => {
const filePath = path.relative(rootDir, diagnostic.file.fileName)
const tranpiledJsPath = `${path.join(this.tempDir, filePath).slice(0, -3)}.js`
const errorLine = diagnostic.file.text.slice(0, diagnostic.start).split(/\r\n|\r|\n/).length
if (fs.existsSync(tranpiledJsPath)) {
fs.writeFileSync(tranpiledJsPath, '', 'utf8')
}
this.emit('error', `[Error ${diagnostic.code}]`, `${filePath}:${errorLine}`, ':', ts.flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()))
}
const reportWatchStatusChanged = (diagnostic, newLine, options, errorCount) => {
if (errorCount !== undefined) {
// only change semaphore if test files are modified
let updateSemaphore = false
for (let i = 0; i < testFiles.length; i++) {
const checksum = fileChecksum(testFiles[i])
if (this.testFilesChecksums[testFiles[i]] !== checksum) {
updateSemaphore = true
this.testFilesChecksums[testFiles[i]] = checksum
}
}
if (this.commonjs) {
renameJsToCjs(mochaTsDir)
}
this.emit('ready', updateSemaphore)
} else {
this.emit('busy')
if (diagnostic.code === 6031) {
this.emit('message', 'transpiling your tests...')
} else if (diagnostic.code === 6032) {
this.emit('message', 'file changes detected. Transpiling your tests...')
}
}
}
// Note that there is another overload for `createWatchCompilerHost` that takes
// a set of root files.
this.host = ts.createWatchCompilerHost(
this.tempTsConfigPath,
{},
ts.sys,
createProgram,
reportDiagnostic,
reportWatchStatusChanged
)
// `createWatchProgram` creates an initial program, watches files, and updates
// the program over time.
this.watcher = ts.createWatchProgram(this.host)
this.watcher.getProgram()
return await this.ready()
}
async close () {
await super.close()
this.watcher.close()
fs.unlinkSync(this.tempTsConfigPath)
}
}
exports.TestsBuilder = TestsBuilder
exports.testBuilder = new TestsBuilder({
name: 'tsc',
configPath: path.join(rootDir, 'tsconfig.json'),
tempDir: mochaTsDir
})

View File

@ -1,127 +0,0 @@
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs'
import json5 from 'json5'
import { isAbsolute, join, relative, resolve } from 'path'
import { fileURLToPath } from 'url'
import typescript from 'typescript'
import Builder from './Builder.js'
const { sys, createSemanticDiagnosticsBuilderProgram, flattenDiagnosticMessageText, createWatchCompilerHost, createWatchProgram } = typescript
const __dirname = resolve(fileURLToPath(import.meta.url), '../')
const rootDir = join(__dirname, '../../../../')
// const pkgJson = (await import(join(rootDir, 'package.json'), {
// assert: {
// type: "json",
// }
// })).default
const pkgJson = json5.parse(readFileSync(join(rootDir, 'package.json')))
const mochaTsRelativeDir = '.mocha-ts'
const mochaTsDir = join(rootDir, mochaTsRelativeDir)
const formatHost = {
getCanonicalFileName: path => path,
getCurrentDirectory: sys.getCurrentDirectory,
getNewLine: () => sys.newLine
}
export default class TestsBuilder extends Builder {
constructor ({ name = 'tsc', configPath = join(rootDir, 'tsconfig.json'), tempDir = mochaTsDir }) {
super(join(tempDir, 'semaphore'), name)
if (existsSync(configPath) !== true) throw new Error(`Couldn't find a tsconfig file at ${configPath}`)
this.tempDir = tempDir
this.tempPkgJsonPath = join(tempDir, 'package.json')
delete pkgJson.type
writeFileSync(this.tempPkgJsonPath, JSON.stringify(pkgJson, undefined, 2))
const tsConfig = json5.parse(readFileSync(configPath, 'utf8'))
tsConfig.file = undefined
// Exclude already transpiled files in src
tsConfig.exclude = ['src/ts/**/!(*.spec).ts']
// "noResolve": true
tsConfig.compilerOptions.noResolve = false
// we don't need declaration files
tsConfig.compilerOptions.declaration = false
// we need to emit files
tsConfig.compilerOptions.noEmit = false
// source mapping eases debuging
tsConfig.compilerOptions.sourceMap = true
// This prevents SyntaxError: Cannot use import statement outside a module
tsConfig.compilerOptions.module = 'commonjs'
// Removed typeroots (it causes issues)
tsConfig.compilerOptions.typeRoots = undefined
tsConfig.compilerOptions.outDir = isAbsolute(tempDir) ? relative(rootDir, tempDir) : tempDir
this.tempTsConfigPath = join(rootDir, '.tsconfig.json')
writeFileSync(this.tempTsConfigPath, JSON.stringify(tsConfig, undefined, 2))
const createProgram = createSemanticDiagnosticsBuilderProgram
const reportDiagnostic = (diagnostic) => {
const filePath = relative(rootDir, diagnostic.file.fileName)
const tranpiledJsPath = `${join(tempDir, filePath).slice(0, -3)}.js`
const errorLine = diagnostic.file.text.slice(0, diagnostic.start).split(/\r\n|\r|\n/).length
if (existsSync(tranpiledJsPath)) {
writeFileSync(tranpiledJsPath, '', 'utf8')
}
this.emit('error', `[Error ${diagnostic.code}]`, `${filePath}:${errorLine}`, ':', flattenDiagnosticMessageText(diagnostic.messageText, formatHost.getNewLine()))
}
const reportWatchStatusChanged = (diagnostic, newLine, options, errorCount) => {
if (errorCount !== undefined) {
this.emit('ready')
} else {
this.emit('busy')
if (diagnostic.code === 6031) {
this.emit('message', 'transpiling your tests...')
} else if (diagnostic.code === 6032) {
this.emit('message', 'file changes detected. Transpiling your tests...')
}
}
}
// Note that there is another overload for `createWatchCompilerHost` that takes
// a set of root files.
this.host = createWatchCompilerHost(
this.tempTsConfigPath,
{},
sys,
createProgram,
reportDiagnostic,
reportWatchStatusChanged
)
}
async start () {
await super.start()
// `createWatchProgram` creates an initial program, watches files, and updates
// the program over time.
this.watcher = createWatchProgram(this.host)
return await this.ready()
}
async close () {
await super.close()
this.watcher.close()
unlinkSync(this.tempTsConfigPath)
}
}

View File

@ -0,0 +1,66 @@
'use strict'
const fs = require('fs')
const path = require('path')
const chai = require('chai')
const rimraf = require('rimraf')
require('dotenv').config()
const rollupBuilder = require('./builders/RollupBuilder.cjs').rollupBuilder
const testsBuilder = require('./builders/TestsBuilder.cjs').testBuilder
const rootDir = path.join(__dirname, '../../../')
const pkgJson = require(path.join(rootDir, 'package.json'))
const mochaTsRelativeDir = pkgJson.directories['mocha-ts']
const tempDir = path.join(rootDir, mochaTsRelativeDir)
global.chai = chai
global.IS_BROWSER = false
const watch = process.argv.includes('--watch') || process.argv.includes('-w')
const setup = JSON.parse(fs.readFileSync(path.join(tempDir, 'testSetup.json'), 'utf-8'))
const testFiles = setup.testFiles
let commonjs = setup.commonjs
commonjs = watch ? true : commonjs // mocha in watch mode only supports commonjs
exports.mochaGlobalSetup = async function () {
if (watch) {
await rollupBuilder.start({ commonjs, watch })
testsBuilder.start({ testFiles, commonjs })
}
}
exports.mochaHooks = {
beforeAll: [
async function () {
this.timeout('120000')
if (watch) {
await Promise.all([rollupBuilder.ready(), testsBuilder.ready()])
// reset any transpiled module (just delete the cache so it is fully reloaded)
for (const key in require.cache) {
const relativePath = path.relative(rootDir, key)
if (relativePath.startsWith(`.mocha-ts${path.sep}`) || relativePath.startsWith(`dist${path.sep}`)) {
delete require.cache[key]
}
}
}
}
]
}
exports.mochaGlobalTeardown = async function () {
if (watch) {
await testsBuilder.close()
await rollupBuilder.close()
}
// I use the sync version of rimraf precisely because it blocks the
// main thread and thus the mocha watcher, which otherwise would complain
// about files being deleted
rimraf.sync(tempDir, { disableGlob: true })
}

View File

@ -1,82 +0,0 @@
'use strict'
import { join, resolve } from 'path'
import { readFileSync } from 'fs'
import json5 from 'json5'
import chai from 'chai'
import rimraf from 'rimraf'
import { fileURLToPath } from 'url'
import RollupBuilder from './builders/RollupBuilder.js'
import TestsBuilder from './builders/TestsBuilder.js'
import 'dotenv/config'
const __dirname = resolve(fileURLToPath(import.meta.url), '../')
const rootDir = join(__dirname, '../../../')
const pkgJson = json5.parse(readFileSync(join(rootDir, 'package.json')))
global.chai = chai
async function reloadModule () {
const _pkg = await import(join(rootDir, pkgJson.exports['.'].node.import + `?update=${Date.now()}`))
global._pkg = _pkg
// if (typeof _pkg === 'function') { // If it is just a default export, load it as named (for compatibility)
// global._pkg = {
// default: _pkg
// }
// } else {
// global._pkg = _pkg
// }
}
reloadModule()
global.IS_BROWSER = false
const watch = process.argv.includes('--watch') || process.argv.includes('-w')
const tempDir = join(rootDir, '.mocha-ts')
const rollupBuilder = new RollupBuilder({ name: 'rollup', configPath: join(rootDir, 'build/rollup.config.js'), tempDir, watch })
const testBuilder = new TestsBuilder({ name: 'tsc', tempDir })
rollupBuilder.start() // This should be in exports.mochaGlobalSetup but mocha fails when not in watch mode (DIRT...)
testBuilder.start() // This should be in exports.mochaGlobalSetup but mocha fails when not in watch mode (DIRT...)
export const mochaHooks = {
beforeAll: [
async function () {
this.timeout('120000')
await Promise.all([rollupBuilder.ready(), testBuilder.ready()])
// Just in case our module had been modified. Reload it when the tests are repeated (for mocha watch mode).
// delete require.cache[require.resolve(rootDir)]
await reloadModule()
// And now reset any other transpiled module (just delete the cache so it is fully reloaded)
// for (const key in require.cache) {
// const relativePath = relative(rootDir, key)
// if (relativePath.startsWith(`.mocha-ts${sep}`)) {
// delete require.cache[key]
// }
// }
}
]
}
// exports.mochaGlobalSetup = async function () {
// await rollupBuilder.start()
// await testBuilder.start()
// }
export const mochaGlobalTeardown = async function () {
await testBuilder.close()
await rollupBuilder.close()
// I use the sync version of rimraf precisely because it blocks the
// main thread and thus the mocha watcher, which otherwise would complain
// about files being deleted
rimraf.sync(tempDir, { disableGlob: true })
}

View File

@ -1,4 +0,0 @@
import * as _pkgModule from '../../src/ts/index'
export as namespace _pkg
export = _pkgModule

2
dist/bundles/esm.js vendored
View File

@ -10,7 +10,7 @@ function abs(a) {
}
/**
* Returns the bitlength of a number
* Returns the (minimum) length of a number expressed in bits.
*
* @param a
* @returns The bit length

View File

@ -18,7 +18,7 @@ function abs(a) {
}
/**
* Returns the bitlength of a number
* Returns the (minimum) length of a number expressed in bits.
*
* @param a
* @returns The bit length

View File

@ -10,7 +10,7 @@ function abs(a) {
}
/**
* Returns the bitlength of a number
* Returns the (minimum) length of a number expressed in bits.
*
* @param a
* @returns The bit length

View File

@ -10,7 +10,7 @@ function abs(a) {
}
/**
* Returns the bitlength of a number
* Returns the (minimum) length of a number expressed in bits.
*
* @param a
* @returns The bit length

View File

@ -53,7 +53,7 @@ ___
**bitLength**(`a`): `number`
Returns the bitlength of a number
Returns the (minimum) length of a number expressed in bits.
#### Parameters
@ -155,7 +155,7 @@ A promise that resolves to a boolean that is either true (a probably prime numbe
#### Defined in
[src/ts/isProbablyPrime.ts:20](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/isProbablyPrime.ts#L20)
[src/ts/isProbablyPrime.ts:20](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/isProbablyPrime.ts#L20)
___
@ -322,7 +322,7 @@ A promise that resolves to a bigint probable prime of bitLength bits.
#### Defined in
[src/ts/prime.ts:28](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/prime.ts#L28)
[src/ts/prime.ts:28](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/prime.ts#L28)
___
@ -352,7 +352,7 @@ A bigint probable prime of bitLength bits.
#### Defined in
[src/ts/prime.ts:109](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/prime.ts#L109)
[src/ts/prime.ts:109](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/prime.ts#L109)
___
@ -381,7 +381,7 @@ A cryptographically secure random bigint between [min,max]
#### Defined in
[src/ts/randBetween.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/randBetween.ts#L14)
[src/ts/randBetween.ts:14](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/randBetween.ts#L14)
___
@ -410,7 +410,7 @@ A Promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
#### Defined in
[src/ts/randBits.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/randBits.ts#L13)
[src/ts/randBits.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/randBits.ts#L13)
___
@ -439,7 +439,7 @@ A Uint8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
#### Defined in
[src/ts/randBits.ts:43](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/randBits.ts#L43)
[src/ts/randBits.ts:43](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/randBits.ts#L43)
___
@ -468,7 +468,7 @@ A promise that resolves to a UInt8Array/Buffer (Browser/Node.js) filled with cry
#### Defined in
[src/ts/randBytes.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/randBytes.ts#L13)
[src/ts/randBytes.ts:13](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/randBytes.ts#L13)
___
@ -498,7 +498,7 @@ A UInt8Array/Buffer (Browser/Node.js) filled with cryptographically secure rando
#### Defined in
[src/ts/randBytes.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/6fda498/src/ts/randBytes.ts#L45)
[src/ts/randBytes.ts:45](https://github.com/juanelas/bigint-crypto-utils/blob/3138bfa/src/ts/randBytes.ts#L45)
___

373
package-lock.json generated
View File

@ -15,22 +15,22 @@
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^4.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-node-resolve": "^14.1.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.2.0",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@types/mocha": "^10.0.0",
"c8": "^7.12.0",
"chai": "^4.3.3",
"dotenv": "^16.0.0",
"fs-extra": "^10.0.0",
"dotenv": "^16.0.3",
"fs-extra": "^10.1.0",
"glob": "^8.0.1",
"json5": "^2.2.0",
"minimatch": "^5.0.1",
"mocha": "^10.0.0",
"npm-run-all": "^4.1.5",
"pirates": "^4.0.1",
"puppeteer": "^15.5.0",
"puppeteer": "^18.0.5",
"rimraf": "^3.0.2",
"rollup": "^2.57.0",
"rollup-plugin-terser": "^7.0.2",
@ -57,9 +57,9 @@
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz",
"integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==",
"version": "7.19.1",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz",
"integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==",
"dev": true,
"engines": {
"node": ">=6.9.0"
@ -465,9 +465,9 @@
}
},
"node_modules/@rollup/plugin-node-resolve": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz",
"integrity": "sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==",
"version": "14.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-14.1.0.tgz",
"integrity": "sha512-5G2niJroNCz/1zqwXtk0t9+twOSDlG00k1Wfd7bkbbXmwg8H8dvgHdIWAun53Ps/rckfvOC7scDBjuGFg5OaWw==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^3.1.0",
@ -481,7 +481,7 @@
"node": ">= 10.0.0"
},
"peerDependencies": {
"rollup": "^2.42.0"
"rollup": "^2.78.0"
}
},
"node_modules/@rollup/plugin-replace": {
@ -586,15 +586,15 @@
"dev": true
},
"node_modules/@types/mocha": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz",
"integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==",
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.0.tgz",
"integrity": "sha512-rADY+HtTOA52l9VZWtgQfn4p+UDVM2eDVkMZT1I6syp0YKxW2F9v+0pbRZLsvskhQv/vMb6ZfCay81GHbz5SHg==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.7.16",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.16.tgz",
"integrity": "sha512-EQHhixfu+mkqHMZl1R2Ovuvn47PUw18azMJOTwSZr9/fhzHNGXAJ0ma0dayRVchprpCj0Kc1K1xKoWaATWF1qg==",
"version": "18.8.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.0.tgz",
"integrity": "sha512-u+h43R6U8xXDt2vzUaVP3VwjjLyOJk6uEciZS8OSyziUQGOwmk+l+4drxcsDboHXwyTaqS1INebghmWMRxq3LA==",
"dev": true
},
"node_modules/@types/resolve": {
@ -1019,9 +1019,9 @@
]
},
"node_modules/bigint-mod-arith": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.1.tgz",
"integrity": "sha512-SzFqdncZKXq5uh3oLFZXmzaZEMDsA7ml9l53xKaVGO6/+y26xNwAaTQEg2R+D+d07YduLbKi0dni3YPsR51UDQ==",
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.2.tgz",
"integrity": "sha512-nx8J8bBeiRR+NlsROFH9jHswW5HO8mgfOSqW0AmjicMMvaONDa8AO+5ViKDUUNytBPWiwfvZP4/Bj4Y3lUfvgQ==",
"engines": {
"node": ">=10.4.0"
}
@ -1424,9 +1424,9 @@
}
},
"node_modules/devtools-protocol": {
"version": "0.0.1019158",
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1019158.tgz",
"integrity": "sha512-wvq+KscQ7/6spEV7czhnZc9RM/woz1AY+/Vpd8/h2HFMwJSdTliu7f/yr1A6vDdJfKICZsShqsYpEQbdhg8AFQ==",
"version": "0.0.1036444",
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1036444.tgz",
"integrity": "sha512-0y4f/T8H9lsESV9kKP1HDUXgHxCdniFeJh6Erq+FbdOEvp/Ydp9t8kcAAM5gOd17pMrTDlFWntoHtzzeTUWKNw==",
"dev": true
},
"node_modules/diff": {
@ -1472,9 +1472,9 @@
}
},
"node_modules/dotenv": {
"version": "16.0.2",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.2.tgz",
"integrity": "sha512-JvpYKUmzQhYoIFgK2MOnF3bciIZoItIIoryihy0rIA+H4Jy0FmgyKYAHCTN98P5ybGSJcIFbh6QKeJdtZd1qhA==",
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"dev": true,
"engines": {
"node": ">=12"
@ -1517,22 +1517,22 @@
}
},
"node_modules/es-abstract": {
"version": "1.20.2",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.2.tgz",
"integrity": "sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==",
"version": "1.20.3",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.3.tgz",
"integrity": "sha512-AyrnaKVpMzljIdwjzrj+LxGmj8ik2LckwXacHqrJJ/jxz6dDDBcZ7I7nlHM0FvEW8MfbWJwOd+yT2XzYW49Frw==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"function.prototype.name": "^1.1.5",
"get-intrinsic": "^1.1.2",
"get-intrinsic": "^1.1.3",
"get-symbol-description": "^1.0.0",
"has": "^1.0.3",
"has-property-descriptors": "^1.0.0",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"is-callable": "^1.2.4",
"is-callable": "^1.2.6",
"is-negative-zero": "^2.0.2",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
@ -1542,6 +1542,7 @@
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"safe-regex-test": "^1.0.0",
"string.prototype.trimend": "^1.0.5",
"string.prototype.trimstart": "^1.0.5",
"unbox-primitive": "^1.0.2"
@ -2543,9 +2544,9 @@
}
},
"node_modules/get-intrinsic": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz",
"integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz",
"integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==",
"dev": true,
"dependencies": {
"function-bind": "^1.1.1",
@ -2941,9 +2942,9 @@
}
},
"node_modules/is-callable": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.5.tgz",
"integrity": "sha512-ZIWRujF6MvYGkEuHMYtFRkL2wAtFw89EHfKlXrkPkjQZZRWeh9L1q3SV13NIfHnqxugjLvAOkEHx9mb1zcMnEw==",
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
"dev": true,
"engines": {
"node": ">= 0.4"
@ -3421,9 +3422,9 @@
}
},
"node_modules/marked": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.1.0.tgz",
"integrity": "sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.1.1.tgz",
"integrity": "sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==",
"dev": true,
"bin": {
"marked": "bin/marked.js"
@ -4347,70 +4348,6 @@
"node": ">=6"
}
},
"node_modules/pkg-dir": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
"integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
"dev": true,
"dependencies": {
"find-up": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/pkg-dir/node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dev": true,
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/pkg-dir/node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dev": true,
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/pkg-dir/node_modules/p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dev": true,
"dependencies": {
"p-try": "^2.0.0"
},
"engines": {
"node": ">=6"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/pkg-dir/node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dev": true,
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@ -4466,24 +4403,23 @@
}
},
"node_modules/puppeteer": {
"version": "15.5.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-15.5.0.tgz",
"integrity": "sha512-+vZPU8iBSdCx1Kn5hHas80fyo0TiVyMeqLGv/1dygX2HKhAZjO9YThadbRTCoTYq0yWw+w/CysldPsEekDtjDQ==",
"version": "18.0.5",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-18.0.5.tgz",
"integrity": "sha512-s4erjxU0VtKojPvF+KvLKG6OHUPw7gO2YV1dtOsoryyCbhrs444fXb4QZqGWuTv3V/rgSCUzeixxu34g0ZkSMA==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"cross-fetch": "3.1.5",
"debug": "4.3.4",
"devtools-protocol": "0.0.1019158",
"devtools-protocol": "0.0.1036444",
"extract-zip": "2.0.1",
"https-proxy-agent": "5.0.1",
"pkg-dir": "4.2.0",
"progress": "2.0.3",
"proxy-from-env": "1.1.0",
"rimraf": "3.0.2",
"tar-fs": "2.1.1",
"unbzip2-stream": "1.4.3",
"ws": "8.8.0"
"ws": "8.8.1"
},
"engines": {
"node": ">=14.1.0"
@ -4705,9 +4641,9 @@
}
},
"node_modules/rollup": {
"version": "2.79.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz",
"integrity": "sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==",
"version": "2.79.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz",
"integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==",
"dev": true,
"bin": {
"rollup": "dist/bin/rollup"
@ -4786,6 +4722,20 @@
}
]
},
"node_modules/safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
"integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"is-regex": "^1.1.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
@ -5409,9 +5359,9 @@
}
},
"node_modules/typedoc": {
"version": "0.23.14",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.14.tgz",
"integrity": "sha512-s2I+ZKBET38EctZvbXp2GooHrNaKjWZkrwGEK/sttnOGiKJqU0vHrsdcwLgKZGuo2aedNL3RRPj1LnAAeYscig==",
"version": "0.23.15",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.15.tgz",
"integrity": "sha512-x9Zu+tTnwxb9YdVr+zvX7LYzyBl1nieOr6lrSHbHsA22/RJK2m4Y525WIg5Mj4jWCmfL47v6f4hUzY7EIuwS5w==",
"dev": true,
"dependencies": {
"lunr": "^2.3.9",
@ -5442,9 +5392,9 @@
}
},
"node_modules/typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"version": "4.8.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz",
"integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@ -5455,9 +5405,9 @@
}
},
"node_modules/uglify-js": {
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.0.tgz",
"integrity": "sha512-aTeNPVmgIMPpm1cxXr2Q/nEbvkmV8yq66F3om7X3P/cvOXQ0TMQ64Wk63iyT1gPlmdmGzjGpyLh1f3y8MZWXGg==",
"version": "3.17.2",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.2.tgz",
"integrity": "sha512-bbxglRjsGQMchfvXZNusUcYgiB9Hx2K4AHYXQy2DITZ9Rd+JzhX7+hoocE5Winr7z2oHvPsekkBwXtigvxevXg==",
"dev": true,
"optional": true,
"bin": {
@ -5650,9 +5600,9 @@
"dev": true
},
"node_modules/ws": {
"version": "8.8.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz",
"integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==",
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz",
"integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==",
"dev": true,
"engines": {
"node": ">=10.0.0"
@ -5770,9 +5720,9 @@
}
},
"@babel/helper-validator-identifier": {
"version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz",
"integrity": "sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==",
"version": "7.19.1",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz",
"integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==",
"dev": true
},
"@babel/highlight": {
@ -6102,9 +6052,9 @@
}
},
"@rollup/plugin-node-resolve": {
"version": "13.3.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.3.0.tgz",
"integrity": "sha512-Lus8rbUo1eEcnS4yTFKLZrVumLPY+YayBdWXgFSHYhTT2iJbMhoaaBL3xl5NCdeRytErGr8tZ0L71BMRmnlwSw==",
"version": "14.1.0",
"resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-14.1.0.tgz",
"integrity": "sha512-5G2niJroNCz/1zqwXtk0t9+twOSDlG00k1Wfd7bkbbXmwg8H8dvgHdIWAun53Ps/rckfvOC7scDBjuGFg5OaWw==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^3.1.0",
@ -6192,15 +6142,15 @@
"dev": true
},
"@types/mocha": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz",
"integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==",
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.0.tgz",
"integrity": "sha512-rADY+HtTOA52l9VZWtgQfn4p+UDVM2eDVkMZT1I6syp0YKxW2F9v+0pbRZLsvskhQv/vMb6ZfCay81GHbz5SHg==",
"dev": true
},
"@types/node": {
"version": "18.7.16",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.16.tgz",
"integrity": "sha512-EQHhixfu+mkqHMZl1R2Ovuvn47PUw18azMJOTwSZr9/fhzHNGXAJ0ma0dayRVchprpCj0Kc1K1xKoWaATWF1qg==",
"version": "18.8.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.0.tgz",
"integrity": "sha512-u+h43R6U8xXDt2vzUaVP3VwjjLyOJk6uEciZS8OSyziUQGOwmk+l+4drxcsDboHXwyTaqS1INebghmWMRxq3LA==",
"dev": true
},
"@types/resolve": {
@ -6472,9 +6422,9 @@
"dev": true
},
"bigint-mod-arith": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.1.tgz",
"integrity": "sha512-SzFqdncZKXq5uh3oLFZXmzaZEMDsA7ml9l53xKaVGO6/+y26xNwAaTQEg2R+D+d07YduLbKi0dni3YPsR51UDQ=="
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bigint-mod-arith/-/bigint-mod-arith-3.1.2.tgz",
"integrity": "sha512-nx8J8bBeiRR+NlsROFH9jHswW5HO8mgfOSqW0AmjicMMvaONDa8AO+5ViKDUUNytBPWiwfvZP4/Bj4Y3lUfvgQ=="
},
"binary-extensions": {
"version": "2.2.0",
@ -6776,9 +6726,9 @@
}
},
"devtools-protocol": {
"version": "0.0.1019158",
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1019158.tgz",
"integrity": "sha512-wvq+KscQ7/6spEV7czhnZc9RM/woz1AY+/Vpd8/h2HFMwJSdTliu7f/yr1A6vDdJfKICZsShqsYpEQbdhg8AFQ==",
"version": "0.0.1036444",
"resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1036444.tgz",
"integrity": "sha512-0y4f/T8H9lsESV9kKP1HDUXgHxCdniFeJh6Erq+FbdOEvp/Ydp9t8kcAAM5gOd17pMrTDlFWntoHtzzeTUWKNw==",
"dev": true
},
"diff": {
@ -6814,9 +6764,9 @@
}
},
"dotenv": {
"version": "16.0.2",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.2.tgz",
"integrity": "sha512-JvpYKUmzQhYoIFgK2MOnF3bciIZoItIIoryihy0rIA+H4Jy0FmgyKYAHCTN98P5ybGSJcIFbh6QKeJdtZd1qhA==",
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"dev": true
},
"emoji-regex": {
@ -6853,22 +6803,22 @@
}
},
"es-abstract": {
"version": "1.20.2",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.2.tgz",
"integrity": "sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==",
"version": "1.20.3",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.3.tgz",
"integrity": "sha512-AyrnaKVpMzljIdwjzrj+LxGmj8ik2LckwXacHqrJJ/jxz6dDDBcZ7I7nlHM0FvEW8MfbWJwOd+yT2XzYW49Frw==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"function.prototype.name": "^1.1.5",
"get-intrinsic": "^1.1.2",
"get-intrinsic": "^1.1.3",
"get-symbol-description": "^1.0.0",
"has": "^1.0.3",
"has-property-descriptors": "^1.0.0",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"is-callable": "^1.2.4",
"is-callable": "^1.2.6",
"is-negative-zero": "^2.0.2",
"is-regex": "^1.1.4",
"is-shared-array-buffer": "^1.0.2",
@ -6878,6 +6828,7 @@
"object-keys": "^1.1.1",
"object.assign": "^4.1.4",
"regexp.prototype.flags": "^1.4.3",
"safe-regex-test": "^1.0.0",
"string.prototype.trimend": "^1.0.5",
"string.prototype.trimstart": "^1.0.5",
"unbox-primitive": "^1.0.2"
@ -7616,9 +7567,9 @@
"dev": true
},
"get-intrinsic": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz",
"integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==",
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz",
"integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==",
"dev": true,
"requires": {
"function-bind": "^1.1.1",
@ -7887,9 +7838,9 @@
}
},
"is-callable": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.5.tgz",
"integrity": "sha512-ZIWRujF6MvYGkEuHMYtFRkL2wAtFw89EHfKlXrkPkjQZZRWeh9L1q3SV13NIfHnqxugjLvAOkEHx9mb1zcMnEw==",
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
"dev": true
},
"is-core-module": {
@ -8239,9 +8190,9 @@
}
},
"marked": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.1.0.tgz",
"integrity": "sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.1.1.tgz",
"integrity": "sha512-0cNMnTcUJPxbA6uWmCmjWz4NJRe/0Xfk2NhXCUHjew9qJzFN20krFnsUe7QynwqOwa5m1fZ4UDg0ycKFVC0ccw==",
"dev": true
},
"matched": {
@ -8925,54 +8876,6 @@
}
}
},
"pkg-dir": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
"integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
"dev": true,
"requires": {
"find-up": "^4.0.0"
},
"dependencies": {
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dev": true,
"requires": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
}
},
"locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dev": true,
"requires": {
"p-locate": "^4.1.0"
}
},
"p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dev": true,
"requires": {
"p-try": "^2.0.0"
}
},
"p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dev": true,
"requires": {
"p-limit": "^2.2.0"
}
}
}
},
"prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@ -9019,23 +8922,22 @@
"dev": true
},
"puppeteer": {
"version": "15.5.0",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-15.5.0.tgz",
"integrity": "sha512-+vZPU8iBSdCx1Kn5hHas80fyo0TiVyMeqLGv/1dygX2HKhAZjO9YThadbRTCoTYq0yWw+w/CysldPsEekDtjDQ==",
"version": "18.0.5",
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-18.0.5.tgz",
"integrity": "sha512-s4erjxU0VtKojPvF+KvLKG6OHUPw7gO2YV1dtOsoryyCbhrs444fXb4QZqGWuTv3V/rgSCUzeixxu34g0ZkSMA==",
"dev": true,
"requires": {
"cross-fetch": "3.1.5",
"debug": "4.3.4",
"devtools-protocol": "0.0.1019158",
"devtools-protocol": "0.0.1036444",
"extract-zip": "2.0.1",
"https-proxy-agent": "5.0.1",
"pkg-dir": "4.2.0",
"progress": "2.0.3",
"proxy-from-env": "1.1.0",
"rimraf": "3.0.2",
"tar-fs": "2.1.1",
"unbzip2-stream": "1.4.3",
"ws": "8.8.0"
"ws": "8.8.1"
}
},
"queue-microtask": {
@ -9187,9 +9089,9 @@
}
},
"rollup": {
"version": "2.79.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz",
"integrity": "sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==",
"version": "2.79.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz",
"integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==",
"dev": true,
"requires": {
"fsevents": "~2.3.2"
@ -9233,6 +9135,17 @@
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"dev": true
},
"safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
"integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"get-intrinsic": "^1.1.3",
"is-regex": "^1.1.4"
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
@ -9723,9 +9636,9 @@
"dev": true
},
"typedoc": {
"version": "0.23.14",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.14.tgz",
"integrity": "sha512-s2I+ZKBET38EctZvbXp2GooHrNaKjWZkrwGEK/sttnOGiKJqU0vHrsdcwLgKZGuo2aedNL3RRPj1LnAAeYscig==",
"version": "0.23.15",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.15.tgz",
"integrity": "sha512-x9Zu+tTnwxb9YdVr+zvX7LYzyBl1nieOr6lrSHbHsA22/RJK2m4Y525WIg5Mj4jWCmfL47v6f4hUzY7EIuwS5w==",
"dev": true,
"requires": {
"lunr": "^2.3.9",
@ -9744,15 +9657,15 @@
}
},
"typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"version": "4.8.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz",
"integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==",
"dev": true
},
"uglify-js": {
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.0.tgz",
"integrity": "sha512-aTeNPVmgIMPpm1cxXr2Q/nEbvkmV8yq66F3om7X3P/cvOXQ0TMQ64Wk63iyT1gPlmdmGzjGpyLh1f3y8MZWXGg==",
"version": "3.17.2",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.2.tgz",
"integrity": "sha512-bbxglRjsGQMchfvXZNusUcYgiB9Hx2K4AHYXQy2DITZ9Rd+JzhX7+hoocE5Winr7z2oHvPsekkBwXtigvxevXg==",
"dev": true,
"optional": true
},
@ -9912,9 +9825,9 @@
"dev": true
},
"ws": {
"version": "8.8.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.8.0.tgz",
"integrity": "sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==",
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz",
"integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==",
"dev": true,
"requires": {}
},

View File

@ -43,75 +43,83 @@
"./umd-browser-bundle": "./dist/bundles/umd.js",
"./types": "./types/index.d.ts"
},
"imports": {
"#pkg": {
"import": "./dist/esm/index.node.js",
"require": "./dist/cjs/index.node.cjs"
}
},
"directories": {
"build": "./build",
"dist": "./dist",
"docs": "./docs",
"src": "./src",
"test": "./test"
"test": "./test",
"benchmark": "./benchmark",
"mocha-ts": "./.mocha-ts"
},
"scripts": {
"build": "run-s lint build:js docs",
"build:js": "rollup -c build/rollup.config.js",
"clean": "rimraf .mocha-ts coverage dist types docs",
"coverage": "c8 --clean --check-coverage --exclude-after-remap --exclude '{build,node_modules,src/ts/**/*.spec.ts,test/**/*.ts,.mocha-ts/**/*}' --reporter=text --reporter=lcov node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js '{src/ts/**/*.spec.ts,test/**/*.ts}'",
"coverage": "c8 --clean --check-coverage --exclude '{src/ts/**/*.spec.ts,test,test-vectors,build}' --exclude-after-remap --reporter=text --reporter=lcov node ./build/bin/mocha-ts.cjs --commonjs ",
"docs": "node build/build.docs.cjs",
"git:add": "git add -A",
"lint": "ts-standard --fix",
"mocha-ts": "node ./build/bin/mocha-ts.js --require build/testing/mocha/mocha-init.js ",
"mocha-ts": "node --experimental-modules --es-module-specifier-resolution=node ./build/bin/mocha-ts.cjs ",
"mocha-ts:cjs": "node ./build/bin/mocha-ts.cjs --commonjs ",
"mocha-ts:watch": "npm run mocha-ts:cjs -- --watch ",
"mocha-ts:browser": "node build/testing/browser/index.cjs ",
"mocha-ts:browser-headless": "node build/testing/browser/index.cjs headless ",
"preversion": "run-s clean lint build:js coverage test:browser-headless",
"version": "run-s docs git:add",
"postversion": "git push --follow-tags",
"test": "run-s test:browser-headless test:node",
"test": "run-s test:node test:browser-headless",
"test:browser": "npm run mocha-ts:browser",
"test:browser-headless": "npm run mocha-ts:browser-headless",
"test:node": "npm run mocha-ts -- '{src/ts/**/*.spec.ts,test/**/*.ts}'",
"watch": "npm run mocha-ts -- --watch '{src/ts/**/*.spec.ts,test/**/*.ts}'"
"test:node": "run-s test:node-cjs test:node-esm",
"test:node-cjs": "npm run mocha-ts:cjs ",
"test:node-esm": "npm run mocha-ts ",
"watch": "npm run mocha-ts:watch "
},
"ts-standard": {
"project": "tsconfig.json",
"env": [
"mocha"
],
"globals": [
"Blob",
"postMessage",
"self",
"Worker",
"IS_BROWSER",
"browser",
"page",
"_pkg",
"chai"
],
"project": "tsconfig.json",
"ignore": [
"dist/**/*",
"examples/**/*",
"types/**/*"
"types/**/*",
"build/testing/mocha/mocha-init.js"
]
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^4.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-node-resolve": "^14.1.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.2.0",
"@types/chai": "^4.2.22",
"@types/mocha": "^9.0.0",
"@types/mocha": "^10.0.0",
"c8": "^7.12.0",
"chai": "^4.3.3",
"dotenv": "^16.0.0",
"fs-extra": "^10.0.0",
"dotenv": "^16.0.3",
"fs-extra": "^10.1.0",
"glob": "^8.0.1",
"json5": "^2.2.0",
"minimatch": "^5.0.1",
"mocha": "^10.0.0",
"npm-run-all": "^4.1.5",
"pirates": "^4.0.1",
"puppeteer": "^15.5.0",
"puppeteer": "^18.0.5",
"rimraf": "^3.0.2",
"rollup": "^2.57.0",
"rollup-plugin-terser": "^7.0.2",

View File

@ -1,3 +1,5 @@
import * as bcu from '#pkg'
describe('isProbablyPrime', function () {
this.timeout(90000)
const numbers = [
@ -79,15 +81,15 @@ describe('isProbablyPrime', function () {
describe(`isProbablyPrime(${num.value}, ${num.iterations}, ${String(!num.workers)})`, function () {
it(`should return ${String(num.prime)}`, async function () {
let ret
if (num.iterations === 16 && num.workers) ret = await _pkg.isProbablyPrime(num.value)
else ret = await _pkg.isProbablyPrime(num.value, num.iterations, !num.workers)
if (num.iterations === 16 && num.workers) ret = await bcu.isProbablyPrime(num.value)
else ret = await bcu.isProbablyPrime(num.value, num.iterations, !num.workers)
chai.expect(ret).to.equal(num.prime)
})
})
}
describe('isProbablyPrime(-1)', function () {
it('should throw RangeError', function () {
chai.expect(() => _pkg.isProbablyPrime(-1)).to.throw(RangeError) // eslint-disable-line
chai.expect(() => bcu.isProbablyPrime(-1)).to.throw(RangeError) // eslint-disable-line
})
})
})

View File

@ -1,3 +1,5 @@
import * as bcu from '#pkg'
describe('Testing prime generation', function () {
const bitLengths = [
0,
@ -15,21 +17,21 @@ describe('Testing prime generation', function () {
describe(`prime(${bitLength})`, function () {
if (bitLength > 0) {
it(`should return a random ${bitLength}-bits probable prime`, async function () {
const prime = await _pkg.prime(bitLength)
chai.expect(_pkg.bitLength(prime)).to.equal(bitLength)
const prime = await bcu.prime(bitLength)
chai.expect(bcu.bitLength(prime)).to.equal(bitLength)
})
} else {
it('should throw error', function () {
chai.expect(() => _pkg.prime(bitLength)).to.throw(RangeError) // eslint-disable-line
chai.expect(() => bcu.prime(bitLength)).to.throw(RangeError) // eslint-disable-line
})
}
})
}
describe('Testing sync (NOT-RECOMMENDED) version: primeSync()', function () {
it('should return a random 1024-bits probable prime', function () {
const prime = _pkg.primeSync(1024, 16)
chai.expect(_pkg.bitLength(prime)).to.equal(1024)
chai.expect(() => _pkg.primeSync(0)).to.throw(RangeError)
const prime = bcu.primeSync(1024, 16)
chai.expect(bcu.bitLength(prime)).to.equal(1024)
chai.expect(() => bcu.primeSync(0)).to.throw(RangeError)
})
})
})

View File

@ -1,3 +1,5 @@
import * as bcu from '#pkg'
describe('randBetween', function () {
const numbers = [
{
@ -57,14 +59,14 @@ describe('randBetween', function () {
it(`[${num.iterations} iterations] should return x such that min <= x <= max`, function () {
let ret = true
for (let i = 0; i < num.iterations; i++) {
const x = _pkg.randBetween(num.max, num.min)
const x = bcu.randBetween(num.max, num.min)
ret = ret && x >= num.min && x <= num.max
}
chai.expect(ret).to.equal(true)
})
} else {
it('should throw RangeError (max <=0 || min <0 || min>=max)', function () {
chai.expect(() => _pkg.randBetween(num.max, num.min)).to.throw(RangeError)
chai.expect(() => bcu.randBetween(num.max, num.min)).to.throw(RangeError)
})
}
})
@ -73,14 +75,14 @@ describe('randBetween', function () {
it(`[${num.iterations} iterations] should return x such that 1 <= x <= max`, function () {
let ret = true
for (let i = 0; i < num.iterations; i++) {
const x = _pkg.randBetween(num.max)
const x = bcu.randBetween(num.max)
ret = ret && x >= BigInt(1) && x <= num.max
}
chai.expect(ret).to.equal(true)
})
} else {
it('should throw RangeError (max <= min)', function () {
chai.expect(() => _pkg.randBetween(num.max)).to.throw(RangeError)
chai.expect(() => bcu.randBetween(num.max)).to.throw(RangeError)
})
}
})

View File

@ -1,3 +1,5 @@
import * as bcu from '#pkg'
const iterations = 10
const bitLengths = [-1, 0, 3, 8, 16, 511, 2048]
const byteLengths = [-7, 0, 1, 8, 33, 40]
@ -9,9 +11,9 @@ describe('testing randBits', function () {
it('should return buffers', function () {
let ret = true
for (let i = 0; i < iterations; i++) {
const randbits = _pkg.randBitsSync(bitLength)
const randbits = bcu.randBitsSync(bitLength)
// console.log(JSON.stringify(randbits))
const randbits2 = _pkg.randBitsSync(bitLength, true)
const randbits2 = bcu.randBitsSync(bitLength, true)
// console.log(JSON.stringify(randbits2))
if (!(((randbits instanceof Uint8Array) && (randbits2 instanceof Uint8Array)) ||
((randbits instanceof Buffer) && (randbits2 instanceof Buffer)))) {
@ -23,7 +25,7 @@ describe('testing randBits', function () {
})
} else {
it('should throw RangeError', function () {
chai.expect(() => _pkg.randBitsSync(bitLength)).to.throw(RangeError)
chai.expect(() => bcu.randBitsSync(bitLength)).to.throw(RangeError)
})
}
})
@ -32,9 +34,9 @@ describe('testing randBits', function () {
it('should return buffers', async function () {
let ret = true
for (let i = 0; i < iterations; i++) {
const randbits = await _pkg.randBits(bitLength)
const randbits = await bcu.randBits(bitLength)
// console.log(JSON.stringify(randbits))
const randbits2 = await _pkg.randBits(bitLength, true)
const randbits2 = await bcu.randBits(bitLength, true)
// console.log(JSON.stringify(randbits2))
if (!(((randbits instanceof Uint8Array) && (randbits2 instanceof Uint8Array)) ||
((randbits instanceof Buffer) && (randbits2 instanceof Buffer)))) {
@ -46,7 +48,7 @@ describe('testing randBits', function () {
})
} else {
it('should throw RangeError', function () {
chai.expect(() => _pkg.randBits(bitLength)).to.throw(RangeError) // eslint-disable-line
chai.expect(() => bcu.randBits(bitLength)).to.throw(RangeError) // eslint-disable-line
})
}
})
@ -60,9 +62,9 @@ describe('testing randBytes', function () {
it('should return buffers', function () {
let ret = true
for (let i = 0; i < iterations; i++) {
const randbytes = _pkg.randBytesSync(byteLength)
const randbytes = bcu.randBytesSync(byteLength)
// console.log(JSON.stringify(randbits))
const randbytes2 = _pkg.randBytesSync(byteLength, true)
const randbytes2 = bcu.randBytesSync(byteLength, true)
// console.log(JSON.stringify(randbits2))
if (!(((randbytes instanceof Uint8Array) && (randbytes2 instanceof Uint8Array)) ||
((randbytes instanceof Buffer) && (randbytes2 instanceof Buffer)))) {
@ -73,7 +75,7 @@ describe('testing randBytes', function () {
})
} else {
it('should throw RangeError', function () {
chai.expect(() => _pkg.randBytesSync(byteLength)).to.throw(RangeError)
chai.expect(() => bcu.randBytesSync(byteLength)).to.throw(RangeError)
})
}
})
@ -82,9 +84,9 @@ describe('testing randBytes', function () {
it('should return buffers', async function () {
let ret = true
for (let i = 0; i < iterations; i++) {
const randbytes = await _pkg.randBytes(byteLength)
const randbytes = await bcu.randBytes(byteLength)
// console.log(JSON.stringify(randbits))
const randbytes2 = await _pkg.randBytes(byteLength, true)
const randbytes2 = await bcu.randBytes(byteLength, true)
// console.log(JSON.stringify(randbits2))
if (!(((randbytes instanceof Uint8Array) && (randbytes2 instanceof Uint8Array)) ||
((randbytes instanceof Buffer) && (randbytes2 instanceof Buffer)))) {
@ -95,7 +97,7 @@ describe('testing randBytes', function () {
})
} else {
it('should throw RangeError', function () {
chai.expect(() => _pkg.randBytes(byteLength)).to.throw(RangeError) // eslint-disable-line
chai.expect(() => bcu.randBytes(byteLength)).to.throw(RangeError) // eslint-disable-line
})
}
})

View File

@ -36,7 +36,10 @@
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"resolveJsonModule": true
},
"include": ["src/ts/**/*", "test/**/*", "build/typings/**/*.d.ts"]
"resolveJsonModule": true,
"paths": {
"#pkg": ["."]
}
},
"include": ["src/ts/**/*", "build/typings/**/*.d.ts", "test/**/*", "test-vectors/**/*.ts", "benchmark/**/*.ts"]
}