mashlib 1.11.1-7aefc817 → 1.11.1-8dfefc14

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/mashlib.js CHANGED
@@ -58985,7 +58985,9 @@ class XHTMLHandler extends Handler {
58985
58985
  return 'XHTMLHandler';
58986
58986
  }
58987
58987
  static register(fetcher) {
58988
- fetcher.mediatypes[_types__WEBPACK_IMPORTED_MODULE_14__.XHTMLContentType] = {};
58988
+ fetcher.mediatypes[_types__WEBPACK_IMPORTED_MODULE_14__.XHTMLContentType] = {
58989
+ 'q': 0.8
58990
+ };
58989
58991
  }
58990
58992
  parse(fetcher, responseText, options) {
58991
58993
  let relation, reverse;
@@ -59118,7 +59120,7 @@ class HTMLHandler extends Handler {
59118
59120
  }
59119
59121
  static register(fetcher) {
59120
59122
  fetcher.mediatypes['text/html'] = {
59121
- 'q': 0.9
59123
+ 'q': 0.8
59122
59124
  };
59123
59125
  }
59124
59126
  parse(fetcher, responseText, options) {
@@ -59167,21 +59169,19 @@ class JsonLdHandler extends Handler {
59167
59169
  'q': 0.9
59168
59170
  };
59169
59171
  }
59170
- parse(fetcher, responseText, options, response) {
59172
+ async parse(fetcher, responseText, options, response) {
59171
59173
  const kb = fetcher.store;
59172
- return new Promise((resolve, reject) => {
59173
- try {
59174
- (0,_jsonldparser__WEBPACK_IMPORTED_MODULE_16__["default"])(responseText, kb, options.original.value, () => {
59175
- resolve(fetcher.doneFetch(options, response));
59176
- });
59177
- } catch (err) {
59178
- const msg = 'Error trying to parse ' + options.resource + ' as JSON-LD:\n' + err; // not err.stack -- irrelevant
59179
- resolve(fetcher.failFetch(options, msg, 'parse_error', response));
59180
- }
59181
- });
59174
+ try {
59175
+ await (0,_jsonldparser__WEBPACK_IMPORTED_MODULE_16__["default"])(responseText, kb, options.original.value);
59176
+ fetcher.store.add(options.original, ns.rdf('type'), ns.link('RDFDocument'), fetcher.appNode);
59177
+ return fetcher.doneFetch(options, response);
59178
+ } catch (err) {
59179
+ const msg = 'Error trying to parse ' + options.resource + ' as JSON-LD:\n' + err; // not err.stack -- irrelevant
59180
+ return fetcher.failFetch(options, msg, 'parse_error', response);
59181
+ }
59182
59182
  }
59183
59183
  }
59184
- JsonLdHandler.pattern = /application\/ld\+json/;
59184
+ JsonLdHandler.pattern = /application\/(ld\+json|activity\+json)/;
59185
59185
  class TextHandler extends Handler {
59186
59186
  static toString() {
59187
59187
  return 'TextHandler';
@@ -59219,17 +59219,8 @@ class N3Handler extends Handler {
59219
59219
  return 'N3Handler';
59220
59220
  }
59221
59221
  static register(fetcher) {
59222
- fetcher.mediatypes['text/n3'] = {
59223
- 'q': '1.0'
59224
- }; // as per 2008 spec
59225
- /*
59226
- fetcher.mediatypes['application/x-turtle'] = {
59227
- 'q': 1.0
59228
- } // pre 2008
59229
- */
59230
- fetcher.mediatypes['text/turtle'] = {
59231
- 'q': 1.0
59232
- }; // post 2008
59222
+ fetcher.mediatypes['text/n3'] = {};
59223
+ fetcher.mediatypes['text/turtle'] = {};
59233
59224
  }
59234
59225
  parse(fetcher, responseText, options, response) {
59235
59226
  // Parse the text of this N3 file
@@ -59579,7 +59570,7 @@ class Fetcher {
59579
59570
  options.baseURI = options.baseURI || uri; // Preserve though proxying etc
59580
59571
  options.original = kb.rdfFactory.namedNode(options.baseURI);
59581
59572
  options.req = kb.bnode();
59582
- options.headers = options.headers || new cross_fetch__WEBPACK_IMPORTED_MODULE_13__.Headers();
59573
+ options.headers = options.headers || {};
59583
59574
  if (options.contentType) {
59584
59575
  // @ts-ignore
59585
59576
  options.headers['content-type'] = options.contentType;
@@ -61565,16 +61556,15 @@ function listToCollection(kb, obj) {
61565
61556
  *
61566
61557
  * Ensure that {kb.rdfFactory} is a DataFactory.
61567
61558
  */
61568
- function jsonldParser(str, kb, base, callback) {
61559
+ async function jsonldParser(str, kb, base) {
61569
61560
  const baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
61570
- return Promise.all(/*! import() */[__webpack_require__.e("vendors-node_modules_jsonld_lib_jsonld_js"), __webpack_require__.e("_2b19")]).then(__webpack_require__.t.bind(__webpack_require__, /*! jsonld */ "./node_modules/jsonld/lib/jsonld.js", 23)).then(jsonld => {
61571
- return jsonld.flatten(JSON.parse(str), null, {
61572
- base: baseString
61573
- });
61574
- }).then(flattened => flattened.reduce((store, flatResource) => {
61575
- kb = processResource(kb, base, flatResource);
61576
- return kb;
61577
- }, kb)).then(callback).catch(callback);
61561
+ const jsonld = await Promise.all(/*! import() */[__webpack_require__.e("vendors-node_modules_jsonld_lib_jsonld_js"), __webpack_require__.e("_2b19")]).then(__webpack_require__.t.bind(__webpack_require__, /*! jsonld */ "./node_modules/jsonld/lib/jsonld.js", 23));
61562
+ // ⚠ Unit tests also work without accessing `jsonld.default` explicitly, but real browser usage will fail with
61563
+ // just calling `jsonld.flatten`, so please do not remove `default`
61564
+ const flattened = await jsonld.default.flatten(JSON.parse(str), null, {
61565
+ base: baseString
61566
+ });
61567
+ return flattened.reduce((store, flatResource) => processResource(store, base, flatResource), kb);
61578
61568
  }
61579
61569
  function nodeType(kb, obj) {
61580
61570
  if (obj['@id'].startsWith('_:')) {
@@ -63900,7 +63890,7 @@ __webpack_require__.r(__webpack_exports__);
63900
63890
  * Parse a string and put the result into the graph kb.
63901
63891
  * Normal method is sync.
63902
63892
  * Unfortunately jsdonld is currently written to need to be called async.
63903
- * Hence the mess below with executeCallback.
63893
+ * If you are parsing JSON-LD and want to know when and whether it succeeded, you need to use the callback param.
63904
63894
  * @param str - The input string to parse
63905
63895
  * @param kb - The store to use
63906
63896
  * @param base - The base URI to use
@@ -63936,7 +63926,10 @@ function parse(str, kb, base) {
63936
63926
  (0,_patch_parser__WEBPACK_IMPORTED_MODULE_6__["default"])(str, kb, base);
63937
63927
  executeCallback();
63938
63928
  } else if (contentType === _types__WEBPACK_IMPORTED_MODULE_8__.JSONLDContentType) {
63939
- (0,_jsonldparser__WEBPACK_IMPORTED_MODULE_1__["default"])(str, kb, base, executeCallback);
63929
+ // since we do not await the promise here, rejections will not be covered by the surrounding try catch
63930
+ // we do not use await, because parse() should stay sync
63931
+ // so, to not lose the async error, we need to catch the rejection and call the error callback here too
63932
+ (0,_jsonldparser__WEBPACK_IMPORTED_MODULE_1__["default"])(str, kb, base).then(executeCallback).catch(executeErrorCallback);
63940
63933
  } else if (contentType === _types__WEBPACK_IMPORTED_MODULE_8__.NQuadsContentType || contentType === _types__WEBPACK_IMPORTED_MODULE_8__.NQuadsAltContentType) {
63941
63934
  var n3Parser = new n3__WEBPACK_IMPORTED_MODULE_2__["default"]({
63942
63935
  factory: _factories_extended_term_factory__WEBPACK_IMPORTED_MODULE_0__["default"]
@@ -68125,7 +68118,9 @@ class IndexedFormula extends _formula__WEBPACK_IMPORTED_MODULE_3__["default"] {
68125
68118
  /** Function to remove quads from the store arrays with */
68126
68119
  (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "rdfArrayRemove", void 0);
68127
68120
  /** Callbacks which are triggered after a statement has been added to the store */
68128
- (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "dataCallbacks", void 0);
68121
+ (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "dataCallbacks", []);
68122
+ /** Callbacks which are triggered after a statement has been removed from the store */
68123
+ (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "dataRemovalCallbacks", []);
68129
68124
  this.propertyActions = {};
68130
68125
  this.classActions = {};
68131
68126
  this.redirections = [];
@@ -68147,6 +68142,9 @@ class IndexedFormula extends _formula__WEBPACK_IMPORTED_MODULE_3__["default"] {
68147
68142
  if (opts.dataCallback) {
68148
68143
  this.dataCallbacks = [opts.dataCallback];
68149
68144
  }
68145
+ if (opts.dataRemovalCallback) {
68146
+ this.dataRemovalCallbacks = [opts.dataRemovalCallback];
68147
+ }
68150
68148
  this.initPropertyActions(this.features);
68151
68149
  }
68152
68150
 
@@ -68175,11 +68173,11 @@ class IndexedFormula extends _formula__WEBPACK_IMPORTED_MODULE_3__["default"] {
68175
68173
  * @param cb
68176
68174
  */
68177
68175
  addDataCallback(cb) {
68178
- if (!this.dataCallbacks) {
68179
- this.dataCallbacks = [];
68180
- }
68181
68176
  this.dataCallbacks.push(cb);
68182
68177
  }
68178
+ addDataRemovalCallback(cb) {
68179
+ this.dataRemovalCallbacks.push(cb);
68180
+ }
68183
68181
 
68184
68182
  /**
68185
68183
  * Apply a set of statements to be deleted and to be inserted
@@ -68393,10 +68391,8 @@ class IndexedFormula extends _formula__WEBPACK_IMPORTED_MODULE_3__["default"] {
68393
68391
 
68394
68392
  // log.debug("ADDING {"+subj+" "+pred+" "+objNode+"} "+why)
68395
68393
  this.statements.push(st);
68396
- if (this.dataCallbacks) {
68397
- for (const callback of this.dataCallbacks) {
68398
- callback(st);
68399
- }
68394
+ for (const callback of this.dataCallbacks) {
68395
+ callback(st);
68400
68396
  }
68401
68397
  return st;
68402
68398
  }
@@ -68846,6 +68842,9 @@ class IndexedFormula extends _formula__WEBPACK_IMPORTED_MODULE_3__["default"] {
68846
68842
  }
68847
68843
  }
68848
68844
  this.rdfArrayRemove(this.statements, st);
68845
+ for (const callback of this.dataRemovalCallbacks) {
68846
+ callback(st);
68847
+ }
68849
68848
  return this;
68850
68849
  }
68851
68850
 
@@ -139812,7 +139811,7 @@ __webpack_require__.r(__webpack_exports__);
139812
139811
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
139813
139812
  /* harmony export */ mashStyle: () => (/* binding */ mashStyle)
139814
139813
  /* harmony export */ });
139815
- var mashStyle = {
139814
+ const mashStyle = {
139816
139815
  dbLayout: 'display: flex; flex-direction: column;',
139817
139816
  dbLayoutContent: 'flex: 1 0 auto;',
139818
139817
  dbLayoutHeader: 'flex-shrink: 0;',
@@ -139836,8 +139835,8 @@ __webpack_require__.r(__webpack_exports__);
139836
139835
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
139837
139836
  /* harmony export */ });
139838
139837
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
139839
- buildTime: "2025-09-24T08:56:25Z",
139840
- commit: "7aefc8171296b74ea4e2b8e2f6da0694fa25df2f",
139838
+ buildTime: "2025-11-19T12:00:38Z",
139839
+ commit: "8dfefc14a6c833174356889a4d756090e5671f8d",
139841
139840
  npmInfo: {
139842
139841
  "mashlib": "'1.11.1',",
139843
139842
  "npm": "'10.8.2',",
@@ -140038,7 +140037,6 @@ __webpack_require__.r(__webpack_exports__);
140038
140037
  /******/ script = document.createElement('script');
140039
140038
  /******/
140040
140039
  /******/ script.charset = 'utf-8';
140041
- /******/ script.timeout = 120;
140042
140040
  /******/ if (__webpack_require__.nc) {
140043
140041
  /******/ script.setAttribute("nonce", __webpack_require__.nc);
140044
140042
  /******/ }
@@ -140204,7 +140202,7 @@ __webpack_require__.r(__webpack_exports__);
140204
140202
 
140205
140203
 
140206
140204
 
140207
- var global = window;
140205
+ const global = window;
140208
140206
  global.$rdf = rdflib__WEBPACK_IMPORTED_MODULE_0__;
140209
140207
  global.panes = solid_panes__WEBPACK_IMPORTED_MODULE_2__;
140210
140208
  global.mashlib = {
@@ -140218,14 +140216,14 @@ global.panes.runDataBrowser = function (uri) {
140218
140216
  (_document$getElementB4 = document.getElementById('DummyUUID')) === null || _document$getElementB4 === void 0 || _document$getElementB4.setAttribute('style', _styles_mashlib_style_js__WEBPACK_IMPORTED_MODULE_5__.mashStyle.dbLayoutContent);
140219
140217
 
140220
140218
  // Set up cross-site proxy
140221
- var fetcher = rdflib__WEBPACK_IMPORTED_MODULE_1__["default"];
140219
+ const fetcher = rdflib__WEBPACK_IMPORTED_MODULE_1__["default"];
140222
140220
  fetcher.crossSiteProxyTemplate = window.origin + '/xss/?uri={uri}';
140223
140221
 
140224
140222
  // Add web monetization tag to page header
140225
140223
  try {
140226
- var webMonetizationTag = document.createElement('meta');
140224
+ const webMonetizationTag = document.createElement('meta');
140227
140225
  webMonetizationTag.setAttribute('name', 'monetization');
140228
- webMonetizationTag.setAttribute('content', "$".concat(window.location.host));
140226
+ webMonetizationTag.setAttribute('content', `$${window.location.host}`);
140229
140227
  document.head.appendChild(webMonetizationTag);
140230
140228
  } catch (e) {
140231
140229
  console.error('Failed to add web monetization tag to page header');
@@ -140233,7 +140231,7 @@ global.panes.runDataBrowser = function (uri) {
140233
140231
 
140234
140232
  // Authenticate the user
140235
140233
  solid_logic__WEBPACK_IMPORTED_MODULE_3__.authn.checkUser().then(function (_profile) {
140236
- var mainPage = solid_panes__WEBPACK_IMPORTED_MODULE_2__.initMainPage(solid_logic__WEBPACK_IMPORTED_MODULE_3__.solidLogicSingleton.store, uri);
140234
+ const mainPage = solid_panes__WEBPACK_IMPORTED_MODULE_2__.initMainPage(solid_logic__WEBPACK_IMPORTED_MODULE_3__.solidLogicSingleton.store, uri);
140237
140235
  return mainPage;
140238
140236
  });
140239
140237
  };