create-rspeedy 0.9.2 → 0.9.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # create-rspeedy
2
2
 
3
+ ## 0.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Add testing library for ReactLynx ([#74](https://github.com/lynx-family/lynx-stack/pull/74))
8
+
9
+ - Use `"jsx": "react-jsx"` with `"jsxImportSource": "@lynx-js/react"`. ([#545](https://github.com/lynx-family/lynx-stack/pull/545))
10
+
3
11
  ## 0.9.2
4
12
 
5
13
  ## 0.9.1
package/dist/index.js CHANGED
@@ -6,7 +6,11 @@ import * as __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__ from "create-rsta
6
6
  const src_dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url));
7
7
  const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
8
8
  const { devDependencies } = src_require('../package.json');
9
- const composeTemplateName = ({ template, lang })=>`${template}-${lang}`;
9
+ const composeTemplateName = ({ template, tools, lang })=>{
10
+ const toolsKeys = (tools ? Object.keys(tools) : []).sort();
11
+ const toolsStr = toolsKeys.length > 0 ? `-${toolsKeys.join('-')}` : '';
12
+ return `${template}${toolsStr}-${lang}`;
13
+ };
10
14
  const TEMPLATES = [
11
15
  {
12
16
  template: 'react',
@@ -43,9 +47,26 @@ async function getTemplateName({ template }) {
43
47
  }
44
48
  ]
45
49
  }));
50
+ const tools = (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.checkCancel)(await (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.multiselect)({
51
+ message: 'Select development tools (Use <space> to select, <enter> to continue)',
52
+ required: false,
53
+ options: [
54
+ {
55
+ value: 'vitest-rltl',
56
+ label: 'Add ReactLynx Testing Library for unit testing'
57
+ }
58
+ ],
59
+ initialValues: [
60
+ 'vitest-rltl'
61
+ ]
62
+ }));
46
63
  return composeTemplateName({
47
64
  template: 'react',
48
- lang: language
65
+ lang: language,
66
+ tools: Object.fromEntries(tools.map((tool)=>[
67
+ tool,
68
+ tool
69
+ ]))
49
70
  });
50
71
  }
51
72
  (0, __WEBPACK_EXTERNAL_MODULE_create_rstack_aeeb76b8__.create)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-rspeedy",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Create Rspeedy-powered ReactLynx apps with one command",
