lib0 0.2.69 → 0.2.71
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/README.md +4 -4
- package/bin/0serve.js +1 -1
- package/broadcastchannel.d.ts.map +1 -1
- package/broadcastchannel.js +9 -1
- package/coverage/tmp/coverage-46556-1679393739170-0.json +1 -0
- package/decoding.js +2 -2
- package/deno.json +4 -1
- package/diff.js +5 -5
- package/diff.test.d.ts.map +1 -1
- package/dist/{broadcastchannel-4e5909e2.cjs → broadcastchannel-1097a8e1.cjs} +11 -3
- package/dist/broadcastchannel-1097a8e1.cjs.map +1 -0
- package/dist/broadcastchannel.cjs +3 -3
- package/dist/broadcastchannel.d.ts.map +1 -1
- package/dist/{buffer-9b566988.cjs → buffer-0021c8c3.cjs} +6 -6
- package/dist/buffer-0021c8c3.cjs.map +1 -0
- package/dist/buffer.cjs +2 -2
- package/dist/component.cjs +1 -1
- package/dist/decoding.cjs +2 -2
- package/dist/{diff-6e7deac6.cjs → diff-6b03292e.cjs} +6 -6
- package/dist/diff-6b03292e.cjs.map +1 -0
- package/dist/diff.cjs +1 -1
- package/dist/diff.test.d.ts.map +1 -1
- package/dist/encoding.cjs +2 -2
- package/dist/{environment-01c0e75b.cjs → environment-7991e0f6.cjs} +1 -1
- package/dist/{environment-01c0e75b.cjs.map → environment-7991e0f6.cjs.map} +1 -1
- package/dist/environment.cjs +1 -1
- package/dist/index.cjs +27 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{logging-641c32f4.cjs → logging.browser.cjs} +38 -193
- package/dist/logging.browser.cjs.map +1 -0
- package/dist/{logging.d.ts → logging.browser.d.ts} +2 -10
- package/dist/logging.browser.d.ts.map +1 -0
- package/dist/logging.common.cjs +99 -0
- package/dist/logging.common.cjs.map +1 -0
- package/dist/logging.common.d.ts +12 -0
- package/dist/logging.common.d.ts.map +1 -0
- package/dist/logging.node.cjs +196 -0
- package/dist/logging.node.cjs.map +1 -0
- package/dist/logging.node.d.ts +14 -0
- package/dist/logging.node.d.ts.map +1 -0
- package/dist/performance.browser.cjs +14 -0
- package/dist/performance.browser.cjs.map +1 -0
- package/dist/performance.browser.d.ts +4 -0
- package/dist/performance.browser.d.ts.map +1 -0
- package/dist/performance.node.cjs +35 -0
- package/dist/performance.node.cjs.map +1 -0
- package/dist/performance.node.d.ts +15 -0
- package/dist/performance.node.d.ts.map +1 -0
- package/dist/{prng-cd2451c9.cjs → prng-98750e19.cjs} +2 -2
- package/dist/{prng-cd2451c9.cjs.map → prng-98750e19.cjs.map} +1 -1
- package/dist/prng.cjs +3 -3
- package/dist/random.cjs +3 -3
- package/dist/random.cjs.map +1 -1
- package/dist/random.d.ts.map +1 -1
- package/dist/storage.cjs +11 -1
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.ts +5 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/testing.cjs +66 -48
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/encoding.js +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/isomorphic.js +2 -0
- package/{logging.d.ts → logging.browser.d.ts} +2 -10
- package/logging.browser.d.ts.map +1 -0
- package/{logging.js → logging.browser.js} +16 -152
- package/logging.common.d.ts +12 -0
- package/logging.common.d.ts.map +1 -0
- package/logging.common.js +76 -0
- package/logging.node.d.ts +14 -0
- package/logging.node.d.ts.map +1 -0
- package/logging.node.js +159 -0
- package/package.json +29 -7
- package/performance.browser.d.ts +4 -0
- package/performance.browser.d.ts.map +1 -0
- package/performance.browser.js +5 -0
- package/performance.node.d.ts +15 -0
- package/performance.node.d.ts.map +1 -0
- package/performance.node.js +21 -0
- package/random.d.ts.map +1 -1
- package/random.js +3 -3
- package/storage.d.ts +5 -0
- package/storage.d.ts.map +1 -1
- package/storage.js +10 -1
- package/test.html +2 -3
- package/test.js +1 -1
- package/testing.d.ts +1 -1
- package/testing.d.ts.map +1 -1
- package/testing.js +2 -3
- package/coverage/tmp/coverage-66490-1679054642499-0.json +0 -1
- package/dist/broadcastchannel-4e5909e2.cjs.map +0 -1
- package/dist/buffer-9b566988.cjs.map +0 -1
- package/dist/diff-6e7deac6.cjs.map +0 -1
- package/dist/logging-641c32f4.cjs.map +0 -1
- package/dist/logging.cjs +0 -49
- package/dist/logging.cjs.map +0 -1
- package/dist/logging.d.ts.map +0 -1
- package/logging.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -277,13 +277,13 @@ Using getAsync & setIfUndefined ensures that the init function is only calle
|
|
|
277
277
|
and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
|
|
278
278
|
which is also used in Protocol Buffers.</p>
|
|
279
279
|
<pre class="prettyprint source lang-js"><code>// encoding step
|
|
280
|
-
const encoder =
|
|
280
|
+
const encoder = encoding.createEncoder()
|
|
281
281
|
encoding.writeVarUint(encoder, 256)
|
|
282
282
|
encoding.writeVarString(encoder, 'Hello world!')
|
|
283
283
|
const buf = encoding.toUint8Array(encoder)
|
|
284
284
|
</code></pre>
|
|
285
285
|
<pre class="prettyprint source lang-js"><code>// decoding step
|
|
286
|
-
const decoder =
|
|
286
|
+
const decoder = decoding.createDecoder(buf)
|
|
287
287
|
decoding.readVarUint(decoder) // => 256
|
|
288
288
|
decoding.readVarString(decoder) // => 'Hello world!'
|
|
289
289
|
decoding.hasContent(decoder) // => false - all data is read
|
|
@@ -479,13 +479,13 @@ can better optimize these function calls.</p></dd>
|
|
|
479
479
|
and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
|
|
480
480
|
which is also used in Protocol Buffers.</p>
|
|
481
481
|
<pre class="prettyprint source lang-js"><code>// encoding step
|
|
482
|
-
const encoder =
|
|
482
|
+
const encoder = encoding.createEncoder()
|
|
483
483
|
encoding.writeVarUint(encoder, 256)
|
|
484
484
|
encoding.writeVarString(encoder, 'Hello world!')
|
|
485
485
|
const buf = encoding.toUint8Array(encoder)
|
|
486
486
|
</code></pre>
|
|
487
487
|
<pre class="prettyprint source lang-js"><code>// decoding step
|
|
488
|
-
const decoder =
|
|
488
|
+
const decoder = decoding.createDecoder(buf)
|
|
489
489
|
decoding.readVarUint(decoder) // => 256
|
|
490
490
|
decoding.readVarString(decoder) // => 'Hello world!'
|
|
491
491
|
decoding.hasContent(decoder) // => false - all data is read
|
package/bin/0serve.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from 'path'
|
|
|
4
4
|
import fs from 'fs'
|
|
5
5
|
import * as env from '../environment.js'
|
|
6
6
|
import * as number from '../number.js'
|
|
7
|
-
import * as logging from '
|
|
7
|
+
import * as logging from 'lib0/logging'
|
|
8
8
|
|
|
9
9
|
const host = env.getParam('--host', 'localhost')
|
|
10
10
|
const port = number.parseInt(env.getParam('--port', '8000'))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcastchannel.d.ts","sourceRoot":"","sources":["broadcastchannel.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broadcastchannel.d.ts","sourceRoot":"","sources":["broadcastchannel.js"],"names":[],"mappings":"AA+FO,gCAHI,MAAM,YACG,GAAG,QAAE,GAAG,KAAE,GAAG,UAAb,GAAG,QAAE,GAAG,KAAE,GAAG,CAKhC;AASM,kCAHI,MAAM,YACG,GAAG,QAAE,GAAG,KAAE,GAAG,WAUhC;AAUM,8BAJI,MAAM,QACN,GAAG,WACH,GAAG,QAMb;;UAvGa,WAAa,GAAG,QAAE,GAAG,KAAE,GAAG,CAAC;QAC3B,GAAG"}
|
package/broadcastchannel.js
CHANGED
|
@@ -44,7 +44,11 @@ class LocalStoragePolyfill {
|
|
|
44
44
|
* @type {null|function({data:ArrayBuffer}):void}
|
|
45
45
|
*/
|
|
46
46
|
this.onmessage = null
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @param {any} e
|
|
49
|
+
*/
|
|
50
|
+
this._onChange = e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') })
|
|
51
|
+
storage.onChange(this._onChange)
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
/**
|
|
@@ -53,6 +57,10 @@ class LocalStoragePolyfill {
|
|
|
53
57
|
postMessage (buf) {
|
|
54
58
|
storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))
|
|
55
59
|
}
|
|
60
|
+
|
|
61
|
+
close () {
|
|
62
|
+
storage.offChange(this._onChange)
|
|
63
|
+
}
|
|
56
64
|
}
|
|
57
65
|
/* c8 ignore stop */
|
|
58
66
|
|