Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bayou/doc-common

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bayou/doc-common - npm Package Compare versions

Comparing version 1.0.1 to 1.0.6

69

BodyDelta.js

@@ -5,5 +5,5 @@ // Copyright 2016-2018 the Bayou Authors (Dan Bornstein et alia).

import Delta from 'quill-delta';
import { Text } from '@bayou/config-common';
import { BaseDelta } from '@bayou/ot-common';
import { Logger } from '@bayou/see-all';
import { TBoolean, TObject } from '@bayou/typecheck';

@@ -37,21 +37,3 @@ import { Errors } from '@bayou/util-common';

} else {
try {
TObject.check(quillDelta, Delta);
ops = quillDelta.ops;
} catch (e) {
if ((typeof quillDelta === 'object') && (quillDelta.constructor.name === 'Delta')) {
// The version of `Delta` used by Quill is different than the one we
// specified in our `package.json`. Even though it will often happen
// to work if we just let it slide (e.g. by snarfing `ops` out of the
// object and running with it), we don't want to end up shipping two
// versions of `Delta` to the client; so, instead of just blithely
// accepting this possibility, we reject it here and report an error
// which makes it easy to figure out what happened. Should you find
// yourself looking at this error, the right thing to do is look at
// Quill's `package.json` and update the `quill-delta` dependency in
// this module to what you find there.
throw Errors.badUse('Divergent versions of `quill-delta` package.');
}
throw e;
}
ops = BodyDelta._opsOfQuillDelta(quillDelta);
}

@@ -100,3 +82,3 @@

const ops = this.ops.map(op => op.toQuillForm());
return new Delta(ops);
return new Text.Delta(ops);
}

@@ -204,2 +186,45 @@

}
/**
* Checks that the argument is a Quill delta, and if so returns the `ops`
* array inside it. Throws an error if not.
*
* @param {Delta} quillDelta Quill delta instance.
* @returns {array} Array of Quill operations that `delta` contains.
*/
static _opsOfQuillDelta(quillDelta) {
try {
TObject.check(quillDelta, Text.Delta);
} catch (e) {
if ((typeof quillDelta === 'object') && (quillDelta.constructor.name === 'Delta')) {
// The version of `Delta` used by Quill is different than the one we
// specified in our `package.json`. Even though it will often happen
// to work if we just let it slide (e.g. by snarfing `ops` out of the
// object and running with it), we don't want to end up shipping two
// versions of `Delta` to the client; so, instead of just blithely
// accepting this possibility, we reject it here and report an error
// which makes it easy to figure out what happened. Should you find
// yourself looking at this error, the likely right thing to do is
// look at `package.json` in the version of Quill you are using, and
// update what is returned from
// {@link @bayou/config-common/Text#Delta} to match what Quill has as
// its `quill-delta` dependency.
// **TODO:** Because reasons, this complaint has been demoted to
// from "actual error" to "stern warning," for the time being. The
// `throw` should be restored at the earliest opportunity, along with
// removing the surrounding bits that let this case fall through.
//throw Errors.badUse('Divergent versions of `quill-delta` package.');
if (!BodyDelta._divergentComplaintMade) {
// NB: This is the only code in this module that uses `see-all`.
BodyDelta._divergentComplaintMade = true;
new Logger('doc-common').warn('Divergent versions of `quill-delta` package!');
}
} else {
throw e;
}
}
return quillDelta.ops;
}
}

@@ -7,11 +7,11 @@ {

"dependencies": {
"@bayou/codec": "1.0.1",
"@bayou/config-common": "1.0.1",
"@bayou/deps-quill-common": "1.0.1",
"@bayou/ot-common": "1.0.1",
"@bayou/typecheck": "1.0.1",
"@bayou/util-common": "1.0.1"
"@bayou/codec": "1.0.6",
"@bayou/config-common": "1.0.6",
"@bayou/ot-common": "1.0.6",
"@bayou/see-all": "1.0.6",
"@bayou/typecheck": "1.0.6",
"@bayou/util-common": "1.0.6"
},
"name": "@bayou/doc-common",
"version": "1.0.1"
"version": "1.0.6"
}

@@ -7,4 +7,4 @@ // Copyright 2016-2018 the Bayou Authors (Dan Bornstein et alia).

import { describe, it } from 'mocha';
import Delta from 'quill-delta';
import { Text } from '@bayou/config-common';
import { BodyChange, BodyDelta, BodyOp } from '@bayou/doc-common';

@@ -83,3 +83,3 @@ import { Timestamp } from '@bayou/ot-common';

test(0, { ops: [] });
test(0, new Delta()); // Needs to be a `BodyDelta`.
test(0, new Text.Delta()); // Needs to be a `BodyDelta`.

@@ -86,0 +86,0 @@ // Invalid `timestamp`.

@@ -7,5 +7,5 @@ // Copyright 2016-2018 the Bayou Authors (Dan Bornstein et alia).

import { describe, it } from 'mocha';
import Delta from 'quill-delta';
import { inspect } from 'util';
import { Text } from '@bayou/config-common';
import { BodyDelta, BodyOp } from '@bayou/doc-common';

@@ -43,3 +43,3 @@

const ops = [{ insert: 'foo' }, { retain: 10 }, { insert: 'bar', attributes: { bold: true } }];
const quillDelta = new Delta(ops);
const quillDelta = new Text.Delta(ops);
const result = BodyDelta.fromQuillForm(quillDelta);

@@ -371,3 +371,3 @@

const result = delta.toQuillForm();
assert.instanceOf(result, Delta);
assert.instanceOf(result, Text.Delta);

@@ -374,0 +374,0 @@ const origOps = delta.ops;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc