@reactful/create 0.0.51

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. package/README.md +8 -0
  2. package/bun.lockb +0 -0
  3. package/common/package.json +22 -0
  4. package/common/tsconfig.json +24 -0
  5. package/index.js +77 -0
  6. package/package.json +16 -0
  7. package/templates/empty/index.html +12 -0
  8. package/templates/empty/index.ts +5 -0
  9. package/templates/minimal/index.html +12 -0
  10. package/templates/minimal/index.ts +5 -0
  11. package/templates/sampling/apis/auth/db.ts +15 -0
  12. package/templates/sampling/apis/auth/index.ts +28 -0
  13. package/templates/sampling/apis/hello.ts +3 -0
  14. package/templates/sampling/apis/quotes.ts +16 -0
  15. package/templates/sampling/apis/sub/index.ts +3 -0
  16. package/templates/sampling/apis/sub/sub.ts +3 -0
  17. package/templates/sampling/assets/SLIDEME.png +0 -0
  18. package/templates/sampling/assets/default.css +91 -0
  19. package/templates/sampling/assets/favicon.ico +0 -0
  20. package/templates/sampling/assets/icon.png +0 -0
  21. package/templates/sampling/assets/icon.svg +6 -0
  22. package/templates/sampling/assets/logo-144.png +0 -0
  23. package/templates/sampling/assets/logo-168.png +0 -0
  24. package/templates/sampling/assets/logo-192.png +0 -0
  25. package/templates/sampling/assets/logo-48.png +0 -0
  26. package/templates/sampling/assets/logo-512.png +0 -0
  27. package/templates/sampling/assets/logo-72.png +0 -0
  28. package/templates/sampling/assets/logo-96.png +0 -0
  29. package/templates/sampling/assets/manifest.json +57 -0
  30. package/templates/sampling/assets/markdown.css +274 -0
  31. package/templates/sampling/assets/robots.txt +1 -0
  32. package/templates/sampling/assets/system.css +7 -0
  33. package/templates/sampling/builds/about.html +27 -0
  34. package/templates/sampling/builds/bundle.js +13116 -0
  35. package/templates/sampling/builds/bundle.ts +25 -0
  36. package/templates/sampling/builds/client.ts +1 -0
  37. package/templates/sampling/builds/clock.html +30 -0
  38. package/templates/sampling/builds/counter.html +30 -0
  39. package/templates/sampling/builds/forms/form.html +48 -0
  40. package/templates/sampling/builds/forms/index.html +48 -0
  41. package/templates/sampling/builds/hello.html +60 -0
  42. package/templates/sampling/builds/htmlx.html +24 -0
  43. package/templates/sampling/builds/htmlx.tsx +13 -0
  44. package/templates/sampling/builds/index.html +98 -0
  45. package/templates/sampling/builds/login.html +45 -0
  46. package/templates/sampling/builds/profile/index.html +54 -0
  47. package/templates/sampling/builds/quotes.html +26 -0
  48. package/templates/sampling/builds/shared.js +76 -0
  49. package/templates/sampling/builds/system.html +27 -0
  50. package/templates/sampling/components/header.tsx +7 -0
  51. package/templates/sampling/directives/index.ts +1 -0
  52. package/templates/sampling/directives/shown.ts +6 -0
  53. package/templates/sampling/index.html +20 -0
  54. package/templates/sampling/index.ts +19 -0
  55. package/templates/sampling/routes/about.html +13 -0
  56. package/templates/sampling/routes/clock.tsx +35 -0
  57. package/templates/sampling/routes/counter.tsx +21 -0
  58. package/templates/sampling/routes/forms/form.css +19 -0
  59. package/templates/sampling/routes/forms/form.tsx +51 -0
  60. package/templates/sampling/routes/forms/index.tsx +3 -0
  61. package/templates/sampling/routes/hello.tsx +62 -0
  62. package/templates/sampling/routes/htmlx.html +15 -0
  63. package/templates/sampling/routes/index.md +15 -0
  64. package/templates/sampling/routes/login.tsx +36 -0
  65. package/templates/sampling/routes/profile/detail.css +13 -0
  66. package/templates/sampling/routes/profile/detail.tsx +48 -0
  67. package/templates/sampling/routes/profile/index.tsx +14 -0
  68. package/templates/sampling/routes/profile/profile.css +8 -0
  69. package/templates/sampling/routes/profile/tester.tsx +11 -0
  70. package/templates/sampling/routes/quotes.tsx +25 -0
  71. package/templates/sampling/routes/system.tsx +23 -0
  72. package/templates/sampling/tests/access.spec.ts +29 -0
  73. package/templates/sampling/tests/counter.spec.ts +19 -0
  74. package/templates/sampling/tests/form.spec.ts +51 -0
  75. package/templates/sampling/tests/hello.spec.ts +25 -0
  76. package/templates/sampling/tests/path.test.ts +20 -0
  77. package/testings/apis/auth/db.ts +15 -0
  78. package/testings/apis/auth/index.ts +28 -0
  79. package/testings/apis/hello.ts +3 -0
  80. package/testings/apis/quotes.ts +16 -0
  81. package/testings/apis/sub/index.ts +3 -0
  82. package/testings/apis/sub/sub.ts +3 -0
  83. package/testings/assets/SLIDEME.png +0 -0
  84. package/testings/assets/default.css +91 -0
  85. package/testings/assets/favicon.ico +0 -0
  86. package/testings/assets/icon.png +0 -0
  87. package/testings/assets/icon.svg +6 -0
  88. package/testings/assets/logo-144.png +0 -0
  89. package/testings/assets/logo-168.png +0 -0
  90. package/testings/assets/logo-192.png +0 -0
  91. package/testings/assets/logo-48.png +0 -0
  92. package/testings/assets/logo-512.png +0 -0
  93. package/testings/assets/logo-72.png +0 -0
  94. package/testings/assets/logo-96.png +0 -0
  95. package/testings/assets/manifest.json +57 -0
  96. package/testings/assets/markdown.css +274 -0
  97. package/testings/assets/robots.txt +1 -0
  98. package/testings/assets/system.css +7 -0
  99. package/testings/builds/forms/form.html +48 -0
  100. package/testings/builds/forms/index.html +48 -0
  101. package/testings/builds/profile/index.html +54 -0
  102. package/testings/bun.lockb +0 -0
  103. package/testings/components/header.tsx +7 -0
  104. package/testings/directives/index.ts +1 -0
  105. package/testings/directives/shown.ts +6 -0
  106. package/testings/index.html +20 -0
  107. package/testings/index.ts +19 -0
  108. package/testings/package.json +22 -0
  109. package/testings/routes/about.html +13 -0
  110. package/testings/routes/clock.tsx +35 -0
  111. package/testings/routes/counter.tsx +21 -0
  112. package/testings/routes/forms/form.css +19 -0
  113. package/testings/routes/forms/form.tsx +51 -0
  114. package/testings/routes/forms/index.tsx +3 -0
  115. package/testings/routes/hello.tsx +62 -0
  116. package/testings/routes/htmlx.html +15 -0
  117. package/testings/routes/index.md +15 -0
  118. package/testings/routes/login.tsx +36 -0
  119. package/testings/routes/profile/detail.css +13 -0
  120. package/testings/routes/profile/detail.tsx +48 -0
  121. package/testings/routes/profile/index.tsx +14 -0
  122. package/testings/routes/profile/profile.css +8 -0
  123. package/testings/routes/profile/tester.tsx +11 -0
  124. package/testings/routes/quotes.tsx +25 -0
  125. package/testings/routes/system.tsx +23 -0
  126. package/testings/tests/access.spec.ts +29 -0
  127. package/testings/tests/counter.spec.ts +19 -0
  128. package/testings/tests/form.spec.ts +51 -0
  129. package/testings/tests/hello.spec.ts +25 -0
  130. package/testings/tests/path.test.ts +20 -0
  131. package/testings/tsconfig.json +24 -0
  132. package/tsconfig.json +22 -0
