diff --git a/.eslintrc b/.eslintrc
index 11651495..cea2e6c9 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -19,7 +19,7 @@
"script/*.js",
"script/*.d.ts",
"docs/",
- "docs-raw/",
+ "doc-unminified/",
"test/unit/compat/",
"test/bench/"
]
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index c1bf1851..370221f8 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -22,10 +22,6 @@ jobs:
- x64
cpp_arch:
- x64
- ARCH:
- - x64
- zmq_draft:
- - false
docker:
- ""
docker_cmd:
@@ -34,31 +30,24 @@ jobs:
include:
- os: windows-2022
node_version: 18
- node_arch: x86
- ARCH: x86
+ node_arch: ia32
cpp_arch: amd64_x86
- zmq_draft: false
# - os: windows-2022
# node_version: 18
# node_arch: x64
- # ARCH: arm64
+ # arch: arm64
# cpp_arch: amd64_arm64
- # zmq_draft: false
- os: macos-13
node_version: 18
node_arch: x64
- ARCH: x86_64
cpp_arch: x64
- zmq_draft: false
- os: macos-14
node_version: 18
node_arch: arm64
- ARCH: arm64
cpp_arch: amd64_arm64
- zmq_draft: false
# Alpine
- os: ubuntu-22.04
@@ -69,14 +58,14 @@ jobs:
build.prebuild
node_version: 18
node_arch: x64
- ARCH: x64
cpp_arch: x64
- zmq_draft: false
env:
- ZMQ_DRAFT: ${{ matrix.zmq_draft }}
- ZMQ_SHARED: false
- ARCH: ${{ matrix.ARCH }}
+ npm_config_zmq_draft: false
+ npm_config_zmq_shared: false
+ npm_config_arch: ${{ matrix.node_arch }}
+ npm_config_target_arch: ${{ matrix.node_arch }}
+ setup_node_arch: ${{ matrix.node_arch }}
steps:
- uses: actions/checkout@v4
@@ -87,11 +76,17 @@ jobs:
./node_modules/
./build/
key:
- "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch
- }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version
- }}-${{ hashFiles('./package.json') }}"
+ # prettier-ignore
+ "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch}}-ZMQ_DRAFT:${{env.npm_config_zmq_draft }}-Node:${{ matrix.node_version}}-${{hashFiles('./package.json') }}"
restore-keys: |
- "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ matrix.zmq_draft }}-Node:${{ matrix.node_version }}-"
+ "cache-OS:${{ matrix.os }}-arch:${{ matrix.node_arch }}-ZMQ_DRAFT:${{ env.npm_config_zmq_draft }}-Node:${{ matrix.node_version }}-"
+
+ - name: Env map
+ run: |
+ if [ "${{ matrix.node_arch }}" = "ia32" ]; then
+ echo "setup_node_arch=x86" > $GITHUB_ENV
+ fi
+ shell: bash
- name: Setup Cpp
if: ${{ !matrix.docker }}
@@ -112,21 +107,20 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- architecture: ${{ matrix.node_arch }}
+ architecture: ${{ env.setup_node_arch }}
- name: Install Mac-OS x86_64 Dependencies
- if: ${{ contains(matrix.os, 'macos') && matrix.ARCH == 'x86_64' }}
+ if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'x64' }}
run: |
brew install libsodium gnutls
- name: Install Mac-OS arm64 Dependencies
- if: ${{ contains(matrix.os, 'macos') && matrix.ARCH == 'arm64' }}
+ if: ${{ contains(matrix.os, 'macos') && matrix.node_arch == 'arm64' }}
run: |
brew uninstall libsodium --force --ignore-dependencies
source ./script/macos-arm-deps.sh
echo "PATH=$PATH" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
- echo "npm_config_target_arch=$npm_config_target_arch" >> $GITHUB_ENV
- name: Install Dependencies and Build
if: ${{ !matrix.docker }}
@@ -155,7 +149,7 @@ jobs:
if: "${{ contains(matrix.os, 'ubuntu') && !matrix.docker }}"
run: pnpm run lint-test
- - name: Test (Debug)
+ - name: Test
if: ${{ !matrix.docker }}
uses: nick-fields/retry@v3
with:
diff --git a/.gitignore b/.gitignore
index f369c2cc..fbd8dd1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,18 +13,12 @@ build-tmp-napi-v*
test.js
.cache/
test/typings-compatibility/
-/script/*.js
-/script/*.mjs
+/script/*js
/script/*.d.ts
-/script/*.d.mts
-/script/*.js.map
-/script/*.mjs.map
-/script/*/*.js
-/script/*/*.mjs
-/script/*/*.d.ts
-/script/*/*.js.map
+/script/*.d.*ts
+/script/*js.map
tsconfig.tsbuildinfo
-tsconfig.esm.tsbuildinfo
-/docs-raw
+tsconfig.*.tsbuildinfo
+/doc-unminified
.DS_Store
.idea
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 73f69e09..00000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
-# Editor-based HTTP Client requests
-/httpRequests/
diff --git a/.npmrc b/.npmrc
index 83a8ac89..7cd35e4d 100644
--- a/.npmrc
+++ b/.npmrc
@@ -1,6 +1,2 @@
-public-hoist-pattern[]=*
-package-lock=false
-lockfile=true
-prefer-frozen-lockfile=false
-strict-peer-dependencies=false
+# Zmq settings
build-from-source=true
diff --git a/.prettierignore b/.prettierignore
index d1955fc5..41b46290 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,5 +1,5 @@
/docs/
-/docs-raw
+/doc-unminified
/lib
/prebuilds
/node_modules
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 989bd09a..a7849c88 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -4,5 +4,18 @@
"mochaExplorer.nodeArgv": [
"--expose-gc"
],
- "mochaExplorer.debuggerConfig": "JS-Attach"
+ "mochaExplorer.debuggerConfig": "JS-Attach",
+ "files.exclude": {
+ "**/.git": true,
+ "**/.DS_Store": true,
+ "**/Thumbs.db": true,
+ "**/.cache": true,
+ "**/script/*.js": true,
+ "**/script/*.mjs": true,
+ "**/script/*.js.map": true,
+ "**/script/*.mjs.map": true,
+ "**/script/*.d.ts": true,
+ "**/script/*.d.mts": true,
+ "**/script/*.tsbuildinfo": true,
+ }
}
diff --git a/LICENSE b/LICENSE
index 9da36d45..7f4ecb8c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,7 @@
+Copyright 2019-2024 Amin Yahyaabadi
Copyright 2017-2019 Rolf Timmermans
+Copyright 2011 TJ Holowaychuk
+Copyright 2010, 2011 Justin Tulloss
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
diff --git a/README.md b/README.md
index 024afce8..8f9e8169 100644
--- a/README.md
+++ b/README.md
@@ -81,26 +81,88 @@ source:
- CMake 2.8+
- curl
-To install from source:
+To install from source, specify `build_from_source=true` in a `.npmrc` file
-```sh
-npm install zeromq@6.0.0-beta.20 --build-from-source
+```
+build_from_source=true
```
-If you want to link against a shared ZeroMQ library, you can build skip
-downloading `libzmq` and link with the installed library instead as follows:
+When building from source, you can also specify additional build options in a
+`.npmrc` file in your project:
-```sh
-npm install zeromq@6.0.0-beta.20 --zmq-shared
+### Available Build Options
+
+
+👉🏻 Options
+
+#### Draft support
+
+By default `libzmq` is built with support for `Draft` patterns (e.g.
+`server-client`, `radio-dish`, `scatter-gather`). If you want to build `libzmq`
+without support for `Draft`, you can specify the following in `.npmrc`:
+
+```ini
+zmq_draft=false
```
-If you wish to use any DRAFT sockets then it is also necessary to compile the
-library from source:
+#### Not Synchronous Resolve
-```sh
-npm install zeromq@6.0.0-beta.20 --zmq-draft
+If you want to send/receive on the socket immediately, you can specify the
+following in `.npmrc`:
+
+```ini
+zmq_no_sync_resolve="true"
+```
+
+#### Shared library support
+
+If you want to link against a shared ZeroMQ library installed on your system,
+you can build skip downloading `libzmq` and link with the installed library
+instead by specifying the following in `.npmrc`:
+
+```ini
+zmq_shared=true
+```
+
+#### Alternative libzmq version
+
+You can specify an alternative version or Git revision of `libzmq` to build
+against by specifying the following in `.npmrc`:
+
+```ini
+zmq_version="4.3.5"
+```
+
+#### Debug build of libzmq
+
+If you want to build `libzmq` with debug symbols, you can specify the following
+in `.npmrc`:
+
+```ini
+zmq_build_type="Debug"
```
+#### Cross-compilation for different architectures
+
+If you want to cross-compile for a different architecture, you can specify the
+following in `.npmrc`:
+
+```ini
+arch="arm64"
+target_arch="arm64"
+```
+
+#### MacOS Deployment Target
+
+If you want to specify the MacOS deployment target, you can specify the
+following in `.npmrc`:
+
+```ini
+macos_deployment_target="10.15"
+```
+
+
+
## Examples
**Note:** These examples assume the reader is familiar with ZeroMQ. If you are
diff --git a/binding.gyp b/binding.gyp
index 9b979e20..868a3961 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -12,24 +12,19 @@
{
'target_name': 'libzmq',
'type': 'none',
-
- 'conditions': [
- ["zmq_shared == 'false'", {
- 'actions': [{
- 'action_name': 'build_libzmq',
- 'inputs': [],
- 'conditions': [
- ['OS != "win"', {
- 'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.a', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'],
- }],
- ['OS == "win"', {
- 'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.lib', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'],
- }],
- ],
- 'action': ['node', '<(module_root_dir)/script/build.js'],
+ 'actions': [{
+ 'action_name': 'build_libzmq',
+ 'inputs': [],
+ 'conditions': [
+ ['OS != "win"', {
+ 'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.a', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'],
}],
- }],
- ],
+ ['OS == "win"', {
+ 'outputs': ['<(module_root_dir)/build/libzmq/lib/libzmq.lib', '<(module_root_dir)/build/libzmq/include/zmq.h', '<(module_root_dir)/build/libzmq/include/zmq_utils.h'],
+ }],
+ ],
+ 'action': ['node', '<(module_root_dir)/script/build.js'],
+ }],
},
{
diff --git a/package.json b/package.json
index 224e7fa9..6ff30bd1 100644
--- a/package.json
+++ b/package.json
@@ -83,13 +83,13 @@
],
"scripts": {
"install": "(npm run build.js || echo ok) && aminya-node-gyp-build --build-from-source",
- "clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo",
+ "clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.mjs ./script/*.js.map ./script/*.mjs.map ./script/*.d.ts ./script/*.d.mts ./script/*.cjs ./scripts/*.cjs.map ./scripts/*.d.cts ./script/*.tsbuildinfo",
"clean.release": "shx rm -rf ./build/Release",
"clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp",
"build.library": "tsc -p ./src/tsconfig.json",
- "build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json",
+ "build.script": "tsc -p ./script/tsconfig.esm.json && tsc -p ./script/tsconfig.json",
"build.js": "run-p build.script build.library",
- "build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser",
+ "build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-unminified -d docs --jsCompressor terser && shx rm -rf docs-unminified",
"deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"",
"build.prebuild": "run-s build.js && node ./script/prebuild.mjs",
"build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release",
@@ -127,5 +127,5 @@
"napi"
],
"license": "MIT",
- "author": "Rolf Timmermans "
+ "author": "Amin Yahyaabadi , Rolf Timmermans "
}
diff --git a/script/build.ts b/script/build.ts
index b342e18c..73319d66 100644
--- a/script/build.ts
+++ b/script/build.ts
@@ -1,14 +1,43 @@
import {dirname} from "path"
import {existsSync, writeFileSync} from "fs"
import {mkdir, cd, exec, find, mv} from "shelljs"
+import {toBool, toString} from "./utils.js"
const root = dirname(__dirname)
+type Options = {
+ zmq_shared: boolean
+ zmq_version: string
+ zmq_draft: boolean
+ zmq_build_type: string
+ arch: string
+ macosx_deployment_target?: string
+}
+
+function parseOptions(): Options {
+ return {
+ zmq_shared: toBool(process.env.npm_config_zmq_shared) ?? false,
+ zmq_draft: toBool(process.env.npm_config_zmq_draft) ?? false,
+ zmq_version:
+ toString(process.env.npm_config_zmq_version) ??
+ "5657b4586f24ec433930e8ece02ddba7afcf0fe0",
+ zmq_build_type:
+ toString(process.env.npm_config_zmq_build_type) ?? "Release",
+ arch: toString(process.env.npm_config_arch) ?? process.arch,
+ macosx_deployment_target:
+ toString(process.env.npm_config_macosx_deployment_target) ?? "10.15",
+ }
+}
+
function main() {
- const zmq_rev =
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
- process.env.ZMQ_VERSION || "5657b4586f24ec433930e8ece02ddba7afcf0fe0"
- const src_url = `https://github.com/zeromq/libzmq/archive/${zmq_rev}.tar.gz`
+ const opts = parseOptions()
+ console.log("Building libzmq with options ", opts)
+
+ if (opts.zmq_shared) {
+ return
+ }
+
+ const src_url = `https://github.com/zeromq/libzmq/archive/${opts.zmq_version}.tar.gz`
const libzmq_build_prefix = `${root}/build/libzmq-staging`
const libzmq_install_prefix = `${root}/build/libzmq`
@@ -17,29 +46,25 @@ function main() {
process.platform === "win32" ? ".lib" : ".a"
}`
- const src_dir = `libzmq-${zmq_rev}`
- const tarball = `libzmq-${zmq_rev}.tar.gz`
-
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
- const CMAKE_BUILD_TYPE = process.env.CMAKE_BUILD_TYPE || "Release"
+ const src_dir = `libzmq-${opts.zmq_version}`
+ const tarball = `libzmq-${opts.zmq_version}.tar.gz`
let build_options: string = ""
// https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html
if (process.platform === "win32") {
- if (CMAKE_BUILD_TYPE !== "Debug") {
+ if (opts.zmq_build_type !== "Debug") {
build_options += " -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL"
} else {
build_options += " -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL"
}
}
- build_options += archCMakeOptions()
+ build_options += archCMakeOptions(opts)
if (process.platform === "darwin") {
- const MACOSX_DEPLOYMENT_TARGET = "10.15"
- process.env.MACOSX_DEPLOYMENT_TARGET = MACOSX_DEPLOYMENT_TARGET
- build_options += ` -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}`
+ process.env.MACOSX_DEPLOYMENT_TARGET = opts.macosx_deployment_target
+ build_options += ` -DCMAKE_OSX_DEPLOYMENT_TARGET=${opts.macosx_deployment_target}`
}
mkdir("-p", libzmq_build_prefix)
@@ -65,12 +90,12 @@ function main() {
exec(`tar xzf "${tarball}"`, execOptions)
}
- if (process.env.ZMQ_DRAFT === "true") {
+ if (opts.zmq_draft) {
console.log("Enabling draft support")
build_options += " -DENABLE_DRAFTS=ON"
}
- console.log(`Building libzmq ${CMAKE_BUILD_TYPE}`)
+ console.log(`Building libzmq ${opts.zmq_build_type}`)
// ClangFormat include causes issues but is not required to build.
const clang_format_file = `${src_dir}/builds/cmake/Modules/ClangFormat.cmake`
@@ -78,11 +103,11 @@ function main() {
writeFileSync(clang_format_file, "")
}
- const cmake_configure = `cmake -S "${src_dir}" -B ./build ${build_options} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX="${libzmq_install_prefix}" -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_STATIC=ON -DBUILD_TESTS=OFF -DBUILD_SHARED=OFF -DWITH_DOCS=OFF -DWITH_LIBSODIUM=OFF`
+ const cmake_configure = `cmake -S "${src_dir}" -B ./build ${build_options} -DCMAKE_BUILD_TYPE=${opts.zmq_build_type} -DCMAKE_INSTALL_PREFIX="${libzmq_install_prefix}" -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_STATIC=ON -DBUILD_TESTS=OFF -DBUILD_SHARED=OFF -DWITH_DOCS=OFF -DWITH_LIBSODIUM=OFF`
console.log(cmake_configure)
exec(cmake_configure, execOptions)
- const cmake_build = `cmake --build ./build --config ${CMAKE_BUILD_TYPE} --target install --parallel`
+ const cmake_build = `cmake --build ./build --config ${opts.zmq_build_type} --target install --parallel`
console.log(cmake_build)
exec(cmake_build, execOptions)
@@ -95,9 +120,8 @@ function main() {
main()
-function archCMakeOptions() {
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
- const arch = (process.env.ARCH || process.arch).toLowerCase()
+function archCMakeOptions(opts: Options) {
+ const arch = opts.arch.toLowerCase()
if (process.platform === "win32") {
// CMAKE_GENERATOR_PLATFORM only supported on Windows
diff --git a/script/macos-arm-deps.sh b/script/macos-arm-deps.sh
index 2c70cdeb..a676df0a 100755
--- a/script/macos-arm-deps.sh
+++ b/script/macos-arm-deps.sh
@@ -44,4 +44,3 @@ export PATH="$HOME/arm-target/lib/:$PATH"
SODIUM_PATH=$(~/arm-target/bin/pkg-config libsodium --libs-only-L | sed -e 's/-L//g') # print only -L and replace "-L" itself
export PATH="$SODIUM_PATH:$PATH"
export PKG_CONFIG_PATH="$SODIUM_PATH:$PKG_CONFIG_PATH"
-export npm_config_target_arch=arm64
diff --git a/script/prebuild.mts b/script/prebuild.mts
index d7dd86bb..99a5076d 100644
--- a/script/prebuild.mts
+++ b/script/prebuild.mts
@@ -1,10 +1,30 @@
import {execaCommandSync} from "execa"
+import * as buildUtils from "./utils.js"
+const {toString} = buildUtils
+
+type Options = {
+ arch: string
+}
+
+function parserOptions(): Options {
+ return {
+ arch: toString(process.env.npm_config_arch) ?? process.arch,
+ }
+}
async function main() {
- console.log("Building distribution binary...")
+ const opts = parserOptions()
+
+ console.log("Building distribution binary with options ", opts)
- const prebuildArch = getNodearch()
+ const prebuildArch = getNodearch(opts)
+ process.env.ARCH = prebuildArch
+ process.env.npm_config_arch = prebuildArch
+ process.env.npm_config_target_arch = prebuildArch
+ process.env.PREBUILD_arch = prebuildArch
+
+ // TODO test the triple feature
if (typeof process.env.TRIPLE === "string") {
const TRIPLE = process.env.TRIPLE
@@ -15,10 +35,6 @@ async function main() {
const STRIP = `${TRIPLE}-strip`
process.env.PREBUILD_STRIP_BIN = STRIP
- process.env.npm_config_arch = prebuildArch
- process.env.npm_config_target_arch = prebuildArch
- process.env.PREBUILD_arch = prebuildArch
-
process.env.ZMQ_BUILD_OPTIONS = `--host=${TRIPLE}`
}
@@ -34,6 +50,7 @@ async function main() {
}
execaCommandSync(prebuildScript, {
+ env: process.env,
shell: true,
windowsHide: true,
stdio: "inherit",
@@ -45,10 +62,8 @@ main().catch(e => {
throw e
})
-function getNodearch(): string {
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
- const arch = process.env.ARCH || process.arch
- switch (arch) {
+function getNodearch(opts: Options): string {
+ switch (opts.arch) {
case "x86": {
return "ia32"
}
@@ -56,7 +71,7 @@ function getNodearch(): string {
return "x64"
}
default: {
- return arch
+ return opts.arch
}
}
}
diff --git a/script/tsconfig.esm.json b/script/tsconfig.esm.json
index 9789fa80..b0034fab 100644
--- a/script/tsconfig.esm.json
+++ b/script/tsconfig.esm.json
@@ -5,5 +5,5 @@
"moduleResolution": "node"
},
"include": ["./**/*.mts"],
- "exclude": []
+ "exclude": ["./**/*.d.mts"]
}
diff --git a/script/tsconfig.json b/script/tsconfig.json
index 35018299..7b200ed4 100644
--- a/script/tsconfig.json
+++ b/script/tsconfig.json
@@ -1,8 +1,14 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
- "outDir": "./"
+ "outDir": "./",
},
- "include": ["./**/*.ts"],
- "exclude": []
+ "include": [
+ "./**/*.ts",
+ "./**/*.cts"
+ ],
+ "exclude": [
+ "./**/*.d.ts",
+ "./**/*.d.cts"
+ ]
}
diff --git a/script/utils.ts b/script/utils.ts
new file mode 100644
index 00000000..72f9fb48
--- /dev/null
+++ b/script/utils.ts
@@ -0,0 +1,25 @@
+export function toBool(value: string | undefined): boolean | undefined {
+ switch (value) {
+ case "true":
+ case "1":
+ return true
+ case "false":
+ case "0":
+ return false
+ case undefined:
+ case "":
+ return undefined
+ default:
+ throw new Error(`Invalid boolean value: ${value}`)
+ }
+}
+
+export function toString(value: string | undefined): string | undefined {
+ switch (value) {
+ case undefined:
+ case "":
+ return undefined
+ default:
+ return value
+ }
+}
diff --git a/src/compat.ts b/src/compat.ts
index 815ed175..9adcadbf 100644
--- a/src/compat.ts
+++ b/src/compat.ts
@@ -1,27 +1,6 @@
-/* The API of the compatibility layer and parts of the implementation has been
- adapted from the original ZeroMQ.js version (up to 5.x) for which the license
- and copyright notice is reproduced below.
-
-Copyright (c) 2017-2019 Rolf Timmermans
-Copyright (c) 2011 TJ Holowaychuk
-Copyright (c) 2010, 2011 Justin Tulloss
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+/*
+ The API of the compatibility layer and parts of the implementation has been
+ adapted from the original ZeroMQ.js version (up to 5.x)
*/
import {EventEmitter} from "events"
diff --git a/src/context.cc b/src/context.cc
index e61db5ee..ba6295ee 100644
--- a/src/context.cc
+++ b/src/context.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#include "./context.h"
#include "./module.h"
diff --git a/src/context.h b/src/context.h
index 3a5913b1..f75c138d 100644
--- a/src/context.h
+++ b/src/context.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/incoming_msg.cc b/src/incoming_msg.cc
index 282bf28f..c2fa967c 100644
--- a/src/incoming_msg.cc
+++ b/src/incoming_msg.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#include "./incoming_msg.h"
#include
diff --git a/src/incoming_msg.h b/src/incoming_msg.h
index 5febfbc4..ba5c46c8 100644
--- a/src/incoming_msg.h
+++ b/src/incoming_msg.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/module.cc b/src/module.cc
index 3743502d..1904eb19 100644
--- a/src/module.cc
+++ b/src/module.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#include "./module.h"
#include "./context.h"
diff --git a/src/module.h b/src/module.h
index 7028070e..f60080e2 100644
--- a/src/module.h
+++ b/src/module.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/observer.cc b/src/observer.cc
index d470f960..5fb728c9 100644
--- a/src/observer.cc
+++ b/src/observer.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#include "./observer.h"
#include "./context.h"
diff --git a/src/observer.h b/src/observer.h
index 1b34dedb..e902b5e3 100644
--- a/src/observer.h
+++ b/src/observer.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/outgoing_msg.cc b/src/outgoing_msg.cc
index 269e850e..f32a4619 100644
--- a/src/outgoing_msg.cc
+++ b/src/outgoing_msg.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#include "./outgoing_msg.h"
#include "./module.h"
diff --git a/src/outgoing_msg.h b/src/outgoing_msg.h
index 6ec12609..a86d4373 100644
--- a/src/outgoing_msg.h
+++ b/src/outgoing_msg.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/poller.h b/src/poller.h
index b8fdc652..7f885f9c 100644
--- a/src/poller.h
+++ b/src/poller.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include "util/uvhandle.h"
diff --git a/src/proxy.cc b/src/proxy.cc
index 2b4b21bf..3f969cc3 100644
--- a/src/proxy.cc
+++ b/src/proxy.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#include "./proxy.h"
#include "./context.h"
diff --git a/src/proxy.h b/src/proxy.h
index 7527ba79..77e9faf2 100644
--- a/src/proxy.h
+++ b/src/proxy.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/socket.cc b/src/socket.cc
index 9f1dbc7c..998b07f6 100644
--- a/src/socket.cc
+++ b/src/socket.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
+
#define NOMINMAX // prevent minwindef.h from defining max macro in the debug build
diff --git a/src/socket.h b/src/socket.h
index d639ecb3..52d2ee89 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/arguments.h b/src/util/arguments.h
index 60845feb..faa168a4 100644
--- a/src/util/arguments.h
+++ b/src/util/arguments.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/async_scope.h b/src/util/async_scope.h
index 16b31795..746edf31 100644
--- a/src/util/async_scope.h
+++ b/src/util/async_scope.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/error.h b/src/util/error.h
index abde56c1..02197476 100644
--- a/src/util/error.h
+++ b/src/util/error.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/object.h b/src/util/object.h
index 111c3104..5093bb5c 100644
--- a/src/util/object.h
+++ b/src/util/object.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/reaper.h b/src/util/reaper.h
index 5b028ea9..2f145c19 100644
--- a/src/util/reaper.h
+++ b/src/util/reaper.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/take.h b/src/util/take.h
index 146162c4..91a804ba 100644
--- a/src/util/take.h
+++ b/src/util/take.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/to_string.h b/src/util/to_string.h
index 8724eedc..e1cba4ff 100644
--- a/src/util/to_string.h
+++ b/src/util/to_string.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/trash.h b/src/util/trash.h
index 76299325..618bf334 100644
--- a/src/util/trash.h
+++ b/src/util/trash.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/uvdelayed.h b/src/util/uvdelayed.h
index 9cdbd2c9..e5a74241 100644
--- a/src/util/uvdelayed.h
+++ b/src/util/uvdelayed.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include "uvhandle.h"
diff --git a/src/util/uvhandle.h b/src/util/uvhandle.h
index 87411813..d5e21ba8 100644
--- a/src/util/uvhandle.h
+++ b/src/util/uvhandle.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/uvloop.h b/src/util/uvloop.h
index cf743d14..3df949f1 100644
--- a/src/util/uvloop.h
+++ b/src/util/uvloop.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include
diff --git a/src/util/uvwork.h b/src/util/uvwork.h
index 20e7b7e9..a3eadda4 100644
--- a/src/util/uvwork.h
+++ b/src/util/uvwork.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include "uvloop.h"
diff --git a/src/zmq_inc.h b/src/zmq_inc.h
index 259d3d6b..c840cbbb 100644
--- a/src/zmq_inc.h
+++ b/src/zmq_inc.h
@@ -1,4 +1,3 @@
-/* Copyright (c) 2017-2019 Rolf Timmermans */
#pragma once
#include // IWYU pragma: export
diff --git a/tsconfig.docs.json b/tsconfig.docs.json
index 2fd3c814..e6397746 100644
--- a/tsconfig.docs.json
+++ b/tsconfig.docs.json
@@ -9,6 +9,7 @@
"exclude": [
"script/**/*",
"test/**/*",
+ "build/**/*",
"examples/**/*",
"src/errors.ts",
"src/util.ts"
diff --git a/tsconfig.json b/tsconfig.json
index ca487d00..bd1d7379 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -5,6 +5,7 @@
"target": "es2020",
"declaration": true,
"module": "commonjs",
+ "moduleResolution": "node",
"types": [
"node",
"mocha"
diff --git a/typedoc.json b/typedoc.json
index 16277d4d..195d096c 100644
--- a/typedoc.json
+++ b/typedoc.json
@@ -3,7 +3,7 @@
"name": "zeromq.js",
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.docs.json",
- "out": "docs-raw",
+ "out": "docs-unminified",
"excludePrivate": true,
"excludeExternals": false,
"exclude": [