create-rstack 2.1.2 → 3.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 (272) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +43 -73
  3. package/bin.js +2 -0
  4. package/dist/index.js +202 -3588
  5. package/package.json +26 -46
  6. package/template-app-lit-js/package.json +23 -0
  7. package/template-app-lit-js/rstack.config.js +28 -0
  8. package/template-app-lit-js/src/index.css +6 -0
  9. package/template-app-lit-js/src/index.html +7 -0
  10. package/template-app-lit-js/src/index.js +4 -0
  11. package/template-app-lit-js/src/my-element.js +34 -0
  12. package/template-app-lit-js/tests/index.test.js +12 -0
  13. package/template-app-lit-ts/package.json +25 -0
  14. package/template-app-lit-ts/rstack.config.ts +27 -0
  15. package/template-app-lit-ts/src/index.css +6 -0
  16. package/template-app-lit-ts/src/index.html +7 -0
  17. package/template-app-lit-ts/src/index.ts +4 -0
  18. package/template-app-lit-ts/src/my-element.ts +34 -0
  19. package/template-app-lit-ts/tests/index.test.ts +12 -0
  20. package/template-app-lit-ts/tsconfig.json +23 -0
  21. package/template-app-preact-js/package.json +26 -0
  22. package/template-app-preact-js/rstack.config.js +29 -0
  23. package/template-app-preact-js/src/App.css +26 -0
  24. package/template-app-preact-js/src/App.jsx +12 -0
  25. package/template-app-preact-js/src/index.jsx +4 -0
  26. package/template-app-preact-js/tests/index.test.jsx +8 -0
  27. package/template-app-preact-js/tests/rstest.setup.js +4 -0
  28. package/template-app-preact-ts/package.json +28 -0
  29. package/template-app-preact-ts/rstack.config.ts +29 -0
  30. package/template-app-preact-ts/src/App.css +26 -0
  31. package/template-app-preact-ts/src/App.tsx +12 -0
  32. package/template-app-preact-ts/src/index.tsx +7 -0
  33. package/template-app-preact-ts/tests/index.test.tsx +8 -0
  34. package/template-app-preact-ts/tests/rstest.setup.ts +4 -0
  35. package/template-app-preact-ts/tests/tsconfig.json +7 -0
  36. package/template-app-preact-ts/tsconfig.json +28 -0
  37. package/template-app-react-js/package.json +28 -0
  38. package/template-app-react-js/rstack.config.js +29 -0
  39. package/template-app-react-js/src/App.css +26 -0
  40. package/template-app-react-js/src/App.jsx +12 -0
  41. package/template-app-react-js/src/index.jsx +10 -0
  42. package/template-app-react-js/tests/index.test.jsx +8 -0
  43. package/template-app-react-js/tests/rstest.setup.js +4 -0
  44. package/template-app-react-ts/package.json +32 -0
  45. package/template-app-react-ts/rstack.config.ts +29 -0
  46. package/template-app-react-ts/src/App.css +26 -0
  47. package/template-app-react-ts/src/App.tsx +12 -0
  48. package/template-app-react-ts/src/env.d.ts +9 -0
  49. package/template-app-react-ts/src/index.tsx +13 -0
  50. package/template-app-react-ts/tests/index.test.tsx +8 -0
  51. package/template-app-react-ts/tests/rstest.setup.ts +4 -0
  52. package/template-app-react-ts/tests/tsconfig.json +7 -0
  53. package/template-app-react-ts/tsconfig.json +23 -0
  54. package/template-app-solid-js/package.json +27 -0
  55. package/template-app-solid-js/rstack.config.js +31 -0
  56. package/template-app-solid-js/src/App.css +26 -0
  57. package/template-app-solid-js/src/App.jsx +12 -0
  58. package/template-app-solid-js/src/index.jsx +4 -0
  59. package/template-app-solid-js/tests/index.test.jsx +8 -0
  60. package/template-app-solid-js/tests/rstest.setup.js +4 -0
  61. package/template-app-solid-ts/package.json +29 -0
  62. package/template-app-solid-ts/rstack.config.ts +30 -0
  63. package/template-app-solid-ts/src/App.css +26 -0
  64. package/template-app-solid-ts/src/App.tsx +12 -0
  65. package/template-app-solid-ts/src/index.tsx +7 -0
  66. package/template-app-solid-ts/tests/index.test.tsx +8 -0
  67. package/template-app-solid-ts/tests/rstest.setup.ts +4 -0
  68. package/template-app-solid-ts/tests/tsconfig.json +7 -0
  69. package/template-app-solid-ts/tsconfig.json +24 -0
  70. package/template-app-svelte-js/package.json +27 -0
  71. package/template-app-svelte-js/pnpm-workspace.yaml +2 -0
  72. package/template-app-svelte-js/rstack.config.js +26 -0
  73. package/template-app-svelte-js/src/App.svelte +28 -0
  74. package/template-app-svelte-js/src/index.css +6 -0
  75. package/template-app-svelte-js/src/index.js +8 -0
  76. package/template-app-svelte-js/tests/index.test.js +8 -0
  77. package/template-app-svelte-js/tests/rstest.setup.js +4 -0
  78. package/template-app-svelte-ts/package.json +30 -0
  79. package/template-app-svelte-ts/pnpm-workspace.yaml +2 -0
  80. package/template-app-svelte-ts/rstack.config.ts +25 -0
  81. package/template-app-svelte-ts/src/App.svelte +37 -0
  82. package/template-app-svelte-ts/src/index.css +6 -0
  83. package/template-app-svelte-ts/src/index.ts +14 -0
  84. package/template-app-svelte-ts/tests/index.test.ts +11 -0
  85. package/template-app-svelte-ts/tests/rstest.setup.ts +4 -0
  86. package/template-app-svelte-ts/tests/tsconfig.json +7 -0
  87. package/template-app-svelte-ts/tsconfig.json +22 -0
  88. package/template-app-vanilla-js/package.json +22 -0
  89. package/template-app-vanilla-js/rstack.config.js +21 -0
  90. package/template-app-vanilla-js/src/index.css +26 -0
  91. package/template-app-vanilla-js/src/index.js +12 -0
  92. package/template-app-vanilla-js/tests/dom.test.js +12 -0
  93. package/template-app-vanilla-js/tests/rstest.setup.js +4 -0
  94. package/template-app-vanilla-ts/package.json +24 -0
  95. package/template-app-vanilla-ts/rstack.config.ts +20 -0
  96. package/template-app-vanilla-ts/src/index.css +26 -0
  97. package/template-app-vanilla-ts/src/index.ts +12 -0
  98. package/template-app-vanilla-ts/tests/dom.test.ts +12 -0
  99. package/template-app-vanilla-ts/tests/rstest.setup.ts +4 -0
  100. package/template-app-vanilla-ts/tests/tsconfig.json +7 -0
  101. package/template-app-vanilla-ts/tsconfig.json +22 -0
  102. package/template-app-vue-js/package.json +26 -0
  103. package/template-app-vue-js/rstack.config.js +25 -0
  104. package/template-app-vue-js/src/App.vue +28 -0
  105. package/template-app-vue-js/src/index.css +6 -0
  106. package/template-app-vue-js/src/index.js +5 -0
  107. package/template-app-vue-js/tests/index.test.js +8 -0
  108. package/template-app-vue-js/tests/rstest.setup.js +6 -0
  109. package/template-app-vue-ts/package.json +29 -0
  110. package/template-app-vue-ts/rstack.config.ts +24 -0
  111. package/template-app-vue-ts/src/App.vue +28 -0
  112. package/template-app-vue-ts/src/index.css +6 -0
  113. package/template-app-vue-ts/src/index.ts +5 -0
  114. package/template-app-vue-ts/tests/index.test.ts +8 -0
  115. package/template-app-vue-ts/tests/rstest.setup.ts +6 -0
  116. package/template-app-vue-ts/tests/tsconfig.json +7 -0
  117. package/template-app-vue-ts/tsconfig.json +24 -0
  118. package/template-common/AGENTS.md +7 -0
  119. package/template-common/README.md +34 -0
  120. package/template-common/gitignore +13 -0
  121. package/template-doc-basic/README.md +34 -0
  122. package/template-doc-basic/docs/_nav.json +16 -0
  123. package/template-doc-basic/docs/api/_meta.json +1 -0
  124. package/template-doc-basic/docs/api/commands.mdx +25 -0
  125. package/template-doc-basic/docs/api/index.mdx +6 -0
  126. package/template-doc-basic/docs/guide/_meta.json +7 -0
  127. package/template-doc-basic/docs/guide/start/_meta.json +1 -0
  128. package/template-doc-basic/docs/guide/start/introduction.md +5 -0
  129. package/template-doc-basic/docs/index.md +39 -0
  130. package/template-doc-basic/gitignore +14 -0
  131. package/template-doc-basic/package.json +24 -0
  132. package/template-doc-basic/rstack.config.ts +23 -0
  133. package/template-doc-basic/tsconfig.json +26 -0
  134. package/template-doc-i18n/README.md +34 -0
  135. package/template-doc-i18n/docs/en/_nav.json +16 -0
  136. package/template-doc-i18n/docs/en/api/_meta.json +1 -0
  137. package/template-doc-i18n/docs/en/api/commands.mdx +25 -0
  138. package/template-doc-i18n/docs/en/api/index.mdx +6 -0
  139. package/template-doc-i18n/docs/en/guide/_meta.json +7 -0
  140. package/template-doc-i18n/docs/en/guide/start/_meta.json +1 -0
  141. package/template-doc-i18n/docs/en/guide/start/introduction.md +5 -0
  142. package/template-doc-i18n/docs/en/index.md +39 -0
  143. package/template-doc-i18n/docs/zh/_nav.json +16 -0
  144. package/template-doc-i18n/docs/zh/api/_meta.json +12 -0
  145. package/template-doc-i18n/docs/zh/api/commands.mdx +25 -0
  146. package/template-doc-i18n/docs/zh/api/index.mdx +6 -0
  147. package/template-doc-i18n/docs/zh/guide/_meta.json +7 -0
  148. package/template-doc-i18n/docs/zh/guide/start/_meta.json +7 -0
  149. package/template-doc-i18n/docs/zh/guide/start/introduction.md +5 -0
  150. package/template-doc-i18n/docs/zh/index.md +39 -0
  151. package/template-doc-i18n/gitignore +14 -0
  152. package/template-doc-i18n/package.json +24 -0
  153. package/template-doc-i18n/rstack.config.ts +39 -0
  154. package/template-doc-i18n/tsconfig.json +26 -0
  155. package/template-lib-node-js/README.md +40 -0
  156. package/template-lib-node-js/package.json +33 -0
  157. package/template-lib-node-js/rstack.config.js +21 -0
  158. package/template-lib-node-js/src/index.js +1 -0
  159. package/template-lib-node-js/tests/index.test.js +7 -0
  160. package/template-lib-node-ts/README.md +40 -0
  161. package/template-lib-node-ts/package.json +37 -0
  162. package/template-lib-node-ts/rstack.config.ts +21 -0
  163. package/template-lib-node-ts/src/index.ts +1 -0
  164. package/template-lib-node-ts/tests/index.test.ts +7 -0
  165. package/template-lib-node-ts/tsconfig.json +23 -0
  166. package/template-lib-react-js/README.md +40 -0
  167. package/template-lib-react-js/package.json +41 -0
  168. package/template-lib-react-js/rstack.config.js +38 -0
  169. package/template-lib-react-js/src/Button.jsx +21 -0
  170. package/template-lib-react-js/src/button.css +34 -0
  171. package/template-lib-react-js/src/index.jsx +1 -0
  172. package/template-lib-react-js/tests/index.test.jsx +11 -0
  173. package/template-lib-react-js/tests/rstest.setup.js +4 -0
  174. package/template-lib-react-ts/README.md +40 -0
  175. package/template-lib-react-ts/package.json +46 -0
  176. package/template-lib-react-ts/rstack.config.ts +39 -0
  177. package/template-lib-react-ts/src/Button.tsx +46 -0
  178. package/template-lib-react-ts/src/button.css +34 -0
  179. package/template-lib-react-ts/src/index.tsx +1 -0
  180. package/template-lib-react-ts/tests/index.test.tsx +11 -0
  181. package/template-lib-react-ts/tests/rstest.setup.ts +4 -0
  182. package/template-lib-react-ts/tests/tsconfig.json +8 -0
  183. package/template-lib-react-ts/tsconfig.json +24 -0
  184. package/template-lib-solid-js/README.md +40 -0
  185. package/template-lib-solid-js/package.json +39 -0
  186. package/template-lib-solid-js/rstack.config.js +86 -0
  187. package/template-lib-solid-js/src/Button.jsx +18 -0
  188. package/template-lib-solid-js/src/button.css +34 -0
  189. package/template-lib-solid-js/src/index.jsx +1 -0
  190. package/template-lib-solid-js/tests/index.test.jsx +11 -0
  191. package/template-lib-solid-js/tests/rstest.setup.js +4 -0
  192. package/template-lib-solid-ts/README.md +40 -0
  193. package/template-lib-solid-ts/package.json +43 -0
  194. package/template-lib-solid-ts/rstack.config.ts +86 -0
  195. package/template-lib-solid-ts/src/Button.tsx +43 -0
  196. package/template-lib-solid-ts/src/button.css +34 -0
  197. package/template-lib-solid-ts/src/index.tsx +2 -0
  198. package/template-lib-solid-ts/tests/index.test.tsx +11 -0
  199. package/template-lib-solid-ts/tests/rstest.setup.ts +4 -0
  200. package/template-lib-solid-ts/tests/tsconfig.json +8 -0
  201. package/template-lib-solid-ts/tsconfig.json +25 -0
  202. package/template-lib-svelte-js/README.md +40 -0
  203. package/template-lib-svelte-js/package.json +36 -0
  204. package/template-lib-svelte-js/pnpm-workspace.yaml +2 -0
  205. package/template-lib-svelte-js/rstack.config.js +35 -0
  206. package/template-lib-svelte-js/src/Button.svelte +24 -0
  207. package/template-lib-svelte-js/src/button.css +34 -0
  208. package/template-lib-svelte-js/src/index.js +1 -0
  209. package/template-lib-svelte-js/tests/index.test.js +19 -0
  210. package/template-lib-svelte-ts/README.md +40 -0
  211. package/template-lib-svelte-ts/package.json +42 -0
  212. package/template-lib-svelte-ts/pnpm-workspace.yaml +2 -0
  213. package/template-lib-svelte-ts/rstack.config.ts +35 -0
  214. package/template-lib-svelte-ts/scripts/rslib-plugin-svelte-dts.ts +59 -0
  215. package/template-lib-svelte-ts/src/Button.svelte +34 -0
  216. package/template-lib-svelte-ts/src/button.css +34 -0
  217. package/template-lib-svelte-ts/src/index.ts +1 -0
  218. package/template-lib-svelte-ts/tests/index.test.ts +19 -0
  219. package/template-lib-svelte-ts/tests/tsconfig.json +7 -0
  220. package/template-lib-svelte-ts/tsconfig.json +25 -0
  221. package/template-lib-vue-js/README.md +40 -0
  222. package/template-lib-vue-js/package.json +37 -0
  223. package/template-lib-vue-js/rstack.config.js +34 -0
  224. package/template-lib-vue-js/src/Button.vue +43 -0
  225. package/template-lib-vue-js/src/button.css +34 -0
  226. package/template-lib-vue-js/src/index.js +1 -0
  227. package/template-lib-vue-js/tests/index.test.js +17 -0
  228. package/template-lib-vue-js/tests/rstest.setup.js +6 -0
  229. package/template-lib-vue-ts/README.md +40 -0
  230. package/template-lib-vue-ts/package.json +42 -0
  231. package/template-lib-vue-ts/rstack.config.ts +33 -0
  232. package/template-lib-vue-ts/src/Button.vue +35 -0
  233. package/template-lib-vue-ts/src/button.css +34 -0
  234. package/template-lib-vue-ts/src/index.ts +1 -0
  235. package/template-lib-vue-ts/tests/index.test.ts +17 -0
  236. package/template-lib-vue-ts/tests/rstest.setup.ts +6 -0
  237. package/template-lib-vue-ts/tests/tsconfig.json +8 -0
  238. package/template-lib-vue-ts/tsconfig.json +27 -0
  239. package/dist/index.d.ts +0 -316
  240. package/template-biome/AGENTS.md +0 -6
  241. package/template-biome/biome.json.template +0 -34
  242. package/template-biome/package.json +0 -12
  243. package/template-eslint/AGENTS.md +0 -5
  244. package/template-eslint/react-js/eslint.config.mjs +0 -23
  245. package/template-eslint/react-js/package.json +0 -15
  246. package/template-eslint/react-ts/eslint.config.mjs +0 -22
  247. package/template-eslint/react-ts/package.json +0 -16
  248. package/template-eslint/svelte-js/eslint.config.mjs +0 -20
  249. package/template-eslint/svelte-js/package.json +0 -14
  250. package/template-eslint/svelte-ts/eslint.config.mjs +0 -28
  251. package/template-eslint/svelte-ts/package.json +0 -16
  252. package/template-eslint/vanilla-js/eslint.config.mjs +0 -8
  253. package/template-eslint/vanilla-js/package.json +0 -13
  254. package/template-eslint/vanilla-ts/eslint.config.mjs +0 -10
  255. package/template-eslint/vanilla-ts/package.json +0 -14
  256. package/template-eslint/vue-js/eslint.config.mjs +0 -15
  257. package/template-eslint/vue-js/package.json +0 -14
  258. package/template-eslint/vue-ts/eslint.config.mjs +0 -23
  259. package/template-eslint/vue-ts/package.json +0 -15
  260. package/template-prettier/.prettierignore +0 -4
  261. package/template-prettier/.prettierrc +0 -3
  262. package/template-prettier/AGENTS.md +0 -5
  263. package/template-prettier/package.json +0 -11
  264. package/template-rslint/AGENTS.md +0 -9
  265. package/template-rslint/react-js/package.json +0 -11
  266. package/template-rslint/react-js/rslint.config.ts +0 -7
  267. package/template-rslint/react-ts/package.json +0 -11
  268. package/template-rslint/react-ts/rslint.config.ts +0 -14
  269. package/template-rslint/vanilla-js/package.json +0 -11
  270. package/template-rslint/vanilla-js/rslint.config.ts +0 -3
  271. package/template-rslint/vanilla-ts/package.json +0 -11
  272. package/template-rslint/vanilla-ts/rslint.config.ts +0 -3
