Skip to content

Commit a96efd8

Browse files
committed
init
1 parent fcd3cb2 commit a96efd8

27 files changed

+7430
-243
lines changed

.eslintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
node_modules/
2-
1+
npm node_modules
2+
build
33
main.js
4+
Publish.js

.eslintrc

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"env": { "node": true },
5-
"plugins": [
6-
"@typescript-eslint"
7-
],
8-
"extends": [
9-
"eslint:recommended",
10-
"plugin:@typescript-eslint/eslint-recommended",
11-
"plugin:@typescript-eslint/recommended"
12-
],
13-
"parserOptions": {
14-
"sourceType": "module"
15-
},
16-
"rules": {
17-
"no-unused-vars": "off",
18-
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
19-
"@typescript-eslint/ban-ts-comment": "off",
20-
"no-prototype-builtins": "off",
21-
"@typescript-eslint/no-empty-function": "off"
22-
}
23-
}
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"env": {
5+
"node": true
6+
},
7+
"plugins": ["@typescript-eslint", "only-warn"],
8+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended"],
9+
"parserOptions": {
10+
"sourceType": "module"
11+
},
12+
"rules": {
13+
"no-unused-vars": "off",
14+
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
15+
"@typescript-eslint/ban-ts-comment": "off",
16+
"no-prototype-builtins": "off",
17+
"@typescript-eslint/no-empty-function": "off",
18+
"@typescript-eslint/no-inferrable-types": "off",
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"@typescript-eslint/explicit-function-return-type": ["warn"]
21+
}
22+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Publish.js linguist-generated

