@mnaoumov/create-obsidian-plugin 0.0.0-stage → 1.0.0

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.
Files changed (470) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +341 -2
  3. package/dist/main.js +4184 -0
  4. package/package.json +78 -4
  5. package/src/main.ts +650 -0
  6. package/templates/default/.depcheckrc.json.ejs +19 -0
  7. package/templates/default/.editorconfig.ejs +11 -0
  8. package/templates/default/.env.ejs +1 -0
  9. package/templates/default/.env@vault_has-vault-false.ejs +2 -0
  10. package/templates/default/.env@vault_has-vault-true.ejs +1 -0
  11. package/templates/default/.gitattributes.ejs +7 -0
  12. package/templates/default/.github/FUNDING.yml.ejs +3 -0
  13. package/templates/default/.github/ISSUE_TEMPLATE/bug_report.yml.ejs +71 -0
  14. package/templates/default/.github/ISSUE_TEMPLATE/config.yml.ejs +1 -0
  15. package/templates/default/.github/ISSUE_TEMPLATE/feature_request.yml.ejs +61 -0
  16. package/templates/default/.github/workflows/attest-release-assets.yml.ejs +24 -0
  17. package/templates/default/.github/workflows/ci.yml.ejs +20 -0
  18. package/templates/default/.github/workflows/ci.yml@steps_biome-linter.ejs +1 -0
  19. package/templates/default/.github/workflows/ci.yml@steps_cspell.ejs +1 -0
  20. package/templates/default/.github/workflows/ci.yml@steps_dprint.ejs +1 -0
  21. package/templates/default/.github/workflows/ci.yml@steps_eslint.ejs +1 -0
  22. package/templates/default/.github/workflows/ci.yml@steps_jest.ejs +1 -0
  23. package/templates/default/.github/workflows/ci.yml@steps_markdownlint.ejs +1 -0
  24. package/templates/default/.github/workflows/ci.yml@steps_prettier.ejs +1 -0
  25. package/templates/default/.github/workflows/ci.yml@steps_vitest.ejs +1 -0
  26. package/templates/default/.github/workflows/release.yml.ejs +27 -0
  27. package/templates/default/.github/workflows/update-license-year.yml.ejs +38 -0
  28. package/templates/default/.gitignore_common.ejs +27 -0
  29. package/templates/default/.gitignore_scss.ejs +1 -0
  30. package/templates/default/.gitignore_tailwind.ejs +3 -0
  31. package/templates/default/.husky/commit-msg.ejs +1 -0
  32. package/templates/default/.husky/pre-commit.ejs +1 -0
  33. package/templates/default/.markdownlint-cli2.mjs.ejs +4 -0
  34. package/templates/default/.nano-staged.mjs.ejs +5 -0
  35. package/templates/default/.npmrc.ejs +1 -0
  36. package/templates/default/.parcelrc.ejs +9 -0
  37. package/templates/default/.parcelrc@transformers_svelte.ejs +1 -0
  38. package/templates/default/.prettierignore.ejs +10 -0
  39. package/templates/default/.typesafe-i18n.json.ejs +5 -0
  40. package/templates/default/CONTRIBUTING.md.ejs +49 -0
  41. package/templates/default/CONTRIBUTING.md@demo-vault_dev-utils.ejs +15 -0
  42. package/templates/default/CONTRIBUTING.md@scripts_biome-formatter.ejs +1 -0
  43. package/templates/default/CONTRIBUTING.md@scripts_biome-linter.ejs +1 -0
  44. package/templates/default/CONTRIBUTING.md@scripts_conventional-commits.ejs +1 -0
  45. package/templates/default/CONTRIBUTING.md@scripts_cspell.ejs +1 -0
  46. package/templates/default/CONTRIBUTING.md@scripts_dev-utils.ejs +1 -0
  47. package/templates/default/CONTRIBUTING.md@scripts_dprint.ejs +1 -0
  48. package/templates/default/CONTRIBUTING.md@scripts_eslint.ejs +1 -0
  49. package/templates/default/CONTRIBUTING.md@scripts_jest.ejs +1 -0
  50. package/templates/default/CONTRIBUTING.md@scripts_markdownlint.ejs +1 -0
  51. package/templates/default/CONTRIBUTING.md@scripts_prettier.ejs +1 -0
  52. package/templates/default/CONTRIBUTING.md@scripts_vitest.ejs +1 -0
  53. package/templates/default/LICENSE.ejs +21 -0
  54. package/templates/default/README.md.ejs +28 -0
  55. package/templates/default/README.md@demo-vault_dev-utils.ejs +12 -0
  56. package/templates/default/README.md@preset_dev-utils.ejs +12 -0
  57. package/templates/default/README.md@support_has-funding.ejs +8 -0
  58. package/templates/default/babel.config.json.ejs +8 -0
  59. package/templates/default/babel.config.mjs.ejs +5 -0
  60. package/templates/default/biome.jsonc.ejs +47 -0
  61. package/templates/default/commitlint.config.ts.ejs +1 -0
  62. package/templates/default/cspell.json.ejs +67 -0
  63. package/templates/default/demo-vault/.gitignore.ejs +15 -0
  64. package/templates/default/demo-vault/.obsidian/app.json.ejs +4 -0
  65. package/templates/default/demo-vault/.obsidian/community-plugins.json.ejs +4 -0
  66. package/templates/default/demo-vault/00 Start.md.ejs +32 -0
  67. package/templates/default/demo-vault/00 Start.md@features_wasm.ejs +1 -0
  68. package/templates/default/demo-vault/01 Sample commands.md.ejs +38 -0
  69. package/templates/default/demo-vault/01 Sample commands.md@commands_wasm.ejs +4 -0
  70. package/templates/default/demo-vault/02 Settings.md.ejs +40 -0
  71. package/templates/default/demo-vault/03 WebAssembly.md.ejs +34 -0
  72. package/templates/default/demo-vault/Materials/01 Sample commands/Scratch note.md.ejs +5 -0
  73. package/templates/default/demo-vault/README.md.ejs +10 -0
  74. package/templates/default/demo-vault/_assets/CodeScriptToolkit/demoSetup.ts.ejs +88 -0
  75. package/templates/default/demo-vault/_assets/CodeScriptToolkit/demoSetup.ts@commands_wasm.ejs +10 -0
  76. package/templates/default/demo-vault/_assets/CodeScriptToolkit/startup.ts.ejs +17 -0
  77. package/templates/default/dprint.json_dev-utils.ejs +10 -0
  78. package/templates/default/dprint.json_standalone.ejs +26 -0
  79. package/templates/default/e2e/sample.spec.ts_obsidian-test.ejs +16 -0
  80. package/templates/default/e2e/sample.spec.ts_obsidian-test@lint-no-void-disable_dev-utils.ejs +3 -0
  81. package/templates/default/e2e/sample.spec.ts_obsidian-test@lint-no-void-enable_dev-utils.ejs +1 -0
  82. package/templates/default/e2e/sample.spec.ts_obsidian-test@unofficial_with-unofficial.ejs +13 -0
  83. package/templates/default/e2e/sample.spec.ts_wdio-obsidian.ejs +7 -0
  84. package/templates/default/e2e/sample.spec.ts_wdio-obsidian@unofficial_with-unofficial.ejs +15 -0
  85. package/templates/default/eslint.config.mts_dev-utils.ejs +1 -0
  86. package/templates/default/eslint.config.mts_standalone.ejs +119 -0
  87. package/templates/default/eslint.config.mts_standalone@extra-files_has-e2e.ejs +2 -0
  88. package/templates/default/jest.config.ts.ejs +57 -0
  89. package/templates/default/jest.config.ts@lint-root-dir_dev-utils.ejs +1 -0
  90. package/templates/default/jest.config.ts@ts-jest-tsconfig_solid.ejs +8 -0
  91. package/templates/default/linkinator.config.json.ejs +11 -0
  92. package/templates/default/manifest.json.ejs +11 -0
  93. package/templates/default/manifest.json@funding_has-funding.ejs +1 -0
  94. package/templates/default/manifest.json@platform_desktop-and-mobile.ejs +1 -0
  95. package/templates/default/manifest.json@platform_desktop-only.ejs +1 -0
  96. package/templates/default/package.json.ejs +32 -0
  97. package/templates/default/package.json@targets_parcel.ejs +36 -0
  98. package/templates/default/parcel-namer-obsidian.cjs.ejs +26 -0
  99. package/templates/default/parcel-resolver-obsidian.cjs.ejs +37 -0
  100. package/templates/default/parcel-transformer-inline-imports.cjs.ejs +39 -0
  101. package/templates/default/parcel-transformer-svelte.cjs.ejs +67 -0
  102. package/templates/default/pinned-versions.json.ejs +1 -0
  103. package/templates/default/pnpm-workspace.yaml.ejs +19 -0
  104. package/templates/default/postcss.config.cjs.ejs +12 -0
  105. package/templates/default/prettier.config.mjs.ejs +5 -0
  106. package/templates/default/rollup.config.mjs.ejs +7 -0
  107. package/templates/default/scripts/babel.config.ts_rollup.ejs +16 -0
  108. package/templates/default/scripts/babel.config.ts_rollup@babel-plugin_preact.ejs +1 -0
  109. package/templates/default/scripts/babel.config.ts_rollup@babel-preset_react.ejs +1 -0
  110. package/templates/default/scripts/babel.config.ts_rollup@babel-preset_solid.ejs +1 -0
  111. package/templates/default/scripts/build-clean.ts.ejs +4 -0
  112. package/templates/default/scripts/build-compile.ts.ejs +4 -0
  113. package/templates/default/scripts/build-styles.ts.ejs +12 -0
  114. package/templates/default/scripts/build.ts.ejs +6 -0
  115. package/templates/default/scripts/build.ts@bundler_cli-bundler.ejs +63 -0
  116. package/templates/default/scripts/build.ts@bundler_cli-bundler@compile_svelte.ejs +4 -0
  117. package/templates/default/scripts/build.ts@bundler_cli-bundler@fs-import_hot-reload-plugin.ejs +2 -0
  118. package/templates/default/scripts/build.ts@bundler_cli-bundler@hot-reload_hot-reload-plugin.ejs +3 -0
  119. package/templates/default/scripts/build.ts@bundler_cli-bundler@import_tailwind.ejs +2 -0
  120. package/templates/default/scripts/build.ts@bundler_cli-bundler@lint-build-styles_dev-utils.ejs +1 -0
  121. package/templates/default/scripts/build.ts@bundler_cli-bundler@reload_obsidian-cli.ejs +5 -0
  122. package/templates/default/scripts/build.ts@bundler_cli-bundler@run_parcel.ejs +1 -0
  123. package/templates/default/scripts/build.ts@bundler_cli-bundler@run_rollup.ejs +1 -0
  124. package/templates/default/scripts/build.ts@bundler_cli-bundler@run_vite.ejs +1 -0
  125. package/templates/default/scripts/build.ts@bundler_cli-bundler@run_webpack.ejs +1 -0
  126. package/templates/default/scripts/build.ts@bundler_esbuild.ejs +3 -0
  127. package/templates/default/scripts/build.ts@bundler_esbuild@compile_svelte.ejs +4 -0
  128. package/templates/default/scripts/build.ts@bundler_esbuild@dev-utils-pre-build_tailwind.ejs +2 -0
  129. package/templates/default/scripts/build.ts@bundler_esbuild@fs-import_hot-reload-plugin.ejs +2 -0
  130. package/templates/default/scripts/build.ts@bundler_esbuild@hot-reload_hot-reload-plugin.ejs +4 -0
  131. package/templates/default/scripts/build.ts@bundler_esbuild@import_postcss.ejs +1 -0
  132. package/templates/default/scripts/build.ts@bundler_esbuild@import_scss.ejs +1 -0
  133. package/templates/default/scripts/build.ts@bundler_esbuild@import_solid.ejs +1 -0
  134. package/templates/default/scripts/build.ts@bundler_esbuild@import_svelte.ejs +10 -0
  135. package/templates/default/scripts/build.ts@bundler_esbuild@import_tailwind.ejs +1 -0
  136. package/templates/default/scripts/build.ts@bundler_esbuild@import_vue.ejs +1 -0
  137. package/templates/default/scripts/build.ts@bundler_esbuild@lint-build-styles_dev-utils.ejs +1 -0
  138. package/templates/default/scripts/build.ts@bundler_esbuild@options_preact.ejs +2 -0
  139. package/templates/default/scripts/build.ts@bundler_esbuild@options_react.ejs +1 -0
  140. package/templates/default/scripts/build.ts@bundler_esbuild@options_wasm.ejs +5 -0
  141. package/templates/default/scripts/build.ts@bundler_esbuild@plugin_postcss.ejs +1 -0
  142. package/templates/default/scripts/build.ts@bundler_esbuild@plugin_scss.ejs +1 -0
  143. package/templates/default/scripts/build.ts@bundler_esbuild@plugin_solid.ejs +1 -0
  144. package/templates/default/scripts/build.ts@bundler_esbuild@plugin_svelte.ejs +5 -0
  145. package/templates/default/scripts/build.ts@bundler_esbuild@plugin_vue.ejs +1 -0
  146. package/templates/default/scripts/build.ts@bundler_esbuild@preset_dev-utils.ejs +7 -0
  147. package/templates/default/scripts/build.ts@bundler_esbuild@preset_standalone.ejs +138 -0
  148. package/templates/default/scripts/build.ts@bundler_esbuild@reload_obsidian-cli.ejs +6 -0
  149. package/templates/default/scripts/commit.ts_dev-utils.ejs +3 -0
  150. package/templates/default/scripts/commit.ts_standalone.ejs +3 -0
  151. package/templates/default/scripts/commitlint-config.ts.ejs +5 -0
  152. package/templates/default/scripts/demo-vault-global-setup.ts.ejs +43 -0
  153. package/templates/default/scripts/dev.ts.ejs +6 -0
  154. package/templates/default/scripts/dev.ts@bundler_cli-bundler.ejs +8 -0
  155. package/templates/default/scripts/dev.ts@bundler_esbuild.ejs +3 -0
  156. package/templates/default/scripts/dev.ts@bundler_esbuild@dev-utils-pre-build_tailwind.ejs +2 -0
  157. package/templates/default/scripts/dev.ts@bundler_esbuild@lint-build-styles_dev-utils.ejs +1 -0
  158. package/templates/default/scripts/dev.ts@bundler_esbuild@preset_dev-utils.ejs +7 -0
  159. package/templates/default/scripts/dev.ts@bundler_esbuild@preset_standalone.ejs +3 -0
  160. package/templates/default/scripts/esbuild-plugins.ts.ejs +20 -0
  161. package/templates/default/scripts/esbuild-plugins.ts@dev-utils-import_vue.ejs +2 -0
  162. package/templates/default/scripts/esbuild-plugins.ts@dev-utils-plugin_vue.ejs +1 -0
  163. package/templates/default/scripts/esbuild-plugins.ts@dev-utils-plugin_wasm.ejs +13 -0
  164. package/templates/default/scripts/eslint-config.ts.ejs +113 -0
  165. package/templates/default/scripts/eslint-config.ts@extra-files_has-e2e.ejs +7 -0
  166. package/templates/default/scripts/find-overexposed-fix.ts.ejs +26 -0
  167. package/templates/default/scripts/find-overexposed.ts.ejs +15 -0
  168. package/templates/default/scripts/format-check.ts.ejs +4 -0
  169. package/templates/default/scripts/format-check.ts@tool_biome-formatter.ejs +8 -0
  170. package/templates/default/scripts/format-check.ts@tool_dprint.ejs +3 -0
  171. package/templates/default/scripts/format-check.ts@tool_dprint@preset_dev-utils.ejs +7 -0
  172. package/templates/default/scripts/format-check.ts@tool_dprint@preset_standalone.ejs +8 -0
  173. package/templates/default/scripts/format-check.ts@tool_prettier.ejs +8 -0
  174. package/templates/default/scripts/format.ts.ejs +4 -0
  175. package/templates/default/scripts/format.ts@tool_biome-formatter.ejs +8 -0
  176. package/templates/default/scripts/format.ts@tool_dprint.ejs +3 -0
  177. package/templates/default/scripts/format.ts@tool_dprint@preset_dev-utils.ejs +7 -0
  178. package/templates/default/scripts/format.ts@tool_dprint@preset_standalone.ejs +8 -0
  179. package/templates/default/scripts/format.ts@tool_prettier.ejs +8 -0
  180. package/templates/default/scripts/framework-component-stub.ts.ejs +46 -0
  181. package/templates/default/scripts/gate.ts.ejs +10 -0
  182. package/templates/default/scripts/lint-fix.ts.ejs +6 -0
  183. package/templates/default/scripts/lint-fix.ts@tool_biome-linter.ejs +8 -0
  184. package/templates/default/scripts/lint-fix.ts@tool_eslint.ejs +3 -0
  185. package/templates/default/scripts/lint-fix.ts@tool_eslint@preset_dev-utils.ejs +7 -0
  186. package/templates/default/scripts/lint-fix.ts@tool_eslint@preset_standalone.ejs +8 -0
  187. package/templates/default/scripts/lint-md-fix.ts_dev-utils.ejs +7 -0
  188. package/templates/default/scripts/lint-md-fix.ts_standalone.ejs +37 -0
  189. package/templates/default/scripts/lint-md.ts_dev-utils.ejs +7 -0
  190. package/templates/default/scripts/lint-md.ts_standalone.ejs +37 -0
  191. package/templates/default/scripts/lint.ts.ejs +6 -0
  192. package/templates/default/scripts/lint.ts@tool_biome-linter.ejs +8 -0
  193. package/templates/default/scripts/lint.ts@tool_eslint.ejs +3 -0
  194. package/templates/default/scripts/lint.ts@tool_eslint@preset_dev-utils.ejs +7 -0
  195. package/templates/default/scripts/lint.ts@tool_eslint@preset_standalone.ejs +8 -0
  196. package/templates/default/scripts/markdownlint-cli2-config.ts_dev-utils.ejs +14 -0
  197. package/templates/default/scripts/markdownlint-cli2-config.ts_standalone.ejs +36 -0
  198. package/templates/default/scripts/nano-staged-config.ts.ejs +9 -0
  199. package/templates/default/scripts/postcss.config.ts.ejs +1 -0
  200. package/templates/default/scripts/postcss.config.ts@plugins_postcss.ejs +7 -0
  201. package/templates/default/scripts/prepare.ts_dev-utils.ejs +3 -0
  202. package/templates/default/scripts/prepare.ts_standalone.ejs +3 -0
  203. package/templates/default/scripts/prettier.config.ts.ejs +12 -0
  204. package/templates/default/scripts/rollup.config.ts.ejs +129 -0
  205. package/templates/default/scripts/rollup.config.ts@import_rollup-babel.ejs +5 -0
  206. package/templates/default/scripts/rollup.config.ts@import_rollup-json.ejs +1 -0
  207. package/templates/default/scripts/rollup.config.ts@import_rollup-postcss.ejs +4 -0
  208. package/templates/default/scripts/rollup.config.ts@import_scss.ejs +1 -0
  209. package/templates/default/scripts/rollup.config.ts@import_svelte.ejs +2 -0
  210. package/templates/default/scripts/rollup.config.ts@import_vue.ejs +1 -0
  211. package/templates/default/scripts/rollup.config.ts@import_wasm.ejs +1 -0
  212. package/templates/default/scripts/rollup.config.ts@lint-out-dir_dev-utils.ejs +1 -0
  213. package/templates/default/scripts/rollup.config.ts@post-plugin_preact.ejs +4 -0
  214. package/templates/default/scripts/rollup.config.ts@post-plugin_react.ejs +5 -0
  215. package/templates/default/scripts/rollup.config.ts@post-plugin_rollup-json.ejs +1 -0
  216. package/templates/default/scripts/rollup.config.ts@post-plugin_rollup-postcss.ejs +4 -0
  217. package/templates/default/scripts/rollup.config.ts@post-plugin_scss.ejs +4 -0
  218. package/templates/default/scripts/rollup.config.ts@post-plugin_solid.ejs +4 -0
  219. package/templates/default/scripts/rollup.config.ts@post-plugin_wasm.ejs +4 -0
  220. package/templates/default/scripts/rollup.config.ts@pre-plugin_svelte.ejs +4 -0
  221. package/templates/default/scripts/rollup.config.ts@pre-plugin_vue.ejs +13 -0
  222. package/templates/default/scripts/rollup.config.ts@unwrap_rollup-babel.ejs +1 -0
  223. package/templates/default/scripts/rollup.config.ts@unwrap_rollup-json.ejs +1 -0
  224. package/templates/default/scripts/rollup.config.ts@unwrap_rollup-postcss.ejs +1 -0
  225. package/templates/default/scripts/rollup.config.ts@unwrap_scss.ejs +1 -0
  226. package/templates/default/scripts/rollup.config.ts@unwrap_svelte.ejs +1 -0
  227. package/templates/default/scripts/rollup.config.ts@unwrap_vue.ejs +1 -0
  228. package/templates/default/scripts/rollup.config.ts@unwrap_wasm.ejs +1 -0
  229. package/templates/default/scripts/spellcheck.ts_dev-utils.ejs +7 -0
  230. package/templates/default/scripts/spellcheck.ts_standalone.ejs +8 -0
  231. package/templates/default/scripts/stylesheet-stub.ts.ejs +17 -0
  232. package/templates/default/scripts/test-coverage.ts.ejs +8 -0
  233. package/templates/default/scripts/test-e2e.ts.ejs +1 -0
  234. package/templates/default/scripts/test-e2e.ts@tool_obsidian-test.ejs +8 -0
  235. package/templates/default/scripts/test-e2e.ts@tool_wdio-obsidian.ejs +8 -0
  236. package/templates/default/scripts/test-integration-android.ts.ejs +8 -0
  237. package/templates/default/scripts/test-integration-demo-vault.ts.ejs +8 -0
  238. package/templates/default/scripts/test-integration-desktop-performance.ts.ejs +8 -0
  239. package/templates/default/scripts/test-integration-desktop.ts.ejs +8 -0
  240. package/templates/default/scripts/test-integration-no-app.ts.ejs +8 -0
  241. package/templates/default/scripts/test-integration.ts.ejs +22 -0
  242. package/templates/default/scripts/test-watch.ts_dev-utils.ejs +1 -0
  243. package/templates/default/scripts/test-watch.ts_dev-utils@tool_jest.ejs +13 -0
  244. package/templates/default/scripts/test-watch.ts_dev-utils@tool_vitest.ejs +8 -0
  245. package/templates/default/scripts/test-watch.ts_standalone.ejs +1 -0
  246. package/templates/default/scripts/test-watch.ts_standalone@tool_jest.ejs +13 -0
  247. package/templates/default/scripts/test-watch.ts_standalone@tool_vitest.ejs +8 -0
  248. package/templates/default/scripts/test.ts_dev-utils.ejs +1 -0
  249. package/templates/default/scripts/test.ts_dev-utils@tool_jest.ejs +13 -0
  250. package/templates/default/scripts/test.ts_dev-utils@tool_vitest.ejs +8 -0
  251. package/templates/default/scripts/test.ts_standalone.ejs +1 -0
  252. package/templates/default/scripts/test.ts_standalone@tool_jest.ejs +13 -0
  253. package/templates/default/scripts/test.ts_standalone@tool_vitest.ejs +8 -0
  254. package/templates/default/scripts/version.ts_dev-utils.ejs +10 -0
  255. package/templates/default/scripts/version.ts_standalone.ejs +317 -0
  256. package/templates/default/scripts/vite.config.ts.ejs +76 -0
  257. package/templates/default/scripts/vite.config.ts@import_preact.ejs +1 -0
  258. package/templates/default/scripts/vite.config.ts@import_react.ejs +1 -0
  259. package/templates/default/scripts/vite.config.ts@import_solid.ejs +1 -0
  260. package/templates/default/scripts/vite.config.ts@import_svelte.ejs +1 -0
  261. package/templates/default/scripts/vite.config.ts@import_vue.ejs +1 -0
  262. package/templates/default/scripts/vite.config.ts@lint-empty-out-dir_dev-utils.ejs +1 -0
  263. package/templates/default/scripts/vite.config.ts@lint-out-dir_dev-utils.ejs +1 -0
  264. package/templates/default/scripts/vite.config.ts@plugin_preact.ejs +1 -0
  265. package/templates/default/scripts/vite.config.ts@plugin_react.ejs +1 -0
  266. package/templates/default/scripts/vite.config.ts@plugin_solid.ejs +1 -0
  267. package/templates/default/scripts/vite.config.ts@plugin_svelte.ejs +1 -0
  268. package/templates/default/scripts/vite.config.ts@plugin_vue.ejs +1 -0
  269. package/templates/default/scripts/vitest-config.ts.ejs +75 -0
  270. package/templates/default/scripts/vitest-config.ts@post-config_solid.ejs +67 -0
  271. package/templates/default/scripts/wasm-module-stub.ts.ejs +21 -0
  272. package/templates/default/scripts/webpack.config.ts.ejs +124 -0
  273. package/templates/default/scripts/webpack.config.ts@import_svelte.ejs +1 -0
  274. package/templates/default/scripts/webpack.config.ts@import_vue.ejs +1 -0
  275. package/templates/default/scripts/webpack.config.ts@import_webpack-css-extract.ejs +4 -0
  276. package/templates/default/scripts/webpack.config.ts@lint-webpack-default_dev-utils.ejs +1 -0
  277. package/templates/default/scripts/webpack.config.ts@plugin_vue.ejs +1 -0
  278. package/templates/default/scripts/webpack.config.ts@plugin_webpack-css-extract.ejs +4 -0
  279. package/templates/default/scripts/webpack.config.ts@rule_css-modules.ejs +7 -0
  280. package/templates/default/scripts/webpack.config.ts@rule_css.ejs +4 -0
  281. package/templates/default/scripts/webpack.config.ts@rule_postcss.ejs +4 -0
  282. package/templates/default/scripts/webpack.config.ts@rule_scss.ejs +4 -0
  283. package/templates/default/scripts/webpack.config.ts@rule_solid.ejs +17 -0
  284. package/templates/default/scripts/webpack.config.ts@rule_svelte.ejs +7 -0
  285. package/templates/default/scripts/webpack.config.ts@rule_tailwind.ejs +4 -0
  286. package/templates/default/scripts/webpack.config.ts@rule_vue.ejs +4 -0
  287. package/templates/default/scripts/webpack.config.ts@rule_wasm.ejs +8 -0
  288. package/templates/default/scripts/webpack.config.ts@ts-loader-compiler-options_vue.ejs +5 -0
  289. package/templates/default/scripts/webpack.config.ts@ts-loader-options_vue.ejs +5 -0
  290. package/templates/default/src/demo-vault-buttons.demo-vault.integration.test.ts.ejs +12 -0
  291. package/templates/default/src/demo-vault.no-app.integration.test.ts.ejs +18 -0
  292. package/templates/default/src/editor-extensions/sample-state-field.ts_dev-utils.ejs +56 -0
  293. package/templates/default/src/editor-extensions/sample-state-field.ts_standalone.ejs +60 -0
  294. package/templates/default/src/editor-extensions/sample-view-plugin.ts.ejs +66 -0
  295. package/templates/default/src/editor-extensions/sample-widget.ts.ejs +22 -0
  296. package/templates/default/src/editor-suggests/sample-editor-suggest.ts.ejs +42 -0
  297. package/templates/default/src/i18n/en/index.ts.ejs +10 -0
  298. package/templates/default/src/i18n/index.ts_i18next.ejs +21 -0
  299. package/templates/default/src/i18n/index.ts_typesafe-i18n.ejs +14 -0
  300. package/templates/default/src/i18n/locales/en.json.ejs +3 -0
  301. package/templates/default/src/lit-elements/sample-lit-element.ts.ejs +54 -0
  302. package/templates/default/src/main.test.ts.ejs +11 -0
  303. package/templates/default/src/main.test.ts@test-imports_vitest.ejs +6 -0
  304. package/templates/default/src/main.ts.ejs +4 -0
  305. package/templates/default/src/main.ts@import_css-modules.ejs +1 -0
  306. package/templates/default/src/main.ts@import_css.ejs +1 -0
  307. package/templates/default/src/main.ts@import_postcss.ejs +1 -0
  308. package/templates/default/src/main.ts@import_scss.ejs +1 -0
  309. package/templates/default/src/main.ts@import_tailwind.ejs +1 -0
  310. package/templates/default/src/modals/sample-form-modal.ts.ejs +35 -0
  311. package/templates/default/src/modals/sample-suggest-modal.ts.ejs +37 -0
  312. package/templates/default/src/plugin-settings-component.test.ts_demo.ejs +49 -0
  313. package/templates/default/src/plugin-settings-component.test.ts_demo@test-imports_vitest.ejs +5 -0
  314. package/templates/default/src/plugin-settings-component.test.ts_enhanced.ejs +41 -0
  315. package/templates/default/src/plugin-settings-component.test.ts_enhanced@test-imports_vitest.ejs +5 -0
  316. package/templates/default/src/plugin-settings-component.ts_demo.ejs +87 -0
  317. package/templates/default/src/plugin-settings-component.ts_enhanced.ejs +27 -0
  318. package/templates/default/src/plugin-settings-tab.ts_demo.ejs +286 -0
  319. package/templates/default/src/plugin-settings-tab.ts_enhanced.ejs +26 -0
  320. package/templates/default/src/plugin-settings.test.ts_demo.ejs +14 -0
  321. package/templates/default/src/plugin-settings.test.ts_demo@test-imports_vitest.ejs +6 -0
  322. package/templates/default/src/plugin-settings.ts_demo.ejs +64 -0
  323. package/templates/default/src/plugin-settings.ts_enhanced.ejs +3 -0
  324. package/templates/default/src/plugin.test.ts_jest.ejs +9 -0
  325. package/templates/default/src/plugin.test.ts_vitest.ejs +14 -0
  326. package/templates/default/src/plugin.ts_demo.ejs +316 -0
  327. package/templates/default/src/plugin.ts_demo@import_i18next.ejs +1 -0
  328. package/templates/default/src/plugin.ts_demo@import_lit.ejs +4 -0
  329. package/templates/default/src/plugin.ts_demo@import_preact.ejs +4 -0
  330. package/templates/default/src/plugin.ts_demo@import_react.ejs +4 -0
  331. package/templates/default/src/plugin.ts_demo@import_solid.ejs +4 -0
  332. package/templates/default/src/plugin.ts_demo@import_svelte.ejs +4 -0
  333. package/templates/default/src/plugin.ts_demo@import_typesafe-i18n.ejs +1 -0
  334. package/templates/default/src/plugin.ts_demo@import_vue.ejs +4 -0
  335. package/templates/default/src/plugin.ts_demo@import_wasm.ejs +1 -0
  336. package/templates/default/src/plugin.ts_demo@method_ui-view.ejs +7 -0
  337. package/templates/default/src/plugin.ts_demo@onload_i18next.ejs +2 -0
  338. package/templates/default/src/plugin.ts_demo@onload_lit.ejs +4 -0
  339. package/templates/default/src/plugin.ts_demo@onload_preact.ejs +4 -0
  340. package/templates/default/src/plugin.ts_demo@onload_react.ejs +4 -0
  341. package/templates/default/src/plugin.ts_demo@onload_solid.ejs +4 -0
  342. package/templates/default/src/plugin.ts_demo@onload_svelte.ejs +4 -0
  343. package/templates/default/src/plugin.ts_demo@onload_typesafe-i18n.ejs +8 -0
  344. package/templates/default/src/plugin.ts_demo@onload_vue.ejs +4 -0
  345. package/templates/default/src/plugin.ts_demo@onload_wasm.ejs +2 -0
  346. package/templates/default/src/plugin.ts_enhanced.ejs +72 -0
  347. package/templates/default/src/plugin.ts_enhanced@import2_codemirror.ejs +3 -0
  348. package/templates/default/src/plugin.ts_enhanced@import2_i18next.ejs +2 -0
  349. package/templates/default/src/plugin.ts_enhanced@import2_lit.ejs +4 -0
  350. package/templates/default/src/plugin.ts_enhanced@import2_preact.ejs +4 -0
  351. package/templates/default/src/plugin.ts_enhanced@import2_react.ejs +4 -0
  352. package/templates/default/src/plugin.ts_enhanced@import2_solid.ejs +4 -0
  353. package/templates/default/src/plugin.ts_enhanced@import2_svelte.ejs +4 -0
  354. package/templates/default/src/plugin.ts_enhanced@import2_typesafe-i18n.ejs +2 -0
  355. package/templates/default/src/plugin.ts_enhanced@import2_vue.ejs +4 -0
  356. package/templates/default/src/plugin.ts_enhanced@import2_wasm.ejs +1 -0
  357. package/templates/default/src/plugin.ts_enhanced@method_ui-view.ejs +7 -0
  358. package/templates/default/src/plugin.ts_enhanced@onload_codemirror.ejs +4 -0
  359. package/templates/default/src/plugin.ts_enhanced@onload_i18next.ejs +2 -0
  360. package/templates/default/src/plugin.ts_enhanced@onload_lit.ejs +4 -0
  361. package/templates/default/src/plugin.ts_enhanced@onload_preact.ejs +4 -0
  362. package/templates/default/src/plugin.ts_enhanced@onload_react.ejs +4 -0
  363. package/templates/default/src/plugin.ts_enhanced@onload_solid.ejs +4 -0
  364. package/templates/default/src/plugin.ts_enhanced@onload_svelte.ejs +4 -0
  365. package/templates/default/src/plugin.ts_enhanced@onload_typesafe-i18n.ejs +8 -0
  366. package/templates/default/src/plugin.ts_enhanced@onload_vue.ejs +4 -0
  367. package/templates/default/src/plugin.ts_enhanced@onload_wasm.ejs +2 -0
  368. package/templates/default/src/plugin.ts_standalone.ejs +56 -0
  369. package/templates/default/src/plugin.ts_standalone@import_codemirror.ejs +3 -0
  370. package/templates/default/src/plugin.ts_standalone@import_i18next.ejs +1 -0
  371. package/templates/default/src/plugin.ts_standalone@import_lit.ejs +4 -0
  372. package/templates/default/src/plugin.ts_standalone@import_preact.ejs +4 -0
  373. package/templates/default/src/plugin.ts_standalone@import_react.ejs +4 -0
  374. package/templates/default/src/plugin.ts_standalone@import_solid.ejs +4 -0
  375. package/templates/default/src/plugin.ts_standalone@import_svelte.ejs +4 -0
  376. package/templates/default/src/plugin.ts_standalone@import_typesafe-i18n.ejs +1 -0
  377. package/templates/default/src/plugin.ts_standalone@import_vue.ejs +4 -0
  378. package/templates/default/src/plugin.ts_standalone@import_wasm.ejs +1 -0
  379. package/templates/default/src/plugin.ts_standalone@method_ui-view.ejs +7 -0
  380. package/templates/default/src/plugin.ts_standalone@onload_codemirror.ejs +4 -0
  381. package/templates/default/src/plugin.ts_standalone@onload_i18next.ejs +2 -0
  382. package/templates/default/src/plugin.ts_standalone@onload_lit.ejs +4 -0
  383. package/templates/default/src/plugin.ts_standalone@onload_preact.ejs +4 -0
  384. package/templates/default/src/plugin.ts_standalone@onload_react.ejs +4 -0
  385. package/templates/default/src/plugin.ts_standalone@onload_solid.ejs +4 -0
  386. package/templates/default/src/plugin.ts_standalone@onload_svelte.ejs +4 -0
  387. package/templates/default/src/plugin.ts_standalone@onload_typesafe-i18n.ejs +8 -0
  388. package/templates/default/src/plugin.ts_standalone@onload_vue.ejs +4 -0
  389. package/templates/default/src/plugin.ts_standalone@onload_wasm.ejs +2 -0
  390. package/templates/default/src/preact-components/sample-preact-component.tsx_dev-utils.ejs +47 -0
  391. package/templates/default/src/preact-components/sample-preact-component.tsx_standalone.ejs +47 -0
  392. package/templates/default/src/react-components/sample-react-component.tsx_dev-utils.ejs +35 -0
  393. package/templates/default/src/react-components/sample-react-component.tsx_standalone.ejs +47 -0
  394. package/templates/default/src/settings.ts.ejs +32 -0
  395. package/templates/default/src/solid-components/sample-solid-component.tsx_dev-utils.ejs +47 -0
  396. package/templates/default/src/solid-components/sample-solid-component.tsx_standalone.ejs +47 -0
  397. package/templates/default/src/styles/css-modules.d.ts.ejs +4 -0
  398. package/templates/default/src/styles/main.css_dev-utils.ejs +17 -0
  399. package/templates/default/src/styles/main.css_dev-utils@content_tailwind.ejs +1 -0
  400. package/templates/default/src/styles/main.css_standalone.ejs +11 -0
  401. package/templates/default/src/styles/main.css_standalone@content_tailwind.ejs +1 -0
  402. package/templates/default/src/styles/main.module.css.ejs +3 -0
  403. package/templates/default/src/styles/main.scss_dev-utils.ejs +16 -0
  404. package/templates/default/src/styles/main.scss_standalone.ejs +10 -0
  405. package/templates/default/src/styles/styles.d.ts.ejs +4 -0
  406. package/templates/default/src/svelte-components/sample-svelte-component.d.ts.ejs +7 -0
  407. package/templates/default/src/svelte-components/sample-svelte-component.svelte.ejs +24 -0
  408. package/templates/default/src/views/sample-lit-view.ts.ejs +30 -0
  409. package/templates/default/src/views/sample-lit-view.ts@lint-register-element_dev-utils.ejs +1 -0
  410. package/templates/default/src/views/sample-preact-view.tsx_dev-utils.ejs +45 -0
  411. package/templates/default/src/views/sample-preact-view.tsx_standalone.ejs +42 -0
  412. package/templates/default/src/views/sample-react-view.tsx_dev-utils.ejs +47 -0
  413. package/templates/default/src/views/sample-react-view.tsx_standalone.ejs +49 -0
  414. package/templates/default/src/views/sample-solid-view.tsx_dev-utils.ejs +46 -0
  415. package/templates/default/src/views/sample-solid-view.tsx_standalone.ejs +46 -0
  416. package/templates/default/src/views/sample-svelte-view.ts.ejs +47 -0
  417. package/templates/default/src/views/sample-view.ts.ejs +37 -0
  418. package/templates/default/src/views/sample-vue-view.ts.ejs +34 -0
  419. package/templates/default/src/vue-components/sample-vue-component.d.ts.ejs +6 -0
  420. package/templates/default/src/vue-components/sample-vue-component.vue.ejs +25 -0
  421. package/templates/default/src/wasm/README.md.ejs +29 -0
  422. package/templates/default/src/wasm/answer.ts_esbuild.ejs +23 -0
  423. package/templates/default/src/wasm/answer.ts_parcel.ejs +29 -0
  424. package/templates/default/src/wasm/answer.ts_rollup.ejs +19 -0
  425. package/templates/default/src/wasm/answer.ts_vite.ejs +29 -0
  426. package/templates/default/src/wasm/answer.ts_webpack.ejs +29 -0
  427. package/templates/default/src/wasm/module.wasm +0 -0
  428. package/templates/default/src/wasm/module.wat.ejs +12 -0
  429. package/templates/default/src/wasm/sample-command.ts.ejs +33 -0
  430. package/templates/default/src/wasm.d.ts_esbuild.ejs +12 -0
  431. package/templates/default/src/wasm.d.ts_parcel.ejs +7 -0
  432. package/templates/default/src/wasm.d.ts_rollup.ejs +8 -0
  433. package/templates/default/src/wasm.d.ts_vite.ejs +8 -0
  434. package/templates/default/src/wasm.d.ts_webpack.ejs +7 -0
  435. package/templates/default/tsconfig.json_dev-utils.ejs +34 -0
  436. package/templates/default/tsconfig.json_dev-utils@compiler-options_i18next.ejs +1 -0
  437. package/templates/default/tsconfig.json_dev-utils@compiler-options_lit.ejs +2 -0
  438. package/templates/default/tsconfig.json_dev-utils@compiler-options_preact.ejs +2 -0
  439. package/templates/default/tsconfig.json_dev-utils@compiler-options_react.ejs +1 -0
  440. package/templates/default/tsconfig.json_dev-utils@compiler-options_solid.ejs +2 -0
  441. package/templates/default/tsconfig.json_dev-utils@include_has-e2e.ejs +1 -0
  442. package/templates/default/tsconfig.json_dev-utils@include_svelte.ejs +1 -0
  443. package/templates/default/tsconfig.json_dev-utils@include_vue.ejs +1 -0
  444. package/templates/default/tsconfig.json_dev-utils@types_jest.ejs +2 -0
  445. package/templates/default/tsconfig.json_dev-utils@types_svelte.ejs +2 -0
  446. package/templates/default/tsconfig.json_dev-utils@types_wdio-obsidian.ejs +5 -0
  447. package/templates/default/tsconfig.json_dev-utils@types_with-unofficial.ejs +2 -0
  448. package/templates/default/tsconfig.json_standalone.ejs +47 -0
  449. package/templates/default/tsconfig.json_standalone@compiler-options_i18next.ejs +1 -0
  450. package/templates/default/tsconfig.json_standalone@compiler-options_lit.ejs +2 -0
  451. package/templates/default/tsconfig.json_standalone@compiler-options_preact.ejs +2 -0
  452. package/templates/default/tsconfig.json_standalone@compiler-options_react.ejs +1 -0
  453. package/templates/default/tsconfig.json_standalone@compiler-options_solid.ejs +2 -0
  454. package/templates/default/tsconfig.json_standalone@include-extra_preact.ejs +2 -0
  455. package/templates/default/tsconfig.json_standalone@include-extra_react.ejs +2 -0
  456. package/templates/default/tsconfig.json_standalone@include-extra_solid.ejs +2 -0
  457. package/templates/default/tsconfig.json_standalone@include_has-e2e.ejs +1 -0
  458. package/templates/default/tsconfig.json_standalone@include_svelte.ejs +1 -0
  459. package/templates/default/tsconfig.json_standalone@include_vue.ejs +1 -0
  460. package/templates/default/tsconfig.json_standalone@types_jest.ejs +2 -0
  461. package/templates/default/tsconfig.json_standalone@types_svelte.ejs +2 -0
  462. package/templates/default/tsconfig.json_standalone@types_wdio-obsidian.ejs +5 -0
  463. package/templates/default/tsconfig.json_standalone@types_with-unofficial.ejs +2 -0
  464. package/templates/default/versions.json.ejs +3 -0
  465. package/templates/default/vite.config.ts.ejs +3 -0
  466. package/templates/default/vitest.config.ts_dev-utils.ejs +1 -0
  467. package/templates/default/vitest.config.ts_standalone.ejs +55 -0
  468. package/templates/default/vitest.config.ts_standalone@jsx_solid.ejs +11 -0
  469. package/templates/default/wdio.conf.ts.ejs +21 -0
  470. package/templates/default/webpack.config.ts.ejs +3 -0
