@leofcoin/chain 1.5.65 → 1.5.67
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/exports/browser/{_polyfill-node.url-1q06MepH.js → _polyfill-node.url-Bp9XkJZf.js} +1 -1
- package/exports/browser/{browser-1GyRaZxg-C9SpI6hG.js → browser-Ei0BXMlu-C1_XUL9Y.js} +2 -2
- package/exports/browser/browser-store.js +122 -309
- package/exports/browser/chain.js +38 -14
- package/exports/browser/{client-UOCjJBGl-pbv-pTHd.js → client-A009z8av-DQfd3vOY.js} +5 -5
- package/exports/browser/{index-ub31QSed-EMPr2oeb.js → index-G74WLzL7-Dt2dwaXq.js} +2 -2
- package/exports/browser/{index-K4Kwju30-vS3fNpxy.js → index-YQrIDBUQ-c7011Ab4.js} +2 -2
- package/exports/browser/{messages-guyZfse6-JeAlT5Nb.js → messages-lWRTai7t-ClhClfC1.js} +2 -2
- package/exports/browser/{node-browser-0Ly80awM.js → node-browser-DqIklEKv.js} +624 -622
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +1 -1
- package/exports/chain.js +8 -1
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +1 -1
- package/package.json +1 -1
- /package/exports/browser/{_polyfill-node.child_process-rc1HO9Xs.js → _polyfill-node.child_process-BsjYmFff.js} +0 -0
- /package/exports/browser/{browser-AyxSBUXj-AyxSBUXj.js → browser-AyxSBUXj-pguCHlVu.js} +0 -0
- /package/exports/browser/{password-JCRBtU5A.js → password-oDixGC8h.js} +0 -0
- /package/exports/browser/{qr-scanner-worker.min-RaSiJc_R-RaSiJc_R.js → qr-scanner-worker.min-RaSiJc_R-Dy0qkKA4.js} +0 -0
- /package/exports/browser/workers/{worker-hbo9s9AT.js → worker-CltAyHf1.js} +0 -0
- /package/exports/workers/{worker-hbo9s9AT.js → worker-CltAyHf1.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as getDefaultExportFromCjs } from './node-browser-
|
|
2
|
-
import './_polyfill-node.child_process-
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './node-browser-DqIklEKv.js';
|
|
2
|
+
import './_polyfill-node.child_process-BsjYmFff.js';
|
|
3
3
|
|
|
4
4
|
var global;
|
|
5
5
|
var hasRequiredGlobal;
|
|
@@ -70,310 +70,61 @@ class KeyValue {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const transformCache = new WeakMap();
|
|
99
|
-
const reverseTransformCache = new WeakMap();
|
|
100
|
-
function promisifyRequest(request) {
|
|
101
|
-
const promise = new Promise((resolve, reject) => {
|
|
102
|
-
const unlisten = () => {
|
|
103
|
-
request.removeEventListener('success', success);
|
|
104
|
-
request.removeEventListener('error', error);
|
|
105
|
-
};
|
|
106
|
-
const success = () => {
|
|
107
|
-
resolve(wrap(request.result));
|
|
108
|
-
unlisten();
|
|
109
|
-
};
|
|
110
|
-
const error = () => {
|
|
111
|
-
reject(request.error);
|
|
112
|
-
unlisten();
|
|
113
|
-
};
|
|
114
|
-
request.addEventListener('success', success);
|
|
115
|
-
request.addEventListener('error', error);
|
|
116
|
-
});
|
|
117
|
-
// This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This
|
|
118
|
-
// is because we create many promises from a single IDBRequest.
|
|
119
|
-
reverseTransformCache.set(promise, request);
|
|
120
|
-
return promise;
|
|
121
|
-
}
|
|
122
|
-
function cacheDonePromiseForTransaction(tx) {
|
|
123
|
-
// Early bail if we've already created a done promise for this transaction.
|
|
124
|
-
if (transactionDoneMap.has(tx))
|
|
125
|
-
return;
|
|
126
|
-
const done = new Promise((resolve, reject) => {
|
|
127
|
-
const unlisten = () => {
|
|
128
|
-
tx.removeEventListener('complete', complete);
|
|
129
|
-
tx.removeEventListener('error', error);
|
|
130
|
-
tx.removeEventListener('abort', error);
|
|
131
|
-
};
|
|
132
|
-
const complete = () => {
|
|
133
|
-
resolve();
|
|
134
|
-
unlisten();
|
|
135
|
-
};
|
|
136
|
-
const error = () => {
|
|
137
|
-
reject(tx.error || new DOMException('AbortError', 'AbortError'));
|
|
138
|
-
unlisten();
|
|
139
|
-
};
|
|
140
|
-
tx.addEventListener('complete', complete);
|
|
141
|
-
tx.addEventListener('error', error);
|
|
142
|
-
tx.addEventListener('abort', error);
|
|
143
|
-
});
|
|
144
|
-
// Cache it for later retrieval.
|
|
145
|
-
transactionDoneMap.set(tx, done);
|
|
146
|
-
}
|
|
147
|
-
let idbProxyTraps = {
|
|
148
|
-
get(target, prop, receiver) {
|
|
149
|
-
if (target instanceof IDBTransaction) {
|
|
150
|
-
// Special handling for transaction.done.
|
|
151
|
-
if (prop === 'done')
|
|
152
|
-
return transactionDoneMap.get(target);
|
|
153
|
-
// Make tx.store return the only store in the transaction, or undefined if there are many.
|
|
154
|
-
if (prop === 'store') {
|
|
155
|
-
return receiver.objectStoreNames[1]
|
|
156
|
-
? undefined
|
|
157
|
-
: receiver.objectStore(receiver.objectStoreNames[0]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Else transform whatever we get back.
|
|
161
|
-
return wrap(target[prop]);
|
|
162
|
-
},
|
|
163
|
-
set(target, prop, value) {
|
|
164
|
-
target[prop] = value;
|
|
165
|
-
return true;
|
|
166
|
-
},
|
|
167
|
-
has(target, prop) {
|
|
168
|
-
if (target instanceof IDBTransaction &&
|
|
169
|
-
(prop === 'done' || prop === 'store')) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
return prop in target;
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
function replaceTraps(callback) {
|
|
176
|
-
idbProxyTraps = callback(idbProxyTraps);
|
|
177
|
-
}
|
|
178
|
-
function wrapFunction(func) {
|
|
179
|
-
// Due to expected object equality (which is enforced by the caching in `wrap`), we
|
|
180
|
-
// only create one new func per func.
|
|
181
|
-
// Cursor methods are special, as the behaviour is a little more different to standard IDB. In
|
|
182
|
-
// IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
|
|
183
|
-
// cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
|
|
184
|
-
// with real promises, so each advance methods returns a new promise for the cursor object, or
|
|
185
|
-
// undefined if the end of the cursor has been reached.
|
|
186
|
-
if (getCursorAdvanceMethods().includes(func)) {
|
|
187
|
-
return function (...args) {
|
|
188
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
189
|
-
// the original object.
|
|
190
|
-
func.apply(unwrap(this), args);
|
|
191
|
-
return wrap(this.request);
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
return function (...args) {
|
|
195
|
-
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
196
|
-
// the original object.
|
|
197
|
-
return wrap(func.apply(unwrap(this), args));
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function transformCachableValue(value) {
|
|
201
|
-
if (typeof value === 'function')
|
|
202
|
-
return wrapFunction(value);
|
|
203
|
-
// This doesn't return, it just creates a 'done' promise for the transaction,
|
|
204
|
-
// which is later returned for transaction.done (see idbObjectHandler).
|
|
205
|
-
if (value instanceof IDBTransaction)
|
|
206
|
-
cacheDonePromiseForTransaction(value);
|
|
207
|
-
if (instanceOfAny(value, getIdbProxyableTypes()))
|
|
208
|
-
return new Proxy(value, idbProxyTraps);
|
|
209
|
-
// Return the same value back if we're not going to transform it.
|
|
210
|
-
return value;
|
|
211
|
-
}
|
|
212
|
-
function wrap(value) {
|
|
213
|
-
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
214
|
-
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
215
|
-
if (value instanceof IDBRequest)
|
|
216
|
-
return promisifyRequest(value);
|
|
217
|
-
// If we've already transformed this value before, reuse the transformed value.
|
|
218
|
-
// This is faster, but it also provides object equality.
|
|
219
|
-
if (transformCache.has(value))
|
|
220
|
-
return transformCache.get(value);
|
|
221
|
-
const newValue = transformCachableValue(value);
|
|
222
|
-
// Not all types are transformed.
|
|
223
|
-
// These may be primitive types, so they can't be WeakMap keys.
|
|
224
|
-
if (newValue !== value) {
|
|
225
|
-
transformCache.set(value, newValue);
|
|
226
|
-
reverseTransformCache.set(newValue, value);
|
|
227
|
-
}
|
|
228
|
-
return newValue;
|
|
229
|
-
}
|
|
230
|
-
const unwrap = (value) => reverseTransformCache.get(value);
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Open a database.
|
|
234
|
-
*
|
|
235
|
-
* @param name Name of the database.
|
|
236
|
-
* @param version Schema version.
|
|
237
|
-
* @param callbacks Additional callbacks.
|
|
238
|
-
*/
|
|
239
|
-
function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
|
|
240
|
-
const request = indexedDB.open(name, version);
|
|
241
|
-
const openPromise = wrap(request);
|
|
242
|
-
if (upgrade) {
|
|
243
|
-
request.addEventListener('upgradeneeded', (event) => {
|
|
244
|
-
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
if (blocked) {
|
|
248
|
-
request.addEventListener('blocked', (event) => blocked(
|
|
249
|
-
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
250
|
-
event.oldVersion, event.newVersion, event));
|
|
251
|
-
}
|
|
252
|
-
openPromise
|
|
253
|
-
.then((db) => {
|
|
254
|
-
if (terminated)
|
|
255
|
-
db.addEventListener('close', () => terminated());
|
|
256
|
-
if (blocking) {
|
|
257
|
-
db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
|
|
258
|
-
}
|
|
259
|
-
})
|
|
260
|
-
.catch(() => { });
|
|
261
|
-
return openPromise;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
|
|
265
|
-
const writeMethods = ['put', 'add', 'delete', 'clear'];
|
|
266
|
-
const cachedMethods = new Map();
|
|
267
|
-
function getMethod(target, prop) {
|
|
268
|
-
if (!(target instanceof IDBDatabase &&
|
|
269
|
-
!(prop in target) &&
|
|
270
|
-
typeof prop === 'string')) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (cachedMethods.get(prop))
|
|
274
|
-
return cachedMethods.get(prop);
|
|
275
|
-
const targetFuncName = prop.replace(/FromIndex$/, '');
|
|
276
|
-
const useIndex = prop !== targetFuncName;
|
|
277
|
-
const isWrite = writeMethods.includes(targetFuncName);
|
|
278
|
-
if (
|
|
279
|
-
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
280
|
-
!(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
|
|
281
|
-
!(isWrite || readMethods.includes(targetFuncName))) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const method = async function (storeName, ...args) {
|
|
285
|
-
// isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
|
|
286
|
-
const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
|
|
287
|
-
let target = tx.store;
|
|
288
|
-
if (useIndex)
|
|
289
|
-
target = target.index(args.shift());
|
|
290
|
-
// Must reject if op rejects.
|
|
291
|
-
// If it's a write operation, must reject if tx.done rejects.
|
|
292
|
-
// Must reject with op rejection first.
|
|
293
|
-
// Must resolve with op value.
|
|
294
|
-
// Must handle both promises (no unhandled rejections)
|
|
295
|
-
return (await Promise.all([
|
|
296
|
-
target[targetFuncName](...args),
|
|
297
|
-
isWrite && tx.done,
|
|
298
|
-
]))[0];
|
|
299
|
-
};
|
|
300
|
-
cachedMethods.set(prop, method);
|
|
301
|
-
return method;
|
|
73
|
+
if (!globalThis.DEBUG) {
|
|
74
|
+
let DEBUG = [];
|
|
75
|
+
if (globalThis.localStorage) {
|
|
76
|
+
DEBUG = globalThis.localStorage.getItem('DEBUG');
|
|
77
|
+
globalThis.DEBUG = DEBUG ? DEBUG.split(',') : [DEBUG];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const debug$1 = (target, text) => {
|
|
82
|
+
if (!globalThis.DEBUG && globalThis.DEBUG.length === 0) return;
|
|
83
|
+
if (
|
|
84
|
+
globalThis.DEBUG === 'true' ||
|
|
85
|
+
globalThis.DEBUG === true ||
|
|
86
|
+
globalThis.DEBUG?.indexOf(target) !== -1 ||
|
|
87
|
+
globalThis.DEBUG?.indexOf('*') !== -1 ||
|
|
88
|
+
globalThis.DEBUG?.indexOf(target.split('/')[0]) !== -1
|
|
89
|
+
)
|
|
90
|
+
if (text) console.log('\x1b[34m\x1b[1m%s', `${target}: ${text}`, '\x1b[0m');
|
|
91
|
+
else console.log('\x1b[34m\x1b[1m%s', `${target}`, '\x1b[0m');
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
if (!globalThis.debug) {
|
|
95
|
+
globalThis.debug = debug$1;
|
|
96
|
+
|
|
97
|
+
globalThis.createDebugger = (target) => (text) => debug$1(target, text);
|
|
302
98
|
}
|
|
303
|
-
replaceTraps((oldTraps) => ({
|
|
304
|
-
...oldTraps,
|
|
305
|
-
get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
|
|
306
|
-
has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
|
|
307
|
-
}));
|
|
308
|
-
|
|
309
|
-
const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];
|
|
310
|
-
const methodMap = {};
|
|
311
|
-
const advanceResults = new WeakMap();
|
|
312
|
-
const ittrProxiedCursorToOriginalProxy = new WeakMap();
|
|
313
|
-
const cursorIteratorTraps = {
|
|
314
|
-
get(target, prop) {
|
|
315
|
-
if (!advanceMethodProps.includes(prop))
|
|
316
|
-
return target[prop];
|
|
317
|
-
let cachedFunc = methodMap[prop];
|
|
318
|
-
if (!cachedFunc) {
|
|
319
|
-
cachedFunc = methodMap[prop] = function (...args) {
|
|
320
|
-
advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return cachedFunc;
|
|
324
|
-
},
|
|
325
|
-
};
|
|
326
|
-
async function* iterate(...args) {
|
|
327
|
-
// tslint:disable-next-line:no-this-assignment
|
|
328
|
-
let cursor = this;
|
|
329
|
-
if (!(cursor instanceof IDBCursor)) {
|
|
330
|
-
cursor = await cursor.openCursor(...args);
|
|
331
|
-
}
|
|
332
|
-
if (!cursor)
|
|
333
|
-
return;
|
|
334
|
-
cursor = cursor;
|
|
335
|
-
const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
|
|
336
|
-
ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
|
|
337
|
-
// Map this double-proxy back to the original, so other cursor methods work.
|
|
338
|
-
reverseTransformCache.set(proxiedCursor, unwrap(cursor));
|
|
339
|
-
while (cursor) {
|
|
340
|
-
yield proxiedCursor;
|
|
341
|
-
// If one of the advancing methods was not called, call continue().
|
|
342
|
-
cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
|
|
343
|
-
advanceResults.delete(proxiedCursor);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
function isIteratorProp(target, prop) {
|
|
347
|
-
return ((prop === Symbol.asyncIterator &&
|
|
348
|
-
instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) ||
|
|
349
|
-
(prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore])));
|
|
350
|
-
}
|
|
351
|
-
replaceTraps((oldTraps) => ({
|
|
352
|
-
...oldTraps,
|
|
353
|
-
get(target, prop, receiver) {
|
|
354
|
-
if (isIteratorProp(target, prop))
|
|
355
|
-
return iterate;
|
|
356
|
-
return oldTraps.get(target, prop, receiver);
|
|
357
|
-
},
|
|
358
|
-
has(target, prop) {
|
|
359
|
-
return isIteratorProp(target, prop) || oldTraps.has(target, prop);
|
|
360
|
-
},
|
|
361
|
-
}));
|
|
362
99
|
|
|
100
|
+
const debug = globalThis.createDebugger('leofcoin/storage');
|
|
101
|
+
const opfsRoot = await navigator.storage.getDirectory();
|
|
363
102
|
class BrowerStore {
|
|
364
103
|
db;
|
|
365
104
|
name;
|
|
366
105
|
root;
|
|
106
|
+
inWorker;
|
|
367
107
|
version;
|
|
368
|
-
|
|
108
|
+
busy;
|
|
109
|
+
queue = [];
|
|
110
|
+
async init(name = 'storage', root = '.leofcoin', version = '1', inWorker = false) {
|
|
369
111
|
this.version = version;
|
|
370
112
|
this.name = name;
|
|
371
|
-
this.root =
|
|
372
|
-
this.
|
|
373
|
-
|
|
374
|
-
|
|
113
|
+
this.root = opfsRoot;
|
|
114
|
+
this.inWorker = inWorker;
|
|
115
|
+
let directoryHandle;
|
|
116
|
+
try {
|
|
117
|
+
directoryHandle = await opfsRoot.getDirectoryHandle(this.name, {
|
|
118
|
+
create: true
|
|
119
|
+
});
|
|
120
|
+
if (inWorker) {
|
|
121
|
+
directoryHandle = await directoryHandle.createSyncAccessHandle();
|
|
375
122
|
}
|
|
376
|
-
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
console.error(error);
|
|
126
|
+
}
|
|
127
|
+
this.db = directoryHandle;
|
|
377
128
|
}
|
|
378
129
|
toKeyPath(key) {
|
|
379
130
|
if (key instanceof KeyPath)
|
|
@@ -386,40 +137,102 @@ class BrowerStore {
|
|
|
386
137
|
// @ts-ignore
|
|
387
138
|
return value.uint8Array;
|
|
388
139
|
}
|
|
140
|
+
async has(key) {
|
|
141
|
+
debug(`has ${this.toKeyPath(key)}`);
|
|
142
|
+
try {
|
|
143
|
+
await this.db.getFileHandle(this.toKeyPath(key));
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
389
150
|
async get(key) {
|
|
390
|
-
|
|
151
|
+
debug(`get ${this.toKeyPath(key)}`);
|
|
152
|
+
let handle = await this.db.getFileHandle(this.toKeyPath(key));
|
|
153
|
+
let readBuffer;
|
|
154
|
+
if (this.inWorker) {
|
|
155
|
+
handle = await handle.createSyncAccessHandle();
|
|
156
|
+
const fileSize = handle.getSize();
|
|
157
|
+
// Read file content to a buffer.
|
|
158
|
+
const buffer = new DataView(new ArrayBuffer(fileSize));
|
|
159
|
+
readBuffer = handle.read(buffer, { at: 0 });
|
|
160
|
+
handle.close();
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const file = await handle.getFile();
|
|
164
|
+
readBuffer = await file.arrayBuffer();
|
|
165
|
+
}
|
|
166
|
+
return new Uint8Array(readBuffer);
|
|
391
167
|
}
|
|
392
168
|
async put(key, value) {
|
|
393
|
-
|
|
169
|
+
const promise = () => new Promise(async (resolve) => {
|
|
170
|
+
debug(`put ${this.toKeyPath(key)}`);
|
|
171
|
+
let handle = await this.db.getFileHandle(this.toKeyPath(key), { create: true });
|
|
172
|
+
let writeable;
|
|
173
|
+
if (this.inWorker) {
|
|
174
|
+
writeable = await handle.createSyncAccessHandle();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
writeable = await handle.createWritable();
|
|
178
|
+
}
|
|
179
|
+
(await writeable).write(this.toKeyValue(value));
|
|
180
|
+
(await writeable).close();
|
|
181
|
+
resolve(true);
|
|
182
|
+
if (this.queue.length > 0 && !this.busy) {
|
|
183
|
+
this.runQueue();
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
this.queue.push(promise);
|
|
187
|
+
this.runQueue();
|
|
188
|
+
return promise;
|
|
189
|
+
}
|
|
190
|
+
async runQueue() {
|
|
191
|
+
if (this.queue.length > 0) {
|
|
192
|
+
this.busy = true;
|
|
193
|
+
const next = this.queue.shift();
|
|
194
|
+
await next();
|
|
195
|
+
return this.runQueue();
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this.busy = false;
|
|
199
|
+
}
|
|
394
200
|
}
|
|
395
201
|
async delete(key) {
|
|
396
|
-
|
|
202
|
+
debug(`delete ${this.toKeyPath(key)}`);
|
|
203
|
+
return this.db.removeEntry(this.toKeyPath(key));
|
|
397
204
|
}
|
|
398
205
|
async clear() {
|
|
399
|
-
|
|
206
|
+
debug(`clear ${this.toKeyPath(key)}`);
|
|
207
|
+
for await (const key of this.db.keys()) {
|
|
208
|
+
await this.db.removeEntry(key);
|
|
209
|
+
}
|
|
400
210
|
}
|
|
401
211
|
async values(limit = -1) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
for await (const cursor of
|
|
405
|
-
values.push(cursor.
|
|
406
|
-
if (limit && values.length === limit)
|
|
407
|
-
|
|
212
|
+
debug(`values ${limit}`);
|
|
213
|
+
let values = [];
|
|
214
|
+
for await (const cursor of this.db.values()) {
|
|
215
|
+
values.push(cursor.getFile());
|
|
216
|
+
if (limit && values.length === limit) {
|
|
217
|
+
values = await Promise.all(values);
|
|
218
|
+
return Promise.all(values.map(async (file) => new Uint8Array(await file.arrayBuffer())));
|
|
219
|
+
}
|
|
408
220
|
}
|
|
409
|
-
|
|
221
|
+
values = await Promise.all(values);
|
|
222
|
+
return Promise.all(values.map(async (file) => new Uint8Array(await file.arrayBuffer())));
|
|
410
223
|
}
|
|
411
224
|
async keys(limit = -1) {
|
|
225
|
+
debug(`keys ${limit}`);
|
|
412
226
|
const keys = [];
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
keys.push(cursor.key);
|
|
227
|
+
for await (const cursor of this.db.keys()) {
|
|
228
|
+
keys.push(cursor);
|
|
416
229
|
if (limit && keys.length === limit)
|
|
417
230
|
return keys;
|
|
418
231
|
}
|
|
419
232
|
return keys;
|
|
420
233
|
}
|
|
421
234
|
async iterate() {
|
|
422
|
-
return
|
|
235
|
+
return this.db.entries();
|
|
423
236
|
}
|
|
424
237
|
}
|
|
425
238
|
|
package/exports/browser/chain.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { c as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, d as arrayify, e as isBytes, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, f as getDefaultExportFromCjs, B as BlockMessage, a as BWMessage, b as BWRequestMessage } from './_polyfill-node.child_process-
|
|
1
|
+
import { c as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, d as arrayify, e as isBytes, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, f as getDefaultExportFromCjs, B as BlockMessage, a as BWMessage, b as BWRequestMessage } from './_polyfill-node.child_process-BsjYmFff.js';
|
|
2
2
|
|
|
3
3
|
if (!globalThis.DEBUG) {
|
|
4
4
|
let DEBUG = [];
|
|
5
5
|
if (globalThis.localStorage) {
|
|
6
6
|
DEBUG = globalThis.localStorage.getItem('DEBUG');
|
|
7
|
-
globalThis.DEBUG = DEBUG
|
|
7
|
+
globalThis.DEBUG = DEBUG.startsWith('[')
|
|
8
|
+
? JSON.parse(DEBUG).split(',')
|
|
9
|
+
: [DEBUG];
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
12
|
|
|
@@ -21,10 +23,12 @@ const debug$5 = (target, text) => {
|
|
|
21
23
|
else console.log('\x1b[34m\x1b[1m%s', `${target}`, '\x1b[0m');
|
|
22
24
|
};
|
|
23
25
|
|
|
26
|
+
const createDebugger = (target) => (text) => debug$5(target, text);
|
|
27
|
+
|
|
24
28
|
if (!globalThis.debug) {
|
|
25
29
|
globalThis.debug = debug$5;
|
|
26
|
-
|
|
27
|
-
globalThis.createDebugger =
|
|
30
|
+
// todo: deprecate
|
|
31
|
+
globalThis.createDebugger = createDebugger;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
const logger$1 = new Logger(version$1);
|
|
@@ -700,12 +704,17 @@ var debug_1 = debug$4;
|
|
|
700
704
|
|
|
701
705
|
// Coercion.
|
|
702
706
|
// Extract anything that could conceivably be a part of a valid semver
|
|
703
|
-
createToken('
|
|
707
|
+
createToken('COERCEPLAIN', `${'(^|[^\\d])' +
|
|
704
708
|
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
705
709
|
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
706
|
-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`
|
|
710
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
711
|
+
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
712
|
+
createToken('COERCEFULL', src[t.COERCEPLAIN] +
|
|
713
|
+
`(?:${src[t.PRERELEASE]})?` +
|
|
714
|
+
`(?:${src[t.BUILD]})?` +
|
|
707
715
|
`(?:$|[^\\d])`);
|
|
708
716
|
createToken('COERCERTL', src[t.COERCE], true);
|
|
717
|
+
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
|
709
718
|
|
|
710
719
|
// Tilde ranges.
|
|
711
720
|
// Meaning is "reasonably at or greater than"
|
|
@@ -1367,35 +1376,43 @@ const coerce$1 = (version, options) => {
|
|
|
1367
1376
|
|
|
1368
1377
|
let match = null;
|
|
1369
1378
|
if (!options.rtl) {
|
|
1370
|
-
match = version.match(re[t.COERCE]);
|
|
1379
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
1371
1380
|
} else {
|
|
1372
1381
|
// Find the right-most coercible string that does not share
|
|
1373
1382
|
// a terminus with a more left-ward coercible string.
|
|
1374
1383
|
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
1384
|
+
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
|
|
1375
1385
|
//
|
|
1376
1386
|
// Walk through the string checking with a /g regexp
|
|
1377
1387
|
// Manually set the index so as to pick up overlapping matches.
|
|
1378
1388
|
// Stop when we get a match that ends at the string end, since no
|
|
1379
1389
|
// coercible string can be more right-ward without the same terminus.
|
|
1390
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
1380
1391
|
let next;
|
|
1381
|
-
while ((next =
|
|
1392
|
+
while ((next = coerceRtlRegex.exec(version)) &&
|
|
1382
1393
|
(!match || match.index + match[0].length !== version.length)
|
|
1383
1394
|
) {
|
|
1384
1395
|
if (!match ||
|
|
1385
1396
|
next.index + next[0].length !== match.index + match[0].length) {
|
|
1386
1397
|
match = next;
|
|
1387
1398
|
}
|
|
1388
|
-
|
|
1399
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
1389
1400
|
}
|
|
1390
1401
|
// leave it in a clean state
|
|
1391
|
-
|
|
1402
|
+
coerceRtlRegex.lastIndex = -1;
|
|
1392
1403
|
}
|
|
1393
1404
|
|
|
1394
1405
|
if (match === null) {
|
|
1395
1406
|
return null
|
|
1396
1407
|
}
|
|
1397
1408
|
|
|
1398
|
-
|
|
1409
|
+
const major = match[2];
|
|
1410
|
+
const minor = match[3] || '0';
|
|
1411
|
+
const patch = match[4] || '0';
|
|
1412
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '';
|
|
1413
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : '';
|
|
1414
|
+
|
|
1415
|
+
return parse$1(`${major}.${minor}.${patch}${prerelease}${build}`, options)
|
|
1399
1416
|
};
|
|
1400
1417
|
var coerce_1 = coerce$1;
|
|
1401
1418
|
|
|
@@ -3805,7 +3822,7 @@ class EasyWorker {
|
|
|
3805
3822
|
this.worker = new Worker(url, {...options});
|
|
3806
3823
|
} else {
|
|
3807
3824
|
return new Promise(async (resolve, reject) => {
|
|
3808
|
-
const {fork} = await import('./_polyfill-node.child_process-
|
|
3825
|
+
const {fork} = await import('./_polyfill-node.child_process-BsjYmFff.js').then(function (n) { return n._; });
|
|
3809
3826
|
this.worker = fork(url, ['easy-worker-child'], options);
|
|
3810
3827
|
resolve(this);
|
|
3811
3828
|
})
|
|
@@ -3906,7 +3923,14 @@ class Machine {
|
|
|
3906
3923
|
case 'transactionLoaded': {
|
|
3907
3924
|
const { from, nonce, hash } = data.result;
|
|
3908
3925
|
(await transactionPoolStore.has(hash)) && (await transactionPoolStore.delete(hash));
|
|
3909
|
-
|
|
3926
|
+
try {
|
|
3927
|
+
const _nonce = await accountsStore.get(from);
|
|
3928
|
+
if (nonce > _nonce)
|
|
3929
|
+
await accountsStore.put(from, nonce);
|
|
3930
|
+
}
|
|
3931
|
+
catch (error) {
|
|
3932
|
+
await accountsStore.put(from, nonce);
|
|
3933
|
+
}
|
|
3910
3934
|
break;
|
|
3911
3935
|
}
|
|
3912
3936
|
case 'contractError': {
|
|
@@ -3955,7 +3979,7 @@ class Machine {
|
|
|
3955
3979
|
pubsub.subscribe('machine.ready', machineReady);
|
|
3956
3980
|
let pre;
|
|
3957
3981
|
try {
|
|
3958
|
-
const importee = await import('./_polyfill-node.url-
|
|
3982
|
+
const importee = await import('./_polyfill-node.url-Bp9XkJZf.js');
|
|
3959
3983
|
const url = importee.default;
|
|
3960
3984
|
if (url)
|
|
3961
3985
|
pre = url.fileURLToPath(new URL('.', import.meta.url));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './node-browser-
|
|
2
|
-
import './_polyfill-node.child_process-
|
|
1
|
+
import { L as LittlePubSub } from './node-browser-DqIklEKv.js';
|
|
2
|
+
import './_polyfill-node.child_process-BsjYmFff.js';
|
|
3
3
|
|
|
4
4
|
class Api {
|
|
5
5
|
_pubsub;
|
|
@@ -206,7 +206,7 @@ class SocketRequestClient {
|
|
|
206
206
|
const init = async () => {
|
|
207
207
|
// @ts-ignore
|
|
208
208
|
if (!globalThis.WebSocket)
|
|
209
|
-
globalThis.WebSocket = (await import('./browser-
|
|
209
|
+
globalThis.WebSocket = (await import('./browser-Ei0BXMlu-C1_XUL9Y.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
210
210
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
211
211
|
client.onmessage = this.onmessage;
|
|
212
212
|
client.onerror = this.onerror;
|
|
@@ -280,7 +280,7 @@ const iceServers = [
|
|
|
280
280
|
credential: 'openrelayproject'
|
|
281
281
|
}
|
|
282
282
|
];
|
|
283
|
-
const SimplePeer = (await import('./index-
|
|
283
|
+
const SimplePeer = (await import('./index-YQrIDBUQ-c7011Ab4.js').then(function (n) { return n.i; })).default;
|
|
284
284
|
class Peer extends SimplePeer {
|
|
285
285
|
peerId;
|
|
286
286
|
channelName;
|
|
@@ -408,7 +408,7 @@ class Client {
|
|
|
408
408
|
async _init() {
|
|
409
409
|
// reconnectJob()
|
|
410
410
|
if (!globalThis.RTCPeerConnection)
|
|
411
|
-
globalThis.wrtc = (await import('./browser-AyxSBUXj-
|
|
411
|
+
globalThis.wrtc = (await import('./browser-AyxSBUXj-pguCHlVu.js').then(function (n) { return n.b; })).default;
|
|
412
412
|
for (const star of this.starsConfig) {
|
|
413
413
|
try {
|
|
414
414
|
const client = new SocketRequestClient(star, this.networkVersion);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-
|
|
2
|
-
import './_polyfill-node.child_process-
|
|
1
|
+
import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-DqIklEKv.js';
|
|
2
|
+
import './_polyfill-node.child_process-BsjYmFff.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @params {String} network
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-
|
|
2
|
-
import './_polyfill-node.child_process-
|
|
1
|
+
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-DqIklEKv.js';
|
|
2
|
+
import './_polyfill-node.child_process-BsjYmFff.js';
|
|
3
3
|
|
|
4
4
|
var browser$2 = {exports: {}};
|
|
5
5
|
|