@muze-nl/jsfs-solid 0.1.7 → 0.1.8

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/browser.js CHANGED
@@ -8246,6 +8246,8 @@
8246
8246
  for (let option of options) {
8247
8247
  if (typeof option == "string" || option instanceof String) {
8248
8248
  this.clientOptions.url = url(this.clientOptions.url.href, option);
8249
+ } else if (option instanceof _Client) {
8250
+ Object.assign(this.clientOptions, option.clientOptions);
8249
8251
  } else if (option instanceof Function) {
8250
8252
  this.#addMiddlewares([option]);
8251
8253
  } else if (option && typeof option == "object") {
@@ -8841,7 +8843,7 @@
8841
8843
  async read(path) {
8842
8844
  let response2 = await this.#client.get(path);
8843
8845
  let result2 = {
8844
- type: this.#getMimetype(response2),
8846
+ type: this.getMimetype(response2),
8845
8847
  name: Path.filename(path),
8846
8848
  http: {
8847
8849
  headers: response2.headers,
@@ -8878,13 +8880,13 @@
8878
8880
  if (supportedContentTypes.includes(result2.type.split(";")[0])) {
8879
8881
  var html = result2.contents;
8880
8882
  } else {
8881
- let url2 = this.#getUrl(path);
8883
+ let url2 = this.getUrl(path);
8882
8884
  throw new TypeError("URL " + url2 + " is not of a supported content type", {
8883
8885
  cause: result2
8884
8886
  });
8885
8887
  }
8886
8888
  let basePath = url(this.#client.clientOptions.url).pathname;
8887
- let parentUrl = this.#getUrl(path);
8889
+ let parentUrl = this.getUrl(path);
8888
8890
  let dom = document.createElement("template");
8889
8891
  dom.innerHTML = html;
8890
8892
  let links = dom.content.querySelectorAll("a[href]");
@@ -8910,12 +8912,12 @@
8910
8912
  };
8911
8913
  });
8912
8914
  }
8913
- #getUrl(path) {
8915
+ getUrl(path) {
8914
8916
  let basePath = url(this.#client.clientOptions.url).pathname;
8915
8917
  path = Path.collapse(basePath + Path.collapse(path));
8916
8918
  return new URL(path, this.#client.clientOptions.url);
8917
8919
  }
8918
- #getMimetype(response2) {
8920
+ getMimetype(response2) {
8919
8921
  if (response2.headers.has("Content-Type")) {
8920
8922
  return response2.headers.get("Content-Type");
8921
8923
  } else {
@@ -8991,7 +8993,7 @@
8991
8993
  }
8992
8994
  }
8993
8995
  let res = await next(req);
8994
- if (isJSON(res.headers.get("Content-Type"))) {
8996
+ if (res && isJSON(res.headers?.get("Content-Type"))) {
8995
8997
  let tempRes = res.clone();
8996
8998
  let body = await tempRes.text();
8997
8999
  try {
@@ -14686,14 +14688,39 @@
14686
14688
 
14687
14689
  // src/SolidAdapter.js
14688
14690
  var SolidAdapter = class extends HttpAdapter {
14691
+ #client;
14692
+ #path;
14689
14693
  constructor(metroClient, path = "/", solidConfiguration = {}) {
14690
- metroClient = client(metroClient).with(browser_default.oidcmw(solidConfiguration)).with(src_default3(solidConfiguration));
14691
- path = new Path(path);
14692
- super(metroClient, path);
14694
+ this.#client = client(metroClient).with(browser_default.oidcmw(solidConfiguration)).with(src_default3(solidConfiguration));
14695
+ this.#path = new Path(path);
14696
+ super(this.#client, this.#path);
14693
14697
  }
14694
14698
  get name() {
14695
14699
  return "SolidAdapter";
14696
14700
  }
14701
+ async read(path) {
14702
+ let response2 = await this.#client.get(path);
14703
+ let result2 = {
14704
+ type: this.getMimetype(response2),
14705
+ name: Path.filename(path),
14706
+ http: {
14707
+ headers: response2.headers,
14708
+ status: response2.status,
14709
+ url: response2.url
14710
+ }
14711
+ };
14712
+ if (response2.data) {
14713
+ result2.data = response2.data;
14714
+ }
14715
+ if (result2.type.match(/text\/.*/)) {
14716
+ result2.contents = await response2.text();
14717
+ } else if (result2.type.match(/application\/json.*/)) {
14718
+ result2.contents = await response2.json();
14719
+ } else {
14720
+ result2.contents = await response2.blob();
14721
+ }
14722
+ return result2;
14723
+ }
14697
14724
  async list(path) {
14698
14725
  let result2 = await this.read(path);
14699
14726
  if (result2.data) {