rdflib 2.3.6 → 2.3.7

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/esm/rdfaparser.js CHANGED
@@ -265,8 +265,8 @@ export default class RDFaProcessor {
265
265
  var queue = [];
266
266
  // Fix for Firefox that includes the hash in the base URI
267
267
  var removeHash = function (baseURI) {
268
- // Fix for undefined baseURI property
269
- if (!baseURI && options && options.baseURI) {
268
+ // xmldom 0.9 defaults XMLDocument.baseURI to about:blank, which is not a useful document base.
269
+ if ((!baseURI || baseURI === 'about:blank') && options && options.baseURI) {
270
270
  return options.baseURI;
271
271
  }
272
272
  var hash = baseURI.indexOf('#');
@@ -206,7 +206,7 @@ export default class RDFParser {
206
206
 
207
207
  /**
208
208
  * Build our initial scope frame and parse the DOM into triples
209
- * @param {HTMLDocument} document The DOM to parse
209
+ * @param {import('@xmldom/xmldom').Document} document The DOM to parse
210
210
  * @param {String} base The base URL to use
211
211
  * @param {Object} why The context to which this resource belongs
212
212
  */
package/esm/utils-js.js CHANGED
@@ -226,6 +226,7 @@ import { DOMParser } from '@xmldom/xmldom';
226
226
 
227
227
  /**
228
228
  * Returns a DOM from parsed XML.
229
+ * @returns {Document}
229
230
  */
230
231
  export function parseXML(str, options) {
231
232
  var dparser;
package/lib/fetcher.d.ts CHANGED
@@ -25,6 +25,7 @@
25
25
  */
26
26
  import IndexedFormula from './store';
27
27
  import RDFlibNamedNode from './named-node';
28
+ import type { Document as XmldomDocument } from '@xmldom/xmldom';
28
29
  import { ContentType } from './types';
29
30
  import { BlankNode, Quad_Graph, NamedNode, Quad_Predicate, Quad_Subject } from './tf-types';
30
31
  export interface FetchError extends Error {
@@ -113,9 +114,9 @@ export interface AutoInitOptions extends RequestInit {
113
114
  }
114
115
  declare class Handler {
115
116
  response: ExtendedResponse;
116
- dom: Document;
117
+ dom: XmldomDocument;
117
118
  static pattern: RegExp;
118
- constructor(response: ExtendedResponse, dom?: Document);
119
+ constructor(response: ExtendedResponse, dom?: XmldomDocument);
119
120
  }
120
121
  type StatusValues =
121
122
  /** No record of web access or record reset */
package/lib/rdfaparser.js CHANGED
@@ -273,8 +273,8 @@ class RDFaProcessor {
273
273
  var queue = [];
274
274
  // Fix for Firefox that includes the hash in the base URI
275
275
  var removeHash = function (baseURI) {
276
- // Fix for undefined baseURI property
277
- if (!baseURI && options && options.baseURI) {
276
+ // xmldom 0.9 defaults XMLDocument.baseURI to about:blank, which is not a useful document base.
277
+ if ((!baseURI || baseURI === 'about:blank') && options && options.baseURI) {
278
278
  return options.baseURI;
279
279
  }
280
280
  var hash = baseURI.indexOf('#');
@@ -40,11 +40,11 @@ export default class RDFParser {
40
40
  getAttributeNodeNS(node: any, uri: any, name: any): any;
41
41
  /**
42
42
  * Build our initial scope frame and parse the DOM into triples
43
- * @param {HTMLDocument} document The DOM to parse
43
+ * @param {import('@xmldom/xmldom').Document} document The DOM to parse
44
44
  * @param {String} base The base URL to use
45
45
  * @param {Object} why The context to which this resource belongs
46
46
  */
47
- parse(document: HTMLDocument, base: string, why: any): boolean;
47
+ parse(document: import("@xmldom/xmldom").Document, base: string, why: any): boolean;
48
48
  base: string | undefined;
49
49
  parseDOM(frame: any): void;
50
50
  /**
@@ -215,7 +215,7 @@ class RDFParser {
215
215
 
216
216
  /**
217
217
  * Build our initial scope frame and parse the DOM into triples
218
- * @param {HTMLDocument} document The DOM to parse
218
+ * @param {import('@xmldom/xmldom').Document} document The DOM to parse
219
219
  * @param {String} base The base URL to use
220
220
  * @param {Object} why The context to which this resource belongs
221
221
  */
package/lib/utils-js.d.ts CHANGED
@@ -29,6 +29,7 @@ export function heavyCompareSPO(x: any, y: any, g: any, uriMap: any): any;
29
29
  export function output(o: string): void;
30
30
  /**
31
31
  * Returns a DOM from parsed XML.
32
+ * @returns {Document}
32
33
  */
33
34
  export function parseXML(str: any, options: any): Document;
34
35
  /**
package/lib/utils-js.js CHANGED
@@ -255,6 +255,7 @@ function output(o) {
255
255
  }
256
256
  /**
257
257
  * Returns a DOM from parsed XML.
258
+ * @returns {Document}
258
259
  */
259
260
  function parseXML(str, options) {
260
261
  var dparser;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rdflib",
3
3
  "description": "an RDF library for node.js. Suitable for client and server side.",
4
- "version": "2.3.6",
4
+ "version": "2.3.7",
5
5
  "private": false,
6
6
  "browserslist": [
7
7
  "> 0.5%"
@@ -44,13 +44,15 @@
44
44
  "homepage": "http://github.com/linkeddata/rdflib.js",
45
45
  "bugs": "http://github.com/linkeddata/rdflib.js/issues",
46
46
  "dependencies": {
47
- "@babel/runtime": "^7.28.6",
47
+ "@babel/runtime": "^7.29.2",
48
48
  "@frogcat/ttl2jsonld": "^0.0.10",
49
49
  "@rdfjs/types": "^2.0.1",
50
- "@xmldom/xmldom": "^0.8.11",
50
+ "@xmldom/xmldom": "^0.9.10",
51
51
  "cross-fetch": "^4.1.0",
52
52
  "jsonld": "^9.0.0",
53
53
  "n3": "^2.0.3",
54
+ "package-lock.json": "^1.0.0",
55
+ "package.json": "^2.0.1",
54
56
  "solid-namespace": "^0.5.4"
55
57
  },
56
58
  "devDependencies": {
@@ -58,37 +60,37 @@
58
60
  "@babel/core": "^7.29.0",
59
61
  "@babel/plugin-proposal-class-properties": "^7.18.6",
60
62
  "@babel/plugin-transform-runtime": "^7.29.0",
61
- "@babel/preset-env": "^7.29.0",
63
+ "@babel/preset-env": "^7.29.5",
62
64
  "@babel/preset-typescript": "^7.28.5",
63
- "@babel/register": "^7.28.6",
65
+ "@babel/register": "^7.29.3",
64
66
  "@types/chai": "^5.2.3",
65
67
  "@types/dirty-chai": "^2.0.5",
66
68
  "@types/express": "^5.0.6",
67
69
  "@types/jsonld": "^1.5.15",
68
70
  "@types/mocha": "^10.0.10",
69
- "@types/node": "^25.5.0",
71
+ "@types/node": "^25.8.0",
70
72
  "@types/sinon-chai": "^4.0.0",
71
73
  "babel-loader": "^10.1.1",
72
74
  "chai": "^6.2.2",
73
75
  "colors": "^1.4.0",
74
- "diff": "^8.0.3",
75
- "eslint": "^10.0.3",
76
- "globals": "^17.4.0",
76
+ "diff": "^8.0.4",
77
+ "eslint": "^10.3.0",
78
+ "globals": "^17.6.0",
77
79
  "locate-path": "^8.0.0",
78
80
  "mocha": "^11.7.5",
79
- "nock": "^14.0.11",
81
+ "nock": "^14.0.15",
80
82
  "node-fetch": "^3.3.2",
81
83
  "node-polyfill-webpack-plugin": "^4.1.0",
82
84
  "rimraf": "^6.1.3",
83
- "sinon": "^21.0.2",
85
+ "sinon": "^21.1.2",
84
86
  "sinon-chai": "^4.0.1",
85
87
  "source-map-loader": "^5.0.0",
86
88
  "ts-node": "^10.9.2",
87
- "typedoc": "^0.28.17",
89
+ "typedoc": "^0.28.19",
88
90
  "typescript": "^5.9.3",
89
- "webpack": "^5.105.4",
90
- "webpack-cli": "^7.0.0",
91
- "webpack-dev-server": "^5.2.3"
91
+ "webpack": "^5.106.2",
92
+ "webpack-cli": "^7.0.2",
93
+ "webpack-dev-server": "^5.2.4"
92
94
  },
93
95
  "scripts": {
94
96
  "build": "babel src --extensions \".ts,.js\" -d lib",
package/src/fetcher.ts CHANGED
@@ -38,6 +38,7 @@ import { isCollection, isNamedNode} from './utils/terms'
38
38
  import * as Util from './utils-js'
39
39
  import serialize from './serialize'
40
40
  import crossFetch, { Headers } from 'cross-fetch'
41
+ import type { Document as XmldomDocument, Element as XmldomElement, Node as XmldomNode } from '@xmldom/xmldom'
41
42
 
42
43
  import {
43
44
  ContentType, TurtleContentType, RDFXMLContentType, XHTMLContentType
@@ -199,10 +200,10 @@ class Handler {
199
200
  // TODO: Document, type
200
201
  response: ExtendedResponse
201
202
  // TODO: Document, type
202
- dom: Document
203
+ dom: XmldomDocument
203
204
  static pattern: RegExp
204
205
 
205
- constructor (response: ExtendedResponse, dom?: Document) {
206
+ constructor (response: ExtendedResponse, dom?: XmldomDocument) {
206
207
  this.response = response
207
208
  // The type assertion operator here might need to be removed.
208
209
  this.dom = dom!
@@ -232,7 +233,7 @@ class RDFXMLHandler extends Handler {
232
233
  ) {
233
234
  let kb = fetcher.store
234
235
  if (!this.dom) {
235
- this.dom = Util.parseXML(responseText)
236
+ this.dom = Util.parseXML(responseText) as unknown as XmldomDocument
236
237
  }
237
238
  let root = this.dom.documentElement
238
239
  if (root && root.nodeName === 'parsererror') { // Mozilla only See issue/issue110
@@ -277,7 +278,7 @@ class XHTMLHandler extends Handler {
277
278
  ): Promise<FetchError> | ExtendedResponse {
278
279
  let relation, reverse: boolean
279
280
  if (!this.dom) {
280
- this.dom = Util.parseXML(responseText)
281
+ this.dom = Util.parseXML(responseText) as unknown as XmldomDocument
281
282
  }
282
283
  let kb = fetcher.store
283
284
 
@@ -345,7 +346,7 @@ class XMLHandler extends Handler {
345
346
  fetcher.mediatypes['application/xml'] = { 'q': 0.5 }
346
347
  }
347
348
 
348
- static isElement(node: Node): node is Element {
349
+ static isElement(node: XmldomNode): node is XmldomElement {
349
350
  return node.nodeType === Node.ELEMENT_NODE;
350
351
  }
351
352
 
@@ -359,14 +360,14 @@ class XMLHandler extends Handler {
359
360
  resource: Quad_Subject
360
361
  } & Options,
361
362
  ): ExtendedResponse | Promise<FetchError> {
362
- let dom = Util.parseXML(responseText)
363
+ let dom = Util.parseXML(responseText) as unknown as XmldomDocument
363
364
 
364
365
  // XML Semantics defined by root element namespace
365
366
  // figure out the root element
366
367
  for (let c = 0; c < dom.childNodes.length; c++) {
367
368
  const node = dom.childNodes[c]
368
369
  // is this node an element?
369
- if (XMLHandler.isElement(node)) {
370
+ if (XMLHandler.isElement(node as XmldomNode)) {
370
371
 
371
372
  // We've found the first element, it's the root
372
373
  let ns = node.namespaceURI
package/src/parse.ts CHANGED
@@ -10,6 +10,7 @@ import * as Util from './utils-js'
10
10
  import Formula from './formula'
11
11
  import { ContentType, TurtleContentType, N3ContentType, RDFXMLContentType, XHTMLContentType, HTMLContentType, SPARQLUpdateContentType, SPARQLUpdateSingleMatchContentType, JSONLDContentType, NQuadsContentType, NQuadsAltContentType } from './types'
12
12
  import { Quad } from './tf-types'
13
+ import type { Document as XmldomDocument } from '@xmldom/xmldom'
13
14
 
14
15
  type CallbackFunc = (error: any, kb: Formula | null) => void
15
16
 
@@ -40,13 +41,13 @@ export default function parse (
40
41
  executeCallback()
41
42
  } else if (contentType === RDFXMLContentType) {
42
43
  var parser = new RDFParser(kb)
43
- parser.parse(Util.parseXML(str), base, kb.sym(base))
44
+ parser.parse(Util.parseXML(str) as unknown as XmldomDocument, base, kb.sym(base))
44
45
  executeCallback()
45
46
  } else if (contentType === XHTMLContentType) {
46
- parseRDFaDOM(Util.parseXML(str, {contentType: XHTMLContentType}), kb, base)
47
+ parseRDFaDOM(Util.parseXML(str, {contentType: XHTMLContentType}) as unknown as XmldomDocument, kb, base)
47
48
  executeCallback()
48
49
  } else if (contentType === HTMLContentType) {
49
- parseRDFaDOM(Util.parseXML(str, {contentType: HTMLContentType}), kb, base)
50
+ parseRDFaDOM(Util.parseXML(str, {contentType: HTMLContentType}) as unknown as XmldomDocument, kb, base)
50
51
  executeCallback()
51
52
  } else if ((contentType === SPARQLUpdateContentType) || (contentType === SPARQLUpdateSingleMatchContentType)) { // @@ we handle a subset
52
53
  sparqlUpdateParser(str, kb, base)
package/src/rdfaparser.js CHANGED
@@ -280,8 +280,8 @@ export default class RDFaProcessor {
280
280
  var queue = []
281
281
  // Fix for Firefox that includes the hash in the base URI
282
282
  var removeHash = function (baseURI) {
283
- // Fix for undefined baseURI property
284
- if (!baseURI && options && options.baseURI) {
283
+ // xmldom 0.9 defaults XMLDocument.baseURI to about:blank, which is not a useful document base.
284
+ if ((!baseURI || baseURI === 'about:blank') && options && options.baseURI) {
285
285
  return options.baseURI
286
286
  }
287
287
 
@@ -198,7 +198,7 @@ export default class RDFParser {
198
198
 
199
199
  /**
200
200
  * Build our initial scope frame and parse the DOM into triples
201
- * @param {HTMLDocument} document The DOM to parse
201
+ * @param {import('@xmldom/xmldom').Document} document The DOM to parse
202
202
  * @param {String} base The base URL to use
203
203
  * @param {Object} why The context to which this resource belongs
204
204
  */
package/src/utils-js.js CHANGED
@@ -249,6 +249,7 @@ import { DOMParser } from '@xmldom/xmldom'
249
249
 
250
250
  /**
251
251
  * Returns a DOM from parsed XML.
252
+ * @returns {Document}
252
253
  */
253
254
  export function parseXML (str, options) {
254
255
  var dparser