5
5
  "keywords": [
6
6
  "webpack",
@@ -34,10 +34,10 @@
34
34
  "create-rstack": "1.4.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@lynx-js/qrcode-rsbuild-plugin": "^0.3.5",
38
- "@lynx-js/react": "^0.106.5",
39
- "@lynx-js/react-rsbuild-plugin": "^0.9.7",
40
- "@lynx-js/rspeedy": "^0.9.2"
37
+ "@lynx-js/qrcode-rsbuild-plugin": "^0.3.6",
38
+ "@lynx-js/react": "^0.107.0",
39
+ "@lynx-js/react-rsbuild-plugin": "^0.9.8",
40
+ "@lynx-js/rspeedy": "^0.9.3"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=18"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "jsx": "preserve",
4
-
3
+ "jsx": "react-jsx",
4
+ "jsxImportSource": "@lynx-js/react",
5
5
  "module": "node16",
6
6
  "moduleResolution": "node16",
7
7
 
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from '@lynx-js/rspeedy'
2
+
3
+ import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin'
4
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
5
+
6
+ export default defineConfig({
7
+ plugins: [
8
+ pluginQRCode({
9
+ schema(url) {
10
+ // We use `?fullscreen=true` to open the page in LynxExplorer in full screen mode
11
+ return `${url}?fullscreen=true`
12
+ },
13
+ }),
14
+ pluginReactLynx(),
15
+ ],
16
+ })
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "rspeedy-react-js",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "rspeedy build",
7
+ "dev": "rspeedy dev",
8
+ "preview": "rspeedy preview",
9
+ "test": "vitest run"
10
+ },
11
+ "dependencies": {
12
+ "@lynx-js/react": "workspace:*"
13
+ },
14
+ "devDependencies": {
15
+ "@lynx-js/qrcode-rsbuild-plugin": "workspace:*",
16
+ "@lynx-js/react-rsbuild-plugin": "workspace:*",
17
+ "@lynx-js/rspeedy": "workspace:*",
18
+ "@testing-library/jest-dom": "^6.6.3",
19
+ "jsdom": "^26.1.0",
20
+ "vitest": "^3.1.2"
21
+ },
22
+ "engines": {
23
+ "node": ">=18"
24
+ }
25
+ }
@@ -0,0 +1,46 @@
1
+ import { useCallback, useEffect, useState } from '@lynx-js/react'
2
+
3
+ import './App.css'
4
+ import arrow from './assets/arrow.png'
5
+ import lynxLogo from './assets/lynx-logo.png'
6
+ import reactLynxLogo from './assets/react-logo.png'
7
+
8
+ export function App(props) {
9
+ const [alterLogo, setAlterLogo] = useState(false)
10
+
11
+ useEffect(() => {
12
+ console.info('Hello, ReactLynx')
13
+ props.onMounted?.()
14
+ }, [])
15
+
16
+ const onTap = useCallback(() => {
17
+ 'background only'
18
+ setAlterLogo(!alterLogo)
19
+ }, [alterLogo])
20
+
21
+ return (
22
+ <view>
23
+ <view className='Background' />
24
+ <view className='App'>
25
+ <view className='Banner'>
26
+ <view className='Logo' bindtap={onTap}>
27
+ {alterLogo
28
+ ? <image src={reactLynxLogo} className='Logo--react' />
29
+ : <image src={lynxLogo} className='Logo--lynx' />}
30
+ </view>
31
+ <text className='Title'>React</text>
32
+ <text className='Subtitle'>on Lynx</text>
33
+ </view>
34
+ <view className='Content'>
35
+ <image src={arrow} className='Arrow' />
36
+ <text className='Description'>Tap the logo and have fun!</text>
37
+ <text className='Hint'>
38
+ Edit<text style={{ fontStyle: 'italic' }}>{' src/App.tsx '}</text>
39
+ to see updates!
40
+ </text>
41
+ </view>
42
+ <view style={{ flex: 1 }}></view>
43
+ </view>
44
+ </view>
45
+ )
46
+ }
@@ -0,0 +1,102 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import '@testing-library/jest-dom'
5
+ import { expect, test, vi } from 'vitest'
6
+ import { render, getQueriesForElement } from '@lynx-js/react/testing-library'
7
+
8
+ import { App } from '../App.jsx'
9
+
10
+ test('App', async () => {
11
+ const cb = vi.fn()
12
+
13
+ render(
14
+ <App
15
+ onMounted={() => {
16
+ cb(`__MAIN_THREAD__: ${__MAIN_THREAD__}`)
17
+ }}
18
+ />,
19
+ )
20
+ expect(cb).toBeCalledTimes(1)
21
+ expect(cb.mock.calls).toMatchInlineSnapshot(`
22
+ [
23
+ [
24
+ "__MAIN_THREAD__: false",
25
+ ],
26
+ ]
27
+ `)
28
+ expect(elementTree.root).toMatchInlineSnapshot(`
29
+ <page>
30
+ <view>
31
+ <view
32
+ class="Background"
33
+ />
34
+ <view
35
+ class="App"
36
+ >
37
+ <view
38
+ class="Banner"
39
+ >
40
+ <view
41
+ class="Logo"
42
+ >
43
+ <image
44
+ class="Logo--lynx"
45
+ src="/src/assets/lynx-logo.png"
46
+ />
47
+ </view>
48
+ <text
49
+ class="Title"
50
+ >
51
+ React
52
+ </text>
53
+ <text
54
+ class="Subtitle"
55
+ >
56
+ on Lynx
57
+ </text>
58
+ </view>
59
+ <view
60
+ class="Content"
61
+ >
62
+ <image
63
+ class="Arrow"
64
+ src="/src/assets/arrow.png"
65
+ />
66
+ <text
67
+ class="Description"
68
+ >
69
+ Tap the logo and have fun!
70
+ </text>
71
+ <text
72
+ class="Hint"
73
+ >
74
+ Edit
75
+ <text
76
+ style="font-style: italic;"
77
+ >
78
+ src/App.tsx
79
+ </text>
80
+ to see updates!
81
+ </text>
82
+ </view>
83
+ <view
84
+ style="flex: 1;"
85
+ />
86
+ </view>
87
+ </view>
88
+ </page>
89
+ `)
90
+ const {
91
+ findByText,
92
+ } = getQueriesForElement(elementTree.root)
93
+ const element = await findByText('Tap the logo and have fun!')
94
+ expect(element).toBeInTheDocument()
95
+ expect(element).toMatchInlineSnapshot(`
96
+ <text
97
+ class="Description"
98
+ >
99
+ Tap the logo and have fun!
100
+ </text>
101
+ `)
102
+ })
@@ -0,0 +1,9 @@
1
+ import { root } from '@lynx-js/react'
2
+
3
+ import { App } from './App.jsx'
4
+
5
+ root.render(<App />)
6
+
7
+ if (import.meta.webpackHot) {
8
+ import.meta.webpackHot.accept()
9
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig, mergeConfig } from 'vitest/config'
2
+ import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config'
3
+
4
+ const defaultConfig = await createVitestConfig()
5
+ const config = defineConfig({
6
+ test: {},
7
+ })
8
+
9
+ export default mergeConfig(defaultConfig, config)
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from '@lynx-js/rspeedy'
2
+
3
+ import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin'
4
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
5
+
6
+ export default defineConfig({
7
+ plugins: [
8
+ pluginQRCode({
9
+ schema(url) {
10
+ // We use `?fullscreen=true` to open the page in LynxExplorer in full screen mode
11
+ return `${url}?fullscreen=true`
12
+ },
13
+ }),
14
+ pluginReactLynx(),
15
+ ],
16
+ })
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "rspeedy-react-ts",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "rspeedy build",
7
+ "dev": "rspeedy dev",
8
+ "preview": "rspeedy preview",
9
+ "test": "vitest run"
10
+ },
11
+ "dependencies": {
12
+ "@lynx-js/react": "workspace:*"
13
+ },
14
+ "devDependencies": {
15
+ "@lynx-js/qrcode-rsbuild-plugin": "workspace:*",
16
+ "@lynx-js/react-rsbuild-plugin": "workspace:*",
17
+ "@lynx-js/rspeedy": "workspace:*",
18
+ "@lynx-js/types": "^3.2.1",
19
+ "@testing-library/jest-dom": "^6.6.3",
20
+ "@types/react": "^18.3.20",
21
+ "jsdom": "^26.1.0",
22
+ "typescript": "~5.8.3",
23
+ "vitest": "^3.1.2"
24
+ },
25
+ "engines": {
26
+ "node": ">=18"
27
+ }
28
+ }
@@ -0,0 +1,48 @@
1
+ import { useCallback, useEffect, useState } from '@lynx-js/react'
2
+
3
+ import './App.css'
4
+ import arrow from './assets/arrow.png'
5
+ import lynxLogo from './assets/lynx-logo.png'
6
+ import reactLynxLogo from './assets/react-logo.png'
7
+
8
+ export function App(props: {
9
+ onMounted?: () => void
10
+ }) {
11
+ const [alterLogo, setAlterLogo] = useState(false)
12
+
13
+ useEffect(() => {
14
+ console.info('Hello, ReactLynx')
15
+ props.onMounted?.()
16
+ }, [])
17
+
18
+ const onTap = useCallback(() => {
19
+ 'background only'
20
+ setAlterLogo(!alterLogo)
21
+ }, [alterLogo])
22
+
23
+ return (
24
+ <view>
25
+ <view className='Background' />
26
+ <view className='App'>
27
+ <view className='Banner'>
28
+ <view className='Logo' bindtap={onTap}>
29
+ {alterLogo
30
+ ? <image src={reactLynxLogo} className='Logo--react' />
31
+ : <image src={lynxLogo} className='Logo--lynx' />}
32
+ </view>
33
+ <text className='Title'>React</text>
34
+ <text className='Subtitle'>on Lynx</text>
35
+ </view>
36
+ <view className='Content'>
37
+ <image src={arrow} className='Arrow' />
38
+ <text className='Description'>Tap the logo and have fun!</text>
39
+ <text className='Hint'>
40
+ Edit<text style={{ fontStyle: 'italic' }}>{' src/App.tsx '}</text>
41
+ to see updates!
42
+ </text>
43
+ </view>
44
+ <view style={{ flex: 1 }}></view>
45
+ </view>
46
+ </view>
47
+ )
48
+ }
@@ -0,0 +1,102 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import '@testing-library/jest-dom'
5
+ import { expect, test, vi } from 'vitest'
6
+ import { render, getQueriesForElement } from '@lynx-js/react/testing-library'
7
+
8
+ import { App } from '../App.jsx'
9
+
10
+ test('App', async () => {
11
+ const cb = vi.fn()
12
+
13
+ render(
14
+ <App
15
+ onMounted={() => {
16
+ cb(`__MAIN_THREAD__: ${__MAIN_THREAD__}`)
17
+ }}
18
+ />,
19
+ )
20
+ expect(cb).toBeCalledTimes(1)
21
+ expect(cb.mock.calls).toMatchInlineSnapshot(`
22
+ [
23
+ [
24
+ "__MAIN_THREAD__: false",
25
+ ],
26
+ ]
27
+ `)
28
+ expect(elementTree.root).toMatchInlineSnapshot(`
29
+ <page>
30
+ <view>
31
+ <view
32
+ class="Background"
33
+ />
34
+ <view
35
+ class="App"
36
+ >
37
+ <view
38
+ class="Banner"
39
+ >
40
+ <view
41
+ class="Logo"
42
+ >
43
+ <image
44
+ class="Logo--lynx"
45
+ src="/src/assets/lynx-logo.png"
46
+ />
47
+ </view>
48
+ <text
49
+ class="Title"
50
+ >
51
+ React
52
+ </text>
53
+ <text
54
+ class="Subtitle"
55
+ >
56
+ on Lynx
57
+ </text>
58
+ </view>
59
+ <view
60
+ class="Content"
61
+ >
62
+ <image
63
+ class="Arrow"
64
+ src="/src/assets/arrow.png"
65
+ />
66
+ <text
67
+ class="Description"
68
+ >
69
+ Tap the logo and have fun!
70
+ </text>
71
+ <text
72
+ class="Hint"
73
+ >
74
+ Edit
75
+ <text
76
+ style="font-style: italic;"
77
+ >
78
+ src/App.tsx
79
+ </text>
80
+ to see updates!
81
+ </text>
82
+ </view>
83
+ <view
84
+ style="flex: 1;"
85
+ />
86
+ </view>
87
+ </view>
88
+ </page>
89
+ `)
90
+ const {
91
+ findByText,
92
+ } = getQueriesForElement(elementTree.root!)
93
+ const element = await findByText('Tap the logo and have fun!')
94
+ expect(element).toBeInTheDocument()
95
+ expect(element).toMatchInlineSnapshot(`
96
+ <text
97
+ class="Description"
98
+ >
99
+ Tap the logo and have fun!
100
+ </text>
101
+ `)
102
+ })
@@ -0,0 +1,9 @@
1
+ import { root } from '@lynx-js/react'
2
+
3
+ import { App } from './App.jsx'
4
+
5
+ root.render(<App />)
6
+
7
+ if (import.meta.webpackHot) {
8
+ import.meta.webpackHot.accept()
9
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="@lynx-js/rspeedy/client" />
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ "jsxImportSource": "@lynx-js/react",
5
+
6
+ "module": "node18",
7
+ "moduleResolution": "node16",
8
+
9
+ "strict": true,
10
+ "isolatedModules": true,
11
+ "verbatimModuleSyntax": true,
12
+
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": true,
15
+ },
16
+ "exclude": ["dist/"],
17
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig, mergeConfig } from 'vitest/config'
2
+ import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config'
3
+
4
+ const defaultConfig = await createVitestConfig()
5
+ const config = defineConfig({
6
+ test: {},
7
+ })
8
+
9
+ export default mergeConfig(defaultConfig, config)