@@ -0,0 +1,75 @@
1
+ import type { ObsidianPluginVitestConfigContext } from 'obsidian-dev-utils/script-utils/test-runners/vitest-config';
2
+ import type { TestProjectConfiguration } from 'vitest/config';
3
+
4
+ import { fileURLToPath } from 'node:url';
5
+ import { defineObsidianPluginVitestConfig } from 'obsidian-dev-utils/script-utils/test-runners/vitest-config';
6
+
7
+ /**
8
+ * The demo-vault button suite. It drives a real desktop Obsidian like the desktop project, but opens a
9
+ * copy of the in-repo `demo-vault/` rather than an empty vault — hence its own `globalSetup` — and needs
10
+ * its own file suffix so the desktop project does not also collect it and open it against a vault with no
11
+ * notes in it.
12
+ */
13
+ const DEMO_VAULT_TEST_FILES = 'src/**/*.demo-vault.integration.test.ts';
14
+
15
+ /**
16
+ * One `it` per note runs every button in that note, and each button re-opens the note, walks the preview
17
+ * to find itself and then waits for a result. A note with several buttons blows past the desktop
18
+ * project's 30s default — which fails the whole note with a bare vitest timeout instead of naming the
19
+ * button that actually misbehaved.
20
+ */
21
+ const DEMO_VAULT_TIMEOUT_IN_MILLISECONDS = 600_000;
22
+
23
+ /**
24
+ * Where every `.svelte` / `.vue` import in a unit test's module graph is sent. Compiling a single-file
25
+ * component is the bundler's job, and the plugin that does it is a dependency only of the bundler that
26
+ * was chosen — so a unit test that imports the plugin's own code would otherwise fail on a file vitest
27
+ * cannot transform. Absolute, because a vite alias replacement is resolved from the project root rather
28
+ * than from this file.
29
+ */
30
+ const FRAMEWORK_COMPONENT_STUB_PATH = fileURLToPath(new URL('framework-component-stub.ts', import.meta.url));
31
+
32
+ /**
33
+ * Where every `.wasm` import in a unit test's module graph is sent, for the same reason as the component
34
+ * stub above. Vitest resolves a `.wasm` through vite's own WebAssembly helper, which fetches it from a
35
+ * URL that exists only under a dev server — so a unit test that imports the plugin's own code fails on
36
+ * `Failed to parse URL` before it runs a single assertion.
37
+ */
38
+ const WASM_MODULE_STUB_PATH = fileURLToPath(new URL('wasm-module-stub.ts', import.meta.url));
39
+
40
+ /**
41
+ * Where every stylesheet import in a unit test's module graph is sent. `src/main.ts` imports one for its
42
+ * side effect, and on the `tailwind` styling the file it names is generated by the first build — so a
43
+ * unit test run on a fresh clone would otherwise fail to resolve it.
44
+ */
45
+ const STYLESHEET_STUB_PATH = fileURLToPath(new URL('stylesheet-stub.ts', import.meta.url));
46
+
47
+ export const config = defineObsidianPluginVitestConfig({
48
+ customProjects(context: ObsidianPluginVitestConfigContext): TestProjectConfiguration[] {
49
+ return [
50
+ {
51
+ test: {
52
+ ...context.desktop,
53
+ globalSetup: ['./scripts/demo-vault-global-setup.ts'],
54
+ include: [DEMO_VAULT_TEST_FILES],
55
+ name: 'integration-tests:demo-vault',
56
+ testTimeout: DEMO_VAULT_TIMEOUT_IN_MILLISECONDS
57
+ }
58
+ }
59
+ ];
60
+ },
61
+ // `^.+` is load-bearing, not decoration: a vite alias built from a RegExp replaces only the part the
62
+ // Pattern MATCHED, so `/\.svelte$/` rewrites the extension and leaves the rest of the specifier glued
63
+ // To the front of the stub path. The pattern has to cover the whole id.
64
+ editContext(context: ObsidianPluginVitestConfigContext): void {
65
+ context.unitTests.alias = [
66
+ { find: /^.+\.(?:svelte|vue)$/u, replacement: FRAMEWORK_COMPONENT_STUB_PATH },
67
+ { find: /^.+\.(?:css|scss)$/u, replacement: STYLESHEET_STUB_PATH },
68
+ // Two patterns because two bundlers do not write the import plainly: vite asks for the asset's URL
69
+ // (`./module.wasm?url`) and parcel uses a scheme (`data-url:./module.wasm`).
70
+ { find: /^.+\.wasm(?:\?.*)?$/u, replacement: WASM_MODULE_STUB_PATH },
71
+ { find: /^data-url:.+$/u, replacement: WASM_MODULE_STUB_PATH }
72
+ ];
73
+ }
74
+ });
75
+ <%- render('post-config') -%>
@@ -0,0 +1,67 @@
1
+
2
+ /**
3
+ * The config above, narrowed to the one field this file writes through.
4
+ */
5
+ interface ConfigWithProjects {
6
+ test: ProjectsSection;
7
+ }
8
+
9
+ /**
10
+ * The shape of a project entry this file reaches into, which vitest's own union type does not narrow to.
11
+ */
12
+ interface JsxProject {
13
+ oxc?: OxcSection;
14
+ }
15
+
16
+ /**
17
+ * The JSX transform a test project is given.
18
+ *
19
+ * Deliberately not named `…Options`: the shared lint config requires every member of a `Params` /
20
+ * `Options` / `Result` interface to be `readonly`, and this one is assigned to.
21
+ */
22
+ interface JsxRuntimeSpec {
23
+ importSource: string;
24
+ runtime: string;
25
+ }
26
+
27
+ /**
28
+ * The `oxc` section of a project entry.
29
+ */
30
+ interface OxcSection {
31
+ jsx: JsxRuntimeSpec;
32
+ }
33
+
34
+ /**
35
+ * The `test` section of the config above.
36
+ */
37
+ interface ProjectsSection {
38
+ projects: JsxProject[];
39
+ }
40
+
41
+ /*
42
+ * Solid compiles its JSX with `babel-preset-solid`, so the project's `tsconfig.json` sets
43
+ * `jsx: 'preserve'` and leaves the JSX in place for the bundler. Vite refuses to parse a file in that
44
+ * state at all -- "make sure to not set jsx to preserve" -- so every suite whose module graph reaches a
45
+ * `.tsx` file fails before it runs. The test projects transform JSX with the automatic runtime instead,
46
+ * from `solid-js/h`, which is the entry point that publishes a `jsx-runtime`; plain `solid-js` does not.
47
+ * Reactivity is not compiled in, which unit tests do not need -- rendering a Solid component is an
48
+ * integration-test job.
49
+ *
50
+ * Applied here rather than through `editContext`, which reaches a project's `test` section only, while
51
+ * `oxc` is a vite-level option on the project itself.
52
+ *
53
+ * Widened through a separate `unknown` binding rather than asserted twice in one expression: the
54
+ * returned type does not overlap `ConfigWithProjects`, so a direct assertion is TS2352, and
55
+ * `as unknown as` in one expression is what the shared lint config bans.
56
+ */
57
+ const untypedConfig: unknown = config;
58
+ const configWithProjects = untypedConfig as ConfigWithProjects;
59
+
60
+ for (const project of configWithProjects.test.projects) {
61
+ project.oxc = {
62
+ jsx: {
63
+ importSource: 'solid-js/h',
64
+ runtime: 'automatic'
65
+ }
66
+ };
67
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The unit runners' stand-in for a `.wasm` import.
3
+ *
4
+ * Neither runner can load one the way the bundler does, and each fails differently: vitest resolves a
5
+ * `.wasm` through vite's own WebAssembly helper, which tries to `fetch` it from a URL that does not
6
+ * exist outside a dev server, and jest has no transform for the extension at all. Meanwhile the emitted
7
+ * `src/plugin.ts` reaches the module through `src/wasm/sample-command.ts`, so ANY unit test that imports
8
+ * the plugin -- which the sample one does, deliberately -- pulls the `.wasm` into its module graph.
9
+ *
10
+ * So both runners send every `.wasm` import here, exactly as they send every `.svelte` / `.vue` import
11
+ * to `framework-component-stub.ts`, and for the same reason: loading the real thing is the bundler's
12
+ * job, and no unit test needs it.
13
+ *
14
+ * It throws rather than returning inert bytes. A unit test that really does want to run WebAssembly
15
+ * should instantiate the module itself from `readFileSync`, and this sentence is what tells it so.
16
+ *
17
+ * @throws Always.
18
+ */
19
+ export default function wasmModuleStub(): never {
20
+ throw new Error('A `.wasm` import is not loaded in unit tests. Read the file and instantiate it directly if a test needs the real module.');
21
+ }
@@ -0,0 +1,124 @@
1
+ import type { Configuration } from 'webpack';
2
+
3
+ <%# Sorted as one group: the per-answer partials contribute imports in question-registration order, -%>
4
+ <%# which is not the order an import-sorting lint rule wants. See `sortImports` in `src/templates.ts`. -%>
5
+ <%- sortImports(`import { builtinModules } from 'node:module';
6
+ import { join } from 'node:path';
7
+ import process from 'node:process';
8
+ import TerserPlugin from 'terser-webpack-plugin';
9
+ ${render('lint-webpack-default')}import webpack from 'webpack';
10
+ ${render('import')}`) -%>
11
+
12
+ const isProduction = process.env['BUILD'] === 'production';
13
+ const distFolder = process.env['DIST_FOLDER'] ?? (isProduction ? 'dist/build' : 'dist/dev');
14
+
15
+ const EXTERNAL = [
16
+ 'obsidian',
17
+ 'electron',
18
+ '@codemirror/autocomplete',
19
+ '@codemirror/collab',
20
+ '@codemirror/commands',
21
+ '@codemirror/language',
22
+ '@codemirror/lint',
23
+ '@codemirror/search',
24
+ '@codemirror/state',
25
+ '@codemirror/view',
26
+ '@lezer/common',
27
+ '@lezer/highlight',
28
+ '@lezer/lr',
29
+ 'esbuild',
30
+ 'eslint',
31
+ ...builtinModules
32
+ ];
33
+
34
+ <%# Each per-answer partial ends its entry with a comma so two of them concatenate into a valid list; -%>
35
+ <%# the last entry of each array must not carry one. Stripped here rather than by making every partial -%>
36
+ <%# know whether it is last. -%>
37
+ <%
38
+ const rules = ` {
39
+ // The emitted \`tsconfig.json\` declares \`noEmit: true\` and allows \`.ts\` import specifiers, both
40
+ // Right for the file itself -- more than tsc reads it. ts-loader compiles WITH emit, so it needs
41
+ // Both overridden, and the overrides belong here, in the one tool that needs them, exactly as
42
+ // \`jest.config.ts\` overrides \`rootDir\` for the same reason.
43
+ //
44
+ // \`rewriteRelativeImportExtensions\` rather than turning \`allowImportingTsExtensions\` off: the
45
+ // Emitted \`src/\` really does import \`./plugin.ts\` by that name, so switching it off trades
46
+ // TS5096 for an error on every one of those. This is the option TypeScript added for emitting
47
+ // From exactly such sources. \`onlyCompileBundledFiles\` keeps ts-loader to the graph webpack
48
+ // Actually pulls in, instead of every file the tsconfig's \`include\` lists -- it was reaching
49
+ // \`webpack.config.ts\` and \`scripts/dev.ts\`, which are no business of the bundle.
50
+ exclude: /node_modules/,
51
+ test: /\\.tsx?$/,
52
+ use: {
53
+ loader: 'ts-loader',
54
+ options: {
55
+ ${render('ts-loader-options')} compilerOptions: {
56
+ noEmit: false,
57
+ ${render('ts-loader-compiler-options')} rewriteRelativeImportExtensions: true
58
+ },
59
+ onlyCompileBundledFiles: true
60
+ }
61
+ }
62
+ },
63
+ ${render('rule')}`;
64
+ const plugins = ` new webpack.BannerPlugin({
65
+ banner: \`/*
66
+ THIS IS A GENERATED/BUNDLED FILE BY WEBPACK
67
+ if you want to view the source, please visit the github repository of this plugin
68
+ */\`,
69
+ raw: true
70
+ }),
71
+ ${render('plugin')}`;
72
+ -%>
73
+ export const config: Configuration = {
74
+ devtool: isProduction ? false : 'inline-source-map',
75
+ entry: './src/main.ts',
76
+ externals: Object.fromEntries(
77
+ EXTERNAL.map((moduleName) => [moduleName, `commonjs2 ${moduleName}`])
78
+ ),
79
+ mode: isProduction ? 'production' : 'development',
80
+ module: {
81
+ rules: [
82
+ <%- rules.replace(/,(?<Trailing>\s*)$/, '$<Trailing>') -%>
83
+ ]
84
+ },
85
+ optimization: {
86
+ // Terser's default `extractComments` cuts every bundled dependency's `/*! ... */` and `@license`
87
+ // Comment out of `main.js` into a `main.js.LICENSE.txt` beside it -- which no Obsidian release ships,
88
+ // So the installed plugin would carry the code without the notices it is licensed under. Kept inline
89
+ // Instead, as esbuild's `legalComments` default keeps them.
90
+ minimizer: [new TerserPlugin({ extractComments: false })]
91
+ },
92
+ output: {
93
+ // An Obsidian release ships `main.js` and nothing beside it, so a dynamic import -- obsidian-dev-utils
94
+ // Has several -- must not become a sibling chunk that `main.js` then loads by name at runtime. This is
95
+ // Webpack's twin of rollup's `inlineDynamicImports`.
96
+ asyncChunks: false,
97
+ filename: 'main.js',
98
+ libraryExport: 'default',
99
+ libraryTarget: 'commonjs2',
100
+ path: join(process.cwd(), distFolder)
101
+ },
102
+ plugins: [
103
+ <%- plugins.replace(/,(?<Trailing>\s*)$/, '$<Trailing>') -%>
104
+ ],
105
+ resolve: {
106
+ // A plugin runs in Obsidian's renderer, not in Node, but `target: 'node'` resolves only the `node`
107
+ // Export condition -- which hands Solid and Svelte their SERVER builds, where `render` / `mount` do
108
+ // Nothing a view can use, with the build green. `browser` is what esbuild's `conditions` and rollup's
109
+ // `nodeResolve({ browser: true })` already ask for; `'...'` keeps webpack's own defaults beside it.
110
+ conditionNames: ['browser', '...'],
111
+ // The loader above rewrites `./plugin.ts` to `./plugin.js` on emit, but only `./plugin.ts` exists on
112
+ // Disk, and webpack's `extensions` list only appends a suffix to a request that has no extension --
113
+ // It does not map one extension to another. Without this the bundle fails to resolve "./plugin.js".
114
+ //
115
+ // Under `jsx: preserve` (the Solid answer) it rewrites `./view.tsx` to `./view.jsx` instead, so that
116
+ // Name is mapped back the same way. Nothing else emits a `.jsx` specifier, so elsewhere it is inert.
117
+ extensionAlias: {
118
+ '.js': ['.ts', '.tsx', '.js'],
119
+ '.jsx': ['.tsx', '.jsx']
120
+ },
121
+ extensions: ['.ts', '.tsx', '.js']
122
+ },
123
+ target: 'node'
124
+ };
@@ -0,0 +1 @@
1
+ import { sveltePreprocess } from 'svelte-preprocess';
@@ -0,0 +1 @@
1
+ import { VueLoaderPlugin } from 'vue-loader';
@@ -0,0 +1,4 @@
1
+ <%# Shared by EVERY styling answer that extracts CSS, rather than one identical copy per answer. -%>
2
+ <%# Partials are a Set, so a preset forcing a second styling answer on top of the chosen one -- which -%>
3
+ <%# `demo` does, with `scss` -- renders this once instead of emitting a duplicate `import` (TS2300). -%>
4
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
@@ -0,0 +1 @@
1
+ // eslint-disable-next-line import-x/no-named-as-default -- The default export IS the `webpack` namespace; the same name is the point.
@@ -0,0 +1 @@
1
+ new VueLoaderPlugin(),
@@ -0,0 +1,4 @@
1
+ <%# One instance, for the reason its import partial gives: two plugins both writing `styles.css` is -%>
2
+ <%# what five per-answer copies produced. The per-answer `rule` partials stay per-answer -- they test -%>
3
+ <%# different extensions and are meant to coexist. -%>
4
+ new MiniCssExtractPlugin({ filename: 'styles.css' }),
@@ -0,0 +1,7 @@
1
+ {
2
+ test: /\.module\.css$/,
3
+ use: [
4
+ MiniCssExtractPlugin.loader,
5
+ { loader: 'css-loader', options: { modules: true } }
6
+ ]
7
+ },
@@ -0,0 +1,4 @@
1
+ {
2
+ test: /\.css$/,
3
+ use: [MiniCssExtractPlugin.loader, 'css-loader']
4
+ },
@@ -0,0 +1,4 @@
1
+ {
2
+ test: /\.css$/,
3
+ use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
4
+ },
@@ -0,0 +1,4 @@
1
+ {
2
+ test: /\.scss$/,
3
+ use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
4
+ },
@@ -0,0 +1,17 @@
1
+ <%# Solid's JSX is not React's, so ts-loader leaves it alone: the Solid answer sets `jsx: preserve` for -%>
2
+ <%# `babel-preset-solid`, and ts-loader emits every `.tsx` with its JSX intact. This rule compiles it. -%>
3
+ <%# `enforce: 'post'` runs it AFTER ts-loader, which still type-checks and strips the types, so babel -%>
4
+ <%# needs only the Solid preset. `configFile: false` keeps a babel config another answer emits away from it. -%>
5
+ {
6
+ enforce: 'post',
7
+ exclude: /node_modules/,
8
+ test: /\.tsx$/,
9
+ use: {
10
+ loader: 'babel-loader',
11
+ options: {
12
+ babelrc: false,
13
+ configFile: false,
14
+ presets: ['babel-preset-solid']
15
+ }
16
+ }
17
+ },
@@ -0,0 +1,7 @@
1
+ {
2
+ test: /\.svelte$/,
3
+ use: {
4
+ loader: 'svelte-loader',
5
+ options: { preprocess: sveltePreprocess() }
6
+ }
7
+ },
@@ -0,0 +1,4 @@
1
+ {
2
+ test: /\.css$/,
3
+ use: [MiniCssExtractPlugin.loader, 'css-loader']
4
+ },
@@ -0,0 +1,4 @@
1
+ {
2
+ test: /\.vue$/,
3
+ use: 'vue-loader'
4
+ },
@@ -0,0 +1,8 @@
1
+ {
2
+ // NOT `experiments.asyncWebAssembly`, which is what this used to be. That emits the module as a
3
+ // Separate `.wasm` chunk the bundle fetches at runtime -- and an Obsidian release ships `main.js`
4
+ // And `styles.css` and nothing else, so the chunk is simply absent wherever the plugin is
5
+ // Installed. `asset/inline` carries the module inside `main.js` as a `data:` URL instead.
6
+ test: /\.wasm$/,
7
+ type: 'asset/inline'
8
+ },
@@ -0,0 +1,5 @@
1
+ <%# Only for this compile, not in `tsconfig.json`. `appendTsSuffixTo` hands ts-loader the component's -%>
2
+ <%# `<script>` block as a standalone module, WITHOUT the template that uses its bindings, so every -%>
3
+ <%# handler the template calls reads as unused: TS6133 "'increment' is declared but its value is never -%>
4
+ <%# read". The gate's own `tsc --noEmit`, and the editor, still enforce it on real `.ts` files. -%>
5
+ noUnusedLocals: false,
@@ -0,0 +1,5 @@
1
+ <%# Without this, ts-loader does not recognize vue-loader's `?vue&type=script&lang=ts` request as -%>
2
+ <%# TypeScript, and TypeScript resolves the block against the WRONG file: the build failed with -%>
3
+ <%# "Can't resolve './styles/main.module.css' in src/vue-components" -- which is `src/main.ts`'s import, -%>
4
+ <%# reported from the component's directory. -%>
5
+ appendTsSuffixTo: [/\.vue$/u],
@@ -0,0 +1,12 @@
1
+ import { registerDemoVaultButtonSuite } from 'obsidian-dev-utils/script-utils/demo-vault-buttons';
2
+
3
+ // Clicks every `code-button` in `demo-vault/` against a real Obsidian. A button fails at CLICK time -- a
4
+ // Wrong `require('/demoSetup.ts')` path, or an API that changed shape under it -- so no other gate can
5
+ // Catch it: `lint:md` reads the markdown and the coverage suite checks the authoring conventions, and
6
+ // Neither executes anything.
7
+ //
8
+ // It needs the CodeScript Toolkit binary seeded into `demo-vault/.obsidian/plugins/`, which happens the
9
+ // First time you open `demo-vault/` in Obsidian. See CONTRIBUTING.md.
10
+ //
11
+ // Isolation: `npx vitest run --project integration-tests:demo-vault`.
12
+ registerDemoVaultButtonSuite();
@@ -0,0 +1,18 @@
1
+ import process from 'node:process';
2
+ import { registerDemoVaultCoverageSuite } from 'obsidian-dev-utils/script-utils/demo-vault-coverage';
3
+ import { getRootFolder } from 'obsidian-dev-utils/script-utils/root';
4
+
5
+ // Keeps the in-repo `demo-vault/` honest WITHOUT launching Obsidian. It enforces the authoring convention
6
+ // Every vault owes its readers: an `# H1` and a prose opener on every note, Markdown links rather than
7
+ // Wikilinks (which do not render on GitHub), no `[Docs]` line, every note reachable from `00 Start.md`,
8
+ // And an `.obsidian/app.json` that commits none of the settings obsidian-dev-utils injects at release time.
9
+ //
10
+ // `rootFolder` alone is enough for those. Once your settings surface settles, add a reflection spec so the
11
+ // Suite also fails when a setting is documented nowhere in the vault, or when a note names one that no
12
+ // Longer exists:
13
+ //
14
+ // registerDemoVaultCoverageSuite({
15
+ // configInterfaces: [{ interfaceName: 'PluginSettings', sourcePath: 'src/plugin-settings.ts' }],
16
+ // rootFolder: getRootFolder() ?? process.cwd()
17
+ // });
18
+ registerDemoVaultCoverageSuite({ rootFolder: getRootFolder() ?? process.cwd() });
@@ -0,0 +1,56 @@
1
+ import type {
2
+ Extension,
3
+ Transaction
4
+ } from '@codemirror/state';
5
+ import type { DecorationSet } from '@codemirror/view';
6
+ import type { StateFieldSpec } from 'obsidian-dev-utils/codemirror/state-field-spec';
7
+
8
+ import {
9
+ RangeSetBuilder,
10
+ StateField
11
+ } from '@codemirror/state';
12
+ import {
13
+ Decoration,
14
+ EditorView
15
+ } from '@codemirror/view';
16
+
17
+ import { SampleWidget } from './sample-widget.ts';
18
+
19
+ class SampleStateField implements StateFieldSpec<DecorationSet> {
20
+ public create(state: Transaction['state']): DecorationSet {
21
+ return buildDecorations(state);
22
+ }
23
+
24
+ public provide(field: StateField<DecorationSet>): Extension {
25
+ return EditorView.decorations.from(field);
26
+ }
27
+
28
+ public update(oldState: DecorationSet, transaction: Transaction): DecorationSet {
29
+ return transaction.docChanged ? buildDecorations(transaction.state) : oldState;
30
+ }
31
+ }
32
+
33
+ function buildDecorations(state: Transaction['state']): DecorationSet {
34
+ const builder = new RangeSetBuilder<Decoration>();
35
+ const doc = state.doc;
36
+
37
+ for (let index = 1; index <= doc.lines; index++) {
38
+ const line = doc.line(index);
39
+ const words = line.text.trim().split(/\s+/).filter((w) => w.length > 0);
40
+
41
+ if (words.length > 0) {
42
+ builder.add(
43
+ line.to,
44
+ line.to,
45
+ Decoration.widget({
46
+ side: 1,
47
+ widget: new SampleWidget(words.length)
48
+ })
49
+ );
50
+ }
51
+ }
52
+
53
+ return builder.finish();
54
+ }
55
+
56
+ export const sampleStateField = StateField.define<DecorationSet>(new SampleStateField());
@@ -0,0 +1,60 @@
1
+ import type {
2
+ Extension,
3
+ Transaction
4
+ } from '@codemirror/state';
5
+ import type { DecorationSet } from '@codemirror/view';
6
+
7
+ import {
8
+ RangeSetBuilder,
9
+ StateField
10
+ } from '@codemirror/state';
11
+ import {
12
+ Decoration,
13
+ EditorView
14
+ } from '@codemirror/view';
15
+
16
+ import { SampleWidget } from './sample-widget.ts';
17
+
18
+ function buildDecorations(state: Transaction['state']): DecorationSet {
19
+ const builder = new RangeSetBuilder<Decoration>();
20
+ const doc = state.doc;
21
+
22
+ for (let i = 1; i <= doc.lines; i++) {
23
+ const line = doc.line(i);
24
+ const words = line.text.trim().split(/\s+/).filter((w) => w.length > 0);
25
+
26
+ if (words.length > 0) {
27
+ builder.add(
28
+ line.to,
29
+ line.to,
30
+ Decoration.widget({
31
+ side: 1,
32
+ widget: new SampleWidget(words.length)
33
+ })
34
+ );
35
+ }
36
+ }
37
+
38
+ return builder.finish();
39
+ }
40
+
41
+ function createSampleStateField(): StateField<DecorationSet> {
42
+ return StateField.define<DecorationSet>({
43
+ create(state): DecorationSet {
44
+ return buildDecorations(state);
45
+ },
46
+
47
+ provide(field: StateField<DecorationSet>): Extension {
48
+ return EditorView.decorations.from(field);
49
+ },
50
+
51
+ update(oldState: DecorationSet, transaction: Transaction): DecorationSet {
52
+ if (transaction.docChanged) {
53
+ return buildDecorations(transaction.state);
54
+ }
55
+ return oldState;
56
+ }
57
+ });
58
+ }
59
+
60
+ export const sampleStateField = createSampleStateField();
@@ -0,0 +1,66 @@
1
+ import type {
2
+ DecorationSet,
3
+ EditorView,
4
+ PluginSpec,
5
+ PluginValue,
6
+ ViewUpdate
7
+ } from '@codemirror/view';
8
+
9
+ import { RangeSetBuilder } from '@codemirror/state';
10
+ import {
11
+ Decoration,
12
+ ViewPlugin
13
+ } from '@codemirror/view';
14
+
15
+ import { SampleWidget } from './sample-widget.ts';
16
+
17
+ class SampleViewPlugin implements PluginValue {
18
+ public decorations: DecorationSet;
19
+
20
+ public constructor(view: EditorView) {
21
+ this.decorations = this.buildDecorations(view);
22
+ }
23
+
24
+ public update(update: ViewUpdate): void {
25
+ if (update.docChanged || update.viewportChanged) {
26
+ this.decorations = this.buildDecorations(update.view);
27
+ }
28
+ }
29
+
30
+ private buildDecorations(view: EditorView): DecorationSet {
31
+ const builder = new RangeSetBuilder<Decoration>();
32
+
33
+ for (const { from, to } of view.visibleRanges) {
34
+ const doc = view.state.doc;
35
+ const startLine = doc.lineAt(from).number;
36
+ const endLine = doc.lineAt(to).number;
37
+
38
+ for (let index = startLine; index <= endLine; index++) {
39
+ const line = doc.line(index);
40
+ const words = line.text.trim().split(/\s+/).filter((w) => w.length > 0);
41
+
42
+ if (words.length > 0) {
43
+ builder.add(
44
+ line.to,
45
+ line.to,
46
+ Decoration.widget({
47
+ side: 1,
48
+ widget: new SampleWidget(words.length)
49
+ })
50
+ );
51
+ }
52
+ }
53
+ }
54
+
55
+ return builder.finish();
56
+ }
57
+ }
58
+
59
+ const pluginSpec: PluginSpec<SampleViewPlugin> = {
60
+ decorations: (value: SampleViewPlugin) => value.decorations
61
+ };
62
+
63
+ export const sampleViewPlugin = ViewPlugin.fromClass(
64
+ SampleViewPlugin,
65
+ pluginSpec
66
+ );
@@ -0,0 +1,22 @@
1
+ import { WidgetType } from '@codemirror/view';
2
+
3
+ export class SampleWidget extends WidgetType {
4
+ private readonly count: number;
5
+
6
+ public constructor(count: number) {
7
+ super();
8
+ this.count = count;
9
+ }
10
+
11
+ public override eq(other: SampleWidget): boolean {
12
+ return this.count === other.count;
13
+ }
14
+
15
+ public toDOM(): HTMLElement {
16
+ const span = createSpan({
17
+ cls: 'cm-sample-word-count',
18
+ text: ` [${String(this.count)} words]`
19
+ });
20
+ return span;
21
+ }
22
+ }