From b3dd94649af82f872648056ce447ee02d4cdddb4 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 16 Apr 2024 17:40:41 +0800 Subject: [PATCH] feat(cli): allow to define dtsHeader in napi config (#2045) --- cli/src/api/build.ts | 23 ++++++++++++++---- .../__tests__/__snapshots__/config.spec.ts.md | 2 -- .../__snapshots__/config.spec.ts.snap | Bin 800 -> 790 bytes cli/src/utils/config.ts | 23 +++++++++++++----- cli/src/utils/typegen.ts | 2 +- .../__snapshots__/typegen.spec.ts.md | 1 + .../__snapshots__/typegen.spec.ts.snap | Bin 4850 -> 4858 bytes .../__snapshots__/values.spec.ts.snap | Bin 390 -> 389 bytes examples/napi/dts-header.d.ts | 4 +++ examples/napi/index.d.cts | 1 + examples/napi/package.json | 4 ++- 11 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 examples/napi/dts-header.d.ts diff --git a/cli/src/api/build.ts b/cli/src/api/build.ts index 4446bb5c..821fb17f 100644 --- a/cli/src/api/build.ts +++ b/cli/src/api/build.ts @@ -798,7 +798,20 @@ class Builder { this.envs.TYPE_DEF_TMP_PATH, this.options.constEnum ?? true, !this.options.noDtsHeader - ? this.options.dtsHeader ?? DEFAULT_TYPE_DEF_HEADER + ? this.options.dtsHeader ?? + (this.config.dtsHeaderFile + ? await readFileAsync( + join(this.cwd, this.config.dtsHeaderFile), + 'utf-8', + ).catch(() => { + debug.warn( + `Failed to read dts header file ${this.config.dtsHeaderFile}`, + ) + return null + }) + : null) ?? + this.config.dtsHeader ?? + DEFAULT_TYPE_DEF_HEADER : '', ) @@ -876,8 +889,8 @@ class Builder { name, this.config.packageName, wasiRegisterFunctions, - this.config.wasm.initialMemory, - this.config.wasm.maximumMemory, + this.config.wasm?.initialMemory, + this.config.wasm?.maximumMemory, ) + exportsCode + '\n', @@ -888,8 +901,8 @@ class Builder { createWasiBrowserBinding( name, wasiRegisterFunctions, - this.config.wasm.initialMemory, - this.config.wasm.maximumMemory, + this.config.wasm?.initialMemory, + this.config.wasm?.maximumMemory, ) + idents .map( diff --git a/cli/src/utils/__tests__/__snapshots__/config.spec.ts.md b/cli/src/utils/__tests__/__snapshots__/config.spec.ts.md index 4eca4920..e3c8cc5c 100644 --- a/cli/src/utils/__tests__/__snapshots__/config.spec.ts.md +++ b/cli/src/utils/__tests__/__snapshots__/config.spec.ts.md @@ -48,7 +48,6 @@ Generated by [AVA](https://avajs.dev). triple: 'x86_64-apple-darwin', }, ], - wasm: {}, } ## should be able to read config from napi.json @@ -95,5 +94,4 @@ Generated by [AVA](https://avajs.dev). triple: 'aarch64-apple-darwin', }, ], - wasm: {}, } diff --git a/cli/src/utils/__tests__/__snapshots__/config.spec.ts.snap b/cli/src/utils/__tests__/__snapshots__/config.spec.ts.snap index 975c7e1da6e9ef5a686de0af98b7c19a94819090..38093d0501307b08a9f0ae9d12831b289c82ff6c 100644 GIT binary patch literal 790 zcmV+x1L^!hRzVXx4s5>iE=OBrCO5ULo; z#lEC&owH>-Z7RV~5DQ}CFK9Ow)U7j9CuSxPf{Fpb06P+&oj9}?w}~i-A8Mjce!lzO zd-t8+-CL`a9oJk89;~y_4jtAQ59ZyvW9en4)3U?#(A9lLE!}i^#jffV->vB$H5X}> zjV%N&w*yW+_=Lggnq|?D&T4mMDJw-k(nqvOJf{E-JOws@ZD5#aLqxk-USMWONZTwH zixL@-h$@i+IGGV5<7J5C$~LF|$_-j$$xt?AL1^=;z&yge+BL^!JWNJpj7VgVkZ;JF z4EDD~T!#iBLNc{8S@8;F+J+yDx3ePPDESdE8&bc@!XQ$u%wl2=cmk{wL2YKYTF|#Z zc?rA%-X(Okvh>xX-rC*uP#*+5vMGqo1_w&%2U9&cQl zm;sq$?`Exz$8jQ)Yu9Vz@uwyM@o@v0%a+iaa(|)q# zfrARtEb1d)kBV|lw$T|_P&3?8Lp=-{Ne-OkZB*pP=x}H_XWH(oNZEB2H7|#Jltk*` z>&HYwx^8Eam)UQjNv|61p;twxZm&jl`~PfIuEh=;)nC!5E&{iJd%*MVjp{8Z9{>sG z?-Vc%-2VfODy4un4ja`!d87Zl6qWk5Uo9rz5|b8MkTXJ~#iVtp*C@sJKpx%c>~HK) U=^HAvr_^PB2l#>&omCA003!r*fB*mh literal 800 zcmV+*1K<2XRzVmtUdq79dY`@sUfnr&ndaw;ziL00000000B+RZVLXQ51b|CNt@GQd(Cv zB%NmF%`k7$q~NA*i-@?W;Hv(Hx)5*41r{@NhR2I`DOU_UH|H~>%u3eG zitxBCIP;MciuEniWFdQ`zfnn=L?1dp(~J1M2?W3XpRSDI`=}^JuELgk8Tq{{hhn5I!UXqxD+;^`#w#CC_Ma2rCW0W38 z-(+#PA>=l6NEMQ;)@IpjkZR`xG285lf;Urp0?0lB@@V8=LBNn(ok)OJp3kq{B266sYd z5VpsY|JtP)dIh0q75a!=TZ1M3YA#i4}^Qbd6keSsx%E%o`${($}`|C z@Dcb1Or@kWy(8@|C=UPuyaql1yK-8(Bkin4$OT{tFo6x=lP0AN^qh15$F~1Nx2ttK zbZD+gB~@0in{kO(4cmC?f^n> ze^I5{UR3p$!${PG^l|rNBBedYS?4MHU1;KQ7yIzI=&Ada!M*%{4bC&IBZE7%2Im4V zfNkJ=Z-bkLi<}1Lfycl)@cthdT$e+)b7XLb(g}WFipB!>Pm398i0M{Zk~7Joi|OWU e$KYlsfhEBHi_X@4ppvb1z09Al_8SYu4FCYPLx^<% diff --git a/cli/src/utils/config.ts b/cli/src/utils/config.ts index acc96875..70b1ba36 100644 --- a/cli/src/utils/config.ts +++ b/cli/src/utils/config.ts @@ -42,6 +42,17 @@ export interface UserNapiConfig { */ constEnum?: boolean + /** + * dts header prepend to the generated dts file + */ + dtsHeader?: string + + /** + * dts header file path to be prepended to the generated dts file + * if both dtsHeader and dtsHeaderFile are provided, dtsHeaderFile will be used + */ + dtsHeaderFile?: string + /** * wasm compilation options */ @@ -116,11 +127,12 @@ export interface CommonPackageJsonFields { } export type NapiConfig = Required< - Pick -> & { - targets: Target[] - packageJson: CommonPackageJsonFields -} + Pick +> & + Pick & { + targets: Target[] + packageJson: CommonPackageJsonFields + } export async function readNapiConfig( path: string, @@ -173,7 +185,6 @@ export async function readNapiConfig( targets: [], packageJson: pkgJson, npmClient: 'npm', - wasm: {}, }, omit(userNapiConfig, 'targets'), ) diff --git a/cli/src/utils/typegen.ts b/cli/src/utils/typegen.ts index 610c1705..5b254b37 100644 --- a/cli/src/utils/typegen.ts +++ b/cli/src/utils/typegen.ts @@ -64,7 +64,7 @@ export async function processTypeDef( const defs = await readIntermediateTypeFile(intermediateTypeFile) const groupedDefs = preprocessTypeDef(defs) - header = header ? header + '\n' : '' + header = header ?? '' let dts = '' sortBy(Array.from(groupedDefs), ([namespace]) => namespace).forEach( diff --git a/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md b/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md index 09d3d5e1..1d0ffc52 100644 --- a/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md +++ b/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md @@ -11,6 +11,7 @@ Generated by [AVA](https://avajs.dev). `/* auto-generated by NAPI-RS */␊ /* eslint-disable */␊ ␊ + type MaybePromise = T | Promise␊ ␊ export class ExternalObject {␊ readonly '': {␊ diff --git a/examples/napi/__tests__/__snapshots__/typegen.spec.ts.snap b/examples/napi/__tests__/__snapshots__/typegen.spec.ts.snap index fed22a6fd8b9f29c25994766c0a5bfe0294026f1..54ed56dcf22362860185521beddbbc1b39ee3cdd 100644 GIT binary patch literal 4858 zcmVqp(Jv%rX-?sGG{SmA_>+oQ;I+R zHHrcm{Pyx!|MJDZeu4k_r(b;W%YXjG<=0=4Ad~!oMHG?QhMbSzoIbdmkgvYJ2k)tf zSt1`qOa!x-;@~~C%2}|P(KjhyF+snXJ}3KRO8!WSfqVDp?V6{OgmEAQIlh%NO@jDh z_5lb*fRFbGNof%AB;Jtw_eW}=GL$9k4;dw5vzqZ(y?*!Y$UMFuktqy)y7vjl{OTV0 ziu@SzM94G?B~O1Od@UJI$egF-M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M;(eWKXRq!LZ*k$Ko;MX>{s>rMLD1n&BJ{^+5p{b}f?ngT_;ua;Ygmmj^}8`v-im7i&$>-XDI=n;(43<{#s+)b?*X zS<2!sJ=Iw;o+f@z*$h-zzfH{FbgP`Vhp$dvoW6d3Iu3@8JzZbV_x2x`!w;Da=L9cj Ywai6)4uAjXVaMeCFR%)*p*d0j0LJ#22><{9 diff --git a/examples/napi/__tests__/__snapshots__/values.spec.ts.snap b/examples/napi/__tests__/__snapshots__/values.spec.ts.snap index 164d817503ff7ec51b002a8f0c672b5cf9e6e880..2b1be196c853c9f3064c4e651ba44b589ce03635 100644 GIT binary patch literal 389 zcmV;00eb#HRzV*l-3e0Vm-COav1|q^DTl_cR(uIV|SJ<@dOMQ9%czR;YZTvK2b3(aI8+F5v!9 z6f(%0=rR@^Q9say$&%idcp~1258{hB0U<7kYvPu8B%X;^;+^;;AQIw?IEMBFk}L1! z4uDT-nhNL(7z-GZ5z)k0Kr(^hj5gAl$7yc#ZwbKdxM_perBTR6#Kvi3Y$dKUzp+8D z6>BkTqgmLM3a7>u5|>=JxK3x44hq9`?%kF?7YhjseHJ#&l5Or{SxF8%9QJbW5Hn>f zuDV=xl~H-{&T`Y^ru~1tKIbj}uxhS8;50#P|Aq`3x!#o15vS*Mnw4gAr)_2({ST!x jyM;EU8GO{N@pD(sQ_crlH7~rbl-KSX>}*6NWdZ;It8}%+ literal 390 zcmV;10eSvGRzV zBUZYcJ|Bw+00000000A3k3CYuFc3z+wd4E;CzDXX9Xz3;4h4sxL$MX2phzA`aR^;% zI&Kgu8qUBa;3Qmt$-tUHmFB%SJG+O)T-*HK?_Xq4LCckwu8`TvTcf-YrC-|M_lKeo zLEJ=_FZ6L3qwBLU9@yb|zEz$XC|0cQ~~rsjx} zE9bBDsH?AA-iLBc_ogH63;lU*z-!LY@!lRN8u zCQZev&8jW6%!9LrO@~eM|9V~K4fn9BPwz2JyfS}7`gMHVl<9!!`H^O&-rOmZ8C%G# kw0gHtTGxY5>NS3DWu7wcZRNahs*+CGZ|rPDBxM2s00Jkr$^ZZW diff --git a/examples/napi/dts-header.d.ts b/examples/napi/dts-header.d.ts new file mode 100644 index 00000000..3986614f --- /dev/null +++ b/examples/napi/dts-header.d.ts @@ -0,0 +1,4 @@ +/* auto-generated by NAPI-RS */ +/* eslint-disable */ + +type MaybePromise = T | Promise diff --git a/examples/napi/index.d.cts b/examples/napi/index.d.cts index 993d69dd..93e5500c 100644 --- a/examples/napi/index.d.cts +++ b/examples/napi/index.d.cts @@ -1,6 +1,7 @@ /* auto-generated by NAPI-RS */ /* eslint-disable */ +type MaybePromise = T | Promise export class ExternalObject { readonly '': { diff --git a/examples/napi/package.json b/examples/napi/package.json index 7c84ac45..0e36107e 100644 --- a/examples/napi/package.json +++ b/examples/napi/package.json @@ -14,7 +14,9 @@ "binaryName": "example", "wasm": { "initialMemory": 16384 - } + }, + "dtsHeader": "type MaybePromise = T | Promise", + "dtsHeaderFile": "./dts-header.d.ts" }, "devDependencies": { "@napi-rs/cli": "workspace:*",