Comparing version 0.2.69 to 0.2.70
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
import * as number from '../number.js' | ||
import * as logging from '../logging.js' | ||
import * as logging from 'lib0/logging' | ||
@@ -10,0 +10,0 @@ const host = env.getParam('--host', 'localhost') |
@@ -47,3 +47,7 @@ /* eslint-env browser */ | ||
this.onmessage = null | ||
storage.onChange(e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') })) | ||
/** | ||
* @param {any} e | ||
*/ | ||
this._onChange = e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') }) | ||
storage.onChange(this._onChange) | ||
} | ||
@@ -57,2 +61,6 @@ | ||
} | ||
close () { | ||
storage.offChange(this._onChange) | ||
} | ||
} | ||
@@ -59,0 +67,0 @@ /* c8 ignore stop */ |
@@ -12,3 +12,3 @@ /** | ||
* // encoding step | ||
* const encoder = new encoding.createEncoder() | ||
* const encoder = encoding.createEncoder() | ||
* encoding.writeVarUint(encoder, 256) | ||
@@ -21,3 +21,3 @@ * encoding.writeVarString(encoder, 'Hello world!') | ||
* // decoding step | ||
* const decoder = new decoding.createDecoder(buf) | ||
* const decoder = decoding.createDecoder(buf) | ||
* decoding.readVarUint(decoder) // => 256 | ||
@@ -24,0 +24,0 @@ * decoding.readVarString(decoder) // => 'Hello world!' |
{ | ||
"imports": { | ||
"isomorphic.js": "./node_modules/isomorphic.js/node.mjs", | ||
"lib0/crypto": "./crypto.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/webcrypto": "./webcrypto.deno.js" | ||
} | ||
} |
10
diff.js
@@ -51,3 +51,3 @@ /** | ||
// If the last same character is a high surrogate, we need to rollback to the previous character | ||
if (highSurrogateRegex.test(a[left - 1])) left-- | ||
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]) { | ||
@@ -57,3 +57,3 @@ right++ | ||
// If the last same character is a low surrogate, we need to rollback to the previous character | ||
if (lowSurrogateRegex.test(a[a.length - right])) right-- | ||
if (right > 0 && lowSurrogateRegex.test(a[a.length - right])) right-- | ||
return { | ||
@@ -124,3 +124,3 @@ index: left, | ||
// If the last same character is a high surrogate, we need to rollback to the previous character | ||
if (highSurrogateRegex.test(a[left - 1])) left-- | ||
if (left > 0 && highSurrogateRegex.test(a[left - 1])) left-- | ||
// Iterate right to the left until we find a changed character | ||
@@ -135,3 +135,3 @@ while ( | ||
// If the last same character is a low surrogate, we need to rollback to the previous character | ||
if (lowSurrogateRegex.test(a[a.length - right])) right-- | ||
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 | ||
@@ -145,3 +145,3 @@ while ( | ||
} | ||
if (highSurrogateRegex.test(a[left - 1])) left-- | ||
if (left > 0 && highSurrogateRegex.test(a[left - 1])) left-- | ||
return { | ||
@@ -148,0 +148,0 @@ index: left, |
@@ -17,3 +17,3 @@ import * as array from "./array.js"; | ||
import * as json from "./json.js"; | ||
import * as logging from "./logging.js"; | ||
import * as logging from "lib0/logging"; | ||
import * as map from "./map.js"; | ||
@@ -20,0 +20,0 @@ import * as math from "./math.js"; |
@@ -10,2 +10,7 @@ /** | ||
}) => void): true | void; | ||
export function offChange(eventHandler: (arg0: { | ||
key: string; | ||
newValue: string; | ||
oldValue: string; | ||
}) => void): true | void; | ||
//# sourceMappingURL=storage.d.ts.map |
@@ -36,3 +36,3 @@ export { production } from "./environment.js"; | ||
export function info(info: string): void; | ||
export const printDom: (createNode: () => Node) => void; | ||
export const printDom: (_createNode: () => Node) => void; | ||
export const printCanvas: (canvas: HTMLCanvasElement, height: number) => void; | ||
@@ -39,0 +39,0 @@ export function group(description: string, f: (arg0: void) => void): void; |
@@ -12,3 +12,3 @@ /** | ||
* // encoding step | ||
* const encoder = new encoding.createEncoder() | ||
* const encoder = encoding.createEncoder() | ||
* encoding.writeVarUint(encoder, 256) | ||
@@ -21,3 +21,3 @@ * encoding.writeVarString(encoder, 'Hello world!') | ||
* // decoding step | ||
* const decoder = new decoding.createDecoder(buf) | ||
* const decoder = decoding.createDecoder(buf) | ||
* decoding.readVarUint(decoder) // => 256 | ||
@@ -24,0 +24,0 @@ * decoding.readVarString(decoder) // => 'Hello world!' |
@@ -17,3 +17,3 @@ import * as array from "./array.js"; | ||
import * as json from "./json.js"; | ||
import * as logging from "./logging.js"; | ||
import * as logging from "lib0/logging"; | ||
import * as map from "./map.js"; | ||
@@ -20,0 +20,0 @@ import * as math from "./math.js"; |
@@ -26,3 +26,3 @@ /** | ||
import * as json from './json.js' | ||
import * as logging from './logging.js' | ||
import * as logging from 'lib0/logging' | ||
import * as map from './map.js' | ||
@@ -29,0 +29,0 @@ import * as math from './math.js' |
@@ -7,3 +7,5 @@ /** | ||
// @todo remove this module | ||
// @ts-ignore | ||
export { performance, cryptoRandomBuffer } from 'isomorphic.js' |
{ | ||
"name": "lib0", | ||
"version": "0.2.69", | ||
"version": "0.2.70", | ||
"description": "", | ||
@@ -204,9 +204,16 @@ "sideEffects": false, | ||
}, | ||
"./logging.js": "./logging.js", | ||
"./dist/logging.cjs": "./dist/logging.cjs", | ||
"./logging": { | ||
"types": "./logging.d.ts", | ||
"module": "./logging.js", | ||
"import": "./logging.js", | ||
"require": "./dist/logging.cjs" | ||
"types": "./logging.node.d.ts", | ||
"deno": "./logging.node.js", | ||
"bun": "./logging.browser.js", | ||
"node": { | ||
"require": "./dist/logging.node.cjs", | ||
"module": "./logging.node.js", | ||
"default": "./logging.node.js" | ||
}, | ||
"browser": { | ||
"require": "./dist/logging.browser.cjs", | ||
"module": "./logging.browser.js", | ||
"default": "./logging.browser.js" | ||
} | ||
}, | ||
@@ -411,2 +418,17 @@ "./map.js": "./map.js", | ||
"module": "./webcrypto.browser.js" | ||
}, | ||
"./performance": { | ||
"types": "./performance.browser.d.ts", | ||
"deno": "./performance.node.js", | ||
"bun": "./performance.node.js", | ||
"node": { | ||
"require": "./dist/performance.node.cjs", | ||
"module": "./performance.node.js", | ||
"default": "./performance.node.js" | ||
}, | ||
"browser": { | ||
"require": "./dist/performance.browser.cjs", | ||
"module": "./performance.browser.js", | ||
"default": "./performance.browser.js" | ||
} | ||
} | ||
@@ -413,0 +435,0 @@ }, |
@@ -12,10 +12,10 @@ | ||
import * as binary from './binary.js' | ||
import { cryptoRandomBuffer } from './isomorphic.js' | ||
import { getRandomValues } from 'lib0/webcrypto' | ||
export const rand = Math.random | ||
export const uint32 = () => new Uint32Array(cryptoRandomBuffer(4))[0] | ||
export const uint32 = () => getRandomValues(new Uint32Array(1))[0] | ||
export const uint53 = () => { | ||
const arr = new Uint32Array(cryptoRandomBuffer(8)) | ||
const arr = getRandomValues(new Uint32Array(8)) | ||
return (arr[0] & binary.BITS21) * (binary.BITS32 + 1) + (arr[1] >>> 0) | ||
@@ -22,0 +22,0 @@ } |
@@ -10,2 +10,7 @@ /** | ||
}) => void): true | void; | ||
export function offChange(eventHandler: (arg0: { | ||
key: string; | ||
newValue: string; | ||
oldValue: string; | ||
}) => void): true | void; | ||
//# sourceMappingURL=storage.d.ts.map |
@@ -1,2 +0,2 @@ | ||
/* global localStorage, addEventListener */ | ||
/* eslint-env browser */ | ||
@@ -64,1 +64,10 @@ /** | ||
export const onChange = eventHandler => usePolyfill || addEventListener('storage', /** @type {any} */ (eventHandler)) | ||
/** | ||
* A polyfill for `removeEventListener('storage', event => {..})` that does nothing if the polyfill is being used. | ||
* | ||
* @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler | ||
* @function | ||
*/ | ||
/* c8 ignore next */ | ||
export const offChange = eventHandler => usePolyfill || removeEventListener('storage', /** @type {any} */ (eventHandler)) |
@@ -12,3 +12,3 @@ import { runTests } from './testing.js' | ||
import * as prng from './prng.test.js' | ||
import * as log from './logging.js' | ||
import * as log from 'lib0/logging' | ||
import * as statistics from './statistics.test.js' | ||
@@ -15,0 +15,0 @@ import * as binary from './binary.test.js' |
@@ -36,3 +36,3 @@ export { production } from "./environment.js"; | ||
export function info(info: string): void; | ||
export const printDom: (createNode: () => Node) => void; | ||
export const printDom: (_createNode: () => Node) => void; | ||
export const printCanvas: (canvas: HTMLCanvasElement, height: number) => void; | ||
@@ -39,0 +39,0 @@ export function group(description: string, f: (arg0: void) => void): void; |
@@ -46,3 +46,3 @@ /** | ||
import * as log from './logging.js' | ||
import * as log from 'lib0/logging' | ||
import { simpleDiffString } from './diff.js' | ||
@@ -60,5 +60,4 @@ import * as object from './object.js' | ||
import * as promise from './promise.js' | ||
import * as performance from 'lib0/performance' | ||
import { performance } from './isomorphic.js' | ||
export { production } from './environment.js' | ||
@@ -65,0 +64,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1561488
627
20073