.gitignore

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
# vscode
2-
.vscode
3-
4-
# Intellij
5-
*.iml
6-
.idea
7-
8-
# npm
9-
node_modules
10-
11-
# Don't include the compiled main.js file in the repo.
12-
# They should be uploaded to GitHub releases instead.
13-
main.js
14-
15-
# Exclude sourcemaps
16-
*.map
17-
18-
# obsidian
19-
data.json
20-
21-
# Exclude macOS Finder (System Explorer) View States
22-
.DS_Store
1+
# vscode
2+
.vscode
3+
4+
# Intellij
5+
*.iml
6+
.idea
7+
8+
# npm
9+
node_modules
10+
11+
# Don't include the compiled main.js file in the repo.
12+
# They should be uploaded to GitHub releases instead.
13+
main.js
14+
15+
# Exclude sourcemaps
16+
*.map
17+
18+
# obsidian
19+
data.json
20+
21+
# Exclude macOS Finder (System Explorer) View States
22+
.DS_Store
23+
24+
obsidian.css
25+
26+
!exampleVault/.obsidian
27+
28+
exampleVault/.obsidian/*
29+
!exampleVault/.obsidian/plugins
30+
31+
exampleVault/.obsidian/plugins/*
32+
exampleVault/.obsidian/plugins/obsidian-js-engine-plugin/*
33+
!exampleVault/.obsidian/plugins/obsidian-js-engine-plugin/.hotreload

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/lib
2+
node_modules
3+
package-lock.json
4+
exampleVault
5+
main.js
6+
Publish.js

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 180,
3+
"useTabs": true,
4+
"semi": true,
5+
"singleQuote": true,
6+
"arrowParens": "avoid"
7+
}

esbuild.config.mjs

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,63 @@
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

5-
const banner =
6-
`/*
7+
const banner = `/*
78
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
89
if you want to view the source, please visit the github repository of this plugin
910
*/
1011
`;
1112

12-
const prod = (process.argv[2] === "production");
13+
const prod = process.argv[2] === 'production';
1314

14-
const context = await esbuild.context({
15-
banner: {
16-
js: banner,
17-
},
18-
entryPoints: ["main.ts"],
19-
bundle: true,
20-
external: [
21-
"obsidian",
22-
"electron",
23-
"@codemirror/autocomplete",
24-
"@codemirror/collab",
25-
"@codemirror/commands",
26-
"@codemirror/language",
27-
"@codemirror/lint",
28-
"@codemirror/search",
29-
"@codemirror/state",
30-
"@codemirror/view",
31-
"@lezer/common",
32-
"@lezer/highlight",
33-
"@lezer/lr",
34-
...builtins],
35-
format: "cjs",
36-
target: "es2018",
37-
logLevel: "info",
38-
sourcemap: prod ? false : "inline",
39-
treeShaking: true,
40-
outfile: "main.js",
41-
});
42-
43-
if (prod) {
44-
await context.rebuild();
45-
process.exit(0);
46-
} else {
47-
await context.watch();
48-
}
15+
esbuild
16+
.build({
17+
banner: {
18+
js: banner,
19+
},
20+
entryPoints: ['src/main.ts'],
21+
bundle: true,
22+
external: [
23+
'obsidian',
24+
'electron',
25+
'@codemirror/autocomplete',
26+
'@codemirror/closebrackets',
27+
'@codemirror/collab',
28+
'@codemirror/commands',
29+
'@codemirror/comment',
30+
'@codemirror/fold',
31+
'@codemirror/gutter',
32+
'@codemirror/highlight',
33+
'@codemirror/history',
34+
'@codemirror/language',
35+
'@codemirror/lint',
36+
'@codemirror/matchbrackets',
37+
'@codemirror/panel',
38+
'@codemirror/rangeset',
39+
'@codemirror/rectangular-selection',
40+
'@codemirror/search',
41+
'@codemirror/state',
42+
'@codemirror/stream-parser',
43+
'@codemirror/text',
44+
'@codemirror/tooltip',
45+
'@codemirror/view',
46+
...builtins,
47+
],
48+
format: 'cjs',
49+
watch: !prod,
50+
target: 'es2018',
51+
logLevel: 'info',
52+
sourcemap: prod ? false : 'inline',
53+
treeShaking: true,
54+
outfile: 'main.js',
55+
minify: true,
56+
plugins: [
57+
esbuildSvelte({
58+
compilerOptions: { css: true },
59+
preprocess: sveltePreprocess(),
60+
}),
61+
],
62+
})
63+
.catch(() => process.exit(1));

esbuild.dev.config.mjs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import esbuild from 'esbuild';
2+
import process from 'process';
3+
import builtins from 'builtin-modules';
4+
import copy from 'esbuild-plugin-copy-watch';
5+
import esbuildSvelte from 'esbuild-svelte';
6+
import sveltePreprocess from 'svelte-preprocess';
7+
8+
const banner = `/*
9+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
10+
if you want to view the source, please visit the github repository of this plugin
11+
*/
12+
`;
13+
14+
const prod = process.argv[2] === 'production';
15+
16+
esbuild
17+
.build({
18+
banner: {
19+
js: banner,
20+
},
21+
entryPoints: ['src/main.ts'],
22+
bundle: true,
23+
external: [
24+
'obsidian',
25+
'electron',
26+
'@codemirror/autocomplete',
27+
'@codemirror/closebrackets',
28+
'@codemirror/collab',
29+
'@codemirror/commands',
30+
'@codemirror/comment',
31+
'@codemirror/fold',
32+
'@codemirror/gutter',
33+
'@codemirror/highlight',
34+
'@codemirror/history',
35+
'@codemirror/language',
36+
'@codemirror/lint',
37+
'@codemirror/matchbrackets',
38+
'@codemirror/panel',
39+
'@codemirror/rangeset',
40+
'@codemirror/rectangular-selection',
41+
'@codemirror/search',
42+
'@codemirror/state',
43+
'@codemirror/stream-parser',
44+
'@codemirror/text',
45+
'@codemirror/tooltip',
46+
'@codemirror/view',
47+
...builtins,
48+
],
49+
format: 'cjs',
50+
watch: !prod,
51+
target: 'es2016',
52+
logLevel: 'info',
53+
sourcemap: prod ? false : 'inline',
54+
treeShaking: true,
55+
outdir: 'exampleVault/.obsidian/plugins/obsidian-js-engine-plugin/',
56+
outbase: 'src',
57+
plugins: [
58+
copy([
59+
{
60+
from: './styles.css',
61+
to: '',
62+
},
63+
{
64+
from: './manifest.json',
65+
to: '',
66+
},
67+
]),
68+
esbuildSvelte({
69+
compilerOptions: { css: true },
70+
preprocess: sveltePreprocess(),
71+
})
72+
],
73+
})
74+
.catch(() => process.exit(1));

exampleVault/Test.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
asd
2+
```js-engine
3+
let a = "test";
4+
return a;
5+
```
6+
asdasd
7+
asdasd
8+
asdasd
9+
10+
```js-engine
11+
let markdownBuilder = engine.createMarkdownBuilder()
12+
13+
markdownBuilder.createHeading(2, "Test Heading")
14+
markdownBuilder.createParagraph("This is a test paragraph.")
15+
16+
markdownBuilder.createHeading(3, "This is a sub heading")
17+
markdownBuilder.createHeading(4, "This is a sub sub heading")
18+
markdownBuilder.createParagraph("This is another test paragraph.")
19+
20+
let callout = markdownBuilder.createCallout("This is a callout", "info", "")
21+
22+
let callout2 = callout.createCallout("This is a nested callout", "danger", "")
23+
callout2.createParagraph("This is a test paragraph.")
24+
25+
callout.createParagraph("This is a test paragraph.")
26+
callout.createCodeBlock("js", "let a = 5;\nreturn a;")
27+
28+
let blockquote = callout.createBlockQuote()
29+
blockquote.createHeading(5, "This is a block quote")
30+
blockquote.createParagraph("This is another test paragraph.")
31+
32+
return markdownBuilder
33+
```
34+
35+

jest.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
4+
moduleDirectories: ['node_modules', 'src'],
5+
verbose: true,
6+
};

0 commit comments

Comments
 (0)