@linyjs/plugin-docs 0.0.13

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 (254) hide show
  1. package/README.md +137 -0
  2. package/docs/api-reference/index.md +361 -0
  3. package/docs/best-practices/error-handling.md +462 -0
  4. package/docs/best-practices/naming-conventions.md +496 -0
  5. package/docs/best-practices/performance.md +532 -0
  6. package/docs/best-practices/security.md +620 -0
  7. package/docs/best-practices/service-definition.md +332 -0
  8. package/docs/faq.md +322 -0
  9. package/docs/getting-started/first-plugin.md +358 -0
  10. package/docs/getting-started/installation.md +244 -0
  11. package/docs/getting-started/quick-start.md +235 -0
  12. package/docs/guides/authentication.md +428 -0
  13. package/docs/guides/client-module.md +604 -0
  14. package/docs/guides/data-persistence.md +640 -0
  15. package/docs/guides/permissions.md +440 -0
  16. package/docs/guides/server-module.md +377 -0
  17. package/docs/guides/ui-slots.md +475 -0
  18. package/docs/migration/v0-to-v1.md +354 -0
  19. package/examples/analytics-plugin/README.md +416 -0
  20. package/examples/analytics-plugin/dist/client/index.d.ts +36 -0
  21. package/examples/analytics-plugin/dist/client/index.js +173 -0
  22. package/examples/analytics-plugin/dist/index.d.ts +64 -0
  23. package/examples/analytics-plugin/dist/index.js +72 -0
  24. package/examples/analytics-plugin/dist/server/index.d.ts +119 -0
  25. package/examples/analytics-plugin/dist/server/index.js +313 -0
  26. package/examples/analytics-plugin/package.json +28 -0
  27. package/examples/analytics-plugin/src/client/index.tsx +414 -0
  28. package/examples/analytics-plugin/src/index.ts +71 -0
  29. package/examples/analytics-plugin/src/server/index.ts +349 -0
  30. package/examples/analytics-plugin/tsconfig.json +21 -0
  31. package/examples/blog-plugin/README.md +319 -0
  32. package/examples/blog-plugin/dist/client/index.d.ts +22 -0
  33. package/examples/blog-plugin/dist/client/index.js +197 -0
  34. package/examples/blog-plugin/dist/server/index.d.ts +5 -0
  35. package/examples/blog-plugin/dist/server/index.js +220 -0
  36. package/examples/blog-plugin/package.json +24 -0
  37. package/examples/blog-plugin/src/client/index.tsx +409 -0
  38. package/examples/blog-plugin/src/server/index.ts +240 -0
  39. package/examples/blog-plugin/tsconfig.json +16 -0
  40. package/examples/hello-world/README.md +101 -0
  41. package/examples/hello-world/dist/client/index.d.ts +5 -0
  42. package/examples/hello-world/dist/client/index.js +80 -0
  43. package/examples/hello-world/dist/server/index.d.ts +5 -0
  44. package/examples/hello-world/dist/server/index.js +38 -0
  45. package/examples/hello-world/node_modules/.package-lock.json +61 -0
  46. package/examples/hello-world/node_modules/@linyjs/client-module-interface/HOOKS_USAGE.md +281 -0
  47. package/examples/hello-world/node_modules/@linyjs/client-module-interface/IMPLEMENTATION_SUMMARY.md +166 -0
  48. package/examples/hello-world/node_modules/@linyjs/client-module-interface/QUICK_REFERENCE.md +130 -0
  49. package/examples/hello-world/node_modules/@linyjs/client-module-interface/README.md +214 -0
  50. package/examples/hello-world/node_modules/@linyjs/client-module-interface/package.json +26 -0
  51. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/application.ts +50 -0
  52. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/comparison-example.tsx +229 -0
  53. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/di.ts +127 -0
  54. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/domain.ts +52 -0
  55. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/hooks-example.tsx +275 -0
  56. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/hooks.ts +175 -0
  57. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/index.ts +87 -0
  58. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/interfaces.ts +117 -0
  59. package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/router.ts +49 -0
  60. package/examples/hello-world/node_modules/@linyjs/client-module-interface/tsconfig.json +10 -0
  61. package/examples/hello-world/node_modules/@linyjs/server-module-interface/package.json +21 -0
  62. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/application.ts +21 -0
  63. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/di.ts +127 -0
  64. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/domain.ts +75 -0
  65. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/index.ts +55 -0
  66. package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/interfaces.ts +58 -0
  67. package/examples/hello-world/node_modules/@linyjs/server-module-interface/tsconfig.json +8 -0
  68. package/examples/hello-world/node_modules/@types/react/LICENSE +21 -0
  69. package/examples/hello-world/node_modules/@types/react/README.md +15 -0
  70. package/examples/hello-world/node_modules/@types/react/canary.d.ts +129 -0
  71. package/examples/hello-world/node_modules/@types/react/compiler-runtime.d.ts +4 -0
  72. package/examples/hello-world/node_modules/@types/react/experimental.d.ts +184 -0
  73. package/examples/hello-world/node_modules/@types/react/global.d.ts +166 -0
  74. package/examples/hello-world/node_modules/@types/react/index.d.ts +4369 -0
  75. package/examples/hello-world/node_modules/@types/react/jsx-dev-runtime.d.ts +33 -0
  76. package/examples/hello-world/node_modules/@types/react/jsx-runtime.d.ts +24 -0
  77. package/examples/hello-world/node_modules/@types/react/package.json +210 -0
  78. package/examples/hello-world/node_modules/@types/react/ts5.0/canary.d.ts +129 -0
  79. package/examples/hello-world/node_modules/@types/react/ts5.0/experimental.d.ts +184 -0
  80. package/examples/hello-world/node_modules/@types/react/ts5.0/global.d.ts +166 -0
  81. package/examples/hello-world/node_modules/@types/react/ts5.0/index.d.ts +4356 -0
  82. package/examples/hello-world/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +33 -0
  83. package/examples/hello-world/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +24 -0
  84. package/examples/hello-world/node_modules/csstype/LICENSE +19 -0
  85. package/examples/hello-world/node_modules/csstype/README.md +291 -0
  86. package/examples/hello-world/node_modules/csstype/index.d.ts +22569 -0
  87. package/examples/hello-world/node_modules/csstype/index.js.flow +6863 -0
  88. package/examples/hello-world/node_modules/csstype/package.json +70 -0
  89. package/examples/hello-world/node_modules/react/LICENSE +21 -0
  90. package/examples/hello-world/node_modules/react/README.md +37 -0
  91. package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.development.js +24 -0
  92. package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.production.js +16 -0
  93. package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.profiling.js +16 -0
  94. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.development.js +338 -0
  95. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.production.js +14 -0
  96. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.profiling.js +14 -0
  97. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.react-server.development.js +370 -0
  98. package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.react-server.production.js +40 -0
  99. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.development.js +352 -0
  100. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.production.js +34 -0
  101. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.profiling.js +34 -0
  102. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.react-server.development.js +370 -0
  103. package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.react-server.production.js +40 -0
  104. package/examples/hello-world/node_modules/react/cjs/react.development.js +1284 -0
  105. package/examples/hello-world/node_modules/react/cjs/react.production.js +542 -0
  106. package/examples/hello-world/node_modules/react/cjs/react.react-server.development.js +848 -0
  107. package/examples/hello-world/node_modules/react/cjs/react.react-server.production.js +423 -0
  108. package/examples/hello-world/node_modules/react/compiler-runtime.js +14 -0
  109. package/examples/hello-world/node_modules/react/index.js +7 -0
  110. package/examples/hello-world/node_modules/react/jsx-dev-runtime.js +7 -0
  111. package/examples/hello-world/node_modules/react/jsx-dev-runtime.react-server.js +7 -0
  112. package/examples/hello-world/node_modules/react/jsx-runtime.js +7 -0
  113. package/examples/hello-world/node_modules/react/jsx-runtime.react-server.js +7 -0
  114. package/examples/hello-world/node_modules/react/package.json +51 -0
  115. package/examples/hello-world/node_modules/react/react.react-server.js +7 -0
  116. package/examples/hello-world/node_modules/typescript/LICENSE.txt +55 -0
  117. package/examples/hello-world/node_modules/typescript/README.md +50 -0
  118. package/examples/hello-world/node_modules/typescript/SECURITY.md +41 -0
  119. package/examples/hello-world/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  120. package/examples/hello-world/node_modules/typescript/bin/tsc +2 -0
  121. package/examples/hello-world/node_modules/typescript/bin/tsserver +2 -0
  122. package/examples/hello-world/node_modules/typescript/lib/_tsc.js +133818 -0
  123. package/examples/hello-world/node_modules/typescript/lib/_tsserver.js +659 -0
  124. package/examples/hello-world/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  125. package/examples/hello-world/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
  126. package/examples/hello-world/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
  127. package/examples/hello-world/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
  128. package/examples/hello-world/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
  129. package/examples/hello-world/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
  130. package/examples/hello-world/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
  131. package/examples/hello-world/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
  132. package/examples/hello-world/node_modules/typescript/lib/lib.d.ts +22 -0
  133. package/examples/hello-world/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
  134. package/examples/hello-world/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  135. package/examples/hello-world/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  136. package/examples/hello-world/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
  137. package/examples/hello-world/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
  138. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  139. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  140. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  141. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  142. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
  143. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  144. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  145. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  146. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  147. package/examples/hello-world/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  148. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  149. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  150. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  151. package/examples/hello-world/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  152. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
  153. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
  154. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  155. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  156. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  157. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  158. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  159. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  160. package/examples/hello-world/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  161. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  162. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  163. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  164. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  165. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  166. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  167. package/examples/hello-world/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  168. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  169. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  170. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  171. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  172. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  173. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  174. package/examples/hello-world/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  175. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
  176. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  177. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  178. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  179. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  180. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  181. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  182. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
  183. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
  184. package/examples/hello-world/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  185. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  186. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  187. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  188. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  189. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  190. package/examples/hello-world/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
  191. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  192. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
  193. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
  194. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  195. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
  196. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  197. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  198. package/examples/hello-world/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  199. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  200. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  201. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  202. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  203. package/examples/hello-world/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  204. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
  205. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
  206. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
  207. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
  208. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
  209. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
  210. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
  211. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
  212. package/examples/hello-world/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
  213. package/examples/hello-world/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
  214. package/examples/hello-world/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  215. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  216. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
  217. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  218. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  219. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  220. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
  221. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
  222. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  223. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  224. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  225. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
  226. package/examples/hello-world/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
  227. package/examples/hello-world/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  228. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  229. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
  230. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  231. package/examples/hello-world/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
  232. package/examples/hello-world/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
  233. package/examples/hello-world/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
  234. package/examples/hello-world/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
  235. package/examples/hello-world/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
  236. package/examples/hello-world/node_modules/typescript/lib/tsc.js +8 -0
  237. package/examples/hello-world/node_modules/typescript/lib/tsserver.js +8 -0
  238. package/examples/hello-world/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  239. package/examples/hello-world/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  240. package/examples/hello-world/node_modules/typescript/lib/typesMap.json +497 -0
  241. package/examples/hello-world/node_modules/typescript/lib/typescript.d.ts +11437 -0
  242. package/examples/hello-world/node_modules/typescript/lib/typescript.js +200276 -0
  243. package/examples/hello-world/node_modules/typescript/lib/typingsInstaller.js +8 -0
  244. package/examples/hello-world/node_modules/typescript/lib/watchGuard.js +53 -0
  245. package/examples/hello-world/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
  246. package/examples/hello-world/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
  247. package/examples/hello-world/node_modules/typescript/package.json +120 -0
  248. package/examples/hello-world/package-lock.json +74 -0
  249. package/examples/hello-world/package.json +23 -0
  250. package/examples/hello-world/src/client/index.tsx +110 -0
  251. package/examples/hello-world/src/server/index.ts +42 -0
  252. package/examples/hello-world/tsconfig.json +16 -0
  253. package/package.json +46 -0
  254. package/src/cli.ts +321 -0
