@leofcoin/peernet 0.14.18 → 0.14.20
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/dist/browser/generate-account.js +51 -0
- package/dist/browser/generate-account.mjs +50 -0
- package/dist/browser/messages.js +329 -0
- package/dist/browser/messages.mjs +328 -0
- package/dist/browser/multi-wallet.js +16 -0
- package/dist/browser/multi-wallet.mjs +15 -0
- package/dist/browser/pako.js +670 -501
- package/dist/browser/pako.mjs +6900 -0
- package/dist/browser/peernet-swarm.js +829 -0
- package/dist/browser/peernet-swarm.mjs +827 -0
- package/dist/browser/peernet.js +2657 -11860
- package/dist/browser/peernet.mjs +9555 -0
- package/dist/browser/storage.js +3725 -0
- package/dist/browser/storage.mjs +3724 -0
- package/dist/browser/wrtc.mjs +28 -0
- package/dist/commonjs/peernet.js +1 -10
- package/dist/module/{messages-1b12e93b.js → messages-bce1b91d.js} +14 -27
- package/dist/module/peernet.js +13 -46
- package/index.html +4 -4
- package/package.json +2 -4
- package/rollup.config.js +1 -1
- package/src/peernet.js +1 -10
- package/webpack.config.js +61 -6
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
(self["webpackChunk_leofcoin_peernet"] = self["webpackChunk_leofcoin_peernet"] || []).push([[228],{
|
|
2
|
+
|
|
3
|
+
/***/ 347:
|
|
4
|
+
/***/ (function(__unused_webpack_module, exports) {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.MediaStream = window.MediaStream;
|
|
9
|
+
exports.MediaStreamTrack = window.MediaStreamTrack;
|
|
10
|
+
exports.RTCDataChannel = window.RTCDataChannel;
|
|
11
|
+
exports.RTCDataChannelEvent = window.RTCDataChannelEvent;
|
|
12
|
+
exports.RTCDtlsTransport = window.RTCDtlsTransport;
|
|
13
|
+
exports.RTCIceCandidate = window.RTCIceCandidate;
|
|
14
|
+
exports.RTCIceTransport = window.RTCIceTransport;
|
|
15
|
+
exports.RTCPeerConnection = window.RTCPeerConnection;
|
|
16
|
+
exports.RTCPeerConnectionIceEvent = window.RTCPeerConnectionIceEvent;
|
|
17
|
+
exports.RTCRtpReceiver = window.RTCRtpReceiver;
|
|
18
|
+
exports.RTCRtpSender = window.RTCRtpSender;
|
|
19
|
+
exports.RTCRtpTransceiver = window.RTCRtpTransceiver;
|
|
20
|
+
exports.RTCSctpTransport = window.RTCSctpTransport;
|
|
21
|
+
exports.RTCSessionDescription = window.RTCSessionDescription;
|
|
22
|
+
exports.getUserMedia = window.getUserMedia;
|
|
23
|
+
exports.mediaDevices = navigator.mediaDevices;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/***/ })
|
|
27
|
+
|
|
28
|
+
}])
|
package/dist/commonjs/peernet.js
CHANGED
|
@@ -652,7 +652,7 @@ class Peernet {
|
|
|
652
652
|
this.peerId = this.id;
|
|
653
653
|
|
|
654
654
|
pubsub.subscribe('peer:connected', async (peer) => {
|
|
655
|
-
console.log(peer);
|
|
655
|
+
// console.log(peer);
|
|
656
656
|
// console.log({connected: peer.id, as: this._getPeerId(peer.id) });
|
|
657
657
|
// peer.on('peernet.data', async (message) => {
|
|
658
658
|
// const id = message.id
|
|
@@ -762,7 +762,6 @@ class Peernet {
|
|
|
762
762
|
const walk = async peer => {
|
|
763
763
|
const node = await this.prepareMessage(data);
|
|
764
764
|
let result = await peer.request(node.encoded);
|
|
765
|
-
console.log({result});
|
|
766
765
|
result = new Uint8Array(Object.values(result));
|
|
767
766
|
const proto = await protoFor(result);
|
|
768
767
|
if (proto.name !== 'peernet-dht-response') throw dhtError(proto.name)
|
|
@@ -1109,14 +1108,6 @@ class Peernet {
|
|
|
1109
1108
|
get Buffer() {
|
|
1110
1109
|
return Buffer
|
|
1111
1110
|
}
|
|
1112
|
-
// async block(index) {
|
|
1113
|
-
// const _values = []
|
|
1114
|
-
// for (const peer of this.peers) {
|
|
1115
|
-
// const value = await peer.request({type: 'block', index})
|
|
1116
|
-
// console.log(value);
|
|
1117
|
-
// }
|
|
1118
|
-
//
|
|
1119
|
-
// }
|
|
1120
1111
|
}
|
|
1121
1112
|
globalThis.Peernet = Peernet;
|
|
1122
1113
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var codecFormatInterface = require('@leofcoin/codec-format-interface');
|
|
1
|
+
import { FormatInterface } from '@leofcoin/codec-format-interface';
|
|
4
2
|
|
|
5
3
|
var proto$b = `
|
|
6
4
|
// PeernetMessage
|
|
@@ -12,7 +10,7 @@ message PeernetMessage {
|
|
|
12
10
|
optional string id = 5;
|
|
13
11
|
}`;
|
|
14
12
|
|
|
15
|
-
class PeernetMessage extends
|
|
13
|
+
class PeernetMessage extends FormatInterface {
|
|
16
14
|
get keys() {
|
|
17
15
|
return ['data', 'signature', 'from', 'to', 'id']
|
|
18
16
|
}
|
|
@@ -43,7 +41,7 @@ message PeernetDHTMessage {
|
|
|
43
41
|
message = new DHTMessage('hashmvbs124xcfd...', 'block')
|
|
44
42
|
`
|
|
45
43
|
*/
|
|
46
|
-
class DHTMessage extends
|
|
44
|
+
class DHTMessage extends FormatInterface {
|
|
47
45
|
/**
|
|
48
46
|
*
|
|
49
47
|
*/
|
|
@@ -69,7 +67,7 @@ message PeernetDHTMessageResponse {
|
|
|
69
67
|
}
|
|
70
68
|
`;
|
|
71
69
|
|
|
72
|
-
class DHTMessageResponse extends
|
|
70
|
+
class DHTMessageResponse extends FormatInterface {
|
|
73
71
|
get keys() {
|
|
74
72
|
return ['hash', 'has']
|
|
75
73
|
}
|
|
@@ -95,7 +93,7 @@ message PeernetDataMessage {
|
|
|
95
93
|
/**
|
|
96
94
|
* @extends {CodecFormat}
|
|
97
95
|
*/
|
|
98
|
-
class DataMessage extends
|
|
96
|
+
class DataMessage extends FormatInterface {
|
|
99
97
|
get keys() {
|
|
100
98
|
return ['hash', 'store']
|
|
101
99
|
}
|
|
@@ -118,7 +116,7 @@ message PsMessage {
|
|
|
118
116
|
required bytes topic = 2;
|
|
119
117
|
}`;
|
|
120
118
|
|
|
121
|
-
class PsMessage extends
|
|
119
|
+
class PsMessage extends FormatInterface {
|
|
122
120
|
get keys() {
|
|
123
121
|
return ['data', 'topic']
|
|
124
122
|
}
|
|
@@ -140,7 +138,7 @@ message PeernetPeerMessage {
|
|
|
140
138
|
}
|
|
141
139
|
`;
|
|
142
140
|
|
|
143
|
-
class PeerMessage extends
|
|
141
|
+
class PeerMessage extends FormatInterface {
|
|
144
142
|
get keys() {
|
|
145
143
|
return ['id']
|
|
146
144
|
}
|
|
@@ -162,7 +160,7 @@ message PeernetRequestMessage {
|
|
|
162
160
|
}
|
|
163
161
|
`;
|
|
164
162
|
|
|
165
|
-
class RequestMessage extends
|
|
163
|
+
class RequestMessage extends FormatInterface {
|
|
166
164
|
get keys() {
|
|
167
165
|
return ['request']
|
|
168
166
|
}
|
|
@@ -184,7 +182,7 @@ message PeernetResponseMessage {
|
|
|
184
182
|
}
|
|
185
183
|
`;
|
|
186
184
|
|
|
187
|
-
class ResponseMessage extends
|
|
185
|
+
class ResponseMessage extends FormatInterface {
|
|
188
186
|
get keys() {
|
|
189
187
|
return ['response']
|
|
190
188
|
}
|
|
@@ -206,7 +204,7 @@ message PeernetPeerMessageResponse {
|
|
|
206
204
|
}
|
|
207
205
|
`;
|
|
208
206
|
|
|
209
|
-
class PeerMessageResponse extends
|
|
207
|
+
class PeerMessageResponse extends FormatInterface {
|
|
210
208
|
get keys() {
|
|
211
209
|
return ['id']
|
|
212
210
|
}
|
|
@@ -229,7 +227,7 @@ message PeernetDataMessageResponse {
|
|
|
229
227
|
}
|
|
230
228
|
`;
|
|
231
229
|
|
|
232
|
-
class DataMessageResponse extends
|
|
230
|
+
class DataMessageResponse extends FormatInterface {
|
|
233
231
|
get keys() {
|
|
234
232
|
return ['hash', 'data']
|
|
235
233
|
}
|
|
@@ -252,7 +250,7 @@ message ChatMessage {
|
|
|
252
250
|
repeated string files = 4;
|
|
253
251
|
}`;
|
|
254
252
|
|
|
255
|
-
class ChatMessage extends
|
|
253
|
+
class ChatMessage extends FormatInterface {
|
|
256
254
|
get keys() {
|
|
257
255
|
return ['author', 'value', 'timestamp', 'files']
|
|
258
256
|
}
|
|
@@ -285,7 +283,7 @@ message PeernetFile {
|
|
|
285
283
|
/**
|
|
286
284
|
* @extends {CodecFormat}
|
|
287
285
|
*/
|
|
288
|
-
class PeernetFile extends
|
|
286
|
+
class PeernetFile extends FormatInterface {
|
|
289
287
|
get keys() {
|
|
290
288
|
return ['path', 'content', 'links']
|
|
291
289
|
}
|
|
@@ -301,15 +299,4 @@ class PeernetFile extends codecFormatInterface.FormatInterface {
|
|
|
301
299
|
}
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
|
|
305
|
-
exports.DHTMessage = DHTMessage;
|
|
306
|
-
exports.DHTMessageResponse = DHTMessageResponse;
|
|
307
|
-
exports.DataMessage = DataMessage;
|
|
308
|
-
exports.DataMessageResponse = DataMessageResponse;
|
|
309
|
-
exports.PeerMessage = PeerMessage;
|
|
310
|
-
exports.PeerMessageResponse = PeerMessageResponse;
|
|
311
|
-
exports.PeernetFile = PeernetFile;
|
|
312
|
-
exports.PeernetMessage = PeernetMessage;
|
|
313
|
-
exports.PsMessage = PsMessage;
|
|
314
|
-
exports.RequestMessage = RequestMessage;
|
|
315
|
-
exports.ResponseMessage = ResponseMessage;
|
|
302
|
+
export { ChatMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PeerMessage, PeerMessageResponse, PeernetFile, PeernetMessage, PsMessage, RequestMessage, ResponseMessage };
|
package/dist/module/peernet.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var PubSub = require('@vandeurenglenn/little-pubsub');
|
|
5
|
-
var codecFormatInterface = require('@leofcoin/codec-format-interface');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n["default"] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var PubSub__default = /*#__PURE__*/_interopDefaultLegacy(PubSub);
|
|
1
|
+
import '@vandeurenglenn/debug';
|
|
2
|
+
import PubSub from '@vandeurenglenn/little-pubsub';
|
|
3
|
+
import { Codec } from '@leofcoin/codec-format-interface';
|
|
28
4
|
|
|
29
5
|
const BufferToUint8Array = data => {
|
|
30
6
|
if (data.type === 'Buffer') {
|
|
@@ -34,7 +10,7 @@ const BufferToUint8Array = data => {
|
|
|
34
10
|
};
|
|
35
11
|
|
|
36
12
|
const protoFor = (message) => {
|
|
37
|
-
const codec = new
|
|
13
|
+
const codec = new Codec(message);
|
|
38
14
|
if (!codec.name) throw new Error('proto not found')
|
|
39
15
|
const Proto = globalThis.peernet.protos[codec.name];
|
|
40
16
|
if (!Proto) throw (new Error(`No proto defined for ${codec.name}`))
|
|
@@ -389,7 +365,7 @@ class MessageHandler {
|
|
|
389
365
|
let identity = await walletStore.get('identity');
|
|
390
366
|
identity = JSON.parse(identity);
|
|
391
367
|
if (!globalThis.MultiWallet) {
|
|
392
|
-
const importee = await
|
|
368
|
+
const importee = await import(/* webpackChunkName: "multi-wallet" */ '@leofcoin/multi-wallet');
|
|
393
369
|
globalThis.MultiWallet = importee.default;
|
|
394
370
|
}
|
|
395
371
|
const wallet = new MultiWallet(this.network);
|
|
@@ -432,8 +408,8 @@ const nothingFoundError = (hash) => {
|
|
|
432
408
|
};
|
|
433
409
|
|
|
434
410
|
globalThis.leofcoin = globalThis.leofcoin || {};
|
|
435
|
-
globalThis.pubsub = globalThis.pubsub || new
|
|
436
|
-
globalThis.globalSub = globalThis.globalSub || new
|
|
411
|
+
globalThis.pubsub = globalThis.pubsub || new PubSub();
|
|
412
|
+
globalThis.globalSub = globalThis.globalSub || new PubSub({verbose: true});
|
|
437
413
|
|
|
438
414
|
/**
|
|
439
415
|
* @access public
|
|
@@ -493,7 +469,7 @@ class Peernet {
|
|
|
493
469
|
|
|
494
470
|
async addStore(name, prefix, root, isPrivate = true) {
|
|
495
471
|
if (!globalThis.LeofcoinStorage) {
|
|
496
|
-
const importee = await
|
|
472
|
+
const importee = await import(/* webpackChunkName: "storage" */ '@leofcoin/storage');
|
|
497
473
|
globalThis.LeofcoinStorage = importee.default;
|
|
498
474
|
}
|
|
499
475
|
if (name === 'block' || name === 'transaction' || name === 'chain' ||
|
|
@@ -582,7 +558,7 @@ class Peernet {
|
|
|
582
558
|
ChatMessage,
|
|
583
559
|
PeernetFile
|
|
584
560
|
// FolderMessageResponse
|
|
585
|
-
} = await
|
|
561
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-bce1b91d.js');
|
|
586
562
|
|
|
587
563
|
/**
|
|
588
564
|
* proto Object containing protos
|
|
@@ -634,7 +610,7 @@ class Peernet {
|
|
|
634
610
|
this.accounts = [accounts.split(',')];
|
|
635
611
|
}
|
|
636
612
|
} else {
|
|
637
|
-
const importee = await
|
|
613
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ '@leofcoin/generate-account');
|
|
638
614
|
const generateAccount = importee.default;
|
|
639
615
|
const {identity, accounts, config} = await generateAccount(this.network);
|
|
640
616
|
// await accountStore.put('config', JSON.stringify(config));
|
|
@@ -650,7 +626,7 @@ class Peernet {
|
|
|
650
626
|
this.peerId = this.id;
|
|
651
627
|
|
|
652
628
|
pubsub.subscribe('peer:connected', async (peer) => {
|
|
653
|
-
console.log(peer);
|
|
629
|
+
// console.log(peer);
|
|
654
630
|
// console.log({connected: peer.id, as: this._getPeerId(peer.id) });
|
|
655
631
|
// peer.on('peernet.data', async (message) => {
|
|
656
632
|
// const id = message.id
|
|
@@ -667,7 +643,7 @@ class Peernet {
|
|
|
667
643
|
pubsub.subscribe('peer:data', dataHandler);
|
|
668
644
|
|
|
669
645
|
|
|
670
|
-
const importee = await
|
|
646
|
+
const importee = await import(/* webpackChunkName: "peernet-swarm" */ '@leofcoin/peernet-swarm');
|
|
671
647
|
/**
|
|
672
648
|
* @access public
|
|
673
649
|
* @type {PeernetClient}
|
|
@@ -760,7 +736,6 @@ class Peernet {
|
|
|
760
736
|
const walk = async peer => {
|
|
761
737
|
const node = await this.prepareMessage(data);
|
|
762
738
|
let result = await peer.request(node.encoded);
|
|
763
|
-
console.log({result});
|
|
764
739
|
result = new Uint8Array(Object.values(result));
|
|
765
740
|
const proto = await protoFor(result);
|
|
766
741
|
if (proto.name !== 'peernet-dht-response') throw dhtError(proto.name)
|
|
@@ -1107,15 +1082,7 @@ class Peernet {
|
|
|
1107
1082
|
get Buffer() {
|
|
1108
1083
|
return Buffer
|
|
1109
1084
|
}
|
|
1110
|
-
// async block(index) {
|
|
1111
|
-
// const _values = []
|
|
1112
|
-
// for (const peer of this.peers) {
|
|
1113
|
-
// const value = await peer.request({type: 'block', index})
|
|
1114
|
-
// console.log(value);
|
|
1115
|
-
// }
|
|
1116
|
-
//
|
|
1117
|
-
// }
|
|
1118
1085
|
}
|
|
1119
1086
|
globalThis.Peernet = Peernet;
|
|
1120
1087
|
|
|
1121
|
-
|
|
1088
|
+
export { Peernet as default };
|
package/index.html
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
<title></title>
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
|
-
<script src="./dist/browser/peernet.js">
|
|
9
|
-
</script>
|
|
8
|
+
<!-- <script src="./dist/browser/peernet.js">
|
|
9
|
+
</script> -->
|
|
10
10
|
|
|
11
|
-
<script >
|
|
12
|
-
|
|
11
|
+
<script type="module">
|
|
12
|
+
import Peernet from './dist/browser/peernet.mjs';
|
|
13
13
|
(async () => {
|
|
14
14
|
const peernet = await new Peernet()
|
|
15
15
|
peernet.addRequestHandler('lastBlock', () => new peernet.protos['peernet-response']({response: new TextEncoder().encode(100)}))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/peernet",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "src/peernet.js",
|
|
6
6
|
"main": "dist/commonjs/peernet.js",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"keccak": "^3.0.1",
|
|
40
40
|
"koa": "^2.13.1",
|
|
41
41
|
"node-fetch": "^2.6.1",
|
|
42
|
+
"readable-stream": "^4.2.0",
|
|
42
43
|
"socket-request-client": "^1.5.0",
|
|
43
44
|
"socket-request-server": "^1.5.0",
|
|
44
45
|
"varint": "^6.0.0"
|
|
@@ -49,13 +50,10 @@
|
|
|
49
50
|
"eslint": "^7.31.0",
|
|
50
51
|
"eslint-config-google": "^0.14.0",
|
|
51
52
|
"nyc": "^15.1.0",
|
|
52
|
-
"os-browserify": "^0.3.0",
|
|
53
53
|
"path-browserify": "^1.0.1",
|
|
54
54
|
"rollup": "^2.70.2",
|
|
55
55
|
"rollup-plugin-modify": "^3.0.0",
|
|
56
|
-
"stream-browserify": "^3.0.0",
|
|
57
56
|
"tape": "^5.2.2",
|
|
58
|
-
"vm-browserify": "^1.1.2",
|
|
59
57
|
"webpack": "^5.72.0",
|
|
60
58
|
"webpack-cli": "^4.9.2"
|
|
61
59
|
}
|
package/rollup.config.js
CHANGED
package/src/peernet.js
CHANGED
|
@@ -228,7 +228,7 @@ export default class Peernet {
|
|
|
228
228
|
this.peerId = this.id
|
|
229
229
|
|
|
230
230
|
pubsub.subscribe('peer:connected', async (peer) => {
|
|
231
|
-
console.log(peer);
|
|
231
|
+
// console.log(peer);
|
|
232
232
|
// console.log({connected: peer.id, as: this._getPeerId(peer.id) });
|
|
233
233
|
// peer.on('peernet.data', async (message) => {
|
|
234
234
|
// const id = message.id
|
|
@@ -342,7 +342,6 @@ export default class Peernet {
|
|
|
342
342
|
const walk = async peer => {
|
|
343
343
|
const node = await this.prepareMessage(data)
|
|
344
344
|
let result = await peer.request(node.encoded)
|
|
345
|
-
console.log({result});
|
|
346
345
|
result = new Uint8Array(Object.values(result))
|
|
347
346
|
const proto = await protoFor(result)
|
|
348
347
|
if (proto.name !== 'peernet-dht-response') throw dhtError(proto.name)
|
|
@@ -690,13 +689,5 @@ export default class Peernet {
|
|
|
690
689
|
get Buffer() {
|
|
691
690
|
return Buffer
|
|
692
691
|
}
|
|
693
|
-
// async block(index) {
|
|
694
|
-
// const _values = []
|
|
695
|
-
// for (const peer of this.peers) {
|
|
696
|
-
// const value = await peer.request({type: 'block', index})
|
|
697
|
-
// console.log(value);
|
|
698
|
-
// }
|
|
699
|
-
//
|
|
700
|
-
// }
|
|
701
692
|
}
|
|
702
693
|
globalThis.Peernet = Peernet
|
package/webpack.config.js
CHANGED
|
@@ -8,8 +8,11 @@ module.exports = [{
|
|
|
8
8
|
plugins: [
|
|
9
9
|
// Work around for Buffer is undefined:
|
|
10
10
|
// https://github.com/webpack/changelog-v5/issues/10
|
|
11
|
+
// new webpack.ProvidePlugin({
|
|
12
|
+
// Buffer: ['buffer', 'Buffer'],
|
|
13
|
+
// }),
|
|
11
14
|
new webpack.ProvidePlugin({
|
|
12
|
-
|
|
15
|
+
Stream: ['stream', 'Stream'],
|
|
13
16
|
}),
|
|
14
17
|
new webpack.ProvidePlugin({
|
|
15
18
|
process: 'process/browser',
|
|
@@ -36,12 +39,10 @@ resolve: {
|
|
|
36
39
|
fallback: {
|
|
37
40
|
fs: false,
|
|
38
41
|
util: false,
|
|
39
|
-
"stream": require.resolve("stream-browserify"),
|
|
40
|
-
"buffer": require.resolve("buffer"),
|
|
41
42
|
"path": require.resolve("path-browserify"),
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"stream": require.resolve("readable-stream"),
|
|
44
|
+
"os": require.resolve("@leofcoin/storage/src/os-shim.js"),
|
|
45
|
+
"@os:import": require.resolve("@leofcoin/storage/src/os-shim.js"),
|
|
45
46
|
"@store:import": require.resolve("@leofcoin/storage/src/store-shim.js")
|
|
46
47
|
}
|
|
47
48
|
},
|
|
@@ -56,4 +57,58 @@ resolve: {
|
|
|
56
57
|
filename: '[name].js',
|
|
57
58
|
path: path.resolve(__dirname, 'dist', 'browser'),
|
|
58
59
|
},
|
|
60
|
+
}, {
|
|
61
|
+
entry: {
|
|
62
|
+
peernet: './dist/module/peernet.js'
|
|
63
|
+
},
|
|
64
|
+
mode: 'production',
|
|
65
|
+
plugins: [
|
|
66
|
+
// Work around for Buffer is undefined:
|
|
67
|
+
// https://github.com/webpack/changelog-v5/issues/10
|
|
68
|
+
// new webpack.ProvidePlugin({
|
|
69
|
+
// Buffer: ['buffer', 'Buffer'],
|
|
70
|
+
// }),
|
|
71
|
+
new webpack.ProvidePlugin({
|
|
72
|
+
Stream: ['stream', 'Stream'],
|
|
73
|
+
}),
|
|
74
|
+
new webpack.ProvidePlugin({
|
|
75
|
+
process: 'process/browser',
|
|
76
|
+
}),
|
|
77
|
+
new webpack.DefinePlugin({
|
|
78
|
+
HTTP_IMPORT: '',
|
|
79
|
+
"import fetch from 'node-fetch'": ''
|
|
80
|
+
}),
|
|
81
|
+
new webpack.IgnorePlugin({
|
|
82
|
+
checkResource(resource, context) {
|
|
83
|
+
if (resource.includes('./wordlists') && !resource.includes('english')) return true
|
|
84
|
+
// console.log(resource, context);
|
|
85
|
+
}
|
|
86
|
+
}) // bi39 wordlist (mnemonic) only english
|
|
87
|
+
],
|
|
88
|
+
optimization: {
|
|
89
|
+
minimize: false
|
|
90
|
+
},
|
|
91
|
+
experiments: {
|
|
92
|
+
outputModule: true
|
|
93
|
+
},
|
|
94
|
+
resolve: {
|
|
95
|
+
extensions: [ '.ts', '.js' ],
|
|
96
|
+
fallback: {
|
|
97
|
+
fs: false,
|
|
98
|
+
util: false,
|
|
99
|
+
"path": require.resolve("path-browserify"),
|
|
100
|
+
"stream": require.resolve("readable-stream"),
|
|
101
|
+
"os": require.resolve("@leofcoin/storage/src/os-shim.js"),
|
|
102
|
+
"@os:import": require.resolve("@leofcoin/storage/src/os-shim.js"),
|
|
103
|
+
"@store:import": require.resolve("@leofcoin/storage/src/store-shim.js")
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
output: {
|
|
107
|
+
library: {
|
|
108
|
+
type: 'module'
|
|
109
|
+
},
|
|
110
|
+
chunkFilename: '[name].mjs',
|
|
111
|
+
filename: '[name].mjs',
|
|
112
|
+
path: path.resolve(__dirname, 'dist', 'browser'),
|
|
113
|
+
},
|
|
59
114
|
}];
|