lib0 1.0.0-rc.2 → 1.0.0-rc.21
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 +0 -1315
- package/{types → dist}/buffer.d.ts +2 -10
- package/{types → dist}/delta/delta.d.ts +582 -144
- package/dist/delta/position.d.ts +65 -0
- package/dist/delta/rdt/delta.d.ts +57 -0
- package/dist/delta/rdt/dom.d.ts +102 -0
- package/dist/delta/rdt.d.ts +180 -0
- package/dist/delta/transformer/attr.d.ts +64 -0
- package/dist/delta/transformer/attribution-to-format.d.ts +52 -0
- package/dist/delta/transformer/children.d.ts +69 -0
- package/dist/delta/transformer/conform.d.ts +83 -0
- package/dist/delta/transformer/core.d.ts +189 -0
- package/dist/delta/transformer/full-attributions.d.ts +37 -0
- package/dist/delta/transformer/id.d.ts +2 -0
- package/dist/delta/transformer/inline.d.ts +89 -0
- package/dist/delta/transformer/pipe.d.ts +182 -0
- package/dist/delta/transformer/project.d.ts +223 -0
- package/dist/delta/transformer/rename-attrs.d.ts +75 -0
- package/dist/delta/transformer/rename.d.ts +41 -0
- package/dist/delta/transformer/value.d.ts +92 -0
- package/dist/delta/transformer.d.ts +14 -0
- package/dist/diff/patience.d.ts +25 -0
- package/{types → dist}/environment.d.ts +10 -0
- package/dist/hash/fnv1a.d.ts +11 -0
- package/{types → dist}/schema.d.ts +49 -38
- package/{types → dist}/ts.d.ts +4 -0
- package/dist/webcrypto.d.ts +3 -0
- package/package.json +148 -82
- package/src/bin/0serve.js +11 -3
- package/src/broadcastchannel.js +6 -1
- package/src/buffer.js +35 -25
- package/src/decoding.js +1 -1
- package/src/delta/delta.js +2531 -564
- package/src/delta/position.js +165 -0
- package/src/delta/rdt/delta.js +105 -0
- package/src/delta/rdt/dom.js +307 -0
- package/src/delta/rdt.js +255 -0
- package/src/delta/transformer/attr.js +126 -0
- package/src/delta/transformer/attribution-to-format.js +335 -0
- package/src/delta/transformer/children.js +219 -0
- package/src/delta/transformer/conform.js +401 -0
- package/src/delta/transformer/core.js +323 -0
- package/src/delta/transformer/full-attributions.js +282 -0
- package/src/delta/transformer/id.js +13 -0
- package/src/delta/transformer/inline.js +818 -0
- package/src/delta/transformer/pipe.js +272 -0
- package/src/delta/transformer/project.js +526 -0
- package/src/delta/transformer/rename-attrs.js +152 -0
- package/src/delta/transformer/rename.js +84 -0
- package/src/delta/transformer/value.js +214 -0
- package/src/delta/transformer.js +38 -0
- package/src/diff/patience.js +22 -11
- package/src/dom.js +2 -2
- package/src/encoding.js +1 -1
- package/src/environment.js +15 -0
- package/src/hash/fnv1a.js +82 -0
- package/src/number.js +1 -3
- package/src/performance.node.js +3 -3
- package/src/schema.js +231 -177
- package/src/string.js +3 -5
- package/src/testing.js +1 -1
- package/src/trait/equality.js +1 -1
- package/src/trait/fingerprint.js +1 -1
- package/src/ts.js +11 -0
- package/src/bin/gendocs.js +0 -117
- package/src/component.js +0 -414
- package/src/delta/binding.js +0 -372
- package/src/tree.js +0 -546
- package/types/bin/gendocs.d.ts +0 -3
- package/types/component.d.ts +0 -86
- package/types/delta/binding.d.ts +0 -106
- package/types/diff/patience.d.ts +0 -16
- package/types/tree.d.ts +0 -96
- package/types/webcrypto.d.ts +0 -3
- /package/{types → dist}/array.d.ts +0 -0
- /package/{types → dist}/bin/0ecdsa-generate-keypair.d.ts +0 -0
- /package/{types → dist}/bin/0serve.d.ts +0 -0
- /package/{types → dist}/bin/gentesthtml.d.ts +0 -0
- /package/{types → dist}/binary.d.ts +0 -0
- /package/{types → dist}/broadcastchannel.d.ts +0 -0
- /package/{types → dist}/cache.d.ts +0 -0
- /package/{types → dist}/conditions.d.ts +0 -0
- /package/{types → dist}/crypto/aes-gcm.d.ts +0 -0
- /package/{types → dist}/crypto/common.d.ts +0 -0
- /package/{types → dist}/crypto/ecdsa.d.ts +0 -0
- /package/{types → dist}/crypto/jwt.d.ts +0 -0
- /package/{types → dist}/crypto/rsa-oaep.d.ts +0 -0
- /package/{types → dist}/decoding.d.ts +0 -0
- /package/{types → dist}/diff.d.ts +0 -0
- /package/{types → dist}/dom.d.ts +0 -0
- /package/{types → dist}/encoding.d.ts +0 -0
- /package/{types → dist}/error.d.ts +0 -0
- /package/{types → dist}/eventloop.d.ts +0 -0
- /package/{types → dist}/function.d.ts +0 -0
- /package/{types → dist}/hash/rabin-gf2-polynomial.d.ts +0 -0
- /package/{types → dist}/hash/rabin-uncached.d.ts +0 -0
- /package/{types → dist}/hash/rabin.d.ts +0 -0
- /package/{types → dist}/hash/sha256.d.ts +0 -0
- /package/{types → dist}/hash/sha256.node.d.ts +0 -0
- /package/{types → dist}/indexeddb.d.ts +0 -0
- /package/{types → dist}/indexeddbV2.d.ts +0 -0
- /package/{types → dist}/iterator.d.ts +0 -0
- /package/{types → dist}/json.d.ts +0 -0
- /package/{types → dist}/list.d.ts +0 -0
- /package/{types → dist}/logging.common.d.ts +0 -0
- /package/{types → dist}/logging.d.ts +0 -0
- /package/{types → dist}/logging.node.d.ts +0 -0
- /package/{types → dist}/map.d.ts +0 -0
- /package/{types → dist}/math.d.ts +0 -0
- /package/{types → dist}/metric.d.ts +0 -0
- /package/{types → dist}/mutex.d.ts +0 -0
- /package/{types → dist}/number.d.ts +0 -0
- /package/{types → dist}/object.d.ts +0 -0
- /package/{types → dist}/observable.d.ts +0 -0
- /package/{types → dist}/pair.d.ts +0 -0
- /package/{types → dist}/performance.d.ts +0 -0
- /package/{types → dist}/performance.node.d.ts +0 -0
- /package/{types → dist}/pledge.d.ts +0 -0
- /package/{types → dist}/prng/Mt19937.d.ts +0 -0
- /package/{types → dist}/prng/Xoroshiro128plus.d.ts +0 -0
- /package/{types → dist}/prng/Xorshift32.d.ts +0 -0
- /package/{types → dist}/prng.d.ts +0 -0
- /package/{types → dist}/promise.d.ts +0 -0
- /package/{types → dist}/queue.d.ts +0 -0
- /package/{types → dist}/random.d.ts +0 -0
- /package/{types → dist}/set.d.ts +0 -0
- /package/{types → dist}/sort.d.ts +0 -0
- /package/{types → dist}/statistics.d.ts +0 -0
- /package/{types → dist}/storage.d.ts +0 -0
- /package/{types → dist}/string.d.ts +0 -0
- /package/{types → dist}/symbol.d.ts +0 -0
- /package/{types → dist}/testing.d.ts +0 -0
- /package/{types → dist}/time.d.ts +0 -0
- /package/{types → dist}/trait/equality.d.ts +0 -0
- /package/{types → dist}/trait/fingerprint.d.ts +0 -0
- /package/{types → dist}/trait/traits.d.ts +0 -0
- /package/{types → dist}/url.d.ts +0 -0
- /package/{types → dist}/webcrypto.deno.d.ts +0 -0
- /package/{types → dist}/webcrypto.node.d.ts +0 -0
- /package/{types → dist}/webcrypto.react-native.d.ts +0 -0
- /package/{types → dist}/websocket.d.ts +0 -0
package/src/bin/0serve.js
CHANGED
|
@@ -13,7 +13,7 @@ import * as env from '../environment.js'
|
|
|
13
13
|
import * as number from '../number.js'
|
|
14
14
|
import * as logging from 'lib0/logging'
|
|
15
15
|
|
|
16
|
-
const host = env.getParam('--host', '
|
|
16
|
+
const host = env.getParam('--host', '127.0.0.1')
|
|
17
17
|
const port = number.parseInt(env.getParam('--port', '8000'))
|
|
18
18
|
const paramOpenFile = env.getParam('-o', '')
|
|
19
19
|
const debugBrowser = env.getConf('DEBUG_BROWSER')
|
|
@@ -89,9 +89,17 @@ const server = http.createServer((req, res) => {
|
|
|
89
89
|
server.listen(port, host, () => {
|
|
90
90
|
logging.print(logging.BOLD, logging.ORANGE, `Server is running on http://${host}:${port}`)
|
|
91
91
|
if (paramOpenFile) {
|
|
92
|
-
const
|
|
92
|
+
const url = `http://${host}:${port}/${paramOpenFile}`
|
|
93
93
|
import('child_process').then(cp => {
|
|
94
|
-
|
|
94
|
+
if (debugBrowser) {
|
|
95
|
+
cp.execFile(debugBrowser, [url])
|
|
96
|
+
} else if (process.platform === 'darwin') {
|
|
97
|
+
cp.execFile('open', [url])
|
|
98
|
+
} else if (process.platform === 'win32') {
|
|
99
|
+
cp.execFile('cmd', ['/c', 'start', '', url])
|
|
100
|
+
} else {
|
|
101
|
+
cp.execFile('xdg-open', [url])
|
|
102
|
+
}
|
|
95
103
|
})
|
|
96
104
|
}
|
|
97
105
|
})
|
package/src/broadcastchannel.js
CHANGED
|
@@ -44,6 +44,10 @@ class LocalStoragePolyfill {
|
|
|
44
44
|
* @type {null|function({data:Uint8Array}):void}
|
|
45
45
|
*/
|
|
46
46
|
this.onmessage = null
|
|
47
|
+
/**
|
|
48
|
+
* @type {null|((this: BroadcastChannel, ev: MessageEvent) => any)}
|
|
49
|
+
*/
|
|
50
|
+
this.onmessageerror = null
|
|
47
51
|
/**
|
|
48
52
|
* @param {any} e
|
|
49
53
|
*/
|
|
@@ -79,8 +83,9 @@ const getChannel = room =>
|
|
|
79
83
|
/**
|
|
80
84
|
* @param {{data:ArrayBuffer}} e
|
|
81
85
|
*/
|
|
82
|
-
/* c8 ignore next */
|
|
86
|
+
/* c8 ignore next 3 */
|
|
83
87
|
bc.onmessage = e => subs.forEach(sub => sub(e.data, 'broadcastchannel'))
|
|
88
|
+
bc.onmessageerror = e => console.error('broadcastchannel error', e)
|
|
84
89
|
return {
|
|
85
90
|
bc, subs
|
|
86
91
|
}
|
package/src/buffer.js
CHANGED
|
@@ -34,17 +34,24 @@ export const createUint8ArrayFromArrayBuffer = buffer => new Uint8Array(buffer)
|
|
|
34
34
|
|
|
35
35
|
/* c8 ignore start */
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
* Prefer native `Uint8Array.prototype.toBase64` (TC39 "Uint8Array to/from
|
|
38
|
+
* base64") when available; fall back to the btoa char-code loop for older
|
|
39
|
+
* browsers.
|
|
40
|
+
*
|
|
41
|
+
* @type {(bytes: Uint8Array) => string}
|
|
42
|
+
*/
|
|
43
|
+
const toBase64Browser = /* @__PURE__ */(() =>
|
|
44
|
+
typeof (/** @type {any} */ (Uint8Array.prototype).toBase64) === 'function'
|
|
45
|
+
? bytes => /** @type {any} */ (bytes).toBase64()
|
|
46
|
+
: bytes => {
|
|
47
|
+
let s = ''
|
|
48
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
49
|
+
s += string.fromCharCode(bytes[i])
|
|
50
|
+
}
|
|
51
|
+
// eslint-disable-next-line no-undef
|
|
52
|
+
return btoa(s)
|
|
53
|
+
}
|
|
54
|
+
)()
|
|
48
55
|
/* c8 ignore stop */
|
|
49
56
|
|
|
50
57
|
/**
|
|
@@ -55,18 +62,21 @@ const toBase64Node = bytes => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.
|
|
|
55
62
|
|
|
56
63
|
/* c8 ignore start */
|
|
57
64
|
/**
|
|
58
|
-
* @
|
|
59
|
-
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
65
|
+
* @type {(s: string) => Uint8Array<ArrayBuffer>}
|
|
66
|
+
*/
|
|
67
|
+
const fromBase64Browser = /* @__PURE__ */(() =>
|
|
68
|
+
typeof (/** @type {any} */ (Uint8Array).fromBase64) === 'function'
|
|
69
|
+
? s => /** @type {any} */ (Uint8Array).fromBase64(s)
|
|
70
|
+
: s => {
|
|
71
|
+
// eslint-disable-next-line no-undef
|
|
72
|
+
const a = atob(s)
|
|
73
|
+
const bytes = createUint8ArrayFromLen(a.length)
|
|
74
|
+
for (let i = 0; i < a.length; i++) {
|
|
75
|
+
bytes[i] = a.charCodeAt(i)
|
|
76
|
+
}
|
|
77
|
+
return bytes
|
|
78
|
+
}
|
|
79
|
+
)()
|
|
70
80
|
/* c8 ignore stop */
|
|
71
81
|
|
|
72
82
|
/**
|
|
@@ -78,10 +88,10 @@ const fromBase64Node = s => {
|
|
|
78
88
|
}
|
|
79
89
|
|
|
80
90
|
/* c8 ignore next */
|
|
81
|
-
export const toBase64 = env.isBrowser ? toBase64Browser : toBase64Node
|
|
91
|
+
export const toBase64 = /* @__PURE__ */(() => env.isBrowser ? toBase64Browser : toBase64Node)()
|
|
82
92
|
|
|
83
93
|
/* c8 ignore next */
|
|
84
|
-
export const fromBase64 = env.isBrowser ? fromBase64Browser : fromBase64Node
|
|
94
|
+
export const fromBase64 = /* @__PURE__ */(() => env.isBrowser ? fromBase64Browser : fromBase64Node)()
|
|
85
95
|
|
|
86
96
|
/**
|
|
87
97
|
* Implements base64url - see https://datatracker.ietf.org/doc/html/rfc4648#section-5
|
package/src/decoding.js
CHANGED
|
@@ -387,7 +387,7 @@ export const _readVarStringNative = decoder =>
|
|
|
387
387
|
*
|
|
388
388
|
*/
|
|
389
389
|
/* c8 ignore next */
|
|
390
|
-
export const readVarString = string.utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill
|
|
390
|
+
export const readVarString = /* @__PURE__ */(() => string.utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill)()
|
|
391
391
|
|
|
392
392
|
/**
|
|
393
393
|
* @param {Decoder} decoder
|