diff --git a/package.json b/package.json index 0779caf..bf638b6 100755 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "version": "0.0.2", "scripts": { "dev": "tiddlywiki-plugin-dev dev", + "dev:wiki": "tiddlywiki-plugin-dev dev --write-wiki", + "test": "tiddlywiki-plugin-dev test", "build": "npm run clean && tiddlywiki-plugin-dev build", "publish": "npm run clean && tiddlywiki-plugin-dev publish", "reset": "rimraf ./**/node_modules", @@ -46,6 +48,6 @@ "dependencies": { "npm-check-updates": "^16.14.17", "tiddlywiki": "^5.3.3", - "tiddlywiki-plugin-dev": "^0.0.41" + "tiddlywiki-plugin-dev": "^0.1.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 96ca73d..83e9543 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^5.3.3 version: 5.3.3 tiddlywiki-plugin-dev: - specifier: ^0.0.41 - version: 0.0.41(postcss@8.4.38)(ts-node@10.9.2) + specifier: ^0.1.1 + version: 0.1.1(postcss@8.4.38)(ts-node@10.9.2) devDependencies: '@modern-js/tsconfig': @@ -1256,8 +1256,8 @@ packages: peerDependencies: postcss: ^8.1.0 dependencies: - browserslist: 4.22.1 - caniuse-lite: 1.0.30001554 + browserslist: 4.23.0 + caniuse-lite: 1.0.30001599 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.0.0 @@ -1328,17 +1328,6 @@ packages: dependencies: fill-range: 7.0.1 - /browserslist@4.22.1: - resolution: {integrity: sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==} - engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} - hasBin: true - dependencies: - caniuse-lite: 1.0.30001554 - electron-to-chromium: 1.4.567 - node-releases: 2.0.13 - update-browserslist-db: 1.0.13(browserslist@4.22.1) - dev: false - /browserslist@4.23.0: resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -1348,7 +1337,6 @@ packages: electron-to-chromium: 1.4.713 node-releases: 2.0.14 update-browserslist-db: 1.0.13(browserslist@4.23.0) - dev: true /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -1448,13 +1436,8 @@ packages: engines: {node: '>=14.16'} dev: false - /caniuse-lite@1.0.30001554: - resolution: {integrity: sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ==} - dev: false - /caniuse-lite@1.0.30001599: resolution: {integrity: sha512-LRAQHZ4yT1+f9LemSMeqdMpMxZcc4RMWdj4tiFe3G8tNkWK+E58g+/tzotb5cU6TbcVJLr4fySiAW7XmxQvZQA==} - dev: true /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} @@ -1908,13 +1891,8 @@ packages: /eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - /electron-to-chromium@1.4.567: - resolution: {integrity: sha512-8KR114CAYQ4/r5EIEsOmOMqQ9j0MRbJZR3aXD/KFA8RuKzyoUB4XrUCg+l8RUGqTVQgKNIgTpjaG8YHRPAbX2w==} - dev: false - /electron-to-chromium@1.4.713: resolution: {integrity: sha512-vDarADhwntXiULEdmWd77g2dV6FrNGa8ecAC29MZ4TwPut2fvosD0/5sJd1qWNNe8HcJFAC+F5Lf9jW1NPtWmw==} - dev: true /emoji-regex@10.3.0: resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} @@ -1988,7 +1966,7 @@ packages: has-property-descriptors: 1.0.1 has-proto: 1.0.1 has-symbols: 1.0.3 - hasown: 2.0.0 + hasown: 2.0.2 internal-slot: 1.0.6 is-array-buffer: 3.0.2 is-callable: 1.2.7 @@ -2112,7 +2090,7 @@ packages: dependencies: get-intrinsic: 1.2.2 has-tostringtag: 1.0.0 - hasown: 2.0.0 + hasown: 2.0.2 dev: true /es-set-tostringtag@2.0.3: @@ -2127,7 +2105,7 @@ packages: /es-shim-unscopables@1.0.2: resolution: {integrity: sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==} dependencies: - hasown: 2.0.0 + hasown: 2.0.2 dev: true /es-to-primitive@1.2.1: @@ -2139,14 +2117,14 @@ packages: is-symbol: 1.0.4 dev: true - /esbuild-plugin-browserslist@0.11.1(browserslist@4.22.1)(esbuild@0.20.2): + /esbuild-plugin-browserslist@0.11.1(browserslist@4.23.0)(esbuild@0.20.2): resolution: {integrity: sha512-yNdZRdDBEbm0PT4q2bJBhXvnwakXG5mG8ipiwGe5SRDPnKa7L7kQm2tHuBMowBtcFz6kRtZTv5njK7PJwU+tCQ==} engines: {node: '>=18'} peerDependencies: browserslist: ^4.21.8 esbuild: ~0.20.0 dependencies: - browserslist: 4.22.1 + browserslist: 4.23.0 debug: 4.3.4 esbuild: 0.20.2 zod: 3.22.4 @@ -2937,7 +2915,7 @@ packages: function-bind: 1.1.2 has-proto: 1.0.1 has-symbols: 1.0.3 - hasown: 2.0.0 + hasown: 2.0.2 dev: true /get-intrinsic@1.2.4: @@ -2948,7 +2926,7 @@ packages: function-bind: 1.1.2 has-proto: 1.0.3 has-symbols: 1.0.3 - hasown: 2.0.0 + hasown: 2.0.2 dev: true /get-port-please@2.6.1: @@ -3175,18 +3153,11 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: false - /hasown@2.0.0: - resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} - engines: {node: '>= 0.4'} - dependencies: - function-bind: 1.1.2 - /hasown@2.0.2: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} dependencies: function-bind: 1.1.2 - dev: true /hosted-git-info@2.8.9: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} @@ -3401,7 +3372,7 @@ packages: engines: {node: '>= 0.4'} dependencies: get-intrinsic: 1.2.2 - hasown: 2.0.0 + hasown: 2.0.2 side-channel: 1.0.4 dev: true @@ -3410,7 +3381,7 @@ packages: engines: {node: '>= 0.4'} dependencies: es-errors: 1.3.0 - hasown: 2.0.0 + hasown: 2.0.2 side-channel: 1.0.4 dev: true @@ -3488,7 +3459,7 @@ packages: /is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} dependencies: - hasown: 2.0.0 + hasown: 2.0.2 /is-data-view@1.0.1: resolution: {integrity: sha512-AHkaJrsUVW6wq6JS8y3JnM/GJF/9cf+k20+iDzlSaJrinEo5+7vRiteOSwBhHRiAyQATN1AmY4hwzxJKPmYf+w==} @@ -4227,13 +4198,8 @@ packages: - supports-color dev: false - /node-releases@2.0.13: - resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==} - dev: false - /node-releases@2.0.14: resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==} - dev: true /nopt@6.0.0: resolution: {integrity: sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==} @@ -4750,7 +4716,7 @@ packages: lilconfig: 2.1.0 postcss: 8.4.38 ts-node: 10.9.2(@types/node@20.11.30)(typescript@5.4.3) - yaml: 2.3.3 + yaml: 2.3.4 dev: false /postcss-modules-extract-imports@3.0.0(postcss@8.4.38): @@ -5240,7 +5206,7 @@ packages: dependencies: chokidar: 3.5.3 immutable: 4.3.4 - source-map-js: 1.0.2 + source-map-js: 1.2.0 dev: false /sax@1.2.4: @@ -5420,11 +5386,6 @@ packages: smart-buffer: 4.2.0 dev: false - /source-map-js@1.0.2: - resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} - engines: {node: '>=0.10.0'} - dev: false - /source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} @@ -5743,20 +5704,20 @@ packages: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} dev: false - /tiddlywiki-plugin-dev@0.0.41(postcss@8.4.38)(ts-node@10.9.2): - resolution: {integrity: sha512-TLFCj9eJ+rgf3sKquLxxhNSnhIA8M2+MygM/PoCnJ/9WVBE7An4v17Xpw+mff41YE3geORqAed0Q/2WgnRnXLA==} + /tiddlywiki-plugin-dev@0.1.1(postcss@8.4.38)(ts-node@10.9.2): + resolution: {integrity: sha512-uTCMpYEVX4uk6n3/F7WnT520+iTJ2U2obzzSl9Y/ER2FAdstmMtKeHWMUMfRQeSkpFFrG5AcSnQCgrfpOEl2eA==} engines: {node: '>=14.17.6'} hasBin: true dependencies: autoprefixer: 10.4.16(postcss@8.4.38) - browserslist: 4.22.1 + browserslist: 4.23.0 chalk: 4.1.2 chokidar: 3.5.3 clean-css: 5.3.2 cli-progress: 3.12.0 commander: 9.5.0 esbuild: 0.20.2 - esbuild-plugin-browserslist: 0.11.1(browserslist@4.22.1)(esbuild@0.20.2) + esbuild-plugin-browserslist: 0.11.1(browserslist@4.23.0)(esbuild@0.20.2) esbuild-style-plugin: 1.6.3 get-port-please: 2.6.1 html-minifier-terser: 7.2.0 @@ -5785,6 +5746,7 @@ packages: engines: {node: '>=0.8.2'} hasBin: true dev: false + bundledDependencies: [] /tmp@0.0.33: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} @@ -6058,17 +6020,6 @@ packages: engines: {node: '>=8'} dev: false - /update-browserslist-db@1.0.13(browserslist@4.22.1): - resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} - hasBin: true - peerDependencies: - browserslist: '>= 4.21.0' - dependencies: - browserslist: 4.22.1 - escalade: 3.1.1 - picocolors: 1.0.0 - dev: false - /update-browserslist-db@1.0.13(browserslist@4.23.0): resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} hasBin: true @@ -6078,7 +6029,6 @@ packages: browserslist: 4.23.0 escalade: 3.1.1 picocolors: 1.0.0 - dev: true /update-notifier@6.0.2: resolution: {integrity: sha512-EDxhTEVPZZRLWYcJ4ZXjGFN0oP7qYvbXWzEgRm/Yql4dHX5wDbvh89YHP6PK1lzZJYrMtXUuZZz8XGK+U6U1og==} @@ -6287,15 +6237,9 @@ packages: /yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - /yaml@2.3.3: - resolution: {integrity: sha512-zw0VAJxgeZ6+++/su5AFoqBbZbrEakwu+X0M5HmcwUiBL7AzcuPKjj5we4xfQLp78LkEMpD0cOnUhmgOVy3KdQ==} - engines: {node: '>= 14'} - dev: false - /yaml@2.3.4: resolution: {integrity: sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==} engines: {node: '>= 14'} - dev: true /yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} diff --git a/src/doc/tutorials/en/007-commands.tid b/src/doc/tutorials/en/007-commands.tid index 6f2afad..88c68a7 100644 --- a/src/doc/tutorials/en/007-commands.tid +++ b/src/doc/tutorials/en/007-commands.tid @@ -37,6 +37,24 @@ npm run dev After a short compilation, a web server will open and a browser will open it to see the effect. The page will be automatically recompiled and refreshed as the content of the plugin is modified. +This page is read-only, changes to it are not written back to the wiki folder, so feel free to modify it to debug. + +!! Entering documentation writing mode + +```bash +npm run dev:wiki +``` + +The page started is an editable page that allows you to edit the contents of the wiki folder directly. + +!! Running tests + +```bash +npm run test +``` + +See [[012-About debugging|$:/plugins/Modern.TiddlyDev/doc/tutorials/en/012-关于调试]] for details. + !! Building plugins There are two forms. diff --git a/src/doc/tutorials/en/012-About debugging.tid b/src/doc/tutorials/en/012-About debugging.tid index 31a1f87..6e11fe2 100644 --- a/src/doc/tutorials/en/012-About debugging.tid +++ b/src/doc/tutorials/en/012-About debugging.tid @@ -3,7 +3,7 @@ caption: About debugging authors: whitefall type: text/vnd.tiddlywiki -Q: How friendly is debugging? I generally prefer to play with the idea of finding the value, depending on the result, see what he is, in the next step, and then implement it step by step. +!! Q: How friendly is debugging? I generally prefer to play with the idea of finding the value, depending on the result, see what he is, in the next step, and then implement it step by step. A: Use the console more often: @@ -12,4 +12,17 @@ A: Use the console more often: * But it should be noted that the environment you usually write widgets in is a sandbox not a browser environment (you can understand that some global variables you can't get, or some variables are only available inside), this should be noted. -A: Use debugger debugging statements. \ No newline at end of file +A: Use debugger debugging statements. + +!! Q: How do I write tests? + +You can write tests in the `wiki/tiddlers/tests` folder, or you can write them in your plugin folder, as long as the meta file contains them: + +```tid +type: application/javascript +tags: $:/tags/test-spec +``` + +The `$:/tags/test-spec` tag will mark this tiddler as a test and will be executed when you run `pnpm run test`. + +Note that writing tests in the `wiki/tiddlers/tests` folder can only be done with JS; writing tests in plugins can be done with TS, but the tests will be packaged into the plugin, increasing its size. diff --git a/src/doc/tutorials/zh/007-commands.tid b/src/doc/tutorials/zh/007-commands.tid index af0eea6..e233ebc 100644 --- a/src/doc/tutorials/zh/007-commands.tid +++ b/src/doc/tutorials/zh/007-commands.tid @@ -37,6 +37,24 @@ npm run dev 经过短暂编译后,会打开一个网页服务器,浏览器打开之可以看到效果。页面会随着插件内容的修改自动重新编译、刷新。 +这个页面是只读的,对它的修改不会写回到 wiki 文件夹,可以随意调试。 + +!! 进入文档编写模式 + +```bash +npm run dev:wiki +``` + +启动的页面是可编辑的页面,可以直接编辑 wiki 文件夹中的内容。 + +!! 运行自动化测试 + +```bash +npm run test +``` + +详见[[012-关于调试|$:/plugins/Modern.TiddlyDev/doc/tutorials/zh/012-关于调试]]。 + !! 构建插件 有两种形式: diff --git "a/src/doc/tutorials/zh/012-\345\205\263\344\272\216\350\260\203\350\257\225.tid" "b/src/doc/tutorials/zh/012-\345\205\263\344\272\216\350\260\203\350\257\225.tid" index 67d9f6a..33fe2b1 100644 --- "a/src/doc/tutorials/zh/012-\345\205\263\344\272\216\350\260\203\350\257\225.tid" +++ "b/src/doc/tutorials/zh/012-\345\205\263\344\272\216\350\260\203\350\257\225.tid" @@ -3,7 +3,7 @@ caption: 关于调试 authors: whitefall type: text/vnd.tiddlywiki -Q:如何友好的调试呢?我一般比较喜欢用求值的思维玩,根据求得的结果,看看他是什么,在进行下一步,然后一步步实现它。 +!! Q:如何友好的调试呢?我一般比较喜欢用求值的思维玩,根据求得的结果,看看他是什么,在进行下一步,然后一步步实现它。 A:多用控制台: @@ -12,4 +12,17 @@ A:多用控制台: * 但需要注意的是,你平时写widget的那个环境是沙盒并非浏览器环境(你可以理解成有些全局变量你拿不到,或者有些变量只有里面才能拿到),这个要注意。 -A:使用debugger调试语句。 \ No newline at end of file +A:使用debugger调试语句。 + +!! Q:如何写测试呢? + +你可以在 `wiki/tiddlers/tests` 文件夹里写测试,也可以在插件里写,只要 meta 文件里包含这些即可: + +```tid +type: application/javascript +tags: $:/tags/test-spec +``` + +`$:/tags/test-spec` 标签会将这个条目标记为测试,并在你执行 `pnpm run test` 的时候被执行。 + +注意在 `wiki/tiddlers/tests` 文件夹里写测试只能用 JS;在插件里写测试可以用 TS 但是测试会被打包进插件,增大插件体积。 diff --git a/wiki/tiddlers/tests/example/filters.js b/wiki/tiddlers/tests/example/filters.js new file mode 100644 index 0000000..6f108e7 --- /dev/null +++ b/wiki/tiddlers/tests/example/filters.js @@ -0,0 +1,8 @@ +describe('Filter tests', function() { + // Test copy from https://github.com/Jermolene/TiddlyWiki5/blob/31ec1bdd50ce7fa58e4e2c8701106bd809c47dc3/editions/test/tiddlers/tests/test-filters.js + it('should parse new-style rich operator suffixes', function() { + expect($tw.wiki.parseFilter('[search:: four, , five,, six [operand]]')).toEqual( + [{ prefix: '', operators: [{ operator: 'search', suffix: ': four, , five,, six ', suffixes: [[], ['four', 'five', 'six']], operands: [{ text: 'operand' }] }] }], + ); + }); +}); diff --git a/wiki/tiddlers/tests/example/filters.js.meta b/wiki/tiddlers/tests/example/filters.js.meta new file mode 100644 index 0000000..abd9200 --- /dev/null +++ b/wiki/tiddlers/tests/example/filters.js.meta @@ -0,0 +1,3 @@ +title: tests/example/test-filters.js +type: application/javascript +tags: $:/tags/test-spec \ No newline at end of file