@@ -0,0 +1,39 @@
1
+ // Rstack configuration guide: https://rstack.rs/config
2
+ import { define } from 'rstack';
3
+
4
+ define.lib(async () => {
5
+ const { pluginReact } = await import('@rsbuild/plugin-react');
6
+
7
+ return {
8
+ bundle: false,
9
+ dts: true,
10
+ source: {
11
+ entry: {
12
+ index: ['./src/**'],
13
+ },
14
+ },
15
+ output: {
16
+ target: 'web',
17
+ },
18
+ plugins: [pluginReact()],
19
+ };
20
+ });
21
+
22
+ define.test({
23
+ setupFiles: ['./tests/rstest.setup.ts'],
24
+ });
25
+
26
+ define.lint(async () => {
27
+ const { js, ts, reactPlugin, reactHooksPlugin } = await import('rstack/lint');
28
+
29
+ return [
30
+ js.configs.recommended,
31
+ ts.configs.recommended,
32
+ reactPlugin.configs.recommended,
33
+ reactHooksPlugin.configs.recommended,
34
+ ];
35
+ });
36
+
37
+ define.fmt({
38
+ singleQuote: true,
39
+ });
@@ -0,0 +1,46 @@
1
+ import './button.css';
2
+
3
+ export interface ButtonProps {
4
+ /**
5
+ * Whether the button is primary
6
+ * @default false
7
+ */
8
+ primary?: boolean;
9
+ /**
10
+ * Background color of the button
11
+ */
12
+ backgroundColor?: string;
13
+ /**
14
+ * Size of Button
15
+ * @default 'medium'
16
+ */
17
+ size?: 'small' | 'medium' | 'large';
18
+ /**
19
+ * Label of the button
20
+ */
21
+ label: string;
22
+ /**
23
+ * Optional click handler
24
+ */
25
+ onClick?: () => void;
26
+ }
27
+
28
+ export const Button = ({
29
+ primary = false,
30
+ size = 'medium',
31
+ backgroundColor,
32
+ label,
33
+ ...props
34
+ }: ButtonProps) => {
35
+ const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
36
+ return (
37
+ <button
38
+ type="button"
39
+ className={['demo-button', `demo-button--${size}`, mode].join(' ')}
40
+ style={{ backgroundColor }}
41
+ {...props}
42
+ >
43
+ {label}
44
+ </button>
45
+ );
46
+ };
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0 0 0 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1 @@
1
+ export { Button } from './Button';
@@ -0,0 +1,11 @@
1
+ import { expect, test } from 'rstack/test';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { Button } from '../src/Button';
4
+
5
+ test('The button should have correct background color', async () => {
6
+ render(<Button backgroundColor="#ccc" label="Demo Button" />);
7
+ const button = screen.getByText('Demo Button');
8
+ expect(button).toHaveStyle({
9
+ backgroundColor: '#ccc',
10
+ });
11
+ });
@@ -0,0 +1,4 @@
1
+ import { expect } from 'rstack/test';
2
+ import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3
+
4
+ expect.extend(jestDomMatchers);
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "..",
5
+ "types": ["@testing-library/jest-dom"]
6
+ },
7
+ "include": ["./"]
8
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["DOM", "ES2022"],
4
+ "jsx": "react-jsx",
5
+ "target": "ES2022",
6
+ "noEmit": true,
7
+ "skipLibCheck": true,
8
+ "types": ["rstack/types", "node"],
9
+ "useDefineForClassFields": true,
10
+ "rootDir": "src",
11
+
12
+ /* modules */
13
+ "moduleDetection": "force",
14
+ "moduleResolution": "bundler",
15
+ "verbatimModuleSyntax": true,
16
+ "resolveJsonModule": true,
17
+ "allowImportingTsExtensions": true,
18
+
19
+ /* type checking */
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true
22
+ },
23
+ "include": ["src"]
24
+ }
@@ -0,0 +1,40 @@
1
+ # Rstack library
2
+
3
+ ## Setup
4
+
5
+ Install the dependencies:
6
+
7
+ ```bash
8
+ {{ packageManager }} install
9
+ ```
10
+
11
+ ## Get started
12
+
13
+ Build the library:
14
+
15
+ ```bash
16
+ {{ packageManager }} run build
17
+ ```
18
+
19
+ Build the library in watch mode:
20
+
21
+ ```bash
22
+ {{ packageManager }} run dev
23
+ ```
24
+
25
+ Run tests:
26
+
27
+ ```bash
28
+ {{ packageManager }} run test
29
+ ```
30
+
31
+ Run tests in watch mode:
32
+
33
+ ```bash
34
+ {{ packageManager }} run test:watch
35
+ ```
36
+
37
+ ## Learn more
38
+
39
+ - [Rstack documentation](https://rstack.rs)
40
+ - [Rslib documentation](https://rslib.rs)
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "rstack-lib-solid-js",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "solid": "./dist/index.jsx",
8
+ "default": "./dist/index.js"
9
+ }
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "build": "rs lib",
17
+ "check": "rs lint && rs fmt --check",
18
+ "dev": "rs lib --watch",
19
+ "format": "rs fmt",
20
+ "lint": "rs lint",
21
+ "test": "rs test",
22
+ "test:watch": "rs test --watch"
23
+ },
24
+ "devDependencies": {
25
+ "@rsbuild/plugin-babel": "^2.0.1",
26
+ "@rsbuild/plugin-solid": "^1.2.2",
27
+ "@solidjs/testing-library": "^0.8.10",
28
+ "@testing-library/jest-dom": "^7.0.0",
29
+ "happy-dom": "^20.11.2",
30
+ "rstack": "^0.4.0",
31
+ "solid-js": "^1.9.14"
32
+ },
33
+ "peerDependencies": {
34
+ "solid-js": ">=1.8.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ }
39
+ }
@@ -0,0 +1,86 @@
1
+ // @ts-check
2
+ // Rstack configuration guide: https://rstack.rs/config
3
+ import { define } from 'rstack';
4
+
5
+ define.lib(async () => {
6
+ const { pluginBabel } = await import('@rsbuild/plugin-babel');
7
+ const { pluginSolid } = await import('@rsbuild/plugin-solid');
8
+
9
+ return {
10
+ lib: [
11
+ {
12
+ id: 'compiled',
13
+ bundle: false,
14
+ plugins: [
15
+ pluginBabel({
16
+ include: /\.(?:jsx|tsx)$/,
17
+ }),
18
+ pluginSolid(),
19
+ ],
20
+ },
21
+ {
22
+ id: 'source',
23
+ bundle: false,
24
+ output: {
25
+ filename: {
26
+ js: '[name].jsx',
27
+ },
28
+ },
29
+ tools: {
30
+ swc: {
31
+ detectSyntax: 'auto',
32
+ jsc: {
33
+ transform: {
34
+ react: {
35
+ runtime: 'preserve',
36
+ },
37
+ },
38
+ },
39
+ },
40
+ rspack: {
41
+ module: {
42
+ parser: {
43
+ javascript: {
44
+ jsx: true,
45
+ },
46
+ },
47
+ },
48
+ },
49
+ },
50
+ },
51
+ ],
52
+ source: {
53
+ entry: {
54
+ index: ['./src/**'],
55
+ },
56
+ },
57
+ output: {
58
+ target: 'web',
59
+ },
60
+ };
61
+ });
62
+
63
+ define.test(async () => {
64
+ const { pluginBabel } = await import('@rsbuild/plugin-babel');
65
+ const { pluginSolid } = await import('@rsbuild/plugin-solid');
66
+
67
+ return {
68
+ setupFiles: ['./tests/rstest.setup.js'],
69
+ plugins: [
70
+ pluginBabel({
71
+ include: /\.(?:jsx|tsx)$/,
72
+ }),
73
+ pluginSolid(),
74
+ ],
75
+ };
76
+ });
77
+
78
+ define.lint(async () => {
79
+ const { js } = await import('rstack/lint');
80
+
81
+ return [js.configs.recommended];
82
+ });
83
+
84
+ define.fmt({
85
+ singleQuote: true,
86
+ });
@@ -0,0 +1,18 @@
1
+ import './button.css';
2
+
3
+ export function Button(props) {
4
+ const mode = () =>
5
+ props.primary ? 'demo-button--primary' : 'demo-button--secondary';
6
+ const size = () => props.size ?? 'medium';
7
+
8
+ return (
9
+ <button
10
+ type="button"
11
+ class={`demo-button demo-button--${size()} ${mode()}`}
12
+ style={{ 'background-color': props.backgroundColor }}
13
+ onClick={props.onClick}
14
+ >
15
+ {props.label}
16
+ </button>
17
+ );
18
+ }
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0 0 0 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1 @@
1
+ export { Button } from './Button';
@@ -0,0 +1,11 @@
1
+ import { render, screen } from '@solidjs/testing-library';
2
+ import { expect, test } from 'rstack/test';
3
+ import { Button } from '../src/Button';
4
+
5
+ test('The button should have correct background color', async () => {
6
+ render(() => <Button backgroundColor="#ccc" label="Demo Button" />);
7
+ const button = screen.getByText('Demo Button');
8
+ expect(button).toHaveStyle({
9
+ 'background-color': '#ccc',
10
+ });
11
+ });
@@ -0,0 +1,4 @@
1
+ import { expect } from 'rstack/test';
2
+ import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3
+
4
+ expect.extend(jestDomMatchers);
@@ -0,0 +1,40 @@
1
+ # Rstack library
2
+
3
+ ## Setup
4
+
5
+ Install the dependencies:
6
+
7
+ ```bash
8
+ {{ packageManager }} install
9
+ ```
10
+
11
+ ## Get started
12
+
13
+ Build the library:
14
+
15
+ ```bash
16
+ {{ packageManager }} run build
17
+ ```
18
+
19
+ Build the library in watch mode:
20
+
21
+ ```bash
22
+ {{ packageManager }} run dev
23
+ ```
24
+
25
+ Run tests:
26
+
27
+ ```bash
28
+ {{ packageManager }} run test
29
+ ```
30
+
31
+ Run tests in watch mode:
32
+
33
+ ```bash
34
+ {{ packageManager }} run test:watch
35
+ ```
36
+
37
+ ## Learn more
38
+
39
+ - [Rstack documentation](https://rstack.rs)
40
+ - [Rslib documentation](https://rslib.rs)
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "rstack-lib-solid-ts",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "solid": "./dist/index.jsx",
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "types": "./dist/index.d.ts",
13
+ "files": [
14
+ "dist",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "rs lib",
19
+ "check": "rs lint --type-check && rs fmt --check",
20
+ "dev": "rs lib --watch",
21
+ "format": "rs fmt",
22
+ "lint": "rs lint",
23
+ "test": "rs test",
24
+ "test:watch": "rs test --watch"
25
+ },
26
+ "devDependencies": {
27
+ "@rsbuild/plugin-babel": "^2.0.1",
28
+ "@rsbuild/plugin-solid": "^1.2.2",
29
+ "@solidjs/testing-library": "^0.8.10",
30
+ "@testing-library/jest-dom": "^7.0.0",
31
+ "@types/node": "^24.13.3",
32
+ "happy-dom": "^20.11.2",
33
+ "rstack": "^0.4.0",
34
+ "solid-js": "^1.9.14",
35
+ "typescript": "^7.0.2"
36
+ },
37
+ "peerDependencies": {
38
+ "solid-js": ">=1.8.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ }
43
+ }
@@ -0,0 +1,86 @@
1
+ // Rstack configuration guide: https://rstack.rs/config
2
+ import { define } from 'rstack';
3
+
4
+ define.lib(async () => {
5
+ const { pluginBabel } = await import('@rsbuild/plugin-babel');
6
+ const { pluginSolid } = await import('@rsbuild/plugin-solid');
7
+
8
+ return {
9
+ lib: [
10
+ {
11
+ id: 'compiled',
12
+ bundle: false,
13
+ dts: true,
14
+ plugins: [
15
+ pluginBabel({
16
+ include: /\.(?:jsx|tsx)$/,
17
+ }),
18
+ pluginSolid(),
19
+ ],
20
+ },
21
+ {
22
+ id: 'source',
23
+ bundle: false,
24
+ output: {
25
+ filename: {
26
+ js: '[name].jsx',
27
+ },
28
+ },
29
+ tools: {
30
+ swc: {
31
+ detectSyntax: 'auto',
32
+ jsc: {
33
+ transform: {
34
+ react: {
35
+ runtime: 'preserve',
36
+ },
37
+ },
38
+ },
39
+ },
40
+ rspack: {
41
+ module: {
42
+ parser: {
43
+ javascript: {
44
+ jsx: true,
45
+ },
46
+ },
47
+ },
48
+ },
49
+ },
50
+ },
51
+ ],
52
+ source: {
53
+ entry: {
54
+ index: ['./src/**'],
55
+ },
56
+ },
57
+ output: {
58
+ target: 'web',
59
+ },
60
+ };
61
+ });
62
+
63
+ define.test(async () => {
64
+ const { pluginBabel } = await import('@rsbuild/plugin-babel');
65
+ const { pluginSolid } = await import('@rsbuild/plugin-solid');
66
+
67
+ return {
68
+ setupFiles: ['./tests/rstest.setup.ts'],
69
+ plugins: [
70
+ pluginBabel({
71
+ include: /\.(?:jsx|tsx)$/,
72
+ }),
73
+ pluginSolid(),
74
+ ],
75
+ };
76
+ });
77
+
78
+ define.lint(async () => {
79
+ const { js, ts } = await import('rstack/lint');
80
+
81
+ return [js.configs.recommended, ts.configs.recommended];
82
+ });
83
+
84
+ define.fmt({
85
+ singleQuote: true,
86
+ });
@@ -0,0 +1,43 @@
1
+ import './button.css';
2
+
3
+ export interface ButtonProps {
4
+ /**
5
+ * Whether the button is primary
6
+ * @default false
7
+ */
8
+ primary?: boolean;
9
+ /**
10
+ * Background color of the button
11
+ */
12
+ backgroundColor?: string;
13
+ /**
14
+ * Size of Button
15
+ * @default 'medium'
16
+ */
17
+ size?: 'small' | 'medium' | 'large';
18
+ /**
19
+ * Label of the button
20
+ */
21
+ label: string;
22
+ /**
23
+ * Optional click handler
24
+ */
25
+ onClick?: () => void;
26
+ }
27
+
28
+ export function Button(props: ButtonProps) {
29
+ const mode = () =>
30
+ props.primary ? 'demo-button--primary' : 'demo-button--secondary';
31
+ const size = () => props.size ?? 'medium';
32
+
33
+ return (
34
+ <button
35
+ type="button"
36
+ class={`demo-button demo-button--${size()} ${mode()}`}
37
+ style={{ 'background-color': props.backgroundColor }}
38
+ onClick={props.onClick}
39
+ >
40
+ {props.label}
41
+ </button>
42
+ );
43
+ }
@@ -0,0 +1,34 @@
1
+ .demo-button {
2
+ font-weight: 700;
3
+ border: 0;
4
+ border-radius: 3em;
5
+ cursor: pointer;
6
+ display: inline-block;
7
+ line-height: 1;
8
+ }
9
+
10
+ .demo-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+
15
+ .demo-button--secondary {
16
+ color: #333;
17
+ background-color: transparent;
18
+ box-shadow: rgba(0, 0, 0, 0.15) 0 0 0 1px inset;
19
+ }
20
+
21
+ .demo-button--small {
22
+ font-size: 12px;
23
+ padding: 10px 16px;
24
+ }
25
+
26
+ .demo-button--medium {
27
+ font-size: 14px;
28
+ padding: 11px 20px;
29
+ }
30
+
31
+ .demo-button--large {
32
+ font-size: 16px;
33
+ padding: 12px 24px;
34
+ }
@@ -0,0 +1,2 @@
1
+ export { Button } from './Button';
2
+ export type { ButtonProps } from './Button';
@@ -0,0 +1,11 @@
1
+ import { render, screen } from '@solidjs/testing-library';
2
+ import { expect, test } from 'rstack/test';
3
+ import { Button } from '../src/Button';
4
+
5
+ test('The button should have correct background color', async () => {
6
+ render(() => <Button backgroundColor="#ccc" label="Demo Button" />);
7
+ const button = screen.getByText('Demo Button');
8
+ expect(button).toHaveStyle({
9
+ 'background-color': '#ccc',
10
+ });
11
+ });
@@ -0,0 +1,4 @@
1
+ import { expect } from 'rstack/test';
2
+ import * as jestDomMatchers from '@testing-library/jest-dom/matchers';
3
+
4
+ expect.extend(jestDomMatchers);