@reactful/create 0.0.51
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -0
- package/bun.lockb +0 -0
- package/common/package.json +22 -0
- package/common/tsconfig.json +24 -0
- package/index.js +77 -0
- package/package.json +16 -0
- package/templates/empty/index.html +12 -0
- package/templates/empty/index.ts +5 -0
- package/templates/minimal/index.html +12 -0
- package/templates/minimal/index.ts +5 -0
- package/templates/sampling/apis/auth/db.ts +15 -0
- package/templates/sampling/apis/auth/index.ts +28 -0
- package/templates/sampling/apis/hello.ts +3 -0
- package/templates/sampling/apis/quotes.ts +16 -0
- package/templates/sampling/apis/sub/index.ts +3 -0
- package/templates/sampling/apis/sub/sub.ts +3 -0
- package/templates/sampling/assets/SLIDEME.png +0 -0
- package/templates/sampling/assets/default.css +91 -0
- package/templates/sampling/assets/favicon.ico +0 -0
- package/templates/sampling/assets/icon.png +0 -0
- package/templates/sampling/assets/icon.svg +6 -0
- package/templates/sampling/assets/logo-144.png +0 -0
- package/templates/sampling/assets/logo-168.png +0 -0
- package/templates/sampling/assets/logo-192.png +0 -0
- package/templates/sampling/assets/logo-48.png +0 -0
- package/templates/sampling/assets/logo-512.png +0 -0
- package/templates/sampling/assets/logo-72.png +0 -0
- package/templates/sampling/assets/logo-96.png +0 -0
- package/templates/sampling/assets/manifest.json +57 -0
- package/templates/sampling/assets/markdown.css +274 -0
- package/templates/sampling/assets/robots.txt +1 -0
- package/templates/sampling/assets/system.css +7 -0
- package/templates/sampling/builds/about.html +27 -0
- package/templates/sampling/builds/bundle.js +13116 -0
- package/templates/sampling/builds/bundle.ts +25 -0
- package/templates/sampling/builds/client.ts +1 -0
- package/templates/sampling/builds/clock.html +30 -0
- package/templates/sampling/builds/counter.html +30 -0
- package/templates/sampling/builds/forms/form.html +48 -0
- package/templates/sampling/builds/forms/index.html +48 -0
- package/templates/sampling/builds/hello.html +60 -0
- package/templates/sampling/builds/htmlx.html +24 -0
- package/templates/sampling/builds/htmlx.tsx +13 -0
- package/templates/sampling/builds/index.html +98 -0
- package/templates/sampling/builds/login.html +45 -0
- package/templates/sampling/builds/profile/index.html +54 -0
- package/templates/sampling/builds/quotes.html +26 -0
- package/templates/sampling/builds/shared.js +76 -0
- package/templates/sampling/builds/system.html +27 -0
- package/templates/sampling/components/header.tsx +7 -0
- package/templates/sampling/directives/index.ts +1 -0
- package/templates/sampling/directives/shown.ts +6 -0
- package/templates/sampling/index.html +20 -0
- package/templates/sampling/index.ts +19 -0
- package/templates/sampling/routes/about.html +13 -0
- package/templates/sampling/routes/clock.tsx +35 -0
- package/templates/sampling/routes/counter.tsx +21 -0
- package/templates/sampling/routes/forms/form.css +19 -0
- package/templates/sampling/routes/forms/form.tsx +51 -0
- package/templates/sampling/routes/forms/index.tsx +3 -0
- package/templates/sampling/routes/hello.tsx +62 -0
- package/templates/sampling/routes/htmlx.html +15 -0
- package/templates/sampling/routes/index.md +15 -0
- package/templates/sampling/routes/login.tsx +36 -0
- package/templates/sampling/routes/profile/detail.css +13 -0
- package/templates/sampling/routes/profile/detail.tsx +48 -0
- package/templates/sampling/routes/profile/index.tsx +14 -0
- package/templates/sampling/routes/profile/profile.css +8 -0
- package/templates/sampling/routes/profile/tester.tsx +11 -0
- package/templates/sampling/routes/quotes.tsx +25 -0
- package/templates/sampling/routes/system.tsx +23 -0
- package/templates/sampling/tests/access.spec.ts +29 -0
- package/templates/sampling/tests/counter.spec.ts +19 -0
- package/templates/sampling/tests/form.spec.ts +51 -0
- package/templates/sampling/tests/hello.spec.ts +25 -0
- package/templates/sampling/tests/path.test.ts +20 -0
- package/testings/apis/auth/db.ts +15 -0
- package/testings/apis/auth/index.ts +28 -0
- package/testings/apis/hello.ts +3 -0
- package/testings/apis/quotes.ts +16 -0
- package/testings/apis/sub/index.ts +3 -0
- package/testings/apis/sub/sub.ts +3 -0
- package/testings/assets/SLIDEME.png +0 -0
- package/testings/assets/default.css +91 -0
- package/testings/assets/favicon.ico +0 -0
- package/testings/assets/icon.png +0 -0
- package/testings/assets/icon.svg +6 -0
- package/testings/assets/logo-144.png +0 -0
- package/testings/assets/logo-168.png +0 -0
- package/testings/assets/logo-192.png +0 -0
- package/testings/assets/logo-48.png +0 -0
- package/testings/assets/logo-512.png +0 -0
- package/testings/assets/logo-72.png +0 -0
- package/testings/assets/logo-96.png +0 -0
- package/testings/assets/manifest.json +57 -0
- package/testings/assets/markdown.css +274 -0
- package/testings/assets/robots.txt +1 -0
- package/testings/assets/system.css +7 -0
- package/testings/builds/forms/form.html +48 -0
- package/testings/builds/forms/index.html +48 -0
- package/testings/builds/profile/index.html +54 -0
- package/testings/bun.lockb +0 -0
- package/testings/components/header.tsx +7 -0
- package/testings/directives/index.ts +1 -0
- package/testings/directives/shown.ts +6 -0
- package/testings/index.html +20 -0
- package/testings/index.ts +19 -0
- package/testings/package.json +22 -0
- package/testings/routes/about.html +13 -0
- package/testings/routes/clock.tsx +35 -0
- package/testings/routes/counter.tsx +21 -0
- package/testings/routes/forms/form.css +19 -0
- package/testings/routes/forms/form.tsx +51 -0
- package/testings/routes/forms/index.tsx +3 -0
- package/testings/routes/hello.tsx +62 -0
- package/testings/routes/htmlx.html +15 -0
- package/testings/routes/index.md +15 -0
- package/testings/routes/login.tsx +36 -0
- package/testings/routes/profile/detail.css +13 -0
- package/testings/routes/profile/detail.tsx +48 -0
- package/testings/routes/profile/index.tsx +14 -0
- package/testings/routes/profile/profile.css +8 -0
- package/testings/routes/profile/tester.tsx +11 -0
- package/testings/routes/quotes.tsx +25 -0
- package/testings/routes/system.tsx +23 -0
- package/testings/tests/access.spec.ts +29 -0
- package/testings/tests/counter.spec.ts +19 -0
- package/testings/tests/form.spec.ts +51 -0
- package/testings/tests/hello.spec.ts +25 -0
- package/testings/tests/path.test.ts +20 -0
- package/testings/tsconfig.json +24 -0
- package/tsconfig.json +22 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { seo, client, useStore, state } from '@reactful/web'
|
3
|
+
import { Header } from '../components/header'
|
4
|
+
|
5
|
+
const orbital1 = useStore({ value:0 })
|
6
|
+
const orbital2 = useStore({ value:1 })
|
7
|
+
|
8
|
+
//@ts-ignore
|
9
|
+
@client(true)
|
10
|
+
@state(orbital1)
|
11
|
+
@state(orbital2)
|
12
|
+
@seo('Hello', 'Hello forms...')
|
13
|
+
export default function Hello(props, { store }: Feeds) {
|
14
|
+
if (globalThis.document) globalThis.props = props
|
15
|
+
|
16
|
+
return <>
|
17
|
+
<Header>Hello Forms</Header>
|
18
|
+
<main grid gaps='0 10px' cols={1}>
|
19
|
+
<label>
|
20
|
+
<b>LOCAL state </b> <code>function(props)</code><br/>
|
21
|
+
<input id='1' data={props} bind="value" placeholder="{props}" />
|
22
|
+
<input id='1.1' bind="value" placeholder="default" />
|
23
|
+
<SubLocal id='1.1.1' placeholder="inner" />
|
24
|
+
</label>
|
25
|
+
|
26
|
+
<label>
|
27
|
+
<b>GLOBAL state</b> <code>function(props, {'{ store }'})</code><br/>
|
28
|
+
<input id='2' data={store} bind="value" placeholder="outer" />
|
29
|
+
<SubGlobal id='2.1' placeholder='inner' />
|
30
|
+
</label>
|
31
|
+
|
32
|
+
<label>
|
33
|
+
<b>ORBITAL state</b> <code>useStore(...) + @state(...)</code><br/>
|
34
|
+
<input id='3' data={orbital1} bind="value" placeholder="outer" />
|
35
|
+
<SubOrbital id='3.1' placeholder='inner' />
|
36
|
+
<input id='3.2' data={orbital2} bind="value" placeholder="other" /> = {orbital2.value }
|
37
|
+
</label>
|
38
|
+
</main>
|
39
|
+
<br />
|
40
|
+
<hr />
|
41
|
+
<code>
|
42
|
+
<strong>local</strong>: <label id='l1'>{ props.value }</label><br />
|
43
|
+
<strong>global</strong>: <label id='l2'>{ store.value }</label><br />
|
44
|
+
<strong>orbital</strong>: <label id='l3'>{ orbital1.value }</label>
|
45
|
+
</code>
|
46
|
+
</>
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
function SubGlobal(props, { store }) {
|
51
|
+
return <input {...props} data={store} bind='value' />
|
52
|
+
}
|
53
|
+
|
54
|
+
function SubLocal(props) {
|
55
|
+
return <><input {...props} data={props} bind='value' /><label> = {props.value}</label></>
|
56
|
+
}
|
57
|
+
|
58
|
+
//@ts-ignore
|
59
|
+
@state(orbital1)
|
60
|
+
function SubOrbital(props) {
|
61
|
+
return <input {...props} data={orbital1} bind='value' />
|
62
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<head>
|
2
|
+
<title>Sample</title>
|
3
|
+
<meta name="description" content="Sample page">
|
4
|
+
<link type="component" href="../components/header.tsx" rel="Header" />
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<!-- no {interpolation} -->
|
8
|
+
<Header title="HTML-X" />
|
9
|
+
<p>
|
10
|
+
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
11
|
+
Similique eum quaerat nesciunt est molestias accusantium
|
12
|
+
aut sit odit, vero voluptate iure vel aperiam modi libero
|
13
|
+
in praesentium nam obcaecati error!
|
14
|
+
</p>
|
15
|
+
</body>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Welcome
|
2
|
+
> with markdown (powered by marked)
|
3
|
+
|
4
|
+
| | |
|
5
|
+
| ----------------------: | ----------------------------------------------- |
|
6
|
+
| [About](/about) | Static generation (default) |
|
7
|
+
| [Clock](/clock) | Dynamic generation (with lazy) |
|
8
|
+
| [HTML-X](/htmlx) | HTML with JSX using link[type='component'] |
|
9
|
+
| [System](/system) | Server component |
|
10
|
+
| [Quotes](/quotes) | Periodic genreation |
|
11
|
+
| [Counter](/counter) | Client component |
|
12
|
+
| [Hello](/hello) | Stateful object + data bind props |
|
13
|
+
| [Forms](/forms) | reactful forms + validation API + server action |
|
14
|
+
| [Login](/login) | reactful forms server action authentication |
|
15
|
+
| [Profile](/profile/123) | Parametric (dynamic) routes with modular CSS |
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// @ts-ignore: 1206
|
2
|
+
|
3
|
+
import React from 'react'
|
4
|
+
import { client } from '@reactful/web'
|
5
|
+
|
6
|
+
//@ts-ignore
|
7
|
+
@client(true)
|
8
|
+
export default (props, feeds: Feeds) => <>
|
9
|
+
<h1>Login</h1>
|
10
|
+
|
11
|
+
<progress hidden={!feeds.await}>loading...</progress>
|
12
|
+
|
13
|
+
<form method="POST" data={props.user}
|
14
|
+
action="http://localhost:3000/api/auth"
|
15
|
+
bearer="access_token">
|
16
|
+
|
17
|
+
<section grid cols={1}>
|
18
|
+
<label>UserName<input bind="username" /></label>
|
19
|
+
<label>PassWord<input type="password" bind="password" /></label>
|
20
|
+
</section>
|
21
|
+
|
22
|
+
<button>Submit</button>
|
23
|
+
</form>
|
24
|
+
|
25
|
+
<fieldset shown={!!feeds.fails?.length}>
|
26
|
+
<legend>ERROR</legend>
|
27
|
+
<ul>{ feeds.fails?.map((x,i) => <li key={i}>{ x.error }</li>) }</ul>
|
28
|
+
</fieldset>
|
29
|
+
|
30
|
+
<br />
|
31
|
+
|
32
|
+
<fieldset style={{ wordBreak: 'break-all' }}>
|
33
|
+
<legend>token</legend>
|
34
|
+
{ sessionStorage.getItem("token") }
|
35
|
+
</fieldset>
|
36
|
+
</>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { client } from '@reactful/web'
|
3
|
+
import '@reactful/extensions'
|
4
|
+
import './detail.css'
|
5
|
+
|
6
|
+
const Tester = import('./tester').asLazyComponent("Tester")
|
7
|
+
|
8
|
+
//@ts-ignore
|
9
|
+
@client(true)
|
10
|
+
export function Detail(_, feeds: Feeds) {
|
11
|
+
return <>
|
12
|
+
<h3>Detail</h3>
|
13
|
+
Parametric value = <b>{ feeds.param.id }</b>
|
14
|
+
|
15
|
+
<hr />
|
16
|
+
<p>modular CSS keep original color</p>
|
17
|
+
|
18
|
+
<fieldset>
|
19
|
+
<legend>Mode</legend>
|
20
|
+
|
21
|
+
<section>
|
22
|
+
<button link='./developer'>developer</button>
|
23
|
+
<button link='./manager'>manager</button>
|
24
|
+
<button link='./tester'>tester (component)</button>
|
25
|
+
</section>
|
26
|
+
|
27
|
+
<hr/>
|
28
|
+
|
29
|
+
<section route='./developer'>
|
30
|
+
<b>DEVELOPER</b> is Lorem ipsum dolor sit amet consectetur
|
31
|
+
adipisicing elit. Aspernatur similique ipsa, molestiae
|
32
|
+
numquam laudantium quod, aliquid soluta cumque placeat
|
33
|
+
saepe mollitia sint consectetur labore consequatur
|
34
|
+
pariatur praesentium animi. Obcaecati, nihil?
|
35
|
+
</section>
|
36
|
+
|
37
|
+
<section route='./manager'>
|
38
|
+
<b>MANAGER</b> is Lorem ipsum dolor sit amet consectetur
|
39
|
+
adipisicing elit. Aspernatur similique ipsa, molestiae
|
40
|
+
numquam laudantium quod, aliquid soluta cumque placeat
|
41
|
+
saepe mollitia sint consectetur labore consequatur
|
42
|
+
pariatur praesentium animi. Obcaecati, nihil?
|
43
|
+
</section>
|
44
|
+
|
45
|
+
<Tester route='./tester' />
|
46
|
+
</fieldset>
|
47
|
+
</>
|
48
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Detail } from './detail'
|
3
|
+
import { seo, route } from '@reactful/web'
|
4
|
+
import './profile.css'
|
5
|
+
|
6
|
+
//@ts-ignore
|
7
|
+
@route("/profile/:id")
|
8
|
+
@seo('Profile', 'Profile description')
|
9
|
+
export default () => <>
|
10
|
+
<h1>Profile</h1>
|
11
|
+
<Detail />
|
12
|
+
<hr/>
|
13
|
+
<p>modular CSS chainging to red</p>
|
14
|
+
</>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react"
|
2
|
+
|
3
|
+
export function Tester() {
|
4
|
+
return <section route='./manager'>
|
5
|
+
<b>TESTER</b> is Lorem ipsum dolor sit amet consectetur
|
6
|
+
adipisicing elit. Aspernatur similique ipsa, molestiae
|
7
|
+
numquam laudantium quod, aliquid soluta cumque placeat
|
8
|
+
saepe mollitia sint consectetur labore consequatur
|
9
|
+
pariatur praesentium animi. Obcaecati, nihil?
|
10
|
+
</section>
|
11
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { seo, server, error } from '@reactful/web'
|
3
|
+
|
4
|
+
//@ts-ignore
|
5
|
+
@server("periodic", "30min")
|
6
|
+
@error(specificErrorComponent)
|
7
|
+
@seo('Quotes', 'Philosophy quotes...')
|
8
|
+
export default async function Quotes(props: any) {
|
9
|
+
const url = "http://localhost:3000/api/quotes"
|
10
|
+
const txt = await fetch(url).then(x => x.text())
|
11
|
+
|
12
|
+
return <>
|
13
|
+
<h1>Philosophy quote of the day</h1>
|
14
|
+
<blockquote style={{zoom:1.1}}>{txt}</blockquote>
|
15
|
+
<hr /><code>it will be regenerated in each 30min (press F5 to check)</code>
|
16
|
+
</>
|
17
|
+
}
|
18
|
+
|
19
|
+
function specificErrorComponent(status: number, errors: string[]) {
|
20
|
+
return <>
|
21
|
+
<h1>My custom error component</h1>
|
22
|
+
<p> { errors.join(', ') } </p><hr/>
|
23
|
+
<code>it will be regenerated in each 30min (press F5 to check)</code>
|
24
|
+
</>
|
25
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import OS from "os"
|
2
|
+
import React from "react"
|
3
|
+
import { seo, style } from '@reactful/web'
|
4
|
+
|
5
|
+
const metatags: MetaTags = {
|
6
|
+
charset:"UTF-16",
|
7
|
+
rating:"general",
|
8
|
+
keywords:"hello, hi"
|
9
|
+
}
|
10
|
+
|
11
|
+
//@ts-ignore
|
12
|
+
@seo('System', metatags)
|
13
|
+
@style('/assets/system.css')
|
14
|
+
export default function System() {
|
15
|
+
const [ type, arch, release ] = [OS.type(), OS.arch(), OS.release()]
|
16
|
+
|
17
|
+
return <>
|
18
|
+
<h1>Server OS</h1>
|
19
|
+
<h2>server side information</h2>
|
20
|
+
<pre>{type} | {arch} | {release} </pre>
|
21
|
+
<section shown={false}>DONT SHOW ME!</section>
|
22
|
+
</>
|
23
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { test, expect } from '@playwright/test'
|
2
|
+
|
3
|
+
const cases = [
|
4
|
+
['/about', 'About'],
|
5
|
+
['/clock', 'World Clock'],
|
6
|
+
['/htmlx', 'HTML-X'],
|
7
|
+
['/system', 'Server OS'],
|
8
|
+
['/quotes', 'My custom error component', 'Philosophy quote of the day'],
|
9
|
+
['/counter', 'Counter'],
|
10
|
+
['/hello', 'Hello Forms'],
|
11
|
+
['/forms', 'Uncontrolled Components'],
|
12
|
+
['/profile/123', 'Profile'],
|
13
|
+
]
|
14
|
+
|
15
|
+
cases.forEach(function(scenario) {
|
16
|
+
const [ href, head, that ] = scenario
|
17
|
+
|
18
|
+
test(href, async ({ page }) => {
|
19
|
+
await page.goto('http://localhost:3000/')
|
20
|
+
await page.goto(href)
|
21
|
+
await page.waitForTimeout(333)
|
22
|
+
await page.waitForURL(`http://localhost:3000${href}`);
|
23
|
+
|
24
|
+
const h1 = await page.locator(`h1`).innerHTML()
|
25
|
+
const ok = [head,that].includes(h1)
|
26
|
+
|
27
|
+
if (!ok) expect(h1).toBe(that || head)
|
28
|
+
})
|
29
|
+
})
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { test, expect } from '@playwright/test'
|
2
|
+
|
3
|
+
test('counter: statefull props', async ({ page }) => {
|
4
|
+
await page.goto('http://localhost:3000/counter')
|
5
|
+
await page.waitForTimeout(99)
|
6
|
+
await page.click('button', { delay:99 })
|
7
|
+
await page.click('button', { delay:99 })
|
8
|
+
await page.click('button', { delay:99 })
|
9
|
+
await page.waitForTimeout(99)
|
10
|
+
|
11
|
+
const btn = await page.locator('button').innerText()
|
12
|
+
expect(btn.trim()).toBe('COUNTED: 3')
|
13
|
+
})
|
14
|
+
|
15
|
+
test('counter: shown custom props directive', async ({ page }) => {
|
16
|
+
await page.goto('http://localhost:3000/counter')
|
17
|
+
const h2IsVisible = await page.locator('h6').isVisible()
|
18
|
+
expect(h2IsVisible).toBe(false)
|
19
|
+
})
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// import { test, expect } from '@playwright/test'
|
2
|
+
|
3
|
+
// async function goto(page) {
|
4
|
+
// await page.goto('http://localhost:3000/forms')
|
5
|
+
// await page.waitForTimeout(1500)
|
6
|
+
// }
|
7
|
+
|
8
|
+
// test(`form validation: checkbox`, async function({ page }) {
|
9
|
+
// await goto(page)
|
10
|
+
// await page.click('button', { delay:333 })
|
11
|
+
|
12
|
+
// const check = await page.locator('[type="checkbox"]')
|
13
|
+
// const checkHandle = await check!.evaluateHandle(x => x['validationMessage'])
|
14
|
+
// const validationMessage = await checkHandle.jsonValue()
|
15
|
+
|
16
|
+
// expect(validationMessage).toBe('Please check this box if you want to proceed')
|
17
|
+
// })
|
18
|
+
|
19
|
+
// test(`form validation: input`, async function({ page }) {
|
20
|
+
// await goto(page)
|
21
|
+
// await page.click('[uid="14"]')
|
22
|
+
// await page.click('button', { delay:333 })
|
23
|
+
|
24
|
+
// const input = await page.evaluate(() => document.querySelector('[bind="mode"]'))
|
25
|
+
// const validationMessage = input && input['validationMessage']
|
26
|
+
|
27
|
+
// // const input = await page.$('[bind="mode"]');
|
28
|
+
// // const inputHandle = await input!.evaluateHandle(x => x['validationMessage'])
|
29
|
+
// // const validationMessage = await inputHandle.jsonValue()
|
30
|
+
|
31
|
+
// expect(validationMessage).toBe('Mode is required!')
|
32
|
+
// })
|
33
|
+
|
34
|
+
// test(`form action: errors feedback`, async function({ page }) {
|
35
|
+
// await goto(page)
|
36
|
+
|
37
|
+
// const checkbox = await page.getByLabel('Accepted?')
|
38
|
+
// await checkbox.click()
|
39
|
+
|
40
|
+
// await page.getByLabel('Accepted?').click()
|
41
|
+
// await page.fill('[bind="mode"]', 'ok', { timeout:99 })
|
42
|
+
// await page.click('button', { delay:333 })
|
43
|
+
|
44
|
+
// const progress = await page.locator('progress').isVisible()
|
45
|
+
// expect(progress).toBe(true)
|
46
|
+
|
47
|
+
// await page.waitForTimeout(333)
|
48
|
+
|
49
|
+
// const li = await page.locator('ul > li').innerHTML()
|
50
|
+
// expect(li).toContain('URL not found')
|
51
|
+
// })
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { test, expect } from '@playwright/test'
|
2
|
+
|
3
|
+
const cases = [
|
4
|
+
['local', 'hi!', '[id="1"]', '#l1'],
|
5
|
+
['global (outer)', 'hi!', '[id="2"]', '#l2'],
|
6
|
+
['global (inner)', 'hi!', '[id="3"]', '#l2'],
|
7
|
+
]
|
8
|
+
|
9
|
+
cases.forEach(function(scenario) {
|
10
|
+
const [ scope, text, inputId, labelId ] = scenario
|
11
|
+
|
12
|
+
test(`hello: ${scope} props binding`, async function({ page }) {
|
13
|
+
await page.goto('http://localhost:3000/hello')
|
14
|
+
await page.waitForTimeout(99)
|
15
|
+
|
16
|
+
for await (const char of text.split('')) {
|
17
|
+
await page.waitForTimeout(99)
|
18
|
+
await page.type(inputId, char, { delay: 99 })
|
19
|
+
}
|
20
|
+
|
21
|
+
await page.waitForTimeout(99)
|
22
|
+
const result = await page.locator(labelId).innerText()
|
23
|
+
expect(result).toBe(text)
|
24
|
+
})
|
25
|
+
})
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { test, expect } from 'bun:test'
|
2
|
+
|
3
|
+
const scenarios = [
|
4
|
+
['url', '/routes', '/'],
|
5
|
+
['sub url', '/routes/sub', '/sub'],
|
6
|
+
['http', 'http://domain.com/routes', '/'],
|
7
|
+
['https', 'https://domain.com/routes', '/'],
|
8
|
+
['https port', 'https://domain.com:3000/routes', '/'],
|
9
|
+
['https port file', 'https://domain.com:3000/routes/file.tsx', '/file'],
|
10
|
+
['https port index', 'https://domain.com:3000/routes/index', '/'],
|
11
|
+
['https port sub file', 'https://domain.com:3000/routes/sub/file.tsx', '/sub/file'],
|
12
|
+
]
|
13
|
+
|
14
|
+
scenarios.forEach(function([ scenario, sampling, expected ]) {
|
15
|
+
test(`new Path(url).href: ${scenario}`, function() {
|
16
|
+
const resulted = new URL(sampling).pathname
|
17
|
+
expect(resulted).toBe(expected as any)
|
18
|
+
// console.log('sampling:', sampling)
|
19
|
+
})
|
20
|
+
})
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"exclude": ["node_modules"],
|
3
|
+
"compilerOptions": {
|
4
|
+
"rootDir": ".",
|
5
|
+
"jsx": "react",
|
6
|
+
"target": "esnext",
|
7
|
+
"module": "esnext",
|
8
|
+
"types": ["bun-types"],
|
9
|
+
"moduleDetection": "auto",
|
10
|
+
"moduleResolution": "bundler",
|
11
|
+
"noEmit": true,
|
12
|
+
"strict": false,
|
13
|
+
"allowJs": true,
|
14
|
+
"sourceMap": true,
|
15
|
+
"composite": true,
|
16
|
+
"declaration": true,
|
17
|
+
"skipLibCheck": true,
|
18
|
+
"noImplicitAny": false,
|
19
|
+
"esModuleInterop": true,
|
20
|
+
"downlevelIteration": true,
|
21
|
+
"allowSyntheticDefaultImports": true,
|
22
|
+
"forceConsistentCasingInFileNames": true
|
23
|
+
}
|
24
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"exclude": ["node_modules"],
|
3
|
+
"compilerOptions": {
|
4
|
+
"types": ["bun-types"],
|
5
|
+
"module": "esnext",
|
6
|
+
"target": "esnext",
|
7
|
+
"moduleDetection": "auto",
|
8
|
+
"moduleResolution": "bundler",
|
9
|
+
"noEmit": true,
|
10
|
+
"strict": true,
|
11
|
+
"allowJs": true,
|
12
|
+
"composite": true,
|
13
|
+
"declaration": true,
|
14
|
+
"skipLibCheck": true,
|
15
|
+
"noImplicitAny": false,
|
16
|
+
"esModuleInterop": true,
|
17
|
+
"downlevelIteration": true,
|
18
|
+
"allowImportingTsExtensions": true,
|
19
|
+
"allowSyntheticDefaultImports": true,
|
20
|
+
"forceConsistentCasingInFileNames": true
|
21
|
+
}
|
22
|
+
}
|