Skip to content

Commit 5b79a86

Browse files
Merge pull request #64 from mProjectsCode/master
merge into release
2 parents 6a0d192 + 217e4f7 commit 5b79a86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+9443
-1981
lines changed

__mocks__/obsidian.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { RequestUrlParam, RequestUrlResponse } from "obsidian";
2+
3+
export function requestUrl(request: RequestUrlParam): Promise<RequestUrlResponse> {
4+
return fetch(request.url, {
5+
method: request.method,
6+
headers: request.headers,
7+
body: request.body,
8+
}).then(async (response) => {
9+
if (response.status >= 400 && request.throw) {
10+
throw new Error(`Request failed, ${response.status}`);
11+
}
12+
13+
// Turn response headers into Record<string, string> object
14+
const headers: Record<string, string> = {};
15+
response.headers.forEach((value, key) => {
16+
headers[key] = value;
17+
});
18+
19+
const arraybuffer = await response.arrayBuffer();
20+
const text = arraybuffer ? new TextDecoder().decode(arraybuffer) : '';
21+
const json = text ? JSON.parse(text) : {};
22+
23+
let response_body: RequestUrlResponse = {
24+
status: response.status,
25+
headers: headers,
26+
arrayBuffer: arraybuffer,
27+
json: json,
28+
text: text,
29+
};
30+
return response_body;
31+
});
32+
}

esbuild.config.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import esbuild from "esbuild";
2-
import process from "process";
3-
import builtins from 'builtin-modules'
1+
import esbuild from 'esbuild';
2+
import process from 'process';
3+
import builtins from 'builtin-modules';
4+
import esbuildSvelte from 'esbuild-svelte';
5+
import sveltePreprocess from 'svelte-preprocess';
46

57
const banner =
6-
`/*
8+
`/*
79
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
810
if you want to view the source, please visit the github repository of this plugin
911
*/
@@ -45,8 +47,14 @@ esbuild.build({
4547
format: 'cjs',
4648
watch: !prod,
4749
target: 'es2016',
48-
logLevel: "info",
50+
logLevel: 'info',
4951
sourcemap: prod ? false : 'inline',
5052
treeShaking: true,
5153
outfile: 'main.js',
54+
plugins: [
55+
esbuildSvelte({
56+
compilerOptions: { css: true },
57+
preprocess: sveltePreprocess(),
58+
}),
59+
],
5260
}).catch(() => process.exit(1));

jest.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
"roots": [
3+
"<rootDir>/src",
4+
"<rootDir>"
5+
],
6+
"testMatch": [
7+
"**/__tests__/**/*.+(ts|tsx|js)",
8+
"**/?(*.)+(spec|test).+(ts|tsx|js)"
9+
],
10+
"transform": {
11+
"^.+\\.(ts|tsx)$": "ts-jest"
12+
},
13+
}

0 commit comments

Comments
 (0)