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

@atjson/hir

Package Overview
Dependencies
Maintainers
2
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atjson/hir - npm Package Compare versions

Comparing version 0.5.17 to 0.7.0

7

dist/commonjs/hir-node.d.ts

@@ -1,2 +0,2 @@

import { Annotation } from '@atjson/core';
import { Annotation, Schema } from '@atjson/document';
import JSONNode from './json-node';

@@ -12,2 +12,3 @@ export default class HIRNode {

private sibling;
private schema;
constructor(node: {

@@ -19,4 +20,4 @@ type: string;

text?: string;
});
toJSON(filter?: (node: HIRNode) => HIRNode): JSONNode | string;
}, schema: Schema);
toJSON(): JSONNode | string;
children(): HIRNode[];

@@ -23,0 +24,0 @@ siblings(): HIRNode[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ROOT_NODE_RANK = 0;
const BLOCK_NODE_RANK = 1;
const PARAGRAPH_NODE_RANK = 2;
const SPAN_NODE_RANK = 3;
const OBJECT_NODE_RANK = 4;
const PARSE_NODE_RANK = Number.MAX_SAFE_INTEGER;
const TEXT_NODE_RANK = Infinity;
const RANK = {
root: 0,
block: 1,
paragraph: 2,
inline: 3,
object: 4,
parse: Number.MAX_SAFE_INTEGER,
text: Infinity
};
class HIRNode {
constructor(node) {
constructor(node, schema) {
this.type = node.type;

@@ -16,56 +18,30 @@ this.start = node.start;

this.attributes = node.attributes;
switch (node.type) {
case 'root':
this.rank = ROOT_NODE_RANK;
break;
case 'parse-token':
this.rank = PARSE_NODE_RANK;
break;
case 'text':
if (typeof (node.text) === 'string') {
this.text = node.text.slice(node.start, node.end);
this.rank = TEXT_NODE_RANK;
}
else {
throw new Error('Encountered a text node with no text.');
}
break;
case 'paragraph':
this.rank = PARAGRAPH_NODE_RANK;
break;
case 'embed':
case 'image':
case 'asset':
case 'horizontal-rule':
case 'section-break':
this.rank = OBJECT_NODE_RANK;
break;
case 'bold':
case 'italic':
this.rank = SPAN_NODE_RANK;
break;
case 'callout':
case 'ordered-list':
case 'unordered-list':
case 'list-item':
case 'blockquote':
this.rank = BLOCK_NODE_RANK;
break;
default:
this.rank = SPAN_NODE_RANK;
this.rank = RANK.inline;
this.schema = schema || {};
if (node.display) {
this.rank = RANK[node.display];
}
else if (node.type === 'text' && typeof node.text === 'string') {
this.rank = RANK.text;
this.text = node.text;
}
else if (node.type === 'parse-token') {
this.rank = RANK.parse;
}
else if (node.type === 'root') {
this.rank = RANK.root;
}
else if (this.schema[this.type]) {
this.rank = RANK[this.schema[this.type].display];
}
}
toJSON(filter) {
let thisNode = this;
if (filter) {
thisNode = filter(this);
toJSON() {
if (this.type === 'text' && typeof this.text === 'string') {
return this.text;
}
if (thisNode.type === 'text' && typeof (thisNode.text) === 'string') {
return thisNode.text;
}
return {
type: thisNode.type,
attributes: thisNode.attributes,
children: thisNode.children().map(child => {
return child.toJSON(filter);
type: this.type,
attributes: this.attributes,
children: this.children().map(child => {
return child.toJSON();
})

@@ -76,3 +52,3 @@ };

if (this.child) {
return [this.child].concat(this.child.siblings()).filter((node) => node.type != 'parse-token');
return [this.child].concat(this.child.siblings()).filter(node => node.type !== 'parse-token');
}

@@ -92,3 +68,3 @@ else {

insertAnnotation(annotation) {
let hirNode = new HIRNode(annotation);
let hirNode = new HIRNode(annotation, this.schema);
this.insertNode(hirNode);

@@ -102,3 +78,3 @@ }

return;
if (text.length === 1 && this.end - this.start === 1 && text === "\uFFFC")
if (text.length === 1 && this.end - this.start === 1 && text === '\uFFFC')
return;

@@ -238,3 +214,3 @@ let node = new HIRNode({

newNode.text = this.text.slice(newNode.start - this.start, newNode.end - this.start);
if (newNode.text === "\uFFFC") {
if (newNode.text === '\uFFFC') {
return;

@@ -247,2 +223,2 @@ }

exports.default = HIRNode;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlyLW5vZGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc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QyxHQUFHLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxHQUFHLENBQUMsQ0FBQyxDQUFDO1FBRWxFLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxLQUFLLEtBQUssT0FBTyxDQUFDLEdBQUcsQ0FBQztZQUFDLE1BQU0sQ0FBQztRQUUxQyxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsS0FBSyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO1lBQ2hDLE1BQU0sSUFBSSxLQUFLLENBQUMsMkNBQTJDLENBQUMsQ0FBQztRQUMvRCxDQUFDO1FBR0QsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksS0FBSyxNQUFNLElBQUksT0FBTSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsS0FBSyxRQUFRLENBQUMsQ0FBQyxDQUFDO1lBQzlELE9BQU8sQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLEtBQUssR0FBRyxJQUFJLENBQUMsS0FBSyxFQUFFLE9BQU8sQ0FBQyxHQUFHLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDO1lBQ3JGLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxJQUFJLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQztnQkFDOUIsTUFBTSxDQUFDO1lBQ1QsQ0FBQztRQUNILENBQUM7UUFFRCxNQUFNLENBQUMsT0FBTyxDQUFDO0lBQ2pCLENBQUM7Q0FDRjtBQXRQRCwwQkFzUEMifQ==
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@atjson/core");
const entities = require("entities");
const document_1 = require("@atjson/document");
const hir_node_1 = require("./hir-node");
class HIR {
constructor(atjson) {
if (atjson instanceof core_1.AtJSON) {
this.atjson = atjson;
}
else if (typeof atjson === 'string') {
this.atjson = new core_1.AtJSON(atjson);
}
else {
throw new Error('Invalid argument');
}
constructor(document) {
this.document = new document_1.default({
content: document.content,
contentType: document.contentType,
annotations: [...document.annotations],
schema: document.schema
});
this.populateHIR();
}
toJSON() {
if (this.atjson.contentType === 'text/html') {
return this.rootNode.toJSON((node) => {
if (node.type === 'text' && typeof (node.text) === 'string') {
node.text = entities.decodeHTML5(node.text);
}
return node;
});
}
else {
return this.rootNode.toJSON();
}
return this.rootNode.toJSON();
}
populateHIR() {
let atjson = this.atjson;
atjson.annotations
.filter(a => a.type === 'parse-token')
.forEach((a, idx) => {
atjson.objectReplacementSubstitution(a);
});
atjson.annotations
let document = this.document;
document.annotations
.filter(a => a.start === a.end)
.forEach(a => {
atjson.insertText(a.start, "\uFFFC");
document.insertText(a.start, '\uFFFC');
a.start--;
});
atjson.annotations
.filter(a => a.type === 'parse-element')
.forEach(a => atjson.removeAnnotation(a));
document.where({ type: 'parse-element' }).remove();
this.rootNode = new hir_node_1.default({
type: 'root',
start: 0,
end: atjson.content.length
});
atjson.annotations
.sort((a, b) => {
end: document.content.length
}, document.schema);
document.annotations.sort((a, b) => {
if (a.start === b.start) {

@@ -67,55 +45,6 @@ if (a.type === b.type) {

}).forEach(annotation => this.rootNode.insertAnnotation(annotation));
this.rootNode.insertText(atjson.content);
this.rootNode.insertText(document.content);
}
parseContent() {
return this.getParser().parse(this.atjson.content);
}
getParser() {
switch (this.atjson.contentType) {
case undefined:
case 'text/plain': {
return { parse: this.plainTextParser };
}
case 'text/atjson': {
return { parse() { return []; } };
}
default: {
throw new Error('Unsupported Content-Type');
}
}
}
plainTextParser(content) {
let prevIdx = 0;
let breakIdx = content.indexOf('\n\n', 0);
let annotations = [];
while (breakIdx !== -1) {
annotations.push({
type: 'paragraph',
start: prevIdx,
end: breakIdx
});
annotations.push({
type: 'parse-element',
start: prevIdx,
end: breakIdx + 2,
});
annotations.push({
type: 'parse-token',
start: breakIdx,
end: breakIdx + 2
});
prevIdx = breakIdx + 2;
breakIdx = content.indexOf('\n\n', breakIdx + 2);
}
if (prevIdx < content.length) {
annotations.push({
type: 'paragraph',
start: prevIdx,
end: content.length
});
}
return annotations;
}
}
exports.default = HIR;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHVDQUFrRDtBQUNsRCxxQ0FBcUM7QUFDckMseUNBQWlDO0FBR2pDO0lBS0UsWUFBWSxNQUF1QjtRQUNqQyxFQUFFLENBQUMsQ0FBQyxNQUFNLFlBQVksYUFBTSxDQUFDLENBQUMsQ0FBQztZQUM3QixJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sQ0FBQztRQUN2QixDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLE9BQU8sTUFBTSxLQUFLLFFBQVEsQ0FBQyxDQUFDLENBQUM7WUFDdEMsSUFBSSxDQUFDLE1BQU0sR0FBRyxJQUFJLGFBQU0sQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUNuQyxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDTixNQUFNLElBQUksS0FBSyxDQUFDLGtCQUFrQixDQUFDLENBQUM7UUFDdEMsQ0FBQztRQUVELElBQUksQ0FBQyxXQUFXLEVBQUUsQ0FBQztJQUNyQixDQUFDO0lBRUQsTUFBTTtRQUNKLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsV0FBVyxLQUFLLFdBQVcsQ0FBQyxDQUFDLENBQUM7WUFDNUMsTUFBTSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUMsSUFBYSx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0FBQyxDQUFDLEtBQUssQ0FBQztZQUMzQixDQUFDO1FBQ0gsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0IsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDO1FBRXJFLElBQUksQ0FBQyxRQUFRLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUM3QyxDQUFDO0NBQ0Y7QUFuREQsc0JBbURDIn0=

@@ -1,2 +0,2 @@

export declare type node = JSONNode | string;
export declare type Node = JSONNode | string;
export default interface JSONNode {

@@ -7,3 +7,3 @@ type: string;

};
children: node[];
children: Node[];
}

@@ -1,2 +0,2 @@

import { Annotation } from '@atjson/core';
import { Annotation, Schema } from '@atjson/document';
import JSONNode from './json-node';

@@ -12,2 +12,3 @@ export default class HIRNode {

private sibling;
private schema;
constructor(node: {

@@ -19,4 +20,4 @@ type: string;

text?: string;
});
toJSON(filter?: (node: HIRNode) => HIRNode): JSONNode | string;
}, schema: Schema);
toJSON(): JSONNode | string;
children(): HIRNode[];

@@ -23,0 +24,0 @@ siblings(): HIRNode[];

"use strict";
const ROOT_NODE_RANK = 0;
const BLOCK_NODE_RANK = 1;
const PARAGRAPH_NODE_RANK = 2;
const SPAN_NODE_RANK = 3;
const OBJECT_NODE_RANK = 4;
const PARSE_NODE_RANK = Number.MAX_SAFE_INTEGER;
const TEXT_NODE_RANK = Infinity;
const RANK = {
root: 0,
block: 1,
paragraph: 2,
inline: 3,
object: 4,
parse: Number.MAX_SAFE_INTEGER,
text: Infinity
};
export default class HIRNode {
constructor(node) {
constructor(node, schema) {
this.type = node.type;

@@ -15,56 +17,30 @@ this.start = node.start;

this.attributes = node.attributes;
switch (node.type) {
case 'root':
this.rank = ROOT_NODE_RANK;
break;
case 'parse-token':
this.rank = PARSE_NODE_RANK;
break;
case 'text':
if (typeof (node.text) === 'string') {
this.text = node.text.slice(node.start, node.end);
this.rank = TEXT_NODE_RANK;
}
else {
throw new Error('Encountered a text node with no text.');
}
break;
case 'paragraph':
this.rank = PARAGRAPH_NODE_RANK;
break;
case 'embed':
case 'image':
case 'asset':
case 'horizontal-rule':
case 'section-break':
this.rank = OBJECT_NODE_RANK;
break;
case 'bold':
case 'italic':
this.rank = SPAN_NODE_RANK;
break;
case 'callout':
case 'ordered-list':
case 'unordered-list':
case 'list-item':
case 'blockquote':
this.rank = BLOCK_NODE_RANK;
break;
default:
this.rank = SPAN_NODE_RANK;
this.rank = RANK.inline;
this.schema = schema || {};
if (node.display) {
this.rank = RANK[node.display];
}
else if (node.type === 'text' && typeof node.text === 'string') {
this.rank = RANK.text;
this.text = node.text;
}
else if (node.type === 'parse-token') {
this.rank = RANK.parse;
}
else if (node.type === 'root') {
this.rank = RANK.root;
}
else if (this.schema[this.type]) {
this.rank = RANK[this.schema[this.type].display];
}
}
toJSON(filter) {
let thisNode = this;
if (filter) {
thisNode = filter(this);
toJSON() {
if (this.type === 'text' && typeof this.text === 'string') {
return this.text;
}
if (thisNode.type === 'text' && typeof (thisNode.text) === 'string') {
return thisNode.text;
}
return {
type: thisNode.type,
attributes: thisNode.attributes,
children: thisNode.children().map(child => {
return child.toJSON(filter);
type: this.type,
attributes: this.attributes,
children: this.children().map(child => {
return child.toJSON();
})

@@ -75,3 +51,3 @@ };

if (this.child) {
return [this.child].concat(this.child.siblings()).filter((node) => node.type != 'parse-token');
return [this.child].concat(this.child.siblings()).filter(node => node.type !== 'parse-token');
}

@@ -91,3 +67,3 @@ else {

insertAnnotation(annotation) {
let hirNode = new HIRNode(annotation);
let hirNode = new HIRNode(annotation, this.schema);
this.insertNode(hirNode);

@@ -101,3 +77,3 @@ }

return;
if (text.length === 1 && this.end - this.start === 1 && text === "\uFFFC")
if (text.length === 1 && this.end - this.start === 1 && text === '\uFFFC')
return;

@@ -237,3 +213,3 @@ let node = new HIRNode({

newNode.text = this.text.slice(newNode.start - this.start, newNode.end - this.start);
if (newNode.text === "\uFFFC") {
if (newNode.text === '\uFFFC') {
return;

@@ -245,2 +221,2 @@ }

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlyLW5vZGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaGlyLW5vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUdBLE1BQU0sY0FBYyxHQUFHLENBQUMsQ0FBQztBQUN6QixNQUFNLGVBQWUsR0FBRyxDQUFDLENBQUM7QUFDMUIsTUFBTSxtQkFBbUIsR0FBRyxDQUFDLENBQUM7QUFDOUIsTUFBTSxjQUFjLEdBQUcsQ0FBQyxDQUFDO0FBQ3pCLE1BQU0sZ0JBQWdCLEdBQUcsQ0FBQyxDQUFDO0FBQzNCLE1BQU0sZUFBZSxHQUFHLE1BQU0sQ0FBQyxnQkFBZ0IsQ0FBQztBQUNoRCxNQUFNLGNBQWMsR0FBRyxRQUFRLENBQUM7QUFFaEMsTUFBTSxDQUFDLE9BQU87SUFlWixZQUFZLElBQW9GO1FBRTlGLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQztRQUV0QixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUM7UUFDeEIsSUFBSSxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsR0FBRyxDQUFDO1FBQ3BCLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQztRQUVsQyxNQUFNLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQztZQUNsQixLQUFLLE1BQU07Z0JBQ1QsSUFBSSxDQUFDLElBQUksR0FBRyxjQUFjLENBQUM7Z0JBQzNCLEtBQUssQ0FBQztZQUVSLEtBQUssYUFBYTtnQkFDaEIsSUFBSSxDQU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RQUVELE1BQU0sQ0FBQyxPQUFPLENBQUM7SUFDakIsQ0FBQztDQUNGIn0=
"use strict";
import { AtJSON } from '@atjson/core';
import * as entities from 'entities';
import Document from '@atjson/document';
import HIRNode from './hir-node';
export default class HIR {
constructor(atjson) {
if (atjson instanceof AtJSON) {
this.atjson = atjson;
}
else if (typeof atjson === 'string') {
this.atjson = new AtJSON(atjson);
}
else {
throw new Error('Invalid argument');
}
constructor(document) {
this.document = new Document({
content: document.content,
contentType: document.contentType,
annotations: [...document.annotations],
schema: document.schema
});
this.populateHIR();
}
toJSON() {
if (this.atjson.contentType === 'text/html') {
return this.rootNode.toJSON((node) => {
if (node.type === 'text' && typeof (node.text) === 'string') {
node.text = entities.decodeHTML5(node.text);
}
return node;
});
}
else {
return this.rootNode.toJSON();
}
return this.rootNode.toJSON();
}
populateHIR() {
let atjson = this.atjson;
atjson.annotations
.filter(a => a.type === 'parse-token')
.forEach((a, idx) => {
atjson.objectReplacementSubstitution(a);
});
atjson.annotations
let document = this.document;
document.annotations
.filter(a => a.start === a.end)
.forEach(a => {
atjson.insertText(a.start, "\uFFFC");
document.insertText(a.start, '\uFFFC');
a.start--;
});
atjson.annotations
.filter(a => a.type === 'parse-element')
.forEach(a => atjson.removeAnnotation(a));
document.where({ type: 'parse-element' }).remove();
this.rootNode = new HIRNode({
type: 'root',
start: 0,
end: atjson.content.length
});
atjson.annotations
.sort((a, b) => {
end: document.content.length
}, document.schema);
document.annotations.sort((a, b) => {
if (a.start === b.start) {

@@ -66,54 +44,5 @@ if (a.type === b.type) {

}).forEach(annotation => this.rootNode.insertAnnotation(annotation));
this.rootNode.insertText(atjson.content);
this.rootNode.insertText(document.content);
}
parseContent() {
return this.getParser().parse(this.atjson.content);
}
getParser() {
switch (this.atjson.contentType) {
case undefined:
case 'text/plain': {
return { parse: this.plainTextParser };
}
case 'text/atjson': {
return { parse() { return []; } };
}
default: {
throw new Error('Unsupported Content-Type');
}
}
}
plainTextParser(content) {
let prevIdx = 0;
let breakIdx = content.indexOf('\n\n', 0);
let annotations = [];
while (breakIdx !== -1) {
annotations.push({
type: 'paragraph',
start: prevIdx,
end: breakIdx
});
annotations.push({
type: 'parse-element',
start: prevIdx,
end: breakIdx + 2,
});
annotations.push({
type: 'parse-token',
start: breakIdx,
end: breakIdx + 2
});
prevIdx = breakIdx + 2;
breakIdx = content.indexOf('\n\n', breakIdx + 2);
}
if (prevIdx < content.length) {
annotations.push({
type: 'paragraph',
start: prevIdx,
end: content.length
});
}
return annotations;
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsT0FBTyxFQUFjLE1BQU0sRUFBRSxNQUFNLGNBQWMsQ0FBQztBQUNsRCxPQUFPLEtBQUssUUFBUSxNQUFNLFVBQVUsQ0FBQztBQUNyQyxPQUFPLE9BQU8sTUFBTSxZQUFZLENBQUM7QUFHakMsTUFBTSxDQUFDLE9BQU87SUFLWixZQUFZLE1BQXVCO1FBQ2pDLEVBQUUsQ0FBQyxDQUFDLE1BQU0sWUFBWSxNQUFNLENBQUMsQ0FBQyxDQUFDO1lBQzdCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO1FBQ3ZCLENBQUM7UUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsT0FBTyxNQUFNLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQztZQUN0QyxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksTUFBTSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1FBQ25DLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE1BQU0sSUFBSSxLQUFLLENBQUMsa0JBQWtCLENBQUMsQ0FBQztRQUN0QyxDQUFDO1FBRUQsSUFBSSxDQUFDLFdBQVcsRU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xDQUFDO29CQUNOLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLEdBQUcsQ0FBQyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLEdBQUcsR0FBRyxDQUFDLENBQUMsS0FBSyxDQUFDLENBQUM7Z0JBQy9DLENBQUM7WUFDSCxDQUFDO1lBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQ04sTUFBTSxDQUFDLENBQUMsQ0FBQyxLQUFLLEdBQUcsQ0FBQyxDQUFDLEtBQUssQ0FBQztZQUMzQixDQUFDO1FBQ0gsQ0FBQyxDQUFDLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0IsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDO1FBRXJFLElBQUksQ0FBQyxRQUFRLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUM3QyxDQUFDO0NBQ0YifQ==

@@ -1,2 +0,2 @@

export declare type node = JSONNode | string;
export declare type Node = JSONNode | string;
export default interface JSONNode {

@@ -7,3 +7,3 @@ type: string;

};
children: node[];
children: Node[];
}
{
"name": "@atjson/hir",
"version": "0.5.17",
"version": "0.7.0",
"description": "Libraries for annotated JSON documents",

@@ -23,10 +23,8 @@ "contributors": [

"devDependencies": {
"tslint": "^5.7.0",
"typescript": "^2.4.2"
"tslint": "^5.9.1",
"typescript": "^2.6.2"
},
"dependencies": {
"@atjson/core": "^0.5.12",
"@types/entities": "^1.1.0",
"entities": "^1.1.1"
"@atjson/document": "^0.7.0"
}
}

@@ -1,11 +0,13 @@

import { Annotation } from '@atjson/core';
import { Annotation, Schema } from '@atjson/document';
import JSONNode from './json-node';
const ROOT_NODE_RANK = 0;
const BLOCK_NODE_RANK = 1;
const PARAGRAPH_NODE_RANK = 2;
const SPAN_NODE_RANK = 3;
const OBJECT_NODE_RANK = 4;
const PARSE_NODE_RANK = Number.MAX_SAFE_INTEGER;
const TEXT_NODE_RANK = Infinity;
const RANK = {
root: 0,
block: 1,
paragraph: 2,
inline: 3,
object: 4,
parse: Number.MAX_SAFE_INTEGER,
text: Infinity
};

@@ -26,74 +28,39 @@ export default class HIRNode {

private sibling: HIRNode | undefined;
private schema: Schema;
constructor(node: {type: string, start: number, end: number, attributes?: object, text?: string}) {
constructor(node: {type: string, start: number, end: number, attributes?: object, text?: string}, schema: Schema) {
this.type = node.type;
this.start = node.start;
this.end = node.end;
this.attributes = node.attributes;
this.rank = RANK.inline;
this.schema = schema || {};
switch (node.type) {
case 'root':
this.rank = ROOT_NODE_RANK;
break;
// Overrides on annotations are used first
if (node.display) {
this.rank = RANK[node.display];
case 'parse-token':
this.rank = PARSE_NODE_RANK;
break;
case 'text':
if (typeof(node.text) === 'string') {
this.text = node.text.slice(node.start, node.end);
this.rank = TEXT_NODE_RANK;
} else {
throw new Error('Encountered a text node with no text.');
}
break;
case 'paragraph':
this.rank = PARAGRAPH_NODE_RANK;
break;
case 'embed':
case 'image':
case 'asset':
case 'horizontal-rule':
case 'section-break':
this.rank = OBJECT_NODE_RANK;
break;
case 'bold':
case 'italic':
this.rank = SPAN_NODE_RANK;
break;
case 'callout':
case 'ordered-list':
case 'unordered-list':
case 'list-item':
case 'blockquote':
this.rank = BLOCK_NODE_RANK;
break;
default:
this.rank = SPAN_NODE_RANK;
// Handle built-in types first
} else if (node.type === 'text' && typeof node.text === 'string') {
this.rank = RANK.text;
this.text = node.text;
} else if (node.type === 'parse-token') {
this.rank = RANK.parse;
} else if (node.type === 'root') {
this.rank = RANK.root;
} else if (this.schema[this.type]) {
this.rank = RANK[this.schema[this.type].display];
}
}
toJSON(filter?: (node: HIRNode) => HIRNode): JSONNode|string {
let thisNode: HIRNode = this;
if (filter) {
thisNode = filter(this);
toJSON(): JSONNode | string {
if (this.type === 'text' && typeof this.text === 'string') {
return this.text;
}
if (thisNode.type === 'text' && typeof(thisNode.text) === 'string') {
return thisNode.text;
}
return {
type: thisNode.type,
attributes: thisNode.attributes,
children: thisNode.children().map(child => {
return child.toJSON(filter);
type: this.type,
attributes: this.attributes,
children: this.children().map(child => {
return child.toJSON();
})

@@ -105,3 +72,3 @@ };

if (this.child) {
return [this.child].concat(this.child.siblings()).filter((node) => node.type != 'parse-token');
return [this.child].concat(this.child.siblings()).filter(node => node.type !== 'parse-token');
} else {

@@ -121,3 +88,3 @@ return [];

insertAnnotation(annotation: Annotation): void {
let hirNode = new HIRNode(annotation);
let hirNode = new HIRNode(annotation, this.schema);
this.insertNode(hirNode);

@@ -134,3 +101,3 @@ }

// Don't insert Object Replacement Characters.
if (text.length === 1 && this.end - this.start === 1 && text === "\uFFFC") return;
if (text.length === 1 && this.end - this.start === 1 && text === '\uFFFC') return;

@@ -269,3 +236,3 @@ let node = new HIRNode({

trim(start: number, end: number): HIRNode|void {
trim(start: number, end: number): HIRNode | void {
let newStart = Math.max(this.start, start);

@@ -291,3 +258,3 @@ let newEnd = Math.min(this.end, end);

newNode.text = this.text.slice(newNode.start - this.start, newNode.end - this.start);
if (newNode.text === "\uFFFC") {
if (newNode.text === '\uFFFC') {
return;

@@ -294,0 +261,0 @@ }

@@ -1,3 +0,2 @@

import { Annotation, AtJSON } from '@atjson/core';
import * as entities from 'entities';
import Document, { Annotation } from '@atjson/document';
import HIRNode from './hir-node';

@@ -11,10 +10,9 @@ import JSONNode from './json-node';

constructor(atjson: string | AtJSON) {
if (atjson instanceof AtJSON) {
this.atjson = atjson;
} else if (typeof atjson === 'string') {
this.atjson = new AtJSON(atjson);
} else {
throw new Error('Invalid argument');
}
constructor(document: Document) {
this.document = new Document({
content: document.content,
contentType: document.contentType,
annotations: [...document.annotations],
schema: document.schema
});

@@ -24,13 +22,4 @@ this.populateHIR();

toJSON(): JSONNode|string {
if (this.atjson.contentType === 'text/html') {
return this.rootNode.toJSON((node: HIRNode): HIRNode => {
if (node.type === 'text' && typeof(node.text) === 'string') {
node.text = entities.decodeHTML5(node.text);
}
return node;
});
} else {
return this.rootNode.toJSON();
}
toJSON(): JSONNode | string {
return this.rootNode.toJSON();
}

@@ -40,17 +29,10 @@

let atjson = this.atjson;
atjson.annotations
.filter(a => a.type === 'parse-token')
.forEach((a, idx) => {
atjson.objectReplacementSubstitution(a)
});
atjson.annotations
let document = this.document;
document.annotations
.filter(a => a.start === a.end)
.forEach(a => {
atjson.insertText(a.start, "\uFFFC")
document.insertText(a.start, '\uFFFC');
a.start--;
});
atjson.annotations
.filter(a => a.type === 'parse-element')
.forEach(a => atjson.removeAnnotation(a));
});
document.where({ type: 'parse-element' }).remove();

@@ -60,79 +42,19 @@ this.rootNode = new HIRNode({

start: 0,
end: atjson.content.length
});
end: document.content.length
}, document.schema);
atjson.annotations
.sort((a: Annotation, b: Annotation) => {
if (a.start === b.start) {
if (a.type === b.type) {
return a.end - b.end;
} else {
return (b.end - b.start) - (a.end - a.start);
}
document.annotations.sort((a: Annotation, b: Annotation) => {
if (a.start === b.start) {
if (a.type === b.type) {
return a.end - b.end;
} else {
return a.start - b.start;
return (b.end - b.start) - (a.end - a.start);
}
}).forEach(annotation => this.rootNode.insertAnnotation(annotation));
this.rootNode.insertText(atjson.content);
}
parseContent(): Annotation[] {
return this.getParser().parse(this.atjson.content);
}
getParser() {
switch (this.atjson.contentType) {
case undefined:
case 'text/plain': {
return { parse: this.plainTextParser };
} else {
return a.start - b.start;
}
case 'text/atjson': {
return { parse() { return []; } };
}
default: {
throw new Error('Unsupported Content-Type');
}
}
}
}).forEach(annotation => this.rootNode.insertAnnotation(annotation));
plainTextParser(content: string): Annotation[] {
let prevIdx = 0;
let breakIdx = content.indexOf('\n\n', 0);
let annotations = [];
while (breakIdx !== -1) {
annotations.push({
type: 'paragraph',
start: prevIdx,
end: breakIdx
} as Annotation);
annotations.push({
type: 'parse-element',
start: prevIdx,
end: breakIdx + 2,
} as Annotation);
annotations.push({
type: 'parse-token',
start: breakIdx,
end: breakIdx + 2
} as Annotation);
prevIdx = breakIdx + 2;
breakIdx = content.indexOf('\n\n', breakIdx + 2);
}
if (prevIdx < content.length) {
annotations.push({
type: 'paragraph',
start: prevIdx,
end: content.length
} as Annotation);
}
return annotations;
this.rootNode.insertText(document.content);
}
}

@@ -1,2 +0,2 @@

export type node = JSONNode|string;
export type Node = JSONNode | string;

@@ -6,3 +6,3 @@ export default interface JSONNode {

attributes?: { [key: string]: any };
children: node[];
children: Node[];
}
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