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.
- package/LICENSE +1 -1
- package/README.md +43 -73
- package/bin.js +2 -0
- package/dist/index.js +202 -3588
- package/package.json +26 -46
- package/template-app-lit-js/package.json +23 -0
- package/template-app-lit-js/rstack.config.js +28 -0
- package/template-app-lit-js/src/index.css +6 -0
- package/template-app-lit-js/src/index.html +7 -0
- package/template-app-lit-js/src/index.js +4 -0
- package/template-app-lit-js/src/my-element.js +34 -0
- package/template-app-lit-js/tests/index.test.js +12 -0
- package/template-app-lit-ts/package.json +25 -0
- package/template-app-lit-ts/rstack.config.ts +27 -0
- package/template-app-lit-ts/src/index.css +6 -0
- package/template-app-lit-ts/src/index.html +7 -0
- package/template-app-lit-ts/src/index.ts +4 -0
- package/template-app-lit-ts/src/my-element.ts +34 -0
- package/template-app-lit-ts/tests/index.test.ts +12 -0
- package/template-app-lit-ts/tsconfig.json +23 -0
- package/template-app-preact-js/package.json +26 -0
- package/template-app-preact-js/rstack.config.js +29 -0
- package/template-app-preact-js/src/App.css +26 -0
- package/template-app-preact-js/src/App.jsx +12 -0
- package/template-app-preact-js/src/index.jsx +4 -0
- package/template-app-preact-js/tests/index.test.jsx +8 -0
- package/template-app-preact-js/tests/rstest.setup.js +4 -0
- package/template-app-preact-ts/package.json +28 -0
- package/template-app-preact-ts/rstack.config.ts +29 -0
- package/template-app-preact-ts/src/App.css +26 -0
- package/template-app-preact-ts/src/App.tsx +12 -0
- package/template-app-preact-ts/src/index.tsx +7 -0
- package/template-app-preact-ts/tests/index.test.tsx +8 -0
- package/template-app-preact-ts/tests/rstest.setup.ts +4 -0
- package/template-app-preact-ts/tests/tsconfig.json +7 -0
- package/template-app-preact-ts/tsconfig.json +28 -0
- package/template-app-react-js/package.json +28 -0
- package/template-app-react-js/rstack.config.js +29 -0
- package/template-app-react-js/src/App.css +26 -0
- package/template-app-react-js/src/App.jsx +12 -0
- package/template-app-react-js/src/index.jsx +10 -0
- package/template-app-react-js/tests/index.test.jsx +8 -0
- package/template-app-react-js/tests/rstest.setup.js +4 -0
- package/template-app-react-ts/package.json +32 -0
- package/template-app-react-ts/rstack.config.ts +29 -0
- package/template-app-react-ts/src/App.css +26 -0
- package/template-app-react-ts/src/App.tsx +12 -0
- package/template-app-react-ts/src/env.d.ts +9 -0
- package/template-app-react-ts/src/index.tsx +13 -0
- package/template-app-react-ts/tests/index.test.tsx +8 -0
- package/template-app-react-ts/tests/rstest.setup.ts +4 -0
- package/template-app-react-ts/tests/tsconfig.json +7 -0
- package/template-app-react-ts/tsconfig.json +23 -0
- package/template-app-solid-js/package.json +27 -0
- package/template-app-solid-js/rstack.config.js +31 -0
- package/template-app-solid-js/src/App.css +26 -0
- package/template-app-solid-js/src/App.jsx +12 -0
- package/template-app-solid-js/src/index.jsx +4 -0
- package/template-app-solid-js/tests/index.test.jsx +8 -0
- package/template-app-solid-js/tests/rstest.setup.js +4 -0
- package/template-app-solid-ts/package.json +29 -0
- package/template-app-solid-ts/rstack.config.ts +30 -0
- package/template-app-solid-ts/src/App.css +26 -0
- package/template-app-solid-ts/src/App.tsx +12 -0
- package/template-app-solid-ts/src/index.tsx +7 -0
- package/template-app-solid-ts/tests/index.test.tsx +8 -0
- package/template-app-solid-ts/tests/rstest.setup.ts +4 -0
- package/template-app-solid-ts/tests/tsconfig.json +7 -0
- package/template-app-solid-ts/tsconfig.json +24 -0
- package/template-app-svelte-js/package.json +27 -0
- package/template-app-svelte-js/pnpm-workspace.yaml +2 -0
- package/template-app-svelte-js/rstack.config.js +26 -0
- package/template-app-svelte-js/src/App.svelte +28 -0
- package/template-app-svelte-js/src/index.css +6 -0
- package/template-app-svelte-js/src/index.js +8 -0
- package/template-app-svelte-js/tests/index.test.js +8 -0
- package/template-app-svelte-js/tests/rstest.setup.js +4 -0
- package/template-app-svelte-ts/package.json +30 -0
- package/template-app-svelte-ts/pnpm-workspace.yaml +2 -0
- package/template-app-svelte-ts/rstack.config.ts +25 -0
- package/template-app-svelte-ts/src/App.svelte +37 -0
- package/template-app-svelte-ts/src/index.css +6 -0
- package/template-app-svelte-ts/src/index.ts +14 -0
- package/template-app-svelte-ts/tests/index.test.ts +11 -0
- package/template-app-svelte-ts/tests/rstest.setup.ts +4 -0
- package/template-app-svelte-ts/tests/tsconfig.json +7 -0
- package/template-app-svelte-ts/tsconfig.json +22 -0
- package/template-app-vanilla-js/package.json +22 -0
- package/template-app-vanilla-js/rstack.config.js +21 -0
- package/template-app-vanilla-js/src/index.css +26 -0
- package/template-app-vanilla-js/src/index.js +12 -0
- package/template-app-vanilla-js/tests/dom.test.js +12 -0
- package/template-app-vanilla-js/tests/rstest.setup.js +4 -0
- package/template-app-vanilla-ts/package.json +24 -0
- package/template-app-vanilla-ts/rstack.config.ts +20 -0
- package/template-app-vanilla-ts/src/index.css +26 -0
- package/template-app-vanilla-ts/src/index.ts +12 -0
- package/template-app-vanilla-ts/tests/dom.test.ts +12 -0
- package/template-app-vanilla-ts/tests/rstest.setup.ts +4 -0
- package/template-app-vanilla-ts/tests/tsconfig.json +7 -0
- package/template-app-vanilla-ts/tsconfig.json +22 -0
- package/template-app-vue-js/package.json +26 -0
- package/template-app-vue-js/rstack.config.js +25 -0
- package/template-app-vue-js/src/App.vue +28 -0
- package/template-app-vue-js/src/index.css +6 -0
- package/template-app-vue-js/src/index.js +5 -0
- package/template-app-vue-js/tests/index.test.js +8 -0
- package/template-app-vue-js/tests/rstest.setup.js +6 -0
- package/template-app-vue-ts/package.json +29 -0
- package/template-app-vue-ts/rstack.config.ts +24 -0
- package/template-app-vue-ts/src/App.vue +28 -0
- package/template-app-vue-ts/src/index.css +6 -0
- package/template-app-vue-ts/src/index.ts +5 -0
- package/template-app-vue-ts/tests/index.test.ts +8 -0
- package/template-app-vue-ts/tests/rstest.setup.ts +6 -0
- package/template-app-vue-ts/tests/tsconfig.json +7 -0
- package/template-app-vue-ts/tsconfig.json +24 -0
- package/template-common/AGENTS.md +7 -0
- package/template-common/README.md +34 -0
- package/template-common/gitignore +13 -0
- package/template-doc-basic/README.md +34 -0
- package/template-doc-basic/docs/_nav.json +16 -0
- package/template-doc-basic/docs/api/_meta.json +1 -0
- package/template-doc-basic/docs/api/commands.mdx +25 -0
- package/template-doc-basic/docs/api/index.mdx +6 -0
- package/template-doc-basic/docs/guide/_meta.json +7 -0
- package/template-doc-basic/docs/guide/start/_meta.json +1 -0
- package/template-doc-basic/docs/guide/start/introduction.md +5 -0
- package/template-doc-basic/docs/index.md +39 -0
- package/template-doc-basic/gitignore +14 -0
- package/template-doc-basic/package.json +24 -0
- package/template-doc-basic/rstack.config.ts +23 -0
- package/template-doc-basic/tsconfig.json +26 -0
- package/template-doc-i18n/README.md +34 -0
- package/template-doc-i18n/docs/en/_nav.json +16 -0
- package/template-doc-i18n/docs/en/api/_meta.json +1 -0
- package/template-doc-i18n/docs/en/api/commands.mdx +25 -0
- package/template-doc-i18n/docs/en/api/index.mdx +6 -0
- package/template-doc-i18n/docs/en/guide/_meta.json +7 -0
- package/template-doc-i18n/docs/en/guide/start/_meta.json +1 -0
- package/template-doc-i18n/docs/en/guide/start/introduction.md +5 -0
- package/template-doc-i18n/docs/en/index.md +39 -0
- package/template-doc-i18n/docs/zh/_nav.json +16 -0
- package/template-doc-i18n/docs/zh/api/_meta.json +12 -0
- package/template-doc-i18n/docs/zh/api/commands.mdx +25 -0
- package/template-doc-i18n/docs/zh/api/index.mdx +6 -0
- package/template-doc-i18n/docs/zh/guide/_meta.json +7 -0
- package/template-doc-i18n/docs/zh/guide/start/_meta.json +7 -0
- package/template-doc-i18n/docs/zh/guide/start/introduction.md +5 -0
- package/template-doc-i18n/docs/zh/index.md +39 -0
- package/template-doc-i18n/gitignore +14 -0
- package/template-doc-i18n/package.json +24 -0
- package/template-doc-i18n/rstack.config.ts +39 -0
- package/template-doc-i18n/tsconfig.json +26 -0
- package/template-lib-node-js/README.md +40 -0
- package/template-lib-node-js/package.json +33 -0
- package/template-lib-node-js/rstack.config.js +21 -0
- package/template-lib-node-js/src/index.js +1 -0
- package/template-lib-node-js/tests/index.test.js +7 -0
- package/template-lib-node-ts/README.md +40 -0
- package/template-lib-node-ts/package.json +37 -0
- package/template-lib-node-ts/rstack.config.ts +21 -0
- package/template-lib-node-ts/src/index.ts +1 -0
- package/template-lib-node-ts/tests/index.test.ts +7 -0
- package/template-lib-node-ts/tsconfig.json +23 -0
- package/template-lib-react-js/README.md +40 -0
- package/template-lib-react-js/package.json +41 -0
- package/template-lib-react-js/rstack.config.js +38 -0
- package/template-lib-react-js/src/Button.jsx +21 -0
- package/template-lib-react-js/src/button.css +34 -0
- package/template-lib-react-js/src/index.jsx +1 -0
- package/template-lib-react-js/tests/index.test.jsx +11 -0
- package/template-lib-react-js/tests/rstest.setup.js +4 -0
- package/template-lib-react-ts/README.md +40 -0
- package/template-lib-react-ts/package.json +46 -0
- package/template-lib-react-ts/rstack.config.ts +39 -0
- package/template-lib-react-ts/src/Button.tsx +46 -0
- package/template-lib-react-ts/src/button.css +34 -0
- package/template-lib-react-ts/src/index.tsx +1 -0
- package/template-lib-react-ts/tests/index.test.tsx +11 -0
- package/template-lib-react-ts/tests/rstest.setup.ts +4 -0
- package/template-lib-react-ts/tests/tsconfig.json +8 -0
- package/template-lib-react-ts/tsconfig.json +24 -0
- package/template-lib-solid-js/README.md +40 -0
- package/template-lib-solid-js/package.json +39 -0
- package/template-lib-solid-js/rstack.config.js +86 -0
- package/template-lib-solid-js/src/Button.jsx +18 -0
- package/template-lib-solid-js/src/button.css +34 -0
- package/template-lib-solid-js/src/index.jsx +1 -0
- package/template-lib-solid-js/tests/index.test.jsx +11 -0
- package/template-lib-solid-js/tests/rstest.setup.js +4 -0
- package/template-lib-solid-ts/README.md +40 -0
- package/template-lib-solid-ts/package.json +43 -0
- package/template-lib-solid-ts/rstack.config.ts +86 -0
- package/template-lib-solid-ts/src/Button.tsx +43 -0
- package/template-lib-solid-ts/src/button.css +34 -0
- package/template-lib-solid-ts/src/index.tsx +2 -0
- package/template-lib-solid-ts/tests/index.test.tsx +11 -0
- package/template-lib-solid-ts/tests/rstest.setup.ts +4 -0
- package/template-lib-solid-ts/tests/tsconfig.json +8 -0
- package/template-lib-solid-ts/tsconfig.json +25 -0
- package/template-lib-svelte-js/README.md +40 -0
- package/template-lib-svelte-js/package.json +36 -0
- package/template-lib-svelte-js/pnpm-workspace.yaml +2 -0
- package/template-lib-svelte-js/rstack.config.js +35 -0
- package/template-lib-svelte-js/src/Button.svelte +24 -0
- package/template-lib-svelte-js/src/button.css +34 -0
- package/template-lib-svelte-js/src/index.js +1 -0
- package/template-lib-svelte-js/tests/index.test.js +19 -0
- package/template-lib-svelte-ts/README.md +40 -0
- package/template-lib-svelte-ts/package.json +42 -0
- package/template-lib-svelte-ts/pnpm-workspace.yaml +2 -0
- package/template-lib-svelte-ts/rstack.config.ts +35 -0
- package/template-lib-svelte-ts/scripts/rslib-plugin-svelte-dts.ts +59 -0
- package/template-lib-svelte-ts/src/Button.svelte +34 -0
- package/template-lib-svelte-ts/src/button.css +34 -0
- package/template-lib-svelte-ts/src/index.ts +1 -0
- package/template-lib-svelte-ts/tests/index.test.ts +19 -0
- package/template-lib-svelte-ts/tests/tsconfig.json +7 -0
- package/template-lib-svelte-ts/tsconfig.json +25 -0
- package/template-lib-vue-js/README.md +40 -0
- package/template-lib-vue-js/package.json +37 -0
- package/template-lib-vue-js/rstack.config.js +34 -0
- package/template-lib-vue-js/src/Button.vue +43 -0
- package/template-lib-vue-js/src/button.css +34 -0
- package/template-lib-vue-js/src/index.js +1 -0
- package/template-lib-vue-js/tests/index.test.js +17 -0
- package/template-lib-vue-js/tests/rstest.setup.js +6 -0
- package/template-lib-vue-ts/README.md +40 -0
- package/template-lib-vue-ts/package.json +42 -0
- package/template-lib-vue-ts/rstack.config.ts +33 -0
- package/template-lib-vue-ts/src/Button.vue +35 -0
- package/template-lib-vue-ts/src/button.css +34 -0
- package/template-lib-vue-ts/src/index.ts +1 -0
- package/template-lib-vue-ts/tests/index.test.ts +17 -0
- package/template-lib-vue-ts/tests/rstest.setup.ts +6 -0
- package/template-lib-vue-ts/tests/tsconfig.json +8 -0
- package/template-lib-vue-ts/tsconfig.json +27 -0
- package/dist/index.d.ts +0 -316
- package/template-biome/AGENTS.md +0 -6
- package/template-biome/biome.json.template +0 -34
- package/template-biome/package.json +0 -12
- package/template-eslint/AGENTS.md +0 -5
- package/template-eslint/react-js/eslint.config.mjs +0 -23
- package/template-eslint/react-js/package.json +0 -15
- package/template-eslint/react-ts/eslint.config.mjs +0 -22
- package/template-eslint/react-ts/package.json +0 -16
- package/template-eslint/svelte-js/eslint.config.mjs +0 -20
- package/template-eslint/svelte-js/package.json +0 -14
- package/template-eslint/svelte-ts/eslint.config.mjs +0 -28
- package/template-eslint/svelte-ts/package.json +0 -16
- package/template-eslint/vanilla-js/eslint.config.mjs +0 -8
- package/template-eslint/vanilla-js/package.json +0 -13
- package/template-eslint/vanilla-ts/eslint.config.mjs +0 -10
- package/template-eslint/vanilla-ts/package.json +0 -14
- package/template-eslint/vue-js/eslint.config.mjs +0 -15
- package/template-eslint/vue-js/package.json +0 -14
- package/template-eslint/vue-ts/eslint.config.mjs +0 -23
- package/template-eslint/vue-ts/package.json +0 -15
- package/template-prettier/.prettierignore +0 -4
- package/template-prettier/.prettierrc +0 -3
- package/template-prettier/AGENTS.md +0 -5
- package/template-prettier/package.json +0 -11
- package/template-rslint/AGENTS.md +0 -9
- package/template-rslint/react-js/package.json +0 -11
- package/template-rslint/react-js/rslint.config.ts +0 -7
- package/template-rslint/react-ts/package.json +0 -11
- package/template-rslint/react-ts/rslint.config.ts +0 -14
- package/template-rslint/vanilla-js/package.json +0 -11
- package/template-rslint/vanilla-js/rslint.config.ts +0 -3
- package/template-rslint/vanilla-ts/package.json +0 -11
- package/template-rslint/vanilla-ts/rslint.config.ts +0 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["DOM", "ES2022"],
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"jsxImportSource": "solid-js",
|
|
6
|
+
"target": "ES2022",
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"types": ["rstack/types", "node"],
|
|
10
|
+
"useDefineForClassFields": true,
|
|
11
|
+
"rootDir": "src",
|
|
12
|
+
|
|
13
|
+
/* modules */
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
|
|
20
|
+
/* type checking */
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true
|
|
23
|
+
},
|
|
24
|
+
"include": ["src"]
|
|
25
|
+
}
|
|
@@ -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,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rstack-lib-svelte-js",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"default": "./dist/index.js"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rs lib",
|
|
16
|
+
"check": "rs lint && rs fmt --check",
|
|
17
|
+
"dev": "rs lib --watch",
|
|
18
|
+
"format": "rs fmt",
|
|
19
|
+
"lint": "rs lint",
|
|
20
|
+
"test": "rs test",
|
|
21
|
+
"test:watch": "rs test --watch"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rsbuild/plugin-svelte": "^2.0.1",
|
|
25
|
+
"happy-dom": "^20.11.2",
|
|
26
|
+
"prettier-plugin-svelte": "^4.1.1",
|
|
27
|
+
"rstack": "^0.4.0",
|
|
28
|
+
"svelte": "^5.56.8"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"svelte": "^5.0.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Rstack configuration guide: https://rstack.rs/config
|
|
3
|
+
import { define } from 'rstack';
|
|
4
|
+
|
|
5
|
+
define.lib(async () => {
|
|
6
|
+
const { pluginSvelte } = await import('@rsbuild/plugin-svelte');
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
bundle: false,
|
|
10
|
+
source: {
|
|
11
|
+
entry: {
|
|
12
|
+
index: ['./src/**'],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
output: {
|
|
16
|
+
target: 'web',
|
|
17
|
+
},
|
|
18
|
+
plugins: [pluginSvelte()],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
define.test({
|
|
23
|
+
testEnvironment: 'happy-dom',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
define.lint(async () => {
|
|
27
|
+
const { js } = await import('rstack/lint');
|
|
28
|
+
|
|
29
|
+
return [js.configs.recommended];
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
define.fmt({
|
|
33
|
+
plugins: ['prettier-plugin-svelte'],
|
|
34
|
+
singleQuote: true,
|
|
35
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import './button.css';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
primary = false,
|
|
6
|
+
backgroundColor,
|
|
7
|
+
size = 'medium',
|
|
8
|
+
label = 'Demo Button',
|
|
9
|
+
onClick,
|
|
10
|
+
} = $props();
|
|
11
|
+
|
|
12
|
+
const mode = $derived(
|
|
13
|
+
primary ? 'demo-button--primary' : 'demo-button--secondary',
|
|
14
|
+
);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<button
|
|
18
|
+
type="button"
|
|
19
|
+
class={['demo-button', `demo-button--${size}`, mode].join(' ')}
|
|
20
|
+
style:background-color={backgroundColor}
|
|
21
|
+
onclick={onClick}
|
|
22
|
+
>
|
|
23
|
+
{label}
|
|
24
|
+
</button>
|
|
@@ -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 { default as Button } from './Button.svelte';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expect, test } from 'rstack/test';
|
|
2
|
+
import { mount, unmount } from 'svelte';
|
|
3
|
+
import Button from '../src/Button.svelte';
|
|
4
|
+
|
|
5
|
+
test('The button should render the default label', () => {
|
|
6
|
+
const target = document.createElement('div');
|
|
7
|
+
document.body.append(target);
|
|
8
|
+
const component = mount(Button, { target });
|
|
9
|
+
const button = target.querySelector('button');
|
|
10
|
+
|
|
11
|
+
if (!button) {
|
|
12
|
+
throw new Error('Expected button to be rendered');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
expect(button.textContent).toBe('Demo Button');
|
|
16
|
+
|
|
17
|
+
unmount(component);
|
|
18
|
+
target.remove();
|
|
19
|
+
});
|
|
@@ -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,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rstack-lib-svelte-ts",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"default": "./dist/index.js"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "svelte-check && rs lib",
|
|
18
|
+
"check": "rs lint && rs fmt --check",
|
|
19
|
+
"dev": "rs lib --watch",
|
|
20
|
+
"format": "rs fmt",
|
|
21
|
+
"lint": "rs lint",
|
|
22
|
+
"test": "rs test",
|
|
23
|
+
"test:watch": "rs test --watch"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@rsbuild/plugin-svelte": "^2.0.1",
|
|
27
|
+
"@types/node": "^24.13.3",
|
|
28
|
+
"happy-dom": "^20.11.2",
|
|
29
|
+
"prettier-plugin-svelte": "^4.1.1",
|
|
30
|
+
"rstack": "^0.4.0",
|
|
31
|
+
"svelte": "^5.56.8",
|
|
32
|
+
"svelte-check": "^4.7.5",
|
|
33
|
+
"svelte2tsx": "^0.7.59",
|
|
34
|
+
"typescript": "^6.0.3"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"svelte": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Rstack configuration guide: https://rstack.rs/config
|
|
2
|
+
import { define } from 'rstack';
|
|
3
|
+
import { svelteDtsPlugin } from './scripts/rslib-plugin-svelte-dts.ts';
|
|
4
|
+
|
|
5
|
+
define.lib(async () => {
|
|
6
|
+
const { pluginSvelte } = await import('@rsbuild/plugin-svelte');
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
bundle: false,
|
|
10
|
+
source: {
|
|
11
|
+
entry: {
|
|
12
|
+
index: ['./src/**'],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
output: {
|
|
16
|
+
target: 'web',
|
|
17
|
+
},
|
|
18
|
+
plugins: [pluginSvelte(), svelteDtsPlugin()],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
define.test({
|
|
23
|
+
testEnvironment: 'happy-dom',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
define.lint(async () => {
|
|
27
|
+
const { js, ts } = await import('rstack/lint');
|
|
28
|
+
|
|
29
|
+
return [js.configs.recommended, ts.configs.recommended];
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
define.fmt({
|
|
33
|
+
plugins: ['prettier-plugin-svelte'],
|
|
34
|
+
singleQuote: true,
|
|
35
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RsbuildPlugin } from 'rstack/lib';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { emitDts, type EmitDtsConfig } from 'svelte2tsx';
|
|
5
|
+
|
|
6
|
+
type SvelteDtsPluginOptions = Partial<EmitDtsConfig>;
|
|
7
|
+
|
|
8
|
+
const resolveProjectPath = (rootPath: string, path: string): string =>
|
|
9
|
+
resolve(rootPath, path);
|
|
10
|
+
|
|
11
|
+
export function svelteDtsPlugin(
|
|
12
|
+
options: SvelteDtsPluginOptions = {},
|
|
13
|
+
): RsbuildPlugin {
|
|
14
|
+
return {
|
|
15
|
+
name: 'rslib-plugin-svelte-dts',
|
|
16
|
+
setup(api) {
|
|
17
|
+
api.onAfterBuild(async ({ isWatch }) => {
|
|
18
|
+
if (!isWatch) {
|
|
19
|
+
api.logger.start('generating declaration files...');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
declarationDir = './dist',
|
|
24
|
+
libRoot = './src',
|
|
25
|
+
tsconfig,
|
|
26
|
+
} = options;
|
|
27
|
+
const rootPath = api.context.rootPath;
|
|
28
|
+
const tsconfigPath = resolveProjectPath(
|
|
29
|
+
rootPath,
|
|
30
|
+
tsconfig ??
|
|
31
|
+
api.getNormalizedConfig().source.tsconfigPath ??
|
|
32
|
+
'./tsconfig.json',
|
|
33
|
+
);
|
|
34
|
+
const svelteShimsPath = options.svelteShimsPath
|
|
35
|
+
? resolveProjectPath(rootPath, options.svelteShimsPath)
|
|
36
|
+
: fileURLToPath(
|
|
37
|
+
import.meta.resolve('svelte2tsx/svelte-shims-v4.d.ts'),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
await emitDts({
|
|
42
|
+
declarationDir: resolveProjectPath(rootPath, declarationDir),
|
|
43
|
+
svelteShimsPath,
|
|
44
|
+
libRoot: resolveProjectPath(rootPath, libRoot),
|
|
45
|
+
tsconfig: tsconfigPath,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
api.logger.ready('declaration files generated with svelte2tsx.');
|
|
49
|
+
} catch (error) {
|
|
50
|
+
api.logger.error(
|
|
51
|
+
'Failed to generate declaration files with svelte2tsx.',
|
|
52
|
+
);
|
|
53
|
+
api.logger.error(error);
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import './button.css';
|
|
3
|
+
|
|
4
|
+
type Size = 'small' | 'medium' | 'large';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
primary?: boolean;
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
size?: Size;
|
|
10
|
+
label?: string;
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
primary = false,
|
|
16
|
+
backgroundColor,
|
|
17
|
+
size = 'medium',
|
|
18
|
+
label = 'Demo Button',
|
|
19
|
+
onClick,
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
|
|
22
|
+
const mode = $derived(
|
|
23
|
+
primary ? 'demo-button--primary' : 'demo-button--secondary',
|
|
24
|
+
);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
class={['demo-button', `demo-button--${size}`, mode].join(' ')}
|
|
30
|
+
style:background-color={backgroundColor}
|
|
31
|
+
onclick={onClick}
|
|
32
|
+
>
|
|
33
|
+
{label}
|
|
34
|
+
</button>
|
|
@@ -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 { default as Button } from './Button.svelte';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expect, test } from 'rstack/test';
|
|
2
|
+
import { mount, unmount } from 'svelte';
|
|
3
|
+
import Button from '../src/Button.svelte';
|
|
4
|
+
|
|
5
|
+
test('The button should render the default label', () => {
|
|
6
|
+
const target = document.createElement('div');
|
|
7
|
+
document.body.append(target);
|
|
8
|
+
const component = mount(Button, { target });
|
|
9
|
+
const button = target.querySelector('button');
|
|
10
|
+
|
|
11
|
+
if (!button) {
|
|
12
|
+
throw new Error('Expected button to be rendered');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
expect(button.textContent).toBe('Demo Button');
|
|
16
|
+
|
|
17
|
+
unmount(component);
|
|
18
|
+
target.remove();
|
|
19
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["DOM", "ES2022"],
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"emitDeclarationOnly": true,
|
|
7
|
+
"isolatedModules": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"types": ["rstack/types", "node", "svelte"],
|
|
10
|
+
"useDefineForClassFields": true,
|
|
11
|
+
|
|
12
|
+
/* modules */
|
|
13
|
+
"module": "preserve",
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
|
|
20
|
+
/* type checking */
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true
|
|
23
|
+
},
|
|
24
|
+
"include": ["src", "scripts", "*.config.ts"]
|
|
25
|
+
}
|
|
@@ -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,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rstack-lib-vue-js",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"default": "./dist/index.js"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rs lib",
|
|
16
|
+
"check": "rs lint && rs fmt --check",
|
|
17
|
+
"dev": "rs lib --watch",
|
|
18
|
+
"format": "rs fmt",
|
|
19
|
+
"lint": "rs lint",
|
|
20
|
+
"test": "rs test",
|
|
21
|
+
"test:watch": "rs test --watch"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rsbuild/plugin-vue": "^2.0.1",
|
|
25
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
26
|
+
"@vue/test-utils": "^2.4.11",
|
|
27
|
+
"happy-dom": "^20.11.2",
|
|
28
|
+
"rstack": "^0.4.0",
|
|
29
|
+
"vue": "^3.5.41"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": ">=3.2.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Rstack configuration guide: https://rstack.rs/config
|
|
3
|
+
import { define } from 'rstack';
|
|
4
|
+
|
|
5
|
+
define.lib(async () => {
|
|
6
|
+
const { pluginVue } = await import('@rsbuild/plugin-vue');
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
bundle: false,
|
|
10
|
+
source: {
|
|
11
|
+
entry: {
|
|
12
|
+
index: ['./src/**'],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
output: {
|
|
16
|
+
target: 'web',
|
|
17
|
+
},
|
|
18
|
+
plugins: [pluginVue()],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
define.test({
|
|
23
|
+
setupFiles: ['./tests/rstest.setup.js'],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
define.lint(async () => {
|
|
27
|
+
const { js } = await import('rstack/lint');
|
|
28
|
+
|
|
29
|
+
return [js.configs.recommended];
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
define.fmt({
|
|
33
|
+
singleQuote: true,
|
|
34
|
+
});
|