implemented frontend including separate message system; started to implement backend
This commit is contained in:
24
yjs-poll/node_modules/lib0/.github/workflows/node.js.yml
generated
vendored
Normal file
24
yjs-poll/node_modules/lib0/.github/workflows/node.js.yml
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||
|
||||
name: Testing Lib0
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x, 18.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
18
yjs-poll/node_modules/lib0/.jsdoc.json
generated
vendored
Normal file
18
yjs-poll/node_modules/lib0/.jsdoc.json
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"plugins": [
|
||||
"plugins/markdown",
|
||||
"jsdoc-plugin-typescript"
|
||||
],
|
||||
"recurseDepth": 10,
|
||||
"source": {
|
||||
"excludePattern": "/\\.test\\.js/"
|
||||
},
|
||||
"sourceType": "module",
|
||||
"tags": {
|
||||
"allowUnknownTags": true,
|
||||
"dictionaries": ["jsdoc", "closure"]
|
||||
},
|
||||
"typescript": {
|
||||
"moduleRoot": "./"
|
||||
}
|
||||
}
|
||||
17
yjs-poll/node_modules/lib0/.vscode/launch.json
generated
vendored
Normal file
17
yjs-poll/node_modules/lib0/.vscode/launch.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Gen Docs",
|
||||
"program": "${workspaceFolder}/bin/gendocs.js",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
21
yjs-poll/node_modules/lib0/LICENSE
generated
vendored
Normal file
21
yjs-poll/node_modules/lib0/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1414
yjs-poll/node_modules/lib0/README.md
generated
vendored
Normal file
1414
yjs-poll/node_modules/lib0/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
30
yjs-poll/node_modules/lib0/array.d.ts
generated
vendored
Normal file
30
yjs-poll/node_modules/lib0/array.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export function last<L>(arr: ArrayLike<L>): L;
|
||||
export function create<C>(): Array<C>;
|
||||
export function copy<D>(a: Array<D>): Array<D>;
|
||||
export function appendTo<M>(dest: Array<M>, src: Array<M>): void;
|
||||
/**
|
||||
* Transforms something array-like to an actual Array.
|
||||
*
|
||||
* @function
|
||||
* @template T
|
||||
* @param {ArrayLike<T>|Iterable<T>} arraylike
|
||||
* @return {T}
|
||||
*/
|
||||
export const from: {
|
||||
<T_1>(arrayLike: ArrayLike<T_1>): T_1[];
|
||||
<T_1, U>(arrayLike: ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
|
||||
<T_1>(iterable: Iterable<T_1> | ArrayLike<T_1>): T_1[];
|
||||
<T_1, U>(iterable: Iterable<T_1> | ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
|
||||
};
|
||||
export function every<ARR extends ArrayLike<any>>(arr: ARR, f: ARR extends ArrayLike<infer S> ? ((value: S, index: number, arr: ARR) => boolean) : any): boolean;
|
||||
export function some<ARR extends ArrayLike<any>>(arr: ARR, f: ARR extends ArrayLike<infer S> ? ((value: S, index: number, arr: ARR) => boolean) : never): boolean;
|
||||
export function equalFlat<ELEM>(a: ArrayLike<ELEM>, b: ArrayLike<ELEM>): boolean;
|
||||
export function flatten<ELEM>(arr: Array<Array<ELEM>>): Array<ELEM>;
|
||||
export function unfold<T_1>(len: number, f: (arg0: number, arg1: Array<T_1>) => T_1): Array<T_1>;
|
||||
export function fold<T_1, RESULT>(arr: Array<T_1>, seed: RESULT, folder: (arg0: RESULT, arg1: T_1, arg2: number) => RESULT): RESULT;
|
||||
export const isArray: (arg: any) => arg is any[];
|
||||
export function unique<T_1>(arr: Array<T_1>): Array<T_1>;
|
||||
export function uniqueBy<T_1, M>(arr: ArrayLike<T_1>, mapper: (arg0: T_1) => M): Array<T_1>;
|
||||
export function map<ARR extends ArrayLike<any>, MAPPER extends (arg0: ARR extends ArrayLike<infer T_1> ? T_1 : never, arg1: number, arg2: ARR) => any>(arr: ARR, mapper: MAPPER): Array<MAPPER extends (...args: any[]) => infer M ? M : never>;
|
||||
export function bubblesortItem<T_1>(arr: Array<T_1>, i: number, compareFn: (a: T_1, b: T_1) => number): number;
|
||||
//# sourceMappingURL=array.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/array.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/array.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["array.js"],"names":[],"mappings":"AAeO,qBAJM,CAAC,OACH,SAAS,CAAC,CAAC,CAAC,GACX,CAAC,CAEiC;AAMvC,uBAHM,CAAC,KACF,KAAK,CAAC,CAAC,CAAC,CAEoC;AAOjD,qBAJM,CAAC,KACH,KAAK,CAAC,CAAC,CAAC,GACP,KAAK,CAAC,CAAC,CAAC,CAEwC;AASrD,yBAJM,CAAC,QACH,KAAK,CAAC,CAAC,CAAC,OACR,KAAK,CAAC,CAAC,CAAC,QAMlB;AAED;;;;;;;GAOG;AACH;;;;;EAA8B;AAYvB,sBANuB,GAAG,SAAnB,SAAS,CAAC,GAAG,CAAE,OAElB,GAAG,KACH,GAAG,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAC,CAAC,EAAE,KAAK,EAAC,MAAM,EAAE,GAAG,EAAC,GAAG,KAAK,OAAO,CAAC,GAAG,GAAG,GACnF,OAAO,CASlB;AAYM,qBANuB,GAAG,SAAnB,SAAS,CAAC,GAAG,CAAE,OAElB,GAAG,KACH,GAAG,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAC,CAAC,EAAE,KAAK,EAAC,MAAM,EAAE,GAAG,EAAC,GAAG,KAAK,OAAO,CAAC,GAAG,KAAK,GACrF,OAAO,CASlB;AASM,0BANM,IAAI,KAEN,SAAS,CAAC,IAAI,CAAC,KACf,SAAS,CAAC,IAAI,CAAC,GACd,OAAO,CAEqF;AAOjG,wBAJM,IAAI,OACN,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GACjB,KAAK,CAAC,IAAI,CAAC,CAEgF;AAQhG,iCAJI,MAAM,KACN,CAAS,IAAM,EAAN,MAAM,EAAE,IAAQ,EAAR,KAAK,CAAC,GAAC,CAAC,KAAE,GAAC,GAC3B,KAAK,CAAC,GAAC,CAAC,CAQnB;AASM,0BALM,MAAM,OACR,KAAK,CAAC,GAAC,CAAC,QACR,MAAM,UACN,CAAS,IAAM,EAAN,MAAM,EAAE,IAAC,EAAD,GAAC,EAAE,IAAM,EAAN,MAAM,KAAE,MAAM,UAEsB;AAEnE,iDAAoC;AAO7B,iCAHI,KAAK,CAAC,GAAC,CAAC,GACP,KAAK,CAAC,GAAC,CAAC,CAE4B;AASzC,8BALM,CAAC,OACH,SAAS,CAAC,GAAC,CAAC,UACZ,CAAS,IAAC,EAAD,GAAC,KAAE,CAAC,GACZ,KAAK,CAAC,GAAC,CAAC,CAoBnB;AASM,oBANuB,GAAG,SAAnB,SAAS,CAAC,GAAG,CAAE,EACwD,MAAM,SAA9E,CAAU,IAA0C,EAA1C,GAAG,SAAS,SAAS,CAAC,MAAM,GAAC,CAAC,GAAG,GAAC,GAAG,KAAK,EAAE,IAAM,EAAN,MAAM,EAAE,IAAG,EAAH,GAAG,KAAE,GAAI,OACzE,GAAG,UACH,MAAM,GACL,KAAK,CAAC,MAAM,SAAS,IAAS,IAAM,EAAH,GAAG,EAAA,KAAG,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAWtE;AAoBM,yCAJI,KAAK,CAAC,GAAC,CAAC,KACR,MAAM,aACN,CAAC,CAAC,EAAC,GAAC,EAAC,CAAC,EAAC,GAAC,KAAK,MAAM,UAkB7B"}
|
||||
219
yjs-poll/node_modules/lib0/array.js
generated
vendored
Normal file
219
yjs-poll/node_modules/lib0/array.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* Utility module to work with Arrays.
|
||||
*
|
||||
* @module array
|
||||
*/
|
||||
|
||||
import * as set from './set.js'
|
||||
|
||||
/**
|
||||
* Return the last element of an array. The element must exist
|
||||
*
|
||||
* @template L
|
||||
* @param {ArrayLike<L>} arr
|
||||
* @return {L}
|
||||
*/
|
||||
export const last = arr => arr[arr.length - 1]
|
||||
|
||||
/**
|
||||
* @template C
|
||||
* @return {Array<C>}
|
||||
*/
|
||||
export const create = () => /** @type {Array<C>} */ ([])
|
||||
|
||||
/**
|
||||
* @template D
|
||||
* @param {Array<D>} a
|
||||
* @return {Array<D>}
|
||||
*/
|
||||
export const copy = a => /** @type {Array<D>} */ (a.slice())
|
||||
|
||||
/**
|
||||
* Append elements from src to dest
|
||||
*
|
||||
* @template M
|
||||
* @param {Array<M>} dest
|
||||
* @param {Array<M>} src
|
||||
*/
|
||||
export const appendTo = (dest, src) => {
|
||||
for (let i = 0; i < src.length; i++) {
|
||||
dest.push(src[i])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms something array-like to an actual Array.
|
||||
*
|
||||
* @function
|
||||
* @template T
|
||||
* @param {ArrayLike<T>|Iterable<T>} arraylike
|
||||
* @return {T}
|
||||
*/
|
||||
export const from = Array.from
|
||||
|
||||
/**
|
||||
* True iff condition holds on every element in the Array.
|
||||
*
|
||||
* @function
|
||||
* @template {ArrayLike<any>} ARR
|
||||
*
|
||||
* @param {ARR} arr
|
||||
* @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : any} f
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const every = (arr, f) => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (!f(arr[i], i, arr)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* True iff condition holds on some element in the Array.
|
||||
*
|
||||
* @function
|
||||
* @template {ArrayLike<any>} ARR
|
||||
*
|
||||
* @param {ARR} arr
|
||||
* @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : never} f
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const some = (arr, f) => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (f(arr[i], i, arr)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @template ELEM
|
||||
*
|
||||
* @param {ArrayLike<ELEM>} a
|
||||
* @param {ArrayLike<ELEM>} b
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const equalFlat = (a, b) => a.length === b.length && every(a, (item, index) => item === b[index])
|
||||
|
||||
/**
|
||||
* @template ELEM
|
||||
* @param {Array<Array<ELEM>>} arr
|
||||
* @return {Array<ELEM>}
|
||||
*/
|
||||
export const flatten = arr => fold(arr, /** @type {Array<ELEM>} */ ([]), (acc, val) => acc.concat(val))
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {number} len
|
||||
* @param {function(number, Array<T>):T} f
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
export const unfold = (len, f) => {
|
||||
const array = new Array(len)
|
||||
for (let i = 0; i < len; i++) {
|
||||
array[i] = f(i, array)
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template RESULT
|
||||
* @param {Array<T>} arr
|
||||
* @param {RESULT} seed
|
||||
* @param {function(RESULT, T, number):RESULT} folder
|
||||
*/
|
||||
export const fold = (arr, seed, folder) => arr.reduce(folder, seed)
|
||||
|
||||
export const isArray = Array.isArray
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Array<T>} arr
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
export const unique = arr => from(set.from(arr))
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template M
|
||||
* @param {ArrayLike<T>} arr
|
||||
* @param {function(T):M} mapper
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
export const uniqueBy = (arr, mapper) => {
|
||||
/**
|
||||
* @type {Set<M>}
|
||||
*/
|
||||
const happened = set.create()
|
||||
/**
|
||||
* @type {Array<T>}
|
||||
*/
|
||||
const result = []
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const el = arr[i]
|
||||
const mapped = mapper(el)
|
||||
if (!happened.has(mapped)) {
|
||||
happened.add(mapped)
|
||||
result.push(el)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {ArrayLike<any>} ARR
|
||||
* @template {function(ARR extends ArrayLike<infer T> ? T : never, number, ARR):any} MAPPER
|
||||
* @param {ARR} arr
|
||||
* @param {MAPPER} mapper
|
||||
* @return {Array<MAPPER extends function(...any): infer M ? M : never>}
|
||||
*/
|
||||
export const map = (arr, mapper) => {
|
||||
/**
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
const res = Array(arr.length)
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
res[i] = mapper(/** @type {any} */ (arr[i]), i, /** @type {any} */ (arr))
|
||||
}
|
||||
return /** @type {any} */ (res)
|
||||
}
|
||||
|
||||
/**
|
||||
* This function bubble-sorts a single item to the correct position. The sort happens in-place and
|
||||
* might be useful to ensure that a single item is at the correct position in an otherwise sorted
|
||||
* array.
|
||||
*
|
||||
* @example
|
||||
* const arr = [3, 2, 5]
|
||||
* arr.sort((a, b) => a - b)
|
||||
* arr // => [2, 3, 5]
|
||||
* arr.splice(1, 0, 7)
|
||||
* array.bubbleSortItem(arr, 1, (a, b) => a - b)
|
||||
* arr // => [2, 3, 5, 7]
|
||||
*
|
||||
* @template T
|
||||
* @param {Array<T>} arr
|
||||
* @param {number} i
|
||||
* @param {(a:T,b:T) => number} compareFn
|
||||
*/
|
||||
export const bubblesortItem = (arr, i, compareFn) => {
|
||||
const n = arr[i]
|
||||
let j = i
|
||||
// try to sort to the right
|
||||
while (j + 1 < arr.length && compareFn(n, arr[j + 1]) > 0) {
|
||||
arr[j] = arr[j + 1]
|
||||
arr[++j] = n
|
||||
}
|
||||
if (i === j && j > 0) { // no change yet
|
||||
// sort to the left
|
||||
while (j > 0 && compareFn(arr[j - 1], n) > 0) {
|
||||
arr[j] = arr[j - 1]
|
||||
arr[--j] = n
|
||||
}
|
||||
}
|
||||
return j
|
||||
}
|
||||
13
yjs-poll/node_modules/lib0/array.test.d.ts
generated
vendored
Normal file
13
yjs-poll/node_modules/lib0/array.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export function testIsarrayPerformance(_tc: t.TestCase): void;
|
||||
export function testAppend(_tc: t.TestCase): void;
|
||||
export function testBasic(_tc: t.TestCase): void;
|
||||
export function testflatten(_tc: t.TestCase): void;
|
||||
export function testFolding(_tc: t.TestCase): void;
|
||||
export function testEvery(_tc: t.TestCase): void;
|
||||
export function testIsArray(_tc: t.TestCase): void;
|
||||
export function testUnique(_tc: t.TestCase): void;
|
||||
export function testBubblesortItemEdgeCases(tc: t.TestCase): void;
|
||||
export function testRepeatBubblesortItem(tc: t.TestCase): void;
|
||||
export function testRepeatBubblesort(tc: t.TestCase): void;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=array.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/array.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/array.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"array.test.d.ts","sourceRoot":"","sources":["array.test.js"],"names":[],"mappings":"AAOO,4CAFI,CAAC,CAAC,QAAQ,QAkCpB;AAKM,gCAFI,CAAC,CAAC,QAAQ,QAMpB;AAKM,+BAFI,CAAC,CAAC,QAAQ,QAMpB;AAKM,iCAFI,CAAC,CAAC,QAAQ,QAKpB;AAKM,iCAFI,CAAC,CAAC,QAAQ,QAkBpB;AAKM,+BAFI,CAAC,CAAC,QAAQ,QAQpB;AAKM,iCAFI,CAAC,CAAC,QAAQ,QASpB;AAKM,gCAFI,CAAC,CAAC,QAAQ,QAOpB;AAKM,gDAFI,CAAC,CAAC,QAAQ,QAOpB;AAKM,6CAFI,CAAC,CAAC,QAAQ,QAWpB;AAKM,yCAFI,CAAC,CAAC,QAAQ,QASpB;mBA1JkB,cAAc"}
|
||||
3
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=0ecdsa-generate-keypair.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"0ecdsa-generate-keypair.d.ts","sourceRoot":"","sources":["0ecdsa-generate-keypair.js"],"names":[],"mappings":""}
|
||||
15
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.js
generated
vendored
Normal file
15
yjs-poll/node_modules/lib0/bin/0ecdsa-generate-keypair.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
import * as ecdsa from 'lib0/crypto/ecdsa'
|
||||
import * as json from 'lib0/json'
|
||||
import * as env from 'lib0/environment'
|
||||
|
||||
const prefix = env.getConf('name')
|
||||
|
||||
const keypair = await ecdsa.generateKeyPair({ extractable: true })
|
||||
const privateJwk = json.stringify(await ecdsa.exportKeyJwk(keypair.privateKey))
|
||||
const publicJwk = json.stringify(await ecdsa.exportKeyJwk(keypair.publicKey))
|
||||
|
||||
console.log(`
|
||||
${prefix ? prefix.toUpperCase() + '_' : ''}PUBLIC_KEY=${publicJwk}
|
||||
${prefix ? prefix.toUpperCase() + '_' : ''}PRIVATE_KEY=${privateJwk}
|
||||
`)
|
||||
3
yjs-poll/node_modules/lib0/bin/0serve.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/0serve.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=0serve.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/0serve.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/0serve.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"0serve.d.ts","sourceRoot":"","sources":["0serve.js"],"names":[],"mappings":""}
|
||||
97
yjs-poll/node_modules/lib0/bin/0serve.js
generated
vendored
Normal file
97
yjs-poll/node_modules/lib0/bin/0serve.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Simple http server implementation.
|
||||
* Optionally, you may set `DEBUG_BROWSER` environment variable to use a different browser to debug
|
||||
* web apps.
|
||||
*/
|
||||
|
||||
import * as http from 'http'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import * as env from '../environment.js'
|
||||
import * as number from '../number.js'
|
||||
import * as logging from 'lib0/logging'
|
||||
|
||||
const host = env.getParam('--host', 'localhost')
|
||||
const port = number.parseInt(env.getParam('--port', '8000'))
|
||||
const paramOpenFile = env.getParam('-o', '')
|
||||
const debugBrowser = env.getConf('DEBUG_BROWSER')
|
||||
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const types = {
|
||||
html: 'text/html',
|
||||
css: 'text/css',
|
||||
js: 'application/javascript',
|
||||
mjs: 'application/javascript',
|
||||
png: 'image/png',
|
||||
jpg: 'image/jpeg',
|
||||
jpeg: 'image/jpeg',
|
||||
gif: 'image/gif',
|
||||
json: 'application/json',
|
||||
xml: 'application/xml',
|
||||
wasm: 'application/wasm'
|
||||
}
|
||||
|
||||
const root = path.normalize(path.resolve('./'))
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const url = (req.url || '/index.html').split('?')[0]
|
||||
logging.print(logging.ORANGE, logging.BOLD, req.method || '', ' ', logging.GREY, logging.UNBOLD, url)
|
||||
const extension = path.extname(url).slice(1)
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const type = (extension && types[extension]) || types.html
|
||||
const supportedExtension = Boolean(type)
|
||||
if (!supportedExtension) {
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end('404: File not found')
|
||||
return
|
||||
}
|
||||
let fileName = url
|
||||
if (url === '/') fileName = 'index.html'
|
||||
else if (!extension) {
|
||||
try {
|
||||
fs.accessSync(path.join(root, url + '.html'), fs.constants.F_OK)
|
||||
fileName = url + '.html'
|
||||
} catch (e) {
|
||||
fileName = path.join(url, 'index.html')
|
||||
}
|
||||
}
|
||||
|
||||
const filePath = path.join(root, fileName)
|
||||
const isPathUnderRoot = path
|
||||
.normalize(path.resolve(filePath))
|
||||
.startsWith(root)
|
||||
|
||||
if (!isPathUnderRoot) {
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end('404: File not found')
|
||||
logging.print(logging.RED, logging.BOLD, 'Not Found: ', logging.GREY, logging.UNBOLD, url)
|
||||
return
|
||||
}
|
||||
|
||||
fs.readFile(filePath, (err, data) => {
|
||||
if (err) {
|
||||
logging.print(logging.RED, logging.BOLD, 'Cannot read file: ', logging.GREY, logging.UNBOLD, url)
|
||||
res.writeHead(404, { 'Content-Type': 'text/html' })
|
||||
res.end('404: File not found')
|
||||
} else {
|
||||
res.writeHead(200, { 'Content-Type': type })
|
||||
res.end(data)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(port, host, () => {
|
||||
logging.print(logging.BOLD, logging.ORANGE, `Server is running on http://${host}:${port}`)
|
||||
if (paramOpenFile) {
|
||||
const start = debugBrowser || (process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open')
|
||||
import('child_process').then(cp => {
|
||||
cp.exec(`${start} http://${host}:${port}/${paramOpenFile}`)
|
||||
})
|
||||
}
|
||||
})
|
||||
3
yjs-poll/node_modules/lib0/bin/gendocs.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/gendocs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=gendocs.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/gendocs.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/gendocs.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gendocs.d.ts","sourceRoot":"","sources":["gendocs.js"],"names":[],"mappings":""}
|
||||
117
yjs-poll/node_modules/lib0/bin/gendocs.js
generated
vendored
Normal file
117
yjs-poll/node_modules/lib0/bin/gendocs.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env node
|
||||
// @ts-ignore
|
||||
import jsdoc from 'jsdoc-api'
|
||||
import * as fs from 'fs'
|
||||
|
||||
const firstTagContentRegex = /<\w>([^<]+)<\/\w>([^]*)/
|
||||
const jsdocReturnRegex = /\* @return {(.*)}/
|
||||
const jsdocTypeRegex = /\* @type {(.*)}/
|
||||
|
||||
const files = fs.readdirSync('./').filter(file => /(?<!(test|config))\.js$/.test(file))
|
||||
|
||||
const _ltregex = /</g
|
||||
const _rtregex = />/g
|
||||
/**
|
||||
* @param {string} s
|
||||
*/
|
||||
const toSafeHtml = s => s.replace(_ltregex, '<').replace(_rtregex, '>')
|
||||
|
||||
const READMEcontent = fs.readFileSync('./README.md', 'utf8')
|
||||
|
||||
jsdoc.explain({
|
||||
files,
|
||||
configure: '.jsdoc.json'
|
||||
}).then(/** @param {Array<any>} json */ json => {
|
||||
const strBuilder = []
|
||||
/**
|
||||
* @type {Object<string, { items: Array<any>, name: string, description: string }>}
|
||||
*/
|
||||
const modules = {}
|
||||
json.forEach(item => {
|
||||
if (item.meta && item.meta.filename) {
|
||||
const mod = modules[item.meta.filename] || (modules[item.meta.filename] = { items: [], name: item.meta.filename.slice(0, -3), description: '' })
|
||||
if (item.kind === 'module') {
|
||||
mod.name = item.name
|
||||
mod.description = item.description || ''
|
||||
} else {
|
||||
mod.items.push(item)
|
||||
}
|
||||
}
|
||||
})
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const classDescriptions = {}
|
||||
for (const fileName in modules) {
|
||||
const mod = modules[fileName]
|
||||
const items = mod.items
|
||||
const desc = firstTagContentRegex.exec(mod.description)
|
||||
const descHead = desc ? desc[1] : ''
|
||||
const descRest = desc ? desc[2] : ''
|
||||
strBuilder.push(`<details><summary><b>[lib0/${mod.name}]</b> ${descHead}</summary>`)
|
||||
strBuilder.push(`<pre>import * as ${mod.name} from 'lib0/${fileName.slice(0, -3)}'</pre>`)
|
||||
if (descRest.length > 0) {
|
||||
strBuilder.push(descRest)
|
||||
}
|
||||
strBuilder.push('<dl>')
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i]
|
||||
if (!item.ignore && item.scope !== 'inner' && item.name[0] !== '_' && item.longname.indexOf('~') < 0) {
|
||||
// strBuilder.push(JSON.stringify(item)) // output json for debugging
|
||||
switch (item.kind) {
|
||||
case 'class': {
|
||||
if (item.params == null) {
|
||||
classDescriptions[item.longname] = item.classdesc
|
||||
break
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
case 'constant': {
|
||||
if (item.params == null && item.returns == null) {
|
||||
const typeEval = jsdocTypeRegex.exec(item.comment)
|
||||
strBuilder.push(`<b><code>${item.longname.slice(7)}${typeEval ? (': ' + toSafeHtml(typeEval[1])) : ''}</code></b><br>`)
|
||||
if (item.description) {
|
||||
strBuilder.push(`<dd>${item.description}</dd>`)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
case 'function': {
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
const getOriginalParamTypeDecl = name => {
|
||||
const regval = new RegExp('@param {(.*)} \\[?' + name + '\\]?[^\\w]*').exec(item.comment)
|
||||
return regval ? regval[1] : null
|
||||
}
|
||||
if (item.params == null && item.returns == null) {
|
||||
break
|
||||
}
|
||||
const paramVal = (item.params || []).map(/** @param {any} ret */ ret => `${ret.name}: ${getOriginalParamTypeDecl(ret.name) || ret.type.names.join('|')}`).join(', ')
|
||||
const evalReturnRegex = jsdocReturnRegex.exec(item.comment)
|
||||
const returnVal = evalReturnRegex ? `: ${evalReturnRegex[1]}` : (item.returns ? item.returns.map(/** @param {any} r */ r => r.type.names.join('|')).join('|') : '')
|
||||
strBuilder.push(`<b><code>${item.kind === 'class' ? 'new ' : ''}${item.longname.slice(7)}(${toSafeHtml(paramVal)})${toSafeHtml(returnVal)}</code></b><br>`)
|
||||
const desc = item.description || item.classdesc || classDescriptions[item.longname] || null
|
||||
if (desc) {
|
||||
strBuilder.push(`<dd>${desc}</dd>`)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'member': {
|
||||
if (item.type) {
|
||||
strBuilder.push(`<b><code>${item.longname.slice(7)}: ${toSafeHtml(/** @type {RegExpExecArray} */ (jsdocTypeRegex.exec(item.comment))[1])}</code></b><br>`)
|
||||
if (item.description) {
|
||||
strBuilder.push(`<dd>${item.description}</dd>`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
strBuilder.push('</dl>')
|
||||
strBuilder.push('</details>')
|
||||
}
|
||||
const replaceReadme = READMEcontent.replace(/<details>[^]*<\/details>/, strBuilder.join('\n'))
|
||||
fs.writeFileSync('./README.md', replaceReadme)
|
||||
})
|
||||
3
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
//# sourceMappingURL=gentesthtml.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/bin/gentesthtml.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"gentesthtml.d.ts","sourceRoot":"","sources":["gentesthtml.js"],"names":[],"mappings":""}
|
||||
89
yjs-poll/node_modules/lib0/bin/gentesthtml.js
generated
vendored
Normal file
89
yjs-poll/node_modules/lib0/bin/gentesthtml.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env node
|
||||
import * as fs from 'fs'
|
||||
import * as object from '../object.js'
|
||||
import * as env from '../environment.js'
|
||||
|
||||
const script = env.getParam('--script', './test.js')
|
||||
const includeDeps = env.getParam('--include-dependencies', '').split(',').filter(d => d.length)
|
||||
const customImportsPath = env.getParam('--custom-imports', '')
|
||||
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const exports = {}
|
||||
/**
|
||||
* @type {Object<string,Object<string,string>>}
|
||||
*/
|
||||
const scopes = {}
|
||||
|
||||
/**
|
||||
* @param {any} v
|
||||
* @param {string} k
|
||||
* @param {string} pkgName
|
||||
* @param {string} pathPrefix
|
||||
* @param {Object<string,string>} importMap
|
||||
*/
|
||||
const extractModMap = (v, k, pkgName, pathPrefix, importMap) => {
|
||||
if (k[0] !== '.') return
|
||||
if (typeof v === 'object') {
|
||||
extractModMap(v.browser || v.import || v.module || v.default, k, pkgName, pathPrefix, importMap)
|
||||
} else if (v && v[0] === '.') {
|
||||
importMap[pkgName + k.slice(1)] = pathPrefix + v.slice(1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
*/
|
||||
const _maybeAddRelPrefix = s => (s[0] !== '.' ? './' : '') + s
|
||||
|
||||
/**
|
||||
* @param {any} pkgJson
|
||||
* @param {string} pathPrefix
|
||||
* @param {Object<string,string>} importMap
|
||||
*/
|
||||
const readPkg = (pkgJson, pathPrefix, importMap) => {
|
||||
if (pkgJson.exports == null && pkgJson.main != null) {
|
||||
importMap[pkgJson.name] = pathPrefix + _maybeAddRelPrefix(pkgJson.main).slice(1)
|
||||
}
|
||||
object.forEach(pkgJson.exports, (v, k) => extractModMap(v, k, pkgJson.name, pathPrefix, importMap))
|
||||
object.forEach(pkgJson.dependencies, (_v, depName) => {
|
||||
const nextImportMap = pathPrefix === '.' ? exports : (scopes[pathPrefix + '/'] || (scopes[pathPrefix + '/'] = {}))
|
||||
const prefix = `./node_modules/${depName}`
|
||||
const depPkgJson = JSON.parse(fs.readFileSync(prefix + '/package.json', { encoding: 'utf8' }))
|
||||
readPkg(depPkgJson, prefix, nextImportMap)
|
||||
})
|
||||
}
|
||||
|
||||
const rootPkgJson = JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' }))
|
||||
readPkg(rootPkgJson, '.', exports)
|
||||
includeDeps.forEach(depName => {
|
||||
const prefix = `./node_modules/${depName}`
|
||||
const depPkgJson = JSON.parse(fs.readFileSync(`${prefix}/package.json`, { encoding: 'utf8' }))
|
||||
readPkg(depPkgJson, prefix, exports)
|
||||
})
|
||||
|
||||
const customImports = {}
|
||||
if (customImportsPath !== '') {
|
||||
object.assign(customImports, JSON.parse(fs.readFileSync(customImportsPath, { encoding: 'utf8' })))
|
||||
}
|
||||
|
||||
const testHtml = `
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Testing ${rootPkgJson.name}</title>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": ${JSON.stringify(object.assign({}, exports, customImports), null, 2)},
|
||||
"scopes": ${JSON.stringify(scopes, null, 2)}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="${script}"></script>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
||||
console.log(testHtml)
|
||||
87
yjs-poll/node_modules/lib0/binary.d.ts
generated
vendored
Normal file
87
yjs-poll/node_modules/lib0/binary.d.ts
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Binary data constants.
|
||||
*
|
||||
* @module binary
|
||||
*/
|
||||
/**
|
||||
* n-th bit activated.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
export const BIT1: number;
|
||||
export const BIT2: 2;
|
||||
export const BIT3: 4;
|
||||
export const BIT4: 8;
|
||||
export const BIT5: 16;
|
||||
export const BIT6: 32;
|
||||
export const BIT7: 64;
|
||||
export const BIT8: 128;
|
||||
export const BIT9: 256;
|
||||
export const BIT10: 512;
|
||||
export const BIT11: 1024;
|
||||
export const BIT12: 2048;
|
||||
export const BIT13: 4096;
|
||||
export const BIT14: 8192;
|
||||
export const BIT15: 16384;
|
||||
export const BIT16: 32768;
|
||||
export const BIT17: 65536;
|
||||
export const BIT18: number;
|
||||
export const BIT19: number;
|
||||
export const BIT20: number;
|
||||
export const BIT21: number;
|
||||
export const BIT22: number;
|
||||
export const BIT23: number;
|
||||
export const BIT24: number;
|
||||
export const BIT25: number;
|
||||
export const BIT26: number;
|
||||
export const BIT27: number;
|
||||
export const BIT28: number;
|
||||
export const BIT29: number;
|
||||
export const BIT30: number;
|
||||
export const BIT31: number;
|
||||
export const BIT32: number;
|
||||
/**
|
||||
* First n bits activated.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
export const BITS0: number;
|
||||
export const BITS1: 1;
|
||||
export const BITS2: 3;
|
||||
export const BITS3: 7;
|
||||
export const BITS4: 15;
|
||||
export const BITS5: 31;
|
||||
export const BITS6: 63;
|
||||
export const BITS7: 127;
|
||||
export const BITS8: 255;
|
||||
export const BITS9: 511;
|
||||
export const BITS10: 1023;
|
||||
export const BITS11: 2047;
|
||||
export const BITS12: 4095;
|
||||
export const BITS13: 8191;
|
||||
export const BITS14: 16383;
|
||||
export const BITS15: 32767;
|
||||
export const BITS16: 65535;
|
||||
export const BITS17: number;
|
||||
export const BITS18: number;
|
||||
export const BITS19: number;
|
||||
export const BITS20: number;
|
||||
export const BITS21: number;
|
||||
export const BITS22: number;
|
||||
export const BITS23: number;
|
||||
export const BITS24: number;
|
||||
export const BITS25: number;
|
||||
export const BITS26: number;
|
||||
export const BITS27: number;
|
||||
export const BITS28: number;
|
||||
export const BITS29: number;
|
||||
export const BITS30: number;
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const BITS31: number;
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const BITS32: number;
|
||||
//# sourceMappingURL=binary.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/binary.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/binary.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"binary.d.ts","sourceRoot":"","sources":["binary.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;;;GAIG;AACH,mBAFU,MAAM,CAEK;AACrB,mBAAoB,CAAC,CAAA;AACrB,mBAAoB,CAAC,CAAA;AACrB,mBAAoB,CAAC,CAAA;AACrB,mBAAoB,EAAE,CAAA;AACtB,mBAAoB,EAAE,CAAA;AACtB,mBAAoB,EAAE,CAAA;AACtB,mBAAoB,GAAG,CAAA;AACvB,mBAAoB,GAAG,CAAA;AACvB,oBAAqB,GAAG,CAAA;AACxB,oBAAqB,IAAI,CAAA;AACzB,oBAAqB,IAAI,CAAA;AACzB,oBAAqB,IAAI,CAAA;AACzB,oBAAqB,IAAI,CAAA;AACzB,oBAAqB,KAAK,CAAA;AAC1B,oBAAqB,KAAK,CAAA;AAC1B,oBAAqB,KAAK,CAAA;AAC1B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAC5B,2BAA4B;AAE5B;;;;GAIG;AACH,oBAFU,MAAM,CAEM;AACtB,oBAAqB,CAAC,CAAA;AACtB,oBAAqB,CAAC,CAAA;AACtB,oBAAqB,CAAC,CAAA;AACtB,oBAAqB,EAAE,CAAA;AACvB,oBAAqB,EAAE,CAAA;AACvB,oBAAqB,EAAE,CAAA;AACvB,oBAAqB,GAAG,CAAA;AACxB,oBAAqB,GAAG,CAAA;AACxB,oBAAqB,GAAG,CAAA;AACxB,qBAAsB,IAAI,CAAA;AAC1B,qBAAsB,IAAI,CAAA;AAC1B,qBAAsB,IAAI,CAAA;AAC1B,qBAAsB,IAAI,CAAA;AAC1B,qBAAsB,KAAK,CAAA;AAC3B,qBAAsB,KAAK,CAAA;AAC3B,qBAAsB,KAAK,CAAA;AAC3B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B,4BAA+B;AAC/B;;GAEG;AACH,qBAFU,MAAM,CAEgB;AAChC;;GAEG;AACH,qBAFU,MAAM,CAEgB"}
|
||||
90
yjs-poll/node_modules/lib0/binary.js
generated
vendored
Normal file
90
yjs-poll/node_modules/lib0/binary.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* Binary data constants.
|
||||
*
|
||||
* @module binary
|
||||
*/
|
||||
|
||||
/**
|
||||
* n-th bit activated.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
export const BIT1 = 1
|
||||
export const BIT2 = 2
|
||||
export const BIT3 = 4
|
||||
export const BIT4 = 8
|
||||
export const BIT5 = 16
|
||||
export const BIT6 = 32
|
||||
export const BIT7 = 64
|
||||
export const BIT8 = 128
|
||||
export const BIT9 = 256
|
||||
export const BIT10 = 512
|
||||
export const BIT11 = 1024
|
||||
export const BIT12 = 2048
|
||||
export const BIT13 = 4096
|
||||
export const BIT14 = 8192
|
||||
export const BIT15 = 16384
|
||||
export const BIT16 = 32768
|
||||
export const BIT17 = 65536
|
||||
export const BIT18 = 1 << 17
|
||||
export const BIT19 = 1 << 18
|
||||
export const BIT20 = 1 << 19
|
||||
export const BIT21 = 1 << 20
|
||||
export const BIT22 = 1 << 21
|
||||
export const BIT23 = 1 << 22
|
||||
export const BIT24 = 1 << 23
|
||||
export const BIT25 = 1 << 24
|
||||
export const BIT26 = 1 << 25
|
||||
export const BIT27 = 1 << 26
|
||||
export const BIT28 = 1 << 27
|
||||
export const BIT29 = 1 << 28
|
||||
export const BIT30 = 1 << 29
|
||||
export const BIT31 = 1 << 30
|
||||
export const BIT32 = 1 << 31
|
||||
|
||||
/**
|
||||
* First n bits activated.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
export const BITS0 = 0
|
||||
export const BITS1 = 1
|
||||
export const BITS2 = 3
|
||||
export const BITS3 = 7
|
||||
export const BITS4 = 15
|
||||
export const BITS5 = 31
|
||||
export const BITS6 = 63
|
||||
export const BITS7 = 127
|
||||
export const BITS8 = 255
|
||||
export const BITS9 = 511
|
||||
export const BITS10 = 1023
|
||||
export const BITS11 = 2047
|
||||
export const BITS12 = 4095
|
||||
export const BITS13 = 8191
|
||||
export const BITS14 = 16383
|
||||
export const BITS15 = 32767
|
||||
export const BITS16 = 65535
|
||||
export const BITS17 = BIT18 - 1
|
||||
export const BITS18 = BIT19 - 1
|
||||
export const BITS19 = BIT20 - 1
|
||||
export const BITS20 = BIT21 - 1
|
||||
export const BITS21 = BIT22 - 1
|
||||
export const BITS22 = BIT23 - 1
|
||||
export const BITS23 = BIT24 - 1
|
||||
export const BITS24 = BIT25 - 1
|
||||
export const BITS25 = BIT26 - 1
|
||||
export const BITS26 = BIT27 - 1
|
||||
export const BITS27 = BIT28 - 1
|
||||
export const BITS28 = BIT29 - 1
|
||||
export const BITS29 = BIT30 - 1
|
||||
export const BITS30 = BIT31 - 1
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const BITS31 = 0x7FFFFFFF
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const BITS32 = 0xFFFFFFFF
|
||||
4
yjs-poll/node_modules/lib0/binary.test.d.ts
generated
vendored
Normal file
4
yjs-poll/node_modules/lib0/binary.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export function testBitx(tc: t.TestCase): void;
|
||||
export function testBitsx(tc: t.TestCase): void;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=binary.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/binary.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/binary.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"binary.test.d.ts","sourceRoot":"","sources":["binary.test.js"],"names":[],"mappings":"AAMO,6BAFI,CAAC,CAAC,QAAQ,QAOpB;AAKM,8BAFI,CAAC,CAAC,QAAQ,QAWpB;mBAxBkB,cAAc"}
|
||||
8
yjs-poll/node_modules/lib0/broadcastchannel.d.ts
generated
vendored
Normal file
8
yjs-poll/node_modules/lib0/broadcastchannel.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export function subscribe(room: string, f: (arg0: any, arg1: any) => any): (arg0: any, arg1: any) => any;
|
||||
export function unsubscribe(room: string, f: (arg0: any, arg1: any) => any): boolean;
|
||||
export function publish(room: string, data: any, origin?: any): void;
|
||||
export type Channel = {
|
||||
subs: Set<(arg0: any, arg1: any) => any>;
|
||||
bc: any;
|
||||
};
|
||||
//# sourceMappingURL=broadcastchannel.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/broadcastchannel.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/broadcastchannel.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"broadcastchannel.d.ts","sourceRoot":"","sources":["broadcastchannel.js"],"names":[],"mappings":"AA+FO,gCAHI,MAAM,KACN,CAAS,IAAG,EAAH,GAAG,EAAE,IAAG,EAAH,GAAG,KAAE,GAAG,UAAb,GAAG,QAAE,GAAG,KAAE,GAAG,CAKhC;AASM,kCAHI,MAAM,KACN,CAAS,IAAG,EAAH,GAAG,EAAE,IAAG,EAAH,GAAG,KAAE,GAAG,WAUhC;AAUM,8BAJI,MAAM,QACN,GAAG,WACH,GAAG,QAMb;;UAvGa,GAAG,CAAC,CAAS,IAAG,EAAH,GAAG,EAAE,IAAG,EAAH,GAAG,KAAE,GAAG,CAAC;QAC3B,GAAG"}
|
||||
130
yjs-poll/node_modules/lib0/broadcastchannel.js
generated
vendored
Normal file
130
yjs-poll/node_modules/lib0/broadcastchannel.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.
|
||||
*
|
||||
* ```js
|
||||
* // In browser window A:
|
||||
* broadcastchannel.subscribe('my events', data => console.log(data))
|
||||
* broadcastchannel.publish('my events', 'Hello world!') // => A: 'Hello world!' fires synchronously in same tab
|
||||
*
|
||||
* // In browser window B:
|
||||
* broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from tab B'
|
||||
* ```
|
||||
*
|
||||
* @module broadcastchannel
|
||||
*/
|
||||
|
||||
// @todo before next major: use Uint8Array instead as buffer object
|
||||
|
||||
import * as map from './map.js'
|
||||
import * as set from './set.js'
|
||||
import * as buffer from './buffer.js'
|
||||
import * as storage from './storage.js'
|
||||
|
||||
/**
|
||||
* @typedef {Object} Channel
|
||||
* @property {Set<function(any, any):any>} Channel.subs
|
||||
* @property {any} Channel.bc
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Map<string, Channel>}
|
||||
*/
|
||||
const channels = new Map()
|
||||
|
||||
/* c8 ignore start */
|
||||
class LocalStoragePolyfill {
|
||||
/**
|
||||
* @param {string} room
|
||||
*/
|
||||
constructor (room) {
|
||||
this.room = room
|
||||
/**
|
||||
* @type {null|function({data:Uint8Array}):void}
|
||||
*/
|
||||
this.onmessage = null
|
||||
/**
|
||||
* @param {any} e
|
||||
*/
|
||||
this._onChange = e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') })
|
||||
storage.onChange(this._onChange)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer} buf
|
||||
*/
|
||||
postMessage (buf) {
|
||||
storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))
|
||||
}
|
||||
|
||||
close () {
|
||||
storage.offChange(this._onChange)
|
||||
}
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
// Use BroadcastChannel or Polyfill
|
||||
/* c8 ignore next */
|
||||
const BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel
|
||||
|
||||
/**
|
||||
* @param {string} room
|
||||
* @return {Channel}
|
||||
*/
|
||||
const getChannel = room =>
|
||||
map.setIfUndefined(channels, room, () => {
|
||||
const subs = set.create()
|
||||
const bc = new BC(room)
|
||||
/**
|
||||
* @param {{data:ArrayBuffer}} e
|
||||
*/
|
||||
/* c8 ignore next */
|
||||
bc.onmessage = e => subs.forEach(sub => sub(e.data, 'broadcastchannel'))
|
||||
return {
|
||||
bc, subs
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Subscribe to global `publish` events.
|
||||
*
|
||||
* @function
|
||||
* @param {string} room
|
||||
* @param {function(any, any):any} f
|
||||
*/
|
||||
export const subscribe = (room, f) => {
|
||||
getChannel(room).subs.add(f)
|
||||
return f
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from `publish` global events.
|
||||
*
|
||||
* @function
|
||||
* @param {string} room
|
||||
* @param {function(any, any):any} f
|
||||
*/
|
||||
export const unsubscribe = (room, f) => {
|
||||
const channel = getChannel(room)
|
||||
const unsubscribed = channel.subs.delete(f)
|
||||
if (unsubscribed && channel.subs.size === 0) {
|
||||
channel.bc.close()
|
||||
channels.delete(room)
|
||||
}
|
||||
return unsubscribed
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish data to all subscribers (including subscribers on this tab)
|
||||
*
|
||||
* @function
|
||||
* @param {string} room
|
||||
* @param {any} data
|
||||
* @param {any} [origin]
|
||||
*/
|
||||
export const publish = (room, data, origin = null) => {
|
||||
const c = getChannel(room)
|
||||
c.bc.postMessage(data)
|
||||
c.subs.forEach(sub => sub(data, origin))
|
||||
}
|
||||
3
yjs-poll/node_modules/lib0/broadcastchannel.test.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/broadcastchannel.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function testBroadcastChannel(tc: t.TestCase): void;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=broadcastchannel.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/broadcastchannel.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/broadcastchannel.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"broadcastchannel.test.d.ts","sourceRoot":"","sources":["broadcastchannel.test.js"],"names":[],"mappings":"AAMO,yCAFI,CAAC,CAAC,QAAQ,QAkBpB;mBAtBkB,cAAc"}
|
||||
22
yjs-poll/node_modules/lib0/buffer.d.ts
generated
vendored
Normal file
22
yjs-poll/node_modules/lib0/buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
export function createUint8ArrayFromLen(len: number): Uint8Array<ArrayBuffer>;
|
||||
export function createUint8ArrayViewFromArrayBuffer(buffer: ArrayBuffer, byteOffset: number, length: number): Uint8Array<ArrayBuffer>;
|
||||
export function createUint8ArrayFromArrayBuffer(buffer: ArrayBuffer): Uint8Array<ArrayBuffer>;
|
||||
/**
|
||||
* @param {Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
export function toBase64(bytes: Uint8Array): string;
|
||||
/**
|
||||
* @param {string} s
|
||||
* @return {Uint8Array<ArrayBuffer>}
|
||||
*/
|
||||
export function fromBase64(s: string): Uint8Array<ArrayBuffer>;
|
||||
export function toBase64UrlEncoded(buf: Uint8Array): string;
|
||||
export function fromBase64UrlEncoded(base64: string): Uint8Array<ArrayBuffer>;
|
||||
export function toHexString(buf: Uint8Array): string;
|
||||
export function fromHexString(hex: string): Uint8Array<ArrayBuffer>;
|
||||
export function copyUint8Array(uint8Array: Uint8Array): Uint8Array;
|
||||
export function encodeAny(data: any): Uint8Array;
|
||||
export function decodeAny(buf: Uint8Array): any;
|
||||
export function shiftNBitsLeft(bs: Uint8Array, N: number): Uint8Array<ArrayBufferLike>;
|
||||
//# sourceMappingURL=buffer.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/buffer.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/buffer.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["buffer.js"],"names":[],"mappings":"AAgBO,6CAFI,MAAM,2BAEgD;AAS1D,4DAJI,WAAW,cACX,MAAM,UACN,MAAM,2BAE4G;AAOtH,wDAFI,WAAW,2BAEyD;AAG/E;;;GAGG;AACH,gCAHW,UAAU,GACT,MAAM,CASjB;AAUD;;;GAGG;AACH,8BAHW,MAAM,GACL,UAAU,CAAC,WAAW,CAAC,CAUlC;AAqBM,wCAFI,UAAU,UAE+F;AAK7G,6CAFI,MAAM,2BAEyF;AAOnG,iCAFI,UAAU,UAE0E;AAOxF,mCAFI,MAAM,2BAShB;AAQM,2CAHI,UAAU,GACT,UAAU,CAMrB;AASM,gCAHI,GAAG,GACF,UAAU,CAGwC;AAQvD,+BAHI,UAAU,GACT,GAAG,CAE8D;AAQtE,mCAHI,UAAU,KACV,MAAM,+BAWhB"}
|
||||
163
yjs-poll/node_modules/lib0/buffer.js
generated
vendored
Normal file
163
yjs-poll/node_modules/lib0/buffer.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* Utility functions to work with buffers (Uint8Array).
|
||||
*
|
||||
* @module buffer
|
||||
*/
|
||||
|
||||
import * as string from './string.js'
|
||||
import * as env from './environment.js'
|
||||
import * as array from './array.js'
|
||||
import * as math from './math.js'
|
||||
import * as encoding from './encoding.js'
|
||||
import * as decoding from './decoding.js'
|
||||
|
||||
/**
|
||||
* @param {number} len
|
||||
*/
|
||||
export const createUint8ArrayFromLen = len => new Uint8Array(len)
|
||||
|
||||
/**
|
||||
* Create Uint8Array with initial content from buffer
|
||||
*
|
||||
* @param {ArrayBuffer} buffer
|
||||
* @param {number} byteOffset
|
||||
* @param {number} length
|
||||
*/
|
||||
export const createUint8ArrayViewFromArrayBuffer = (buffer, byteOffset, length) => new Uint8Array(buffer, byteOffset, length)
|
||||
|
||||
/**
|
||||
* Create Uint8Array with initial content from buffer
|
||||
*
|
||||
* @param {ArrayBuffer} buffer
|
||||
*/
|
||||
export const createUint8ArrayFromArrayBuffer = buffer => new Uint8Array(buffer)
|
||||
|
||||
/* c8 ignore start */
|
||||
/**
|
||||
* @param {Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
const toBase64Browser = bytes => {
|
||||
let s = ''
|
||||
for (let i = 0; i < bytes.byteLength; i++) {
|
||||
s += string.fromCharCode(bytes[i])
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
return btoa(s)
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
/**
|
||||
* @param {Uint8Array} bytes
|
||||
* @return {string}
|
||||
*/
|
||||
const toBase64Node = bytes => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64')
|
||||
|
||||
/* c8 ignore start */
|
||||
/**
|
||||
* @param {string} s
|
||||
* @return {Uint8Array<ArrayBuffer>}
|
||||
*/
|
||||
const fromBase64Browser = s => {
|
||||
// eslint-disable-next-line no-undef
|
||||
const a = atob(s)
|
||||
const bytes = createUint8ArrayFromLen(a.length)
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
bytes[i] = a.charCodeAt(i)
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
*/
|
||||
const fromBase64Node = s => {
|
||||
const buf = Buffer.from(s, 'base64')
|
||||
return createUint8ArrayViewFromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength)
|
||||
}
|
||||
|
||||
/* c8 ignore next */
|
||||
export const toBase64 = env.isBrowser ? toBase64Browser : toBase64Node
|
||||
|
||||
/* c8 ignore next */
|
||||
export const fromBase64 = env.isBrowser ? fromBase64Browser : fromBase64Node
|
||||
|
||||
/**
|
||||
* Implements base64url - see https://datatracker.ietf.org/doc/html/rfc4648#section-5
|
||||
* @param {Uint8Array} buf
|
||||
*/
|
||||
export const toBase64UrlEncoded = buf => toBase64(buf).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '')
|
||||
|
||||
/**
|
||||
* @param {string} base64
|
||||
*/
|
||||
export const fromBase64UrlEncoded = base64 => fromBase64(base64.replaceAll('-', '+').replaceAll('_', '/'))
|
||||
|
||||
/**
|
||||
* Base64 is always a more efficient choice. This exists for utility purposes only.
|
||||
*
|
||||
* @param {Uint8Array} buf
|
||||
*/
|
||||
export const toHexString = buf => array.map(buf, b => b.toString(16).padStart(2, '0')).join('')
|
||||
|
||||
/**
|
||||
* Note: This function expects that the hex doesn't start with 0x..
|
||||
*
|
||||
* @param {string} hex
|
||||
*/
|
||||
export const fromHexString = hex => {
|
||||
const hlen = hex.length
|
||||
const buf = new Uint8Array(math.ceil(hlen / 2))
|
||||
for (let i = 0; i < hlen; i += 2) {
|
||||
buf[buf.length - i / 2 - 1] = Number.parseInt(hex.slice(hlen - i - 2, hlen - i), 16)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the content of an Uint8Array view to a new ArrayBuffer.
|
||||
*
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
export const copyUint8Array = uint8Array => {
|
||||
const newBuf = createUint8ArrayFromLen(uint8Array.byteLength)
|
||||
newBuf.set(uint8Array)
|
||||
return newBuf
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode anything as a UInt8Array. It's a pun on typescripts's `any` type.
|
||||
* See encoding.writeAny for more information.
|
||||
*
|
||||
* @param {any} data
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
export const encodeAny = data =>
|
||||
encoding.encode(encoder => encoding.writeAny(encoder, data))
|
||||
|
||||
/**
|
||||
* Decode an any-encoded value.
|
||||
*
|
||||
* @param {Uint8Array} buf
|
||||
* @return {any}
|
||||
*/
|
||||
export const decodeAny = buf => decoding.readAny(decoding.createDecoder(buf))
|
||||
|
||||
/**
|
||||
* Shift Byte Array {N} bits to the left. Does not expand byte array.
|
||||
*
|
||||
* @param {Uint8Array} bs
|
||||
* @param {number} N should be in the range of [0-7]
|
||||
*/
|
||||
export const shiftNBitsLeft = (bs, N) => {
|
||||
if (N === 0) return bs
|
||||
bs = new Uint8Array(bs)
|
||||
bs[0] <<= N
|
||||
for (let i = 1; i < bs.length; i++) {
|
||||
bs[i - 1] |= bs[i] >>> (8 - N)
|
||||
bs[i] <<= N
|
||||
}
|
||||
return bs
|
||||
}
|
||||
6
yjs-poll/node_modules/lib0/buffer.test.d.ts
generated
vendored
Normal file
6
yjs-poll/node_modules/lib0/buffer.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export function testRepeatBase64urlEncoding(tc: t.TestCase): void;
|
||||
export function testRepeatBase64Encoding(tc: t.TestCase): void;
|
||||
export function testRepeatHexEncoding(tc: t.TestCase): void;
|
||||
export function testAnyEncoding(_tc: t.TestCase): void;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=buffer.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/buffer.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/buffer.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"buffer.test.d.ts","sourceRoot":"","sources":["buffer.test.js"],"names":[],"mappings":"AA2BO,gDAFI,CAAC,CAAC,QAAQ,QAIpB;AAKM,6CAFI,CAAC,CAAC,QAAQ,QAIpB;AAKM,0CAFI,CAAC,CAAC,QAAQ,QAIpB;AAKM,qCAFI,CAAC,CAAC,QAAQ,QAMpB;mBApDkB,cAAc"}
|
||||
52
yjs-poll/node_modules/lib0/cache.d.ts
generated
vendored
Normal file
52
yjs-poll/node_modules/lib0/cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @template K, V
|
||||
*/
|
||||
export class Cache<K, V> {
|
||||
/**
|
||||
* @param {number} timeout
|
||||
*/
|
||||
constructor(timeout: number);
|
||||
timeout: number;
|
||||
/**
|
||||
* @type list.List<Entry<K, V>>
|
||||
*/
|
||||
_q: list.List<Entry<K, V>>;
|
||||
/**
|
||||
* @type {Map<K, Entry<K, V>>}
|
||||
*/
|
||||
_map: Map<K, Entry<K, V>>;
|
||||
}
|
||||
export function removeStale<K, V>(cache: Cache<K, V>): number;
|
||||
export function set<K, V>(cache: Cache<K, V>, key: K, value: V): void;
|
||||
export function get<K, V>(cache: Cache<K, V>, key: K): V | undefined;
|
||||
export function refreshTimeout<K, V>(cache: Cache<K, V>, key: K): void;
|
||||
export function getAsync<K, V>(cache: Cache<K, V>, key: K): V | Promise<V> | undefined;
|
||||
export function remove<K, V>(cache: Cache<K, V>, key: K): NonNullable<V> | undefined;
|
||||
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>, removeNull?: boolean): Promise<V> | V;
|
||||
export function create(timeout: number): Cache<any, any>;
|
||||
import * as list from './list.js';
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @implements {list.ListNode}
|
||||
*/
|
||||
declare class Entry<K, V> implements list.ListNode {
|
||||
/**
|
||||
* @param {K} key
|
||||
* @param {V | Promise<V>} val
|
||||
*/
|
||||
constructor(key: K, val: V | Promise<V>);
|
||||
/**
|
||||
* @type {this | null}
|
||||
*/
|
||||
prev: this | null;
|
||||
/**
|
||||
* @type {this | null}
|
||||
*/
|
||||
next: this | null;
|
||||
created: number;
|
||||
val: V | Promise<V>;
|
||||
key: K;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=cache.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/cache.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/cache.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["cache.js"],"names":[],"mappings":"AAqCA;;GAEG;AACH,mBAFa,CAAC,EAAE,CAAC;IAGf;;OAEG;IACH,qBAFW,MAAM,EAYhB;IATC,gBAAsB;IACtB;;OAEG;IACH,IAFS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAER;IACvB;;OAEG;IACH,MAFU,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAEL;CAE3B;AAQM,4BALM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GACV,MAAM,CAUjB;AASM,oBANM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OACX,CAAC,SACD,CAAC,QAgBX;AAwBM,oBANM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OACX,CAAC,GACA,CAAC,GAAG,SAAS,CAKxB;AAQM,+BALM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OACX,CAAC,QAWX;AAYM,yBANM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OACX,CAAC,GACA,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAKrC;AAQM,uBALM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OACX,CAAC,8BASX;AAWM,+BARM,CAAC,EAAE,CAAC,SAEN,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OACX,CAAC,QACD,MAAW,OAAO,CAAC,CAAC,CAAC,eACrB,OAAO,GACN,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAuBzB;AAKM,gCAFI,MAAM,mBAEkC;sBArM7B,WAAW;AAIjC;;;;GAIG;AACH,oBAJa,CAAC,EAAE,CAAC,aAED,IAAI,CAAC,QAAQ;IAG3B;;;OAGG;IACH,iBAHW,CAAC,OACD,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAcxB;IAXC;;OAEG;IACH,MAFU,IAAI,GAAG,IAAI,CAEL;IAChB;;OAEG;IACH,MAFU,IAAI,GAAG,IAAI,CAEL;IAChB,gBAAiC;IACjC,oBAAc;IACd,OAAc;CAEjB"}
|
||||
206
yjs-poll/node_modules/lib0/cache.js
generated
vendored
Normal file
206
yjs-poll/node_modules/lib0/cache.js
generated
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* An implementation of a map which has keys that expire.
|
||||
*
|
||||
* @module cache
|
||||
*/
|
||||
|
||||
import * as list from './list.js'
|
||||
import * as map from './map.js'
|
||||
import * as time from './time.js'
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @implements {list.ListNode}
|
||||
*/
|
||||
class Entry {
|
||||
/**
|
||||
* @param {K} key
|
||||
* @param {V | Promise<V>} val
|
||||
*/
|
||||
constructor (key, val) {
|
||||
/**
|
||||
* @type {this | null}
|
||||
*/
|
||||
this.prev = null
|
||||
/**
|
||||
* @type {this | null}
|
||||
*/
|
||||
this.next = null
|
||||
this.created = time.getUnixTime()
|
||||
this.val = val
|
||||
this.key = key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*/
|
||||
export class Cache {
|
||||
/**
|
||||
* @param {number} timeout
|
||||
*/
|
||||
constructor (timeout) {
|
||||
this.timeout = timeout
|
||||
/**
|
||||
* @type list.List<Entry<K, V>>
|
||||
*/
|
||||
this._q = list.create()
|
||||
/**
|
||||
* @type {Map<K, Entry<K, V>>}
|
||||
*/
|
||||
this._map = map.create()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @return {number} Returns the current timestamp
|
||||
*/
|
||||
export const removeStale = cache => {
|
||||
const now = time.getUnixTime()
|
||||
const q = cache._q
|
||||
while (q.start && now - q.start.created > cache.timeout) {
|
||||
cache._map.delete(q.start.key)
|
||||
list.popFront(q)
|
||||
}
|
||||
return now
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
* @param {V} value
|
||||
*/
|
||||
export const set = (cache, key, value) => {
|
||||
const now = removeStale(cache)
|
||||
const q = cache._q
|
||||
const n = cache._map.get(key)
|
||||
if (n) {
|
||||
list.removeNode(q, n)
|
||||
list.pushEnd(q, n)
|
||||
n.created = now
|
||||
n.val = value
|
||||
} else {
|
||||
const node = new Entry(key, value)
|
||||
list.pushEnd(q, node)
|
||||
cache._map.set(key, node)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
* @return {Entry<K, V> | undefined}
|
||||
*/
|
||||
const getNode = (cache, key) => {
|
||||
removeStale(cache)
|
||||
const n = cache._map.get(key)
|
||||
if (n) {
|
||||
return n
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
* @return {V | undefined}
|
||||
*/
|
||||
export const get = (cache, key) => {
|
||||
const n = getNode(cache, key)
|
||||
return n && !(n.val instanceof Promise) ? n.val : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
*/
|
||||
export const refreshTimeout = (cache, key) => {
|
||||
const now = time.getUnixTime()
|
||||
const q = cache._q
|
||||
const n = cache._map.get(key)
|
||||
if (n) {
|
||||
list.removeNode(q, n)
|
||||
list.pushEnd(q, n)
|
||||
n.created = now
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Works well in conjunktion with setIfUndefined which has an async init function.
|
||||
* Using getAsync & setIfUndefined ensures that the init function is only called once.
|
||||
*
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
* @return {V | Promise<V> | undefined}
|
||||
*/
|
||||
export const getAsync = (cache, key) => {
|
||||
const n = getNode(cache, key)
|
||||
return n ? n.val : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
*/
|
||||
export const remove = (cache, key) => {
|
||||
const n = cache._map.get(key)
|
||||
if (n) {
|
||||
list.removeNode(cache._q, n)
|
||||
cache._map.delete(key)
|
||||
return n.val && !(n.val instanceof Promise) ? n.val : undefined
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template K, V
|
||||
*
|
||||
* @param {Cache<K, V>} cache
|
||||
* @param {K} key
|
||||
* @param {function():Promise<V>} init
|
||||
* @param {boolean} removeNull Optional argument that automatically removes values that resolve to null/undefined from the cache.
|
||||
* @return {Promise<V> | V}
|
||||
*/
|
||||
export const setIfUndefined = (cache, key, init, removeNull = false) => {
|
||||
removeStale(cache)
|
||||
const q = cache._q
|
||||
const n = cache._map.get(key)
|
||||
if (n) {
|
||||
return n.val
|
||||
} else {
|
||||
const p = init()
|
||||
const node = new Entry(key, p)
|
||||
list.pushEnd(q, node)
|
||||
cache._map.set(key, node)
|
||||
p.then(v => {
|
||||
if (p === node.val) {
|
||||
node.val = v
|
||||
}
|
||||
if (removeNull && v == null) {
|
||||
remove(cache, key)
|
||||
}
|
||||
})
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} timeout
|
||||
*/
|
||||
export const create = timeout => new Cache(timeout)
|
||||
3
yjs-poll/node_modules/lib0/cache.test.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/cache.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function testCache(tc: t.TestCase): Promise<void>;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=cache.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/cache.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/cache.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache.test.d.ts","sourceRoot":"","sources":["cache.test.js"],"names":[],"mappings":"AAOO,8BAFI,CAAC,CAAC,QAAQ,iBA6EpB;mBAlFkB,cAAc"}
|
||||
86
yjs-poll/node_modules/lib0/component.d.ts
generated
vendored
Normal file
86
yjs-poll/node_modules/lib0/component.d.ts
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @type {CustomElementRegistry}
|
||||
*/
|
||||
export const registry: CustomElementRegistry;
|
||||
export function define(name: string, constr: any, opts?: ElementDefinitionOptions): void;
|
||||
export function whenDefined(name: string): Promise<CustomElementConstructor>;
|
||||
/**
|
||||
* @template S
|
||||
*/
|
||||
export class Lib0Component<S> extends HTMLElement {
|
||||
/**
|
||||
* @param {S} [state]
|
||||
*/
|
||||
constructor(state?: S);
|
||||
/**
|
||||
* @type {S|null}
|
||||
*/
|
||||
state: S | null;
|
||||
/**
|
||||
* @type {any}
|
||||
*/
|
||||
_internal: any;
|
||||
/**
|
||||
* @param {S} _state
|
||||
* @param {boolean} [_forceStateUpdate] Force that the state is rerendered even if state didn't change
|
||||
*/
|
||||
setState(_state: S, _forceStateUpdate?: boolean): void;
|
||||
/**
|
||||
* @param {any} _stateUpdate
|
||||
*/
|
||||
updateState(_stateUpdate: any): void;
|
||||
}
|
||||
export function createComponent<T>(name: string, { template, style, state: defaultState, onStateChange, childStates, attrs, listeners, slots }: CONF<T>): typeof Lib0Component;
|
||||
export function createComponentDefiner(definer: Function): () => any;
|
||||
export function defineListComponent(): any;
|
||||
export function defineLazyLoadingComponent(): any;
|
||||
export type CONF<S> = {
|
||||
/**
|
||||
* Template for the shadow dom.
|
||||
*/
|
||||
template?: string | null | undefined;
|
||||
/**
|
||||
* shadow dom style. Is only used when
|
||||
* `CONF.template` is defined
|
||||
*/
|
||||
style?: string | undefined;
|
||||
/**
|
||||
* Initial component state.
|
||||
*/
|
||||
state?: S | undefined;
|
||||
/**
|
||||
* Called when
|
||||
* the state changes.
|
||||
*/
|
||||
onStateChange?: ((arg0: S, arg1: S | null, arg2: Lib0Component<S>) => void) | undefined;
|
||||
/**
|
||||
* maps from
|
||||
* CSS-selector to transformer function. The first element that matches the
|
||||
* CSS-selector receives state updates via the transformer function.
|
||||
*/
|
||||
childStates?: {
|
||||
[x: string]: (arg0: any, arg1: any) => Object;
|
||||
} | undefined;
|
||||
/**
|
||||
* attrs-keys and state-keys should be camelCase, but the DOM uses kebap-case. I.e.
|
||||
* `attrs = { myAttr: 4 }` is represeted as `<my-elem my-attr="4" />` in the DOM
|
||||
*/
|
||||
attrs?: {
|
||||
[x: string]: "string" | "number" | "json" | "bool";
|
||||
} | undefined;
|
||||
/**
|
||||
* Maps from dom-event-name
|
||||
* to event listener.
|
||||
*/
|
||||
listeners?: {
|
||||
[x: string]: (arg0: CustomEvent, arg1: Lib0Component<any>) => boolean | void;
|
||||
} | undefined;
|
||||
/**
|
||||
* Fill slots
|
||||
* automatically when state changes. Maps from slot-name to slot-html.
|
||||
*/
|
||||
slots?: ((arg0: S, arg1: S, arg2: Lib0Component<S>) => {
|
||||
[x: string]: string;
|
||||
}) | undefined;
|
||||
};
|
||||
//# sourceMappingURL=component.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/component.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/component.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["component.js"],"names":[],"mappings":"AAiBA;;GAEG;AACH,uBAFU,qBAAqB,CAEO;AAO/B,6BAJI,MAAM,UACN,GAAG,SACH,wBAAwB,QAE8C;AAM1E,kCAHI,MAAM,GACL,OAAO,CAAC,wBAAwB,CAAC,CAEgB;AAM7D;;GAEG;AACH,2BAFa,CAAC;IAGZ;;OAEG;IACH,oBAFW,CAAC,EAYX;IARC;;OAEG;IACH,OAFU,CAAC,GAAC,IAAI,CAEuB;IACvC;;OAEG;IACH,WAFU,GAAG,CAEM;IAGrB;;;OAGG;IACH,iBAHW,CAAC,sBACD,OAAO,QAE4B;IAE9C;;QAEI;IACJ,0BAFY,GAAG,QAEe;CAC/B;AA6DM,gCALM,CAAC,QACH,MAAM,iGACN,IAAI,CAAC,CAAC,CAAC,GACN,OAAO,aAAa,CAuM/B;AAKM,qEAWN;AANQ,2CAKN;AALM,kDAKN;iBA9OU,CAAC;;;;;;;;;;;;;;;;;;4BAMS,CAAC,QAAC,CAAC,GAAC,IAAI,QAAC,aAAa,CAAC,CAAC,CAAC,KAAE,IAAI;;;;;;;4BAEjB,GAAG,QAAE,GAAG,KAAE,MAAM;;;;;;;;;;;;;;4BAMf,WAAW,QAAE,aAAa,CAAC,GAAG,CAAC,KAAE,OAAO,GAAC,IAAI;;;;;;oBAE5D,CAAC,QAAE,CAAC,QAAE,aAAa,CAAC,CAAC,CAAC"}
|
||||
414
yjs-poll/node_modules/lib0/component.js
generated
vendored
Normal file
414
yjs-poll/node_modules/lib0/component.js
generated
vendored
Normal file
@@ -0,0 +1,414 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/**
|
||||
* Web components.
|
||||
*
|
||||
* @module component
|
||||
*/
|
||||
|
||||
import * as dom from './dom.js'
|
||||
import * as diff from './diff.js'
|
||||
import * as object from './object.js'
|
||||
import * as json from './json.js'
|
||||
import * as string from './string.js'
|
||||
import * as array from './array.js'
|
||||
import * as number from './number.js'
|
||||
import * as func from './function.js'
|
||||
|
||||
/**
|
||||
* @type {CustomElementRegistry}
|
||||
*/
|
||||
export const registry = customElements
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {any} constr
|
||||
* @param {ElementDefinitionOptions} [opts]
|
||||
*/
|
||||
export const define = (name, constr, opts) => registry.define(name, constr, opts)
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @return {Promise<CustomElementConstructor>}
|
||||
*/
|
||||
export const whenDefined = name => registry.whenDefined(name)
|
||||
|
||||
const upgradedEventName = 'upgraded'
|
||||
const connectedEventName = 'connected'
|
||||
const disconnectedEventName = 'disconnected'
|
||||
|
||||
/**
|
||||
* @template S
|
||||
*/
|
||||
export class Lib0Component extends HTMLElement {
|
||||
/**
|
||||
* @param {S} [state]
|
||||
*/
|
||||
constructor (state) {
|
||||
super()
|
||||
/**
|
||||
* @type {S|null}
|
||||
*/
|
||||
this.state = /** @type {any} */ (state)
|
||||
/**
|
||||
* @type {any}
|
||||
*/
|
||||
this._internal = {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {S} _state
|
||||
* @param {boolean} [_forceStateUpdate] Force that the state is rerendered even if state didn't change
|
||||
*/
|
||||
setState (_state, _forceStateUpdate = true) {}
|
||||
|
||||
/**
|
||||
* @param {any} _stateUpdate
|
||||
*/
|
||||
updateState (_stateUpdate) { }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} val
|
||||
* @param {"json"|"string"|"number"} type
|
||||
* @return {string}
|
||||
*/
|
||||
const encodeAttrVal = (val, type) => {
|
||||
if (type === 'json') {
|
||||
val = json.stringify(val)
|
||||
}
|
||||
return val + ''
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} val
|
||||
* @param {"json"|"string"|"number"|"bool"} type
|
||||
* @return {any}
|
||||
*/
|
||||
const parseAttrVal = (val, type) => {
|
||||
switch (type) {
|
||||
case 'json':
|
||||
return json.parse(val)
|
||||
case 'number':
|
||||
return Number.parseFloat(val)
|
||||
case 'string':
|
||||
return val
|
||||
case 'bool':
|
||||
return val != null
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template S
|
||||
* @typedef {Object} CONF
|
||||
* @property {string?} [CONF.template] Template for the shadow dom.
|
||||
* @property {string} [CONF.style] shadow dom style. Is only used when
|
||||
* `CONF.template` is defined
|
||||
* @property {S} [CONF.state] Initial component state.
|
||||
* @property {function(S,S|null,Lib0Component<S>):void} [CONF.onStateChange] Called when
|
||||
* the state changes.
|
||||
* @property {Object<string,function(any, any):Object>} [CONF.childStates] maps from
|
||||
* CSS-selector to transformer function. The first element that matches the
|
||||
* CSS-selector receives state updates via the transformer function.
|
||||
* @property {Object<string,"json"|"number"|"string"|"bool">} [CONF.attrs]
|
||||
* attrs-keys and state-keys should be camelCase, but the DOM uses kebap-case. I.e.
|
||||
* `attrs = { myAttr: 4 }` is represeted as `<my-elem my-attr="4" />` in the DOM
|
||||
* @property {Object<string, function(CustomEvent, Lib0Component<any>):boolean|void>} [CONF.listeners] Maps from dom-event-name
|
||||
* to event listener.
|
||||
* @property {function(S, S, Lib0Component<S>):Object<string,string>} [CONF.slots] Fill slots
|
||||
* automatically when state changes. Maps from slot-name to slot-html.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {string} name
|
||||
* @param {CONF<T>} cnf
|
||||
* @return {typeof Lib0Component}
|
||||
*/
|
||||
export const createComponent = (name, { template, style = '', state: defaultState, onStateChange = () => {}, childStates = { }, attrs = {}, listeners = {}, slots = () => ({}) }) => {
|
||||
/**
|
||||
* Maps from camelCase attribute name to kebap-case attribute name.
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
const normalizedAttrs = {}
|
||||
for (const key in attrs) {
|
||||
normalizedAttrs[string.fromCamelCase(key, '-')] = key
|
||||
}
|
||||
const templateElement = template
|
||||
? /** @type {HTMLTemplateElement} */ (dom.parseElement(`
|
||||
<template>
|
||||
<style>${style}</style>
|
||||
${template}
|
||||
</template>
|
||||
`))
|
||||
: null
|
||||
|
||||
class _Lib0Component extends HTMLElement {
|
||||
/**
|
||||
* @param {T} [state]
|
||||
*/
|
||||
constructor (state) {
|
||||
super()
|
||||
/**
|
||||
* @type {Array<{d:Lib0Component<T>, s:function(any, any):Object}>}
|
||||
*/
|
||||
this._childStates = []
|
||||
/**
|
||||
* @type {Object<string,string>}
|
||||
*/
|
||||
this._slots = {}
|
||||
this._init = false
|
||||
/**
|
||||
* @type {any}
|
||||
*/
|
||||
this._internal = {}
|
||||
/**
|
||||
* @type {any}
|
||||
*/
|
||||
this.state = state || null
|
||||
this.connected = false
|
||||
// init shadow dom
|
||||
if (templateElement) {
|
||||
const shadow = /** @type {ShadowRoot} */ (this.attachShadow({ mode: 'open' }))
|
||||
shadow.appendChild(templateElement.content.cloneNode(true))
|
||||
// fill child states
|
||||
for (const key in childStates) {
|
||||
this._childStates.push({
|
||||
d: /** @type {Lib0Component<T>} */ (dom.querySelector(/** @type {any} */ (shadow), key)),
|
||||
s: childStates[key]
|
||||
})
|
||||
}
|
||||
}
|
||||
dom.emitCustomEvent(this, upgradedEventName, { bubbles: true })
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
this.connected = true
|
||||
if (!this._init) {
|
||||
this._init = true
|
||||
const shadow = this.shadowRoot
|
||||
if (shadow) {
|
||||
dom.addEventListener(shadow, upgradedEventName, event => {
|
||||
this.setState(this.state, true)
|
||||
event.stopPropagation()
|
||||
})
|
||||
}
|
||||
/**
|
||||
* @type {Object<string, any>}
|
||||
*/
|
||||
const startState = this.state || object.assign({}, defaultState)
|
||||
if (attrs) {
|
||||
for (const key in attrs) {
|
||||
const normalizedKey = string.fromCamelCase(key, '-')
|
||||
const val = parseAttrVal(this.getAttribute(normalizedKey), attrs[key])
|
||||
if (val) {
|
||||
startState[key] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
// add event listeners
|
||||
for (const key in listeners) {
|
||||
dom.addEventListener(shadow || this, key, event => {
|
||||
if (listeners[key](/** @type {CustomEvent} */ (event), this) !== false) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
// first setState call
|
||||
this.state = null
|
||||
this.setState(startState)
|
||||
}
|
||||
dom.emitCustomEvent(/** @type {any} */ (this.shadowRoot || this), connectedEventName, { bubbles: true })
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
this.connected = false
|
||||
dom.emitCustomEvent(/** @type {any} */ (this.shadowRoot || this), disconnectedEventName, { bubbles: true })
|
||||
this.setState(null)
|
||||
}
|
||||
|
||||
static get observedAttributes () {
|
||||
return object.keys(normalizedAttrs)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} oldVal
|
||||
* @param {string} newVal
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
attributeChangedCallback (name, oldVal, newVal) {
|
||||
const curState = /** @type {any} */ (this.state)
|
||||
const camelAttrName = normalizedAttrs[name]
|
||||
const type = attrs[camelAttrName]
|
||||
const parsedVal = parseAttrVal(newVal, type)
|
||||
if (curState && (type !== 'json' || json.stringify(curState[camelAttrName]) !== newVal) && curState[camelAttrName] !== parsedVal && !number.isNaN(parsedVal)) {
|
||||
this.updateState({ [camelAttrName]: parsedVal })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} stateUpdate
|
||||
*/
|
||||
updateState (stateUpdate) {
|
||||
this.setState(object.assign({}, this.state, stateUpdate))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} state
|
||||
*/
|
||||
setState (state, forceStateUpdates = false) {
|
||||
const prevState = this.state
|
||||
this.state = state
|
||||
if (this._init && (!func.equalityFlat(state, prevState) || forceStateUpdates)) {
|
||||
// fill slots
|
||||
if (state) {
|
||||
const slotElems = slots(state, prevState, this)
|
||||
for (const key in slotElems) {
|
||||
const slotContent = slotElems[key]
|
||||
if (this._slots[key] !== slotContent) {
|
||||
this._slots[key] = slotContent
|
||||
const currentSlots = /** @type {Array<any>} */ (key !== 'default' ? array.from(dom.querySelectorAll(this, `[slot="${key}"]`)) : array.from(this.childNodes).filter(/** @param {any} child */ child => !dom.checkNodeType(child, dom.ELEMENT_NODE) || !child.hasAttribute('slot')))
|
||||
currentSlots.slice(1).map(dom.remove)
|
||||
const nextSlot = dom.parseFragment(slotContent)
|
||||
if (key !== 'default') {
|
||||
array.from(nextSlot.children).forEach(c => c.setAttribute('slot', key))
|
||||
}
|
||||
if (currentSlots.length > 0) {
|
||||
dom.replaceWith(currentSlots[0], nextSlot)
|
||||
} else {
|
||||
dom.appendChild(this, nextSlot)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onStateChange(state, prevState, this)
|
||||
if (state != null) {
|
||||
this._childStates.forEach(cnf => {
|
||||
const d = cnf.d
|
||||
if (d.updateState) {
|
||||
d.updateState(cnf.s(state, this))
|
||||
}
|
||||
})
|
||||
}
|
||||
for (const key in attrs) {
|
||||
const normalizedKey = string.fromCamelCase(key, '-')
|
||||
if (state == null) {
|
||||
this.removeAttribute(normalizedKey)
|
||||
} else {
|
||||
const stateVal = state[key]
|
||||
const attrsType = attrs[key]
|
||||
if (!prevState || prevState[key] !== stateVal) {
|
||||
if (attrsType === 'bool') {
|
||||
if (stateVal) {
|
||||
this.setAttribute(normalizedKey, '')
|
||||
} else {
|
||||
this.removeAttribute(normalizedKey)
|
||||
}
|
||||
} else if (stateVal == null && (attrsType === 'string' || attrsType === 'number')) {
|
||||
this.removeAttribute(normalizedKey)
|
||||
} else {
|
||||
this.setAttribute(normalizedKey, encodeAttrVal(stateVal, attrsType))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
define(name, _Lib0Component)
|
||||
// @ts-ignore
|
||||
return _Lib0Component
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function} definer function that defines a component when executed
|
||||
*/
|
||||
export const createComponentDefiner = definer => {
|
||||
/**
|
||||
* @type {any}
|
||||
*/
|
||||
let defined = null
|
||||
return () => {
|
||||
if (!defined) {
|
||||
defined = definer()
|
||||
}
|
||||
return defined
|
||||
}
|
||||
}
|
||||
|
||||
export const defineListComponent = createComponentDefiner(() => {
|
||||
const ListItem = createComponent('lib0-list-item', {
|
||||
template: '<slot name="content"></slot>',
|
||||
slots: state => ({
|
||||
content: `<div>${state}</div>`
|
||||
})
|
||||
})
|
||||
return createComponent('lib0-list', {
|
||||
state: { list: /** @type {Array<string>} */ ([]), Item: ListItem },
|
||||
onStateChange: (state, prevState, component) => {
|
||||
if (state == null) {
|
||||
return
|
||||
}
|
||||
const { list = /** @type {Array<any>} */ ([]), Item = ListItem } = state
|
||||
// @todo deep compare here by providing another parameter to simpleDiffArray
|
||||
let { index, remove, insert } = diff.simpleDiffArray(prevState ? prevState.list : [], list, func.equalityFlat)
|
||||
if (remove === 0 && insert.length === 0) {
|
||||
return
|
||||
}
|
||||
let child = /** @type {Lib0Component<any>} */ (component.firstChild)
|
||||
while (index-- > 0) {
|
||||
child = /** @type {Lib0Component<any>} */ (child.nextElementSibling)
|
||||
}
|
||||
let insertStart = 0
|
||||
while (insertStart < insert.length && remove-- > 0) {
|
||||
// update existing state
|
||||
child.setState(insert[insertStart++])
|
||||
child = /** @type {Lib0Component<any>} */ (child.nextElementSibling)
|
||||
}
|
||||
while (remove-- > 0) {
|
||||
// remove remaining
|
||||
const prevChild = child
|
||||
child = /** @type {Lib0Component<any>} */ (child.nextElementSibling)
|
||||
component.removeChild(prevChild)
|
||||
}
|
||||
// insert remaining
|
||||
component.insertBefore(dom.fragment(insert.slice(insertStart).map(/** @param {any} insState */ insState => {
|
||||
const el = new Item()
|
||||
el.setState(insState)
|
||||
return el
|
||||
})), child)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
export const defineLazyLoadingComponent = createComponentDefiner(() => createComponent('lib0-lazy', {
|
||||
state: /** @type {{component:null|String,import:null|function():Promise<any>,state:null|object}} */ ({
|
||||
component: null, import: null, state: null
|
||||
}),
|
||||
attrs: {
|
||||
component: 'string'
|
||||
},
|
||||
onStateChange: ({ component, state, import: getImport }, prevState, componentEl) => {
|
||||
if (component !== null) {
|
||||
if (getImport) {
|
||||
getImport()
|
||||
}
|
||||
if (!prevState || component !== prevState.component) {
|
||||
const el = /** @type {any} */ (dom.createElement(component))
|
||||
componentEl.innerHTML = ''
|
||||
componentEl.insertBefore(el, null)
|
||||
}
|
||||
const el = /** @type {any} */ (componentEl.firstElementChild)
|
||||
// @todo generalize setting state and check if setState is defined
|
||||
if (el.setState) {
|
||||
el.setState(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
2
yjs-poll/node_modules/lib0/conditions.d.ts
generated
vendored
Normal file
2
yjs-poll/node_modules/lib0/conditions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export function undefinedToNull<T>(v: T | null | undefined): T | null;
|
||||
//# sourceMappingURL=conditions.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/conditions.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/conditions.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["conditions.js"],"names":[],"mappings":"AAYO,gCALM,CAAC,KACH,CAAC,GAAC,IAAI,GAAC,SAAS,GACf,CAAC,GAAC,IAAI,CAG4C"}
|
||||
13
yjs-poll/node_modules/lib0/conditions.js
generated
vendored
Normal file
13
yjs-poll/node_modules/lib0/conditions.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Often used conditions.
|
||||
*
|
||||
* @module conditions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T|null|undefined} v
|
||||
* @return {T|null}
|
||||
*/
|
||||
/* c8 ignore next */
|
||||
export const undefinedToNull = v => v === undefined ? null : v
|
||||
1
yjs-poll/node_modules/lib0/coverage/tmp/coverage-70359-1766561372098-0.json
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/coverage/tmp/coverage-70359-1766561372098-0.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
yjs-poll/node_modules/lib0/crypto.test.d.ts
generated
vendored
Normal file
9
yjs-poll/node_modules/lib0/crypto.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export function testJwt(_tc: t.TestCase): Promise<void>;
|
||||
export function testEncryption(tc: t.TestCase): Promise<void>;
|
||||
export function testReapeatEncryption(tc: t.TestCase): Promise<void>;
|
||||
export function testImportExport(tc: t.TestCase): Promise<void>;
|
||||
export function testEncryptionPerformance(tc: t.TestCase): Promise<void>;
|
||||
export function testConsistentKeyGeneration(_tc: t.TestCase): Promise<void>;
|
||||
export function testSigning(tc: t.TestCase): Promise<void>;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=crypto.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/crypto.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/crypto.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"crypto.test.d.ts","sourceRoot":"","sources":["crypto.test.js"],"names":[],"mappings":"AAYO,6BAFI,CAAC,CAAC,QAAQ,iBA8BpB;AAKM,mCAFI,CAAC,CAAC,QAAQ,iBAoCpB;AAKM,0CAFI,CAAC,CAAC,QAAQ,iBA8BpB;AAKM,qCAFI,CAAC,CAAC,QAAQ,iBAgDpB;AAKM,8CAFI,CAAC,CAAC,QAAQ,iBAwCpB;AAKM,iDAFI,CAAC,CAAC,QAAQ,iBA2EpB;AAKM,gCAFI,CAAC,CAAC,QAAQ,iBAapB;mBAvSkB,cAAc"}
|
||||
17
yjs-poll/node_modules/lib0/crypto/aes-gcm.d.ts
generated
vendored
Normal file
17
yjs-poll/node_modules/lib0/crypto/aes-gcm.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export function encrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer>>;
|
||||
export function decrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array>;
|
||||
export function importKeyJwk(jwk: any, { usages, extractable }?: {
|
||||
usages?: Usages | undefined;
|
||||
extractable?: boolean | undefined;
|
||||
}): Promise<CryptoKey>;
|
||||
export function importKeyRaw(raw: Uint8Array<ArrayBuffer>, { usages, extractable }?: {
|
||||
usages?: Usages | undefined;
|
||||
extractable?: boolean | undefined;
|
||||
}): Promise<CryptoKey>;
|
||||
export function deriveKey(secret: Uint8Array<ArrayBuffer> | string, salt: Uint8Array<ArrayBuffer> | string, { extractable, usages }?: {
|
||||
extractable?: boolean | undefined;
|
||||
usages?: Usages | undefined;
|
||||
}): Promise<CryptoKey>;
|
||||
export type Usages = Array<"encrypt" | "decrypt">;
|
||||
export { exportKeyJwk, exportKeyRaw } from "./common.js";
|
||||
//# sourceMappingURL=aes-gcm.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/crypto/aes-gcm.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/crypto/aes-gcm.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"aes-gcm.d.ts","sourceRoot":"","sources":["aes-gcm.js"],"names":[],"mappings":"AAuBO,6BAHI,SAAS,QACT,UAAU,CAAC,WAAW,CAAC,oCAkBjC;AAWM,6BAJI,SAAS,QACT,UAAU,CAAC,WAAW,CAAC,GACtB,WAAW,CAAC,UAAU,CAAC,CAclC;AAaM,kCALI,GAAG,4BAEX;IAAsB,MAAM;IACL,WAAW;CAAC,sBAQrC;AAUM,kCALI,UAAU,CAAC,WAAW,CAAC,4BAE/B;IAAsB,MAAM;IACL,WAAW;CAAC,sBAG0D;AAmBzF,kCANI,UAAU,CAAC,WAAW,CAAC,GAAC,MAAM,QAC9B,UAAU,CAAC,WAAW,CAAC,GAAC,MAAM,4BAEtC;IAAuB,WAAW;IACZ,MAAM;CAAC,sBAsB7B;qBAxHU,KAAK,CAAC,SAAS,GAAC,SAAS,CAAC"}
|
||||
132
yjs-poll/node_modules/lib0/crypto/aes-gcm.js
generated
vendored
Normal file
132
yjs-poll/node_modules/lib0/crypto/aes-gcm.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* AES-GCM is a symmetric key for encryption
|
||||
*/
|
||||
|
||||
import * as encoding from '../encoding.js'
|
||||
import * as decoding from '../decoding.js'
|
||||
import * as webcrypto from 'lib0/webcrypto'
|
||||
import * as string from '../string.js'
|
||||
export { exportKeyJwk, exportKeyRaw } from './common.js'
|
||||
|
||||
/**
|
||||
* @typedef {Array<'encrypt'|'decrypt'>} Usages
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Usages}
|
||||
*/
|
||||
const defaultUsages = ['encrypt', 'decrypt']
|
||||
|
||||
/**
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
*/
|
||||
export const encrypt = (key, data) => {
|
||||
const iv = webcrypto.getRandomValues(new Uint8Array(16)) // 92bit is enough. 128bit is recommended if space is not an issue.
|
||||
return webcrypto.subtle.encrypt(
|
||||
{
|
||||
name: 'AES-GCM',
|
||||
iv
|
||||
},
|
||||
key,
|
||||
data
|
||||
).then(cipher => {
|
||||
const encryptedDataEncoder = encoding.createEncoder()
|
||||
// iv may be sent in the clear to the other peers
|
||||
encoding.writeUint8Array(encryptedDataEncoder, iv)
|
||||
encoding.writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher))
|
||||
return encoding.toUint8Array(encryptedDataEncoder)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Decrypt some data using AES-GCM method.
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
* @return {PromiseLike<Uint8Array>} decrypted buffer
|
||||
*/
|
||||
export const decrypt = (key, data) => {
|
||||
const dataDecoder = decoding.createDecoder(data)
|
||||
const iv = decoding.readUint8Array(dataDecoder, 16)
|
||||
const cipher = decoding.readVarUint8Array(dataDecoder)
|
||||
return webcrypto.subtle.decrypt(
|
||||
{
|
||||
name: 'AES-GCM',
|
||||
iv
|
||||
},
|
||||
key,
|
||||
cipher
|
||||
).then(data => new Uint8Array(data))
|
||||
}
|
||||
|
||||
const aesAlgDef = {
|
||||
name: 'AES-GCM',
|
||||
length: 256
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} jwk
|
||||
* @param {Object} opts
|
||||
* @param {Usages} [opts.usages]
|
||||
* @param {boolean} [opts.extractable]
|
||||
*/
|
||||
export const importKeyJwk = (jwk, { usages, extractable = false } = {}) => {
|
||||
if (usages == null) {
|
||||
/* c8 ignore next */
|
||||
usages = jwk.key_ops || defaultUsages
|
||||
}
|
||||
return webcrypto.subtle.importKey('jwk', jwk, 'AES-GCM', extractable, /** @type {Usages} */ (usages))
|
||||
}
|
||||
|
||||
/**
|
||||
* Only suited for importing public keys.
|
||||
*
|
||||
* @param {Uint8Array<ArrayBuffer>} raw
|
||||
* @param {Object} opts
|
||||
* @param {Usages} [opts.usages]
|
||||
* @param {boolean} [opts.extractable]
|
||||
*/
|
||||
export const importKeyRaw = (raw, { usages = defaultUsages, extractable = false } = {}) =>
|
||||
webcrypto.subtle.importKey('raw', raw, aesAlgDef, extractable, /** @type {Usages} */ (usages))
|
||||
|
||||
/**
|
||||
* @param {Uint8Array<ArrayBuffer> | string} data
|
||||
*/
|
||||
/* c8 ignore next */
|
||||
const toBinary = data => typeof data === 'string' ? string.encodeUtf8(data) : data
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Derive an symmetric key using the Password-Based-Key-Derivation-Function-2.
|
||||
*
|
||||
* @param {Uint8Array<ArrayBuffer>|string} secret
|
||||
* @param {Uint8Array<ArrayBuffer>|string} salt
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
*/
|
||||
export const deriveKey = (secret, salt, { extractable = false, usages = defaultUsages } = {}) =>
|
||||
webcrypto.subtle.importKey(
|
||||
'raw',
|
||||
toBinary(secret),
|
||||
'PBKDF2',
|
||||
false,
|
||||
['deriveKey']
|
||||
).then(keyMaterial =>
|
||||
webcrypto.subtle.deriveKey(
|
||||
{
|
||||
name: 'PBKDF2',
|
||||
salt: toBinary(salt), // NIST recommends at least 64 bits
|
||||
iterations: 600000, // OWASP recommends 600k iterations
|
||||
hash: 'SHA-256'
|
||||
},
|
||||
keyMaterial,
|
||||
aesAlgDef,
|
||||
extractable,
|
||||
usages
|
||||
)
|
||||
)
|
||||
3
yjs-poll/node_modules/lib0/crypto/common.d.ts
generated
vendored
Normal file
3
yjs-poll/node_modules/lib0/crypto/common.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function exportKeyJwk(key: CryptoKey): Promise<JsonWebKey>;
|
||||
export function exportKeyRaw(key: CryptoKey): Promise<Uint8Array<ArrayBuffer>>;
|
||||
//# sourceMappingURL=common.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/crypto/common.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/crypto/common.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.js"],"names":[],"mappings":"AAKO,kCAFI,SAAS,uBAMnB;AAQM,kCAHI,SAAS,GACR,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAG6B"}
|
||||
19
yjs-poll/node_modules/lib0/crypto/common.js
generated
vendored
Normal file
19
yjs-poll/node_modules/lib0/crypto/common.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as webcrypto from 'lib0/webcrypto'
|
||||
|
||||
/**
|
||||
* @param {CryptoKey} key
|
||||
*/
|
||||
export const exportKeyJwk = async key => {
|
||||
const jwk = await webcrypto.subtle.exportKey('jwk', key)
|
||||
jwk.key_ops = key.usages
|
||||
return jwk
|
||||
}
|
||||
|
||||
/**
|
||||
* Only suited for exporting public keys.
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @return {Promise<Uint8Array<ArrayBuffer>>}
|
||||
*/
|
||||
export const exportKeyRaw = key =>
|
||||
webcrypto.subtle.exportKey('raw', key).then(key => new Uint8Array(key))
|
||||
17
yjs-poll/node_modules/lib0/crypto/ecdsa.d.ts
generated
vendored
Normal file
17
yjs-poll/node_modules/lib0/crypto/ecdsa.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export function sign(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array<ArrayBuffer>>;
|
||||
export function verify(key: CryptoKey, signature: Uint8Array<ArrayBuffer>, data: Uint8Array<ArrayBuffer>): PromiseLike<boolean>;
|
||||
export function generateKeyPair({ extractable, usages }?: {
|
||||
extractable?: boolean | undefined;
|
||||
usages?: Usages | undefined;
|
||||
}): Promise<CryptoKeyPair>;
|
||||
export function importKeyJwk(jwk: any, { extractable, usages }?: {
|
||||
extractable?: boolean | undefined;
|
||||
usages?: Usages | undefined;
|
||||
}): Promise<CryptoKey>;
|
||||
export function importKeyRaw(raw: any, { extractable, usages }?: {
|
||||
extractable?: boolean | undefined;
|
||||
usages?: Usages | undefined;
|
||||
}): Promise<CryptoKey>;
|
||||
export type Usages = Array<"sign" | "verify">;
|
||||
export { exportKeyJwk, exportKeyRaw } from "./common.js";
|
||||
//# sourceMappingURL=ecdsa.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/crypto/ecdsa.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/crypto/ecdsa.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["ecdsa.js"],"names":[],"mappings":"AA8BO,0BAJI,SAAS,QACT,UAAU,CAAC,WAAW,CAAC,GACtB,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAOA;AAYzC,4BALI,SAAS,aACT,UAAU,CAAC,WAAW,CAAC,QACvB,UAAU,CAAC,WAAW,CAAC,GACtB,WAAW,CAAC,OAAO,CAAC,CAQ7B;AAaI,0DAHJ;IAAuB,WAAW;IACZ,MAAM;CAAC,0BAO7B;AAQI,kCALI,GAAG,4BAEX;IAAuB,WAAW;IACZ,MAAM;CAAC,sBAQ/B;AAUM,kCALI,GAAG,4BAEX;IAAuB,WAAW;IACZ,MAAM;CAAC,sBAGkD;qBAxFrE,KAAK,CAAC,MAAM,GAAC,QAAQ,CAAC"}
|
||||
97
yjs-poll/node_modules/lib0/crypto/ecdsa.js
generated
vendored
Normal file
97
yjs-poll/node_modules/lib0/crypto/ecdsa.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* ECDSA is an asymmetric key for signing
|
||||
*/
|
||||
|
||||
import * as webcrypto from 'lib0/webcrypto'
|
||||
export { exportKeyJwk, exportKeyRaw } from './common.js'
|
||||
|
||||
/**
|
||||
* @typedef {Array<'sign'|'verify'>} Usages
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Usages}
|
||||
*/
|
||||
const defaultUsages = ['sign', 'verify']
|
||||
|
||||
const defaultSignAlgorithm = {
|
||||
name: 'ECDSA',
|
||||
hash: 'SHA-384'
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Sign a message
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
* @return {PromiseLike<Uint8Array<ArrayBuffer>>} signature
|
||||
*/
|
||||
export const sign = (key, data) =>
|
||||
webcrypto.subtle.sign(
|
||||
defaultSignAlgorithm,
|
||||
key,
|
||||
data
|
||||
).then(signature => new Uint8Array(signature))
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Sign a message
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} signature
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
* @return {PromiseLike<boolean>} signature
|
||||
*/
|
||||
export const verify = (key, signature, data) =>
|
||||
webcrypto.subtle.verify(
|
||||
defaultSignAlgorithm,
|
||||
key,
|
||||
signature,
|
||||
data
|
||||
)
|
||||
|
||||
const defaultKeyAlgorithm = {
|
||||
name: 'ECDSA',
|
||||
namedCurve: 'P-384'
|
||||
}
|
||||
|
||||
/* c8 ignore next */
|
||||
/**
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
*/
|
||||
export const generateKeyPair = ({ extractable = false, usages = defaultUsages } = {}) =>
|
||||
webcrypto.subtle.generateKey(
|
||||
defaultKeyAlgorithm,
|
||||
extractable,
|
||||
usages
|
||||
)
|
||||
|
||||
/**
|
||||
* @param {any} jwk
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
*/
|
||||
export const importKeyJwk = (jwk, { extractable = false, usages } = {}) => {
|
||||
if (usages == null) {
|
||||
/* c8 ignore next 2 */
|
||||
usages = jwk.key_ops || defaultUsages
|
||||
}
|
||||
return webcrypto.subtle.importKey('jwk', jwk, defaultKeyAlgorithm, extractable, /** @type {Usages} */ (usages))
|
||||
}
|
||||
|
||||
/**
|
||||
* Only suited for importing public keys.
|
||||
*
|
||||
* @param {any} raw
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
*/
|
||||
export const importKeyRaw = (raw, { extractable = false, usages = defaultUsages } = {}) =>
|
||||
webcrypto.subtle.importKey('raw', raw, defaultKeyAlgorithm, extractable, usages)
|
||||
10
yjs-poll/node_modules/lib0/crypto/jwt.d.ts
generated
vendored
Normal file
10
yjs-poll/node_modules/lib0/crypto/jwt.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export function encodeJwt(privateKey: CryptoKey, payload: Object): PromiseLike<string>;
|
||||
export function verifyJwt(publicKey: CryptoKey, jwt: string): Promise<{
|
||||
header: any;
|
||||
payload: any;
|
||||
}>;
|
||||
export function unsafeDecode(jwt: string): {
|
||||
header: any;
|
||||
payload: any;
|
||||
};
|
||||
//# sourceMappingURL=jwt.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/crypto/jwt.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/crypto/jwt.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["jwt.js"],"names":[],"mappings":"AAqBO,sCAHI,SAAS,WACT,MAAM,uBAgBhB;AAMM,qCAHI,SAAS,OACT,MAAM;;;GAiBhB;AAOM,kCAFI,MAAM;;;EAQhB"}
|
||||
70
yjs-poll/node_modules/lib0/crypto/jwt.js
generated
vendored
Normal file
70
yjs-poll/node_modules/lib0/crypto/jwt.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import * as error from '../error.js'
|
||||
import * as buffer from '../buffer.js'
|
||||
import * as string from '../string.js'
|
||||
import * as json from '../json.js'
|
||||
import * as ecdsa from '../crypto/ecdsa.js'
|
||||
import * as time from '../time.js'
|
||||
|
||||
/**
|
||||
* @param {Object} data
|
||||
*/
|
||||
const _stringify = data => buffer.toBase64UrlEncoded(string.encodeUtf8(json.stringify(data)))
|
||||
|
||||
/**
|
||||
* @param {string} base64url
|
||||
*/
|
||||
const _parse = base64url => json.parse(string.decodeUtf8(buffer.fromBase64UrlEncoded(base64url)))
|
||||
|
||||
/**
|
||||
* @param {CryptoKey} privateKey
|
||||
* @param {Object} payload
|
||||
*/
|
||||
export const encodeJwt = (privateKey, payload) => {
|
||||
const { name: algName, namedCurve: algCurve } = /** @type {any} */ (privateKey.algorithm)
|
||||
/* c8 ignore next 3 */
|
||||
if (algName !== 'ECDSA' || algCurve !== 'P-384') {
|
||||
error.unexpectedCase()
|
||||
}
|
||||
const header = {
|
||||
alg: 'ES384',
|
||||
typ: 'JWT'
|
||||
}
|
||||
const jwt = _stringify(header) + '.' + _stringify(payload)
|
||||
return ecdsa.sign(privateKey, string.encodeUtf8(jwt)).then(signature =>
|
||||
jwt + '.' + buffer.toBase64UrlEncoded(signature)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CryptoKey} publicKey
|
||||
* @param {string} jwt
|
||||
*/
|
||||
export const verifyJwt = async (publicKey, jwt) => {
|
||||
const [headerBase64, payloadBase64, signatureBase64] = jwt.split('.')
|
||||
const verified = await ecdsa.verify(publicKey, buffer.fromBase64UrlEncoded(signatureBase64), string.encodeUtf8(headerBase64 + '.' + payloadBase64))
|
||||
/* c8 ignore next 3 */
|
||||
if (!verified) {
|
||||
throw new Error('Invalid JWT')
|
||||
}
|
||||
const payload = _parse(payloadBase64)
|
||||
if (payload.exp != null && time.getUnixTime() > payload.exp) {
|
||||
throw new Error('Expired JWT')
|
||||
}
|
||||
return {
|
||||
header: _parse(headerBase64),
|
||||
payload
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a jwt without verifying it. Probably a bad idea to use this. Only use if you know the jwt was already verified!
|
||||
*
|
||||
* @param {string} jwt
|
||||
*/
|
||||
export const unsafeDecode = jwt => {
|
||||
const [headerBase64, payloadBase64] = jwt.split('.')
|
||||
return {
|
||||
header: _parse(headerBase64),
|
||||
payload: _parse(payloadBase64)
|
||||
}
|
||||
}
|
||||
13
yjs-poll/node_modules/lib0/crypto/rsa-oaep.d.ts
generated
vendored
Normal file
13
yjs-poll/node_modules/lib0/crypto/rsa-oaep.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export { exportKeyJwk } from "./common.js";
|
||||
export function encrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array<ArrayBuffer>>;
|
||||
export function decrypt(key: CryptoKey, data: Uint8Array<ArrayBuffer>): PromiseLike<Uint8Array>;
|
||||
export function generateKeyPair({ extractable, usages }?: {
|
||||
extractable?: boolean | undefined;
|
||||
usages?: Usages | undefined;
|
||||
}): Promise<CryptoKeyPair>;
|
||||
export function importKeyJwk(jwk: any, { extractable, usages }?: {
|
||||
extractable?: boolean | undefined;
|
||||
usages?: Usages | undefined;
|
||||
}): Promise<CryptoKey>;
|
||||
export type Usages = Array<"encrypt" | "decrypt">;
|
||||
//# sourceMappingURL=rsa-oaep.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/crypto/rsa-oaep.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/crypto/rsa-oaep.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"rsa-oaep.d.ts","sourceRoot":"","sources":["rsa-oaep.js"],"names":[],"mappings":";AAuBO,6BAJI,SAAS,QACT,UAAU,CAAC,WAAW,CAAC,GACtB,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CASZ;AAW7B,6BAJI,SAAS,QACT,UAAU,CAAC,WAAW,CAAC,GACtB,WAAW,CAAC,UAAU,CAAC,CASG;AAQ/B,0DAJJ;IAAuB,WAAW;IACZ,MAAM;CAC5B,GAAS,OAAO,CAAC,aAAa,CAAC,CAY/B;AAQI,kCALI,GAAG,4BAEX;IAAuB,WAAW;IACZ,MAAM;CAAC,sBAQ/B;qBAxEY,KAAK,CAAC,SAAS,GAAC,SAAS,CAAC"}
|
||||
81
yjs-poll/node_modules/lib0/crypto/rsa-oaep.js
generated
vendored
Normal file
81
yjs-poll/node_modules/lib0/crypto/rsa-oaep.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* RSA-OAEP is an asymmetric keypair used for encryption
|
||||
*/
|
||||
|
||||
import * as webcrypto from 'lib0/webcrypto'
|
||||
export { exportKeyJwk } from './common.js'
|
||||
|
||||
/**
|
||||
* @typedef {Array<'encrypt'|'decrypt'>} Usages
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Usages}
|
||||
*/
|
||||
const defaultUsages = ['encrypt', 'decrypt']
|
||||
|
||||
/**
|
||||
* Note that the max data size is limited by the size of the RSA key.
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
* @return {PromiseLike<Uint8Array<ArrayBuffer>>}
|
||||
*/
|
||||
export const encrypt = (key, data) =>
|
||||
webcrypto.subtle.encrypt(
|
||||
{
|
||||
name: 'RSA-OAEP'
|
||||
},
|
||||
key,
|
||||
data
|
||||
).then(buf => new Uint8Array(buf))
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Decrypt some data using AES-GCM method.
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
* @return {PromiseLike<Uint8Array>} decrypted buffer
|
||||
*/
|
||||
export const decrypt = (key, data) =>
|
||||
webcrypto.subtle.decrypt(
|
||||
{
|
||||
name: 'RSA-OAEP'
|
||||
},
|
||||
key,
|
||||
data
|
||||
).then(data => new Uint8Array(data))
|
||||
|
||||
/**
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
* @return {Promise<CryptoKeyPair>}
|
||||
*/
|
||||
export const generateKeyPair = ({ extractable = false, usages = defaultUsages } = {}) =>
|
||||
webcrypto.subtle.generateKey(
|
||||
{
|
||||
name: 'RSA-OAEP',
|
||||
modulusLength: 4096,
|
||||
publicExponent: new Uint8Array([1, 0, 1]),
|
||||
hash: 'SHA-256'
|
||||
},
|
||||
extractable,
|
||||
usages
|
||||
)
|
||||
|
||||
/**
|
||||
* @param {any} jwk
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
*/
|
||||
export const importKeyJwk = (jwk, { extractable = false, usages } = {}) => {
|
||||
if (usages == null) {
|
||||
/* c8 ignore next */
|
||||
usages = jwk.key_ops || defaultUsages
|
||||
}
|
||||
return webcrypto.subtle.importKey('jwk', jwk, { name: 'RSA-OAEP', hash: 'SHA-256' }, extractable, /** @type {Usages} */ (usages))
|
||||
}
|
||||
165
yjs-poll/node_modules/lib0/decoding.d.ts
generated
vendored
Normal file
165
yjs-poll/node_modules/lib0/decoding.d.ts
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* A Decoder handles the decoding of an Uint8Array.
|
||||
* @template {ArrayBufferLike} [Buf=ArrayBufferLike]
|
||||
*/
|
||||
export class Decoder<Buf extends ArrayBufferLike = ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array<Buf>} uint8Array Binary data to decode
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array<Buf>);
|
||||
/**
|
||||
* Decoding target.
|
||||
*
|
||||
* @type {Uint8Array<Buf>}
|
||||
*/
|
||||
arr: Uint8Array<Buf>;
|
||||
/**
|
||||
* Current decoding position.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
pos: number;
|
||||
}
|
||||
export function createDecoder<Buf extends ArrayBufferLike>(uint8Array: Uint8Array<Buf>): Decoder<Buf>;
|
||||
export function hasContent(decoder: Decoder): boolean;
|
||||
export function clone(decoder: Decoder, newPos?: number): Decoder;
|
||||
export function readUint8Array<Buf extends ArrayBufferLike>(decoder: Decoder<Buf>, len: number): Uint8Array<Buf>;
|
||||
export function readVarUint8Array<Buf extends ArrayBufferLike>(decoder: Decoder<Buf>): Uint8Array<Buf>;
|
||||
export function readTailAsUint8Array(decoder: Decoder): Uint8Array;
|
||||
export function skip8(decoder: Decoder): number;
|
||||
export function readUint8(decoder: Decoder): number;
|
||||
export function readUint16(decoder: Decoder): number;
|
||||
export function readUint32(decoder: Decoder): number;
|
||||
export function readUint32BigEndian(decoder: Decoder): number;
|
||||
export function peekUint8(decoder: Decoder): number;
|
||||
export function peekUint16(decoder: Decoder): number;
|
||||
export function peekUint32(decoder: Decoder): number;
|
||||
export function readVarUint(decoder: Decoder): number;
|
||||
export function readVarInt(decoder: Decoder): number;
|
||||
export function peekVarUint(decoder: Decoder): number;
|
||||
export function peekVarInt(decoder: Decoder): number;
|
||||
export function _readVarStringPolyfill(decoder: Decoder): string;
|
||||
export function _readVarStringNative(decoder: Decoder): string;
|
||||
export function readVarString(decoder: Decoder): string;
|
||||
export function readTerminatedUint8Array(decoder: Decoder): Uint8Array;
|
||||
export function readTerminatedString(decoder: Decoder): string;
|
||||
export function peekVarString(decoder: Decoder): string;
|
||||
export function readFromDataView(decoder: Decoder, len: number): DataView;
|
||||
export function readFloat32(decoder: Decoder): number;
|
||||
export function readFloat64(decoder: Decoder): number;
|
||||
export function readBigInt64(decoder: Decoder): any;
|
||||
export function readBigUint64(decoder: Decoder): any;
|
||||
export function readAny(decoder: Decoder): any;
|
||||
/**
|
||||
* T must not be null.
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
export class RleDecoder<T> extends Decoder<ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @param {function(Decoder):T} reader
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array, reader: (arg0: Decoder) => T);
|
||||
/**
|
||||
* The reader
|
||||
*/
|
||||
reader: (arg0: Decoder) => T;
|
||||
/**
|
||||
* Current state
|
||||
* @type {T|null}
|
||||
*/
|
||||
s: T | null;
|
||||
count: number;
|
||||
read(): T;
|
||||
}
|
||||
export class IntDiffDecoder extends Decoder<ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @param {number} start
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array, start: number);
|
||||
/**
|
||||
* Current state
|
||||
* @type {number}
|
||||
*/
|
||||
s: number;
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
read(): number;
|
||||
}
|
||||
export class RleIntDiffDecoder extends Decoder<ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @param {number} start
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array, start: number);
|
||||
/**
|
||||
* Current state
|
||||
* @type {number}
|
||||
*/
|
||||
s: number;
|
||||
count: number;
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
read(): number;
|
||||
}
|
||||
export class UintOptRleDecoder extends Decoder<ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array);
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
s: number;
|
||||
count: number;
|
||||
read(): number;
|
||||
}
|
||||
export class IncUintOptRleDecoder extends Decoder<ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array);
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
s: number;
|
||||
count: number;
|
||||
read(): number;
|
||||
}
|
||||
export class IntDiffOptRleDecoder extends Decoder<ArrayBufferLike> {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array);
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
s: number;
|
||||
count: number;
|
||||
diff: number;
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
read(): number;
|
||||
}
|
||||
export class StringDecoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor(uint8Array: Uint8Array);
|
||||
decoder: UintOptRleDecoder;
|
||||
str: string;
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
spos: number;
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
read(): string;
|
||||
}
|
||||
//# sourceMappingURL=decoding.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/decoding.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/decoding.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decoding.d.ts","sourceRoot":"","sources":["decoding.js"],"names":[],"mappings":"AAsCA;;;GAGG;AACH,qBAFgC,GAAG,SAArB,eAAgB;IAG5B;;OAEG;IACH,wBAFW,UAAU,CAAC,GAAG,CAAC,EAezB;IAZC;;;;OAIG;IACH,KAFU,UAAU,CAAC,GAAG,CAAC,CAEJ;IACrB;;;;OAIG;IACH,KAFU,MAAM,CAEJ;CAEf;AAQM,8BAJwB,GAAG,SAApB,eAAgB,cACnB,UAAU,CAAC,GAAG,CAAC,GACd,OAAO,CAAC,GAAG,CAAC,CAE0C;AAO3D,oCAHI,OAAO,GACN,OAAO,CAEoD;AAWhE,+BAJI,OAAO,WACP,MAAM,GACL,OAAO,CAMlB;AAcM,+BALwB,GAAG,SAApB,eAAgB,WACnB,OAAO,CAAC,GAAG,CAAC,OACZ,MAAM,GACL,UAAU,CAAC,GAAG,CAAC,CAM1B;AAaM,kCAJwB,GAAG,SAApB,eAAgB,WACnB,OAAO,CAAC,GAAG,CAAC,GACX,UAAU,CAAC,GAAG,CAAC,CAE8D;AAQlF,8CAHI,OAAO,GACN,UAAU,CAEkF;AAQjG,+BAHI,OAAO,GACN,MAAM,CAE2B;AAQtC,mCAHI,OAAO,GACN,MAAM,CAE4C;AASvD,oCAHI,OAAO,GACN,MAAM,CAQjB;AASM,oCAHI,OAAO,GACN,MAAM,CAUjB;AAUM,6CAHI,OAAO,GACN,MAAM,CAUjB;AAUM,mCAHI,OAAO,GACN,MAAM,CAE0C;AAUrD,oCAHI,OAAO,GACN,MAAM,CAImB;AAU9B,oCAHI,OAAO,GACN,MAAM,CAOX;AAYA,qCAHI,OAAO,GACN,MAAM,CAqBjB;AAaM,oCAHI,OAAO,GACN,MAAM,CA2BjB;AASM,qCAHI,OAAO,GACN,MAAM,CAOjB;AASM,oCAHI,OAAO,GACN,MAAM,CAOjB;AAgBM,gDAJI,OAAO,UA2BjB;AAQM,8CAHI,OAAO,UAI4D;AAhCvE,uCAJI,OAAO,UA2BjB;AA2BM,kDAHI,OAAO,GACN,UAAU,CAerB;AAMM,8CAHI,OAAO,GACN,MAAM,CAEiF;AAS5F,uCAHI,OAAO,GACN,MAAM,CAOjB;AAOM,0CAJI,OAAO,OACP,MAAM,GACL,QAAQ,CAMnB;AAKM,qCAFI,OAAO,UAEqE;AAKhF,qCAFI,OAAO,UAEqE;AAKhF,sCAFI,OAAO,OAE4F;AAKvG,uCAFI,OAAO,OAE8F;AAyCzG,iCAFI,OAAO,OAEqE;AAEvF;;;;GAIG;AACH,wBAFa,CAAC;IAGZ;;;OAGG;IACH,wBAHW,UAAU,UACV,CAAS,IAAO,EAAP,OAAO,KAAE,CAAC,EAc7B;IAVC;;OAEG;IACH,eAPkB,OAAO,KAAE,CAAC,CAOR;IACpB;;;OAGG;IACH,GAFU,CAAC,GAAC,IAAI,CAEH;IACb,cAAc;IAGhB,QAUoB,CAAC,CACpB;CACF;AAED;IACE;;;OAGG;IACH,wBAHW,UAAU,SACV,MAAM,EAShB;IALC;;;OAGG;IACH,GAFU,MAAM,CAEF;IAGhB;;OAEG;IACH,QAFY,MAAM,CAKjB;CACF;AAED;IACE;;;OAGG;IACH,wBAHW,UAAU,SACV,MAAM,EAUhB;IANC;;;OAGG;IACH,GAFU,MAAM,CAEF;IACd,cAAc;IAGhB;;OAEG;IACH,QAFY,MAAM,CAajB;CACF;AAED;IACE;;OAEG;IACH,wBAFW,UAAU,EASpB;IALC;;OAEG;IACH,GAFU,MAAM,CAEN;IACV,cAAc;IAGhB,QAYoB,MAAM,CACzB;CACF;AAED;IACE;;OAEG;IACH,wBAFW,UAAU,EASpB;IALC;;OAEG;IACH,GAFU,MAAM,CAEN;IACV,cAAc;IAGhB,QAYoB,MAAM,CACzB;CACF;AAED;IACE;;OAEG;IACH,wBAFW,UAAU,EAUpB;IANC;;OAEG;IACH,GAFU,MAAM,CAEN;IACV,cAAc;IACd,aAAa;IAGf;;OAEG;IACH,QAFY,MAAM,CAgBjB;CACF;AAED;IACE;;OAEG;IACH,wBAFW,UAAU,EASpB;IANC,2BAAgD;IAChD,YAAsC;IACtC;;OAEG;IACH,MAFU,MAAM,CAEH;IAGf;;OAEG;IACH,QAFY,MAAM,CAOjB;CACF"}
|
||||
710
yjs-poll/node_modules/lib0/decoding.js
generated
vendored
Normal file
710
yjs-poll/node_modules/lib0/decoding.js
generated
vendored
Normal file
@@ -0,0 +1,710 @@
|
||||
/**
|
||||
* Efficient schema-less binary decoding with support for variable length encoding.
|
||||
*
|
||||
* Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.
|
||||
*
|
||||
* Encodes numbers in little-endian order (least to most significant byte order)
|
||||
* and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
|
||||
* which is also used in Protocol Buffers.
|
||||
*
|
||||
* ```js
|
||||
* // encoding step
|
||||
* const encoder = encoding.createEncoder()
|
||||
* encoding.writeVarUint(encoder, 256)
|
||||
* encoding.writeVarString(encoder, 'Hello world!')
|
||||
* const buf = encoding.toUint8Array(encoder)
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* // decoding step
|
||||
* const decoder = decoding.createDecoder(buf)
|
||||
* decoding.readVarUint(decoder) // => 256
|
||||
* decoding.readVarString(decoder) // => 'Hello world!'
|
||||
* decoding.hasContent(decoder) // => false - all data is read
|
||||
* ```
|
||||
*
|
||||
* @module decoding
|
||||
*/
|
||||
|
||||
import * as binary from './binary.js'
|
||||
import * as math from './math.js'
|
||||
import * as number from './number.js'
|
||||
import * as string from './string.js'
|
||||
import * as error from './error.js'
|
||||
import * as encoding from './encoding.js'
|
||||
|
||||
const errorUnexpectedEndOfArray = error.create('Unexpected end of array')
|
||||
const errorIntegerOutOfRange = error.create('Integer out of Range')
|
||||
|
||||
/**
|
||||
* A Decoder handles the decoding of an Uint8Array.
|
||||
* @template {ArrayBufferLike} [Buf=ArrayBufferLike]
|
||||
*/
|
||||
export class Decoder {
|
||||
/**
|
||||
* @param {Uint8Array<Buf>} uint8Array Binary data to decode
|
||||
*/
|
||||
constructor (uint8Array) {
|
||||
/**
|
||||
* Decoding target.
|
||||
*
|
||||
* @type {Uint8Array<Buf>}
|
||||
*/
|
||||
this.arr = uint8Array
|
||||
/**
|
||||
* Current decoding position.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
this.pos = 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @template {ArrayBufferLike} Buf
|
||||
* @param {Uint8Array<Buf>} uint8Array
|
||||
* @return {Decoder<Buf>}
|
||||
*/
|
||||
export const createDecoder = uint8Array => new Decoder(uint8Array)
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const hasContent = decoder => decoder.pos !== decoder.arr.length
|
||||
|
||||
/**
|
||||
* Clone a decoder instance.
|
||||
* Optionally set a new position parameter.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder The decoder instance
|
||||
* @param {number} [newPos] Defaults to current position
|
||||
* @return {Decoder} A clone of `decoder`
|
||||
*/
|
||||
export const clone = (decoder, newPos = decoder.pos) => {
|
||||
const _decoder = createDecoder(decoder.arr)
|
||||
_decoder.pos = newPos
|
||||
return _decoder
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Uint8Array view of the next `len` bytes and advance the position by `len`.
|
||||
*
|
||||
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
||||
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
||||
*
|
||||
* @function
|
||||
* @template {ArrayBufferLike} Buf
|
||||
* @param {Decoder<Buf>} decoder The decoder instance
|
||||
* @param {number} len The length of bytes to read
|
||||
* @return {Uint8Array<Buf>}
|
||||
*/
|
||||
export const readUint8Array = (decoder, len) => {
|
||||
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)
|
||||
decoder.pos += len
|
||||
return view
|
||||
}
|
||||
|
||||
/**
|
||||
* Read variable length Uint8Array.
|
||||
*
|
||||
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
||||
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
||||
*
|
||||
* @function
|
||||
* @template {ArrayBufferLike} Buf
|
||||
* @param {Decoder<Buf>} decoder
|
||||
* @return {Uint8Array<Buf>}
|
||||
*/
|
||||
export const readVarUint8Array = decoder => readUint8Array(decoder, readVarUint(decoder))
|
||||
|
||||
/**
|
||||
* Read the rest of the content as an ArrayBuffer
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
export const readTailAsUint8Array = decoder => readUint8Array(decoder, decoder.arr.length - decoder.pos)
|
||||
|
||||
/**
|
||||
* Skip one byte, jump to the next position.
|
||||
* @function
|
||||
* @param {Decoder} decoder The decoder instance
|
||||
* @return {number} The next position
|
||||
*/
|
||||
export const skip8 = decoder => decoder.pos++
|
||||
|
||||
/**
|
||||
* Read one byte as unsigned integer.
|
||||
* @function
|
||||
* @param {Decoder} decoder The decoder instance
|
||||
* @return {number} Unsigned 8-bit integer
|
||||
*/
|
||||
export const readUint8 = decoder => decoder.arr[decoder.pos++]
|
||||
|
||||
/**
|
||||
* Read 2 bytes as unsigned integer.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.
|
||||
*/
|
||||
export const readUint16 = decoder => {
|
||||
const uint =
|
||||
decoder.arr[decoder.pos] +
|
||||
(decoder.arr[decoder.pos + 1] << 8)
|
||||
decoder.pos += 2
|
||||
return uint
|
||||
}
|
||||
|
||||
/**
|
||||
* Read 4 bytes as unsigned integer.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.
|
||||
*/
|
||||
export const readUint32 = decoder => {
|
||||
const uint =
|
||||
(decoder.arr[decoder.pos] +
|
||||
(decoder.arr[decoder.pos + 1] << 8) +
|
||||
(decoder.arr[decoder.pos + 2] << 16) +
|
||||
(decoder.arr[decoder.pos + 3] << 24)) >>> 0
|
||||
decoder.pos += 4
|
||||
return uint
|
||||
}
|
||||
|
||||
/**
|
||||
* Read 4 bytes as unsigned integer in big endian order.
|
||||
* (most significant byte first)
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.
|
||||
*/
|
||||
export const readUint32BigEndian = decoder => {
|
||||
const uint =
|
||||
(decoder.arr[decoder.pos + 3] +
|
||||
(decoder.arr[decoder.pos + 2] << 8) +
|
||||
(decoder.arr[decoder.pos + 1] << 16) +
|
||||
(decoder.arr[decoder.pos] << 24)) >>> 0
|
||||
decoder.pos += 4
|
||||
return uint
|
||||
}
|
||||
|
||||
/**
|
||||
* Look ahead without incrementing the position
|
||||
* to the next byte and read it as unsigned integer.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.
|
||||
*/
|
||||
export const peekUint8 = decoder => decoder.arr[decoder.pos]
|
||||
|
||||
/**
|
||||
* Look ahead without incrementing the position
|
||||
* to the next byte and read it as unsigned integer.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.
|
||||
*/
|
||||
export const peekUint16 = decoder =>
|
||||
decoder.arr[decoder.pos] +
|
||||
(decoder.arr[decoder.pos + 1] << 8)
|
||||
|
||||
/**
|
||||
* Look ahead without incrementing the position
|
||||
* to the next byte and read it as unsigned integer.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.
|
||||
*/
|
||||
export const peekUint32 = decoder => (
|
||||
decoder.arr[decoder.pos] +
|
||||
(decoder.arr[decoder.pos + 1] << 8) +
|
||||
(decoder.arr[decoder.pos + 2] << 16) +
|
||||
(decoder.arr[decoder.pos + 3] << 24)
|
||||
) >>> 0
|
||||
|
||||
/**
|
||||
* Read unsigned integer (32bit) with variable length.
|
||||
* 1/8th of the storage is used as encoding overhead.
|
||||
* * numbers < 2^7 is stored in one bytlength
|
||||
* * numbers < 2^14 is stored in two bylength
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.length
|
||||
*/
|
||||
export const readVarUint = decoder => {
|
||||
let num = 0
|
||||
let mult = 1
|
||||
const len = decoder.arr.length
|
||||
while (decoder.pos < len) {
|
||||
const r = decoder.arr[decoder.pos++]
|
||||
// num = num | ((r & binary.BITS7) << len)
|
||||
num = num + (r & binary.BITS7) * mult // shift $r << (7*#iterations) and add it to num
|
||||
mult *= 128 // next iteration, shift 7 "more" to the left
|
||||
if (r < binary.BIT8) {
|
||||
return num
|
||||
}
|
||||
/* c8 ignore start */
|
||||
if (num > number.MAX_SAFE_INTEGER) {
|
||||
throw errorIntegerOutOfRange
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
throw errorUnexpectedEndOfArray
|
||||
}
|
||||
|
||||
/**
|
||||
* Read signed integer (32bit) with variable length.
|
||||
* 1/8th of the storage is used as encoding overhead.
|
||||
* * numbers < 2^7 is stored in one bytlength
|
||||
* * numbers < 2^14 is stored in two bylength
|
||||
* @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number} An unsigned integer.length
|
||||
*/
|
||||
export const readVarInt = decoder => {
|
||||
let r = decoder.arr[decoder.pos++]
|
||||
let num = r & binary.BITS6
|
||||
let mult = 64
|
||||
const sign = (r & binary.BIT7) > 0 ? -1 : 1
|
||||
if ((r & binary.BIT8) === 0) {
|
||||
// don't continue reading
|
||||
return sign * num
|
||||
}
|
||||
const len = decoder.arr.length
|
||||
while (decoder.pos < len) {
|
||||
r = decoder.arr[decoder.pos++]
|
||||
// num = num | ((r & binary.BITS7) << len)
|
||||
num = num + (r & binary.BITS7) * mult
|
||||
mult *= 128
|
||||
if (r < binary.BIT8) {
|
||||
return sign * num
|
||||
}
|
||||
/* c8 ignore start */
|
||||
if (num > number.MAX_SAFE_INTEGER) {
|
||||
throw errorIntegerOutOfRange
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
throw errorUnexpectedEndOfArray
|
||||
}
|
||||
|
||||
/**
|
||||
* Look ahead and read varUint without incrementing position
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number}
|
||||
*/
|
||||
export const peekVarUint = decoder => {
|
||||
const pos = decoder.pos
|
||||
const s = readVarUint(decoder)
|
||||
decoder.pos = pos
|
||||
return s
|
||||
}
|
||||
|
||||
/**
|
||||
* Look ahead and read varUint without incrementing position
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {number}
|
||||
*/
|
||||
export const peekVarInt = decoder => {
|
||||
const pos = decoder.pos
|
||||
const s = readVarInt(decoder)
|
||||
decoder.pos = pos
|
||||
return s
|
||||
}
|
||||
|
||||
/**
|
||||
* We don't test this function anymore as we use native decoding/encoding by default now.
|
||||
* Better not modify this anymore..
|
||||
*
|
||||
* Transforming utf8 to a string is pretty expensive. The code performs 10x better
|
||||
* when String.fromCodePoint is fed with all characters as arguments.
|
||||
* But most environments have a maximum number of arguments per functions.
|
||||
* For effiency reasons we apply a maximum of 10000 characters at once.
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {String} The read String.
|
||||
*/
|
||||
/* c8 ignore start */
|
||||
export const _readVarStringPolyfill = decoder => {
|
||||
let remainingLen = readVarUint(decoder)
|
||||
if (remainingLen === 0) {
|
||||
return ''
|
||||
} else {
|
||||
let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen
|
||||
if (--remainingLen < 100) { // do not create a Uint8Array for small strings
|
||||
while (remainingLen--) {
|
||||
encodedString += String.fromCodePoint(readUint8(decoder))
|
||||
}
|
||||
} else {
|
||||
while (remainingLen > 0) {
|
||||
const nextLen = remainingLen < 10000 ? remainingLen : 10000
|
||||
// this is dangerous, we create a fresh array view from the existing buffer
|
||||
const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen)
|
||||
decoder.pos += nextLen
|
||||
// Starting with ES5.1 we can supply a generic array-like object as arguments
|
||||
encodedString += String.fromCodePoint.apply(null, /** @type {any} */ (bytes))
|
||||
remainingLen -= nextLen
|
||||
}
|
||||
}
|
||||
return decodeURIComponent(escape(encodedString))
|
||||
}
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
/**
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {String} The read String
|
||||
*/
|
||||
export const _readVarStringNative = decoder =>
|
||||
/** @type any */ (string.utf8TextDecoder).decode(readVarUint8Array(decoder))
|
||||
|
||||
/**
|
||||
* Read string of variable length
|
||||
* * varUint is used to store the length of the string
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {String} The read String
|
||||
*
|
||||
*/
|
||||
/* c8 ignore next */
|
||||
export const readVarString = string.utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
export const readTerminatedUint8Array = decoder => {
|
||||
const encoder = encoding.createEncoder()
|
||||
let b
|
||||
while (true) {
|
||||
b = readUint8(decoder)
|
||||
if (b === 0) {
|
||||
return encoding.toUint8Array(encoder)
|
||||
}
|
||||
if (b === 1) {
|
||||
b = readUint8(decoder)
|
||||
}
|
||||
encoding.write(encoder, b)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
* @return {string}
|
||||
*/
|
||||
export const readTerminatedString = decoder => string.decodeUtf8(readTerminatedUint8Array(decoder))
|
||||
|
||||
/**
|
||||
* Look ahead and read varString without incrementing position
|
||||
*
|
||||
* @function
|
||||
* @param {Decoder} decoder
|
||||
* @return {string}
|
||||
*/
|
||||
export const peekVarString = decoder => {
|
||||
const pos = decoder.pos
|
||||
const s = readVarString(decoder)
|
||||
decoder.pos = pos
|
||||
return s
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
* @param {number} len
|
||||
* @return {DataView}
|
||||
*/
|
||||
export const readFromDataView = (decoder, len) => {
|
||||
const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len)
|
||||
decoder.pos += len
|
||||
return dv
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
*/
|
||||
export const readFloat32 = decoder => readFromDataView(decoder, 4).getFloat32(0, false)
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
*/
|
||||
export const readFloat64 = decoder => readFromDataView(decoder, 8).getFloat64(0, false)
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
*/
|
||||
export const readBigInt64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigInt64(0, false)
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
*/
|
||||
export const readBigUint64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigUint64(0, false)
|
||||
|
||||
/**
|
||||
* @type {Array<function(Decoder):any>}
|
||||
*/
|
||||
const readAnyLookupTable = [
|
||||
decoder => undefined, // CASE 127: undefined
|
||||
decoder => null, // CASE 126: null
|
||||
readVarInt, // CASE 125: integer
|
||||
readFloat32, // CASE 124: float32
|
||||
readFloat64, // CASE 123: float64
|
||||
readBigInt64, // CASE 122: bigint
|
||||
decoder => false, // CASE 121: boolean (false)
|
||||
decoder => true, // CASE 120: boolean (true)
|
||||
readVarString, // CASE 119: string
|
||||
decoder => { // CASE 118: object<string,any>
|
||||
const len = readVarUint(decoder)
|
||||
/**
|
||||
* @type {Object<string,any>}
|
||||
*/
|
||||
const obj = {}
|
||||
for (let i = 0; i < len; i++) {
|
||||
const key = readVarString(decoder)
|
||||
obj[key] = readAny(decoder)
|
||||
}
|
||||
return obj
|
||||
},
|
||||
decoder => { // CASE 117: array<any>
|
||||
const len = readVarUint(decoder)
|
||||
const arr = []
|
||||
for (let i = 0; i < len; i++) {
|
||||
arr.push(readAny(decoder))
|
||||
}
|
||||
return arr
|
||||
},
|
||||
readVarUint8Array // CASE 116: Uint8Array
|
||||
]
|
||||
|
||||
/**
|
||||
* @param {Decoder} decoder
|
||||
*/
|
||||
export const readAny = decoder => readAnyLookupTable[127 - readUint8(decoder)](decoder)
|
||||
|
||||
/**
|
||||
* T must not be null.
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
export class RleDecoder extends Decoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @param {function(Decoder):T} reader
|
||||
*/
|
||||
constructor (uint8Array, reader) {
|
||||
super(uint8Array)
|
||||
/**
|
||||
* The reader
|
||||
*/
|
||||
this.reader = reader
|
||||
/**
|
||||
* Current state
|
||||
* @type {T|null}
|
||||
*/
|
||||
this.s = null
|
||||
this.count = 0
|
||||
}
|
||||
|
||||
read () {
|
||||
if (this.count === 0) {
|
||||
this.s = this.reader(this)
|
||||
if (hasContent(this)) {
|
||||
this.count = readVarUint(this) + 1 // see encoder implementation for the reason why this is incremented
|
||||
} else {
|
||||
this.count = -1 // read the current value forever
|
||||
}
|
||||
}
|
||||
this.count--
|
||||
return /** @type {T} */ (this.s)
|
||||
}
|
||||
}
|
||||
|
||||
export class IntDiffDecoder extends Decoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @param {number} start
|
||||
*/
|
||||
constructor (uint8Array, start) {
|
||||
super(uint8Array)
|
||||
/**
|
||||
* Current state
|
||||
* @type {number}
|
||||
*/
|
||||
this.s = start
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
read () {
|
||||
this.s += readVarInt(this)
|
||||
return this.s
|
||||
}
|
||||
}
|
||||
|
||||
export class RleIntDiffDecoder extends Decoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
* @param {number} start
|
||||
*/
|
||||
constructor (uint8Array, start) {
|
||||
super(uint8Array)
|
||||
/**
|
||||
* Current state
|
||||
* @type {number}
|
||||
*/
|
||||
this.s = start
|
||||
this.count = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
read () {
|
||||
if (this.count === 0) {
|
||||
this.s += readVarInt(this)
|
||||
if (hasContent(this)) {
|
||||
this.count = readVarUint(this) + 1 // see encoder implementation for the reason why this is incremented
|
||||
} else {
|
||||
this.count = -1 // read the current value forever
|
||||
}
|
||||
}
|
||||
this.count--
|
||||
return /** @type {number} */ (this.s)
|
||||
}
|
||||
}
|
||||
|
||||
export class UintOptRleDecoder extends Decoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor (uint8Array) {
|
||||
super(uint8Array)
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.s = 0
|
||||
this.count = 0
|
||||
}
|
||||
|
||||
read () {
|
||||
if (this.count === 0) {
|
||||
this.s = readVarInt(this)
|
||||
// if the sign is negative, we read the count too, otherwise count is 1
|
||||
const isNegative = math.isNegativeZero(this.s)
|
||||
this.count = 1
|
||||
if (isNegative) {
|
||||
this.s = -this.s
|
||||
this.count = readVarUint(this) + 2
|
||||
}
|
||||
}
|
||||
this.count--
|
||||
return /** @type {number} */ (this.s)
|
||||
}
|
||||
}
|
||||
|
||||
export class IncUintOptRleDecoder extends Decoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor (uint8Array) {
|
||||
super(uint8Array)
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.s = 0
|
||||
this.count = 0
|
||||
}
|
||||
|
||||
read () {
|
||||
if (this.count === 0) {
|
||||
this.s = readVarInt(this)
|
||||
// if the sign is negative, we read the count too, otherwise count is 1
|
||||
const isNegative = math.isNegativeZero(this.s)
|
||||
this.count = 1
|
||||
if (isNegative) {
|
||||
this.s = -this.s
|
||||
this.count = readVarUint(this) + 2
|
||||
}
|
||||
}
|
||||
this.count--
|
||||
return /** @type {number} */ (this.s++)
|
||||
}
|
||||
}
|
||||
|
||||
export class IntDiffOptRleDecoder extends Decoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor (uint8Array) {
|
||||
super(uint8Array)
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.s = 0
|
||||
this.count = 0
|
||||
this.diff = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
read () {
|
||||
if (this.count === 0) {
|
||||
const diff = readVarInt(this)
|
||||
// if the first bit is set, we read more data
|
||||
const hasCount = diff & 1
|
||||
this.diff = math.floor(diff / 2) // shift >> 1
|
||||
this.count = 1
|
||||
if (hasCount) {
|
||||
this.count = readVarUint(this) + 2
|
||||
}
|
||||
}
|
||||
this.s += this.diff
|
||||
this.count--
|
||||
return this.s
|
||||
}
|
||||
}
|
||||
|
||||
export class StringDecoder {
|
||||
/**
|
||||
* @param {Uint8Array} uint8Array
|
||||
*/
|
||||
constructor (uint8Array) {
|
||||
this.decoder = new UintOptRleDecoder(uint8Array)
|
||||
this.str = readVarString(this.decoder)
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.spos = 0
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
read () {
|
||||
const end = this.spos + this.decoder.read()
|
||||
const res = this.str.slice(this.spos, end)
|
||||
this.spos = end
|
||||
return res
|
||||
}
|
||||
}
|
||||
107
yjs-poll/node_modules/lib0/delta/binding.d.ts
generated
vendored
Normal file
107
yjs-poll/node_modules/lib0/delta/binding.d.ts
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import('../schema.js').Schema<T>} Schema
|
||||
*/
|
||||
/**
|
||||
* @template {delta.AbstractDelta} DeltaA
|
||||
* @template {delta.AbstractDelta} DeltaB
|
||||
*/
|
||||
export class Binding<DeltaA extends delta.AbstractDelta, DeltaB extends delta.AbstractDelta> {
|
||||
/**
|
||||
* @param {RDT<DeltaA>} a
|
||||
* @param {RDT<DeltaB>} b
|
||||
* @param {dt.Template<any,DeltaA,DeltaB>} template
|
||||
*/
|
||||
constructor(a: RDT<DeltaA>, b: RDT<DeltaB>, template: dt.Template<any, DeltaA, DeltaB>);
|
||||
/**
|
||||
* @type {dt.Transformer<any,DeltaA,DeltaB>}
|
||||
*/
|
||||
t: dt.Transformer<any, DeltaA, DeltaB>;
|
||||
a: RDT<DeltaA>;
|
||||
b: RDT<DeltaB>;
|
||||
_mux: mux.mutex;
|
||||
_achanged: (delta: DeltaA) => void;
|
||||
_bchanged: (delta: DeltaB) => void;
|
||||
destroy: () => void;
|
||||
}
|
||||
export function bind<DeltaA extends delta.AbstractDelta, Transformer extends dt.Template<any, DeltaA, any>>(a: RDT<DeltaA>, b: RDT<Transformer extends dt.Template<any, DeltaA, infer DeltaB> ? DeltaB : never>, template: dt.Template<any, DeltaA, any>): Binding<DeltaA, Transformer extends dt.Template<any, DeltaA, infer DeltaB> ? DeltaB : never>;
|
||||
export function deltaRDT<Delta extends delta.AbstractDelta>($delta: Schema<Delta>): DeltaRDT<Delta>;
|
||||
export const $domDelta: any;
|
||||
export function domRDT(dom: Element): DomRDT<delta.RecursiveNode<string, {
|
||||
[key: string]: string;
|
||||
}, never, true>>;
|
||||
export type Schema<T> = import("../schema.js").Schema<T>;
|
||||
/**
|
||||
* Abstract Interface for a delta-based Replicated Data Type.
|
||||
*/
|
||||
export type RDT<Delta extends delta.AbstractDelta> = ObservableV2<{
|
||||
"change": (delta: Delta) => void;
|
||||
"destroy": (rdt: RDT<Delta>) => void;
|
||||
}> & {
|
||||
update: (delta: Delta) => any;
|
||||
destroy: () => void;
|
||||
};
|
||||
export type DomDelta = delta.RecursiveNode<string, {
|
||||
[key: string]: string;
|
||||
}, never, true>;
|
||||
import * as delta from './delta.js';
|
||||
import * as dt from './t3.test.js';
|
||||
import * as mux from '../mutex.js';
|
||||
/**
|
||||
* @template {delta.AbstractDelta} Delta
|
||||
* @implements RDT<Delta>
|
||||
* @extends {ObservableV2<{ change: (delta: Delta) => void, 'destroy': (rdt:DeltaRDT<Delta>)=>void }>}
|
||||
*/
|
||||
declare class DeltaRDT<Delta extends delta.AbstractDelta> extends ObservableV2<{
|
||||
change: (delta: Delta) => void;
|
||||
destroy: (rdt: DeltaRDT<Delta>) => void;
|
||||
}> implements RDT<Delta> {
|
||||
/**
|
||||
* @param {Schema<Delta>} $delta
|
||||
*/
|
||||
constructor($delta: Schema<Delta>);
|
||||
$delta: s.Schema<Delta>;
|
||||
/**
|
||||
* @type {Delta?}
|
||||
*/
|
||||
state: Delta | null;
|
||||
_mux: mux.mutex;
|
||||
/**
|
||||
* @param {Delta} delta
|
||||
*/
|
||||
update: (delta: Delta) => any;
|
||||
}
|
||||
/**
|
||||
* @typedef {delta.RecursiveNode<string, { [key:string]: string }, never, true>} DomDelta
|
||||
*/
|
||||
/**
|
||||
* @template {DomDelta} [D=DomDelta]
|
||||
* @implements RDT<D>
|
||||
* @extends {ObservableV2<{ change: (delta: D)=>void, destroy: (rdt:DomRDT<D>)=>void }>}>}
|
||||
*/
|
||||
declare class DomRDT<D extends DomDelta = delta.RecursiveNode<string, {
|
||||
[key: string]: string;
|
||||
}, never, true>> extends ObservableV2<{
|
||||
change: (delta: D) => void;
|
||||
destroy: (rdt: DomRDT<D>) => void;
|
||||
}> implements RDT<D> {
|
||||
/**
|
||||
* @param {Element} observedNode
|
||||
*/
|
||||
constructor(observedNode: Element);
|
||||
observedNode: Element;
|
||||
_mux: mux.mutex;
|
||||
observer: MutationObserver;
|
||||
/**
|
||||
* @param {MutationRecord[]} mutations
|
||||
*/
|
||||
_mutationHandler: (mutations: MutationRecord[]) => any;
|
||||
/**
|
||||
* @param {D} delta
|
||||
*/
|
||||
update: (delta: D) => void;
|
||||
}
|
||||
import { ObservableV2 } from '../observable.js';
|
||||
import * as s from '../schema.js';
|
||||
export {};
|
||||
//# sourceMappingURL=binding.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/delta/binding.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/delta/binding.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["binding.js"],"names":[],"mappings":"AAeA;;;GAGG;AAEH;;;GAGG;AACH,qBAHmC,MAAM,SAA3B,KAAK,CAAC,aAAc,EACC,MAAM,SAA3B,KAAK,CAAC,aAAc;IAGhC;;;;OAIG;IACH,eAJW,GAAG,CAAC,MAAM,CAAC,KACX,GAAG,CAAC,MAAM,CAAC,YACX,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAC,MAAM,EAAC,MAAM,CAAC,EA4BxC;IAzBC;;OAEG;IACH,GAFU,EAAE,CAAC,WAAW,CAAC,GAAG,EAAC,MAAM,EAAC,MAAM,CAAC,CAEnB;IACxB,eAAU;IACV,eAAU;IACV,gBAA6B;IAC7B,8BAgCoD,IAAI,CAxBrD;IACH,8BAuBoD,IAAI,CAfrD;IAGL,oBAKC;CACF;AAgBM,qBAN4B,MAAM,SAA3B,KAAK,CAAC,aAAc,EACS,WAAW,SAAxC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAC,MAAM,EAAC,GAAG,CAAE,KAC/B,GAAG,CAAC,MAAM,CAAC,KACX,GAAG,CAAC,WAAW,SAAS,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,YAC9E,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAC,MAAM,EAAC,GAAG,CAAC,sEAD0B,MAAM,oBAGH;AA2C5D,yBAH4B,KAAK,SAA1B,KAAK,CAAC,aAAc,UACvB,MAAM,CAAC,KAAK,CAAC,mBAE8B;AAkGtD,4BAA+H;AAsJxH,4BAFI,OAAO;;iBAE0B;mBAnW/B,CAAC,IACD,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;;;;gBAoDV,KAAK,SAA1B,KAAK,CAAC,aAAc,IACrB,YAAY,CAAC;IAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAAC,SAAS,EAAE,CAAC,GAAG,EAAC,GAAG,CAAC,KAAK,CAAC,KAAG,IAAI,CAAA;CAAE,CAAC,GAAG;IAAE,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE;uBAkP9I,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE;IAAE,CAAC,GAAG,EAAC,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,IAAI,CAAC;uBAnTxD,YAAY;oBACf,cAAc;qBAMb,aAAa;AAsElC;;;;GAIG;AACH,uBAJmC,KAAK,SAA1B,KAAK,CAAC,aAAc;YAEE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;aAAa,CAAC,GAAG,EAAC,QAAQ,CAAC,KAAK,CAAC,KAAG,IAAI;cADnF,GAAG,CAAC,KAAK;IAItB;;OAEG;IACH,oBAFW,MAAM,CAAC,KAAK,CAAC,EAUvB;IANC,wBAAoB;IACpB;;OAEG;IACH,OAFU,KAAK,OAAC,CAEC;IACjB,gBAA6B;IAG/B;;OAEG;IACH,SAAS,OAFE,KAEG,SAOZ;CAMH;AAkMD;;GAEG;AAEH;;;;GAIG;AACH,qBAJyB,CAAC,SAAZ,QAAS;;;YAEa,CAAC,KAAK,EAAE,CAAC,KAAG,IAAI;aAAW,CAAC,GAAG,EAAC,MAAM,CAAC,CAAC,CAAC,KAAG,IAAI;cADrE,GAAG,CAAC,CAAC;IAIlB;;OAEG;IACH,0BAFW,OAAO,EAajB;IATC,sBAAgC;IAChC,gBAA6B;IAC7B,2BAA2D;IAS7D;;OAEG;IACH,mBAAmB,WAFR,cAAc,EAEG,SAGxB;IAEJ;;OAEG;IACH,SAAS,OAFE,CAEG,UAWb;CAOF;6BA1W4B,kBAAkB;mBAS5B,cAAc"}
|
||||
372
yjs-poll/node_modules/lib0/delta/binding.js
generated
vendored
Normal file
372
yjs-poll/node_modules/lib0/delta/binding.js
generated
vendored
Normal file
@@ -0,0 +1,372 @@
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
// @todo remove all @ts-nocheck and eslint-disable
|
||||
/* global MutationObserver */
|
||||
import { ObservableV2 } from '../observable.js'
|
||||
import * as delta from './delta.js'
|
||||
import * as dt from './t3.test.js' // eslint-disable-line
|
||||
import * as dom from '../dom.js'
|
||||
import * as set from '../set.js'
|
||||
import * as map from '../map.js'
|
||||
import * as error from '../error.js'
|
||||
import * as math from '../math.js'
|
||||
import * as mux from '../mutex.js'
|
||||
import * as s from '../schema.js'
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import('../schema.js').Schema<T>} Schema
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {delta.AbstractDelta} DeltaA
|
||||
* @template {delta.AbstractDelta} DeltaB
|
||||
*/
|
||||
export class Binding {
|
||||
/**
|
||||
* @param {RDT<DeltaA>} a
|
||||
* @param {RDT<DeltaB>} b
|
||||
* @param {dt.Template<any,DeltaA,DeltaB>} template
|
||||
*/
|
||||
constructor (a, b, template) {
|
||||
/**
|
||||
* @type {dt.Transformer<any,DeltaA,DeltaB>}
|
||||
*/
|
||||
this.t = template.init()
|
||||
this.a = a
|
||||
this.b = b
|
||||
this._mux = mux.createMutex()
|
||||
this._achanged = this.a.on('change', d => this._mux(() => {
|
||||
const tres = this.t.applyA(d)
|
||||
if (tres.a) {
|
||||
a.update(tres.a)
|
||||
}
|
||||
if (tres.b) {
|
||||
b.update(tres.b)
|
||||
}
|
||||
}))
|
||||
this._bchanged = this.b.on('change', d => this._mux(() => {
|
||||
const tres = this.t.applyB(d)
|
||||
if (tres.b) {
|
||||
this.b.update(tres.b)
|
||||
}
|
||||
if (tres.a) {
|
||||
a.update(tres.a)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
destroy = () => {
|
||||
this.a.off('destroy', this.destroy)
|
||||
this.b.off('destroy', this.destroy)
|
||||
this.a.off('change', this._achanged)
|
||||
this.b.off('change', this._bchanged)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract Interface for a delta-based Replicated Data Type.
|
||||
*
|
||||
* @template {delta.AbstractDelta} Delta
|
||||
* @typedef {ObservableV2<{ 'change': (delta: Delta) => void, 'destroy': (rdt:RDT<Delta>)=>void }> & { update: (delta: Delta) => any, destroy: () => void }} RDT
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {delta.AbstractDelta} DeltaA
|
||||
* @template {dt.Template<any,DeltaA,any>} Transformer
|
||||
* @param {RDT<DeltaA>} a
|
||||
* @param {RDT<Transformer extends dt.Template<any,DeltaA,infer DeltaB> ? DeltaB : never>} b
|
||||
* @param {dt.Template<any,DeltaA,any>} template
|
||||
*/
|
||||
export const bind = (a, b, template) => new Binding(a, b, template)
|
||||
|
||||
/**
|
||||
* @template {delta.AbstractDelta} Delta
|
||||
* @implements RDT<Delta>
|
||||
* @extends {ObservableV2<{ change: (delta: Delta) => void, 'destroy': (rdt:DeltaRDT<Delta>)=>void }>}
|
||||
*/
|
||||
class DeltaRDT extends ObservableV2 {
|
||||
/**
|
||||
* @param {Schema<Delta>} $delta
|
||||
*/
|
||||
constructor ($delta) {
|
||||
super()
|
||||
this.$delta = $delta
|
||||
/**
|
||||
* @type {Delta?}
|
||||
*/
|
||||
this.state = null
|
||||
this._mux = mux.createMutex()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Delta} delta
|
||||
*/
|
||||
update = delta => delta.isEmpty() || this._mux(() => {
|
||||
if (this.state != null) {
|
||||
this.state.apply(delta)
|
||||
} else {
|
||||
this.state = delta
|
||||
}
|
||||
this.emit('change', [delta])
|
||||
})
|
||||
|
||||
destroy () {
|
||||
this.emit('destroy', [this])
|
||||
super.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {delta.AbstractDelta} Delta
|
||||
* @param {Schema<Delta>} $delta
|
||||
*/
|
||||
export const deltaRDT = $delta => new DeltaRDT($delta)
|
||||
|
||||
/**
|
||||
* @param {Node} domNode
|
||||
*/
|
||||
const domToDelta = domNode => {
|
||||
if (dom.$element.check(domNode)) {
|
||||
const d = delta.node(domNode.nodeName.toLowerCase())
|
||||
for (let i = 0; i < domNode.attributes.length; i++) {
|
||||
const attr = /** @type {Attr} */ (domNode.attributes.item(i))
|
||||
d.attributes.set(attr.nodeName, attr.value)
|
||||
}
|
||||
domNode.childNodes.forEach(child => {
|
||||
d.children.insert(dom.$text.check(child) ? child.textContent : [domToDelta(child)])
|
||||
})
|
||||
return d
|
||||
}
|
||||
error.unexpectedCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {DomDelta} d
|
||||
*/
|
||||
const deltaToDom = d => {
|
||||
if (delta.$nodeAny.check(d)) {
|
||||
const n = dom.element(d.name)
|
||||
d.attributes.forEach(change => {
|
||||
if (delta.$insertOp.check(change)) {
|
||||
n.setAttribute(change.key, change.value)
|
||||
}
|
||||
})
|
||||
d.children.forEach(child => {
|
||||
if (delta.$insertOp.check(child)) {
|
||||
n.append(...child.insert.map(deltaToDom))
|
||||
} else if (delta.$textOp.check(child)) {
|
||||
n.append(dom.text(child.insert))
|
||||
}
|
||||
})
|
||||
return n
|
||||
}
|
||||
error.unexpectedCase()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} el
|
||||
* @param {delta.Node<string,any,any,any>} d
|
||||
*/
|
||||
const applyDeltaToDom = (el, d) => {
|
||||
d.attributes.forEach(change => {
|
||||
if (delta.$deleteOp.check(change)) {
|
||||
el.removeAttribute(change.key)
|
||||
} else {
|
||||
el.setAttribute(change.key, change.value)
|
||||
}
|
||||
})
|
||||
let childIndex = 0
|
||||
let childOffset = 0
|
||||
d.children.forEach(change => {
|
||||
let child = el.childNodes[childIndex] || null
|
||||
if (delta.$deleteOp.check(change)) {
|
||||
let len = change.length
|
||||
while (len > 0) {
|
||||
if (dom.$element.check(child)) {
|
||||
child.remove()
|
||||
len--
|
||||
} else if (dom.$text.check(child)) {
|
||||
const childLen = child.length
|
||||
if (childOffset === 0 && childLen <= len) {
|
||||
child.remove()
|
||||
len -= childLen
|
||||
} else {
|
||||
const spliceLen = math.min(len, childLen - childOffset)
|
||||
child.deleteData(childOffset, spliceLen)
|
||||
if (child.length <= childOffset) {
|
||||
childOffset = 0
|
||||
childIndex++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (delta.$insertOp.check(change)) {
|
||||
if (childOffset > 0) {
|
||||
const tchild = dom.$text.cast(child)
|
||||
child = tchild.splitText(childOffset)
|
||||
childIndex++
|
||||
childOffset = 0
|
||||
}
|
||||
el.insertBefore(dom.fragment(change.insert.map(deltaToDom)), child)
|
||||
} else if (delta.$modifyOp.check(change)) {
|
||||
applyDeltaToDom(dom.$element.cast(child), change.modify)
|
||||
} else if (delta.$textOp.check(change)) {
|
||||
el.insertBefore(dom.text(change.insert), child)
|
||||
} else {
|
||||
error.unexpectedCase()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const $domDelta = delta.$node(s.$string, s.$record(s.$string, s.$string), s.$never, { recursive: true, withText: true })
|
||||
|
||||
/**
|
||||
* @param {Element} observedNode
|
||||
* @param {MutationRecord[]} mutations
|
||||
* @param {any} origin assign this origin to the generated delta
|
||||
*/
|
||||
const _mutationsToDelta = (observedNode, mutations, origin) => {
|
||||
/**
|
||||
* @typedef {{ removedBefore: Map<Node?,number>, added: Set<Node>, modified: number, d: delta.Node }} ChangedNodeInfo
|
||||
*/
|
||||
/**
|
||||
* Compute all deltas without recursion.
|
||||
*
|
||||
* 1. mark all changed parents in parentsChanged
|
||||
* 2. fill out necessary information for each changed parent ()
|
||||
*/
|
||||
//
|
||||
/**
|
||||
* @type {Map<Node,ChangedNodeInfo>}
|
||||
*/
|
||||
const changedNodes = map.create()
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @return {ChangedNodeInfo}
|
||||
*/
|
||||
const getChangedNodeInfo = node => map.setIfUndefined(changedNodes, node, () => ({ removedBefore: map.create(), added: set.create(), modified: 0, d: delta.node(node.nodeName.toLowerCase()) }))
|
||||
const observedNodeInfo = getChangedNodeInfo(observedNode)
|
||||
mutations.forEach(mutation => {
|
||||
const target = /** @type {HTMLElement} */ (mutation.target)
|
||||
const parent = target.parentNode
|
||||
const attrName = /** @type {string} */ (mutation.attributeName)
|
||||
const newVal = target.getAttribute(attrName)
|
||||
const info = getChangedNodeInfo(target)
|
||||
const d = info.d
|
||||
// go up the tree and mark that a child has been modified
|
||||
for (let changedParent = parent; changedParent != null && getChangedNodeInfo(changedParent).modified++ > 1 && changedParent !== observedNode; changedParent = changedParent.parentNode) {
|
||||
// nop
|
||||
}
|
||||
switch (mutation.type) {
|
||||
case 'attributes': {
|
||||
const attrs = /** @type {delta.Node<any,any,any>} */ (d).attributes
|
||||
if (newVal == null) {
|
||||
attrs.delete(attrName)
|
||||
} else {
|
||||
attrs.set(/** @type {string} */ (attrName), newVal)
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'characterData': {
|
||||
error.methodUnimplemented()
|
||||
break
|
||||
}
|
||||
case 'childList': {
|
||||
const targetInfo = getChangedNodeInfo(target)
|
||||
mutation.addedNodes.forEach(node => {
|
||||
targetInfo.added.add(node)
|
||||
})
|
||||
const removed = mutation.removedNodes.length
|
||||
if (removed > 0) {
|
||||
// @todo this can't work because next can be null
|
||||
targetInfo.removedBefore.set(mutation.nextSibling, removed)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
changedNodes.forEach((info, node) => {
|
||||
const numOfChildChanges = info.modified + info.removedBefore.size + info.added.size
|
||||
const d = /** @type {delta.Node<any,any,any>} */ (info.d)
|
||||
if (numOfChildChanges > 0) {
|
||||
node.childNodes.forEach(nchild => {
|
||||
if (info.removedBefore.has(nchild)) { // can happen separately
|
||||
d.children.delete(/** @type {number} */ (info.removedBefore.get(nchild)))
|
||||
}
|
||||
if (info.added.has(nchild)) {
|
||||
d.children.insert(dom.$text.check(nchild) ? nchild.textContent : [domToDelta(nchild)])
|
||||
} else if (changedNodes.has(nchild)) {
|
||||
d.children.modify(getChangedNodeInfo(nchild).d)
|
||||
}
|
||||
})
|
||||
// remove items to the end, if necessary
|
||||
d.children.delete(info.removedBefore.get(null) ?? 0)
|
||||
}
|
||||
d.done()
|
||||
})
|
||||
observedNodeInfo.d.origin = origin
|
||||
return observedNodeInfo.d
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {delta.RecursiveNode<string, { [key:string]: string }, never, true>} DomDelta
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {DomDelta} [D=DomDelta]
|
||||
* @implements RDT<D>
|
||||
* @extends {ObservableV2<{ change: (delta: D)=>void, destroy: (rdt:DomRDT<D>)=>void }>}>}
|
||||
*/
|
||||
class DomRDT extends ObservableV2 {
|
||||
/**
|
||||
* @param {Element} observedNode
|
||||
*/
|
||||
constructor (observedNode) {
|
||||
super()
|
||||
this.observedNode = observedNode
|
||||
this._mux = mux.createMutex()
|
||||
this.observer = new MutationObserver(this._mutationHandler)
|
||||
this.observer.observe(observedNode, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
characterDataOldValue: true
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {MutationRecord[]} mutations
|
||||
*/
|
||||
_mutationHandler = mutations =>
|
||||
mutations.length > 0 && this._mux(() => {
|
||||
this.emit('change', [/** @type {D} */(_mutationsToDelta(this.observedNode, mutations, this))])
|
||||
})
|
||||
|
||||
/**
|
||||
* @param {D} delta
|
||||
*/
|
||||
update = delta => {
|
||||
if (delta.origin !== this) {
|
||||
// @todo the retrieved changes must be transformed agains the updated changes. need a proper
|
||||
// transaction system
|
||||
this._mutationHandler(this.observer.takeRecords())
|
||||
this._mux(() => {
|
||||
applyDeltaToDom(this.observedNode, delta)
|
||||
const mutations = this.observer.takeRecords()
|
||||
this.emit('change', [/** @type {D} */(_mutationsToDelta(this.observedNode, mutations, delta.origin))])
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.emit('destroy', [this])
|
||||
super.destroy()
|
||||
this.observer.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} dom
|
||||
*/
|
||||
export const domRDT = dom => new DomRDT(dom)
|
||||
5
yjs-poll/node_modules/lib0/delta/binding.test.d.ts
generated
vendored
Normal file
5
yjs-poll/node_modules/lib0/delta/binding.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export function testBinding(): void;
|
||||
export function testDomBindingBasics(): void;
|
||||
export function testDomBindingBackAndForth(): void;
|
||||
export function testDataToDom(): void;
|
||||
//# sourceMappingURL=binding.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/delta/binding.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/delta/binding.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"binding.test.d.ts","sourceRoot":"","sources":["binding.test.js"],"names":[],"mappings":"AAUO,oCAcN;AAEM,6CAcN;AAEM,mDAkCN;AAEM,sCAiBN"}
|
||||
5
yjs-poll/node_modules/lib0/delta/delta-pitch.test.d.ts
generated
vendored
Normal file
5
yjs-poll/node_modules/lib0/delta/delta-pitch.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export function testDeltaBasics(_tc: t.TestCase): void;
|
||||
export function testDeltaBasicSchema(_tc: t.TestCase): void;
|
||||
export function testDeltaValues(_tc: t.TestCase): void;
|
||||
import * as t from 'lib0/testing';
|
||||
//# sourceMappingURL=delta-pitch.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/delta/delta-pitch.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/delta/delta-pitch.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"delta-pitch.test.d.ts","sourceRoot":"","sources":["delta-pitch.test.js"],"names":[],"mappings":"AAmCO,qCAFI,CAAC,CAAC,QAAQ,QAWpB;AAmBM,0CAFI,CAAC,CAAC,QAAQ,QAWpB;AAYM,qCAFI,CAAC,CAAC,QAAQ,QAwBpB;mBAzGkB,cAAc"}
|
||||
1008
yjs-poll/node_modules/lib0/delta/delta.d.ts
generated
vendored
Normal file
1008
yjs-poll/node_modules/lib0/delta/delta.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
yjs-poll/node_modules/lib0/delta/delta.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/delta/delta.d.ts.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2362
yjs-poll/node_modules/lib0/delta/delta.js
generated
vendored
Normal file
2362
yjs-poll/node_modules/lib0/delta/delta.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
29
yjs-poll/node_modules/lib0/delta/delta.test.d.ts
generated
vendored
Normal file
29
yjs-poll/node_modules/lib0/delta/delta.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
export function testDeltaBasicApi(_tc: t.TestCase): void;
|
||||
export function testDeltaValues(_tc: t.TestCase): void;
|
||||
export function testDeltaBasicCases(): void;
|
||||
export function testDeltaArrayBasics(): void;
|
||||
export function testAssignability(): void;
|
||||
export function testText(): void;
|
||||
export function testDelta(_tc: t.TestCase): void;
|
||||
export function testDeltaMerging(_tc: t.TestCase): void;
|
||||
export function testUseAttributes(_tc: t.TestCase): void;
|
||||
export function testUseAttribution(_tc: t.TestCase): void;
|
||||
export function testMapTyping(): void;
|
||||
export function testMapDeltaBasics(_tc: t.TestCase): void;
|
||||
export function testMapDeltaModify(_tc: t.TestCase): void;
|
||||
export function testMapDelta(_tc: t.TestCase): void;
|
||||
export function testRepeatRebaseMergeDeltas(tc: t.TestCase): void;
|
||||
export function testNodeDelta(_tc: t.TestCase): void;
|
||||
export function testRecursiveNode(): void;
|
||||
export function testSimplifiedDeltaSchemaDefinition(): void;
|
||||
export function testDiffing(): void;
|
||||
export function testDiffingCommonPreSuffix(): void;
|
||||
export function testSlice(): void;
|
||||
export function testRepeatRandomListDiff(tc: t.TestCase): void;
|
||||
export function testRepeatRandomMapDiff(tc: t.TestCase): void;
|
||||
export function testDeltaAppend(_tc: t.TestCase): void;
|
||||
export function testDeltaDiffWithFormatting(): void;
|
||||
export function testDeltaDiffWithFormatting2(): void;
|
||||
export function testDeltaDiffIssue1(): void;
|
||||
import * as t from 'lib0/testing';
|
||||
//# sourceMappingURL=delta.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/delta/delta.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/delta/delta.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"delta.test.d.ts","sourceRoot":"","sources":["delta.test.js"],"names":[],"mappings":"AAqCO,uCAFI,CAAC,CAAC,QAAQ,QAWpB;AAYM,qCAFI,CAAC,CAAC,QAAQ,QAwBpB;AAEM,4CA2BN;AAEM,6CAMN;AAKM,0CAkJN;AAEM,iCAWN;AAKM,+BAFI,CAAC,CAAC,QAAQ,QAKpB;AAKM,sCAFI,CAAC,CAAC,QAAQ,QAYpB;AAKM,uCAFI,CAAC,CAAC,QAAQ,QAuBpB;AAKM,wCAFI,CAAC,CAAC,QAAQ,QAsBpB;AAEM,sCAaN;AAKM,wCAFI,CAAC,CAAC,QAAQ,QA4BpB;AAKM,wCAFI,CAAC,CAAC,QAAQ,QA2CpB;AAKM,kCAFI,CAAC,CAAC,QAAQ,QAqDpB;AAKM,gDAFI,CAAC,CAAC,QAAQ,QAoEpB;AAKM,mCAFI,CAAC,CAAC,QAAQ,QAiCpB;AAEM,0CAmBN;AAEM,4DAIN;AAEM,oCAMN;AAEM,mDAMN;AAEM,kCAGN;AAKM,6CAFI,CAAC,CAAC,QAAQ,QAWpB;AAKM,4CAFI,CAAC,CAAC,QAAQ,QAWpB;AAKM,qCAFI,CAAC,CAAC,QAAQ,QAQpB;AAEM,oDAKN;AAEM,qDAKN;AAEM,4CAQN;mBAjtBkB,cAAc"}
|
||||
129
yjs-poll/node_modules/lib0/delta/readme.md
generated
vendored
Normal file
129
yjs-poll/node_modules/lib0/delta/readme.md
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
# Deltas
|
||||
|
||||
- Enable you to efficiently represent changes on all kinds of data structures.
|
||||
- Support schemas
|
||||
- Support OT-style conflict resolution `delta2.apply(delta1.rebase(delta2, true)) === delta1.apply(delta2.rebase(delta1, false))`
|
||||
- nice typings
|
||||
|
||||
## Delta for Map-like structures
|
||||
|
||||
```javascript
|
||||
// define schema
|
||||
const $d = delta.$delta(s.$any, { attr1: s.$string, attr2: s.$number })
|
||||
const d = delta.create($d)
|
||||
|
||||
|
||||
// create an update
|
||||
const update = delta.create().set('attr1', 'val1').set('attr2', 42)
|
||||
d.apply(update)
|
||||
|
||||
// In case of an invalid update
|
||||
const update2 = delta.create().set('attr1', 42)
|
||||
// it is possible to check an update beforehand
|
||||
$d.check(update2) // => false
|
||||
// and you also get type errors
|
||||
d.apply(update2) // type error: expected 'attr1' to be of type string
|
||||
```
|
||||
|
||||
## Delta for Text-like structures
|
||||
|
||||
Text-like deltas work similarly to [Quill Deltas]{https://quilljs.com/docs/delta}
|
||||
|
||||
```javascript
|
||||
// define schema
|
||||
const $d = delta.$delta(s.$any, null, s.$string)
|
||||
const d = delta.create($d).insert('hello world')
|
||||
|
||||
// create an update
|
||||
const update = delta.create().retain(11).insert('!')
|
||||
d.apply(update)
|
||||
|
||||
// In case of an invalid update
|
||||
const update2 = delta.create().insert([{ some: 'object' }])
|
||||
// it is possible to check an update beforehando
|
||||
$d.check(update2) // => false
|
||||
// and you also get type errors
|
||||
d.apply(update2) // type error: unexpected attribute 'attr1'
|
||||
```
|
||||
|
||||
## Delta for Array-like structures
|
||||
|
||||
```javascript
|
||||
// define schema
|
||||
const $d = delta.$delta(s.$any, null, s.$array(s.object({ some: s.$string }, s.$string)))
|
||||
const d = delta.create($d).insert(['hello world'])
|
||||
|
||||
// create an update
|
||||
const update = delta.create().retain(1).insert({ some: 'object' })
|
||||
d.apply(update)
|
||||
|
||||
// In case of an invalid update
|
||||
const update2 = delta.create().insert([{ unknown: 'prop' }])
|
||||
// it is possible to check an update beforehando
|
||||
$d.check(update2) // => false
|
||||
// and you also get type errors
|
||||
d.apply(update2) // type error: { unknown: 'prop' } is not assignable to { some: string }
|
||||
```
|
||||
|
||||
## Delta for Node-like structures (similar to XML,Trees with named nodes)
|
||||
|
||||
```javascript
|
||||
// define schema for a 'p'|'h1' node that may contain text or other instances of itself
|
||||
const $d = delta.$delta(s.$literal('div', 'p', 'h1'), { style: s.$string }, s.$string, true))
|
||||
const d = delta.create('div', $d)
|
||||
|
||||
// create an update - insert paragraph into the <div>
|
||||
const update = delta.create().insert([delta.create('p', { style: 'bold: true' }, 'hello world')])
|
||||
d.apply(update)
|
||||
|
||||
// modify the paragraph by deleting the text 'world' and appending '!'
|
||||
d.apply(delta.create().modify(
|
||||
delta.create().retain(6).delete(5).insert('!')
|
||||
))
|
||||
```
|
||||
|
||||
# Transformers
|
||||
|
||||
We often have two different data structures that we want to sync. There might be
|
||||
slight differences between those data structures. I.e. we might have a Yjs data
|
||||
structure containing the following content:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* {
|
||||
* headline: {{ headline }},
|
||||
* content: {{ content }}
|
||||
* }
|
||||
*/
|
||||
const $data = s.$delta(null, { headline: s.$string, content: s.$string })
|
||||
```
|
||||
|
||||
A typical scenario is that we want to sync that to the dom and back. "two-way bindings"
|
||||
- When the Yjs struucture updates, we want to sync the changes to the dom.
|
||||
- When the dom is updated (because the dom is a `contenteditable` editor), we
|
||||
want to sync back the changes to the yjs structure.
|
||||
|
||||
Now, the dom might look like this:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* <div>
|
||||
* <h1 style='some custom style'>{{headline}}</h1>
|
||||
* <span>dturianed</span>
|
||||
* <p>{{content}}</p>
|
||||
* </div>
|
||||
*/
|
||||
```
|
||||
|
||||
We can achieve automattic back-and-forth transformations with delta
|
||||
transformers:
|
||||
|
||||
```javascript
|
||||
const Λdata = Λ.transform($data, $d =>
|
||||
Λ.delta('div', {}, [
|
||||
Λ.delta('h1', { style: 'bold:true' }, [Λ.query('headline')($d)], []),
|
||||
Λ.delta('p', null, [Λ.query('content')($d)])
|
||||
])
|
||||
)
|
||||
```
|
||||
|
||||
19
yjs-poll/node_modules/lib0/delta/t3.test.d.ts
generated
vendored
Normal file
19
yjs-poll/node_modules/lib0/delta/t3.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export function transformResult<DeltaA extends delta.DeltaBuilder | null, DeltaB extends delta.DeltaBuilder | null>(a: DeltaA, b: DeltaB): TransformResult<DeltaA | null, DeltaB | null>;
|
||||
export const transformResultEmpty: TransformResult<null, null>;
|
||||
export type TransformResult<DeltaA extends delta.Delta | null, DeltaB extends delta.Delta | null> = {
|
||||
a: DeltaA | null;
|
||||
b: DeltaB | null;
|
||||
};
|
||||
export type DeltaTransformer<DeltaA extends delta.DeltaAny, DeltaB extends delta.DeltaAny> = (t: {
|
||||
a: DeltaA | null;
|
||||
b: DeltaB | null;
|
||||
}) => ({
|
||||
a: DeltaA | null;
|
||||
b: DeltaB | null;
|
||||
});
|
||||
export type Transform<DeltaA extends delta.Delta, DeltaB extends delta.Delta> = {
|
||||
applyA: (da: DeltaA) => TransformResult<DeltaA, DeltaB>;
|
||||
applyB: (db: DeltaB) => TransformResult<DeltaA, DeltaB>;
|
||||
};
|
||||
import * as delta from './delta.js';
|
||||
//# sourceMappingURL=t3.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/delta/t3.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/delta/t3.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"t3.test.d.ts","sourceRoot":"","sources":["t3.test.js"],"names":[],"mappings":"AAoBO,gCAN4B,MAAM,SAA3B,KAAK,CAAC,YAAY,OAAE,EACC,MAAM,SAA3B,KAAK,CAAC,YAAY,OAAE,KACvB,MAAM,KACN,MAAM,GACL,eAAe,CAAC,MAAM,OAAC,EAAC,MAAM,OAAC,CAAC,CAEO;AACnD,+DAA+D;4BAbnC,MAAM,SAApB,KAAK,CAAC,KAAK,OAAE,EACC,MAAM,SAApB,KAAK,CAAC,KAAK,OAAE,IACd;IAAE,CAAC,EAAE,MAAM,OAAC,CAAC;IAAC,CAAC,EAAE,MAAM,OAAC,CAAA;CAAE;6BAiBT,MAAM,SAAtB,KAAK,CAAC,QAAS,EACC,MAAM,SAAtB,KAAK,CAAC,QAAS,IAChB,CAAC,CAAC,EAAC;IAAC,CAAC,EAAC,MAAM,OAAC,CAAC;IAAA,CAAC,EAAC,MAAM,OAAC,CAAA;CAAC,KAAG,CAAC;IAAC,CAAC,EAAC,MAAM,OAAC,CAAC;IAAA,CAAC,EAAC,MAAM,OAAC,CAAA;CAAC,CAAC;sBA2GpC,MAAM,SAAnB,KAAK,CAAC,KAAM,EACC,MAAM,SAAnB,KAAK,CAAC,KAAM,IACb;IAAE,MAAM,EAAE,CAAC,EAAE,EAAC,MAAM,KAAG,eAAe,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,CAAC,EAAE,EAAC,MAAM,KAAG,eAAe,CAAC,MAAM,EAAC,MAAM,CAAC,CAAA;CAAE;uBAvIlG,YAAY"}
|
||||
12
yjs-poll/node_modules/lib0/deno.json
generated
vendored
Normal file
12
yjs-poll/node_modules/lib0/deno.json
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"imports": {
|
||||
"isomorphic.js": "./node_modules/isomorphic.js/node.mjs",
|
||||
"lib0/logging": "./logging.node.js",
|
||||
"lib0/performance": "./performance.node.js",
|
||||
"lib0/crypto/aes-gcm": "./crypto/aes-gcm.js",
|
||||
"lib0/crypto/rsa-oaep": "./crypto/rsa-oaep.js",
|
||||
"lib0/crypto/ecdsa": "./crypto/ecdsa.js",
|
||||
"lib0/crypto/jwt": "./crypto/jwt.js",
|
||||
"lib0/webcrypto": "./webcrypto.deno.js"
|
||||
}
|
||||
}
|
||||
122
yjs-poll/node_modules/lib0/deno.lock
generated
vendored
Normal file
122
yjs-poll/node_modules/lib0/deno.lock
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"version": "2",
|
||||
"remote": {
|
||||
"https://deno.land/std@0.177.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462",
|
||||
"https://deno.land/std@0.177.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3",
|
||||
"https://deno.land/std@0.177.0/bytes/index_of_needle.ts": "65c939607df609374c4415598fa4dad04a2f14c4d98cd15775216f0aaf597f24",
|
||||
"https://deno.land/std@0.177.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs": "5dedb7f9aa05f0e18ed017691c58df5f4686e4cbbd70368c6f896e5cca03f2b4",
|
||||
"https://deno.land/std@0.177.0/crypto/_wasm/mod.ts": "e2df88236fc061eac7a89e8cb0b97843f5280b08b2a990e473b7397a3e566003",
|
||||
"https://deno.land/std@0.177.0/crypto/timing_safe_equal.ts": "8d69ab611c67fe51b6127d97fcfb4d8e7d0e1b6b4f3e0cc4ab86744c3691f965",
|
||||
"https://deno.land/std@0.177.0/encoding/base64.ts": "7de04c2f8aeeb41453b09b186480be90f2ff357613b988e99fabb91d2eeceba1",
|
||||
"https://deno.land/std@0.177.0/encoding/base64url.ts": "3f1178f6446834457b16bfde8b559c1cd3481727fe384d3385e4a9995dc2d851",
|
||||
"https://deno.land/std@0.177.0/encoding/hex.ts": "50f8c95b52eae24395d3dfcb5ec1ced37c5fe7610ef6fffdcc8b0fdc38e3b32f",
|
||||
"https://deno.land/std@0.177.0/flags/mod.ts": "d1cdefa18472ef69858a17df5cf7c98445ed27ac10e1460183081303b0ebc270",
|
||||
"https://deno.land/std@0.177.0/node/_core.ts": "9a58c0ef98ee77e9b8fcc405511d1b37a003a705eb6a9b6e95f75434d8009adc",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/base/buffer.js": "c9364c761681134015ec8ba6f33b39c067d6e5dd59860d55face8d5be8522744",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/base/node.js": "8f7f23bfa300990bbd6db7e7395e9688b54a04e3eb2fab5cab9a9a72e26c525f",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/base/reporter.js": "788aec7662991da549e5f7f3edbc3e3d6c6cecabc894b18d1a705b0f204e06c3",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/constants/der.js": "57181db0519bb3864a6cdf4e7eb9bfeb1bf5f80605187fbe80e27083b473e367",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/decoders/der.js": "fdc4de98c9b0b59db169a2b225895741e2ab34b00e14315ac2ff5e389d6db16e",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/decoders/pem.js": "fd7f0072c193c82959fec0374f4fd3adf3f4ac38594fd404d66b3e8724107151",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/encoders/der.js": "137bc4f8fe66b9950c743025e199789e25342f791e2d52353ceb016ad2854b42",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/encoders/pem.js": "e43bc706973c4c27e1e2f96262daba3d38822cb10f5b494f6944c726ee655160",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/asn1.js/mod.js": "1f88293688296be7a6c735bd8ea39425f5b274b94db1d6b7968dddfb54ac9d37",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/bn.js/bn.js": "f3f3c1dae1aa55de9e6472af1d6bec5ccda4b4890ee5c52a90961137fe99564e",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/aes.js": "698e1ed386b7dff27b2d59fa1c75f506beceec96b78670a15a734e438c08f138",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/auth_cipher.js": "5c245b5685b066356a7c9529a3a441bf5f57823a6946ce1b0ef2e1af32bb76f4",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/decrypter.js": "39152b2b3409893b8548feeab7e5997ceb1595f31df0dedaf765708be8f025c0",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/encrypter.js": "f9cc703d5a7b5255999c1a3600fbf48ff564b65f827744877526803093ceebff",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/ghash.js": "759d80b760f44cd3a454b4f161fd03a7d6c359901446f0a907a6870cb66d6767",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/incr32.js": "2bdea27b74b3990ee56807a1a5abe335f118826beabeeb905459c8768094b28f",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/mod.js": "fe4affebbd210d885b2e5135c668751f9d10bc14aa0cc3905cbfff66f04b4c58",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/cbc.js": "ff24b4506522a724ba7a03c1403ad8938aba45056f9fd47c7f0b4fcb3a640adf",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/cfb.js": "643720a1db969b6bcc896c95523630838a8335513d02f340514fd524bb4113cb",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/cfb1.js": "01c9a46aa3affd84a54ae33652fb0fa0ff7c862be2a459d9cb188cb8e2c4b11e",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/cfb8.js": "97476cee25103e02a02b196d7fe6f28a9f0f9e47ee344687d7492bc7282a59f8",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/ctr.js": "1e3835adb753cfe6761e4df8c43d190e31e1ca6a586fd582747c8255c82ed78d",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/ecb.js": "79677b96d4af50c49f0a4f698e5c7e5a64f1d2926b799e0d2eac2cdd5ec7488c",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/mod.js": "fe3db429b867a0a8066c64d7b33b840a1f24cad9174156384a763733f68cf518",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/modes/ofb.js": "3553308f98d078e2006eac39bb6d91818f8bb376b01d962ae98eabf6ee79ad4e",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/stream_cipher.js": "70f50f37ddec530ae95911ca2f286ebd2ddbd54d914ab0be461ec1dc3c61990f",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_aes/xor.ts": "7132baacdb39ba82c3bfe325a60e68ca87469c0ed0cdd0508caf6f40bab852b8",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/browserify_rsa.js": "96e0e4fee7c2cf75ef86d958c709bfc239297a080fd17ace5ea5ab699a1b6174",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/cipher_base.js": "9ebc6ccc364cf7b23024821054d2e72a2d8da8d8a2a36cacdc5aa6cc6770ef93",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/evp_bytes_to_key.ts": "7c4c27b6e321b2d7065a6703d90264921e9a805d91d9dfdb21103393228024e2",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/parse_asn1/asn1.js": "7d99b6df508164169a33377346e8840d519fe2defccb362a023c92c5bd503433",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/parse_asn1/certificate.js": "5795348417b3ec7aafa4854ba55f364e0148eadfdd29d1566c90e617237621bb",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/parse_asn1/fix_proc.js": "858dd3e6ce264d75822cadc21bb55114f4e4867a706abde1663548aa2710fc1b",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/parse_asn1/mod.js": "ea164fbd497ce3d710426742d4b72f71da8954c4ebaeb7eadc33316c5b0060f1",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/public_encrypt/mgf.js": "dfac5008a550b3e7e6b851c4fb42e984aa9e7fae64707888f47f2aa0991c004d",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/public_encrypt/mod.js": "0704326ff3ee2bb0764a964995d1aa62b1147b714ad5465e878ba4d57731e3db",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/public_encrypt/private_decrypt.js": "8a1d11edb176d95d1e3bdf1aff5c3248a986bf9734d1a6b07508e29132d2f65c",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/public_encrypt/public_encrypt.js": "f88b0e3c228d84096fdbc03e614e86bef86e56013cb9628b2425e31b3b142b2c",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/public_encrypt/with_public.js": "752da754d253b5743d89c0f2432b6eb6f8815b80efd9ee588683e10a13d34400",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/public_encrypt/xor.js": "087ebef8f6fcb8ca4c7216cc22de728d9a61ec27b9a036b900681ff25d6409af",
|
||||
"https://deno.land/std@0.177.0/node/_crypto/crypto_browserify/randombytes.ts": "23bde8be640e274d7bb88cf10d1da8bba252654252dc6a877fed86a77da5952c",
|
||||
"https://deno.land/std@0.177.0/node/_events.d.ts": "1347437fd6b084d7c9a4e16b9fe7435f00b030970086482edeeb3b179d0775af",
|
||||
"https://deno.land/std@0.177.0/node/_events.mjs": "d4ba4e629abe3db9f1b14659fd5c282b7da8b2b95eaf13238eee4ebb142a2448",
|
||||
"https://deno.land/std@0.177.0/node/_global.d.ts": "2d88342f38b4083b858998e27c706725fb03a74aa14ef8d985dc18438b5188e4",
|
||||
"https://deno.land/std@0.177.0/node/_next_tick.ts": "9a3cf107d59b019a355d3cf32275b4c6157282e4b68ea85b46a799cb1d379305",
|
||||
"https://deno.land/std@0.177.0/node/_process/exiting.ts": "6e336180aaabd1192bf99ffeb0d14b689116a3dec1dfb34a2afbacd6766e98ab",
|
||||
"https://deno.land/std@0.177.0/node/_process/process.ts": "c96bb1f6253824c372f4866ee006dcefda02b7050d46759736e403f862d91051",
|
||||
"https://deno.land/std@0.177.0/node/_process/stdio.mjs": "cf17727eac8da3a665851df700b5aca6a12bacc3ebbf33e63e4b919f80ba44a6",
|
||||
"https://deno.land/std@0.177.0/node/_stream.d.ts": "112e1a0677cd6db932c3ce0e6e5bbdc7a2ac1874572f449044ecc82afcf5ee2e",
|
||||
"https://deno.land/std@0.177.0/node/_stream.mjs": "d6e2c86c1158ac65b4c2ca4fa019d7e84374ff12e21e2175345fe68c0823efe3",
|
||||
"https://deno.land/std@0.177.0/node/_utils.ts": "7fd55872a0cf9275e3c080a60e2fa6d45b8de9e956ebcde9053e72a344185884",
|
||||
"https://deno.land/std@0.177.0/node/buffer.ts": "85617be2063eccaf177dbb84c7580d1e32023724ed14bd9df4e453b152a26167",
|
||||
"https://deno.land/std@0.177.0/node/crypto.ts": "2c94fa0f76e90190fbc34df891dc5c284bddb86c932fae8ac11747de3f75293c",
|
||||
"https://deno.land/std@0.177.0/node/events.ts": "d2de352d509de11a375e2cb397d6b98f5fed4e562fc1d41be33214903a38e6b0",
|
||||
"https://deno.land/std@0.177.0/node/internal/buffer.d.ts": "bdfa991cd88cb02fd08bf8235d2618550e3e511c970b2a8f2e1a6885a2793cac",
|
||||
"https://deno.land/std@0.177.0/node/internal/buffer.mjs": "e92303a3cc6d9aaabcd270a937ad9319825d9ba08cb332650944df4562029b27",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/_keys.ts": "8f3c3b5a141aa0331a53c205e9338655f1b3b307a08085fd6ff6dda6f7c4190b",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/_randomBytes.ts": "36dd164747f73b830ba86562abb160a8ac5bea34aaeb816a67f3005a00d41177",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/_randomFill.ts": "297186f290eba87a1ad7b8aa42a960ff4278a8b6b0c963fa81918c326d5c0b58",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/_randomInt.ts": "6cf19da9684b67520e67a2d99f2581a3f841140842c7ce2e014d166457550fe1",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/certificate.ts": "b4a6695f82e70a42e85247c74a7691ed4b3a904646451af0287e49efe1a28814",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/cipher.ts": "2bae9b4d94c465e4d1c70e5a9e8fd67ce20bcc66fecd2eec6be00d35144ca4eb",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/constants.ts": "544d605703053218499b08214f2e25cf4310651d535b7ab995891c4b7a217693",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/diffiehellman.ts": "9cfb219c5b2936db773f559b6affe6d25b0e40531010389f05df3f05ce7eebf5",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/hash.ts": "d01f5d3ad5477655b432036d2d553c7a0c31a901ac0e1e9e0d8b3975daae7624",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/hkdf.ts": "5bd801234e56468fbd47466f46e88bdadc66432d625e3616abe38878d410bb66",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/keygen.ts": "530cc1a00acf71a43719bb876a2dc563b6196095d080eba77c92c9f39658a5b9",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/keys.ts": "c4dfa5aa3420cf700178b87203593a0989c8a93934bfef2b29adb3399d687958",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/pbkdf2.ts": "0a0a3e0d3d45db0638fe75a4199c7ed7ca2164405750a520e786e4adebdb45a4",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/random.ts": "85f3147e14cb45c18e016da45d319a5c663309411232a956fdc09c2317acdd9f",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/scrypt.ts": "b55a0fcd12b295af4127d05b1c0bc3098b74fc0e3c62321c2a43c20f9ed18209",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/sig.ts": "25819a89d49c1ebfe3baa1f9464501ec599a36cf53e9b600ec0399e568b9dccc",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/types.ts": "52feb182bcbd59206f3e2f4a3cb8a5775d4452c2a8045c3e613e2178d32c2a86",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/util.ts": "db282c0413aeee28bc0665fcfc1c08a65fc96dc12ed4d03282f2da4907fcf0ce",
|
||||
"https://deno.land/std@0.177.0/node/internal/crypto/x509.ts": "0e8a541c4f58ecb83862c373d3f7d2371aa8f5108f55bc837b190c4ab3408764",
|
||||
"https://deno.land/std@0.177.0/node/internal/error_codes.ts": "8495e33f448a484518d76fa3d41d34fc20fe03c14b30130ad8e936b0035d4b8b",
|
||||
"https://deno.land/std@0.177.0/node/internal/errors.ts": "1c699b8a3cb93174f697a348c004b1c6d576b66688eac8a48ebb78e65c720aae",
|
||||
"https://deno.land/std@0.177.0/node/internal/fixed_queue.ts": "62bb119afa5b5ae8fc0c7048b50502347bec82e2588017d0b250c4671d6eff8f",
|
||||
"https://deno.land/std@0.177.0/node/internal/hide_stack_frames.ts": "9dd1bad0a6e62a1042ce3a51eb1b1ecee2f246907bff44835f86e8f021de679a",
|
||||
"https://deno.land/std@0.177.0/node/internal/normalize_encoding.mjs": "fd1d9df61c44d7196432f6e8244621468715131d18cc79cd299fc78ac549f707",
|
||||
"https://deno.land/std@0.177.0/node/internal/options.ts": "888f267c3fe8f18dc7b2f2fbdbe7e4a0fd3302ff3e99f5d6645601e924f3e3fb",
|
||||
"https://deno.land/std@0.177.0/node/internal/primordials.mjs": "a72d86b5aa55d3d50b8e916b6a59b7cc0dc5a31da8937114b4a113ad5aa08c74",
|
||||
"https://deno.land/std@0.177.0/node/internal/streams/destroy.mjs": "b665fc71178919a34ddeac8389d162a81b4bc693ff7dc2557fa41b3a91011967",
|
||||
"https://deno.land/std@0.177.0/node/internal/streams/end-of-stream.mjs": "a4fb1c2e32d58dff440d4e716e2c4daaa403b3095304a028bb428575cfeed716",
|
||||
"https://deno.land/std@0.177.0/node/internal/streams/utils.mjs": "f2fe2e6bdc506da24c758970890cc2a21642045b129dee618bd3827c60dd9e33",
|
||||
"https://deno.land/std@0.177.0/node/internal/streams/writable.mjs": "775928726d0483ace8e45a35f30db2019a22dd7b9a81b67b158420e21cc692c5",
|
||||
"https://deno.land/std@0.177.0/node/internal/util.mjs": "f7fe2e1ca5e66f550ad0856b9f5ee4d666f0c071fe212ea7fc7f37cfa81f97a5",
|
||||
"https://deno.land/std@0.177.0/node/internal/util/inspect.mjs": "11d7c9cab514b8e485acc3978c74b837263ff9c08ae4537fa18ad56bae633259",
|
||||
"https://deno.land/std@0.177.0/node/internal/util/types.ts": "0e587b44ec5e017cf228589fc5ce9983b75beece6c39409c34170cfad49d6417",
|
||||
"https://deno.land/std@0.177.0/node/internal/validators.mjs": "e02f2b02dd072a5d623970292588d541204dc82207b4c58985d933a5f4b382e6",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/_libuv_winerror.ts": "30c9569603d4b97a1f1a034d88a3f74800d5ea1f12fcc3d225c9899d4e1a518b",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/_node.ts": "cb2389b0eab121df99853eb6a5e3a684e4537e065fb8bf2cca0cbf219ce4e32e",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/_timingSafeEqual.ts": "7d9732464d3c669ff07713868ce5d25bc974a06112edbfb5f017fc3c70c0853e",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/_utils.ts": "7c58a2fbb031a204dee9583ba211cf9c67922112fe77e7f0b3226112469e9fe1",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/_winerror.ts": "3e8cfdfe22e89f13d2b28529bab35155e6b1730c0221ec5a6fc7077dc037be13",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/buffer.ts": "31729e0537921d6c730ad0afea44a7e8a0a1044d070ade8368226cb6f7390c8b",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/constants.ts": "21ff9d1ee71d0a2086541083a7711842fc6ae25e264dbf45c73815aadce06f4c",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/crypto.ts": "29e8f94f283a2e7d4229d3551369c6a40c2af9737fad948cb9be56bef6c468cd",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/node_options.ts": "0b5cb0bf4379a39278d7b7bb6bb2c2751baf428fe437abe5ed3e8441fae1f18b",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/string_decoder.ts": "54c3c1cbd5a9254881be58bf22637965dc69535483014dab60487e299cb95445",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/types.ts": "2187595a58d2cf0134f4db6cc2a12bf777f452f52b15b6c3aed73fa072aa5fc3",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/util.ts": "808ff3b92740284184ab824adfc420e75398c88c8bccf5111f0c24ac18c48f10",
|
||||
"https://deno.land/std@0.177.0/node/internal_binding/uv.ts": "eb0048e30af4db407fb3f95563e30d70efd6187051c033713b0a5b768593a3a3",
|
||||
"https://deno.land/std@0.177.0/node/perf_hooks.ts": "c20e1f02f463e065e8f6c1d4fa97b0d3832dc0db5b5d8ea37f99a962ecf11f35",
|
||||
"https://deno.land/std@0.177.0/node/stream.ts": "09e348302af40dcc7dc58aa5e40fdff868d11d8d6b0cfb85cbb9c75b9fe450c7",
|
||||
"https://deno.land/std@0.177.0/node/string_decoder.ts": "1a17e3572037c512cc5fc4b29076613e90f225474362d18da908cb7e5ccb7e88"
|
||||
}
|
||||
}
|
||||
36
yjs-poll/node_modules/lib0/diff.d.ts
generated
vendored
Normal file
36
yjs-poll/node_modules/lib0/diff.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
export function simpleDiffString(a: string, b: string): SimpleDiff<string>;
|
||||
export function simpleDiff(a: string, b: string): SimpleDiff<string>;
|
||||
export function simpleDiffArray<T>(a: Array<T>, b: Array<T>, compare?: (arg0: T, arg1: T) => boolean): SimpleDiff<Array<T>>;
|
||||
export function simpleDiffStringWithCursor(a: string, b: string, cursor: number): {
|
||||
index: number;
|
||||
remove: number;
|
||||
insert: string;
|
||||
};
|
||||
/**
|
||||
* A SimpleDiff describes a change on a String.
|
||||
*
|
||||
* ```js
|
||||
* console.log(a) // the old value
|
||||
* console.log(b) // the updated value
|
||||
* // Apply changes of diff (pseudocode)
|
||||
* a.remove(diff.index, diff.remove) // Remove `diff.remove` characters
|
||||
* a.insert(diff.index, diff.insert) // Insert `diff.insert`
|
||||
* a === b // values match
|
||||
* ```
|
||||
*/
|
||||
export type SimpleDiff<T extends string | Array<any>> = {
|
||||
/**
|
||||
* The index where changes were applied
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* The number of characters to delete starting
|
||||
* at `index`.
|
||||
*/
|
||||
remove: number;
|
||||
/**
|
||||
* The new text to insert at `index` after applying
|
||||
*/
|
||||
insert: T;
|
||||
};
|
||||
//# sourceMappingURL=diff.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/diff.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/diff.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["diff.js"],"names":[],"mappings":"AAyCO,oCAJI,MAAM,KACN,MAAM,GACL,UAAU,CAAC,MAAM,CAAC,CAoB7B;AAlBM,8BAJI,MAAM,KACN,MAAM,GACL,UAAU,CAAC,MAAM,CAAC,CAoB7B;AAuBM,gCAPM,CAAC,KAEH,KAAK,CAAC,CAAC,CAAC,KACR,KAAK,CAAC,CAAC,CAAC,YACR,CAAS,IAAC,EAAD,CAAC,EAAE,IAAC,EAAD,CAAC,KAAE,OAAO,GACrB,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAgB/B;AASM,8CAJI,MAAM,KACN,MAAM,UACN,MAAM;;;;EAyChB;;;;;;;;;;;;;uBA5HgC,CAAC,SAApB,MAAM,GAAC,KAAK,CAAC,GAAG,CAAE;;;;;;;;;;;;;YAKlB,CAAC"}
|
||||
145
yjs-poll/node_modules/lib0/diff.js
generated
vendored
Normal file
145
yjs-poll/node_modules/lib0/diff.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Efficient diffs.
|
||||
*
|
||||
* @module diff
|
||||
*/
|
||||
|
||||
import { equalityStrict } from './function.js'
|
||||
|
||||
/**
|
||||
* A SimpleDiff describes a change on a String.
|
||||
*
|
||||
* ```js
|
||||
* console.log(a) // the old value
|
||||
* console.log(b) // the updated value
|
||||
* // Apply changes of diff (pseudocode)
|
||||
* a.remove(diff.index, diff.remove) // Remove `diff.remove` characters
|
||||
* a.insert(diff.index, diff.insert) // Insert `diff.insert`
|
||||
* a === b // values match
|
||||
* ```
|
||||
*
|
||||
* @template {string|Array<any>} T
|
||||
* @typedef {Object} SimpleDiff
|
||||
* @property {Number} index The index where changes were applied
|
||||
* @property {Number} remove The number of characters to delete starting
|
||||
* at `index`.
|
||||
* @property {T} insert The new text to insert at `index` after applying
|
||||
*/
|
||||
|
||||
const highSurrogateRegex = /[\uD800-\uDBFF]/
|
||||
const lowSurrogateRegex = /[\uDC00-\uDFFF]/
|
||||
|
||||
/**
|
||||
* Create a diff between two strings. This diff implementation is highly
|
||||
* efficient, but not very sophisticated.
|
||||
*
|
||||
* @function
|
||||
*
|
||||
* @param {string} a The old version of the string
|
||||
* @param {string} b The updated version of the string
|
||||
* @return {SimpleDiff<string>} The diff description.
|
||||
*/
|
||||
export const simpleDiffString = (a, b) => {
|
||||
let left = 0 // number of same characters counting from left
|
||||
let right = 0 // number of same characters counting from right
|
||||
while (left < a.length && left < b.length && a[left] === b[left]) {
|
||||
left++
|
||||
}
|
||||
// If the last same character is a high surrogate, we need to rollback to the previous character
|
||||
if (left > 0 && highSurrogateRegex.test(a[left - 1])) left--
|
||||
while (right + left < a.length && right + left < b.length && a[a.length - right - 1] === b[b.length - right - 1]) {
|
||||
right++
|
||||
}
|
||||
// If the last same character is a low surrogate, we need to rollback to the previous character
|
||||
if (right > 0 && lowSurrogateRegex.test(a[a.length - right])) right--
|
||||
return {
|
||||
index: left,
|
||||
remove: a.length - left - right,
|
||||
insert: b.slice(left, b.length - right)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Remove in favor of simpleDiffString
|
||||
* @deprecated
|
||||
*/
|
||||
export const simpleDiff = simpleDiffString
|
||||
|
||||
/**
|
||||
* Create a diff between two arrays. This diff implementation is highly
|
||||
* efficient, but not very sophisticated.
|
||||
*
|
||||
* Note: This is basically the same function as above. Another function was created so that the runtime
|
||||
* can better optimize these function calls.
|
||||
*
|
||||
* @function
|
||||
* @template T
|
||||
*
|
||||
* @param {Array<T>} a The old version of the array
|
||||
* @param {Array<T>} b The updated version of the array
|
||||
* @param {function(T, T):boolean} [compare]
|
||||
* @return {SimpleDiff<Array<T>>} The diff description.
|
||||
*/
|
||||
export const simpleDiffArray = (a, b, compare = equalityStrict) => {
|
||||
let left = 0 // number of same characters counting from left
|
||||
let right = 0 // number of same characters counting from right
|
||||
while (left < a.length && left < b.length && compare(a[left], b[left])) {
|
||||
left++
|
||||
}
|
||||
while (right + left < a.length && right + left < b.length && compare(a[a.length - right - 1], b[b.length - right - 1])) {
|
||||
right++
|
||||
}
|
||||
return {
|
||||
index: left,
|
||||
remove: a.length - left - right,
|
||||
insert: b.slice(left, b.length - right)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diff text and try to diff at the current cursor position.
|
||||
*
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
* @param {number} cursor This should refer to the current left cursor-range position
|
||||
*/
|
||||
export const simpleDiffStringWithCursor = (a, b, cursor) => {
|
||||
let left = 0 // number of same characters counting from left
|
||||
let right = 0 // number of same characters counting from right
|
||||
// Iterate left to the right until we find a changed character
|
||||
// First iteration considers the current cursor position
|
||||
while (
|
||||
left < a.length &&
|
||||
left < b.length &&
|
||||
a[left] === b[left] &&
|
||||
left < cursor
|
||||
) {
|
||||
left++
|
||||
}
|
||||
// If the last same character is a high surrogate, we need to rollback to the previous character
|
||||
if (left > 0 && highSurrogateRegex.test(a[left - 1])) left--
|
||||
// Iterate right to the left until we find a changed character
|
||||
while (
|
||||
right + left < a.length &&
|
||||
right + left < b.length &&
|
||||
a[a.length - right - 1] === b[b.length - right - 1]
|
||||
) {
|
||||
right++
|
||||
}
|
||||
// If the last same character is a low surrogate, we need to rollback to the previous character
|
||||
if (right > 0 && lowSurrogateRegex.test(a[a.length - right])) right--
|
||||
// Try to iterate left further to the right without caring about the current cursor position
|
||||
while (
|
||||
right + left < a.length &&
|
||||
right + left < b.length &&
|
||||
a[left] === b[left]
|
||||
) {
|
||||
left++
|
||||
}
|
||||
if (left > 0 && highSurrogateRegex.test(a[left - 1])) left--
|
||||
return {
|
||||
index: left,
|
||||
remove: a.length - left - right,
|
||||
insert: b.slice(left, b.length - right)
|
||||
}
|
||||
}
|
||||
6
yjs-poll/node_modules/lib0/diff.test.d.ts
generated
vendored
Normal file
6
yjs-poll/node_modules/lib0/diff.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export function testDiffing(tc: t.TestCase): void;
|
||||
export function testRepeatDiffing(tc: t.TestCase): void;
|
||||
export function testSimpleDiffWithCursor(tc: t.TestCase): void;
|
||||
export function testArrayDiffing(tc: t.TestCase): void;
|
||||
import * as t from './testing.js';
|
||||
//# sourceMappingURL=diff.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/diff.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/diff.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"diff.test.d.ts","sourceRoot":"","sources":["diff.test.js"],"names":[],"mappings":"AA0BO,gCAFI,CAAC,CAAC,QAAQ,QAmBpB;AAKM,sCAFI,CAAC,CAAC,QAAQ,QAQpB;AAKM,6CAFI,CAAC,CAAC,QAAQ,QA4CpB;AAKM,qCAFI,CAAC,CAAC,QAAQ,QAQpB;mBA7GkB,cAAc"}
|
||||
16
yjs-poll/node_modules/lib0/diff/patience.d.ts
generated
vendored
Normal file
16
yjs-poll/node_modules/lib0/diff/patience.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export function diff(as: Array<string>, bs: Array<string>): Array<{
|
||||
index: number;
|
||||
remove: Array<string>;
|
||||
insert: Array<string>;
|
||||
}>;
|
||||
export function diffSplitBy(a: string, b: string, _regexp: RegExp | string): {
|
||||
index: number;
|
||||
remove: string;
|
||||
insert: string;
|
||||
}[];
|
||||
export function diffAuto(a: string, b: string): {
|
||||
insert: string;
|
||||
remove: string;
|
||||
index: number;
|
||||
}[];
|
||||
//# sourceMappingURL=patience.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/diff/patience.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/diff/patience.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"patience.d.ts","sourceRoot":"","sources":["patience.js"],"names":[],"mappings":"AAoBO,yBAJI,KAAK,CAAC,MAAM,CAAC,MACb,KAAK,CAAC,MAAM,CAAC,GACZ,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CAAC,CAAC,CAShF;AAOM,+BAJI,MAAM,KACN,MAAM,WACN,MAAM,GAAC,MAAM;;;;IAqBvB;AAWM,4BAHI,MAAM,KACN,MAAM;;;;IASP"}
|
||||
226
yjs-poll/node_modules/lib0/diff/patience.js
generated
vendored
Normal file
226
yjs-poll/node_modules/lib0/diff/patience.js
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* A very simple diff algorithm. Slightly adapted to support splitting at different stages (e.g.
|
||||
* first diff lines, then diff words)
|
||||
*
|
||||
* https://bramcohen.livejournal.com/73318.html
|
||||
*
|
||||
* @experiemantal This API will likely change.
|
||||
*/
|
||||
|
||||
import * as map from '../map.js'
|
||||
import * as math from '../math.js'
|
||||
import * as array from '../array.js'
|
||||
|
||||
/**
|
||||
* Implementation of patience diff. Expects that content is pre-split (e.g. by newline).
|
||||
*
|
||||
* @param {Array<string>} as
|
||||
* @param {Array<string>} bs
|
||||
* @return {Array<{ index: number, remove: Array<string>, insert: Array<string>}>} changeset @todo should use delta instead
|
||||
*/
|
||||
export const diff = (as, bs) => {
|
||||
const {
|
||||
middleAs,
|
||||
middleBs,
|
||||
commonPrefix
|
||||
} = removeCommonPrefixAndSuffix(as, bs)
|
||||
return lcs(middleAs, middleBs, commonPrefix)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
* @param {RegExp|string} _regexp
|
||||
*/
|
||||
export const diffSplitBy = (a, b, _regexp) => {
|
||||
const isStringSeparator = typeof _regexp === 'string'
|
||||
const separator = isStringSeparator ? _regexp : ''
|
||||
const regexp = isStringSeparator ? new RegExp(_regexp, 'g') : _regexp
|
||||
const as = splitByRegexp(a, regexp, !isStringSeparator)
|
||||
const bs = splitByRegexp(b, regexp, !isStringSeparator)
|
||||
const changes = diff(as, bs)
|
||||
let prevSplitIndex = 0
|
||||
let prevStringIndex = 0
|
||||
return changes.map(change => {
|
||||
for (; prevSplitIndex < change.index; prevSplitIndex++) {
|
||||
prevStringIndex += as[prevSplitIndex].length
|
||||
}
|
||||
return {
|
||||
index: prevStringIndex,
|
||||
remove: change.remove.join(separator),
|
||||
insert: change.insert.join(separator)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Sensible default for diffing strings using patience (it's fast though).
|
||||
*
|
||||
* Perform different types of patience diff on the content. Diff first by newline, then paragraphs, then by word
|
||||
* (split by space, brackets, punctuation)
|
||||
*
|
||||
* @param {string} a
|
||||
* @param {string} b
|
||||
*/
|
||||
export const diffAuto = (a, b) =>
|
||||
diffSplitBy(a, b, '\n').map(d =>
|
||||
diffSplitBy(d.remove, d.insert, /\. |[a-zA-Z0-9]+|[. ()[\],;{}]/g).map(dd => ({
|
||||
insert: dd.insert,
|
||||
remove: dd.remove,
|
||||
index: dd.index + d.index
|
||||
}))
|
||||
).flat()
|
||||
|
||||
/**
|
||||
* @param {Array<string>} as
|
||||
* @param {Array<string>} bs
|
||||
*/
|
||||
const removeCommonPrefixAndSuffix = (as, bs) => {
|
||||
const commonLen = math.min(as.length, bs.length)
|
||||
let commonPrefix = 0
|
||||
let commonSuffix = 0
|
||||
// match start
|
||||
for (; commonPrefix < commonLen && as[commonPrefix] === bs[commonPrefix]; commonPrefix++) { /* nop */ }
|
||||
// match end
|
||||
for (; commonSuffix < commonLen - commonPrefix && as[as.length - 1 - commonSuffix] === bs[bs.length - 1 - commonSuffix]; commonSuffix++) { /* nop */ }
|
||||
const middleAs = as.slice(commonPrefix, as.length - commonSuffix)
|
||||
const middleBs = bs.slice(commonPrefix, bs.length - commonSuffix)
|
||||
return {
|
||||
middleAs, middleBs, commonPrefix, commonSuffix
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits string by regex and returns all strings as an array. The matched parts are also returned.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {RegExp} regexp
|
||||
* @param {boolean} includeSeparator
|
||||
*/
|
||||
const splitByRegexp = (str, regexp, includeSeparator) => {
|
||||
const matches = [...str.matchAll(regexp)]
|
||||
let prevIndex = 0
|
||||
/**
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
const res = []
|
||||
matches.forEach(m => {
|
||||
prevIndex < (m.index || 0) && res.push(str.slice(prevIndex, m.index))
|
||||
includeSeparator && res.push(m[0]) // is always non-empty
|
||||
prevIndex = /** @type {number} */ (m.index) + m[0].length
|
||||
})
|
||||
const end = str.slice(prevIndex)
|
||||
end.length > 0 && res.push(end)
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* An item may have multiple occurances (not when matching unique entries). It also may have a
|
||||
* reference to the stack of other items (from as to bs).
|
||||
*/
|
||||
class Item {
|
||||
constructor () {
|
||||
/**
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
this.indexes = []
|
||||
/**
|
||||
* The matching item from the other side
|
||||
* @type {Item?}
|
||||
*/
|
||||
this.match = null
|
||||
/**
|
||||
* For patience sort. Reference (index of the stack) to the previous pile.
|
||||
*
|
||||
* @type {Item?}
|
||||
*/
|
||||
this.ref = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<string>} xs
|
||||
*/
|
||||
const partition = xs => {
|
||||
/**
|
||||
* @type {Map<string,Item>}
|
||||
*/
|
||||
const refs = map.create()
|
||||
xs.forEach((x, index) => {
|
||||
map.setIfUndefined(refs, x, () => new Item()).indexes.push(index)
|
||||
})
|
||||
return refs
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the longest common subsequence of items using patience sort.
|
||||
*
|
||||
* @param {Array<string>} as
|
||||
* @param {Array<string>} bs
|
||||
* @param {number} indexAdjust
|
||||
*/
|
||||
const lcs = (as, bs, indexAdjust) => {
|
||||
if (as.length === 0 && bs.length === 0) return []
|
||||
const aParts = partition(as)
|
||||
const bParts = partition(bs)
|
||||
/**
|
||||
* @type {Array<Array<Item>>} I.e. Array<Pile<Item>>
|
||||
*/
|
||||
const piles = []
|
||||
aParts.forEach((aItem, aKey) => {
|
||||
// skip if no match or if either item is not unique
|
||||
if (aItem.indexes.length > 1 || (aItem.match = bParts.get(aKey) || null) == null || aItem.match.indexes.length > 1) return
|
||||
for (let i = 0; i < piles.length; i++) {
|
||||
const pile = piles[i]
|
||||
if (aItem.match.indexes[0] < /** @type {Item} */ (pile[pile.length - 1].match).indexes[0]) {
|
||||
pile.push(aItem)
|
||||
if (i > 0) aItem.ref = array.last(piles[i - 1])
|
||||
return
|
||||
}
|
||||
}
|
||||
piles.length > 0 && (aItem.ref = array.last(piles[piles.length - 1]))
|
||||
piles.push([aItem])
|
||||
})
|
||||
/**
|
||||
* References to all matched items
|
||||
*
|
||||
* @type {Array<Item>}
|
||||
*/
|
||||
const matches = []
|
||||
/**
|
||||
* @type {Item?}
|
||||
*/
|
||||
let currPileItem = piles[piles.length - 1]?.[0]
|
||||
while (currPileItem != null) {
|
||||
matches.push(currPileItem)
|
||||
currPileItem = currPileItem.ref
|
||||
}
|
||||
matches.reverse()
|
||||
// add pseude match (assume the string terminal always matches)
|
||||
const pseudoA = new Item()
|
||||
const pseudoB = new Item()
|
||||
pseudoA.match = pseudoB
|
||||
pseudoA.indexes.push(as.length)
|
||||
pseudoB.indexes.push(bs.length)
|
||||
matches.push(pseudoA)
|
||||
/**
|
||||
* @type {Array<{ index: number, remove: Array<string>, insert: Array<string>}>}
|
||||
*/
|
||||
const changeset = []
|
||||
let diffAStart = 0
|
||||
let diffBStart = 0
|
||||
for (let i = 0; i < matches.length; i++) {
|
||||
const m = matches[i]
|
||||
const delLength = m.indexes[0] - diffAStart
|
||||
const insLength = /** @type {Item} */ (m.match).indexes[0] - diffBStart
|
||||
if (delLength !== 0 || insLength !== 0) {
|
||||
const stripped = removeCommonPrefixAndSuffix(as.slice(diffAStart, diffAStart + delLength), bs.slice(diffBStart, diffBStart + insLength))
|
||||
if (stripped.middleAs.length !== 0 || stripped.middleBs.length !== 0) {
|
||||
changeset.push({ index: diffAStart + indexAdjust + stripped.commonPrefix, remove: stripped.middleAs, insert: stripped.middleBs })
|
||||
}
|
||||
}
|
||||
diffAStart = m.indexes[0] + 1
|
||||
diffBStart = /** @type {Item} */ (m.match).indexes[0] + 1
|
||||
}
|
||||
return changeset
|
||||
}
|
||||
4
yjs-poll/node_modules/lib0/diff/patience.test.d.ts
generated
vendored
Normal file
4
yjs-poll/node_modules/lib0/diff/patience.test.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export function testDiffing(_tc: t.TestCase): void;
|
||||
export function testRepeatRandomWordReplace(tc: t.TestCase): void;
|
||||
import * as t from '../testing.js';
|
||||
//# sourceMappingURL=patience.test.d.ts.map
|
||||
1
yjs-poll/node_modules/lib0/diff/patience.test.d.ts.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/diff/patience.test.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"patience.test.d.ts","sourceRoot":"","sources":["patience.test.js"],"names":[],"mappings":"AAmBO,iCAFI,CAAC,CAAC,QAAQ,QAwGpB;AAKM,gDAFI,CAAC,CAAC,QAAQ,QAgDpB;mBA3KkB,eAAe"}
|
||||
171
yjs-poll/node_modules/lib0/dist/aes-gcm.cjs
generated
vendored
Normal file
171
yjs-poll/node_modules/lib0/dist/aes-gcm.cjs
generated
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var encoding = require('./encoding-1a745c43.cjs');
|
||||
var decoding = require('./decoding-76e75827.cjs');
|
||||
var webcrypto = require('lib0/webcrypto');
|
||||
var string = require('./string-fddc5f8b.cjs');
|
||||
var common = require('./common.cjs');
|
||||
require('./math-96d5e8c4.cjs');
|
||||
require('./number-1fb57bba.cjs');
|
||||
require('./binary-ac8e39e2.cjs');
|
||||
require('./array-78849c95.cjs');
|
||||
require('./set-5b47859e.cjs');
|
||||
require('./error-0c1f634f.cjs');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var webcrypto__namespace = /*#__PURE__*/_interopNamespace(webcrypto);
|
||||
|
||||
/**
|
||||
* AES-GCM is a symmetric key for encryption
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Array<'encrypt'|'decrypt'>} Usages
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {Usages}
|
||||
*/
|
||||
const defaultUsages = ['encrypt', 'decrypt'];
|
||||
|
||||
/**
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
*/
|
||||
const encrypt = (key, data) => {
|
||||
const iv = webcrypto__namespace.getRandomValues(new Uint8Array(16)); // 92bit is enough. 128bit is recommended if space is not an issue.
|
||||
return webcrypto__namespace.subtle.encrypt(
|
||||
{
|
||||
name: 'AES-GCM',
|
||||
iv
|
||||
},
|
||||
key,
|
||||
data
|
||||
).then(cipher => {
|
||||
const encryptedDataEncoder = encoding.createEncoder();
|
||||
// iv may be sent in the clear to the other peers
|
||||
encoding.writeUint8Array(encryptedDataEncoder, iv);
|
||||
encoding.writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher));
|
||||
return encoding.toUint8Array(encryptedDataEncoder)
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Decrypt some data using AES-GCM method.
|
||||
*
|
||||
* @param {CryptoKey} key
|
||||
* @param {Uint8Array<ArrayBuffer>} data
|
||||
* @return {PromiseLike<Uint8Array>} decrypted buffer
|
||||
*/
|
||||
const decrypt = (key, data) => {
|
||||
const dataDecoder = decoding.createDecoder(data);
|
||||
const iv = decoding.readUint8Array(dataDecoder, 16);
|
||||
const cipher = decoding.readVarUint8Array(dataDecoder);
|
||||
return webcrypto__namespace.subtle.decrypt(
|
||||
{
|
||||
name: 'AES-GCM',
|
||||
iv
|
||||
},
|
||||
key,
|
||||
cipher
|
||||
).then(data => new Uint8Array(data))
|
||||
};
|
||||
|
||||
const aesAlgDef = {
|
||||
name: 'AES-GCM',
|
||||
length: 256
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} jwk
|
||||
* @param {Object} opts
|
||||
* @param {Usages} [opts.usages]
|
||||
* @param {boolean} [opts.extractable]
|
||||
*/
|
||||
const importKeyJwk = (jwk, { usages, extractable = false } = {}) => {
|
||||
if (usages == null) {
|
||||
/* c8 ignore next */
|
||||
usages = jwk.key_ops || defaultUsages;
|
||||
}
|
||||
return webcrypto__namespace.subtle.importKey('jwk', jwk, 'AES-GCM', extractable, /** @type {Usages} */ (usages))
|
||||
};
|
||||
|
||||
/**
|
||||
* Only suited for importing public keys.
|
||||
*
|
||||
* @param {Uint8Array<ArrayBuffer>} raw
|
||||
* @param {Object} opts
|
||||
* @param {Usages} [opts.usages]
|
||||
* @param {boolean} [opts.extractable]
|
||||
*/
|
||||
const importKeyRaw = (raw, { usages = defaultUsages, extractable = false } = {}) =>
|
||||
webcrypto__namespace.subtle.importKey('raw', raw, aesAlgDef, extractable, /** @type {Usages} */ (usages));
|
||||
|
||||
/**
|
||||
* @param {Uint8Array<ArrayBuffer> | string} data
|
||||
*/
|
||||
/* c8 ignore next */
|
||||
const toBinary = data => typeof data === 'string' ? string.encodeUtf8(data) : data;
|
||||
|
||||
/**
|
||||
* @experimental The API is not final!
|
||||
*
|
||||
* Derive an symmetric key using the Password-Based-Key-Derivation-Function-2.
|
||||
*
|
||||
* @param {Uint8Array<ArrayBuffer>|string} secret
|
||||
* @param {Uint8Array<ArrayBuffer>|string} salt
|
||||
* @param {Object} opts
|
||||
* @param {boolean} [opts.extractable]
|
||||
* @param {Usages} [opts.usages]
|
||||
*/
|
||||
const deriveKey = (secret, salt, { extractable = false, usages = defaultUsages } = {}) =>
|
||||
webcrypto__namespace.subtle.importKey(
|
||||
'raw',
|
||||
toBinary(secret),
|
||||
'PBKDF2',
|
||||
false,
|
||||
['deriveKey']
|
||||
).then(keyMaterial =>
|
||||
webcrypto__namespace.subtle.deriveKey(
|
||||
{
|
||||
name: 'PBKDF2',
|
||||
salt: toBinary(salt), // NIST recommends at least 64 bits
|
||||
iterations: 600000, // OWASP recommends 600k iterations
|
||||
hash: 'SHA-256'
|
||||
},
|
||||
keyMaterial,
|
||||
aesAlgDef,
|
||||
extractable,
|
||||
usages
|
||||
)
|
||||
);
|
||||
|
||||
exports.exportKeyJwk = common.exportKeyJwk;
|
||||
exports.exportKeyRaw = common.exportKeyRaw;
|
||||
exports.decrypt = decrypt;
|
||||
exports.deriveKey = deriveKey;
|
||||
exports.encrypt = encrypt;
|
||||
exports.importKeyJwk = importKeyJwk;
|
||||
exports.importKeyRaw = importKeyRaw;
|
||||
//# sourceMappingURL=aes-gcm.cjs.map
|
||||
1
yjs-poll/node_modules/lib0/dist/aes-gcm.cjs.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/dist/aes-gcm.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
260
yjs-poll/node_modules/lib0/dist/array-78849c95.cjs
generated
vendored
Normal file
260
yjs-poll/node_modules/lib0/dist/array-78849c95.cjs
generated
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
'use strict';
|
||||
|
||||
var set = require('./set-5b47859e.cjs');
|
||||
|
||||
/**
|
||||
* Utility module to work with Arrays.
|
||||
*
|
||||
* @module array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the last element of an array. The element must exist
|
||||
*
|
||||
* @template L
|
||||
* @param {ArrayLike<L>} arr
|
||||
* @return {L}
|
||||
*/
|
||||
const last = arr => arr[arr.length - 1];
|
||||
|
||||
/**
|
||||
* @template C
|
||||
* @return {Array<C>}
|
||||
*/
|
||||
const create = () => /** @type {Array<C>} */ ([]);
|
||||
|
||||
/**
|
||||
* @template D
|
||||
* @param {Array<D>} a
|
||||
* @return {Array<D>}
|
||||
*/
|
||||
const copy = a => /** @type {Array<D>} */ (a.slice());
|
||||
|
||||
/**
|
||||
* Append elements from src to dest
|
||||
*
|
||||
* @template M
|
||||
* @param {Array<M>} dest
|
||||
* @param {Array<M>} src
|
||||
*/
|
||||
const appendTo = (dest, src) => {
|
||||
for (let i = 0; i < src.length; i++) {
|
||||
dest.push(src[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforms something array-like to an actual Array.
|
||||
*
|
||||
* @function
|
||||
* @template T
|
||||
* @param {ArrayLike<T>|Iterable<T>} arraylike
|
||||
* @return {T}
|
||||
*/
|
||||
const from = Array.from;
|
||||
|
||||
/**
|
||||
* True iff condition holds on every element in the Array.
|
||||
*
|
||||
* @function
|
||||
* @template {ArrayLike<any>} ARR
|
||||
*
|
||||
* @param {ARR} arr
|
||||
* @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : any} f
|
||||
* @return {boolean}
|
||||
*/
|
||||
const every = (arr, f) => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (!f(arr[i], i, arr)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
};
|
||||
|
||||
/**
|
||||
* True iff condition holds on some element in the Array.
|
||||
*
|
||||
* @function
|
||||
* @template {ArrayLike<any>} ARR
|
||||
*
|
||||
* @param {ARR} arr
|
||||
* @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : never} f
|
||||
* @return {boolean}
|
||||
*/
|
||||
const some = (arr, f) => {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (f(arr[i], i, arr)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
};
|
||||
|
||||
/**
|
||||
* @template ELEM
|
||||
*
|
||||
* @param {ArrayLike<ELEM>} a
|
||||
* @param {ArrayLike<ELEM>} b
|
||||
* @return {boolean}
|
||||
*/
|
||||
const equalFlat = (a, b) => a.length === b.length && every(a, (item, index) => item === b[index]);
|
||||
|
||||
/**
|
||||
* @template ELEM
|
||||
* @param {Array<Array<ELEM>>} arr
|
||||
* @return {Array<ELEM>}
|
||||
*/
|
||||
const flatten = arr => fold(arr, /** @type {Array<ELEM>} */ ([]), (acc, val) => acc.concat(val));
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {number} len
|
||||
* @param {function(number, Array<T>):T} f
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
const unfold = (len, f) => {
|
||||
const array = new Array(len);
|
||||
for (let i = 0; i < len; i++) {
|
||||
array[i] = f(i, array);
|
||||
}
|
||||
return array
|
||||
};
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template RESULT
|
||||
* @param {Array<T>} arr
|
||||
* @param {RESULT} seed
|
||||
* @param {function(RESULT, T, number):RESULT} folder
|
||||
*/
|
||||
const fold = (arr, seed, folder) => arr.reduce(folder, seed);
|
||||
|
||||
const isArray = Array.isArray;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {Array<T>} arr
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
const unique = arr => from(set.from(arr));
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @template M
|
||||
* @param {ArrayLike<T>} arr
|
||||
* @param {function(T):M} mapper
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
const uniqueBy = (arr, mapper) => {
|
||||
/**
|
||||
* @type {Set<M>}
|
||||
*/
|
||||
const happened = set.create();
|
||||
/**
|
||||
* @type {Array<T>}
|
||||
*/
|
||||
const result = [];
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const el = arr[i];
|
||||
const mapped = mapper(el);
|
||||
if (!happened.has(mapped)) {
|
||||
happened.add(mapped);
|
||||
result.push(el);
|
||||
}
|
||||
}
|
||||
return result
|
||||
};
|
||||
|
||||
/**
|
||||
* @template {ArrayLike<any>} ARR
|
||||
* @template {function(ARR extends ArrayLike<infer T> ? T : never, number, ARR):any} MAPPER
|
||||
* @param {ARR} arr
|
||||
* @param {MAPPER} mapper
|
||||
* @return {Array<MAPPER extends function(...any): infer M ? M : never>}
|
||||
*/
|
||||
const map = (arr, mapper) => {
|
||||
/**
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
const res = Array(arr.length);
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
res[i] = mapper(/** @type {any} */ (arr[i]), i, /** @type {any} */ (arr));
|
||||
}
|
||||
return /** @type {any} */ (res)
|
||||
};
|
||||
|
||||
/**
|
||||
* This function bubble-sorts a single item to the correct position. The sort happens in-place and
|
||||
* might be useful to ensure that a single item is at the correct position in an otherwise sorted
|
||||
* array.
|
||||
*
|
||||
* @example
|
||||
* const arr = [3, 2, 5]
|
||||
* arr.sort((a, b) => a - b)
|
||||
* arr // => [2, 3, 5]
|
||||
* arr.splice(1, 0, 7)
|
||||
* array.bubbleSortItem(arr, 1, (a, b) => a - b)
|
||||
* arr // => [2, 3, 5, 7]
|
||||
*
|
||||
* @template T
|
||||
* @param {Array<T>} arr
|
||||
* @param {number} i
|
||||
* @param {(a:T,b:T) => number} compareFn
|
||||
*/
|
||||
const bubblesortItem = (arr, i, compareFn) => {
|
||||
const n = arr[i];
|
||||
let j = i;
|
||||
// try to sort to the right
|
||||
while (j + 1 < arr.length && compareFn(n, arr[j + 1]) > 0) {
|
||||
arr[j] = arr[j + 1];
|
||||
arr[++j] = n;
|
||||
}
|
||||
if (i === j && j > 0) { // no change yet
|
||||
// sort to the left
|
||||
while (j > 0 && compareFn(arr[j - 1], n) > 0) {
|
||||
arr[j] = arr[j - 1];
|
||||
arr[--j] = n;
|
||||
}
|
||||
}
|
||||
return j
|
||||
};
|
||||
|
||||
var array = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
last: last,
|
||||
create: create,
|
||||
copy: copy,
|
||||
appendTo: appendTo,
|
||||
from: from,
|
||||
every: every,
|
||||
some: some,
|
||||
equalFlat: equalFlat,
|
||||
flatten: flatten,
|
||||
unfold: unfold,
|
||||
fold: fold,
|
||||
isArray: isArray,
|
||||
unique: unique,
|
||||
uniqueBy: uniqueBy,
|
||||
map: map,
|
||||
bubblesortItem: bubblesortItem
|
||||
});
|
||||
|
||||
exports.appendTo = appendTo;
|
||||
exports.array = array;
|
||||
exports.bubblesortItem = bubblesortItem;
|
||||
exports.copy = copy;
|
||||
exports.create = create;
|
||||
exports.equalFlat = equalFlat;
|
||||
exports.every = every;
|
||||
exports.flatten = flatten;
|
||||
exports.fold = fold;
|
||||
exports.from = from;
|
||||
exports.isArray = isArray;
|
||||
exports.last = last;
|
||||
exports.map = map;
|
||||
exports.some = some;
|
||||
exports.unfold = unfold;
|
||||
exports.unique = unique;
|
||||
exports.uniqueBy = uniqueBy;
|
||||
//# sourceMappingURL=array-78849c95.cjs.map
|
||||
1
yjs-poll/node_modules/lib0/dist/array-78849c95.cjs.map
generated
vendored
Normal file
1
yjs-poll/node_modules/lib0/dist/array-78849c95.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user