lib0 1.0.0-rc.7 → 1.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -5
- package/src/broadcastchannel.js +6 -1
- package/src/delta/delta.js +1 -1
- package/src/environment.js +8 -0
- package/src/schema.js +1 -1
- package/src/trait/equality.js +1 -1
- package/src/trait/fingerprint.js +1 -1
- package/types/environment.d.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lib0",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -272,6 +272,7 @@
|
|
|
272
272
|
"devDependencies": {
|
|
273
273
|
"@types/node": "^24.11.0",
|
|
274
274
|
"c8": "^10.1.3",
|
|
275
|
+
"dpdm": "^4.0.1",
|
|
275
276
|
"standard": "^17.1.0",
|
|
276
277
|
"typescript": "^5.9.3"
|
|
277
278
|
},
|
|
@@ -280,15 +281,15 @@
|
|
|
280
281
|
"types": "rm -rf types && tsc -p tsconfig.build.json",
|
|
281
282
|
"dist": "npm run clean && npm run types",
|
|
282
283
|
"debug": "npm run gentesthtml && node ./src/bin/0serve.js -o test.html",
|
|
283
|
-
"test": "c8 --check-coverage --lines
|
|
284
|
+
"test": "c8 --check-coverage --lines 97 --branches 96 --functions 94 --statements 97 node --unhandled-rejections=strict ./src/test.js",
|
|
285
|
+
"test:deno": "deno run -A src/test.js",
|
|
284
286
|
"test-inspect": "node --inspect-brk --unhandled-rejections=strict ./src/test.js --repetition-time 50",
|
|
285
|
-
"test-extensive": "
|
|
287
|
+
"test-extensive": "node ./src/test.js --repetition-time 3000 --extensive",
|
|
286
288
|
"test:bundle": "esbuild bundle.test.js --bundle --outfile=dist/bundle.test.js --analyze --minify && wc -c dist/bundle.test.js",
|
|
287
289
|
"trace-deopt": "clear && node --trace-deopt src/test.js",
|
|
288
290
|
"trace-opt": "clear && node --trace-opt src/test.js",
|
|
289
|
-
"lint": "tsc && standard",
|
|
291
|
+
"lint": "tsc && standard && npx dpdm --exit-code circular:1 --warning false --tree false src/test.js",
|
|
290
292
|
"gendocs": "node ./bin/gendocs.js",
|
|
291
|
-
"release": "npm run dist && np --test-script dist",
|
|
292
293
|
"version": "npm run clean && npm run dist && git add README.md",
|
|
293
294
|
"postpublish": "npm run clean",
|
|
294
295
|
"gentesthtml": "node ./src/bin/gentesthtml.js --script src/test.js > test.html"
|
package/src/broadcastchannel.js
CHANGED
|
@@ -44,6 +44,10 @@ class LocalStoragePolyfill {
|
|
|
44
44
|
* @type {null|function({data:Uint8Array}):void}
|
|
45
45
|
*/
|
|
46
46
|
this.onmessage = null
|
|
47
|
+
/**
|
|
48
|
+
* @type {null|((this: BroadcastChannel, ev: MessageEvent) => any)}
|
|
49
|
+
*/
|
|
50
|
+
this.onmessageerror = null
|
|
47
51
|
/**
|
|
48
52
|
* @param {any} e
|
|
49
53
|
*/
|
|
@@ -79,8 +83,9 @@ const getChannel = room =>
|
|
|
79
83
|
/**
|
|
80
84
|
* @param {{data:ArrayBuffer}} e
|
|
81
85
|
*/
|
|
82
|
-
/* c8 ignore next */
|
|
86
|
+
/* c8 ignore next 3 */
|
|
83
87
|
bc.onmessage = e => subs.forEach(sub => sub(e.data, 'broadcastchannel'))
|
|
88
|
+
bc.onmessageerror = e => console.error('broadcastchannel error', e)
|
|
84
89
|
return {
|
|
85
90
|
bc, subs
|
|
86
91
|
}
|
package/src/delta/delta.js
CHANGED
|
@@ -1533,7 +1533,7 @@ export class DeltaBuilder extends Delta {
|
|
|
1533
1533
|
} else if ($retainOp.check(op)) {
|
|
1534
1534
|
let retainLen = op.length
|
|
1535
1535
|
|
|
1536
|
-
if (offset > 0 && opsI != null && op.format != null && !$deleteOp.check(opsI) &&
|
|
1536
|
+
if (offset > 0 && opsI != null && op.format != null && !$deleteOp.check(opsI) && (/** @type {InsertOp<any>|RetainOp|ModifyOp} */ (opsI).format == null || !fun.equalityDeep(opsI.format, op.format))) {
|
|
1537
1537
|
// need to split current op
|
|
1538
1538
|
const cpy = scheduleForMerge(opsI.clone(offset))
|
|
1539
1539
|
opsI._splice(offset, opsI.length - offset)
|
package/src/environment.js
CHANGED
|
@@ -13,6 +13,14 @@ import * as f from './function.js'
|
|
|
13
13
|
/* c8 ignore next */
|
|
14
14
|
export const isNode = /* @__PURE__ */(() => typeof process !== 'undefined' && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]')()
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* True iff this script is running in deno
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
*/
|
|
20
|
+
/* c8 ignore next 2 */
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
export const isDeno = /* @__PURE__ */(() => typeof Deno !== 'undefined')()
|
|
23
|
+
|
|
16
24
|
/* c8 ignore next */
|
|
17
25
|
export const isBrowser = /* @__PURE__ */(() => typeof window !== 'undefined' && typeof document !== 'undefined' && !isNode)()
|
|
18
26
|
/* c8 ignore next */
|
package/src/schema.js
CHANGED
|
@@ -487,7 +487,7 @@ export class $StringTemplate extends Schema {
|
|
|
487
487
|
check (o, err) {
|
|
488
488
|
const c = this._r.exec(o) != null
|
|
489
489
|
/* c8 ignore next */
|
|
490
|
-
!c && err?.extend(null, this._r.toString(), o+'', 'String doesn\'t match string template.')
|
|
490
|
+
!c && err?.extend(null, this._r.toString(), o + '', 'String doesn\'t match string template.')
|
|
491
491
|
return c
|
|
492
492
|
}
|
|
493
493
|
}
|
package/src/trait/equality.js
CHANGED
package/src/trait/fingerprint.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as encoding from '../encoding.js'
|
|
|
2
2
|
import * as rabin from '../hash/rabin.js'
|
|
3
3
|
import * as buffer from '../buffer.js'
|
|
4
4
|
|
|
5
|
-
export const FingerprintTraitSymbol = Symbol('
|
|
5
|
+
export const FingerprintTraitSymbol = Symbol.for('0:fingerprint')
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* When implementing this trait, it is recommended to write some sort of "magic number" first to
|
package/types/environment.d.ts
CHANGED