univo 0.1.15 → 0.1.17
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/cli.mjs +1 -1
- package/dist/client.mjs +1 -1
- package/dist/index.mjs +15 -7
- package/dist/realtime.mjs +1 -1
- package/dist/shared/{univo.rTUTP64t.mjs → univo.2F7MFHxq.mjs} +5 -40
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { config } from 'dotenv';
|
|
|
5
5
|
import { WebSocket } from 'partysocket';
|
|
6
6
|
import { defineCommand, runMain } from 'citty';
|
|
7
7
|
import { http } from './client.mjs';
|
|
8
|
-
import { c as createLogger, e as version, l as name } from './shared/univo.
|
|
8
|
+
import { c as createLogger, e as version, l as name } from './shared/univo.2F7MFHxq.mjs';
|
|
9
9
|
|
|
10
10
|
const log = createLogger({ quiet: false });
|
|
11
11
|
const dev = defineCommand({
|
package/dist/client.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createException, o as compress, f as getSignature, g as getException } from './shared/univo.
|
|
1
|
+
import { a as createException, o as compress, f as getSignature, g as getException } from './shared/univo.2F7MFHxq.mjs';
|
|
2
2
|
|
|
3
3
|
const MIN_GZIP_SIZE = 1024;
|
|
4
4
|
function http(url, opts = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createLogger, v as verifySignature, d as decompress, a as createException, g as getException, h as hexToNumber, i as isAddressEqual, b as catchException, r as retry, e as version, n as nonNullable, f as getSignature } from './shared/univo.
|
|
1
|
+
import { c as createLogger, v as verifySignature, d as decompress, a as createException, g as getException, h as hexToNumber, i as isAddressEqual, b as catchException, r as retry, e as version, n as nonNullable, f as getSignature } from './shared/univo.2F7MFHxq.mjs';
|
|
2
2
|
|
|
3
3
|
function matchFilter(block, filter) {
|
|
4
4
|
if (!chainValid(block, filter)) return false;
|
|
@@ -223,7 +223,7 @@ function indexer(opts) {
|
|
|
223
223
|
"__lookupGetter__",
|
|
224
224
|
"__lookupSetter__"
|
|
225
225
|
];
|
|
226
|
-
const getWriteEventsProxy = (value,
|
|
226
|
+
const getWriteEventsProxy = (value, callback) => {
|
|
227
227
|
const createProxyHandler = (path) => {
|
|
228
228
|
return {
|
|
229
229
|
get(target, key, receiver) {
|
|
@@ -238,7 +238,7 @@ function indexer(opts) {
|
|
|
238
238
|
if (ignored.some((ignored2) => key.endsWith(ignored2))) {
|
|
239
239
|
return value2;
|
|
240
240
|
}
|
|
241
|
-
|
|
241
|
+
return callback();
|
|
242
242
|
}
|
|
243
243
|
if (typeof value2 === "object" && value2 !== null) {
|
|
244
244
|
return new Proxy(value2, createProxyHandler());
|
|
@@ -255,7 +255,11 @@ function indexer(opts) {
|
|
|
255
255
|
if (relevant_events.length === 0) return { failures: [] };
|
|
256
256
|
if (params.events.length === 0) return { failures: [] };
|
|
257
257
|
const failures = {};
|
|
258
|
-
|
|
258
|
+
let accessed_undefined_key = false;
|
|
259
|
+
const proxied_blocks = getWriteEventsProxy(params.blocks, () => {
|
|
260
|
+
accessed_undefined_key = true;
|
|
261
|
+
throw new Error(IncompleteBlockError);
|
|
262
|
+
});
|
|
259
263
|
const promises = events_grouped_by_storage_map.entries().map(async ([storage, grouped_events]) => {
|
|
260
264
|
const batch = [];
|
|
261
265
|
for (const event2 of grouped_events) {
|
|
@@ -264,6 +268,7 @@ function indexer(opts) {
|
|
|
264
268
|
try {
|
|
265
269
|
if (!event2.filters.some((filter) => matchFilter(block, filter))) continue;
|
|
266
270
|
const events = event2.handler(block);
|
|
271
|
+
if (accessed_undefined_key) throw new Error(IncompleteBlockError);
|
|
267
272
|
for (const event3 of events) batch.push(event3);
|
|
268
273
|
} catch (error) {
|
|
269
274
|
const status = catchException(error, IncompleteBlockError) ? "incomplete_error" : "handler_error";
|
|
@@ -285,7 +290,10 @@ function indexer(opts) {
|
|
|
285
290
|
}
|
|
286
291
|
if (batch.length === 0) return;
|
|
287
292
|
const start = Date.now();
|
|
288
|
-
|
|
293
|
+
try {
|
|
294
|
+
await retry(storage.upsert, [batch], 2);
|
|
295
|
+
if (accessed_undefined_key) throw new Error(IncompleteBlockError);
|
|
296
|
+
} catch (error) {
|
|
289
297
|
const status = catchException(error, IncompleteBlockError) ? "incomplete_error" : "upsert_error";
|
|
290
298
|
if (status === "upsert_error") {
|
|
291
299
|
if (error instanceof Error) {
|
|
@@ -305,7 +313,7 @@ function indexer(opts) {
|
|
|
305
313
|
};
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
|
-
}
|
|
316
|
+
}
|
|
309
317
|
const stop = Date.now() - start;
|
|
310
318
|
for (const event2 of relevant_events) {
|
|
311
319
|
log.debug(`Recorded ${batch.length} ${event2.id} in ${stop}ms`);
|
|
@@ -432,7 +440,7 @@ function indexer(opts) {
|
|
|
432
440
|
const handler = async (req) => {
|
|
433
441
|
let body_buffer;
|
|
434
442
|
try {
|
|
435
|
-
body_buffer =
|
|
443
|
+
body_buffer = await req.arrayBuffer();
|
|
436
444
|
} catch {
|
|
437
445
|
return Response.json(
|
|
438
446
|
{ jsonrpc: "2.0", id: null, error: { code: 0, message: "Invalid request body" } },
|
package/dist/realtime.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import WS from 'ws';
|
|
2
2
|
import { WebSocket } from 'partysocket';
|
|
3
3
|
import { http } from './client.mjs';
|
|
4
|
-
import { c as createLogger, r as retry, h as hexToNumber, j as raise, m as mutex, k as assert } from './shared/univo.
|
|
4
|
+
import { c as createLogger, r as retry, h as hexToNumber, j as raise, m as mutex, k as assert } from './shared/univo.2F7MFHxq.mjs';
|
|
5
5
|
|
|
6
6
|
function createSocket(url, opts) {
|
|
7
7
|
const ws = new WebSocket(url, [], { WebSocket: WS });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const name = "univo";
|
|
2
|
-
const version = "0.1.
|
|
2
|
+
const version = "0.1.17";
|
|
3
3
|
|
|
4
4
|
function createException(message) {
|
|
5
5
|
return `univo:${message}`;
|
|
@@ -108,47 +108,12 @@ function nonNullable(value) {
|
|
|
108
108
|
return value !== null && value !== void 0;
|
|
109
109
|
}
|
|
110
110
|
async function compress(input) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const writer = stream.writable.getWriter();
|
|
114
|
-
writer.write(encoded);
|
|
115
|
-
writer.close();
|
|
116
|
-
const chunks = [];
|
|
117
|
-
const reader = stream.readable.getReader();
|
|
118
|
-
while (true) {
|
|
119
|
-
const { done, value } = await reader.read();
|
|
120
|
-
if (done) break;
|
|
121
|
-
chunks.push(value);
|
|
122
|
-
}
|
|
123
|
-
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
124
|
-
const result = new Uint8Array(totalLength);
|
|
125
|
-
let offset = 0;
|
|
126
|
-
for (const chunk of chunks) {
|
|
127
|
-
result.set(chunk, offset);
|
|
128
|
-
offset += chunk.length;
|
|
129
|
-
}
|
|
130
|
-
return result;
|
|
111
|
+
const compressed = new Blob([input]).stream().pipeThrough(new CompressionStream("gzip"));
|
|
112
|
+
return new Response(compressed).arrayBuffer();
|
|
131
113
|
}
|
|
132
114
|
async function decompress(input) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
writer.write(input);
|
|
136
|
-
writer.close();
|
|
137
|
-
const chunks = [];
|
|
138
|
-
const reader = stream.readable.getReader();
|
|
139
|
-
while (true) {
|
|
140
|
-
const { done, value } = await reader.read();
|
|
141
|
-
if (done) break;
|
|
142
|
-
chunks.push(value);
|
|
143
|
-
}
|
|
144
|
-
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
145
|
-
const result = new Uint8Array(totalLength);
|
|
146
|
-
let offset = 0;
|
|
147
|
-
for (const chunk of chunks) {
|
|
148
|
-
result.set(chunk, offset);
|
|
149
|
-
offset += chunk.length;
|
|
150
|
-
}
|
|
151
|
-
return new TextDecoder().decode(result);
|
|
115
|
+
const decompressed = new Blob([input]).stream().pipeThrough(new DecompressionStream("gzip"));
|
|
116
|
+
return new Response(decompressed).text();
|
|
152
117
|
}
|
|
153
118
|
|
|
154
119
|
export { createException as a, catchException as b, createLogger as c, decompress as d, version as e, getSignature as f, getException as g, hexToNumber as h, isAddressEqual as i, raise as j, assert as k, name as l, mutex as m, nonNullable as n, compress as o, retry as r, verifySignature as v };
|