@@ -0,0 +1,358 @@
1
+ # 第一个插件教程
2
+
3
+ 在本教程中,我们将创建一个完整的博客插件,包含文章的增删改查(CRUD)功能。
4
+
5
+ ## 学习目标
6
+
7
+ 完成本教程后,你将能够:
8
+
9
+ - ✅ 创建服务端 API 控制器
10
+ - ✅ 创建客户端 React 页面
11
+ - ✅ 实现数据持久化(使用内存存储模拟)
12
+ - ✅ 理解插件的完整工作流程
13
+
14
+ ## 项目结构
15
+
16
+ 最终的项目结构如下:
17
+
18
+ ```
19
+ my-blog-plugin/
20
+ ├── package.json
21
+ ├── tsconfig.json
22
+ └── src/
23
+ ├── server/
24
+ │ └── index.ts # 服务端模块
25
+ └── client/
26
+ ├── index.tsx # 客户端模块
27
+ ├── pages/
28
+ │ ├── ArticleList.tsx
29
+ │ └── ArticleDetail.tsx
30
+ └── components/
31
+ └── ArticleCard.tsx
32
+ ```
33
+
34
+ ## 步骤 1: 初始化项目
35
+
36
+ ```bash
37
+ mkdir my-blog-plugin && cd my-blog-plugin
38
+ npm init -y
39
+ npm install @linyjs/server-module-interface @linyjs/client-module-interface react
40
+ npm install -D typescript @types/react
41
+ ```
42
+
43
+ 创建 `tsconfig.json`(参考[安装指南](./installation.md))。
44
+
45
+ ## 步骤 2: 定义数据类型
46
+
47
+ 创建 `src/shared/types.ts`:
48
+
49
+ ```typescript
50
+ export interface Article {
51
+ id: number;
52
+ title: string;
53
+ content: string;
54
+ author: string;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ }
58
+
59
+ export interface ArticleListResponse {
60
+ data: Article[];
61
+ total: number;
62
+ page: number;
63
+ limit: number;
64
+ totalPages: number;
65
+ }
66
+ ```
67
+
68
+ ## 步骤 3: 创建服务端代码
69
+
70
+ ### 3.1 文章服务
71
+
72
+ 创建 `src/server/services/ArticleService.ts`:
73
+
74
+ ```typescript
75
+ import type { Article } from '../../shared/types';
76
+
77
+ export class ArticleService {
78
+ private articles: Article[] = [];
79
+ private nextId = 1;
80
+
81
+ async getArticles(page = 1, limit = 10) {
82
+ const skip = (page - 1) * limit;
83
+ const total = this.articles.length;
84
+ const items = this.articles.slice(skip, skip + limit);
85
+
86
+ return {
87
+ data: items,
88
+ total,
89
+ page,
90
+ limit,
91
+ totalPages: Math.ceil(total / limit)
92
+ };
93
+ }
94
+
95
+ async getArticleById(id: number): Promise<Article> {
96
+ const article = this.articles.find(a => a.id === id);
97
+ if (!article) {
98
+ throw new Error('Article not found');
99
+ }
100
+ return article;
101
+ }
102
+
103
+ async createArticle(data: Partial<Article>): Promise<Article> {
104
+ const article: Article = {
105
+ id: this.nextId++,
106
+ title: data.title || 'Untitled',
107
+ content: data.content || '',
108
+ author: data.author || 'Anonymous',
109
+ createdAt: new Date().toISOString(),
110
+ updatedAt: new Date().toISOString()
111
+ };
112
+
113
+ this.articles.push(article);
114
+ return article;
115
+ }
116
+
117
+ async updateArticle(id: number, data: Partial<Article>): Promise<Article> {
118
+ const index = this.articles.findIndex(a => a.id === id);
119
+ if (index === -1) {
120
+ throw new Error('Article not found');
121
+ }
122
+
123
+ this.articles[index] = {
124
+ ...this.articles[index],
125
+ ...data,
126
+ updatedAt: new Date().toISOString()
127
+ };
128
+
129
+ return this.articles[index];
130
+ }
131
+
132
+ async deleteArticle(id: number): Promise<void> {
133
+ const index = this.articles.findIndex(a => a.id === id);
134
+ if (index === -1) {
135
+ throw new Error('Article not found');
136
+ }
137
+ this.articles.splice(index, 1);
138
+ }
139
+ }
140
+ ```
141
+
142
+ ### 3.2 文章控制器
143
+
144
+ 创建 `src/server/controllers/ArticleController.ts`:
145
+
146
+ ```typescript
147
+ import type { IControllerService } from '@linyjs/server-module-interface';
148
+ import { ArticleService } from '../services/ArticleService';
149
+
150
+ export class ArticleController implements IControllerService {
151
+ private articleService: ArticleService;
152
+
153
+ constructor() {
154
+ this.articleService = new ArticleService();
155
+ }
156
+
157
+ getRoutes() {
158
+ return [
159
+ {
160
+ method: 'GET' as const,
161
+ path: '/api/articles',
162
+ middlewares: [],
163
+ responseType: 'json' as const,
164
+ handler: async (params: any) => {
165
+ const page = parseInt(params.query?.page || '1');
166
+ const limit = parseInt(params.query?.limit || '10');
167
+ return await this.articleService.getArticles(page, limit);
168
+ }
169
+ },
170
+ {
171
+ method: 'POST' as const,
172
+ path: '/api/articles',
173
+ middlewares: [],
174
+ responseType: 'json' as const,
175
+ handler: async (params: any) => {
176
+ const article = await this.articleService.createArticle(params.body);
177
+ return { success: true, data: article };
178
+ }
179
+ }
180
+ // 添加更多路由...
181
+ ];
182
+ }
183
+ }
184
+ ```
185
+
186
+ ### 3.3 服务端模块入口
187
+
188
+ 创建 `src/server/index.ts`:
189
+
190
+ ```typescript
191
+ import type { IModule, IServiceDef } from '@linyjs/server-module-interface';
192
+ import { ArticleController } from './controllers/ArticleController';
193
+
194
+ const articleControllerDef: IServiceDef = {
195
+ serviceTag: 'articleController',
196
+ serviceImpl: ArticleController,
197
+ meta: { usageType: 'controller' }
198
+ };
199
+
200
+ export const blogServerModule: IModule = {
201
+ name: 'blogServer',
202
+ serviceDefs: [articleControllerDef]
203
+ };
204
+ ```
205
+
206
+ ## 步骤 4: 创建客户端代码
207
+
208
+ ### 4.1 文章列表组件
209
+
210
+ 创建 `src/client/components/ArticleCard.tsx`:
211
+
212
+ ```typescript
213
+ import React from 'react';
214
+ import type { Article } from '../../shared/types';
215
+
216
+ interface ArticleCardProps {
217
+ article: Article;
218
+ onClick?: () => void;
219
+ }
220
+
221
+ export function ArticleCard({ article, onClick }: ArticleCardProps) {
222
+ return (
223
+ <div
224
+ style={{
225
+ border: '1px solid #ddd',
226
+ borderRadius: '8px',
227
+ padding: '16px',
228
+ marginBottom: '16px',
229
+ cursor: onClick ? 'pointer' : 'default'
230
+ }}
231
+ onClick={onClick}
232
+ >
233
+ <h3 style={{ margin: '0 0 8px 0' }}>{article.title}</h3>
234
+ <p style={{ color: '#666', margin: '0 0 8px 0' }}>
235
+ By {article.author} • {new Date(article.createdAt).toLocaleDateString()}
236
+ </p>
237
+ <p style={{ margin: 0 }}>{article.content.substring(0, 100)}...</p>
238
+ </div>
239
+ );
240
+ }
241
+ ```
242
+
243
+ ### 4.2 文章列表页面
244
+
245
+ 创建 `src/client/pages/ArticleList.tsx`:
246
+
247
+ ```typescript
248
+ import React, { useState, useEffect } from 'react';
249
+ import type { Article, ArticleListResponse } from '../../shared/types';
250
+ import { ArticleCard } from '../components/ArticleCard';
251
+
252
+ export function ArticleList() {
253
+ const [articles, setArticles] = useState<Article[]>([]);
254
+ const [loading, setLoading] = useState(true);
255
+
256
+ useEffect(() => {
257
+ fetch('/api/articles')
258
+ .then(res => res.json())
259
+ .then((data: ArticleListResponse) => {
260
+ setArticles(data.data);
261
+ setLoading(false);
262
+ })
263
+ .catch(err => {
264
+ console.error('Failed to fetch articles:', err);
265
+ setLoading(false);
266
+ });
267
+ }, []);
268
+
269
+ if (loading) {
270
+ return <div>Loading...</div>;
271
+ }
272
+
273
+ return (
274
+ <div style={{ padding: '20px' }}>
275
+ <h1>Blog Articles</h1>
276
+ {articles.length === 0 ? (
277
+ <p>No articles yet.</p>
278
+ ) : (
279
+ articles.map(article => (
280
+ <ArticleCard key={article.id} article={article} />
281
+ ))
282
+ )}
283
+ </div>
284
+ );
285
+ }
286
+ ```
287
+
288
+ ### 4.3 客户端模块入口
289
+
290
+ 创建 `src/client/index.tsx`:
291
+
292
+ ```typescript
293
+ import type { IModule } from '@linyjs/client-module-interface';
294
+ import { ArticleList } from './pages/ArticleList';
295
+
296
+ class BlogRouteService {
297
+ basePath = '/blog';
298
+
299
+ getRoutes() {
300
+ return [
301
+ {
302
+ path: '/',
303
+ component: ArticleList,
304
+ key: 'article-list',
305
+ meta: { title: 'Blog' }
306
+ }
307
+ ];
308
+ }
309
+ }
310
+
311
+ const blogRouteDef: IServiceDef = {
312
+ serviceTag: 'blogRoute',
313
+ serviceImpl: BlogRouteService,
314
+ meta: { usageType: 'route' }
315
+ };
316
+
317
+ export const blogClientModule: IModule = {
318
+ name: 'blogClient',
319
+ serviceDefs: [blogRouteDef]
320
+ };
321
+ ```
322
+
323
+ ## 步骤 5: 构建和测试
324
+
325
+ ```bash
326
+ # 编译 TypeScript
327
+ npx tsc
328
+
329
+ # 打包为 .mpk
330
+ npx @linyjs/cli pack
331
+
332
+ # 测试插件
333
+ cp my-blog-plugin.mpk /path/to/linyjs/packages/ssr/extensions/
334
+ cd /path/to/linyjs/packages/ssr
335
+ npx tsx src/demo/dev-server-with-pkg.tsx
336
+ ```
337
+
338
+ 访问 `http://localhost:3000/blog` 查看你的博客插件!
339
+
340
+ ## 扩展功能
341
+
342
+ 现在你已经有了基础框架,可以尝试添加:
343
+
344
+ - 📝 文章详情页面
345
+ - ✏️ 文章编辑功能
346
+ - 🗑️ 文章删除功能
347
+ - 🔍 文章搜索功能
348
+ - 👤 用户认证和权限控制
349
+
350
+ ## 下一步
351
+
352
+ - 📖 阅读 [服务端模块开发](../guides/server-module.md) 深入学习后端开发
353
+ - 💻 阅读 [客户端模块开发](../guides/client-module.md) 学习前端开发
354
+ - 💾 阅读 [数据持久化](../guides/data-persistence.md) 学习如何使用 MongoDB
355
+
356
+ ---
357
+
358
+ **上一篇**: [安装指南](./installation.md) | **下一篇**: [服务端模块开发](../guides/server-module.md)
@@ -0,0 +1,244 @@
1
+ # 安装指南
2
+
3
+ 本指南将帮助你正确安装和配置 linyjs 框架及插件开发环境。
4
+
5
+ ## 前置要求
6
+
7
+ 在开始之前,请确保你的系统已安装以下软件:
8
+
9
+ - **Node.js** >= 18.0 ([下载地址](https://nodejs.org/))
10
+ - **npm** >= 9.0 (通常随 Node.js 一起安装)
11
+ - **Git** (用于版本控制)
12
+
13
+ ### 验证安装
14
+
15
+ ```bash
16
+ # 检查 Node.js 版本
17
+ node --version
18
+ # 应显示: v18.x.x 或更高
19
+
20
+ # 检查 npm 版本
21
+ npm --version
22
+ # 应显示: 9.x.x 或更高
23
+
24
+ # 检查 Git
25
+ git --version
26
+ ```
27
+
28
+ ## 安装 linyjs 核心包
29
+
30
+ linyjs 框架由多个 NPM 包组成。根据你的需求,可以选择性安装:
31
+
32
+ ### 1. 安装接口包(必需)
33
+
34
+ 这些包定义了插件开发的接口规范:
35
+
36
+ ```bash
37
+ npm install @linyjs/server-module-interface
38
+ npm install @linyjs/client-module-interface
39
+ npm install @linyjs/ui-slots-interface
40
+ ```
41
+
42
+ ### 2. 安装 CLI 工具(推荐)
43
+
44
+ CLI 工具提供零配置的插件打包功能:
45
+
46
+ ```bash
47
+ # 全局安装
48
+ npm install -g @linyjs/cli
49
+
50
+ # 或在项目中使用
51
+ npx @linyjs/cli <command>
52
+ ```
53
+
54
+ ### 3. 安装文档包(推荐)
55
+
56
+ 文档包包含完整的教程和示例:
57
+
58
+ ```bash
59
+ npm install @linyjs/plugin-docs
60
+ ```
61
+
62
+ 安装后,文档位于 `node_modules/@linyjs/plugin-docs/docs/`。
63
+
64
+ ### 4. 安装其他可选包
65
+
66
+ ```bash
67
+ # MongoDB 服务(数据持久化)
68
+ npm install @linyjs/mdb
69
+
70
+ # 权限管理
71
+ npm install @linyjs/permission
72
+
73
+ # 管理后台
74
+ npm install @linyjs/admin
75
+ ```
76
+
77
+ ## 初始化插件项目
78
+
79
+ ### 方法 1: 使用 CLI 工具(推荐)
80
+
81
+ ```bash
82
+ # 创建新项目
83
+ npx @linyjs/cli init my-plugin
84
+
85
+ # 进入项目目录
86
+ cd my-plugin
87
+
88
+ # 安装依赖
89
+ npm install
90
+ ```
91
+
92
+ ### 方法 2: 手动创建
93
+
94
+ ```bash
95
+ # 创建项目目录
96
+ mkdir my-plugin && cd my-plugin
97
+
98
+ # 初始化 npm
99
+ npm init -y
100
+
101
+ # 安装依赖
102
+ npm install @linyjs/server-module-interface @linyjs/client-module-interface react
103
+ npm install -D typescript @types/react
104
+
105
+ # 创建 TypeScript 配置
106
+ cat > tsconfig.json << 'EOF'
107
+ {
108
+ "compilerOptions": {
109
+ "target": "ES2020",
110
+ "module": "ESNext",
111
+ "lib": ["ES2020", "DOM"],
112
+ "jsx": "react-jsx",
113
+ "declaration": true,
114
+ "outDir": "./dist",
115
+ "rootDir": "./src",
116
+ "strict": true,
117
+ "esModuleInterop": true,
118
+ "skipLibCheck": true,
119
+ "moduleResolution": "node"
120
+ },
121
+ "include": ["src/**/*"]
122
+ }
123
+ EOF
124
+
125
+ # 创建目录结构
126
+ mkdir -p src/{server,client}
127
+ ```
128
+
129
+ ## 配置开发环境
130
+
131
+ ### VS Code 推荐扩展
132
+
133
+ - **TypeScript and JavaScript Language Features** (内置)
134
+ - **ESLint** - 代码质量检查
135
+ - **Prettier** - 代码格式化
136
+ - **React Developer Tools** - React 调试
137
+
138
+ ### ESLint 配置(可选)
139
+
140
+ ```bash
141
+ npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
142
+ ```
143
+
144
+ 创建 `.eslintrc.json`:
145
+
146
+ ```json
147
+ {
148
+ "parser": "@typescript-eslint/parser",
149
+ "plugins": ["@typescript-eslint"],
150
+ "extends": [
151
+ "eslint:recommended",
152
+ "plugin:@typescript-eslint/recommended"
153
+ ],
154
+ "rules": {
155
+ "@typescript-eslint/explicit-function-return-type": "off",
156
+ "@typescript-eslint/no-explicit-any": "warn"
157
+ }
158
+ }
159
+ ```
160
+
161
+ ## 验证安装
162
+
163
+ 创建一个简单的测试文件来验证安装是否正确:
164
+
165
+ **src/server/test.ts:**
166
+
167
+ ```typescript
168
+ import type { IModule } from '@linyjs/server-module-interface';
169
+
170
+ console.log('✓ Server module interface imported successfully');
171
+
172
+ export const testModule: IModule = {
173
+ name: 'test',
174
+ serviceDefs: []
175
+ };
176
+ ```
177
+
178
+ **src/client/test.tsx:**
179
+
180
+ ```typescript
181
+ import type { IModule } from '@linyjs/client-module-interface';
182
+ import React from 'react';
183
+
184
+ console.log('✓ Client module interface imported successfully');
185
+
186
+ export const testModule: IModule = {
187
+ name: 'test',
188
+ serviceDefs: []
189
+ };
190
+ ```
191
+
192
+ 编译测试:
193
+
194
+ ```bash
195
+ npx tsc
196
+ ```
197
+
198
+ 如果编译成功且无错误,说明安装正确!
199
+
200
+ ## 常见问题
201
+
202
+ ### Q: 安装时遇到权限错误?
203
+
204
+ **A:** 尝试使用 `sudo`(macOS/Linux)或以管理员身份运行命令提示符(Windows):
205
+
206
+ ```bash
207
+ sudo npm install -g @linyjs/cli
208
+ ```
209
+
210
+ 或者配置 npm 使用用户目录:
211
+
212
+ ```bash
213
+ npm config set prefix ~/.npm-global
214
+ echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
215
+ source ~/.bashrc
216
+ ```
217
+
218
+ ### Q: TypeScript 编译错误?
219
+
220
+ **A:** 确保安装了正确的 TypeScript 版本:
221
+
222
+ ```bash
223
+ npm install -D typescript@^5.7.0
224
+ ```
225
+
226
+ ### Q: 如何更新到最新版本?
227
+
228
+ **A:** 使用 npm update:
229
+
230
+ ```bash
231
+ npm update @linyjs/server-module-interface
232
+ npm update @linyjs/client-module-interface
233
+ npm update @linyjs/cli
234
+ ```
235
+
236
+ ## 下一步
237
+
238
+ - 🎯 阅读 [快速开始](./quick-start.md) 创建你的第一个插件
239
+ - 📖 查看 [第一个插件教程](./first-plugin.md) 深入学习
240
+ - 💡 浏览 [示例项目](../../examples/) 获取完整代码参考
241
+
242
+ ---
243
+
244
+ **上一篇**: [快速开始](./quick-start.md) | **下一篇**: [第一个插件教程](./first-plugin.md)