@leofcoin/peernet 1.2.18 → 1.2.19
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.
- package/package.json +50 -263
- package/rollup.config.js +77 -10
- package/tsconfig.json +1 -0
- /package/exports/browser/{src/prompts → prompts}/password.js +0 -0
- /package/exports/{src/prompts → prompts}/password.js +0 -0
- /package/exports/types/{src/dht → dht}/dht.d.ts +0 -0
- /package/exports/types/{src/discovery → discovery}/peer-discovery.d.ts +0 -0
- /package/exports/types/{src/errors → errors}/errors.d.ts +0 -0
- /package/exports/types/{src/handlers → handlers}/data.d.ts +0 -0
- /package/exports/types/{src/handlers → handlers}/message.d.ts +0 -0
- /package/exports/types/{src/identity.d.ts → identity.d.ts} +0 -0
- /package/exports/types/{src/messages → messages}/chat.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/data-response.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/data.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/dht-response.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/dht.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/file-link.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/file.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/peer-response.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/peer.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/peernet.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/ps.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/request.d.ts +0 -0
- /package/exports/types/{src/messages → messages}/response.d.ts +0 -0
- /package/exports/types/{src/messages.d.ts → messages.d.ts} +0 -0
- /package/exports/types/{src/peer-info.d.ts → peer-info.d.ts} +0 -0
- /package/exports/types/{src/peernet.d.ts → peernet.d.ts} +0 -0
- /package/exports/types/{src/prompts → prompts}/password/browser.d.ts +0 -0
- /package/exports/types/{src/prompts → prompts}/password/node.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/chat-message.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/data-response.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/data.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/dht-response.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/dht.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/file-link.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/file.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/peer-response.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/peer.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/peernet.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/ps.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/request.proto.d.ts +0 -0
- /package/exports/types/{src/proto → proto}/response.proto.d.ts +0 -0
- /package/exports/types/{src/types.d.ts → types.d.ts} +0 -0
- /package/exports/types/{src/utils → utils}/utils.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,300 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "./exports/browser/peernet.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"import": "exports/peernet.js",
|
|
9
|
-
"types": "exports/types/peernet.d.ts"
|
|
8
|
+
"import": "./exports/peernet.js",
|
|
9
|
+
"types": "./exports/types/peernet.d.ts"
|
|
10
10
|
},
|
|
11
11
|
"./browser": {
|
|
12
|
-
"import": "./exports/browser.js",
|
|
13
|
-
"types": "./exports/types/
|
|
12
|
+
"import": "./exports/browser/peernet.js",
|
|
13
|
+
"types": "./exports/types/peernet.d.ts"
|
|
14
14
|
},
|
|
15
15
|
"./browser.js": {
|
|
16
|
-
"import": "./exports/browser.js",
|
|
17
|
-
"types": "./exports/types/
|
|
18
|
-
},
|
|
19
|
-
"./chat-message.proto": {
|
|
20
|
-
"import": "./exports/chat-message.proto.js",
|
|
21
|
-
"types": "./exports/types/src/proto/chat-message.proto.d.ts"
|
|
22
|
-
},
|
|
23
|
-
"./chat-message.proto.js": {
|
|
24
|
-
"import": "./exports/chat-message.proto.js",
|
|
25
|
-
"types": "./exports/types/src/proto/chat-message.proto.d.ts"
|
|
26
|
-
},
|
|
27
|
-
"./chat": {
|
|
28
|
-
"import": "./exports/chat.js",
|
|
29
|
-
"types": "./exports/types/src/messages/chat.d.ts"
|
|
30
|
-
},
|
|
31
|
-
"./chat.js": {
|
|
32
|
-
"import": "./exports/chat.js",
|
|
33
|
-
"types": "./exports/types/src/messages/chat.d.ts"
|
|
34
|
-
},
|
|
35
|
-
"./data-response": {
|
|
36
|
-
"import": "./exports/data-response.js",
|
|
37
|
-
"types": "./exports/types/src/messages/data-response.d.ts"
|
|
38
|
-
},
|
|
39
|
-
"./data-response.js": {
|
|
40
|
-
"import": "./exports/data-response.js",
|
|
41
|
-
"types": "./exports/types/src/messages/data-response.d.ts"
|
|
42
|
-
},
|
|
43
|
-
"./data-response.proto": {
|
|
44
|
-
"import": "./exports/data-response.proto.js",
|
|
45
|
-
"types": "./exports/types/src/proto/data-response.proto.d.ts"
|
|
46
|
-
},
|
|
47
|
-
"./data-response.proto.js": {
|
|
48
|
-
"import": "./exports/data-response.proto.js",
|
|
49
|
-
"types": "./exports/types/src/proto/data-response.proto.d.ts"
|
|
50
|
-
},
|
|
51
|
-
"./data": {
|
|
52
|
-
"import": "./exports/data.js",
|
|
53
|
-
"types": "./exports/types/src/handlers/data.d.ts"
|
|
54
|
-
},
|
|
55
|
-
"./data.js": {
|
|
56
|
-
"import": "./exports/data.js",
|
|
57
|
-
"types": "./exports/types/src/handlers/data.d.ts"
|
|
58
|
-
},
|
|
59
|
-
"./data.proto": {
|
|
60
|
-
"import": "./exports/data.proto.js",
|
|
61
|
-
"types": "./exports/types/src/proto/data.proto.d.ts"
|
|
62
|
-
},
|
|
63
|
-
"./data.proto.js": {
|
|
64
|
-
"import": "./exports/data.proto.js",
|
|
65
|
-
"types": "./exports/types/src/proto/data.proto.d.ts"
|
|
66
|
-
},
|
|
67
|
-
"./dht-response": {
|
|
68
|
-
"import": "./exports/dht-response.js",
|
|
69
|
-
"types": "./exports/types/src/messages/dht-response.d.ts"
|
|
70
|
-
},
|
|
71
|
-
"./dht-response.js": {
|
|
72
|
-
"import": "./exports/dht-response.js",
|
|
73
|
-
"types": "./exports/types/src/messages/dht-response.d.ts"
|
|
16
|
+
"import": "./exports/browser/peernet.js",
|
|
17
|
+
"types": "./exports/types/peernet.d.ts"
|
|
74
18
|
},
|
|
75
|
-
"./
|
|
76
|
-
"import": "./exports/
|
|
77
|
-
"types": "./exports/types/
|
|
78
|
-
},
|
|
79
|
-
"./dht-response.proto.js": {
|
|
80
|
-
"import": "./exports/dht-response.proto.js",
|
|
81
|
-
"types": "./exports/types/src/proto/dht-response.proto.d.ts"
|
|
82
|
-
},
|
|
83
|
-
"./dht": {
|
|
84
|
-
"import": "./exports/dht.js",
|
|
85
|
-
"types": "./exports/types/src/dht/dht.d.ts"
|
|
86
|
-
},
|
|
87
|
-
"./dht.js": {
|
|
88
|
-
"import": "./exports/dht.js",
|
|
89
|
-
"types": "./exports/types/src/dht/dht.d.ts"
|
|
90
|
-
},
|
|
91
|
-
"./dht.proto": {
|
|
92
|
-
"import": "./exports/dht.proto.js",
|
|
93
|
-
"types": "./exports/types/src/proto/dht.proto.d.ts"
|
|
94
|
-
},
|
|
95
|
-
"./dht.proto.js": {
|
|
96
|
-
"import": "./exports/dht.proto.js",
|
|
97
|
-
"types": "./exports/types/src/proto/dht.proto.d.ts"
|
|
98
|
-
},
|
|
99
|
-
"./errors": {
|
|
100
|
-
"import": "./exports/errors.js",
|
|
101
|
-
"types": "./exports/types/src/errors/errors.d.ts"
|
|
19
|
+
"./node": {
|
|
20
|
+
"import": "./exports/prompts/password.js",
|
|
21
|
+
"types": "./exports/types/prompts/password/node.d.ts"
|
|
102
22
|
},
|
|
103
|
-
"./
|
|
104
|
-
"import": "./exports/
|
|
105
|
-
"types": "./exports/types/
|
|
23
|
+
"./node.js": {
|
|
24
|
+
"import": "./exports/prompts/password.js",
|
|
25
|
+
"types": "./exports/types/prompts/password/node.d.ts"
|
|
106
26
|
},
|
|
107
|
-
"./
|
|
108
|
-
"import": "./exports/
|
|
109
|
-
"types": "./exports/types/src/messages/file-link.d.ts"
|
|
27
|
+
"./browser/browser-store": {
|
|
28
|
+
"import": "./exports/browser/browser-store.js"
|
|
110
29
|
},
|
|
111
|
-
"./
|
|
112
|
-
"import": "./exports/
|
|
113
|
-
"types": "./exports/types/src/messages/file-link.d.ts"
|
|
30
|
+
"./browser/browser-store.js": {
|
|
31
|
+
"import": "./exports/browser/browser-store.js"
|
|
114
32
|
},
|
|
115
|
-
"./
|
|
116
|
-
"import": "./exports/
|
|
117
|
-
"types": "./exports/types/
|
|
33
|
+
"./browser/identity": {
|
|
34
|
+
"import": "./exports/browser/identity.js",
|
|
35
|
+
"types": "./exports/types/identity.d.ts"
|
|
118
36
|
},
|
|
119
|
-
"./
|
|
120
|
-
"import": "./exports/
|
|
121
|
-
"types": "./exports/types/
|
|
37
|
+
"./browser/identity.js": {
|
|
38
|
+
"import": "./exports/browser/identity.js",
|
|
39
|
+
"types": "./exports/types/identity.d.ts"
|
|
122
40
|
},
|
|
123
|
-
"./
|
|
124
|
-
"import": "./exports/
|
|
125
|
-
"types": "./exports/types/
|
|
41
|
+
"./browser/peernet": {
|
|
42
|
+
"import": "./exports/browser/peernet.js",
|
|
43
|
+
"types": "./exports/types/peernet.d.ts"
|
|
126
44
|
},
|
|
127
|
-
"./
|
|
128
|
-
"import": "./exports/
|
|
129
|
-
"types": "./exports/types/
|
|
45
|
+
"./browser/peernet.js": {
|
|
46
|
+
"import": "./exports/browser/peernet.js",
|
|
47
|
+
"types": "./exports/types/peernet.d.ts"
|
|
130
48
|
},
|
|
131
|
-
"./
|
|
132
|
-
"import": "./exports/
|
|
133
|
-
"types": "./exports/types/
|
|
49
|
+
"./browser/prompts/password": {
|
|
50
|
+
"import": "./exports/browser/prompts/password.js",
|
|
51
|
+
"types": "./exports/types/prompts/password/browser.d.ts"
|
|
134
52
|
},
|
|
135
|
-
"./
|
|
136
|
-
"import": "./exports/
|
|
137
|
-
"types": "./exports/types/
|
|
53
|
+
"./browser/prompts/password.js": {
|
|
54
|
+
"import": "./exports/browser/prompts/password.js",
|
|
55
|
+
"types": "./exports/types/prompts/password/browser.d.ts"
|
|
138
56
|
},
|
|
139
57
|
"./identity": {
|
|
140
58
|
"import": "./exports/identity.js",
|
|
141
|
-
"types": "./exports/types/
|
|
59
|
+
"types": "./exports/types/identity.d.ts"
|
|
142
60
|
},
|
|
143
61
|
"./identity.js": {
|
|
144
62
|
"import": "./exports/identity.js",
|
|
145
|
-
"types": "./exports/types/
|
|
146
|
-
},
|
|
147
|
-
"./message": {
|
|
148
|
-
"import": "./exports/message.js",
|
|
149
|
-
"types": "./exports/types/src/handlers/message.d.ts"
|
|
150
|
-
},
|
|
151
|
-
"./message.js": {
|
|
152
|
-
"import": "./exports/message.js",
|
|
153
|
-
"types": "./exports/types/src/handlers/message.d.ts"
|
|
154
|
-
},
|
|
155
|
-
"./messages": {
|
|
156
|
-
"import": "./exports/messages.js",
|
|
157
|
-
"types": "./exports/types/src/messages.d.ts"
|
|
158
|
-
},
|
|
159
|
-
"./messages.js": {
|
|
160
|
-
"import": "./exports/messages.js",
|
|
161
|
-
"types": "./exports/types/src/messages.d.ts"
|
|
162
|
-
},
|
|
163
|
-
"./node": {
|
|
164
|
-
"import": "./exports/node.js",
|
|
165
|
-
"types": "./exports/types/src/prompts/password/node.d.ts"
|
|
166
|
-
},
|
|
167
|
-
"./node.js": {
|
|
168
|
-
"import": "./exports/node.js",
|
|
169
|
-
"types": "./exports/types/src/prompts/password/node.d.ts"
|
|
170
|
-
},
|
|
171
|
-
"./peer-discovery": {
|
|
172
|
-
"import": "./exports/peer-discovery.js",
|
|
173
|
-
"types": "./exports/types/src/discovery/peer-discovery.d.ts"
|
|
174
|
-
},
|
|
175
|
-
"./peer-discovery.js": {
|
|
176
|
-
"import": "./exports/peer-discovery.js",
|
|
177
|
-
"types": "./exports/types/src/discovery/peer-discovery.d.ts"
|
|
178
|
-
},
|
|
179
|
-
"./peer-info": {
|
|
180
|
-
"import": "./exports/peer-info.js",
|
|
181
|
-
"types": "./exports/types/src/peer-info.d.ts"
|
|
182
|
-
},
|
|
183
|
-
"./peer-info.js": {
|
|
184
|
-
"import": "./exports/peer-info.js",
|
|
185
|
-
"types": "./exports/types/src/peer-info.d.ts"
|
|
186
|
-
},
|
|
187
|
-
"./peer-response": {
|
|
188
|
-
"import": "./exports/peer-response.js",
|
|
189
|
-
"types": "./exports/types/src/messages/peer-response.d.ts"
|
|
190
|
-
},
|
|
191
|
-
"./peer-response.js": {
|
|
192
|
-
"import": "./exports/peer-response.js",
|
|
193
|
-
"types": "./exports/types/src/messages/peer-response.d.ts"
|
|
194
|
-
},
|
|
195
|
-
"./peer-response.proto": {
|
|
196
|
-
"import": "./exports/peer-response.proto.js",
|
|
197
|
-
"types": "./exports/types/src/proto/peer-response.proto.d.ts"
|
|
198
|
-
},
|
|
199
|
-
"./peer-response.proto.js": {
|
|
200
|
-
"import": "./exports/peer-response.proto.js",
|
|
201
|
-
"types": "./exports/types/src/proto/peer-response.proto.d.ts"
|
|
202
|
-
},
|
|
203
|
-
"./peer": {
|
|
204
|
-
"import": "./exports/peer.js",
|
|
205
|
-
"types": "./exports/types/src/messages/peer.d.ts"
|
|
206
|
-
},
|
|
207
|
-
"./peer.js": {
|
|
208
|
-
"import": "./exports/peer.js",
|
|
209
|
-
"types": "./exports/types/src/messages/peer.d.ts"
|
|
210
|
-
},
|
|
211
|
-
"./peer.proto": {
|
|
212
|
-
"import": "./exports/peer.proto.js",
|
|
213
|
-
"types": "./exports/types/src/proto/peer.proto.d.ts"
|
|
214
|
-
},
|
|
215
|
-
"./peer.proto.js": {
|
|
216
|
-
"import": "./exports/peer.proto.js",
|
|
217
|
-
"types": "./exports/types/src/proto/peer.proto.d.ts"
|
|
63
|
+
"types": "./exports/types/identity.d.ts"
|
|
218
64
|
},
|
|
219
65
|
"./peernet": {
|
|
220
66
|
"import": "./exports/peernet.js",
|
|
221
|
-
"types": "./exports/types/
|
|
67
|
+
"types": "./exports/types/peernet.d.ts"
|
|
222
68
|
},
|
|
223
69
|
"./peernet.js": {
|
|
224
70
|
"import": "./exports/peernet.js",
|
|
225
|
-
"types": "./exports/types/
|
|
226
|
-
},
|
|
227
|
-
"./peernet.proto": {
|
|
228
|
-
"import": "./exports/peernet.proto.js",
|
|
229
|
-
"types": "./exports/types/src/proto/peernet.proto.d.ts"
|
|
230
|
-
},
|
|
231
|
-
"./peernet.proto.js": {
|
|
232
|
-
"import": "./exports/peernet.proto.js",
|
|
233
|
-
"types": "./exports/types/src/proto/peernet.proto.d.ts"
|
|
234
|
-
},
|
|
235
|
-
"./ps": {
|
|
236
|
-
"import": "./exports/ps.js",
|
|
237
|
-
"types": "./exports/types/src/messages/ps.d.ts"
|
|
238
|
-
},
|
|
239
|
-
"./ps.js": {
|
|
240
|
-
"import": "./exports/ps.js",
|
|
241
|
-
"types": "./exports/types/src/messages/ps.d.ts"
|
|
242
|
-
},
|
|
243
|
-
"./ps.proto": {
|
|
244
|
-
"import": "./exports/ps.proto.js",
|
|
245
|
-
"types": "./exports/types/src/proto/ps.proto.d.ts"
|
|
246
|
-
},
|
|
247
|
-
"./ps.proto.js": {
|
|
248
|
-
"import": "./exports/ps.proto.js",
|
|
249
|
-
"types": "./exports/types/src/proto/ps.proto.d.ts"
|
|
250
|
-
},
|
|
251
|
-
"./request": {
|
|
252
|
-
"import": "./exports/request.js",
|
|
253
|
-
"types": "./exports/types/src/messages/request.d.ts"
|
|
254
|
-
},
|
|
255
|
-
"./request.js": {
|
|
256
|
-
"import": "./exports/request.js",
|
|
257
|
-
"types": "./exports/types/src/messages/request.d.ts"
|
|
258
|
-
},
|
|
259
|
-
"./request.proto": {
|
|
260
|
-
"import": "./exports/request.proto.js",
|
|
261
|
-
"types": "./exports/types/src/proto/request.proto.d.ts"
|
|
262
|
-
},
|
|
263
|
-
"./request.proto.js": {
|
|
264
|
-
"import": "./exports/request.proto.js",
|
|
265
|
-
"types": "./exports/types/src/proto/request.proto.d.ts"
|
|
266
|
-
},
|
|
267
|
-
"./response": {
|
|
268
|
-
"import": "./exports/response.js",
|
|
269
|
-
"types": "./exports/types/src/messages/response.d.ts"
|
|
270
|
-
},
|
|
271
|
-
"./response.js": {
|
|
272
|
-
"import": "./exports/response.js",
|
|
273
|
-
"types": "./exports/types/src/messages/response.d.ts"
|
|
274
|
-
},
|
|
275
|
-
"./response.proto": {
|
|
276
|
-
"import": "./exports/response.proto.js",
|
|
277
|
-
"types": "./exports/types/src/proto/response.proto.d.ts"
|
|
278
|
-
},
|
|
279
|
-
"./response.proto.js": {
|
|
280
|
-
"import": "./exports/response.proto.js",
|
|
281
|
-
"types": "./exports/types/src/proto/response.proto.d.ts"
|
|
71
|
+
"types": "./exports/types/peernet.d.ts"
|
|
282
72
|
},
|
|
283
|
-
"./
|
|
284
|
-
"import": "./exports/
|
|
285
|
-
"types": "./exports/types/
|
|
73
|
+
"./prompts/password": {
|
|
74
|
+
"import": "./exports/prompts/password.js",
|
|
75
|
+
"types": "./exports/types/prompts/password/node.d.ts"
|
|
286
76
|
},
|
|
287
|
-
"./
|
|
288
|
-
"import": "./exports/
|
|
289
|
-
"types": "./exports/types/
|
|
77
|
+
"./prompts/password.js": {
|
|
78
|
+
"import": "./exports/prompts/password.js",
|
|
79
|
+
"types": "./exports/types/prompts/password/node.d.ts"
|
|
290
80
|
},
|
|
291
|
-
"./
|
|
292
|
-
"import": "./exports/
|
|
293
|
-
"types": "./exports/types/src/utils/utils.d.ts"
|
|
81
|
+
"./store": {
|
|
82
|
+
"import": "./exports/store.js"
|
|
294
83
|
},
|
|
295
|
-
"./
|
|
296
|
-
"import": "./exports/
|
|
297
|
-
"types": "./exports/types/src/utils/utils.d.ts"
|
|
84
|
+
"./store.js": {
|
|
85
|
+
"import": "./exports/store.js"
|
|
298
86
|
}
|
|
299
87
|
},
|
|
300
88
|
"type": "module",
|
|
@@ -336,7 +124,6 @@
|
|
|
336
124
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
337
125
|
"@types/node": "^25.9.1",
|
|
338
126
|
"@types/qrcode": "^1.5.6",
|
|
339
|
-
"rollup": "^4.60.4"
|
|
340
|
-
"rollup-plugin-auto-exports": "^1.1.1"
|
|
127
|
+
"rollup": "^4.60.4"
|
|
341
128
|
}
|
|
342
129
|
}
|
package/rollup.config.js
CHANGED
|
@@ -2,9 +2,80 @@ import resolve from '@rollup/plugin-node-resolve'
|
|
|
2
2
|
import commonjs from '@rollup/plugin-commonjs'
|
|
3
3
|
import json from '@rollup/plugin-json'
|
|
4
4
|
import wasm from '@rollup/plugin-wasm'
|
|
5
|
+
import { readdir, readFile, writeFile } from 'node:fs/promises'
|
|
6
|
+
import { extname, relative, sep } from 'node:path'
|
|
5
7
|
import rimraf from 'rimraf'
|
|
6
8
|
import typescript from '@rollup/plugin-typescript'
|
|
7
|
-
|
|
9
|
+
|
|
10
|
+
const toPosix = (value) => value.split(sep).join('/')
|
|
11
|
+
|
|
12
|
+
const walk = async (dir) => {
|
|
13
|
+
const entries = await readdir(dir, { withFileTypes: true })
|
|
14
|
+
const files = []
|
|
15
|
+
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
const fullPath = `${dir}/${entry.name}`
|
|
18
|
+
if (entry.isDirectory()) {
|
|
19
|
+
files.push(...(await walk(fullPath)))
|
|
20
|
+
continue
|
|
21
|
+
}
|
|
22
|
+
files.push(fullPath)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return files
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isHashedChunk = (runtimePath) => /-[A-Za-z0-9_-]{8,}\.js$/.test(runtimePath)
|
|
29
|
+
|
|
30
|
+
const runtimeFirstExports = ({ exportsDir = 'exports', declarationsDir = 'exports/types' } = {}) => ({
|
|
31
|
+
name: 'runtime-first-exports',
|
|
32
|
+
writeBundle: async () => {
|
|
33
|
+
const runtimeFiles = (await walk(exportsDir))
|
|
34
|
+
.map((file) => toPosix(relative(exportsDir, file)))
|
|
35
|
+
.filter((file) => extname(file) === '.js')
|
|
36
|
+
.filter((file) => !file.startsWith('types/'))
|
|
37
|
+
.filter((file) => !isHashedChunk(file))
|
|
38
|
+
.sort((a, b) => a.localeCompare(b))
|
|
39
|
+
|
|
40
|
+
const declarationFiles = (await walk(declarationsDir))
|
|
41
|
+
.map((file) => toPosix(relative(declarationsDir, file)))
|
|
42
|
+
.filter((file) => extname(file) === '.ts' && file.endsWith('.d.ts'))
|
|
43
|
+
|
|
44
|
+
const declarationByRuntime = new Map(declarationFiles.map((file) => [file.slice(0, -'.d.ts'.length), file]))
|
|
45
|
+
|
|
46
|
+
const declarationAliases = {
|
|
47
|
+
'prompts/password': 'prompts/password/node',
|
|
48
|
+
'browser/prompts/password': 'prompts/password/browser',
|
|
49
|
+
'browser/peernet': 'peernet',
|
|
50
|
+
'browser/identity': 'identity'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const packageExports = {
|
|
54
|
+
'.': { import: './exports/peernet.js', types: './exports/types/peernet.d.ts' },
|
|
55
|
+
'./browser': { import: './exports/browser/peernet.js', types: './exports/types/peernet.d.ts' },
|
|
56
|
+
'./browser.js': { import: './exports/browser/peernet.js', types: './exports/types/peernet.d.ts' },
|
|
57
|
+
'./node': { import: './exports/prompts/password.js', types: './exports/types/prompts/password/node.d.ts' },
|
|
58
|
+
'./node.js': { import: './exports/prompts/password.js', types: './exports/types/prompts/password/node.d.ts' }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const runtimeFile of runtimeFiles) {
|
|
62
|
+
const runtimeKey = runtimeFile.slice(0, -'.js'.length)
|
|
63
|
+
const exportKey = `./${runtimeKey}`
|
|
64
|
+
const exportJsKey = `./${runtimeKey}.js`
|
|
65
|
+
const importPath = `./${exportsDir}/${runtimeFile}`
|
|
66
|
+
const declarationKey = declarationAliases[runtimeKey] || runtimeKey
|
|
67
|
+
const declarationPath = declarationByRuntime.get(declarationKey)
|
|
68
|
+
const typesPath = declarationPath ? `./${declarationsDir}/${declarationPath}` : undefined
|
|
69
|
+
|
|
70
|
+
packageExports[exportKey] = typesPath ? { import: importPath, types: typesPath } : { import: importPath }
|
|
71
|
+
packageExports[exportJsKey] = typesPath ? { import: importPath, types: typesPath } : { import: importPath }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const packageJson = JSON.parse(await readFile('./package.json', 'utf8'))
|
|
75
|
+
packageJson.exports = packageExports
|
|
76
|
+
await writeFile('./package.json', `${JSON.stringify(packageJson, null, ' ')}\n`)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
8
79
|
|
|
9
80
|
rimraf.sync('./exports/**')
|
|
10
81
|
|
|
@@ -43,27 +114,23 @@ export default [
|
|
|
43
114
|
outDir: 'exports',
|
|
44
115
|
declarationDir: 'exports/types'
|
|
45
116
|
}
|
|
46
|
-
}),
|
|
47
|
-
autoExports({
|
|
48
|
-
defaultExports: {
|
|
49
|
-
'.': { import: 'exports/peernet.js', types: 'exports/types/peernet.d.ts' }
|
|
50
|
-
}
|
|
51
117
|
})
|
|
52
118
|
],
|
|
53
|
-
external: ['./prompts/password.js']
|
|
119
|
+
external: ['./prompts/password.js', './prompts/password/browser.js', './prompts/password/node.js']
|
|
54
120
|
},
|
|
55
121
|
{
|
|
56
122
|
input: ['./src/prompts/password/browser.js'],
|
|
57
123
|
output: {
|
|
58
124
|
format: 'es',
|
|
59
|
-
file: 'exports/browser/
|
|
125
|
+
file: 'exports/browser/prompts/password.js'
|
|
60
126
|
}
|
|
61
127
|
},
|
|
62
128
|
{
|
|
63
129
|
input: ['./src/prompts/password/node.js'],
|
|
64
130
|
output: {
|
|
65
131
|
format: 'es',
|
|
66
|
-
file: 'exports/
|
|
67
|
-
}
|
|
132
|
+
file: 'exports/prompts/password.js'
|
|
133
|
+
},
|
|
134
|
+
plugins: [runtimeFirstExports()]
|
|
68
135
|
}
|
|
69
136
|
]
|
package/tsconfig.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|