@@ -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,15 @@
1
+ const database = [
2
+ { username: 'usr', password: 'pwd' },
3
+ { username: 'test', password: '123' },
4
+ ]
5
+
6
+ export const db = {
7
+
8
+ has(username, password) {
9
+ const contains = database
10
+ .filter(x => x.username == username)
11
+ .some(x => x.password == password)
12
+
13
+ return Promise.resolve(contains)
14
+ }
15
+ }
@@ -0,0 +1,28 @@
1
+ "user server"
2
+
3
+ import { delay } from '../../../commons/src'
4
+ import { db } from "./db"
5
+
6
+ const SECRET_KEY = '0123456789'
7
+
8
+ export async function post(request: Request) {
9
+ await delay(3000)
10
+
11
+ const AUTHORIZATION = request.headers.get('authorization')
12
+ const UNAUTHORIZED = { status: 401, headers: { 'Content-Type': 'text/plain' }}
13
+ const NO_HEADERS = 'Authorization header missing!'
14
+ const NOT_LOGIN = 'Authentication failed!'
15
+
16
+ if (!AUTHORIZATION?.startsWith('Basic '))
17
+ return new Response(NO_HEADERS, UNAUTHORIZED)
18
+
19
+ const auth = AUTHORIZATION.split(' ')[1]
20
+ const credential = Buffer.from(auth, 'base64').toString('utf-8')
21
+ const [ username, password ] = credential.split(':')
22
+ const exists = await db.has(username, password)
23
+ const settings = exists ? { } : UNAUTHORIZED
24
+ const access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
25
+ const text = exists ? JSON.stringify({ access_token }) : NOT_LOGIN
26
+
27
+ return new Response(text, settings)
28
+ }
@@ -0,0 +1,3 @@
1
+ export function get(request: Request) {
2
+ return new Response("hello world")
3
+ }
@@ -0,0 +1,16 @@
1
+ export function get(request: Request) {
2
+ function getRandomInt(max) { return Math.floor(Math.random() * max); }
3
+
4
+ const messages = [
5
+ "Man is the measure of all things (Protagoras)",
6
+ "The unexamined life is not worth living (Socrates)",
7
+ "One cannot step twice in the same river (Heraclitus)",
8
+ "Life must be understood backward. But it must be lived forward (Kierkegaard)",
9
+ "Science is what you know. Philosophy is what you don't know (Russell)",
10
+ "I can control my passions and emotions if I can understand their nature (Spinoza)"
11
+ ]
12
+
13
+ const message = messages[getRandomInt(messages.length)]
14
+
15
+ return new Response(message)
16
+ }
@@ -0,0 +1,3 @@
1
+ export function get(request: Request) {
2
+ return new Response("hi sub index")
3
+ }
@@ -0,0 +1,3 @@
1
+ export function get(request: Request) {
2
+ return new Response("hi sub-sub.ts")
3
+ }
Binary file
@@ -0,0 +1,91 @@
1
+ @import url('https://fonts.cdnfonts.com/css/share-tech');
2
+
3
+ body,
4
+ h1,
5
+ h2,
6
+ h3,
7
+ h4,
8
+ h5,
9
+ h6,
10
+ button,
11
+ textarea,
12
+ input,
13
+ select {
14
+ font-family: agave !important
15
+ }
16
+
17
+ @media (prefers-color-scheme: dark) {
18
+ body {
19
+ background-color: #333;
20
+ color: #EEE;
21
+ }
22
+
23
+ a {
24
+ color: wheat
25
+ }
26
+
27
+ a:hover {
28
+ color: yellow
29
+ }
30
+
31
+ button {
32
+ background-color: #AAA;
33
+ border-width: 1px;
34
+ padding: 10px 5px;
35
+ }
36
+
37
+ input,
38
+ textarea {
39
+ color: #EEE;
40
+ background-color: #444;
41
+ border-color: #555;
42
+ border-style: solid;
43
+ border-width: 1px;
44
+ outline: none;
45
+ }
46
+
47
+ input:focus {
48
+ border-color: #AAA;
49
+ outline: none;
50
+ }
51
+ }
52
+
53
+ input.Hello,
54
+ [bind='value'],
55
+ [own^='Sub'] {
56
+ width: 50px;
57
+ }
58
+
59
+ label.Hello {
60
+ margin-bottom: 20px;
61
+ }
62
+
63
+ label.Hello code {
64
+ font-size: 12px;
65
+ color: silver;
66
+ }
67
+
68
+ button.Detail {
69
+ padding: 10px;
70
+ margin: 10px;
71
+ cursor: pointer;
72
+ background-color: #ccc;
73
+ border: 1px solid #000;
74
+ transition: margin-top 0.2s ease-in-out, margin-bottom 0.2s ease-in-out;
75
+ }
76
+
77
+ button.Detail:hover {
78
+ background-color: #ddd;
79
+ }
80
+
81
+ button.Detail:active {
82
+ margin-top: 5px;
83
+ margin-bottom: 5px;
84
+ }
85
+
86
+
87
+ button.Detail:active {
88
+ color: white;
89
+ background-color: #777;
90
+ transform: translate(2px, 2px);
91
+ }
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="263px" height="388px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" xmlns:xlink="http://www.w3.org/1999/xlink">
4
+ <g><path style="opacity:1" fill="#f4ddb2" d="M 74.5,-0.5 C 75.5,-0.5 76.5,-0.5 77.5,-0.5C 107.762,24.9817 138.096,50.4817 168.5,76C 122.614,121.98 103.114,177.48 110,242.5C 118.974,305.846 150.474,354.179 204.5,387.5C 201.5,387.5 198.5,387.5 195.5,387.5C 125.186,377.001 70.6858,342.001 32,282.5C 13.2853,251.287 2.45197,217.62 -0.5,181.5C -0.5,171.5 -0.5,161.5 -0.5,151.5C 5.05174,91.1449 30.0517,40.4783 74.5,-0.5 Z"/></g>
5
+ <g><path style="opacity:1" fill="#f4ddb2" d="M 262.5,175.5 C 262.5,180.833 262.5,186.167 262.5,191.5C 254.191,224.617 232.858,240.451 198.5,239C 177.426,234.92 162.593,223.087 154,203.5C 145.539,175.55 153.039,153.05 176.5,136C 202.655,122.121 226.488,125.288 248,145.5C 255.287,154.405 260.12,164.405 262.5,175.5 Z"/></g>
6
+ </svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "React Minus",
3
+ "start_url": ".",
4
+ "theme_color": "#333",
5
+ "short_name": "reactful",
6
+ "display": "standalone",
7
+ "background_color": "#333",
8
+ "description": "A sample app",
9
+ "icons": [
10
+ {
11
+ "src": "logo-48.png",
12
+ "sizes": "48x48",
13
+ "type": "image/png",
14
+ "purpose": "any maskable"
15
+ },
16
+ {
17
+ "src": "logo-72.png",
18
+ "sizes": "72x72",
19
+ "type": "image/png",
20
+ "purpose": "any maskable"
21
+ },
22
+ {
23
+ "src": "logo-96.png",
24
+ "sizes": "96x96",
25
+ "type": "image/png",
26
+ "purpose": "any maskable"
27
+ },
28
+ {
29
+ "src": "logo-144.png",
30
+ "sizes": "144x144",
31
+ "type": "image/png",
32
+ "purpose": "any maskable"
33
+ },
34
+ {
35
+ "src": "logo-168.png",
36
+ "sizes": "168x168",
37
+ "type": "image/png",
38
+ "purpose": "any maskable"
39
+ },
40
+ {
41
+ "src": "logo-192.png",
42
+ "sizes": "192x192",
43
+ "type": "image/png",
44
+ "purpose": "any maskable"
45
+ },
46
+ {
47
+ "src": "logo-512.png",
48
+ "sizes": "512x512",
49
+ "type": "image/png",
50
+ "purpose": "any maskable"
51
+ }
52
+ ],
53
+ "related_applications": [{
54
+ "platform": "play",
55
+ "url": "https://play.google.com/store/apps/details?id=sample"
56
+ }]
57
+ }