Merge remote-tracking branch 'origin/main' into chrono_datetime

This commit is contained in:
Simon Vandel Sillesen 2022-02-11 07:21:07 +01:00
commit cb9be7bc6a
15 changed files with 95 additions and 46 deletions

View file

@ -11,9 +11,7 @@ members = [
"./memory-testing",
]
exclude = [
"./testing"
]
exclude = ["./testing"]
[profile.release]
lto = true

View file

@ -9,13 +9,17 @@ version = "0.1.0"
crate-type = ["cdylib"]
[dependencies]
napi = {path = "../crates/napi", features = ["tokio_rt", "serde-json", "compat-mode"]}
napi-derive = {path = "../crates/macro", features = ["compat-mode"]}
napi = { path = "../crates/napi", features = [
"tokio_rt",
"serde-json",
"compat-mode",
] }
napi-derive = { path = "../crates/macro", features = ["compat-mode"] }
serde = "1"
serde_json = "1"
[target.'cfg(all(target_arch = "x86_64", not(target_env = "musl")))'.dependencies]
mimalloc = {version = "0.1"}
mimalloc = { version = "0.1" }
[build-dependencies]
napi-build = {path = "../crates/build"}
napi-build = { path = "../crates/build" }

View file

@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.4.4](https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.4.3...@napi-rs/cli@2.4.4) (2022-02-11)
### Bug Fixes
- **cli:** generate ExternalObject type on demand ([f9c618e](https://github.com/napi-rs/napi-rs/commit/f9c618e0462c3f75593b0a980f4babcb265ffc0c))
## [2.4.3](https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@2.4.2...@napi-rs/cli@2.4.3) (2022-02-09)
### Bug Fixes

View file

@ -1,6 +1,6 @@
{
"name": "@napi-rs/cli",
"version": "2.4.3",
"version": "2.4.4",
"description": "Cli tools for napi-rs",
"keywords": [
"cli",

View file

@ -493,18 +493,6 @@ async function processIntermediateTypeFile(
return idents
}
const dtsHeader = `/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}\n`
const allDefs = lines.map((line) => JSON.parse(line) as TypeDef)
function convertDefs(defs: TypeDef[], nested = false): string {
@ -597,8 +585,29 @@ export class ExternalObject<T> {
return acc + `export namespace ${mod} {\n${convertDefs(defs, true)}}\n`
}, '')
const dtsHeader = `/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */\n
`
const externalDef =
topLevelDef.indexOf('ExternalObject<') > -1 ||
namespaceDefs.indexOf('ExternalObject<') > -1
? `export class ExternalObject<T> {
readonly '': {
readonly '': unique symbol
[K: symbol]: T
}
}\n`
: ''
await unlinkAsync(source)
await writeFileAsync(target, dtsHeader + topLevelDef + namespaceDefs, 'utf8')
await writeFileAsync(
target,
dtsHeader + externalDef + topLevelDef + namespaceDefs,
'utf8',
)
return idents
}

View file

@ -20,7 +20,7 @@ type-def = ["regex", "once_cell"]
convert_case = "0.5"
proc-macro2 = "1"
quote = "1"
syn = {version = "1", features = ["fold", "full", "extra-traits"]}
syn = { version = "1", features = ["fold", "full", "extra-traits"] }
[dependencies.regex]
optional = true

View file

@ -22,10 +22,10 @@ type-def = ["napi-derive-backend/type-def"]
[dependencies]
convert_case = "0.5"
napi-derive-backend = {version = "1.0.25", path = "../backend"}
napi-derive-backend = { version = "1.0.25", path = "../backend" }
proc-macro2 = "1.0"
quote = "1.0"
syn = {version = "1.0", features = ["fold", "full", "extra-traits"]}
syn = { version = "1.0", features = ["fold", "full", "extra-traits"] }
[lib]
proc-macro = true

View file

@ -73,7 +73,7 @@ optional = true
version = "1"
[target.'cfg(windows)'.dependencies]
windows = { version = "0.30", features = [
windows = { version = "0.32", features = [
"Win32_System_WindowsProgramming",
"Win32_System_LibraryLoader",
"Win32_Foundation",

View file

@ -14,13 +14,18 @@ napi3 = ["napi/napi3"]
[dependencies]
futures = "0.3"
napi = {path = "../../crates/napi", features = ["tokio_rt", "serde-json", "latin1", "compat-mode"]}
napi-derive = {path = "../../crates/macro", features = ["compat-mode"]}
napi = { path = "../../crates/napi", features = [
"tokio_rt",
"serde-json",
"latin1",
"compat-mode",
] }
napi-derive = { path = "../../crates/macro", features = ["compat-mode"] }
serde = "1"
serde_bytes = "0.11"
serde_derive = "1"
serde_json = "1"
tokio = {version = "1", features = ["default", "fs"]}
tokio = { version = "1", features = ["default", "fs"] }
[build-dependencies]
napi-build = {path = "../../crates/build"}
napi-build = { path = "../../crates/build" }

View file

@ -14,6 +14,7 @@ Generated by [AVA](https://avajs.dev).
'@rollup/plugin-json',
'@rollup/plugin-node-resolve',
'@rollup/plugin-replace',
'@taplo/cli',
'@types/debug',
'@types/lodash-es',
'@types/node',

View file

@ -10,13 +10,18 @@ crate-type = ["cdylib"]
[dependencies]
futures = "0.3"
napi = {path = "../crates/napi", features = ["tokio_rt", "serde-json", "latin1", "compat-mode"]}
napi-derive = {path = "../crates/macro", features = ["compat-mode"]}
napi = { path = "../crates/napi", features = [
"tokio_rt",
"serde-json",
"latin1",
"compat-mode",
] }
napi-derive = { path = "../crates/macro", features = ["compat-mode"] }
serde = "1"
serde_bytes = "0.11"
serde_derive = "1"
serde_json = "1"
tokio = {version = "1", features = ["default", "fs"]}
tokio = { version = "1", features = ["default", "fs"] }
[build-dependencies]
napi-build = {path = "../crates/build"}
napi-build = { path = "../crates/build" }

View file

@ -27,9 +27,10 @@
"build:test:android:armv7": "yarn workspace compat-mode-examples build --target armv7-linux-androideabi && yarn workspace examples build --target armv7-linux-androideabi",
"build:test:armv7": "yarn workspace compat-mode-examples build-armv7 && yarn workspace examples build-armv7",
"bundle": "rollup -c rollup.config.js",
"format": "run-p format:prettier format:rs",
"format": "run-p format:prettier format:rs format:toml",
"format:prettier": "prettier . -w",
"format:rs": "cargo fmt",
"format:toml": "taplo format",
"lint": "eslint -c .eslintrc.yml .",
"prepublishOnly": "npm run build && pinst --disable",
"test": "ava",
@ -54,6 +55,12 @@
],
"*.@(js||ts|json|md|yml|yaml)": [
"prettier --write"
],
"*.toml": [
"taplo format"
],
"*.rs": [
"cargo fmt"
]
},
"husky": {
@ -67,6 +74,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-replace": "^3.0.1",
"@taplo/cli": "^0.3.2",
"@types/debug": "^4.1.7",
"@types/lodash-es": "^4.17.5",
"@types/node": "^17.0.10",

View file

@ -1348,6 +1348,18 @@ __metadata:
languageName: node
linkType: hard
"@taplo/cli@npm:^0.3.2":
version: 0.3.2
resolution: "@taplo/cli@npm:0.3.2"
dependencies:
fast-glob: ^3.2.4
node-fetch: ^2.6.1
bin:
taplo: dist/cli.js
checksum: aa289d561b767ee3730ee431dec8a55bf2b2da5bc8e837156ca8cf39a165ae0e2edf16f669e5a40da2b5c8b67ceea5bb80cd2e91803659b09af707505741992c
languageName: node
linkType: hard
"@tootallnate/once@npm:1":
version: 1.1.2
resolution: "@tootallnate/once@npm:1.1.2"
@ -3956,7 +3968,7 @@ __metadata:
languageName: node
linkType: hard
"fast-glob@npm:^3.2.7, fast-glob@npm:^3.2.9":
"fast-glob@npm:^3.2.4, fast-glob@npm:^3.2.7, fast-glob@npm:^3.2.9":
version: 3.2.11
resolution: "fast-glob@npm:3.2.11"
dependencies:
@ -6156,6 +6168,7 @@ __metadata:
"@rollup/plugin-json": ^4.1.0
"@rollup/plugin-node-resolve": ^13.1.3
"@rollup/plugin-replace": ^3.0.1
"@taplo/cli": ^0.3.2
"@types/debug": ^4.1.7
"@types/lodash-es": ^4.17.5
"@types/node": ^17.0.10