@muze-nl/jsfs-solid 0.1.7 → 0.1.9
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 +35 -6
- package/dist/browser.js.map +3 -3
- package/dist/browser.min.js +2 -2
- package/dist/browser.min.js.map +3 -3
- package/package.json +2 -2
- package/package.json~ +2 -2
- package/src/SolidAdapter.js +28 -0
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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,41 @@
|
|
|
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
14694
|
metroClient = client(metroClient).with(browser_default.oidcmw(solidConfiguration)).with(src_default3(solidConfiguration));
|
|
14691
14695
|
path = new Path(path);
|
|
14692
14696
|
super(metroClient, path);
|
|
14697
|
+
this.#client = metroClient;
|
|
14698
|
+
this.#path = path;
|
|
14693
14699
|
}
|
|
14694
14700
|
get name() {
|
|
14695
14701
|
return "SolidAdapter";
|
|
14696
14702
|
}
|
|
14703
|
+
async read(path) {
|
|
14704
|
+
let response2 = await this.#client.get(path);
|
|
14705
|
+
let result2 = {
|
|
14706
|
+
type: this.getMimetype(response2),
|
|
14707
|
+
name: Path.filename(path),
|
|
14708
|
+
http: {
|
|
14709
|
+
headers: response2.headers,
|
|
14710
|
+
status: response2.status,
|
|
14711
|
+
url: response2.url
|
|
14712
|
+
}
|
|
14713
|
+
};
|
|
14714
|
+
if (response2.data) {
|
|
14715
|
+
result2.data = response2.data;
|
|
14716
|
+
}
|
|
14717
|
+
if (result2.type.match(/text\/.*/)) {
|
|
14718
|
+
result2.contents = await response2.text();
|
|
14719
|
+
} else if (result2.type.match(/application\/json.*/)) {
|
|
14720
|
+
result2.contents = await response2.json();
|
|
14721
|
+
} else {
|
|
14722
|
+
result2.contents = await response2.blob();
|
|
14723
|
+
}
|
|
14724
|
+
return result2;
|
|
14725
|
+
}
|
|
14697
14726
|
async list(path) {
|
|
14698
14727
|
let result2 = await this.read(path);
|
|
14699
14728
|
if (result2.data) {
|