@d-i-t-a/reader 2.0.5 → 2.0.6-beta.3
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/dist/esm/index.js
CHANGED
|
@@ -2471,13 +2471,13 @@ var require_common = __commonJS({
|
|
|
2471
2471
|
createDebug.names = [];
|
|
2472
2472
|
createDebug.skips = [];
|
|
2473
2473
|
let i;
|
|
2474
|
-
const
|
|
2475
|
-
const len =
|
|
2474
|
+
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
|
2475
|
+
const len = split.length;
|
|
2476
2476
|
for (i = 0; i < len; i++) {
|
|
2477
|
-
if (!
|
|
2477
|
+
if (!split[i]) {
|
|
2478
2478
|
continue;
|
|
2479
2479
|
}
|
|
2480
|
-
namespaces =
|
|
2480
|
+
namespaces = split[i].replace(/\*/g, ".*?");
|
|
2481
2481
|
if (namespaces[0] === "-") {
|
|
2482
2482
|
createDebug.skips.push(new RegExp("^" + namespaces.slice(1) + "$"));
|
|
2483
2483
|
} else {
|
|
@@ -11626,7 +11626,7 @@ var require_list = __commonJS({
|
|
|
11626
11626
|
split(string, separators, last) {
|
|
11627
11627
|
let array = [];
|
|
11628
11628
|
let current = "";
|
|
11629
|
-
let
|
|
11629
|
+
let split = false;
|
|
11630
11630
|
let func = 0;
|
|
11631
11631
|
let quote = false;
|
|
11632
11632
|
let escape2 = false;
|
|
@@ -11648,13 +11648,13 @@ var require_list = __commonJS({
|
|
|
11648
11648
|
func -= 1;
|
|
11649
11649
|
} else if (func === 0) {
|
|
11650
11650
|
if (separators.includes(letter))
|
|
11651
|
-
|
|
11651
|
+
split = true;
|
|
11652
11652
|
}
|
|
11653
|
-
if (
|
|
11653
|
+
if (split) {
|
|
11654
11654
|
if (current !== "")
|
|
11655
11655
|
array.push(current.trim());
|
|
11656
11656
|
current = "";
|
|
11657
|
-
|
|
11657
|
+
split = false;
|
|
11658
11658
|
} else {
|
|
11659
11659
|
current += letter;
|
|
11660
11660
|
}
|
|
@@ -18371,7 +18371,7 @@ var require_lodash = __commonJS({
|
|
|
18371
18371
|
var snakeCase = createCompounder(function(result2, word, index2) {
|
|
18372
18372
|
return result2 + (index2 ? "_" : "") + word.toLowerCase();
|
|
18373
18373
|
});
|
|
18374
|
-
function
|
|
18374
|
+
function split(string, separator, limit) {
|
|
18375
18375
|
if (limit && typeof limit != "number" && isIterateeCall(string, separator, limit)) {
|
|
18376
18376
|
separator = limit = undefined2;
|
|
18377
18377
|
}
|
|
@@ -18853,7 +18853,7 @@ var require_lodash = __commonJS({
|
|
|
18853
18853
|
lodash4.sortBy = sortBy;
|
|
18854
18854
|
lodash4.sortedUniq = sortedUniq;
|
|
18855
18855
|
lodash4.sortedUniqBy = sortedUniqBy;
|
|
18856
|
-
lodash4.split =
|
|
18856
|
+
lodash4.split = split;
|
|
18857
18857
|
lodash4.spread = spread;
|
|
18858
18858
|
lodash4.tail = tail;
|
|
18859
18859
|
lodash4.take = take;
|
|
@@ -29652,14 +29652,14 @@ var require_lib7 = __commonJS({
|
|
|
29652
29652
|
return regExpStr;
|
|
29653
29653
|
}
|
|
29654
29654
|
function semverify(version) {
|
|
29655
|
-
const
|
|
29656
|
-
if (isAllVersion(
|
|
29657
|
-
return [
|
|
29655
|
+
const split = Array.isArray(version) ? version : version.toString().split(".");
|
|
29656
|
+
if (isAllVersion(split[0])) {
|
|
29657
|
+
return [split[0], 0, 0];
|
|
29658
29658
|
}
|
|
29659
|
-
while (
|
|
29660
|
-
|
|
29659
|
+
while (split.length < 3) {
|
|
29660
|
+
split.push("0");
|
|
29661
29661
|
}
|
|
29662
|
-
return
|
|
29662
|
+
return split.map((_) => {
|
|
29663
29663
|
const num = typeof _ === "number" ? _ : parseInt(_, 10);
|
|
29664
29664
|
return isNaN(num) ? 0 : num;
|
|
29665
29665
|
});
|
|
@@ -33574,1201 +33574,6 @@ var require_eventemitter3 = __commonJS({
|
|
|
33574
33574
|
}
|
|
33575
33575
|
});
|
|
33576
33576
|
|
|
33577
|
-
// node_modules/@textlint/ast-node-types/lib/index.js
|
|
33578
|
-
var require_lib8 = __commonJS({
|
|
33579
|
-
"node_modules/@textlint/ast-node-types/lib/index.js"(exports) {
|
|
33580
|
-
init_polyfills();
|
|
33581
|
-
"use strict";
|
|
33582
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33583
|
-
exports.ASTNodeTypes = void 0;
|
|
33584
|
-
var ASTNodeTypes;
|
|
33585
|
-
(function(ASTNodeTypes2) {
|
|
33586
|
-
ASTNodeTypes2["Document"] = "Document";
|
|
33587
|
-
ASTNodeTypes2["DocumentExit"] = "Document:exit";
|
|
33588
|
-
ASTNodeTypes2["Paragraph"] = "Paragraph";
|
|
33589
|
-
ASTNodeTypes2["ParagraphExit"] = "Paragraph:exit";
|
|
33590
|
-
ASTNodeTypes2["BlockQuote"] = "BlockQuote";
|
|
33591
|
-
ASTNodeTypes2["BlockQuoteExit"] = "BlockQuote:exit";
|
|
33592
|
-
ASTNodeTypes2["ListItem"] = "ListItem";
|
|
33593
|
-
ASTNodeTypes2["ListItemExit"] = "ListItem:exit";
|
|
33594
|
-
ASTNodeTypes2["List"] = "List";
|
|
33595
|
-
ASTNodeTypes2["ListExit"] = "List:exit";
|
|
33596
|
-
ASTNodeTypes2["Header"] = "Header";
|
|
33597
|
-
ASTNodeTypes2["HeaderExit"] = "Header:exit";
|
|
33598
|
-
ASTNodeTypes2["CodeBlock"] = "CodeBlock";
|
|
33599
|
-
ASTNodeTypes2["CodeBlockExit"] = "CodeBlock:exit";
|
|
33600
|
-
ASTNodeTypes2["HtmlBlock"] = "HtmlBlock";
|
|
33601
|
-
ASTNodeTypes2["HtmlBlockExit"] = "HtmlBlock:exit";
|
|
33602
|
-
ASTNodeTypes2["HorizontalRule"] = "HorizontalRule";
|
|
33603
|
-
ASTNodeTypes2["HorizontalRuleExit"] = "HorizontalRule:exit";
|
|
33604
|
-
ASTNodeTypes2["Comment"] = "Comment";
|
|
33605
|
-
ASTNodeTypes2["CommentExit"] = "Comment:exit";
|
|
33606
|
-
ASTNodeTypes2["ReferenceDef"] = "ReferenceDef";
|
|
33607
|
-
ASTNodeTypes2["ReferenceDefExit"] = "ReferenceDef:exit";
|
|
33608
|
-
ASTNodeTypes2["Str"] = "Str";
|
|
33609
|
-
ASTNodeTypes2["StrExit"] = "Str:exit";
|
|
33610
|
-
ASTNodeTypes2["Break"] = "Break";
|
|
33611
|
-
ASTNodeTypes2["BreakExit"] = "Break:exit";
|
|
33612
|
-
ASTNodeTypes2["Emphasis"] = "Emphasis";
|
|
33613
|
-
ASTNodeTypes2["EmphasisExit"] = "Emphasis:exit";
|
|
33614
|
-
ASTNodeTypes2["Strong"] = "Strong";
|
|
33615
|
-
ASTNodeTypes2["StrongExit"] = "Strong:exit";
|
|
33616
|
-
ASTNodeTypes2["Html"] = "Html";
|
|
33617
|
-
ASTNodeTypes2["HtmlExit"] = "Html:exit";
|
|
33618
|
-
ASTNodeTypes2["Link"] = "Link";
|
|
33619
|
-
ASTNodeTypes2["LinkExit"] = "Link:exit";
|
|
33620
|
-
ASTNodeTypes2["Image"] = "Image";
|
|
33621
|
-
ASTNodeTypes2["ImageExit"] = "Image:exit";
|
|
33622
|
-
ASTNodeTypes2["Code"] = "Code";
|
|
33623
|
-
ASTNodeTypes2["CodeExit"] = "Code:exit";
|
|
33624
|
-
ASTNodeTypes2["Delete"] = "Delete";
|
|
33625
|
-
ASTNodeTypes2["DeleteExit"] = "Delete:exit";
|
|
33626
|
-
})(ASTNodeTypes = exports.ASTNodeTypes || (exports.ASTNodeTypes = {}));
|
|
33627
|
-
}
|
|
33628
|
-
});
|
|
33629
|
-
|
|
33630
|
-
// node_modules/boundary/lib/index.js
|
|
33631
|
-
var require_lib9 = __commonJS({
|
|
33632
|
-
"node_modules/boundary/lib/index.js"(exports) {
|
|
33633
|
-
init_polyfills();
|
|
33634
|
-
"use strict";
|
|
33635
|
-
function compare(v1, v2) {
|
|
33636
|
-
return v1 < v2;
|
|
33637
|
-
}
|
|
33638
|
-
function upperBound(array, value, comp) {
|
|
33639
|
-
if (comp === void 0)
|
|
33640
|
-
comp = compare;
|
|
33641
|
-
return function() {
|
|
33642
|
-
var len = array.length;
|
|
33643
|
-
var i = 0;
|
|
33644
|
-
while (len) {
|
|
33645
|
-
var diff = len >>> 1;
|
|
33646
|
-
var cursor = i + diff;
|
|
33647
|
-
if (comp(value, array[cursor])) {
|
|
33648
|
-
len = diff;
|
|
33649
|
-
} else {
|
|
33650
|
-
i = cursor + 1;
|
|
33651
|
-
len -= diff + 1;
|
|
33652
|
-
}
|
|
33653
|
-
}
|
|
33654
|
-
return i;
|
|
33655
|
-
}();
|
|
33656
|
-
}
|
|
33657
|
-
function lowerBound(array, value, comp) {
|
|
33658
|
-
if (comp === void 0)
|
|
33659
|
-
comp = compare;
|
|
33660
|
-
return function() {
|
|
33661
|
-
var len = array.length;
|
|
33662
|
-
var i = 0;
|
|
33663
|
-
while (len) {
|
|
33664
|
-
var diff = len >>> 1;
|
|
33665
|
-
var cursor = i + diff;
|
|
33666
|
-
if (comp(array[cursor], value)) {
|
|
33667
|
-
i = cursor + 1;
|
|
33668
|
-
len -= diff + 1;
|
|
33669
|
-
} else {
|
|
33670
|
-
len = diff;
|
|
33671
|
-
}
|
|
33672
|
-
}
|
|
33673
|
-
return i;
|
|
33674
|
-
}();
|
|
33675
|
-
}
|
|
33676
|
-
function binarySearch(array, value, comp) {
|
|
33677
|
-
if (comp === void 0)
|
|
33678
|
-
comp = compare;
|
|
33679
|
-
return function() {
|
|
33680
|
-
var cursor = lowerBound(array, value, comp);
|
|
33681
|
-
return cursor !== array.length && !comp(value, array[cursor]);
|
|
33682
|
-
}();
|
|
33683
|
-
}
|
|
33684
|
-
exports.compare = compare;
|
|
33685
|
-
exports.lowerBound = lowerBound;
|
|
33686
|
-
exports.upperBound = upperBound;
|
|
33687
|
-
exports.binarySearch = binarySearch;
|
|
33688
|
-
}
|
|
33689
|
-
});
|
|
33690
|
-
|
|
33691
|
-
// node_modules/structured-source/lib/structured-source.js
|
|
33692
|
-
var require_structured_source = __commonJS({
|
|
33693
|
-
"node_modules/structured-source/lib/structured-source.js"(exports) {
|
|
33694
|
-
init_polyfills();
|
|
33695
|
-
"use strict";
|
|
33696
|
-
var _classProps = function(child, staticProps, instanceProps) {
|
|
33697
|
-
if (staticProps)
|
|
33698
|
-
Object.defineProperties(child, staticProps);
|
|
33699
|
-
if (instanceProps)
|
|
33700
|
-
Object.defineProperties(child.prototype, instanceProps);
|
|
33701
|
-
};
|
|
33702
|
-
var upperBound = require_lib9().upperBound;
|
|
33703
|
-
var Position = function Position2(line, column) {
|
|
33704
|
-
this.line = line;
|
|
33705
|
-
this.column = column;
|
|
33706
|
-
};
|
|
33707
|
-
exports.Position = Position;
|
|
33708
|
-
var SourceLocation = function SourceLocation2(start, end) {
|
|
33709
|
-
this.start = start;
|
|
33710
|
-
this.end = end;
|
|
33711
|
-
};
|
|
33712
|
-
exports.SourceLocation = SourceLocation;
|
|
33713
|
-
var StructuredSource = function() {
|
|
33714
|
-
var StructuredSource2 = function StructuredSource3(source) {
|
|
33715
|
-
this.indice = [0];
|
|
33716
|
-
var regexp = /[\r\n\u2028\u2029]/g;
|
|
33717
|
-
var length = source.length;
|
|
33718
|
-
regexp.lastIndex = 0;
|
|
33719
|
-
while (true) {
|
|
33720
|
-
var result = regexp.exec(source);
|
|
33721
|
-
if (!result) {
|
|
33722
|
-
break;
|
|
33723
|
-
}
|
|
33724
|
-
var index2 = result.index;
|
|
33725
|
-
if (source.charCodeAt(index2) === 13 && source.charCodeAt(index2 + 1) === 10) {
|
|
33726
|
-
index2 += 1;
|
|
33727
|
-
}
|
|
33728
|
-
var nextIndex = index2 + 1;
|
|
33729
|
-
if (length < nextIndex) {
|
|
33730
|
-
break;
|
|
33731
|
-
}
|
|
33732
|
-
this.indice.push(nextIndex);
|
|
33733
|
-
regexp.lastIndex = nextIndex;
|
|
33734
|
-
}
|
|
33735
|
-
};
|
|
33736
|
-
StructuredSource2.prototype.locationToRange = function(loc) {
|
|
33737
|
-
return [this.positionToIndex(loc.start), this.positionToIndex(loc.end)];
|
|
33738
|
-
};
|
|
33739
|
-
StructuredSource2.prototype.rangeToLocation = function(range) {
|
|
33740
|
-
return new SourceLocation(this.indexToPosition(range[0]), this.indexToPosition(range[1]));
|
|
33741
|
-
};
|
|
33742
|
-
StructuredSource2.prototype.positionToIndex = function(pos) {
|
|
33743
|
-
var start = this.indice[pos.line - 1];
|
|
33744
|
-
return start + pos.column;
|
|
33745
|
-
};
|
|
33746
|
-
StructuredSource2.prototype.indexToPosition = function(index2) {
|
|
33747
|
-
var startLine = upperBound(this.indice, index2);
|
|
33748
|
-
return new Position(startLine, index2 - this.indice[startLine - 1]);
|
|
33749
|
-
};
|
|
33750
|
-
_classProps(StructuredSource2, null, {
|
|
33751
|
-
line: {
|
|
33752
|
-
get: function() {
|
|
33753
|
-
return this.indice.length;
|
|
33754
|
-
}
|
|
33755
|
-
}
|
|
33756
|
-
});
|
|
33757
|
-
return StructuredSource2;
|
|
33758
|
-
}();
|
|
33759
|
-
exports["default"] = StructuredSource;
|
|
33760
|
-
}
|
|
33761
|
-
});
|
|
33762
|
-
|
|
33763
|
-
// node_modules/structured-source/lib/index.js
|
|
33764
|
-
var require_lib10 = __commonJS({
|
|
33765
|
-
"node_modules/structured-source/lib/index.js"(exports, module) {
|
|
33766
|
-
init_polyfills();
|
|
33767
|
-
"use strict";
|
|
33768
|
-
var StructuredSource = require_structured_source()["default"];
|
|
33769
|
-
module.exports = StructuredSource;
|
|
33770
|
-
}
|
|
33771
|
-
});
|
|
33772
|
-
|
|
33773
|
-
// node_modules/sentence-splitter/lib/parser/SourceCode.js
|
|
33774
|
-
var require_SourceCode = __commonJS({
|
|
33775
|
-
"node_modules/sentence-splitter/lib/parser/SourceCode.js"(exports) {
|
|
33776
|
-
init_polyfills();
|
|
33777
|
-
"use strict";
|
|
33778
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
33779
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
33780
|
-
};
|
|
33781
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33782
|
-
exports.SourceCode = void 0;
|
|
33783
|
-
var structured_source_1 = __importDefault(require_lib10());
|
|
33784
|
-
var SourceCode = function() {
|
|
33785
|
-
function SourceCode2(input) {
|
|
33786
|
-
this.index = 0;
|
|
33787
|
-
this.contexts = [];
|
|
33788
|
-
this.contextRanges = [];
|
|
33789
|
-
if (typeof input === "string") {
|
|
33790
|
-
this.textCharacters = input.split("");
|
|
33791
|
-
this.source = new structured_source_1.default(input);
|
|
33792
|
-
this.startOffset = 0;
|
|
33793
|
-
this.firstChildPadding = 0;
|
|
33794
|
-
} else {
|
|
33795
|
-
this.sourceNode = input;
|
|
33796
|
-
this.startOffset = this.sourceNode.range[0];
|
|
33797
|
-
this.index = this.startOffset;
|
|
33798
|
-
var lineBreaks = Array.from(new Array(this.sourceNode.loc.start.line - 1)).fill("\n");
|
|
33799
|
-
var offset = Array.from(new Array(this.startOffset - lineBreaks.length)).fill("\u222F");
|
|
33800
|
-
this.textCharacters = offset.concat(lineBreaks, input.raw.split(""));
|
|
33801
|
-
this.source = new structured_source_1.default(this.textCharacters.join(""));
|
|
33802
|
-
if (this.sourceNode.children[0]) {
|
|
33803
|
-
this.firstChildPadding = this.sourceNode.children[0].range[0] - this.startOffset;
|
|
33804
|
-
} else {
|
|
33805
|
-
this.firstChildPadding = 0;
|
|
33806
|
-
}
|
|
33807
|
-
}
|
|
33808
|
-
}
|
|
33809
|
-
SourceCode2.prototype.markContextRange = function(range) {
|
|
33810
|
-
this.contextRanges.push(range);
|
|
33811
|
-
};
|
|
33812
|
-
SourceCode2.prototype.isInContextRange = function() {
|
|
33813
|
-
var offset = this.offset;
|
|
33814
|
-
return this.contextRanges.some(function(range) {
|
|
33815
|
-
return range[0] <= offset && offset < range[1];
|
|
33816
|
-
});
|
|
33817
|
-
};
|
|
33818
|
-
SourceCode2.prototype.enterContext = function(context) {
|
|
33819
|
-
this.contexts.push(context);
|
|
33820
|
-
};
|
|
33821
|
-
SourceCode2.prototype.isInContext = function(context) {
|
|
33822
|
-
if (!context) {
|
|
33823
|
-
return this.contexts.length > 0;
|
|
33824
|
-
}
|
|
33825
|
-
return this.contexts.some(function(targetContext) {
|
|
33826
|
-
return targetContext === context;
|
|
33827
|
-
});
|
|
33828
|
-
};
|
|
33829
|
-
SourceCode2.prototype.leaveContext = function(context) {
|
|
33830
|
-
var index2 = this.contexts.lastIndexOf(context);
|
|
33831
|
-
if (index2 !== -1) {
|
|
33832
|
-
this.contexts.splice(index2, 1);
|
|
33833
|
-
}
|
|
33834
|
-
};
|
|
33835
|
-
Object.defineProperty(SourceCode2.prototype, "offset", {
|
|
33836
|
-
get: function() {
|
|
33837
|
-
return this.index + this.firstChildPadding;
|
|
33838
|
-
},
|
|
33839
|
-
enumerable: false,
|
|
33840
|
-
configurable: true
|
|
33841
|
-
});
|
|
33842
|
-
SourceCode2.prototype.now = function() {
|
|
33843
|
-
var indexWithChildrenOffset = this.offset;
|
|
33844
|
-
var position = this.source.indexToPosition(indexWithChildrenOffset);
|
|
33845
|
-
return {
|
|
33846
|
-
line: position.line,
|
|
33847
|
-
column: position.column,
|
|
33848
|
-
offset: indexWithChildrenOffset
|
|
33849
|
-
};
|
|
33850
|
-
};
|
|
33851
|
-
Object.defineProperty(SourceCode2.prototype, "hasEnd", {
|
|
33852
|
-
get: function() {
|
|
33853
|
-
return this.read() === false;
|
|
33854
|
-
},
|
|
33855
|
-
enumerable: false,
|
|
33856
|
-
configurable: true
|
|
33857
|
-
});
|
|
33858
|
-
SourceCode2.prototype.read = function(over) {
|
|
33859
|
-
if (over === void 0) {
|
|
33860
|
-
over = 0;
|
|
33861
|
-
}
|
|
33862
|
-
var index2 = this.offset + over;
|
|
33863
|
-
if (index2 < this.startOffset) {
|
|
33864
|
-
return false;
|
|
33865
|
-
}
|
|
33866
|
-
if (0 <= index2 && index2 < this.textCharacters.length) {
|
|
33867
|
-
return this.textCharacters[index2];
|
|
33868
|
-
}
|
|
33869
|
-
return false;
|
|
33870
|
-
};
|
|
33871
|
-
SourceCode2.prototype.readNode = function(over) {
|
|
33872
|
-
if (over === void 0) {
|
|
33873
|
-
over = 0;
|
|
33874
|
-
}
|
|
33875
|
-
if (!this.sourceNode) {
|
|
33876
|
-
return false;
|
|
33877
|
-
}
|
|
33878
|
-
var index2 = this.offset + over;
|
|
33879
|
-
if (index2 < this.startOffset) {
|
|
33880
|
-
return false;
|
|
33881
|
-
}
|
|
33882
|
-
var matchNodeList = this.sourceNode.children.filter(function(node) {
|
|
33883
|
-
return node.range[0] <= index2 && index2 < node.range[1];
|
|
33884
|
-
});
|
|
33885
|
-
if (matchNodeList.length > 0) {
|
|
33886
|
-
return matchNodeList[matchNodeList.length - 1];
|
|
33887
|
-
}
|
|
33888
|
-
return false;
|
|
33889
|
-
};
|
|
33890
|
-
SourceCode2.prototype.peek = function() {
|
|
33891
|
-
this.index += 1;
|
|
33892
|
-
};
|
|
33893
|
-
SourceCode2.prototype.peekNode = function(node) {
|
|
33894
|
-
this.index += node.range[1] - node.range[0];
|
|
33895
|
-
};
|
|
33896
|
-
SourceCode2.prototype.seekNext = function(parser) {
|
|
33897
|
-
var startPosition = this.now();
|
|
33898
|
-
parser.seek(this);
|
|
33899
|
-
var endPosition = this.now();
|
|
33900
|
-
var value = this.sliceRange(startPosition.offset, endPosition.offset);
|
|
33901
|
-
return {
|
|
33902
|
-
value,
|
|
33903
|
-
startPosition,
|
|
33904
|
-
endPosition
|
|
33905
|
-
};
|
|
33906
|
-
};
|
|
33907
|
-
SourceCode2.prototype.sliceRange = function(start, end) {
|
|
33908
|
-
return this.textCharacters.slice(start, end).join("");
|
|
33909
|
-
};
|
|
33910
|
-
return SourceCode2;
|
|
33911
|
-
}();
|
|
33912
|
-
exports.SourceCode = SourceCode;
|
|
33913
|
-
}
|
|
33914
|
-
});
|
|
33915
|
-
|
|
33916
|
-
// node_modules/sentence-splitter/lib/parser/NewLineParser.js
|
|
33917
|
-
var require_NewLineParser = __commonJS({
|
|
33918
|
-
"node_modules/sentence-splitter/lib/parser/NewLineParser.js"(exports) {
|
|
33919
|
-
init_polyfills();
|
|
33920
|
-
"use strict";
|
|
33921
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33922
|
-
exports.NewLineParser = void 0;
|
|
33923
|
-
var NewLineParser = function() {
|
|
33924
|
-
function NewLineParser2() {
|
|
33925
|
-
}
|
|
33926
|
-
NewLineParser2.prototype.test = function(sourceCode) {
|
|
33927
|
-
var string = sourceCode.read();
|
|
33928
|
-
if (!string) {
|
|
33929
|
-
return false;
|
|
33930
|
-
}
|
|
33931
|
-
return /[\r\n]/.test(string);
|
|
33932
|
-
};
|
|
33933
|
-
NewLineParser2.prototype.seek = function(sourceCode) {
|
|
33934
|
-
while (this.test(sourceCode)) {
|
|
33935
|
-
sourceCode.peek();
|
|
33936
|
-
}
|
|
33937
|
-
};
|
|
33938
|
-
return NewLineParser2;
|
|
33939
|
-
}();
|
|
33940
|
-
exports.NewLineParser = NewLineParser;
|
|
33941
|
-
}
|
|
33942
|
-
});
|
|
33943
|
-
|
|
33944
|
-
// node_modules/sentence-splitter/lib/parser/SpaceParser.js
|
|
33945
|
-
var require_SpaceParser = __commonJS({
|
|
33946
|
-
"node_modules/sentence-splitter/lib/parser/SpaceParser.js"(exports) {
|
|
33947
|
-
init_polyfills();
|
|
33948
|
-
"use strict";
|
|
33949
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33950
|
-
exports.SpaceParser = void 0;
|
|
33951
|
-
var SpaceParser = function() {
|
|
33952
|
-
function SpaceParser2() {
|
|
33953
|
-
}
|
|
33954
|
-
SpaceParser2.prototype.test = function(sourceCode) {
|
|
33955
|
-
var string = sourceCode.read();
|
|
33956
|
-
if (!string) {
|
|
33957
|
-
return false;
|
|
33958
|
-
}
|
|
33959
|
-
return /\s/.test(string);
|
|
33960
|
-
};
|
|
33961
|
-
SpaceParser2.prototype.seek = function(sourceCode) {
|
|
33962
|
-
while (this.test(sourceCode)) {
|
|
33963
|
-
sourceCode.peek();
|
|
33964
|
-
}
|
|
33965
|
-
};
|
|
33966
|
-
return SpaceParser2;
|
|
33967
|
-
}();
|
|
33968
|
-
exports.SpaceParser = SpaceParser;
|
|
33969
|
-
}
|
|
33970
|
-
});
|
|
33971
|
-
|
|
33972
|
-
// node_modules/sentence-splitter/lib/parser/SeparatorParser.js
|
|
33973
|
-
var require_SeparatorParser = __commonJS({
|
|
33974
|
-
"node_modules/sentence-splitter/lib/parser/SeparatorParser.js"(exports) {
|
|
33975
|
-
init_polyfills();
|
|
33976
|
-
"use strict";
|
|
33977
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33978
|
-
exports.SeparatorParser = exports.DefaultOptions = void 0;
|
|
33979
|
-
exports.DefaultOptions = {
|
|
33980
|
-
separatorCharacters: [
|
|
33981
|
-
".",
|
|
33982
|
-
"\uFF0E",
|
|
33983
|
-
"\u3002",
|
|
33984
|
-
"?",
|
|
33985
|
-
"!",
|
|
33986
|
-
"\uFF1F",
|
|
33987
|
-
"\uFF01"
|
|
33988
|
-
]
|
|
33989
|
-
};
|
|
33990
|
-
var SeparatorParser = function() {
|
|
33991
|
-
function SeparatorParser2(options) {
|
|
33992
|
-
this.options = options;
|
|
33993
|
-
this.separatorCharacters = options && options.separatorCharacters ? options.separatorCharacters : exports.DefaultOptions.separatorCharacters;
|
|
33994
|
-
}
|
|
33995
|
-
SeparatorParser2.prototype.test = function(sourceCode) {
|
|
33996
|
-
if (sourceCode.isInContext()) {
|
|
33997
|
-
return false;
|
|
33998
|
-
}
|
|
33999
|
-
if (sourceCode.isInContextRange()) {
|
|
34000
|
-
return false;
|
|
34001
|
-
}
|
|
34002
|
-
var firstChar = sourceCode.read();
|
|
34003
|
-
var nextChar = sourceCode.read(1);
|
|
34004
|
-
if (!firstChar) {
|
|
34005
|
-
return false;
|
|
34006
|
-
}
|
|
34007
|
-
if (!this.separatorCharacters.includes(firstChar)) {
|
|
34008
|
-
return false;
|
|
34009
|
-
}
|
|
34010
|
-
if (firstChar === ".") {
|
|
34011
|
-
if (nextChar) {
|
|
34012
|
-
return /[\s\t\r\n]/.test(nextChar);
|
|
34013
|
-
} else {
|
|
34014
|
-
return true;
|
|
34015
|
-
}
|
|
34016
|
-
}
|
|
34017
|
-
return true;
|
|
34018
|
-
};
|
|
34019
|
-
SeparatorParser2.prototype.seek = function(sourceCode) {
|
|
34020
|
-
while (this.test(sourceCode)) {
|
|
34021
|
-
sourceCode.peek();
|
|
34022
|
-
}
|
|
34023
|
-
};
|
|
34024
|
-
return SeparatorParser2;
|
|
34025
|
-
}();
|
|
34026
|
-
exports.SeparatorParser = SeparatorParser;
|
|
34027
|
-
}
|
|
34028
|
-
});
|
|
34029
|
-
|
|
34030
|
-
// node_modules/sentence-splitter/lib/parser/AnyValueParser.js
|
|
34031
|
-
var require_AnyValueParser = __commonJS({
|
|
34032
|
-
"node_modules/sentence-splitter/lib/parser/AnyValueParser.js"(exports) {
|
|
34033
|
-
init_polyfills();
|
|
34034
|
-
"use strict";
|
|
34035
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34036
|
-
exports.AnyValueParser = void 0;
|
|
34037
|
-
var AnyValueParser = function() {
|
|
34038
|
-
function AnyValueParser2(options) {
|
|
34039
|
-
this.parsers = options.parsers;
|
|
34040
|
-
this.markers = options.markers;
|
|
34041
|
-
}
|
|
34042
|
-
AnyValueParser2.prototype.test = function(sourceCode) {
|
|
34043
|
-
if (sourceCode.hasEnd) {
|
|
34044
|
-
return false;
|
|
34045
|
-
}
|
|
34046
|
-
return this.parsers.every(function(parser) {
|
|
34047
|
-
return !parser.test(sourceCode);
|
|
34048
|
-
});
|
|
34049
|
-
};
|
|
34050
|
-
AnyValueParser2.prototype.seek = function(sourceCode) {
|
|
34051
|
-
var currentNode = sourceCode.readNode();
|
|
34052
|
-
if (!currentNode) {
|
|
34053
|
-
while (this.test(sourceCode)) {
|
|
34054
|
-
this.markers.forEach(function(marker) {
|
|
34055
|
-
return marker.mark(sourceCode);
|
|
34056
|
-
});
|
|
34057
|
-
sourceCode.peek();
|
|
34058
|
-
}
|
|
34059
|
-
return;
|
|
34060
|
-
}
|
|
34061
|
-
var isInCurrentNode = function() {
|
|
34062
|
-
var currentOffset = sourceCode.offset;
|
|
34063
|
-
return currentNode.range[0] <= currentOffset && currentOffset < currentNode.range[1];
|
|
34064
|
-
};
|
|
34065
|
-
while (isInCurrentNode() && this.test(sourceCode)) {
|
|
34066
|
-
this.markers.forEach(function(marker) {
|
|
34067
|
-
return marker.mark(sourceCode);
|
|
34068
|
-
});
|
|
34069
|
-
sourceCode.peek();
|
|
34070
|
-
}
|
|
34071
|
-
};
|
|
34072
|
-
return AnyValueParser2;
|
|
34073
|
-
}();
|
|
34074
|
-
exports.AnyValueParser = AnyValueParser;
|
|
34075
|
-
}
|
|
34076
|
-
});
|
|
34077
|
-
|
|
34078
|
-
// node_modules/sentence-splitter/lib/parser/lang/English.js
|
|
34079
|
-
var require_English = __commonJS({
|
|
34080
|
-
"node_modules/sentence-splitter/lib/parser/lang/English.js"(exports) {
|
|
34081
|
-
init_polyfills();
|
|
34082
|
-
"use strict";
|
|
34083
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34084
|
-
exports.English = void 0;
|
|
34085
|
-
exports.English = {
|
|
34086
|
-
ABBREVIATIONS: [
|
|
34087
|
-
"Adj.",
|
|
34088
|
-
"Adm.",
|
|
34089
|
-
"Adv.",
|
|
34090
|
-
"Al.",
|
|
34091
|
-
"Ala.",
|
|
34092
|
-
"Alta.",
|
|
34093
|
-
"Apr.",
|
|
34094
|
-
"Arc.",
|
|
34095
|
-
"Ariz.",
|
|
34096
|
-
"Ark.",
|
|
34097
|
-
"Art.",
|
|
34098
|
-
"Assn.",
|
|
34099
|
-
"Asst.",
|
|
34100
|
-
"Attys.",
|
|
34101
|
-
"Aug.",
|
|
34102
|
-
"Ave.",
|
|
34103
|
-
"Bart.",
|
|
34104
|
-
"Bld.",
|
|
34105
|
-
"Bldg.",
|
|
34106
|
-
"Blvd.",
|
|
34107
|
-
"Brig.",
|
|
34108
|
-
"Bros.",
|
|
34109
|
-
"Btw.",
|
|
34110
|
-
"Cal.",
|
|
34111
|
-
"Calif.",
|
|
34112
|
-
"Capt.",
|
|
34113
|
-
"Cl.",
|
|
34114
|
-
"Cmdr.",
|
|
34115
|
-
"Co.",
|
|
34116
|
-
"Col.",
|
|
34117
|
-
"Colo.",
|
|
34118
|
-
"Comdr.",
|
|
34119
|
-
"Con.",
|
|
34120
|
-
"Conn.",
|
|
34121
|
-
"Corp.",
|
|
34122
|
-
"Cpl.",
|
|
34123
|
-
"Cres.",
|
|
34124
|
-
"Ct.",
|
|
34125
|
-
"D.phil.",
|
|
34126
|
-
"Dak.",
|
|
34127
|
-
"Dec.",
|
|
34128
|
-
"Del.",
|
|
34129
|
-
"Dept.",
|
|
34130
|
-
"Det.",
|
|
34131
|
-
"Dist.",
|
|
34132
|
-
"Dr.",
|
|
34133
|
-
"Dr.phil.",
|
|
34134
|
-
"Dr.philos.",
|
|
34135
|
-
"Drs.",
|
|
34136
|
-
"E.g.",
|
|
34137
|
-
"Ens.",
|
|
34138
|
-
"Esp.",
|
|
34139
|
-
"Esq.",
|
|
34140
|
-
"Etc.",
|
|
34141
|
-
"Exp.",
|
|
34142
|
-
"Expy.",
|
|
34143
|
-
"Ext.",
|
|
34144
|
-
"Feb.",
|
|
34145
|
-
"Fed.",
|
|
34146
|
-
"Fla.",
|
|
34147
|
-
"Ft.",
|
|
34148
|
-
"Fwy.",
|
|
34149
|
-
"Fy.",
|
|
34150
|
-
"Ga.",
|
|
34151
|
-
"Gen.",
|
|
34152
|
-
"Gov.",
|
|
34153
|
-
"Hon.",
|
|
34154
|
-
"Hosp.",
|
|
34155
|
-
"Hr.",
|
|
34156
|
-
"Hway.",
|
|
34157
|
-
"Hwy.",
|
|
34158
|
-
"I.e.",
|
|
34159
|
-
"Ia.",
|
|
34160
|
-
"Id.",
|
|
34161
|
-
"Ida.",
|
|
34162
|
-
"Ill.",
|
|
34163
|
-
"Inc.",
|
|
34164
|
-
"Ind.",
|
|
34165
|
-
"Ing.",
|
|
34166
|
-
"Insp.",
|
|
34167
|
-
"Is.",
|
|
34168
|
-
"Jan.",
|
|
34169
|
-
"Jr.",
|
|
34170
|
-
"Jul.",
|
|
34171
|
-
"Jun.",
|
|
34172
|
-
"Kan.",
|
|
34173
|
-
"Kans.",
|
|
34174
|
-
"Ken.",
|
|
34175
|
-
"Ky.",
|
|
34176
|
-
"La.",
|
|
34177
|
-
"Lt.",
|
|
34178
|
-
"Ltd.",
|
|
34179
|
-
"Maj.",
|
|
34180
|
-
"Man.",
|
|
34181
|
-
"Mar.",
|
|
34182
|
-
"Mass.",
|
|
34183
|
-
"May.",
|
|
34184
|
-
"Md.",
|
|
34185
|
-
"Me.",
|
|
34186
|
-
"Med.",
|
|
34187
|
-
"Messrs.",
|
|
34188
|
-
"Mex.",
|
|
34189
|
-
"Mfg.",
|
|
34190
|
-
"Mich.",
|
|
34191
|
-
"Min.",
|
|
34192
|
-
"Minn.",
|
|
34193
|
-
"Miss.",
|
|
34194
|
-
"Mlle.",
|
|
34195
|
-
"Mm.",
|
|
34196
|
-
"Mme.",
|
|
34197
|
-
"Mo.",
|
|
34198
|
-
"Mont.",
|
|
34199
|
-
"Mr.",
|
|
34200
|
-
"Mrs.",
|
|
34201
|
-
"Ms.",
|
|
34202
|
-
"Msgr.",
|
|
34203
|
-
"Mssrs.",
|
|
34204
|
-
"Mt.",
|
|
34205
|
-
"Mtn.",
|
|
34206
|
-
"Neb.",
|
|
34207
|
-
"Nebr.",
|
|
34208
|
-
"Nev.",
|
|
34209
|
-
"No.",
|
|
34210
|
-
"Nos.",
|
|
34211
|
-
"Nov.",
|
|
34212
|
-
"Nr.",
|
|
34213
|
-
"Oct.",
|
|
34214
|
-
"Ok.",
|
|
34215
|
-
"Okla.",
|
|
34216
|
-
"Ont.",
|
|
34217
|
-
"Op.",
|
|
34218
|
-
"Ord.",
|
|
34219
|
-
"Ore.",
|
|
34220
|
-
"P.",
|
|
34221
|
-
"Pa.",
|
|
34222
|
-
"Pd.",
|
|
34223
|
-
"Pde.",
|
|
34224
|
-
"Penn.",
|
|
34225
|
-
"Penna.",
|
|
34226
|
-
"Pfc.",
|
|
34227
|
-
"Ph.",
|
|
34228
|
-
"Ph.d.",
|
|
34229
|
-
"Pl.",
|
|
34230
|
-
"Plz.",
|
|
34231
|
-
"Pp.",
|
|
34232
|
-
"Prof.",
|
|
34233
|
-
"Pvt.",
|
|
34234
|
-
"Que.",
|
|
34235
|
-
"Rd.",
|
|
34236
|
-
"Rs.",
|
|
34237
|
-
"Ref.",
|
|
34238
|
-
"Rep.",
|
|
34239
|
-
"Reps.",
|
|
34240
|
-
"Res.",
|
|
34241
|
-
"Rev.",
|
|
34242
|
-
"Rt.",
|
|
34243
|
-
"Sask.",
|
|
34244
|
-
"Sec.",
|
|
34245
|
-
"Sen.",
|
|
34246
|
-
"Sens.",
|
|
34247
|
-
"Sep.",
|
|
34248
|
-
"Sept.",
|
|
34249
|
-
"Sfc.",
|
|
34250
|
-
"Sgt.",
|
|
34251
|
-
"Sr.",
|
|
34252
|
-
"St.",
|
|
34253
|
-
"Supt.",
|
|
34254
|
-
"Surg.",
|
|
34255
|
-
"Tce.",
|
|
34256
|
-
"Tenn.",
|
|
34257
|
-
"Tex.",
|
|
34258
|
-
"Univ.",
|
|
34259
|
-
"Usafa.",
|
|
34260
|
-
"U.S.",
|
|
34261
|
-
"Ut.",
|
|
34262
|
-
"Va.",
|
|
34263
|
-
"V.",
|
|
34264
|
-
"Ver.",
|
|
34265
|
-
"Vs.",
|
|
34266
|
-
"Vt.",
|
|
34267
|
-
"Wash.",
|
|
34268
|
-
"Wis.",
|
|
34269
|
-
"Wisc.",
|
|
34270
|
-
"Wy.",
|
|
34271
|
-
"Wyo.",
|
|
34272
|
-
"Yuk."
|
|
34273
|
-
],
|
|
34274
|
-
PREPOSITIVE_ABBREVIATIONS: [
|
|
34275
|
-
"Adm.",
|
|
34276
|
-
"Attys.",
|
|
34277
|
-
"Brig.",
|
|
34278
|
-
"Capt.",
|
|
34279
|
-
"Cmdr.",
|
|
34280
|
-
"Col.",
|
|
34281
|
-
"Cpl.",
|
|
34282
|
-
"Det.",
|
|
34283
|
-
"Dr.",
|
|
34284
|
-
"Gen.",
|
|
34285
|
-
"Gov.",
|
|
34286
|
-
"Ing.",
|
|
34287
|
-
"Lt.",
|
|
34288
|
-
"Maj.",
|
|
34289
|
-
"Mr.",
|
|
34290
|
-
"Mrs.",
|
|
34291
|
-
"Ms.",
|
|
34292
|
-
"Mt.",
|
|
34293
|
-
"Messrs.",
|
|
34294
|
-
"Mssrs.",
|
|
34295
|
-
"Prof.",
|
|
34296
|
-
"Ph.",
|
|
34297
|
-
"Rep.",
|
|
34298
|
-
"Reps.",
|
|
34299
|
-
"Rev.",
|
|
34300
|
-
"Sen.",
|
|
34301
|
-
"Sens.",
|
|
34302
|
-
"Sgt.",
|
|
34303
|
-
"St.",
|
|
34304
|
-
"Supt.",
|
|
34305
|
-
"V.",
|
|
34306
|
-
"Vs."
|
|
34307
|
-
],
|
|
34308
|
-
EXCALAMATION_WORDS: [
|
|
34309
|
-
"!X\u0169",
|
|
34310
|
-
"!Kung",
|
|
34311
|
-
"\u01C3\u02BCO\u01C3Kung",
|
|
34312
|
-
"!Xuun",
|
|
34313
|
-
"!Kung-Ekoka",
|
|
34314
|
-
"\u01C3Hu",
|
|
34315
|
-
"\u01C3Khung",
|
|
34316
|
-
"\u01C3Ku",
|
|
34317
|
-
"\u01C3ung",
|
|
34318
|
-
"\u01C3Xo",
|
|
34319
|
-
"\u01C3X\xFB",
|
|
34320
|
-
"\u01C3Xung",
|
|
34321
|
-
"\u01C3X\u0169",
|
|
34322
|
-
"!Xun",
|
|
34323
|
-
"Yahoo!",
|
|
34324
|
-
"Y!J",
|
|
34325
|
-
"Yum!"
|
|
34326
|
-
]
|
|
34327
|
-
};
|
|
34328
|
-
}
|
|
34329
|
-
});
|
|
34330
|
-
|
|
34331
|
-
// node_modules/sentence-splitter/lib/parser/AbbrMarker.js
|
|
34332
|
-
var require_AbbrMarker = __commonJS({
|
|
34333
|
-
"node_modules/sentence-splitter/lib/parser/AbbrMarker.js"(exports) {
|
|
34334
|
-
init_polyfills();
|
|
34335
|
-
"use strict";
|
|
34336
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34337
|
-
exports.AbbrMarker = void 0;
|
|
34338
|
-
var English_1 = require_English();
|
|
34339
|
-
var isCapitalized = function(text) {
|
|
34340
|
-
if (!text || text.length === 0) {
|
|
34341
|
-
return false;
|
|
34342
|
-
}
|
|
34343
|
-
return /^[A-Z]/.test(text);
|
|
34344
|
-
};
|
|
34345
|
-
var compareNoCaseSensitive = function(a, b) {
|
|
34346
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
34347
|
-
};
|
|
34348
|
-
var AbbrMarker = function() {
|
|
34349
|
-
function AbbrMarker2(lang) {
|
|
34350
|
-
if (lang === void 0) {
|
|
34351
|
-
lang = English_1.English;
|
|
34352
|
-
}
|
|
34353
|
-
this.lang = lang;
|
|
34354
|
-
}
|
|
34355
|
-
AbbrMarker2.prototype.getWord = function(sourceCode, startIndex) {
|
|
34356
|
-
if (startIndex === void 0) {
|
|
34357
|
-
startIndex = 0;
|
|
34358
|
-
}
|
|
34359
|
-
var whiteSpace = /\s/;
|
|
34360
|
-
var prevChar = sourceCode.read(-1);
|
|
34361
|
-
if (prevChar && !whiteSpace.test(prevChar)) {
|
|
34362
|
-
return "";
|
|
34363
|
-
}
|
|
34364
|
-
var word = "";
|
|
34365
|
-
var count = startIndex;
|
|
34366
|
-
var char = "";
|
|
34367
|
-
while (char = sourceCode.read(count)) {
|
|
34368
|
-
if (whiteSpace.test(char)) {
|
|
34369
|
-
break;
|
|
34370
|
-
}
|
|
34371
|
-
word += char;
|
|
34372
|
-
count++;
|
|
34373
|
-
}
|
|
34374
|
-
return word;
|
|
34375
|
-
};
|
|
34376
|
-
AbbrMarker2.prototype.getPrevWord = function(sourceCode) {
|
|
34377
|
-
var whiteSpace = /\s/;
|
|
34378
|
-
var count = -1;
|
|
34379
|
-
var char = "";
|
|
34380
|
-
while (char = sourceCode.read(count)) {
|
|
34381
|
-
if (!whiteSpace.test(char)) {
|
|
34382
|
-
break;
|
|
34383
|
-
}
|
|
34384
|
-
count--;
|
|
34385
|
-
}
|
|
34386
|
-
while (char = sourceCode.read(count)) {
|
|
34387
|
-
if (whiteSpace.test(char)) {
|
|
34388
|
-
break;
|
|
34389
|
-
}
|
|
34390
|
-
count--;
|
|
34391
|
-
}
|
|
34392
|
-
return this.getWord(sourceCode, count + 1);
|
|
34393
|
-
};
|
|
34394
|
-
AbbrMarker2.prototype.mark = function(sourceCode) {
|
|
34395
|
-
if (sourceCode.isInContextRange()) {
|
|
34396
|
-
return;
|
|
34397
|
-
}
|
|
34398
|
-
var currentWord = this.getWord(sourceCode);
|
|
34399
|
-
if (currentWord.length === 0) {
|
|
34400
|
-
return;
|
|
34401
|
-
}
|
|
34402
|
-
if (/^([a-zA-Z]\.){3,}$/.test(currentWord)) {
|
|
34403
|
-
return sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
|
|
34404
|
-
}
|
|
34405
|
-
var isMatchedEXCALAMATION_WORDS = this.lang.EXCALAMATION_WORDS.some(function(abbr) {
|
|
34406
|
-
return compareNoCaseSensitive(abbr, currentWord);
|
|
34407
|
-
});
|
|
34408
|
-
if (isMatchedEXCALAMATION_WORDS) {
|
|
34409
|
-
return sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
|
|
34410
|
-
}
|
|
34411
|
-
var isMatchedPREPOSITIVE_ABBREVIATIONS = this.lang.PREPOSITIVE_ABBREVIATIONS.some(function(abbr) {
|
|
34412
|
-
return compareNoCaseSensitive(abbr, currentWord);
|
|
34413
|
-
});
|
|
34414
|
-
if (isMatchedPREPOSITIVE_ABBREVIATIONS) {
|
|
34415
|
-
return sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
|
|
34416
|
-
}
|
|
34417
|
-
var isMatched = this.lang.ABBREVIATIONS.some(function(abbr) {
|
|
34418
|
-
return compareNoCaseSensitive(abbr, currentWord);
|
|
34419
|
-
});
|
|
34420
|
-
var prevWord = this.getPrevWord(sourceCode);
|
|
34421
|
-
var nextWord = this.getWord(sourceCode, currentWord.length + 1);
|
|
34422
|
-
if (isCapitalized(prevWord) && /[A-Z]\./.test(currentWord) && isCapitalized(nextWord)) {
|
|
34423
|
-
sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
|
|
34424
|
-
} else if (isMatched && !isCapitalized(nextWord)) {
|
|
34425
|
-
sourceCode.markContextRange([sourceCode.offset, sourceCode.offset + currentWord.length]);
|
|
34426
|
-
}
|
|
34427
|
-
};
|
|
34428
|
-
return AbbrMarker2;
|
|
34429
|
-
}();
|
|
34430
|
-
exports.AbbrMarker = AbbrMarker;
|
|
34431
|
-
}
|
|
34432
|
-
});
|
|
34433
|
-
|
|
34434
|
-
// node_modules/sentence-splitter/lib/logger.js
|
|
34435
|
-
var require_logger = __commonJS({
|
|
34436
|
-
"node_modules/sentence-splitter/lib/logger.js"(exports) {
|
|
34437
|
-
init_polyfills();
|
|
34438
|
-
"use strict";
|
|
34439
|
-
var __spreadArray = exports && exports.__spreadArray || function(to, from) {
|
|
34440
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
34441
|
-
to[j] = from[i];
|
|
34442
|
-
return to;
|
|
34443
|
-
};
|
|
34444
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34445
|
-
exports.debugLog = void 0;
|
|
34446
|
-
function debugLog() {
|
|
34447
|
-
var args = [];
|
|
34448
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
34449
|
-
args[_i] = arguments[_i];
|
|
34450
|
-
}
|
|
34451
|
-
if (process.env.DEBUG !== "sentence-splitter") {
|
|
34452
|
-
return;
|
|
34453
|
-
}
|
|
34454
|
-
console.log.apply(console, __spreadArray(["sentence-splitter: "], args));
|
|
34455
|
-
}
|
|
34456
|
-
exports.debugLog = debugLog;
|
|
34457
|
-
}
|
|
34458
|
-
});
|
|
34459
|
-
|
|
34460
|
-
// node_modules/object_values/index.js
|
|
34461
|
-
var require_object_values = __commonJS({
|
|
34462
|
-
"node_modules/object_values/index.js"(exports, module) {
|
|
34463
|
-
init_polyfills();
|
|
34464
|
-
Object.values = Object.values ? Object.values : function(obj) {
|
|
34465
|
-
var allowedTypes = ["[object String]", "[object Object]", "[object Array]", "[object Function]"];
|
|
34466
|
-
var objType = Object.prototype.toString.call(obj);
|
|
34467
|
-
if (obj === null || typeof obj === "undefined") {
|
|
34468
|
-
throw new TypeError("Cannot convert undefined or null to object");
|
|
34469
|
-
} else if (!~allowedTypes.indexOf(objType)) {
|
|
34470
|
-
return [];
|
|
34471
|
-
} else {
|
|
34472
|
-
if (Object.keys) {
|
|
34473
|
-
return Object.keys(obj).map(function(key) {
|
|
34474
|
-
return obj[key];
|
|
34475
|
-
});
|
|
34476
|
-
}
|
|
34477
|
-
var result = [];
|
|
34478
|
-
for (var prop in obj) {
|
|
34479
|
-
if (obj.hasOwnProperty(prop)) {
|
|
34480
|
-
result.push(obj[prop]);
|
|
34481
|
-
}
|
|
34482
|
-
}
|
|
34483
|
-
return result;
|
|
34484
|
-
}
|
|
34485
|
-
};
|
|
34486
|
-
if (typeof module !== "undefined" && module.exports) {
|
|
34487
|
-
module.exports = Object.values;
|
|
34488
|
-
}
|
|
34489
|
-
}
|
|
34490
|
-
});
|
|
34491
|
-
|
|
34492
|
-
// node_modules/sentence-splitter/lib/parser/PairMaker.js
|
|
34493
|
-
var require_PairMaker = __commonJS({
|
|
34494
|
-
"node_modules/sentence-splitter/lib/parser/PairMaker.js"(exports) {
|
|
34495
|
-
init_polyfills();
|
|
34496
|
-
"use strict";
|
|
34497
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
34498
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
34499
|
-
};
|
|
34500
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34501
|
-
exports.PairMaker = void 0;
|
|
34502
|
-
var logger_1 = require_logger();
|
|
34503
|
-
var object_values_1 = __importDefault(require_object_values());
|
|
34504
|
-
var PairMaker = function() {
|
|
34505
|
-
function PairMaker2() {
|
|
34506
|
-
var _a;
|
|
34507
|
-
this.pairs = (_a = {}, _a['"'] = '"', _a["\u300C"] = "\u300D", _a["\uFF08"] = "\uFF09", _a["("] = ")", _a["\u300E"] = "\u300F", _a["\u3010"] = "\u3011", _a["\u300A"] = "\u300B", _a);
|
|
34508
|
-
this.pairKeys = Object.keys(this.pairs);
|
|
34509
|
-
this.pairValues = object_values_1.default(this.pairs);
|
|
34510
|
-
}
|
|
34511
|
-
PairMaker2.prototype.mark = function(sourceCode) {
|
|
34512
|
-
var string = sourceCode.read();
|
|
34513
|
-
if (!string) {
|
|
34514
|
-
return;
|
|
34515
|
-
}
|
|
34516
|
-
if (!sourceCode.isInContext()) {
|
|
34517
|
-
var keyIndex = this.pairKeys.indexOf(string);
|
|
34518
|
-
if (keyIndex !== -1) {
|
|
34519
|
-
var key = this.pairKeys[keyIndex];
|
|
34520
|
-
logger_1.debugLog("PairMaker -> enterContext: " + key);
|
|
34521
|
-
sourceCode.enterContext(key);
|
|
34522
|
-
}
|
|
34523
|
-
} else {
|
|
34524
|
-
var valueIndex = this.pairValues.indexOf(string);
|
|
34525
|
-
if (valueIndex !== -1) {
|
|
34526
|
-
var key = this.pairKeys[valueIndex];
|
|
34527
|
-
logger_1.debugLog("PairMaker -> leaveContext: " + this.pairValues[valueIndex]);
|
|
34528
|
-
sourceCode.leaveContext(key);
|
|
34529
|
-
}
|
|
34530
|
-
}
|
|
34531
|
-
};
|
|
34532
|
-
return PairMaker2;
|
|
34533
|
-
}();
|
|
34534
|
-
exports.PairMaker = PairMaker;
|
|
34535
|
-
}
|
|
34536
|
-
});
|
|
34537
|
-
|
|
34538
|
-
// node_modules/sentence-splitter/lib/sentence-splitter.js
|
|
34539
|
-
var require_sentence_splitter = __commonJS({
|
|
34540
|
-
"node_modules/sentence-splitter/lib/sentence-splitter.js"(exports) {
|
|
34541
|
-
init_polyfills();
|
|
34542
|
-
"use strict";
|
|
34543
|
-
var __assign = exports && exports.__assign || function() {
|
|
34544
|
-
__assign = Object.assign || function(t) {
|
|
34545
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34546
|
-
s = arguments[i];
|
|
34547
|
-
for (var p in s)
|
|
34548
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
34549
|
-
t[p] = s[p];
|
|
34550
|
-
}
|
|
34551
|
-
return t;
|
|
34552
|
-
};
|
|
34553
|
-
return __assign.apply(this, arguments);
|
|
34554
|
-
};
|
|
34555
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34556
|
-
exports.createNode = exports.createEmptySentenceNode = exports.createTextNode = exports.createPunctuationNode = exports.createWhiteSpaceNode = exports.splitAST = exports.split = exports.SplitParser = exports.Syntax = void 0;
|
|
34557
|
-
var ast_node_types_1 = require_lib8();
|
|
34558
|
-
var SourceCode_1 = require_SourceCode();
|
|
34559
|
-
var NewLineParser_1 = require_NewLineParser();
|
|
34560
|
-
var SpaceParser_1 = require_SpaceParser();
|
|
34561
|
-
var SeparatorParser_1 = require_SeparatorParser();
|
|
34562
|
-
var AnyValueParser_1 = require_AnyValueParser();
|
|
34563
|
-
var AbbrMarker_1 = require_AbbrMarker();
|
|
34564
|
-
var PairMaker_1 = require_PairMaker();
|
|
34565
|
-
var logger_1 = require_logger();
|
|
34566
|
-
exports.Syntax = {
|
|
34567
|
-
WhiteSpace: "WhiteSpace",
|
|
34568
|
-
Punctuation: "Punctuation",
|
|
34569
|
-
Sentence: "Sentence",
|
|
34570
|
-
Str: "Str"
|
|
34571
|
-
};
|
|
34572
|
-
var SplitParser = function() {
|
|
34573
|
-
function SplitParser2(text) {
|
|
34574
|
-
this.nodeList = [];
|
|
34575
|
-
this.results = [];
|
|
34576
|
-
this.source = new SourceCode_1.SourceCode(text);
|
|
34577
|
-
}
|
|
34578
|
-
Object.defineProperty(SplitParser2.prototype, "current", {
|
|
34579
|
-
get: function() {
|
|
34580
|
-
return this.nodeList[this.nodeList.length - 1];
|
|
34581
|
-
},
|
|
34582
|
-
enumerable: false,
|
|
34583
|
-
configurable: true
|
|
34584
|
-
});
|
|
34585
|
-
SplitParser2.prototype.pushNodeToCurrent = function(node) {
|
|
34586
|
-
var current = this.current;
|
|
34587
|
-
if (current) {
|
|
34588
|
-
current.children.push(node);
|
|
34589
|
-
} else {
|
|
34590
|
-
this.results.push(node);
|
|
34591
|
-
}
|
|
34592
|
-
};
|
|
34593
|
-
SplitParser2.prototype.open = function(parentNode) {
|
|
34594
|
-
this.nodeList.push(parentNode);
|
|
34595
|
-
};
|
|
34596
|
-
SplitParser2.prototype.isOpened = function() {
|
|
34597
|
-
return this.nodeList.length > 0;
|
|
34598
|
-
};
|
|
34599
|
-
SplitParser2.prototype.nextLine = function(parser) {
|
|
34600
|
-
var _a = this.source.seekNext(parser), value = _a.value, startPosition = _a.startPosition, endPosition = _a.endPosition;
|
|
34601
|
-
this.pushNodeToCurrent(createWhiteSpaceNode(value, startPosition, endPosition));
|
|
34602
|
-
return endPosition;
|
|
34603
|
-
};
|
|
34604
|
-
SplitParser2.prototype.nextSpace = function(parser) {
|
|
34605
|
-
var _a = this.source.seekNext(parser), value = _a.value, startPosition = _a.startPosition, endPosition = _a.endPosition;
|
|
34606
|
-
this.pushNodeToCurrent(createNode("WhiteSpace", value, startPosition, endPosition));
|
|
34607
|
-
};
|
|
34608
|
-
SplitParser2.prototype.nextValue = function(parser) {
|
|
34609
|
-
var _a = this.source.seekNext(parser), value = _a.value, startPosition = _a.startPosition, endPosition = _a.endPosition;
|
|
34610
|
-
this.pushNodeToCurrent(createTextNode(value, startPosition, endPosition));
|
|
34611
|
-
};
|
|
34612
|
-
SplitParser2.prototype.close = function(parser) {
|
|
34613
|
-
var _a = this.source.seekNext(parser), value = _a.value, startPosition = _a.startPosition, endPosition = _a.endPosition;
|
|
34614
|
-
if (startPosition.offset !== endPosition.offset) {
|
|
34615
|
-
this.pushNodeToCurrent(createPunctuationNode(value, startPosition, endPosition));
|
|
34616
|
-
}
|
|
34617
|
-
var currentNode = this.nodeList.pop();
|
|
34618
|
-
if (!currentNode) {
|
|
34619
|
-
return;
|
|
34620
|
-
}
|
|
34621
|
-
if (currentNode.children.length === 0) {
|
|
34622
|
-
return;
|
|
34623
|
-
}
|
|
34624
|
-
var firstChildNode = currentNode.children[0];
|
|
34625
|
-
var endNow = this.source.now();
|
|
34626
|
-
currentNode.loc = {
|
|
34627
|
-
start: firstChildNode.loc.start,
|
|
34628
|
-
end: nowToLoc(endNow)
|
|
34629
|
-
};
|
|
34630
|
-
var rawValue = this.source.sliceRange(firstChildNode.range[0], endNow.offset);
|
|
34631
|
-
currentNode.range = [firstChildNode.range[0], endNow.offset];
|
|
34632
|
-
currentNode.raw = rawValue;
|
|
34633
|
-
this.results.push(currentNode);
|
|
34634
|
-
};
|
|
34635
|
-
SplitParser2.prototype.toList = function() {
|
|
34636
|
-
return this.results;
|
|
34637
|
-
};
|
|
34638
|
-
return SplitParser2;
|
|
34639
|
-
}();
|
|
34640
|
-
exports.SplitParser = SplitParser;
|
|
34641
|
-
var createParsers = function(options) {
|
|
34642
|
-
if (options === void 0) {
|
|
34643
|
-
options = {};
|
|
34644
|
-
}
|
|
34645
|
-
var newLine = new NewLineParser_1.NewLineParser();
|
|
34646
|
-
var space = new SpaceParser_1.SpaceParser();
|
|
34647
|
-
var separator = new SeparatorParser_1.SeparatorParser(options.SeparatorParser);
|
|
34648
|
-
var abbrMarker = new AbbrMarker_1.AbbrMarker();
|
|
34649
|
-
var pairMaker = new PairMaker_1.PairMaker();
|
|
34650
|
-
var anyValueParser = new AnyValueParser_1.AnyValueParser({
|
|
34651
|
-
parsers: [newLine, separator],
|
|
34652
|
-
markers: [abbrMarker, pairMaker]
|
|
34653
|
-
});
|
|
34654
|
-
return {
|
|
34655
|
-
newLine,
|
|
34656
|
-
space,
|
|
34657
|
-
separator,
|
|
34658
|
-
abbrMarker,
|
|
34659
|
-
anyValueParser
|
|
34660
|
-
};
|
|
34661
|
-
};
|
|
34662
|
-
function split2(text, options) {
|
|
34663
|
-
var _a = createParsers(options), newLine = _a.newLine, space = _a.space, separator = _a.separator, anyValueParser = _a.anyValueParser;
|
|
34664
|
-
var splitParser = new SplitParser(text);
|
|
34665
|
-
var sourceCode = splitParser.source;
|
|
34666
|
-
while (!sourceCode.hasEnd) {
|
|
34667
|
-
if (newLine.test(sourceCode)) {
|
|
34668
|
-
splitParser.nextLine(newLine);
|
|
34669
|
-
} else if (space.test(sourceCode)) {
|
|
34670
|
-
splitParser.nextSpace(space);
|
|
34671
|
-
} else if (separator.test(sourceCode)) {
|
|
34672
|
-
splitParser.close(separator);
|
|
34673
|
-
} else {
|
|
34674
|
-
if (!splitParser.isOpened()) {
|
|
34675
|
-
splitParser.open(createEmptySentenceNode());
|
|
34676
|
-
}
|
|
34677
|
-
splitParser.nextValue(anyValueParser);
|
|
34678
|
-
}
|
|
34679
|
-
}
|
|
34680
|
-
splitParser.close(space);
|
|
34681
|
-
return splitParser.toList();
|
|
34682
|
-
}
|
|
34683
|
-
exports.split = split2;
|
|
34684
|
-
function splitAST(paragraphNode, options) {
|
|
34685
|
-
var _a = createParsers(options), newLine = _a.newLine, space = _a.space, separator = _a.separator, anyValueParser = _a.anyValueParser;
|
|
34686
|
-
var splitParser = new SplitParser(paragraphNode);
|
|
34687
|
-
var sourceCode = splitParser.source;
|
|
34688
|
-
while (!sourceCode.hasEnd) {
|
|
34689
|
-
var currentNode = sourceCode.readNode();
|
|
34690
|
-
if (!currentNode) {
|
|
34691
|
-
break;
|
|
34692
|
-
}
|
|
34693
|
-
if (currentNode.type === ast_node_types_1.ASTNodeTypes.Str) {
|
|
34694
|
-
if (space.test(sourceCode)) {
|
|
34695
|
-
logger_1.debugLog("space");
|
|
34696
|
-
splitParser.nextSpace(space);
|
|
34697
|
-
} else if (separator.test(sourceCode)) {
|
|
34698
|
-
logger_1.debugLog("separator");
|
|
34699
|
-
splitParser.close(separator);
|
|
34700
|
-
} else if (newLine.test(sourceCode)) {
|
|
34701
|
-
logger_1.debugLog("newline");
|
|
34702
|
-
splitParser.nextLine(newLine);
|
|
34703
|
-
} else {
|
|
34704
|
-
if (!splitParser.isOpened()) {
|
|
34705
|
-
logger_1.debugLog("open -> createEmptySentenceNode()");
|
|
34706
|
-
splitParser.open(createEmptySentenceNode());
|
|
34707
|
-
}
|
|
34708
|
-
splitParser.nextValue(anyValueParser);
|
|
34709
|
-
}
|
|
34710
|
-
} else if (currentNode.type === ast_node_types_1.ASTNodeTypes.Break) {
|
|
34711
|
-
splitParser.pushNodeToCurrent(currentNode);
|
|
34712
|
-
sourceCode.peekNode(currentNode);
|
|
34713
|
-
} else {
|
|
34714
|
-
if (!splitParser.isOpened()) {
|
|
34715
|
-
splitParser.open(createEmptySentenceNode());
|
|
34716
|
-
}
|
|
34717
|
-
splitParser.pushNodeToCurrent(currentNode);
|
|
34718
|
-
sourceCode.peekNode(currentNode);
|
|
34719
|
-
}
|
|
34720
|
-
}
|
|
34721
|
-
splitParser.close(space);
|
|
34722
|
-
return __assign(__assign({}, paragraphNode), { children: splitParser.toList() });
|
|
34723
|
-
}
|
|
34724
|
-
exports.splitAST = splitAST;
|
|
34725
|
-
function createWhiteSpaceNode(text, startPosition, endPosition) {
|
|
34726
|
-
return createNode("WhiteSpace", text, startPosition, endPosition);
|
|
34727
|
-
}
|
|
34728
|
-
exports.createWhiteSpaceNode = createWhiteSpaceNode;
|
|
34729
|
-
function createPunctuationNode(text, startPosition, endPosition) {
|
|
34730
|
-
return createNode("Punctuation", text, startPosition, endPosition);
|
|
34731
|
-
}
|
|
34732
|
-
exports.createPunctuationNode = createPunctuationNode;
|
|
34733
|
-
function createTextNode(text, startPosition, endPosition) {
|
|
34734
|
-
return createNode("Str", text, startPosition, endPosition);
|
|
34735
|
-
}
|
|
34736
|
-
exports.createTextNode = createTextNode;
|
|
34737
|
-
function createEmptySentenceNode() {
|
|
34738
|
-
return {
|
|
34739
|
-
type: "Sentence",
|
|
34740
|
-
raw: "",
|
|
34741
|
-
loc: {
|
|
34742
|
-
start: { column: NaN, line: NaN },
|
|
34743
|
-
end: { column: NaN, line: NaN }
|
|
34744
|
-
},
|
|
34745
|
-
range: [NaN, NaN],
|
|
34746
|
-
children: []
|
|
34747
|
-
};
|
|
34748
|
-
}
|
|
34749
|
-
exports.createEmptySentenceNode = createEmptySentenceNode;
|
|
34750
|
-
function createNode(type, text, startPosition, endPosition) {
|
|
34751
|
-
return {
|
|
34752
|
-
type,
|
|
34753
|
-
raw: text,
|
|
34754
|
-
value: text,
|
|
34755
|
-
loc: {
|
|
34756
|
-
start: nowToLoc(startPosition),
|
|
34757
|
-
end: nowToLoc(endPosition)
|
|
34758
|
-
},
|
|
34759
|
-
range: [startPosition.offset, endPosition.offset]
|
|
34760
|
-
};
|
|
34761
|
-
}
|
|
34762
|
-
exports.createNode = createNode;
|
|
34763
|
-
function nowToLoc(now) {
|
|
34764
|
-
return {
|
|
34765
|
-
line: now.line,
|
|
34766
|
-
column: now.column
|
|
34767
|
-
};
|
|
34768
|
-
}
|
|
34769
|
-
}
|
|
34770
|
-
});
|
|
34771
|
-
|
|
34772
33577
|
// src/index.ts
|
|
34773
33578
|
init_polyfills();
|
|
34774
33579
|
|
|
@@ -35020,7 +33825,7 @@ var Publication = class extends import_publication.Publication {
|
|
|
35020
33825
|
}
|
|
35021
33826
|
for (const locator of positions) {
|
|
35022
33827
|
const resource = positions.filter((el) => el.href === decodeURI(locator.href));
|
|
35023
|
-
const positionIndex = Math.ceil(locator.locations.progression ? locator.locations.progression : 0 * (resource.length - 1));
|
|
33828
|
+
const positionIndex = Math.ceil((locator.locations.progression ? locator.locations.progression : 0) * (resource.length - 1));
|
|
35024
33829
|
if (locator.locations.position) {
|
|
35025
33830
|
locator.locations.totalProgression = (locator.locations.position - 1) / positions.length;
|
|
35026
33831
|
}
|
|
@@ -38342,7 +37147,6 @@ var TextHighlighter = class {
|
|
|
38342
37147
|
let doc = el.ownerDocument;
|
|
38343
37148
|
el.addEventListener("mouseup", this.toolboxShowDelayed.bind(this));
|
|
38344
37149
|
el.addEventListener("touchend", this.toolboxShowDelayed.bind(this));
|
|
38345
|
-
doc.addEventListener("selectstart", this.toolboxShowDelayed.bind(this));
|
|
38346
37150
|
if (!hasEventListener) {
|
|
38347
37151
|
window.addEventListener("resize", this.toolboxPlacement.bind(this));
|
|
38348
37152
|
}
|
|
@@ -38376,7 +37180,6 @@ var TextHighlighter = class {
|
|
|
38376
37180
|
let doc = el.ownerDocument;
|
|
38377
37181
|
el.removeEventListener("mouseup", this.toolboxShowDelayed.bind(this));
|
|
38378
37182
|
el.removeEventListener("touchend", this.toolboxShowDelayed.bind(this));
|
|
38379
|
-
doc.removeEventListener("selectstart", this.toolboxShowDelayed.bind(this));
|
|
38380
37183
|
window.removeEventListener("resize", this.toolboxPlacement.bind(this));
|
|
38381
37184
|
doc.removeEventListener("selectionchange", this.toolboxPlacement.bind(this));
|
|
38382
37185
|
el.removeEventListener("mousedown", this.toolboxHide.bind(this));
|
|
@@ -38555,38 +37358,70 @@ var TextHighlighter = class {
|
|
|
38555
37358
|
toolbox.style.display = "none";
|
|
38556
37359
|
this.selectionMenuClosed();
|
|
38557
37360
|
}
|
|
38558
|
-
toolboxShowDelayed() {
|
|
37361
|
+
toolboxShowDelayed(ev) {
|
|
38559
37362
|
let self2 = this;
|
|
38560
37363
|
setTimeout(function() {
|
|
38561
37364
|
if (!self2.isAndroid()) {
|
|
38562
|
-
self2.snapSelectionToWord();
|
|
37365
|
+
self2.snapSelectionToWord(ev.detail === 1);
|
|
38563
37366
|
}
|
|
38564
37367
|
self2.toolboxShow();
|
|
38565
37368
|
}, 100);
|
|
38566
37369
|
}
|
|
38567
|
-
snapSelectionToWord() {
|
|
37370
|
+
snapSelectionToWord(trimmed = false) {
|
|
38568
37371
|
let self2 = this;
|
|
38569
37372
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
38570
37373
|
if (doc) {
|
|
38571
37374
|
let selection = self2.dom(doc.body)?.getWindow()?.getSelection();
|
|
38572
37375
|
if (self2.dom(doc.body)) {
|
|
38573
37376
|
if (selection && !selection?.isCollapsed) {
|
|
37377
|
+
let removeTrailingPunctuation = function(text2) {
|
|
37378
|
+
const match = text2.match(new RegExp(`[^a-zA-Z0-9]+$`));
|
|
37379
|
+
if (!match || !match.index) {
|
|
37380
|
+
return text2;
|
|
37381
|
+
}
|
|
37382
|
+
return text2.slice(0, match.index);
|
|
37383
|
+
};
|
|
37384
|
+
let text = selection.toString();
|
|
37385
|
+
let startOffsetTemp = text.length - text.trimStart().length;
|
|
37386
|
+
let endOffsetTemp = text.length - text.trimEnd().length;
|
|
37387
|
+
let length = text.length;
|
|
37388
|
+
var regex_symbols = /[-!$%^&*()_+|~=`{}\[\]:\/;<>?,.@#]/;
|
|
37389
|
+
text = text.replace(regex_symbols, "");
|
|
37390
|
+
startOffsetTemp = length - text.trimStart().length;
|
|
37391
|
+
text = removeTrailingPunctuation(text);
|
|
37392
|
+
endOffsetTemp = length - text.trimEnd().length;
|
|
38574
37393
|
let range = document.createRange();
|
|
38575
|
-
|
|
38576
|
-
|
|
37394
|
+
if (trimmed) {
|
|
37395
|
+
range.setStart(selection.anchorNode, selection.anchorOffset + startOffsetTemp);
|
|
37396
|
+
range.setEnd(selection.focusNode, selection.focusOffset - endOffsetTemp);
|
|
37397
|
+
} else {
|
|
37398
|
+
range.setStart(selection.anchorNode, selection.anchorOffset);
|
|
37399
|
+
range.setEnd(selection.focusNode, selection.focusOffset);
|
|
37400
|
+
}
|
|
38577
37401
|
let backwards = range.collapsed;
|
|
38578
37402
|
range.detach();
|
|
38579
|
-
let endNode = selection.focusNode
|
|
38580
|
-
|
|
37403
|
+
let endNode = selection.focusNode;
|
|
37404
|
+
let endOffset;
|
|
37405
|
+
if (trimmed) {
|
|
37406
|
+
endOffset = selection.focusOffset - endOffsetTemp;
|
|
37407
|
+
selection.collapse(selection.anchorNode, selection.anchorOffset + startOffsetTemp);
|
|
37408
|
+
} else {
|
|
37409
|
+
endOffset = selection.focusOffset;
|
|
37410
|
+
selection.collapse(selection.anchorNode, selection.anchorOffset);
|
|
37411
|
+
}
|
|
38581
37412
|
let direction = ["forward", "backward"];
|
|
38582
37413
|
if (backwards) {
|
|
38583
37414
|
direction = ["backward", "forward"];
|
|
38584
37415
|
}
|
|
38585
|
-
|
|
38586
|
-
|
|
38587
|
-
|
|
38588
|
-
|
|
38589
|
-
|
|
37416
|
+
if (trimmed) {
|
|
37417
|
+
selection.modify("move", direction[0], "character");
|
|
37418
|
+
selection.modify("move", direction[1], "word");
|
|
37419
|
+
selection.extend(endNode, endOffset);
|
|
37420
|
+
selection.modify("extend", direction[1], "character");
|
|
37421
|
+
selection.modify("extend", direction[0], "word");
|
|
37422
|
+
} else {
|
|
37423
|
+
selection.extend(endNode, endOffset);
|
|
37424
|
+
}
|
|
38590
37425
|
this.selection(selection.toString(), selection);
|
|
38591
37426
|
}
|
|
38592
37427
|
}
|
|
@@ -38885,59 +37720,6 @@ var TextHighlighter = class {
|
|
|
38885
37720
|
this.doneSpeaking();
|
|
38886
37721
|
}
|
|
38887
37722
|
}
|
|
38888
|
-
speakAll() {
|
|
38889
|
-
if (this.delegate.rights.enableTTS) {
|
|
38890
|
-
let getCssSelector = function(element) {
|
|
38891
|
-
const options = {
|
|
38892
|
-
className: (str) => {
|
|
38893
|
-
return _blacklistIdClassForCssSelectors.indexOf(str) < 0;
|
|
38894
|
-
},
|
|
38895
|
-
idName: (str) => {
|
|
38896
|
-
return _blacklistIdClassForCssSelectors.indexOf(str) < 0;
|
|
38897
|
-
}
|
|
38898
|
-
};
|
|
38899
|
-
let doc2 = self2.delegate.iframes[0].contentDocument;
|
|
38900
|
-
if (doc2) {
|
|
38901
|
-
return uniqueCssSelector(element, self2.dom(doc2.body).getDocument(), options);
|
|
38902
|
-
} else {
|
|
38903
|
-
return void 0;
|
|
38904
|
-
}
|
|
38905
|
-
};
|
|
38906
|
-
let self2 = this;
|
|
38907
|
-
let doc = this.delegate.iframes[0].contentDocument;
|
|
38908
|
-
if (doc) {
|
|
38909
|
-
const selectionInfo = getCurrentSelectionInfo(this.dom(doc.body).getWindow(), getCssSelector);
|
|
38910
|
-
if (selectionInfo !== void 0) {
|
|
38911
|
-
self2.speak();
|
|
38912
|
-
} else {
|
|
38913
|
-
var node = this.dom(self2.delegate.iframes[0].contentDocument?.body).getWindow().document.body;
|
|
38914
|
-
if (IS_DEV)
|
|
38915
|
-
console.log(doc);
|
|
38916
|
-
const selection = self2.dom(doc.body).getSelection();
|
|
38917
|
-
const range = this.dom(doc.body).getWindow().document.createRange();
|
|
38918
|
-
range.selectNodeContents(node);
|
|
38919
|
-
selection.removeAllRanges();
|
|
38920
|
-
selection.addRange(range);
|
|
38921
|
-
let win = this.delegate.iframes[0].contentWindow;
|
|
38922
|
-
if (win) {
|
|
38923
|
-
const selectionInfo2 = getCurrentSelectionInfo(win, getCssSelector);
|
|
38924
|
-
if (selectionInfo2 !== void 0 && selectionInfo2.cleanText) {
|
|
38925
|
-
this.delegate.ttsModule.speak(selectionInfo2, false, () => {
|
|
38926
|
-
if (doc) {
|
|
38927
|
-
let selection2 = self2.dom(doc.body).getSelection();
|
|
38928
|
-
selection2.removeAllRanges();
|
|
38929
|
-
}
|
|
38930
|
-
self2.toolboxHide();
|
|
38931
|
-
});
|
|
38932
|
-
} else {
|
|
38933
|
-
self2.dom(doc.body).getSelection().removeAllRanges();
|
|
38934
|
-
self2.toolboxHide();
|
|
38935
|
-
}
|
|
38936
|
-
}
|
|
38937
|
-
}
|
|
38938
|
-
}
|
|
38939
|
-
}
|
|
38940
|
-
}
|
|
38941
37723
|
callbackComplete() {
|
|
38942
37724
|
this.toolboxHide();
|
|
38943
37725
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
@@ -38948,7 +37730,7 @@ var TextHighlighter = class {
|
|
|
38948
37730
|
isOutsideViewport(rect) {
|
|
38949
37731
|
let wrapper = findRequiredElement(document, "#iframe-wrapper");
|
|
38950
37732
|
const windowLeft = wrapper.scrollLeft;
|
|
38951
|
-
const windowRight = windowLeft + wrapper.
|
|
37733
|
+
const windowRight = windowLeft + wrapper.clientWidth;
|
|
38952
37734
|
const right = rect.left + rect.width;
|
|
38953
37735
|
const bottom = rect.top + rect.height;
|
|
38954
37736
|
const windowTop = wrapper.scrollTop;
|
|
@@ -38959,6 +37741,19 @@ var TextHighlighter = class {
|
|
|
38959
37741
|
const isRight = rect.left > windowRight;
|
|
38960
37742
|
return isAbove || isBelow || isLeft || isRight;
|
|
38961
37743
|
}
|
|
37744
|
+
isInsideViewport(rect) {
|
|
37745
|
+
let wrapper = findRequiredElement(document, "#iframe-wrapper");
|
|
37746
|
+
const windowTop = wrapper.scrollTop;
|
|
37747
|
+
const windowBottom = windowTop + wrapper.clientHeight;
|
|
37748
|
+
const isAbove = rect.top + 20 >= windowTop;
|
|
37749
|
+
const isBelow = rect.top <= windowBottom;
|
|
37750
|
+
const windowLeft = wrapper.scrollLeft;
|
|
37751
|
+
const windowRight = windowLeft + wrapper.clientWidth;
|
|
37752
|
+
const right = rect.left + rect.width;
|
|
37753
|
+
const isLeft = rect.left > windowLeft;
|
|
37754
|
+
const isRight = right < windowRight;
|
|
37755
|
+
return isAbove && isBelow && isLeft && isRight;
|
|
37756
|
+
}
|
|
38962
37757
|
get visibleTextRects() {
|
|
38963
37758
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
38964
37759
|
if (doc) {
|
|
@@ -39006,7 +37801,7 @@ var TextHighlighter = class {
|
|
|
39006
37801
|
};
|
|
39007
37802
|
const body = findRequiredIframeElement(doc, "body");
|
|
39008
37803
|
const textNodes = findRects(body);
|
|
39009
|
-
return textNodes.filter((rect) =>
|
|
37804
|
+
return textNodes.filter((rect) => this.isInsideViewport(rect));
|
|
39010
37805
|
}
|
|
39011
37806
|
return [];
|
|
39012
37807
|
}
|
|
@@ -43197,11 +41992,11 @@ var SearchModule = class {
|
|
|
43197
41992
|
var absolutehref = this.publication.getAbsoluteHref(href);
|
|
43198
41993
|
let filteredIndexes = this.bookSearchResult.filter((el) => el.href === href);
|
|
43199
41994
|
if (current) {
|
|
43200
|
-
item = this.currentChapterSearchResult.filter((el) => el.uuid
|
|
43201
|
-
filteredIndex = this.currentChapterSearchResult.findIndex((el) => el.uuid
|
|
41995
|
+
item = this.currentChapterSearchResult.filter((el) => el.uuid === index2)[0];
|
|
41996
|
+
filteredIndex = this.currentChapterSearchResult.findIndex((el) => el.uuid === index2);
|
|
43202
41997
|
} else {
|
|
43203
|
-
item = filteredIndexes.filter((el) => el.uuid
|
|
43204
|
-
filteredIndex = filteredIndexes.findIndex((el) => el.uuid
|
|
41998
|
+
item = filteredIndexes.filter((el) => el.uuid === index2)[0];
|
|
41999
|
+
filteredIndex = filteredIndexes.findIndex((el) => el.uuid === index2);
|
|
43205
42000
|
}
|
|
43206
42001
|
if (item !== void 0) {
|
|
43207
42002
|
if (currentLocation === absolutehref) {
|
|
@@ -46892,13 +45687,15 @@ var PageBreakModule = class {
|
|
|
46892
45687
|
init_polyfills();
|
|
46893
45688
|
var import_sanitize_html2 = __toModule(require_sanitize_html());
|
|
46894
45689
|
var import_debounce6 = __toModule(require_debounce());
|
|
46895
|
-
var import_sentence_splitter = __toModule(require_sentence_splitter());
|
|
46896
45690
|
var TTSModule2 = class {
|
|
46897
45691
|
constructor(delegate, tts, rights, highlighter, properties, api, headerMenu) {
|
|
46898
45692
|
this.voices = [];
|
|
46899
45693
|
this.hasEventListener = false;
|
|
45694
|
+
this.startX = 0;
|
|
45695
|
+
this.startY = 0;
|
|
46900
45696
|
this.index = 0;
|
|
46901
45697
|
this.userScrolled = false;
|
|
45698
|
+
this.scrollPartial = false;
|
|
46902
45699
|
this.speaking = false;
|
|
46903
45700
|
this.restartIndex = -1;
|
|
46904
45701
|
this.ttsQueueIndex = -1;
|
|
@@ -46930,6 +45727,7 @@ var TTSModule2 = class {
|
|
|
46930
45727
|
allowedTags: [],
|
|
46931
45728
|
allowedAttributes: {}
|
|
46932
45729
|
});
|
|
45730
|
+
this.wrapper = findRequiredElement(document, "#iframe-wrapper");
|
|
46933
45731
|
window.speechSynthesis.getVoices();
|
|
46934
45732
|
this.initVoices(true);
|
|
46935
45733
|
if (!this.hasEventListener) {
|
|
@@ -46939,11 +45737,28 @@ var TTSModule2 = class {
|
|
|
46939
45737
|
addEventListenerOptional(document, "keydown", this.wheel.bind(this));
|
|
46940
45738
|
addEventListenerOptional(this.delegate.iframes[0].contentDocument, "keydown", this.wheel.bind(this));
|
|
46941
45739
|
}
|
|
46942
|
-
addEventListenerOptional(this.body, "
|
|
45740
|
+
addEventListenerOptional(this.body, "mousedown", this.clickStart.bind(this));
|
|
45741
|
+
addEventListenerOptional(this.body, "mouseup", this.click.bind(this));
|
|
46943
45742
|
}
|
|
46944
45743
|
}
|
|
46945
|
-
|
|
46946
|
-
if (
|
|
45744
|
+
clickStart(event) {
|
|
45745
|
+
if ("clientX" in event) {
|
|
45746
|
+
this.startX = event.clientX;
|
|
45747
|
+
}
|
|
45748
|
+
if ("clientY" in event) {
|
|
45749
|
+
this.startY = event.clientY;
|
|
45750
|
+
}
|
|
45751
|
+
}
|
|
45752
|
+
click(event) {
|
|
45753
|
+
let startX = 0;
|
|
45754
|
+
let startY = 0;
|
|
45755
|
+
if ("clientX" in event) {
|
|
45756
|
+
startX = event.clientX;
|
|
45757
|
+
}
|
|
45758
|
+
if ("clientY" in event) {
|
|
45759
|
+
startY = event.clientY;
|
|
45760
|
+
}
|
|
45761
|
+
if (window.speechSynthesis.speaking && this.speaking && startX === this.startX && startY === this.startY) {
|
|
46947
45762
|
let doc = this.delegate.iframes[0].contentDocument;
|
|
46948
45763
|
if (doc) {
|
|
46949
45764
|
const selection = this.highlighter.dom(doc.body).getSelection();
|
|
@@ -46963,7 +45778,7 @@ var TTSModule2 = class {
|
|
|
46963
45778
|
let iframe = document.querySelector("main#iframe-wrapper iframe");
|
|
46964
45779
|
let rootEl = iframe.contentWindow?.document.body;
|
|
46965
45780
|
if (this.ttsQueue && rootEl) {
|
|
46966
|
-
const idx = this.findTtsQueueItemIndex(this.ttsQueue, selection.anchorNode, selection.
|
|
45781
|
+
const idx = this.findTtsQueueItemIndex(this.ttsQueue, selection.anchorNode, selection.anchorNode, selection.anchorOffset, rootEl);
|
|
46967
45782
|
selection.removeAllRanges();
|
|
46968
45783
|
if (idx >= 0) {
|
|
46969
45784
|
window.speechSynthesis.cancel();
|
|
@@ -47045,18 +45860,44 @@ var TTSModule2 = class {
|
|
|
47045
45860
|
if (doc) {
|
|
47046
45861
|
const selection = this.highlighter.dom(doc.body).getSelection();
|
|
47047
45862
|
if (rootEl) {
|
|
47048
|
-
|
|
45863
|
+
var ttsQueue = this.generateTtsQueue(rootEl);
|
|
47049
45864
|
if (!ttsQueue.length) {
|
|
47050
45865
|
return;
|
|
47051
45866
|
}
|
|
47052
|
-
|
|
45867
|
+
var idx = this.findTtsQueueItemIndex(ttsQueue, selection.anchorNode, selection.anchorNode, selection.anchorOffset, rootEl);
|
|
47053
45868
|
const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
|
|
45869
|
+
var idxEnd = this.findTtsQueueItemIndex(ttsQueue, selection.focusNode, selection.focusNode, selection.focusOffset, rootEl);
|
|
45870
|
+
const ttsQueueItemEnd = getTtsQueueItemRef(ttsQueue, idxEnd);
|
|
45871
|
+
var restOfTheText;
|
|
47054
45872
|
if (ttsQueueItem && selectionInfo && selectionInfo.cleanText) {
|
|
47055
45873
|
const sentence = getTtsQueueItemRefText(ttsQueueItem);
|
|
47056
|
-
|
|
47057
|
-
|
|
45874
|
+
let startIndex = sentence.indexOf(selectionInfo.cleanText);
|
|
45875
|
+
let textToBeSpoken = selectionInfo.cleanText;
|
|
45876
|
+
if (ttsQueueItemEnd && idx + 1 === idxEnd) {
|
|
45877
|
+
const sentenceEnd = getTtsQueueItemRefText(ttsQueueItemEnd);
|
|
45878
|
+
startIndex = (sentence + " " + sentenceEnd).indexOf(selectionInfo.cleanText);
|
|
45879
|
+
textToBeSpoken = sentence.slice(startIndex, sentence.length);
|
|
45880
|
+
restOfTheText = selectionInfo.cleanText.replace(textToBeSpoken, "");
|
|
45881
|
+
} else if (idxEnd > idx) {
|
|
45882
|
+
let mergedSentenses = "";
|
|
45883
|
+
for (let i = idx + 1; i < idxEnd; i++) {
|
|
45884
|
+
const ttsQueueItemInBetween = getTtsQueueItemRef(ttsQueue, i);
|
|
45885
|
+
if (ttsQueueItemInBetween) {
|
|
45886
|
+
const sentenceInBetween = getTtsQueueItemRefText(ttsQueueItemInBetween);
|
|
45887
|
+
mergedSentenses += sentenceInBetween;
|
|
45888
|
+
restOfTheText = selectionInfo.cleanText.replace(sentenceInBetween, "");
|
|
45889
|
+
}
|
|
45890
|
+
}
|
|
45891
|
+
if (ttsQueueItemEnd) {
|
|
45892
|
+
const sentenceEnd = getTtsQueueItemRefText(ttsQueueItemEnd);
|
|
45893
|
+
mergedSentenses += " " + sentenceEnd;
|
|
45894
|
+
}
|
|
45895
|
+
startIndex = (sentence + " " + mergedSentenses).indexOf(selectionInfo.cleanText);
|
|
45896
|
+
textToBeSpoken = sentence.slice(startIndex, sentence.length);
|
|
45897
|
+
restOfTheText = restOfTheText.replace(textToBeSpoken, "").trim();
|
|
45898
|
+
}
|
|
45899
|
+
utterance = new SpeechSynthesisUtterance(textToBeSpoken);
|
|
47058
45900
|
utterance.onboundary = (ev) => {
|
|
47059
|
-
console.log(ev);
|
|
47060
45901
|
this.updateTTSInfo(ttsQueueItem, ev.charIndex + startIndex, ev.charLength, utterance.text);
|
|
47061
45902
|
};
|
|
47062
45903
|
}
|
|
@@ -47166,16 +46007,57 @@ var TTSModule2 = class {
|
|
|
47166
46007
|
window.speechSynthesis.speak(utterance);
|
|
47167
46008
|
}, 0);
|
|
47168
46009
|
this.index = 0;
|
|
47169
|
-
|
|
47170
|
-
|
|
47171
|
-
|
|
47172
|
-
|
|
47173
|
-
|
|
47174
|
-
|
|
47175
|
-
|
|
46010
|
+
function onend() {
|
|
46011
|
+
utterance.onend = function() {
|
|
46012
|
+
if (idxEnd > idx) {
|
|
46013
|
+
idx = idx + 1;
|
|
46014
|
+
if (idx !== idxEnd) {
|
|
46015
|
+
const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
|
|
46016
|
+
if (ttsQueueItem) {
|
|
46017
|
+
const sentence = getTtsQueueItemRefText(ttsQueueItem);
|
|
46018
|
+
utterance = new SpeechSynthesisUtterance(sentence);
|
|
46019
|
+
utterance.onboundary = (ev) => {
|
|
46020
|
+
self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, utterance.text);
|
|
46021
|
+
};
|
|
46022
|
+
setTimeout(() => {
|
|
46023
|
+
window.speechSynthesis.speak(utterance);
|
|
46024
|
+
}, 0);
|
|
46025
|
+
onend();
|
|
46026
|
+
}
|
|
46027
|
+
} else {
|
|
46028
|
+
const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
|
|
46029
|
+
if (ttsQueueItem) {
|
|
46030
|
+
utterance = new SpeechSynthesisUtterance(restOfTheText);
|
|
46031
|
+
utterance.onboundary = (ev) => {
|
|
46032
|
+
self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, utterance.text);
|
|
46033
|
+
};
|
|
46034
|
+
setTimeout(() => {
|
|
46035
|
+
window.speechSynthesis.speak(utterance);
|
|
46036
|
+
}, 0);
|
|
46037
|
+
onend();
|
|
46038
|
+
}
|
|
46039
|
+
if (idx > idxEnd) {
|
|
46040
|
+
if (IS_DEV)
|
|
46041
|
+
console.log("utterance ended");
|
|
46042
|
+
self2.highlighter.doneSpeaking();
|
|
46043
|
+
self2.api?.finished();
|
|
46044
|
+
self2.delegate.emit("readaloud.finished", "finished");
|
|
46045
|
+
}
|
|
46046
|
+
}
|
|
46047
|
+
} else {
|
|
46048
|
+
if (IS_DEV)
|
|
46049
|
+
console.log("utterance ended");
|
|
46050
|
+
self2.highlighter.doneSpeaking();
|
|
46051
|
+
self2.api?.finished();
|
|
46052
|
+
self2.delegate.emit("readaloud.finished", "finished");
|
|
46053
|
+
}
|
|
46054
|
+
};
|
|
46055
|
+
}
|
|
46056
|
+
onend();
|
|
47176
46057
|
callback();
|
|
47177
46058
|
}
|
|
47178
46059
|
speakPlay() {
|
|
46060
|
+
this.scrollPartial = true;
|
|
47179
46061
|
this.cancel(false);
|
|
47180
46062
|
if (this.api?.started)
|
|
47181
46063
|
this.api?.started();
|
|
@@ -47203,7 +46085,7 @@ var TTSModule2 = class {
|
|
|
47203
46085
|
selection.extend(endNode, endOffset);
|
|
47204
46086
|
selection.collapse(selection.anchorNode, selection.anchorOffset);
|
|
47205
46087
|
if (rootEl) {
|
|
47206
|
-
const idx = self2.findTtsQueueItemIndex(ttsQueue, selection.anchorNode, selection.
|
|
46088
|
+
const idx = self2.findTtsQueueItemIndex(ttsQueue, selection.anchorNode, selection.anchorNode, selection.anchorOffset, rootEl);
|
|
47207
46089
|
if (idx >= 0) {
|
|
47208
46090
|
ttsQueueIndex = idx;
|
|
47209
46091
|
}
|
|
@@ -47211,7 +46093,7 @@ var TTSModule2 = class {
|
|
|
47211
46093
|
selection.removeAllRanges();
|
|
47212
46094
|
}
|
|
47213
46095
|
};
|
|
47214
|
-
const ttsQueue = this.generateTtsQueue(rootEl
|
|
46096
|
+
const ttsQueue = this.generateTtsQueue(rootEl);
|
|
47215
46097
|
if (!ttsQueue.length) {
|
|
47216
46098
|
return;
|
|
47217
46099
|
}
|
|
@@ -47290,7 +46172,7 @@ var TTSModule2 = class {
|
|
|
47290
46172
|
removeEventListenerOptional(this.delegate.iframes[0].contentDocument, "keydown", this.wheel.bind(this));
|
|
47291
46173
|
removeEventListenerOptional(this.body, "click", this.click.bind(this));
|
|
47292
46174
|
}
|
|
47293
|
-
generateTtsQueue(rootElement
|
|
46175
|
+
generateTtsQueue(rootElement) {
|
|
47294
46176
|
const ttsQueue = [];
|
|
47295
46177
|
const elementStack = [];
|
|
47296
46178
|
function processTextNode(textNode) {
|
|
@@ -47310,9 +46192,6 @@ var TTSModule2 = class {
|
|
|
47310
46192
|
if (!current || current.parentElement !== parentElement || current.lang !== lang || current.dir !== dir) {
|
|
47311
46193
|
current = {
|
|
47312
46194
|
combinedText: "",
|
|
47313
|
-
combinedTextSentences: void 0,
|
|
47314
|
-
combinedTextSentencesRangeBegin: void 0,
|
|
47315
|
-
combinedTextSentencesRangeEnd: void 0,
|
|
47316
46195
|
dir,
|
|
47317
46196
|
lang,
|
|
47318
46197
|
parentElement,
|
|
@@ -47348,9 +46227,6 @@ var TTSModule2 = class {
|
|
|
47348
46227
|
const dir = void 0;
|
|
47349
46228
|
ttsQueue.push({
|
|
47350
46229
|
combinedText: txt,
|
|
47351
|
-
combinedTextSentences: void 0,
|
|
47352
|
-
combinedTextSentencesRangeBegin: void 0,
|
|
47353
|
-
combinedTextSentencesRangeEnd: void 0,
|
|
47354
46230
|
dir,
|
|
47355
46231
|
lang,
|
|
47356
46232
|
parentElement: childElement,
|
|
@@ -47379,48 +46255,19 @@ var TTSModule2 = class {
|
|
|
47379
46255
|
if (!ttsQueueItem.combinedText || !ttsQueueItem.combinedText.length) {
|
|
47380
46256
|
ttsQueueItem.combinedText = "";
|
|
47381
46257
|
}
|
|
47382
|
-
ttsQueueItem.combinedTextSentences = void 0;
|
|
47383
46258
|
return;
|
|
47384
46259
|
}
|
|
47385
46260
|
ttsQueueItem.combinedText = combineTextNodes(ttsQueueItem.textNodes, true).replace(/[\r\n]/g, " ");
|
|
47386
|
-
let skipSplitSentences = false;
|
|
47387
46261
|
let parent = ttsQueueItem.parentElement;
|
|
47388
46262
|
while (parent) {
|
|
47389
46263
|
if (parent.tagName) {
|
|
47390
46264
|
const tag = parent.tagName.toLowerCase();
|
|
47391
46265
|
if (tag === "pre" || tag === "code" || tag === "video" || tag === "audio") {
|
|
47392
|
-
skipSplitSentences = true;
|
|
47393
46266
|
break;
|
|
47394
46267
|
}
|
|
47395
46268
|
}
|
|
47396
46269
|
parent = parent.parentElement;
|
|
47397
46270
|
}
|
|
47398
|
-
if (splitSentences && !skipSplitSentences) {
|
|
47399
|
-
try {
|
|
47400
|
-
const txt = ttsQueueItem.combinedText;
|
|
47401
|
-
ttsQueueItem.combinedTextSentences = void 0;
|
|
47402
|
-
const sentences = (0, import_sentence_splitter.split)(txt);
|
|
47403
|
-
ttsQueueItem.combinedTextSentences = [];
|
|
47404
|
-
ttsQueueItem.combinedTextSentencesRangeBegin = [];
|
|
47405
|
-
ttsQueueItem.combinedTextSentencesRangeEnd = [];
|
|
47406
|
-
for (const sentence of sentences) {
|
|
47407
|
-
if (sentence.type === "Sentence") {
|
|
47408
|
-
ttsQueueItem.combinedTextSentences.push(sentence.raw);
|
|
47409
|
-
ttsQueueItem.combinedTextSentencesRangeBegin.push(sentence.range[0]);
|
|
47410
|
-
ttsQueueItem.combinedTextSentencesRangeEnd.push(sentence.range[1]);
|
|
47411
|
-
}
|
|
47412
|
-
}
|
|
47413
|
-
if (ttsQueueItem.combinedTextSentences.length === 0 || ttsQueueItem.combinedTextSentences.length === 1) {
|
|
47414
|
-
ttsQueueItem.combinedTextSentences = void 0;
|
|
47415
|
-
} else {
|
|
47416
|
-
}
|
|
47417
|
-
} catch (err) {
|
|
47418
|
-
console.log(err);
|
|
47419
|
-
ttsQueueItem.combinedTextSentences = void 0;
|
|
47420
|
-
}
|
|
47421
|
-
} else {
|
|
47422
|
-
ttsQueueItem.combinedTextSentences = void 0;
|
|
47423
|
-
}
|
|
47424
46271
|
}
|
|
47425
46272
|
for (const ttsQueueItem of ttsQueue) {
|
|
47426
46273
|
finalizeTextNodes(ttsQueueItem);
|
|
@@ -47432,39 +46279,12 @@ var TTSModule2 = class {
|
|
|
47432
46279
|
for (const ttsQueueItem of ttsQueue) {
|
|
47433
46280
|
if (startTextNode && ttsQueueItem.textNodes) {
|
|
47434
46281
|
if (ttsQueueItem.textNodes.includes(startTextNode)) {
|
|
47435
|
-
|
|
47436
|
-
let offset = 0;
|
|
47437
|
-
for (const txtNode of ttsQueueItem.textNodes) {
|
|
47438
|
-
if (!txtNode.nodeValue && txtNode.nodeValue !== "") {
|
|
47439
|
-
continue;
|
|
47440
|
-
}
|
|
47441
|
-
if (txtNode === startTextNode) {
|
|
47442
|
-
offset += startTextNodeOffset;
|
|
47443
|
-
break;
|
|
47444
|
-
}
|
|
47445
|
-
offset += txtNode.nodeValue.length;
|
|
47446
|
-
}
|
|
47447
|
-
let j = i - 1;
|
|
47448
|
-
for (const end of ttsQueueItem.combinedTextSentencesRangeEnd) {
|
|
47449
|
-
j++;
|
|
47450
|
-
if (end < offset) {
|
|
47451
|
-
continue;
|
|
47452
|
-
}
|
|
47453
|
-
return j;
|
|
47454
|
-
}
|
|
47455
|
-
return i;
|
|
47456
|
-
} else {
|
|
47457
|
-
return i;
|
|
47458
|
-
}
|
|
46282
|
+
return i;
|
|
47459
46283
|
}
|
|
47460
46284
|
} else if (element === ttsQueueItem.parentElement || ttsQueueItem.parentElement !== element.ownerDocument.body && ttsQueueItem.parentElement !== rootElem && ttsQueueItem.parentElement.contains(element) || element.contains(ttsQueueItem.parentElement)) {
|
|
47461
46285
|
return i;
|
|
47462
46286
|
}
|
|
47463
|
-
|
|
47464
|
-
i += ttsQueueItem.combinedTextSentences.length;
|
|
47465
|
-
} else {
|
|
47466
|
-
i++;
|
|
47467
|
-
}
|
|
46287
|
+
i++;
|
|
47468
46288
|
}
|
|
47469
46289
|
return -1;
|
|
47470
46290
|
}
|
|
@@ -47643,11 +46463,6 @@ var TTSModule2 = class {
|
|
|
47643
46463
|
const ttsQueueItem = ttsQueueItemRef.item;
|
|
47644
46464
|
let txtToCheck = ttsQueueItemRef.item.combinedText;
|
|
47645
46465
|
let charIndexAdjusted = charIndex;
|
|
47646
|
-
if (ttsQueueItem.combinedTextSentences && ttsQueueItem.combinedTextSentencesRangeBegin && ttsQueueItem.combinedTextSentencesRangeEnd && ttsQueueItemRef.iSentence >= 0) {
|
|
47647
|
-
const sentOffset = ttsQueueItem.combinedTextSentencesRangeBegin[ttsQueueItemRef.iSentence];
|
|
47648
|
-
charIndexAdjusted += sentOffset;
|
|
47649
|
-
txtToCheck = ttsQueueItem.combinedTextSentences[ttsQueueItemRef.iSentence];
|
|
47650
|
-
}
|
|
47651
46466
|
if (IS_DEV) {
|
|
47652
46467
|
if (utteranceText !== txtToCheck) {
|
|
47653
46468
|
console.log("TTS utteranceText DIFF?? ", `[[${utteranceText}]]`, `[[${txtToCheck}]]`);
|
|
@@ -47720,11 +46535,16 @@ var TTSModule2 = class {
|
|
|
47720
46535
|
}, HighlightType.ReadAloud, "R2_READALOUD_");
|
|
47721
46536
|
if (result) {
|
|
47722
46537
|
this._ttsQueueItemHighlightsWord = result[0];
|
|
47723
|
-
|
|
46538
|
+
const viewportOffset = result[1]?.firstChild?.getBoundingClientRect();
|
|
46539
|
+
const top = viewportOffset.top - this.wrapper.scrollTop;
|
|
46540
|
+
const shouldScroll = top > window.innerHeight / 2 - 65;
|
|
46541
|
+
if (this.delegate.view?.isScrollMode() && this.tts.autoScroll && !this.userScrolled && this.scrollPartial && shouldScroll) {
|
|
47724
46542
|
result[1]?.firstChild?.scrollIntoView({
|
|
47725
46543
|
block: "center",
|
|
47726
46544
|
behavior: "smooth"
|
|
47727
46545
|
});
|
|
46546
|
+
} else if (this.delegate.view?.isPaginated()) {
|
|
46547
|
+
self2.delegate.view?.snap(result[1]?.firstChild);
|
|
47728
46548
|
}
|
|
47729
46549
|
}
|
|
47730
46550
|
}
|
|
@@ -47781,32 +46601,15 @@ function getTtsQueueItemRef(items, index2) {
|
|
|
47781
46601
|
let k = -1;
|
|
47782
46602
|
for (const it of items) {
|
|
47783
46603
|
k++;
|
|
47784
|
-
|
|
47785
|
-
|
|
47786
|
-
|
|
47787
|
-
j++;
|
|
47788
|
-
i++;
|
|
47789
|
-
if (index2 === i) {
|
|
47790
|
-
return { item: it, iArray: k, iGlobal: i, iSentence: j };
|
|
47791
|
-
}
|
|
47792
|
-
}
|
|
47793
|
-
} else {
|
|
47794
|
-
i++;
|
|
47795
|
-
if (index2 === i) {
|
|
47796
|
-
return { item: it, iArray: k, iGlobal: i, iSentence: -1 };
|
|
47797
|
-
}
|
|
46604
|
+
i++;
|
|
46605
|
+
if (index2 === i) {
|
|
46606
|
+
return { item: it, iArray: k, iGlobal: i, iSentence: -1 };
|
|
47798
46607
|
}
|
|
47799
46608
|
}
|
|
47800
46609
|
return void 0;
|
|
47801
46610
|
}
|
|
47802
46611
|
function getTtsQueueItemRefText(obj) {
|
|
47803
|
-
|
|
47804
|
-
return obj.item.combinedText;
|
|
47805
|
-
}
|
|
47806
|
-
if (obj.item.combinedTextSentences) {
|
|
47807
|
-
return obj.item.combinedTextSentences[obj.iSentence];
|
|
47808
|
-
}
|
|
47809
|
-
return "";
|
|
46612
|
+
return obj.item.combinedText;
|
|
47810
46613
|
}
|
|
47811
46614
|
|
|
47812
46615
|
// src/modules/search/DefinitionsModule.ts
|