@napi-rs/cli 3.0.0-alpha.81 → 3.0.0-alpha.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { sortBy, unionWith, isEqual } from 'lodash-es'
1
+ import { sortBy } from 'lodash-es'
2
2
 
3
3
  import { readFileAsync } from './misc.js'
4
4
 
@@ -85,14 +85,11 @@ function exportDeclare(ambient: boolean): string {
85
85
  export async function processTypeDef(
86
86
  intermediateTypeFile: string,
87
87
  constEnum: boolean,
88
- header?: string,
89
88
  ) {
90
89
  const exports: string[] = []
91
90
  const defs = await readIntermediateTypeFile(intermediateTypeFile)
92
91
  const groupedDefs = preprocessTypeDef(defs)
93
92
 
94
- header = header ?? ''
95
-
96
93
  const dts =
97
94
  sortBy(Array.from(groupedDefs), ([namespace]) => namespace)
98
95
  .map(([namespace, defs]) => {
@@ -130,41 +127,22 @@ export async function processTypeDef(
130
127
  })
131
128
  .join('\n\n') + '\n'
132
129
 
133
- if (dts.indexOf('ExternalObject<') > -1) {
134
- header += `
135
- export declare class ExternalObject<T> {
136
- readonly '': {
137
- readonly '': unique symbol
138
- [K: symbol]: T
139
- }
140
- }
141
- `
142
- }
143
-
144
130
  return {
145
- dts: header + dts,
131
+ dts,
146
132
  exports,
147
133
  }
148
134
  }
149
135
 
150
136
  async function readIntermediateTypeFile(file: string) {
151
137
  const content = await readFileAsync(file, 'utf8')
152
- const defs = unionWith(
153
- content
154
- .split('\n')
155
- .filter(Boolean)
156
- .map((line) => {
157
- line = line.trim()
158
- if (!line.startsWith('{')) {
159
- // crateName:{ "def": "", ... }
160
- const start = line.indexOf(':') + 1
161
- line = line.slice(start)
162
- }
163
- return JSON.parse(line) as TypeDefLine
164
- })
165
- .filter((def) => !!def.kind),
166
- (a, b) => isEqual(a, b),
167
- )
138
+
139
+ const defs = content
140
+ .split('\n')
141
+ .filter(Boolean)
142
+ .map((line) => {
143
+ line = line.trim()
144
+ return JSON.parse(line) as TypeDefLine
145
+ })
168
146
 
169
147
  // move all `struct` def to the very top
170
148
  // and order the rest alphabetically.