diff --git a/README.md b/README.md index 43b529d..1bbbb72 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,5 @@ -# siyuan-plugin-importer - -Import from epub, docx, pdf, html etc. to siyuan-note - -## Usage - -```js -// usage -``` - -## Deps - -``` -## Congregations! siyuan-plugin-importer need no deps, it is just pure js code 🎉 -``` - -## Dev +[中文](README_zh_CN.md) -```bash -pnpm dev -F siyuan-plugin-importer -``` - -## Build - -```bash -pnpm build -F siyuan-plugin-importer -``` - -## Test - -Execute the unit tests via [vitest](https://vitest.dev) - -```bash -pnpm test -F siyuan-plugin-importer -``` - -## Publish +# siyuan-plugin-importer -```bash -pnpm publish -F siyuan-plugin-importer --tag latest -``` \ No newline at end of file +Import from epub, docx, pdf, html etc. to siyuan-note \ No newline at end of file diff --git a/README_zh_CN.md b/README_zh_CN.md new file mode 100644 index 0000000..82186bf --- /dev/null +++ b/README_zh_CN.md @@ -0,0 +1,5 @@ +[English](README.md) + +# 导入工具 + +导入 epub, docx, pdf, html 等格式到思源笔记 \ No newline at end of file diff --git a/package.json b/package.json index b536655..a9461bc 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,12 @@ "test": "vitest --watch" }, "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^2.0.3", "@terwer/eslint-config-custom": "^1.2.0", - "@terwer/vite-config-custom": "^0.2.0" + "@terwer/vite-config-custom": "^0.5.0", + "@tsconfig/svelte": "^4.0.1", + "siyuan": "^0.7.1", + "stylus": "^0.59.0", + "svelte": "^3.57.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22294e1..ceb3b87 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,15 +1,34 @@ lockfileVersion: '6.0' devDependencies: + '@sveltejs/vite-plugin-svelte': + specifier: ^2.0.3 + version: 2.0.3(svelte@3.59.1)(vite@4.3.6) '@terwer/eslint-config-custom': specifier: ^1.2.0 version: 1.2.0(@nuxt/eslint-config@0.1.1)(@typescript-eslint/eslint-plugin@5.59.6)(astro-eslint-parser@0.13.3)(eslint-config-prettier@8.8.0)(eslint-config-turbo@1.9.6)(eslint-plugin-prettier@4.2.1)(eslint-plugin-svelte@2.28.0)(eslint-plugin-vue@9.13.0)(eslint@8.40.0)(prettier-plugin-svelte@2.10.0)(prettier@2.8.8)(typescript@5.0.4) '@terwer/vite-config-custom': - specifier: ^0.2.0 - version: 0.2.0(jsdom@22.0.0)(tslib@2.5.0)(typescript@5.0.4)(vite-plugin-css-injected-by-js@3.1.1)(vite-plugin-dts@2.3.0)(vite-plugin-static-copy@0.15.0)(vite-tsconfig-paths@4.2.0)(vite@4.3.6)(vitest@0.31.0) + specifier: ^0.5.0 + version: 0.5.0(jsdom@22.0.0)(minimist@1.2.8)(rollup-plugin-livereload@2.0.5)(tslib@2.5.0)(typescript@5.0.4)(vite-plugin-css-injected-by-js@3.1.1)(vite-plugin-dts@2.3.0)(vite-plugin-no-bundle@2.0.2)(vite-plugin-static-copy@0.15.0)(vite-tsconfig-paths@4.2.0)(vite@4.3.6)(vitest@0.31.0) + '@tsconfig/svelte': + specifier: ^4.0.1 + version: 4.0.1 + siyuan: + specifier: ^0.7.1 + version: 0.7.1 + stylus: + specifier: ^0.59.0 + version: 0.59.0 + svelte: + specifier: ^3.57.0 + version: 3.59.1 packages: + /@adobe/css-tools@4.2.0: + resolution: {integrity: sha512-E09FiIft46CmH5Qnjb0wsW54/YQd69LsxeKUOWawmws1XWvyFGURnAChH0mlr7YPFR1ofwvUQfcL0J3lMxXqPA==} + dev: true + /@astrojs/compiler@1.4.1: resolution: {integrity: sha512-aXAxapNWZwGN41P+Am/ma/2kAzKOhMNaY6YuvLkUHFv+UZkmDHD6F0fE1sQA2Up0bLjgPQa1VQzoAaii5tZWaA==} dev: true @@ -442,6 +461,25 @@ packages: string-argv: 0.3.2 dev: true + /@sveltejs/vite-plugin-svelte@2.0.3(svelte@3.59.1)(vite@4.3.6): + resolution: {integrity: sha512-o+cguBFdwIGtRbNkYOyqTM7KvRUffxh5bfK4oJsWKG2obu+v/cbpT03tJrGl58C7tRXo/aEC0/axN5FVHBj0nA==} + engines: {node: ^14.18.0 || >= 16} + peerDependencies: + svelte: ^3.54.0 + vite: ^4.0.0 + dependencies: + debug: 4.3.4 + deepmerge: 4.3.1 + kleur: 4.1.5 + magic-string: 0.29.0 + svelte: 3.59.1 + svelte-hmr: 0.15.1(svelte@3.59.1) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) + vitefu: 0.2.4(vite@4.3.6) + transitivePeerDependencies: + - supports-color + dev: true + /@terwer/eslint-config-custom@1.2.0(@nuxt/eslint-config@0.1.1)(@typescript-eslint/eslint-plugin@5.59.6)(astro-eslint-parser@0.13.3)(eslint-config-prettier@8.8.0)(eslint-config-turbo@1.9.6)(eslint-plugin-prettier@4.2.1)(eslint-plugin-svelte@2.28.0)(eslint-plugin-vue@9.13.0)(eslint@8.40.0)(prettier-plugin-svelte@2.10.0)(prettier@2.8.8)(typescript@5.0.4): resolution: {integrity: sha512-gygsswnGgCsYvhEsLNgdjA8DZidzWFj6i8sfGJYzOEk2Bwc1o7dteis5e5+LBIeQhEPHuvKGUiaSfcqdNL8qIA==} peerDependencies: @@ -472,28 +510,34 @@ packages: typescript: 5.0.4 dev: true - /@terwer/vite-config-custom@0.2.0(jsdom@22.0.0)(tslib@2.5.0)(typescript@5.0.4)(vite-plugin-css-injected-by-js@3.1.1)(vite-plugin-dts@2.3.0)(vite-plugin-static-copy@0.15.0)(vite-tsconfig-paths@4.2.0)(vite@4.3.6)(vitest@0.31.0): - resolution: {integrity: sha512-uDFFlKmP2rBErHj4DK1aGBg5YfoLBoEEoEGOKvxUZsMJpkpU3YMYu8aCETp6aP0NRCpyXml7qFz4CMxgzNp6QA==} + /@terwer/vite-config-custom@0.5.0(jsdom@22.0.0)(minimist@1.2.8)(rollup-plugin-livereload@2.0.5)(tslib@2.5.0)(typescript@5.0.4)(vite-plugin-css-injected-by-js@3.1.1)(vite-plugin-dts@2.3.0)(vite-plugin-no-bundle@2.0.2)(vite-plugin-static-copy@0.15.0)(vite-tsconfig-paths@4.2.0)(vite@4.3.6)(vitest@0.31.0): + resolution: {integrity: sha512-92CrNpu147xR/1gSVB9z7GZEyApoq6ZTgRoE18/AHVYpfkeNqHPmHdaX7rEwJTs1KxlDIP5m46BBS9JTF6DO3g==} peerDependencies: jsdom: ^22.0.0 + minimist: ^1.2.8 + rollup-plugin-livereload: ^2.0.5 tslib: ^2.5.0 typescript: ^5.0.4 vite: ^4.3.5 vite-plugin-css-injected-by-js: ^3.1.1 vite-plugin-dts: ^2.3.0 + vite-plugin-no-bundle: ^2.0.2 vite-plugin-static-copy: ^0.15.0 vite-tsconfig-paths: ^4.2.0 vitest: ^0.31.0 dependencies: jsdom: 22.0.0 + minimist: 1.2.8 + rollup-plugin-livereload: 2.0.5 tslib: 2.5.0 typescript: 5.0.4 - vite: 4.3.6(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) vite-plugin-css-injected-by-js: 3.1.1(vite@4.3.6) vite-plugin-dts: 2.3.0(vite@4.3.6) + vite-plugin-no-bundle: 2.0.2 vite-plugin-static-copy: 0.15.0(vite@4.3.6) vite-tsconfig-paths: 4.2.0(typescript@5.0.4)(vite@4.3.6) - vitest: 0.31.0(jsdom@22.0.0) + vitest: 0.31.0(jsdom@22.0.0)(stylus@0.59.0) dev: true /@tootallnate/once@2.0.0: @@ -510,6 +554,10 @@ packages: path-browserify: 1.0.1 dev: true + /@tsconfig/svelte@4.0.1: + resolution: {integrity: sha512-B+XlGpmuAQzJqDoBATNCvEPqQg0HkO7S8pM14QDI5NsmtymzRexQ1N+nX2H6RTtFbuFgaZD4I8AAi8voGg0GLg==} + dev: true + /@types/argparse@1.0.38: resolution: {integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==} dev: true @@ -1156,6 +1204,11 @@ packages: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /deepmerge@4.3.1: + resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} + engines: {node: '>=0.10.0'} + dev: true + /default-browser-id@3.0.0: resolution: {integrity: sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==} engines: {node: '>=12'} @@ -1913,6 +1966,11 @@ packages: graceful-fs: 4.2.11 dev: true + /kleur@4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + dev: true + /known-css-properties@0.27.0: resolution: {integrity: sha512-uMCj6+hZYDoffuvAJjFAPz56E9uoowFHmTkqRtRq5WyC5Q6Cu/fTZKNQpX/RbzChBYLLl3lo8CjFZBAZXq9qFg==} dev: true @@ -1934,6 +1992,24 @@ packages: engines: {node: '>=10'} dev: true + /livereload-js@3.4.1: + resolution: {integrity: sha512-5MP0uUeVCec89ZbNOT/i97Mc+q3SxXmiUGhRFOTmhrGPn//uWVQdCvcLJDy64MSBR5MidFdOR7B9viumoavy6g==} + dev: true + + /livereload@0.9.3: + resolution: {integrity: sha512-q7Z71n3i4X0R9xthAryBdNGVGAO2R5X+/xXpmKeuPMrteg+W2U8VusTKV3YiJbXZwKsOlFlHe+go6uSNjfxrZw==} + engines: {node: '>=8.0.0'} + hasBin: true + dependencies: + chokidar: 3.5.3 + livereload-js: 3.4.1 + opts: 2.0.2 + ws: 7.5.9 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: true + /local-pkg@0.4.3: resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} engines: {node: '>=14'} @@ -2048,6 +2124,10 @@ packages: brace-expansion: 2.0.1 dev: true + /minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + dev: true + /mkdirp@2.1.6: resolution: {integrity: sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==} engines: {node: '>=10'} @@ -2152,6 +2232,10 @@ packages: word-wrap: 1.2.3 dev: true + /opts@2.0.2: + resolution: {integrity: sha512-k41FwbcLnlgnFh69f4qdUfvDQ+5vaSDnVPFI/y5XuhKRq97EnVVneO9F1ESVCdiVu4fCS2L8usX3mU331hB7pg==} + dev: true + /p-limit@3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} @@ -2389,6 +2473,16 @@ packages: glob: 7.2.3 dev: true + /rollup-plugin-livereload@2.0.5: + resolution: {integrity: sha512-vqQZ/UQowTW7VoiKEM5ouNW90wE5/GZLfdWuR0ELxyKOJUIaj+uismPZZaICU4DnWPVjnpCDDxEqwU7pcKY/PA==} + engines: {node: '>=8.3'} + dependencies: + livereload: 0.9.3 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: true + /rollup@3.21.7: resolution: {integrity: sha512-KXPaEuR8FfUoK2uHwNjxTmJ18ApyvD6zJpYv9FOJSqLStmt6xOY84l1IjK2dSolQmoXknrhEFRaPRgOPdqCT5w==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} @@ -2418,6 +2512,10 @@ packages: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true + /sax@1.2.4: + resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + dev: true + /saxes@6.0.0: resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} engines: {node: '>=v12.22.7'} @@ -2461,6 +2559,10 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /siyuan@0.7.1: + resolution: {integrity: sha512-Q7OZqpJ8h+axLDkn6afoAdKD6mHPAona/jsoUpf8UgFqHuOscNS6ub8RudhTCPKppDnQzBy5o35xhlecxnrbjQ==} + dev: true + /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -2476,6 +2578,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /source-map@0.7.4: + resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} + engines: {node: '>= 8'} + dev: true + /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} dev: true @@ -2521,6 +2628,19 @@ packages: acorn: 8.8.2 dev: true + /stylus@0.59.0: + resolution: {integrity: sha512-lQ9w/XIOH5ZHVNuNbWW8D822r+/wBSO/d6XvtyHLF7LW4KaCIDeVbvn5DF8fGCJAUCwVhVi/h6J0NUcnylUEjg==} + hasBin: true + dependencies: + '@adobe/css-tools': 4.2.0 + debug: 4.3.4 + glob: 7.2.3 + sax: 1.2.4 + source-map: 0.7.4 + transitivePeerDependencies: + - supports-color + dev: true + /supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -2548,6 +2668,15 @@ packages: svelte: 3.59.1 dev: true + /svelte-hmr@0.15.1(svelte@3.59.1): + resolution: {integrity: sha512-BiKB4RZ8YSwRKCNVdNxK/GfY+r4Kjgp9jCLEy0DuqAKfmQtpL38cQK3afdpjw4sqSs4PLi3jIPJIFp259NkZtA==} + engines: {node: ^12.20 || ^14.13.1 || >= 16} + peerDependencies: + svelte: '>=3.19.0' + dependencies: + svelte: 3.59.1 + dev: true + /svelte@3.59.1: resolution: {integrity: sha512-pKj8fEBmqf6mq3/NfrB9SLtcJcUvjYSWyePlfCqN9gujLB25RitWK8PvFzlwim6hD/We35KbPlRteuA6rnPGcQ==} engines: {node: '>= 8'} @@ -2751,7 +2880,7 @@ packages: engines: {node: '>= 0.10'} dev: true - /vite-node@0.31.0(@types/node@20.1.5): + /vite-node@0.31.0(@types/node@20.1.5)(stylus@0.59.0): resolution: {integrity: sha512-8x1x1LNuPvE2vIvkSB7c1mApX5oqlgsxzHQesYF7l5n1gKrEmrClIiZuOFbFDQcjLsmcWSwwmrWrcGWm9Fxc/g==} engines: {node: '>=v14.18.0'} hasBin: true @@ -2761,7 +2890,7 @@ packages: mlly: 1.2.1 pathe: 1.1.0 picocolors: 1.0.0 - vite: 4.3.6(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) transitivePeerDependencies: - '@types/node' - less @@ -2777,7 +2906,7 @@ packages: peerDependencies: vite: '>2.0.0-0' dependencies: - vite: 4.3.6(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) dev: true /vite-plugin-dts@2.3.0(vite@4.3.6): @@ -2796,13 +2925,20 @@ packages: kolorist: 1.8.0 magic-string: 0.29.0 ts-morph: 18.0.0 - vite: 4.3.6(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) transitivePeerDependencies: - '@types/node' - rollup - supports-color dev: true + /vite-plugin-no-bundle@2.0.2: + resolution: {integrity: sha512-QtMJ0Dzml8mQzZ+Ta09fPJAgy6WXp5rN2w77KQEIV79OeAwkpnaaig/KwH9r6tZLMfa5LkMO7DmmOGQwtph+2A==} + dependencies: + fast-glob: 3.2.12 + micromatch: 4.0.5 + dev: true + /vite-plugin-static-copy@0.15.0(vite@4.3.6): resolution: {integrity: sha512-Ww+/Ug9guV45oIfIi/lA2z8v3K+lLHV9zCJqTVO4FTdqrJoZBj68VgGBSH1fi0N4q/EHW32RsL3ympi4Wlsq5w==} engines: {node: ^14.18.0 || >=16.0.0} @@ -2813,7 +2949,7 @@ packages: fast-glob: 3.2.12 fs-extra: 11.1.1 picocolors: 1.0.0 - vite: 4.3.6(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) dev: true /vite-tsconfig-paths@4.2.0(typescript@5.0.4)(vite@4.3.6): @@ -2827,13 +2963,13 @@ packages: debug: 4.3.4 globrex: 0.1.2 tsconfck: 2.1.1(typescript@5.0.4) - vite: 4.3.6(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) transitivePeerDependencies: - supports-color - typescript dev: true - /vite@4.3.6(@types/node@20.1.5): + /vite@4.3.6(@types/node@20.1.5)(stylus@0.59.0): resolution: {integrity: sha512-cqIyLSbA6gornMS659AXTVKF7cvSHMdKmJJwQ9DXq3lwsT1uZSdktuBRlpHQ8VnOWx0QHtjDwxPpGtyo9Fh/Qg==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -2862,11 +2998,23 @@ packages: esbuild: 0.17.19 postcss: 8.4.23 rollup: 3.21.7 + stylus: 0.59.0 optionalDependencies: fsevents: 2.3.2 dev: true - /vitest@0.31.0(jsdom@22.0.0): + /vitefu@0.2.4(vite@4.3.6): + resolution: {integrity: sha512-fanAXjSaf9xXtOOeno8wZXIhgia+CZury481LsDaV++lSvcU2R9Ch2bPh3PYFyoHW+w9LqAeYRISVQjUIew14g==} + peerDependencies: + vite: ^3.0.0 || ^4.0.0 + peerDependenciesMeta: + vite: + optional: true + dependencies: + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) + dev: true + + /vitest@0.31.0(jsdom@22.0.0)(stylus@0.59.0): resolution: {integrity: sha512-JwWJS9p3GU9GxkG7eBSmr4Q4x4bvVBSswaCFf1PBNHiPx00obfhHRJfgHcnI0ffn+NMlIh9QGvG75FlaIBdKGA==} engines: {node: '>=v14.18.0'} hasBin: true @@ -2920,8 +3068,8 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.5.0 - vite: 4.3.6(@types/node@20.1.5) - vite-node: 0.31.0(@types/node@20.1.5) + vite: 4.3.6(@types/node@20.1.5)(stylus@0.59.0) + vite-node: 0.31.0(@types/node@20.1.5)(stylus@0.59.0) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -3013,6 +3161,19 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true + /ws@7.5.9: + resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + dev: true + /ws@8.13.0: resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} engines: {node: '>=10.0.0'} diff --git a/public/i18n/en_US.json b/public/i18n/en_US.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/public/i18n/en_US.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/public/i18n/zh_CN.json b/public/i18n/zh_CN.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/public/i18n/zh_CN.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000..47d51af Binary files /dev/null and b/public/icon.png differ diff --git a/public/plugin.json b/public/plugin.json new file mode 100644 index 0000000..ac0eaad --- /dev/null +++ b/public/plugin.json @@ -0,0 +1,27 @@ +{ + "name": "siyuan-importer", + "author": "terwer", + "url": "https://github.com/terwer/siyuan-plugin-importer", + "version": "0.0.1", + "displayName": { + "default": "Importer", + "zh_CN": "导入工具" + }, + "description": { + "default": "Import from epub, docx, pdf, html etc. to siyuan-note", + "zh_CN": "导入 epub, docx, pdf, html 等格式到思源笔记" + }, + "readme": { + "default": "README.md", + "zh_CN": "README_zh_CN.md" + }, + "i18n": [ + "en_US", + "zh_CN" + ], + "funding": { + "custom": [ + "https://afdian.net/a/terwer" + ] + } +} \ No newline at end of file diff --git a/public/preview.png b/public/preview.png new file mode 100644 index 0000000..95b93c7 Binary files /dev/null and b/public/preview.png differ diff --git a/src/index.spec.ts b/src/index.spec.ts index ec837a4..21a1371 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + import { describe, it } from "vitest" describe("index", () => { diff --git a/src/index.ts b/src/index.ts index a8d0db9..bf834f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,45 @@ -const init = () => { - return "ok" -} +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import { App, IObject, Plugin } from "siyuan" +import { createLogger } from "./utils/simple-logger" + +export default class ImporterPlugin extends Plugin { + private logger + + constructor(options: { app: App; id: string; name: string; i18n: IObject }) { + super(options) -export default init + this.logger = createLogger("index") + } + + onload() { + this.logger.info("Importer loaded") + } + + onunload() { + this.logger.info("Importer loaded") + } +} diff --git a/src/siyuan.d.ts b/src/siyuan.d.ts new file mode 100644 index 0000000..d51e666 --- /dev/null +++ b/src/siyuan.d.ts @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +declare module "siyuan" { + type TEventBus = "ws-main" + + interface IObject { + [key: string]: string; + } + + interface IWebSocketData { + cmd: string; + callback?: string; + data: any; + msg: string; + code: number; + sid: string; + } + + declare interface IPluginDockTab { + position: "LeftTop" | "LeftBottom" | "RightTop" | "RightBottom" | "BottomLeft" | "BottomRight", + size: { width: number, height: number }, + icon: string, + hotkey?: string, + title: string, + } + + interface IMenuItemOption { + label?: string, + click?: (element: HTMLElement) => void, + type?: "separator" | "submenu" | "readonly", + accelerator?: string, + action?: string, + id?: string, + submenu?: IMenuItemOption[] + disabled?: boolean + icon?: string + iconHTML?: string + current?: boolean + bind?: (element: HTMLElement) => void + } + + export function fetchPost(url: string, data?: any, cb?: (response: IWebSocketData) => void, headers?: IObject): void; + + export function fetchSyncPost(url: string, data?: any): Promise; + + export function fetchGet(url: string, cb: (response: IWebSocketData) => void): void; + + export function openTab(options: { + custom?: { + title: string, + icon: string, + data?: any + fn?: () => any, + } // card 和自定义页签 必填 + position?: "right" | "bottom", + keepCursor?: boolean // 是否跳转到新 tab 上 + removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签 + afterOpen?: () => void // 打开后回调 + }): void + + export function isMobile(): boolean; + + export function adaptHotkey(hotkey: string): string; + + export function confirm(title: string, text: string, confirmCB?: () => void, cancelCB?: () => void): void; + + /** + * @param timeout - ms. 0: manual close;-1: always show; 6000: default + * @param {string} [type=info] + */ + export function showMessage(text: string, timeout?: number, type?: "info" | "error", id?: string): void; + + export class App { + plugins: Plugin[]; + } + + export abstract class Plugin { + eventBus: EventBus; + i18n: IObject; + data: any; + name: string; + + constructor(options: { + app: App, + id: string, + name: string, + i18n: IObject + }) + + onload(): void; + + onunload(): void; + + /* + * @param {string} [options.position=right] + */ + addTopBar(options: { + icon: string, + title: string, + callback: (evt: MouseEvent) => void + position?: "right" | "left" + }): HTMLDivElement; + + openSetting(): void + + // registerCommand(command: IPluginCommand): void; + + // registerSettingRender(settingRender: SettingRender): void; + + loadData(storageName: string): Promise; + + saveData(storageName: string, content: any): Promise; + + addTab(options: { + type: string, + destroy?: () => void, + resize?: () => void, + update?: () => void, + init: () => void + }): () => any + + addDock(options: { + config: IPluginDockTab, + data: any, + type: string, + destroy?: () => void, + resize?: () => void, + update?: () => void, + init: () => void + }): any + } + + export class EventBus { + on(type: TEventBus, listener: (event: CustomEvent) => void): void; + + once(type: TEventBus, listener: (event: CustomEvent) => void): void; + + off(type: TEventBus, listener: (event: CustomEvent) => void): void; + + emit(type: TEventBus, detail?: any): boolean; + } + + export class Dialog { + + element: HTMLElement; + + constructor(options: { + title?: string, + transparent?: boolean, + content: string, + width?: string + height?: string, + destroyCallback?: (options?: IObject) => void + disableClose?: boolean + disableAnimation?: boolean + }); + + destroy(options?: IObject): void; + + bindInput(inputElement: HTMLInputElement | HTMLTextAreaElement, enterEvent?: () => void): void; + } + + export class Menu { + constructor(id?: string, closeCB?: () => void); + + showSubMenu(subMenuElement: HTMLElement): void; + + addItem(options: IMenuItemOption): HTMLElement; + + addSeparator(): void; + + open(options: { x: number, y: number, h?: number, w?: number, isLeft?: boolean }): void; + + /* + * @param {string} [position=all] + */ + fullscreen(position?: "bottom" | "all"): void; + + close(): void; + } +} \ No newline at end of file diff --git a/src/utils/kernel-api.ts b/src/utils/kernel-api.ts new file mode 100644 index 0000000..8a26687 --- /dev/null +++ b/src/utils/kernel-api.ts @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * 思源笔记服务端API v2.8.2 + */ +class KernelApi {} + +export default KernelApi diff --git a/src/utils/simple-logger.ts b/src/utils/simple-logger.ts new file mode 100644 index 0000000..2240e98 --- /dev/null +++ b/src/utils/simple-logger.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * 简单的日志接口 + */ +interface ILogger { + debug: (msg: string, obj?: any) => void + info: (msg: string, obj?: any) => void + error: (msg: string | Error, obj?: any) => void +} + +/** + * 为了在日志系统加载之前记录一些东西,这里写了一个简单的日志工具,仅在 core 使用 + * + * @author terwer + * @version 0.1.0 + * @since 0.1.0 + */ +export const createLogger = (name: string): ILogger => { + const sign = "importer" + + const formatDate = (date: Date) => { + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, "0") + const day = String(date.getDate()).padStart(2, "0") + const hours = String(date.getHours()).padStart(2, "0") + const minutes = String(date.getMinutes()).padStart(2, "0") + const seconds = String(date.getSeconds()).padStart(2, "0") + + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` + } + + const log = (level: string, msg: any, obj?: any) => { + const time = formatDate(new Date()) + if (obj) { + console.log(`[${sign}] [${time}] [${level}] [${name}] ${msg}`, obj) + } else { + console.log(`[${sign}] [${time}] [${level}] [${name}] ${msg}`) + } + } + + return { + debug: (msg: string, obj?: any) => log("DEBUG", msg, obj), + info: (msg: string, obj?: any) => log("INFO", msg, obj), + error: (msg: string | Error, obj?: any) => { + if (typeof msg == "string") { + log("ERROR", msg, obj) + } else { + console.error(`[${sign}] [${formatDate(new Date())}] [ERROR] [${name}] error occurred`, msg) + } + }, + } +} diff --git a/vite.config.ts b/vite.config.ts index d34f8f1..9718771 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,13 +1,74 @@ /// import { resolve } from "path" -import { defineConfig } from "vite" -import dts from "vite-plugin-dts" +import { defineConfig, loadEnv } from "vite" +import minimist from "minimist" +import { viteStaticCopy } from "vite-plugin-static-copy" +import livereload from "rollup-plugin-livereload" +import { svelte } from "@sveltejs/vite-plugin-svelte" + +const args = minimist(process.argv.slice(2)) +const isWatch = args.watch || args.w +const devDistDir = "/Users/terwer/Documents/mydocs/SiYuanWorkspace/public/data/plugins/siyuan-importer" +const distDir = isWatch ? devDistDir : "./dist" +// const mode = process.env.NODE_ENV +const mode = isWatch ? "development" : "production" + +const defineEnv = () => { + const env = loadEnv(mode, process.cwd()) + return { + "process.env": Object.entries(env).reduce((prev, [key, val]) => { + return { + ...prev, + [key]: val, + } + }, {}), + } +} +const env = { + ...defineEnv(), + // 下面可以自定义添加需要注入的环境变量 + "process.env.NODE_ENV": mode, +} + +console.log("mode=>", mode) +console.log("env=>", env) +console.log("isWatch=>", isWatch) +console.log("distDir=>", distDir) export default defineConfig({ - plugins: [dts()], + plugins: [ + svelte(), + + viteStaticCopy({ + targets: [ + { + src: "./README*.md", + dest: "./", + }, + ], + }), + ], + + // https://github.com/vitejs/vite/issues/1930 + // https://vitejs.dev/guide/env-and-mode.html#env-files + // 在这里自定义变量 + define: env, build: { + // 输出路径 + outDir: distDir, + emptyOutDir: false, + + // 构建后是否生成 source map 文件 + sourcemap: false, + + // 设置为 false 可以禁用最小化混淆 + // 或是用来指定是应用哪种混淆器 + // boolean | 'terser' | 'esbuild' + // 不压缩,用于调试 + minify: isWatch, + lib: { // Could also be a dictionary or array of multiple entry points entry: resolve(__dirname, "src/index.ts"), @@ -16,11 +77,15 @@ export default defineConfig({ formats: ["cjs"], }, rollupOptions: { + plugins: [...(isWatch ? [livereload(devDistDir)] : [])] as Plugin[], + // make sure to externalize deps that shouldn't be bundled // into your library - external: [], + external: ["siyuan", "process"], + output: { entryFileNames: "[name].js", + assetFileNames: "[name].[ext]", }, }, },