mashlib 2.1.3-54ca86bb → 2.1.3-65d8af17
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/mash.css +17 -0
- package/dist/mash.css.map +1 -1
- package/dist/mashlib.js +345 -93
- package/dist/mashlib.js.map +1 -1
- package/dist/mashlib.min.js +3 -3
- package/dist/mashlib.min.js.map +1 -1
- package/package.json +2 -2
package/dist/mashlib.js
CHANGED
|
@@ -18207,7 +18207,7 @@ if (true) {
|
|
|
18207
18207
|
(module) {
|
|
18208
18208
|
|
|
18209
18209
|
"use strict";
|
|
18210
|
-
/*! @license DOMPurify 3.3.
|
|
18210
|
+
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */
|
|
18211
18211
|
|
|
18212
18212
|
|
|
18213
18213
|
|
|
@@ -18516,7 +18516,7 @@ const _createHooksMap = function _createHooksMap() {
|
|
|
18516
18516
|
function createDOMPurify() {
|
|
18517
18517
|
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
|
18518
18518
|
const DOMPurify = root => createDOMPurify(root);
|
|
18519
|
-
DOMPurify.version = '3.3.
|
|
18519
|
+
DOMPurify.version = '3.3.3';
|
|
18520
18520
|
DOMPurify.removed = [];
|
|
18521
18521
|
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
|
18522
18522
|
// Not running in a browser, provide a factory function
|
|
@@ -18811,7 +18811,7 @@ function createDOMPurify() {
|
|
|
18811
18811
|
/* Parse profile info */
|
|
18812
18812
|
if (USE_PROFILES) {
|
|
18813
18813
|
ALLOWED_TAGS = addToSet({}, text);
|
|
18814
|
-
ALLOWED_ATTR =
|
|
18814
|
+
ALLOWED_ATTR = create(null);
|
|
18815
18815
|
if (USE_PROFILES.html === true) {
|
|
18816
18816
|
addToSet(ALLOWED_TAGS, html$1);
|
|
18817
18817
|
addToSet(ALLOWED_ATTR, html);
|
|
@@ -18832,6 +18832,13 @@ function createDOMPurify() {
|
|
|
18832
18832
|
addToSet(ALLOWED_ATTR, xml);
|
|
18833
18833
|
}
|
|
18834
18834
|
}
|
|
18835
|
+
/* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */
|
|
18836
|
+
if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {
|
|
18837
|
+
EXTRA_ELEMENT_HANDLING.tagCheck = null;
|
|
18838
|
+
}
|
|
18839
|
+
if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {
|
|
18840
|
+
EXTRA_ELEMENT_HANDLING.attributeCheck = null;
|
|
18841
|
+
}
|
|
18835
18842
|
/* Merge configuration parameters */
|
|
18836
18843
|
if (cfg.ADD_TAGS) {
|
|
18837
18844
|
if (typeof cfg.ADD_TAGS === 'function') {
|
|
@@ -19229,6 +19236,10 @@ function createDOMPurify() {
|
|
|
19229
19236
|
*/
|
|
19230
19237
|
// eslint-disable-next-line complexity
|
|
19231
19238
|
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
|
19239
|
+
/* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
|
|
19240
|
+
if (FORBID_ATTR[lcName]) {
|
|
19241
|
+
return false;
|
|
19242
|
+
}
|
|
19232
19243
|
/* Make sure attribute cannot clobber */
|
|
19233
19244
|
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
|
19234
19245
|
return false;
|
|
@@ -19321,7 +19332,7 @@ function createDOMPurify() {
|
|
|
19321
19332
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
19322
19333
|
}
|
|
19323
19334
|
/* Work around a security issue with comments inside attributes */
|
|
19324
|
-
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
|
|
19335
|
+
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
|
|
19325
19336
|
_removeAttribute(name, currentNode);
|
|
19326
19337
|
continue;
|
|
19327
19338
|
}
|
|
@@ -41850,11 +41861,13 @@ const IRIs_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
|
41850
41861
|
string: `${XSD}string`,
|
|
41851
41862
|
},
|
|
41852
41863
|
rdf: {
|
|
41853
|
-
type:
|
|
41854
|
-
nil:
|
|
41855
|
-
first:
|
|
41856
|
-
rest:
|
|
41857
|
-
langString:
|
|
41864
|
+
type: `${IRIs_RDF}type`,
|
|
41865
|
+
nil: `${IRIs_RDF}nil`,
|
|
41866
|
+
first: `${IRIs_RDF}first`,
|
|
41867
|
+
rest: `${IRIs_RDF}rest`,
|
|
41868
|
+
langString: `${IRIs_RDF}langString`,
|
|
41869
|
+
dirLangString: `${IRIs_RDF}dirLangString`,
|
|
41870
|
+
reifies: `${IRIs_RDF}reifies`,
|
|
41858
41871
|
},
|
|
41859
41872
|
owl: {
|
|
41860
41873
|
sameAs: 'http://www.w3.org/2002/07/owl#sameAs',
|
|
@@ -41892,6 +41905,7 @@ const lineModeRegExps = {
|
|
|
41892
41905
|
_unescapedIri: true,
|
|
41893
41906
|
_simpleQuotedString: true,
|
|
41894
41907
|
_langcode: true,
|
|
41908
|
+
_dircode: true,
|
|
41895
41909
|
_blank: true,
|
|
41896
41910
|
_newline: true,
|
|
41897
41911
|
_comment: true,
|
|
@@ -41909,15 +41923,16 @@ class N3Lexer {
|
|
|
41909
41923
|
this._unescapedIri = /^<([^\x00-\x20<>\\"\{\}\|\^\`]*)>[ \t]*/; // IRI without escape sequences; no unescaping
|
|
41910
41924
|
this._simpleQuotedString = /^"([^"\\\r\n]*)"(?=[^"])/; // string without escape sequences
|
|
41911
41925
|
this._simpleApostropheString = /^'([^'\\\r\n]*)'(?=[^'])/;
|
|
41912
|
-
this._langcode = /^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9
|
|
41926
|
+
this._langcode = /^@([a-z]+(?:-[a-z0-9]+)*)(?=[^a-z0-9])/i;
|
|
41927
|
+
this._dircode = /^--(ltr)|(rtl)/;
|
|
41913
41928
|
this._prefix = /^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:(?=[#\s<])/;
|
|
41914
41929
|
this._prefixed = /^((?:[A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)?:((?:(?:[0-:A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])(?:(?:[\.\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~])*(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff]|%[0-9a-fA-F]{2}|\\[!#-\/;=?\-@_~]))?)?)(?:[ \t]+|(?=\.?[,;!\^\s#()\[\]\{\}"'<>]))/;
|
|
41915
41930
|
this._variable = /^\?(?:(?:[A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:[\-0-:A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?=[.,;!\^\s#()\[\]\{\}"'<>])/;
|
|
41916
41931
|
this._blank = /^_:((?:[0-9A-Z_a-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])(?:\.?[\-0-9A-Z_a-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]|[\ud800-\udb7f][\udc00-\udfff])*)(?:[ \t]+|(?=\.?[,;:\s#()\[\]\{\}"'<>]))/;
|
|
41917
41932
|
this._number = /^[\-+]?(?:(\d+\.\d*|\.?\d+)[eE][\-+]?|\d*(\.)?)\d+(?=\.?[,;:\s#()\[\]\{\}"'<>])/;
|
|
41918
41933
|
this._boolean = /^(?:true|false)(?=[.,;\s#()\[\]\{\}"'<>])/;
|
|
41919
|
-
this.
|
|
41920
|
-
this.
|
|
41934
|
+
this._atKeyword = /^@[a-z]+(?=[\s#<:])/i;
|
|
41935
|
+
this._keyword = /^(?:PREFIX|BASE|VERSION|GRAPH)(?=[\s#<])/i;
|
|
41921
41936
|
this._shortPredicates = /^a(?=[\s#()\[\]\{\}"'<>])/;
|
|
41922
41937
|
this._newline = /^[ \t]*(?:#[^\n\r]*)?(?:\r\n|\n|\r)[ \t]*/;
|
|
41923
41938
|
this._comment = /#([^\n\r]*)/;
|
|
@@ -42022,8 +42037,11 @@ class N3Lexer {
|
|
|
42022
42037
|
return reportSyntaxError(this);
|
|
42023
42038
|
type = 'IRI';
|
|
42024
42039
|
}
|
|
42025
|
-
// Try to find a
|
|
42026
|
-
else if (input.length >
|
|
42040
|
+
// Try to find a triple term
|
|
42041
|
+
else if (input.length > 2 && input[1] === '<' && input[2] === '(')
|
|
42042
|
+
type = '<<(', matchLength = 3;
|
|
42043
|
+
// Try to find a reified triple
|
|
42044
|
+
else if (!this._lineMode && input.length > (inputFinished ? 1 : 2) && input[1] === '<')
|
|
42027
42045
|
type = '<<', matchLength = 2;
|
|
42028
42046
|
// Try to find a backwards implication arrow
|
|
42029
42047
|
else if (this._n3Mode && input.length > 1 && input[1] === '=') {
|
|
@@ -42034,6 +42052,7 @@ class N3Lexer {
|
|
|
42034
42052
|
break;
|
|
42035
42053
|
|
|
42036
42054
|
case '>':
|
|
42055
|
+
// Try to find a reified triple
|
|
42037
42056
|
if (input.length > 1 && input[1] === '>')
|
|
42038
42057
|
type = '>>', matchLength = 2;
|
|
42039
42058
|
break;
|
|
@@ -42089,10 +42108,10 @@ class N3Lexer {
|
|
|
42089
42108
|
|
|
42090
42109
|
case '@':
|
|
42091
42110
|
// Try to find a language code
|
|
42092
|
-
if (this._previousMarker === 'literal' && (match = this._langcode.exec(input)))
|
|
42111
|
+
if (this._previousMarker === 'literal' && (match = this._langcode.exec(input)) && match[1] !== 'version')
|
|
42093
42112
|
type = 'langcode', value = match[1];
|
|
42094
42113
|
// Try to find a keyword
|
|
42095
|
-
else if (match = this.
|
|
42114
|
+
else if (match = this._atKeyword.exec(input))
|
|
42096
42115
|
type = match[0];
|
|
42097
42116
|
break;
|
|
42098
42117
|
|
|
@@ -42117,6 +42136,13 @@ class N3Lexer {
|
|
|
42117
42136
|
case '9':
|
|
42118
42137
|
case '+':
|
|
42119
42138
|
case '-':
|
|
42139
|
+
if (input[1] === '-') {
|
|
42140
|
+
// Try to find a direction code
|
|
42141
|
+
if (this._previousMarker === 'langcode' && (match = this._dircode.exec(input)))
|
|
42142
|
+
type = 'dircode', matchLength = 2, value = (match[1] || match[2]), matchLength = value.length + 2;
|
|
42143
|
+
break;
|
|
42144
|
+
}
|
|
42145
|
+
|
|
42120
42146
|
// Try to find a number. Since it can contain (but not end with) a dot,
|
|
42121
42147
|
// we always need a non-dot character before deciding it is a number.
|
|
42122
42148
|
// Therefore, try inserting a space if we're at the end of the input.
|
|
@@ -42134,8 +42160,10 @@ class N3Lexer {
|
|
|
42134
42160
|
case 'P':
|
|
42135
42161
|
case 'G':
|
|
42136
42162
|
case 'g':
|
|
42163
|
+
case 'V':
|
|
42164
|
+
case 'v':
|
|
42137
42165
|
// Try to find a SPARQL-style keyword
|
|
42138
|
-
if (match = this.
|
|
42166
|
+
if (match = this._keyword.exec(input))
|
|
42139
42167
|
type = match[0].toUpperCase();
|
|
42140
42168
|
else
|
|
42141
42169
|
inconclusive = true;
|
|
@@ -42172,13 +42200,23 @@ class N3Lexer {
|
|
|
42172
42200
|
case '!':
|
|
42173
42201
|
if (!this._n3Mode)
|
|
42174
42202
|
break;
|
|
42203
|
+
case ')':
|
|
42204
|
+
if (!inputFinished && (input.length === 1 || (input.length === 2 && input[1] === '>'))) {
|
|
42205
|
+
// Don't consume yet, as it *could* become a triple term end.
|
|
42206
|
+
break;
|
|
42207
|
+
}
|
|
42208
|
+
// Try to find a triple term
|
|
42209
|
+
if (input.length > 2 && input[1] === '>' && input[2] === '>') {
|
|
42210
|
+
type = ')>>', matchLength = 3;
|
|
42211
|
+
break;
|
|
42212
|
+
}
|
|
42175
42213
|
case ',':
|
|
42176
42214
|
case ';':
|
|
42177
42215
|
case '[':
|
|
42178
42216
|
case ']':
|
|
42179
42217
|
case '(':
|
|
42180
|
-
case ')':
|
|
42181
42218
|
case '}':
|
|
42219
|
+
case '~':
|
|
42182
42220
|
if (!this._lineMode) {
|
|
42183
42221
|
matchLength = 1;
|
|
42184
42222
|
type = firstChar;
|
|
@@ -42489,8 +42527,18 @@ class N3DataFactory_Literal extends Term {
|
|
|
42489
42527
|
// Find the last quotation mark (e.g., '"abc"@en-us')
|
|
42490
42528
|
const id = this.id;
|
|
42491
42529
|
let atPos = id.lastIndexOf('"') + 1;
|
|
42530
|
+
const dirPos = id.lastIndexOf('--');
|
|
42492
42531
|
// If "@" it follows, return the remaining substring; empty otherwise
|
|
42493
|
-
return atPos < id.length && id[atPos++] === '@' ? id.substr(atPos).toLowerCase() : '';
|
|
42532
|
+
return atPos < id.length && id[atPos++] === '@' ? (dirPos > atPos ? id.substr(0, dirPos) : id).substr(atPos).toLowerCase() : '';
|
|
42533
|
+
}
|
|
42534
|
+
|
|
42535
|
+
// ### The direction of this literal
|
|
42536
|
+
get direction() {
|
|
42537
|
+
// Find the last double dash after the closing quote (e.g., '"abc"@en-us--ltr')
|
|
42538
|
+
const id = this.id;
|
|
42539
|
+
const endPos = id.lastIndexOf('"');
|
|
42540
|
+
const dirPos = id.lastIndexOf('--');
|
|
42541
|
+
return dirPos > endPos && dirPos + 2 < id.length ? id.substr(dirPos + 2).toLowerCase() : '';
|
|
42494
42542
|
}
|
|
42495
42543
|
|
|
42496
42544
|
// ### The datatype IRI of this literal
|
|
@@ -42505,8 +42553,8 @@ class N3DataFactory_Literal extends Term {
|
|
|
42505
42553
|
const char = dtPos < id.length ? id[dtPos] : '';
|
|
42506
42554
|
// If "^" it follows, return the remaining substring
|
|
42507
42555
|
return char === '^' ? id.substr(dtPos + 2) :
|
|
42508
|
-
// If "@" follows, return rdf:langString; xsd:string otherwise
|
|
42509
|
-
(char !== '@' ? N3DataFactory_xsd.string : N3DataFactory_rdf.langString);
|
|
42556
|
+
// If "@" follows, return rdf:langString or rdf:dirLangString; xsd:string otherwise
|
|
42557
|
+
(char !== '@' ? N3DataFactory_xsd.string : (id.indexOf('--', dtPos) > 0 ? N3DataFactory_rdf.dirLangString : N3DataFactory_rdf.langString));
|
|
42510
42558
|
}
|
|
42511
42559
|
|
|
42512
42560
|
// ### Returns whether this object represents the same term as the other
|
|
@@ -42520,14 +42568,16 @@ class N3DataFactory_Literal extends Term {
|
|
|
42520
42568
|
this.termType === other.termType &&
|
|
42521
42569
|
this.value === other.value &&
|
|
42522
42570
|
this.language === other.language &&
|
|
42571
|
+
((this.direction === other.direction) || (this.direction === '' && !other.direction)) &&
|
|
42523
42572
|
this.datatype.value === other.datatype.value;
|
|
42524
42573
|
}
|
|
42525
42574
|
|
|
42526
42575
|
toJSON() {
|
|
42527
42576
|
return {
|
|
42528
|
-
termType:
|
|
42529
|
-
value:
|
|
42530
|
-
language:
|
|
42577
|
+
termType: this.termType,
|
|
42578
|
+
value: this.value,
|
|
42579
|
+
language: this.language,
|
|
42580
|
+
direction: this.direction,
|
|
42531
42581
|
datatype: { termType: 'NamedNode', value: this.datatypeString },
|
|
42532
42582
|
};
|
|
42533
42583
|
}
|
|
@@ -42617,9 +42667,22 @@ function termFromId(id, factory, nested) {
|
|
|
42617
42667
|
return factory.literal(id.substr(1, id.length - 2));
|
|
42618
42668
|
// Literal with datatype or language
|
|
42619
42669
|
const endPos = id.lastIndexOf('"', id.length - 1);
|
|
42670
|
+
let languageOrDatatype;
|
|
42671
|
+
if (id[endPos + 1] === '@') {
|
|
42672
|
+
languageOrDatatype = id.substr(endPos + 2);
|
|
42673
|
+
const dashDashIndex = languageOrDatatype.lastIndexOf('--');
|
|
42674
|
+
if (dashDashIndex > 0 && dashDashIndex < languageOrDatatype.length) {
|
|
42675
|
+
languageOrDatatype = {
|
|
42676
|
+
language: languageOrDatatype.substr(0, dashDashIndex),
|
|
42677
|
+
direction: languageOrDatatype.substr(dashDashIndex + 2),
|
|
42678
|
+
};
|
|
42679
|
+
}
|
|
42680
|
+
}
|
|
42681
|
+
else {
|
|
42682
|
+
languageOrDatatype = factory.namedNode(id.substr(endPos + 3));
|
|
42683
|
+
}
|
|
42620
42684
|
return factory.literal(id.substr(1, endPos - 1),
|
|
42621
|
-
|
|
42622
|
-
: factory.namedNode(id.substr(endPos + 3)));
|
|
42685
|
+
languageOrDatatype);
|
|
42623
42686
|
case '[':
|
|
42624
42687
|
id = JSON.parse(id);
|
|
42625
42688
|
break;
|
|
@@ -42656,7 +42719,7 @@ function termToId(term, nested) {
|
|
|
42656
42719
|
case 'Variable': return `?${term.value}`;
|
|
42657
42720
|
case 'DefaultGraph': return '';
|
|
42658
42721
|
case 'Literal': return `"${term.value}"${
|
|
42659
|
-
term.language ? `@${term.language}` :
|
|
42722
|
+
term.language ? `@${term.language}${term.direction ? `--${term.direction}` : ''}` :
|
|
42660
42723
|
(term.datatype && term.datatype.value !== N3DataFactory_xsd.string ? `^^${term.datatype.value}` : '')}`;
|
|
42661
42724
|
case 'Quad':
|
|
42662
42725
|
const res = [
|
|
@@ -42751,6 +42814,11 @@ function literal(value, languageOrDataType) {
|
|
|
42751
42814
|
if (typeof languageOrDataType === 'string')
|
|
42752
42815
|
return new N3DataFactory_Literal(`"${value}"@${languageOrDataType.toLowerCase()}`);
|
|
42753
42816
|
|
|
42817
|
+
// Create a language-tagged string with base direction
|
|
42818
|
+
if (languageOrDataType !== undefined && !('termType' in languageOrDataType)) {
|
|
42819
|
+
return new N3DataFactory_Literal(`"${value}"@${languageOrDataType.language.toLowerCase()}${languageOrDataType.direction ? `--${languageOrDataType.direction.toLowerCase()}` : ''}`);
|
|
42820
|
+
}
|
|
42821
|
+
|
|
42754
42822
|
// Automatically determine datatype for booleans and numbers
|
|
42755
42823
|
let datatype = languageOrDataType ? languageOrDataType.value : '';
|
|
42756
42824
|
if (datatype === '') {
|
|
@@ -42848,8 +42916,6 @@ class N3Parser {
|
|
|
42848
42916
|
this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
|
|
42849
42917
|
// Whether the log:isImpliedBy predicate is supported
|
|
42850
42918
|
this._isImpliedBy = options.isImpliedBy;
|
|
42851
|
-
// Support nesting of triples
|
|
42852
|
-
this._supportsRDFStar = format === '' || /star|\*$/.test(format);
|
|
42853
42919
|
// Disable relative IRIs in N-Triples or N-Quads mode
|
|
42854
42920
|
if (isLineMode)
|
|
42855
42921
|
this._resolveRelativeIRI = iri => { return null; };
|
|
@@ -42858,6 +42924,9 @@ class N3Parser {
|
|
|
42858
42924
|
this._lexer = options.lexer || new N3Lexer({ lineMode: isLineMode, n3: isN3, isImpliedBy: this._isImpliedBy });
|
|
42859
42925
|
// Disable explicit quantifiers by default
|
|
42860
42926
|
this._explicitQuantifiers = !!options.explicitQuantifiers;
|
|
42927
|
+
// Disable parsing of unsupported versions by default
|
|
42928
|
+
this._parseUnsupportedVersions = !!options.parseUnsupportedVersions;
|
|
42929
|
+
this._version = options.version;
|
|
42861
42930
|
}
|
|
42862
42931
|
|
|
42863
42932
|
// ## Static class methods
|
|
@@ -42935,6 +43004,13 @@ class N3Parser {
|
|
|
42935
43004
|
}
|
|
42936
43005
|
}
|
|
42937
43006
|
|
|
43007
|
+
// ### `_readBeforeTopContext` is called once only at the start of parsing.
|
|
43008
|
+
_readBeforeTopContext(token) {
|
|
43009
|
+
if (this._version && !this._isValidVersion(this._version))
|
|
43010
|
+
return this._error(`Detected unsupported version as media type parameter: "${this._version}"`, token);
|
|
43011
|
+
return this._readInTopContext(token);
|
|
43012
|
+
}
|
|
43013
|
+
|
|
42938
43014
|
// ### `_readInTopContext` reads a token when in the top context
|
|
42939
43015
|
_readInTopContext(token) {
|
|
42940
43016
|
switch (token.type) {
|
|
@@ -42954,6 +43030,11 @@ class N3Parser {
|
|
|
42954
43030
|
this._sparqlStyle = true;
|
|
42955
43031
|
case '@base':
|
|
42956
43032
|
return this._readBaseIRI;
|
|
43033
|
+
// It could be a version declaration
|
|
43034
|
+
case 'VERSION':
|
|
43035
|
+
this._sparqlStyle = true;
|
|
43036
|
+
case '@version':
|
|
43037
|
+
return this._readVersion;
|
|
42957
43038
|
// It could be a graph
|
|
42958
43039
|
case '{':
|
|
42959
43040
|
if (this._supportsNamedGraphs) {
|
|
@@ -43018,6 +43099,10 @@ class N3Parser {
|
|
|
43018
43099
|
this._subject = this._factory.blankNode(), null, null);
|
|
43019
43100
|
return this._readBlankNodeHead;
|
|
43020
43101
|
case '(':
|
|
43102
|
+
const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];
|
|
43103
|
+
if (parent.type === '<<') {
|
|
43104
|
+
return this._error('Unexpected list in reified triple', token);
|
|
43105
|
+
}
|
|
43021
43106
|
// Start a new list
|
|
43022
43107
|
this._saveContext('list', this._graph, this.RDF_NIL, null, null);
|
|
43023
43108
|
this._subject = null;
|
|
@@ -43058,9 +43143,13 @@ class N3Parser {
|
|
|
43058
43143
|
this._subject = this._factory.literal(token.value, this._factory.namedNode(token.prefix));
|
|
43059
43144
|
|
|
43060
43145
|
break;
|
|
43146
|
+
case '<<(':
|
|
43147
|
+
if (!this._n3Mode)
|
|
43148
|
+
return this._error('Disallowed triple term as subject', token);
|
|
43149
|
+
this._saveContext('<<(', this._graph, null, null, null);
|
|
43150
|
+
this._graph = null;
|
|
43151
|
+
return this._readSubject;
|
|
43061
43152
|
case '<<':
|
|
43062
|
-
if (!this._supportsRDFStar)
|
|
43063
|
-
return this._error('Unexpected RDF-star syntax', token);
|
|
43064
43153
|
this._saveContext('<<', this._graph, null, null, null);
|
|
43065
43154
|
this._graph = null;
|
|
43066
43155
|
return this._readSubject;
|
|
@@ -43090,6 +43179,7 @@ class N3Parser {
|
|
|
43090
43179
|
case '.':
|
|
43091
43180
|
case ']':
|
|
43092
43181
|
case '}':
|
|
43182
|
+
case '|}':
|
|
43093
43183
|
// Expected predicate didn't come, must have been trailing semicolon
|
|
43094
43184
|
if (this._predicate === null)
|
|
43095
43185
|
return this._error(`Unexpected ${type}`, token);
|
|
@@ -43113,6 +43203,7 @@ class N3Parser {
|
|
|
43113
43203
|
if ((this._predicate = this._readEntity(token)) === undefined)
|
|
43114
43204
|
return;
|
|
43115
43205
|
}
|
|
43206
|
+
this._validAnnotation = true;
|
|
43116
43207
|
// The next token must be an object
|
|
43117
43208
|
return this._readObject;
|
|
43118
43209
|
}
|
|
@@ -43136,6 +43227,10 @@ class N3Parser {
|
|
|
43136
43227
|
this._subject = this._factory.blankNode());
|
|
43137
43228
|
return this._readBlankNodeHead;
|
|
43138
43229
|
case '(':
|
|
43230
|
+
const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];
|
|
43231
|
+
if (parent.type === '<<') {
|
|
43232
|
+
return this._error('Unexpected list in reified triple', token);
|
|
43233
|
+
}
|
|
43139
43234
|
// Start a new list
|
|
43140
43235
|
this._saveContext('list', this._graph, this._subject, this._predicate, this.RDF_NIL);
|
|
43141
43236
|
this._subject = null;
|
|
@@ -43147,9 +43242,11 @@ class N3Parser {
|
|
|
43147
43242
|
this._saveContext('formula', this._graph, this._subject, this._predicate,
|
|
43148
43243
|
this._graph = this._factory.blankNode());
|
|
43149
43244
|
return this._readSubject;
|
|
43245
|
+
case '<<(':
|
|
43246
|
+
this._saveContext('<<(', this._graph, this._subject, this._predicate, null);
|
|
43247
|
+
this._graph = null;
|
|
43248
|
+
return this._readSubject;
|
|
43150
43249
|
case '<<':
|
|
43151
|
-
if (!this._supportsRDFStar)
|
|
43152
|
-
return this._error('Unexpected RDF-star syntax', token);
|
|
43153
43250
|
this._saveContext('<<', this._graph, this._subject, this._predicate, null);
|
|
43154
43251
|
this._graph = null;
|
|
43155
43252
|
return this._readSubject;
|
|
@@ -43185,6 +43282,10 @@ class N3Parser {
|
|
|
43185
43282
|
return this._readBlankNodeTail(token);
|
|
43186
43283
|
}
|
|
43187
43284
|
else {
|
|
43285
|
+
const stack = this._contextStack, parentParent = stack.length > 1 && stack[stack.length - 2];
|
|
43286
|
+
if (parentParent.type === '<<') {
|
|
43287
|
+
return this._error('Unexpected compound blank node expression in reified triple', token);
|
|
43288
|
+
}
|
|
43188
43289
|
this._predicate = null;
|
|
43189
43290
|
return this._readPredicate(token);
|
|
43190
43291
|
}
|
|
@@ -43294,6 +43395,11 @@ class N3Parser {
|
|
|
43294
43395
|
this._saveContext('formula', this._graph, this._subject, this._predicate,
|
|
43295
43396
|
this._graph = this._factory.blankNode());
|
|
43296
43397
|
return this._readSubject;
|
|
43398
|
+
case '<<':
|
|
43399
|
+
this._saveContext('<<', this._graph, null, null, null);
|
|
43400
|
+
this._graph = null;
|
|
43401
|
+
next = this._readSubject;
|
|
43402
|
+
break;
|
|
43297
43403
|
default:
|
|
43298
43404
|
if ((item = this._readEntity(token)) === undefined)
|
|
43299
43405
|
return;
|
|
@@ -43303,6 +43409,10 @@ class N3Parser {
|
|
|
43303
43409
|
if (list === null)
|
|
43304
43410
|
this._subject = list = this._factory.blankNode();
|
|
43305
43411
|
|
|
43412
|
+
// When reading a reified triple, store the list as subject in the stack, as this will be overridden when reading the triple.
|
|
43413
|
+
if (token.type === '<<')
|
|
43414
|
+
stack[stack.length - 1].subject = this._subject;
|
|
43415
|
+
|
|
43306
43416
|
// Is this the first element of the list?
|
|
43307
43417
|
if (previousList === null) {
|
|
43308
43418
|
// This list is either the subject or the object of its parent
|
|
@@ -43343,9 +43453,10 @@ class N3Parser {
|
|
|
43343
43453
|
}
|
|
43344
43454
|
|
|
43345
43455
|
// ### `_completeLiteral` completes a literal with an optional datatype or language
|
|
43346
|
-
_completeLiteral(token) {
|
|
43456
|
+
_completeLiteral(token, component) {
|
|
43347
43457
|
// Create a simple string literal by default
|
|
43348
43458
|
let literal = this._factory.literal(this._literalValue);
|
|
43459
|
+
let readCb;
|
|
43349
43460
|
|
|
43350
43461
|
switch (token.type) {
|
|
43351
43462
|
// Create a datatyped literal
|
|
@@ -43353,43 +43464,82 @@ class N3Parser {
|
|
|
43353
43464
|
case 'typeIRI':
|
|
43354
43465
|
const datatype = this._readEntity(token);
|
|
43355
43466
|
if (datatype === undefined) return; // No datatype means an error occurred
|
|
43467
|
+
if (datatype.value === IRIs.rdf.langString || datatype.value === IRIs.rdf.dirLangString) {
|
|
43468
|
+
return this._error('Detected illegal (directional) languaged-tagged string with explicit datatype', token);
|
|
43469
|
+
}
|
|
43356
43470
|
literal = this._factory.literal(this._literalValue, datatype);
|
|
43357
43471
|
token = null;
|
|
43358
43472
|
break;
|
|
43359
43473
|
// Create a language-tagged string
|
|
43360
43474
|
case 'langcode':
|
|
43475
|
+
if (token.value.split('-').some(t => t.length > 8))
|
|
43476
|
+
return this._error('Detected language tag with subtag longer than 8 characters', token);
|
|
43361
43477
|
literal = this._factory.literal(this._literalValue, token.value);
|
|
43478
|
+
this._literalLanguage = token.value;
|
|
43362
43479
|
token = null;
|
|
43480
|
+
readCb = this._readDirCode.bind(this, component);
|
|
43363
43481
|
break;
|
|
43364
43482
|
}
|
|
43365
43483
|
|
|
43366
|
-
return { token, literal };
|
|
43484
|
+
return { token, literal, readCb };
|
|
43485
|
+
}
|
|
43486
|
+
|
|
43487
|
+
_readDirCode(component, listItem, token) {
|
|
43488
|
+
// Attempt to read a dircode
|
|
43489
|
+
if (token.type === 'dircode') {
|
|
43490
|
+
const term = this._factory.literal(this._literalValue, { language: this._literalLanguage, direction: token.value });
|
|
43491
|
+
if (component === 'subject')
|
|
43492
|
+
this._subject = term;
|
|
43493
|
+
else
|
|
43494
|
+
this._object = term;
|
|
43495
|
+
this._literalLanguage = undefined;
|
|
43496
|
+
token = null;
|
|
43497
|
+
}
|
|
43498
|
+
|
|
43499
|
+
if (component === 'subject')
|
|
43500
|
+
return token === null ? this._readPredicateOrNamedGraph : this._readPredicateOrNamedGraph(token);
|
|
43501
|
+
return this._completeObjectLiteralPost(token, listItem);
|
|
43367
43502
|
}
|
|
43368
43503
|
|
|
43369
43504
|
// Completes a literal in subject position
|
|
43370
43505
|
_completeSubjectLiteral(token) {
|
|
43371
|
-
|
|
43506
|
+
const completed = this._completeLiteral(token, 'subject');
|
|
43507
|
+
this._subject = completed.literal;
|
|
43508
|
+
|
|
43509
|
+
// Postpone completion if the literal is only partially completed (such as lang+dir).
|
|
43510
|
+
if (completed.readCb)
|
|
43511
|
+
return completed.readCb.bind(this, false);
|
|
43512
|
+
|
|
43372
43513
|
return this._readPredicateOrNamedGraph;
|
|
43373
43514
|
}
|
|
43374
43515
|
|
|
43375
43516
|
// Completes a literal in object position
|
|
43376
43517
|
_completeObjectLiteral(token, listItem) {
|
|
43377
|
-
const completed = this._completeLiteral(token);
|
|
43518
|
+
const completed = this._completeLiteral(token, 'object');
|
|
43378
43519
|
if (!completed)
|
|
43379
43520
|
return;
|
|
43521
|
+
|
|
43380
43522
|
this._object = completed.literal;
|
|
43381
43523
|
|
|
43524
|
+
// Postpone completion if the literal is only partially completed (such as lang+dir).
|
|
43525
|
+
if (completed.readCb)
|
|
43526
|
+
return completed.readCb.bind(this, listItem);
|
|
43527
|
+
|
|
43528
|
+
return this._completeObjectLiteralPost(completed.token, listItem);
|
|
43529
|
+
}
|
|
43530
|
+
|
|
43531
|
+
_completeObjectLiteralPost(token, listItem) {
|
|
43382
43532
|
// If this literal was part of a list, write the item
|
|
43383
43533
|
// (we could also check the context stack, but passing in a flag is faster)
|
|
43384
43534
|
if (listItem)
|
|
43385
43535
|
this._emit(this._subject, this.RDF_FIRST, this._object, this._graph);
|
|
43386
43536
|
// If the token was consumed, continue with the rest of the input
|
|
43387
|
-
if (
|
|
43537
|
+
if (token === null)
|
|
43388
43538
|
return this._getContextEndReader();
|
|
43389
43539
|
// Otherwise, consume the token now
|
|
43390
43540
|
else {
|
|
43391
43541
|
this._readCallback = this._getContextEndReader();
|
|
43392
|
-
return this._readCallback(
|
|
43542
|
+
return this._readCallback(token);
|
|
43393
43543
|
}
|
|
43394
43544
|
}
|
|
43395
43545
|
|
|
@@ -43411,7 +43561,7 @@ class N3Parser {
|
|
|
43411
43561
|
|
|
43412
43562
|
// ### `_readPunctuation` reads punctuation between quads or quad parts
|
|
43413
43563
|
_readPunctuation(token) {
|
|
43414
|
-
let next, graph = this._graph;
|
|
43564
|
+
let next, graph = this._graph, startingAnnotation = false;
|
|
43415
43565
|
const subject = this._subject, inversePredicate = this._inversePredicate;
|
|
43416
43566
|
switch (token.type) {
|
|
43417
43567
|
// A closing brace ends a graph
|
|
@@ -43424,6 +43574,7 @@ class N3Parser {
|
|
|
43424
43574
|
// A dot just ends the statement, without sharing anything with the next
|
|
43425
43575
|
case '.':
|
|
43426
43576
|
this._subject = null;
|
|
43577
|
+
this._tripleTerm = null;
|
|
43427
43578
|
next = this._contextStack.length ? this._readSubject : this._readInTopContext;
|
|
43428
43579
|
if (inversePredicate) this._inversePredicate = false;
|
|
43429
43580
|
break;
|
|
@@ -43435,20 +43586,27 @@ class N3Parser {
|
|
|
43435
43586
|
case ',':
|
|
43436
43587
|
next = this._readObject;
|
|
43437
43588
|
break;
|
|
43589
|
+
// ~ is allowed in the annotation syntax
|
|
43590
|
+
case '~':
|
|
43591
|
+
next = this._readReifierInAnnotation;
|
|
43592
|
+
startingAnnotation = true;
|
|
43593
|
+
break;
|
|
43438
43594
|
// {| means that the current triple is annotated with predicate-object pairs.
|
|
43439
43595
|
case '{|':
|
|
43440
|
-
|
|
43441
|
-
|
|
43442
|
-
|
|
43443
|
-
|
|
43444
|
-
this._subject = this._factory.quad(subject, predicate, object, this.DEFAULTGRAPH);
|
|
43596
|
+
// Continue using the last triple as reified triple subject for the predicate-object pairs.
|
|
43597
|
+
this._subject = this._readTripleTerm();
|
|
43598
|
+
this._validAnnotation = false;
|
|
43599
|
+
startingAnnotation = true;
|
|
43445
43600
|
next = this._readPredicate;
|
|
43446
43601
|
break;
|
|
43447
|
-
// |} means that the current
|
|
43602
|
+
// |} means that the current reified triple in annotation syntax is finalized.
|
|
43448
43603
|
case '|}':
|
|
43449
|
-
if (this.
|
|
43450
|
-
return this._error('Unexpected
|
|
43604
|
+
if (!this._annotation)
|
|
43605
|
+
return this._error('Unexpected annotation syntax closing', token);
|
|
43606
|
+
if (!this._validAnnotation)
|
|
43607
|
+
return this._error('Annotation block can not be empty', token);
|
|
43451
43608
|
this._subject = null;
|
|
43609
|
+
this._annotation = false;
|
|
43452
43610
|
next = this._readPunctuation;
|
|
43453
43611
|
break;
|
|
43454
43612
|
default:
|
|
@@ -43460,13 +43618,16 @@ class N3Parser {
|
|
|
43460
43618
|
return this._error(`Expected punctuation to follow "${this._object.id}"`, token);
|
|
43461
43619
|
}
|
|
43462
43620
|
// A quad has been completed now, so return it
|
|
43463
|
-
if (subject !== null) {
|
|
43621
|
+
if (subject !== null && (!startingAnnotation || (startingAnnotation && !this._annotation))) {
|
|
43464
43622
|
const predicate = this._predicate, object = this._object;
|
|
43465
43623
|
if (!inversePredicate)
|
|
43466
43624
|
this._emit(subject, predicate, object, graph);
|
|
43467
43625
|
else
|
|
43468
43626
|
this._emit(object, predicate, subject, graph);
|
|
43469
43627
|
}
|
|
43628
|
+
if (startingAnnotation) {
|
|
43629
|
+
this._annotation = true;
|
|
43630
|
+
}
|
|
43470
43631
|
return next;
|
|
43471
43632
|
}
|
|
43472
43633
|
|
|
@@ -43524,6 +43685,23 @@ class N3Parser {
|
|
|
43524
43685
|
return this._readDeclarationPunctuation;
|
|
43525
43686
|
}
|
|
43526
43687
|
|
|
43688
|
+
// ### `_isValidVersion` checks if the given version is valid for this parser to handle.
|
|
43689
|
+
_isValidVersion(version) {
|
|
43690
|
+
return this._parseUnsupportedVersions || N3Parser.SUPPORTED_VERSIONS.includes(version);
|
|
43691
|
+
}
|
|
43692
|
+
|
|
43693
|
+
// ### `_readVersion` reads version string declaration
|
|
43694
|
+
_readVersion(token) {
|
|
43695
|
+
if (token.type !== 'literal')
|
|
43696
|
+
return this._error('Expected literal to follow version declaration', token);
|
|
43697
|
+
if ((token.end - token.start) !== token.value.length + 2)
|
|
43698
|
+
return this._error('Version declarations must use single quotes', token);
|
|
43699
|
+
this._versionCallback(token.value);
|
|
43700
|
+
if (!this._isValidVersion(token.value))
|
|
43701
|
+
return this._error(`Detected unsupported version: "${token.value}"`, token);
|
|
43702
|
+
return this._readDeclarationPunctuation;
|
|
43703
|
+
}
|
|
43704
|
+
|
|
43527
43705
|
// ### `_readNamedGraphLabel` reads the label of a named graph
|
|
43528
43706
|
_readNamedGraphLabel(token) {
|
|
43529
43707
|
switch (token.type) {
|
|
@@ -43672,25 +43850,15 @@ class N3Parser {
|
|
|
43672
43850
|
return this._readPath;
|
|
43673
43851
|
}
|
|
43674
43852
|
|
|
43675
|
-
|
|
43676
|
-
|
|
43677
|
-
if (token.type !== '>>')
|
|
43678
|
-
|
|
43679
|
-
if (this._supportsQuads && this._graph === null && (this._graph = this._readEntity(token)) !== undefined)
|
|
43680
|
-
return this._readRDFStarTail;
|
|
43681
|
-
return this._error(`Expected >> to follow "${this._object.id}"`, token);
|
|
43682
|
-
}
|
|
43683
|
-
return this._readRDFStarTail(token);
|
|
43684
|
-
}
|
|
43685
|
-
|
|
43686
|
-
// ### `_readRDFStarTail` reads the end of a nested RDF-star triple
|
|
43687
|
-
_readRDFStarTail(token) {
|
|
43688
|
-
if (token.type !== '>>')
|
|
43689
|
-
return this._error(`Expected >> but got ${token.type}`, token);
|
|
43853
|
+
// ### `_readTripleTermTail` reads the end of a triple term
|
|
43854
|
+
_readTripleTermTail(token) {
|
|
43855
|
+
if (token.type !== ')>>')
|
|
43856
|
+
return this._error(`Expected )>> but got ${token.type}`, token);
|
|
43690
43857
|
// Read the quad and restore the previous context
|
|
43691
43858
|
const quad = this._factory.quad(this._subject, this._predicate, this._object,
|
|
43692
|
-
|
|
43693
|
-
this._restoreContext('<<', token);
|
|
43859
|
+
this._graph || this.DEFAULTGRAPH);
|
|
43860
|
+
this._restoreContext('<<(', token);
|
|
43861
|
+
|
|
43694
43862
|
// If the triple was the subject, continue by reading the predicate.
|
|
43695
43863
|
if (this._subject === null) {
|
|
43696
43864
|
this._subject = quad;
|
|
@@ -43703,6 +43871,78 @@ class N3Parser {
|
|
|
43703
43871
|
}
|
|
43704
43872
|
}
|
|
43705
43873
|
|
|
43874
|
+
// ### `_readReifiedTripleTailOrReifier` reads a reifier or the end of a nested reified triple
|
|
43875
|
+
_readReifiedTripleTailOrReifier(token) {
|
|
43876
|
+
if (token.type === '~') {
|
|
43877
|
+
return this._readReifier;
|
|
43878
|
+
}
|
|
43879
|
+
return this._readReifiedTripleTail(token);
|
|
43880
|
+
}
|
|
43881
|
+
|
|
43882
|
+
// ### `_readReifiedTripleTail` reads the end of a nested reified triple
|
|
43883
|
+
_readReifiedTripleTail(token) {
|
|
43884
|
+
if (token.type !== '>>')
|
|
43885
|
+
return this._error(`Expected >> but got ${token.type}`, token);
|
|
43886
|
+
// Read the triple term and restore the previous context
|
|
43887
|
+
this._tripleTerm = null;
|
|
43888
|
+
const reifier = this._readTripleTerm();
|
|
43889
|
+
this._restoreContext('<<', token);
|
|
43890
|
+
|
|
43891
|
+
// // If we're in a list, continue processing that list
|
|
43892
|
+
const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];
|
|
43893
|
+
if (parent && parent.type === 'list') {
|
|
43894
|
+
this._emit(this._subject, this.RDF_FIRST, reifier, this._graph);
|
|
43895
|
+
return this._getContextEndReader();
|
|
43896
|
+
}
|
|
43897
|
+
// If the triple was the subject, continue by reading the predicate.
|
|
43898
|
+
else if (this._subject === null) {
|
|
43899
|
+
this._subject = reifier;
|
|
43900
|
+
return this._readPredicateOrReifierTripleEnd;
|
|
43901
|
+
}
|
|
43902
|
+
// If the triple was the object, read context end.
|
|
43903
|
+
else {
|
|
43904
|
+
this._object = reifier;
|
|
43905
|
+
return this._getContextEndReader();
|
|
43906
|
+
}
|
|
43907
|
+
}
|
|
43908
|
+
|
|
43909
|
+
_readPredicateOrReifierTripleEnd(token) {
|
|
43910
|
+
if (token.type === '.') {
|
|
43911
|
+
this._subject = null;
|
|
43912
|
+
return this._readPunctuation(token);
|
|
43913
|
+
}
|
|
43914
|
+
return this._readPredicate(token);
|
|
43915
|
+
}
|
|
43916
|
+
|
|
43917
|
+
// ### `_readReifier` reads the triple term identifier after a tilde when in a reifying triple.
|
|
43918
|
+
_readReifier(token) {
|
|
43919
|
+
this._reifier = this._readEntity(token);
|
|
43920
|
+
return this._readReifiedTripleTail;
|
|
43921
|
+
}
|
|
43922
|
+
|
|
43923
|
+
// ### `_readReifier` reads the optional triple term identifier after a tilde when in annotation syntax.
|
|
43924
|
+
_readReifierInAnnotation(token) {
|
|
43925
|
+
// If next token is a reifier, read it as such.
|
|
43926
|
+
if (token.type === 'IRI' || token.type === 'typeIRI' || token.type === 'type' || token.type === 'prefixed' || token.type === 'blank' || token.type === 'var') {
|
|
43927
|
+
this._reifier = this._readEntity(token);
|
|
43928
|
+
return this._readPunctuation;
|
|
43929
|
+
}
|
|
43930
|
+
// Otherwise, emit and assert triple term.
|
|
43931
|
+
this._readTripleTerm();
|
|
43932
|
+
this._subject = null;
|
|
43933
|
+
return this._readPunctuation(token);
|
|
43934
|
+
}
|
|
43935
|
+
|
|
43936
|
+
_readTripleTerm() {
|
|
43937
|
+
const stack = this._contextStack, parent = stack.length && stack[stack.length - 1];
|
|
43938
|
+
const parentGraph = parent ? parent.graph : undefined;
|
|
43939
|
+
const reifier = this._reifier || this._factory.blankNode();
|
|
43940
|
+
this._reifier = null;
|
|
43941
|
+
this._tripleTerm = this._tripleTerm || this._factory.quad(this._subject, this._predicate, this._object);
|
|
43942
|
+
this._emit(reifier, this.RDF_REIFIES, this._tripleTerm, parentGraph || this.DEFAULTGRAPH);
|
|
43943
|
+
return reifier;
|
|
43944
|
+
}
|
|
43945
|
+
|
|
43706
43946
|
// ### `_getContextEndReader` gets the next reader function at the end of a context
|
|
43707
43947
|
_getContextEndReader() {
|
|
43708
43948
|
const contextStack = this._contextStack;
|
|
@@ -43716,8 +43956,10 @@ class N3Parser {
|
|
|
43716
43956
|
return this._readListItem;
|
|
43717
43957
|
case 'formula':
|
|
43718
43958
|
return this._readFormulaTail;
|
|
43959
|
+
case '<<(':
|
|
43960
|
+
return this._readTripleTermTail;
|
|
43719
43961
|
case '<<':
|
|
43720
|
-
return this.
|
|
43962
|
+
return this._readReifiedTripleTailOrReifier;
|
|
43721
43963
|
}
|
|
43722
43964
|
}
|
|
43723
43965
|
|
|
@@ -43832,27 +44074,30 @@ class N3Parser {
|
|
|
43832
44074
|
// ## Public methods
|
|
43833
44075
|
|
|
43834
44076
|
// ### `parse` parses the N3 input and emits each parsed quad through the onQuad callback.
|
|
43835
|
-
parse(input, quadCallback, prefixCallback) {
|
|
44077
|
+
parse(input, quadCallback, prefixCallback, versionCallback) {
|
|
43836
44078
|
// The second parameter accepts an object { onQuad: ..., onPrefix: ..., onComment: ...}
|
|
43837
44079
|
// As a second and third parameter it still accepts a separate quadCallback and prefixCallback for backward compatibility as well
|
|
43838
|
-
let onQuad, onPrefix, onComment;
|
|
43839
|
-
if (quadCallback && (quadCallback.onQuad || quadCallback.onPrefix || quadCallback.onComment)) {
|
|
44080
|
+
let onQuad, onPrefix, onComment, onVersion;
|
|
44081
|
+
if (quadCallback && (quadCallback.onQuad || quadCallback.onPrefix || quadCallback.onComment || quadCallback.onVersion)) {
|
|
43840
44082
|
onQuad = quadCallback.onQuad;
|
|
43841
44083
|
onPrefix = quadCallback.onPrefix;
|
|
43842
44084
|
onComment = quadCallback.onComment;
|
|
44085
|
+
onVersion = quadCallback.onVersion;
|
|
43843
44086
|
}
|
|
43844
44087
|
else {
|
|
43845
44088
|
onQuad = quadCallback;
|
|
43846
44089
|
onPrefix = prefixCallback;
|
|
44090
|
+
onVersion = versionCallback;
|
|
43847
44091
|
}
|
|
43848
44092
|
// The read callback is the next function to be executed when a token arrives.
|
|
43849
44093
|
// We start reading in the top context.
|
|
43850
|
-
this._readCallback = this.
|
|
44094
|
+
this._readCallback = this._readBeforeTopContext;
|
|
43851
44095
|
this._sparqlStyle = false;
|
|
43852
44096
|
this._prefixes = Object.create(null);
|
|
43853
44097
|
this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2)
|
|
43854
44098
|
: `b${blankNodePrefix++}_`;
|
|
43855
44099
|
this._prefixCallback = onPrefix || noop;
|
|
44100
|
+
this._versionCallback = onVersion || noop;
|
|
43856
44101
|
this._inversePredicate = false;
|
|
43857
44102
|
this._quantified = Object.create(null);
|
|
43858
44103
|
|
|
@@ -43908,11 +44153,12 @@ function initDataFactory(parser, factory) {
|
|
|
43908
44153
|
parser.DEFAULTGRAPH = factory.defaultGraph();
|
|
43909
44154
|
|
|
43910
44155
|
// Set common named nodes
|
|
43911
|
-
parser.RDF_FIRST
|
|
43912
|
-
parser.RDF_REST
|
|
43913
|
-
parser.RDF_NIL
|
|
43914
|
-
parser.
|
|
43915
|
-
parser.
|
|
44156
|
+
parser.RDF_FIRST = factory.namedNode(IRIs.rdf.first);
|
|
44157
|
+
parser.RDF_REST = factory.namedNode(IRIs.rdf.rest);
|
|
44158
|
+
parser.RDF_NIL = factory.namedNode(IRIs.rdf.nil);
|
|
44159
|
+
parser.RDF_REIFIES = factory.namedNode(IRIs.rdf.reifies);
|
|
44160
|
+
parser.N3_FORALL = factory.namedNode(IRIs.r.forAll);
|
|
44161
|
+
parser.N3_FORSOME = factory.namedNode(IRIs.r.forSome);
|
|
43916
44162
|
parser.ABBREVIATIONS = {
|
|
43917
44163
|
'a': factory.namedNode(IRIs.rdf.type),
|
|
43918
44164
|
'=': factory.namedNode(IRIs.owl.sameAs),
|
|
@@ -43921,6 +44167,11 @@ function initDataFactory(parser, factory) {
|
|
|
43921
44167
|
};
|
|
43922
44168
|
parser.QUANTIFIERS_GRAPH = factory.namedNode('urn:n3:quantifiers');
|
|
43923
44169
|
}
|
|
44170
|
+
N3Parser.SUPPORTED_VERSIONS = [
|
|
44171
|
+
'1.2',
|
|
44172
|
+
'1.2-basic',
|
|
44173
|
+
'1.1',
|
|
44174
|
+
];
|
|
43924
44175
|
initDataFactory(N3Parser.prototype, N3DataFactory);
|
|
43925
44176
|
|
|
43926
44177
|
;// ./node_modules/n3/src/N3Util.js
|
|
@@ -44280,8 +44531,9 @@ class N3Writer {
|
|
|
44280
44531
|
value = value.replace(escapeAll, characterReplacer);
|
|
44281
44532
|
|
|
44282
44533
|
// Write a language-tagged literal
|
|
44534
|
+
const direction = literal.direction ? `--${literal.direction}` : '';
|
|
44283
44535
|
if (literal.language)
|
|
44284
|
-
return `"${value}"@${literal.language}`;
|
|
44536
|
+
return `"${value}"@${literal.language}${direction}`;
|
|
44285
44537
|
|
|
44286
44538
|
// Write dedicated literals per data type
|
|
44287
44539
|
if (this._lineMode) {
|
|
@@ -44336,11 +44588,11 @@ class N3Writer {
|
|
|
44336
44588
|
|
|
44337
44589
|
// ### `_encodeQuad` encodes an RDF-star quad
|
|
44338
44590
|
_encodeQuad({ subject, predicate, object, graph }) {
|
|
44339
|
-
return
|
|
44591
|
+
return `<<(${
|
|
44340
44592
|
this._encodeSubject(subject)} ${
|
|
44341
44593
|
this._encodePredicate(predicate)} ${
|
|
44342
44594
|
this._encodeObject(object)}${
|
|
44343
|
-
N3Util_isDefaultGraph(graph) ? '' : ` ${this._encodeIriOrBlank(graph)}`}>>`;
|
|
44595
|
+
N3Util_isDefaultGraph(graph) ? '' : ` ${this._encodeIriOrBlank(graph)}`})>>`;
|
|
44344
44596
|
}
|
|
44345
44597
|
|
|
44346
44598
|
// ### `_blockedWrite` replaces `_write` after the writer has been closed
|
|
@@ -114365,37 +114617,37 @@ var dist = __webpack_require__(7523);
|
|
|
114365
114617
|
var solid_logic_esm = __webpack_require__(9332);
|
|
114366
114618
|
;// ./src/versionInfo.ts
|
|
114367
114619
|
/* harmony default export */ const versionInfo = ({
|
|
114368
|
-
buildTime: '2026-03-
|
|
114369
|
-
commit: '
|
|
114620
|
+
buildTime: '2026-03-23T09:47:01Z',
|
|
114621
|
+
commit: '65d8af17cf24ef9d2711e935fc11e5c9c657e11f',
|
|
114370
114622
|
npmInfo: {
|
|
114371
114623
|
'mashlib': '2.1.3',
|
|
114372
114624
|
'npm': '10.9.4',
|
|
114373
|
-
'node': '22.22.
|
|
114625
|
+
'node': '22.22.1',
|
|
114374
114626
|
'acorn': '8.15.0',
|
|
114375
114627
|
'ada': '2.9.2',
|
|
114376
|
-
'amaro': '1.1.
|
|
114628
|
+
'amaro': '1.1.5',
|
|
114377
114629
|
'ares': '1.34.6',
|
|
114378
114630
|
'brotli': '1.1.0',
|
|
114379
|
-
'cjs_module_lexer': '2.
|
|
114380
|
-
'cldr': '
|
|
114381
|
-
'icu': '
|
|
114631
|
+
'cjs_module_lexer': '2.2.0',
|
|
114632
|
+
'cldr': '48.0',
|
|
114633
|
+
'icu': '78.2',
|
|
114382
114634
|
'llhttp': '9.3.0',
|
|
114383
114635
|
'modules': '127',
|
|
114384
114636
|
'napi': '10',
|
|
114385
114637
|
'nbytes': '0.1.1',
|
|
114386
114638
|
'ncrypto': '0.0.1',
|
|
114387
114639
|
'nghttp2': '1.64.0',
|
|
114388
|
-
'openssl': '3.5.
|
|
114389
|
-
'simdjson': '
|
|
114640
|
+
'openssl': '3.5.5',
|
|
114641
|
+
'simdjson': '4.2.4',
|
|
114390
114642
|
'simdutf': '6.4.2',
|
|
114391
|
-
'sqlite': '3.
|
|
114392
|
-
'tz': '
|
|
114643
|
+
'sqlite': '3.51.2',
|
|
114644
|
+
'tz': '2025c',
|
|
114393
114645
|
'undici': '6.23.0',
|
|
114394
|
-
'unicode': '
|
|
114646
|
+
'unicode': '17.0',
|
|
114395
114647
|
'uv': '1.51.0',
|
|
114396
114648
|
'uvwasi': '0.0.23',
|
|
114397
|
-
'v8': '12.4.254.21-node.
|
|
114398
|
-
'zlib': '1.3.1-
|
|
114649
|
+
'v8': '12.4.254.21-node.35',
|
|
114650
|
+
'zlib': '1.3.1-e00f703',
|
|
114399
114651
|
'zstd': '1.5.7'
|
|
114400
114652
|
}
|
|
114401
114653
|
});
|