create-vite-hyperapp 1.3.0 → 2.0.1

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 (222) hide show
  1. package/README.md +110 -18
  2. package/create-vite-hyperapp.mjs +193 -0
  3. package/package.json +18 -11
  4. package/templates/{template → common}/_gitignore +1 -1
  5. package/templates/{template-ts/src → common/src/app}/style.css +0 -4
  6. package/templates/{template → js-html-cli}/index.html +3 -3
  7. package/templates/js-html-cli/jsconfig.json +13 -0
  8. package/templates/js-html-cli/package.json +20 -0
  9. package/templates/js-html-cli/src/app/counter.js +5 -0
  10. package/templates/js-html-cli/src/app/logos.js +24 -0
  11. package/templates/js-html-cli/src/app/main.js +24 -0
  12. package/templates/{template → js-html-cli}/src/run.js +2 -2
  13. package/templates/js-html-cli/vite.config.js +12 -0
  14. package/templates/{template-ssr → js-html-ssr}/index.html +2 -2
  15. package/templates/js-html-ssr/jsconfig.json +13 -0
  16. package/templates/js-html-ssr/package.json +25 -0
  17. package/templates/{template-ssr → js-html-ssr}/server.js +10 -8
  18. package/templates/js-html-ssr/src/app/counter.js +5 -0
  19. package/templates/js-html-ssr/src/app/logos.js +24 -0
  20. package/templates/js-html-ssr/src/app/main.js +24 -0
  21. package/templates/{template-ssr → js-html-ssr}/src/entry-client.js +2 -2
  22. package/templates/js-html-ssr/src/entry-server.js +5 -0
  23. package/templates/js-html-ssr/vite.config.js +13 -0
  24. package/templates/js-jsx-cli/index.html +13 -0
  25. package/templates/js-jsx-cli/jsconfig.json +15 -0
  26. package/templates/{template → js-jsx-cli}/package.json +3 -3
  27. package/templates/js-jsx-cli/src/app/logos.jsx +15 -0
  28. package/templates/{template/src → js-jsx-cli/src/app}/main.jsx +1 -13
  29. package/templates/js-jsx-cli/src/run.js +5 -0
  30. package/templates/js-jsx-cli/vite.config.js +12 -0
  31. package/templates/js-jsx-ssr/index.html +13 -0
  32. package/templates/js-jsx-ssr/jsconfig.json +15 -0
  33. package/templates/{template-ssr → js-jsx-ssr}/package.json +7 -7
  34. package/templates/{template-ts-ssr → js-jsx-ssr}/server.js +11 -9
  35. package/templates/js-jsx-ssr/src/app/logos.jsx +15 -0
  36. package/templates/{template-ssr/src → js-jsx-ssr/src/app}/main.jsx +1 -13
  37. package/templates/js-jsx-ssr/src/entry-client.js +5 -0
  38. package/templates/js-jsx-ssr/src/entry-server.js +5 -0
  39. package/templates/js-jsx-ssr/vite.config.js +13 -0
  40. package/templates/js-plain-cli/index.html +13 -0
  41. package/templates/js-plain-cli/jsconfig.json +13 -0
  42. package/templates/{template-ts → js-plain-cli}/package.json +4 -5
  43. package/templates/js-plain-cli/src/app/counter.js +8 -0
  44. package/templates/js-plain-cli/src/app/logos.js +18 -0
  45. package/templates/js-plain-cli/src/app/main.js +25 -0
  46. package/templates/js-plain-cli/src/run.js +5 -0
  47. package/templates/js-plain-cli/vite.config.js +12 -0
  48. package/templates/js-plain-ssr/index.html +13 -0
  49. package/templates/js-plain-ssr/jsconfig.json +13 -0
  50. package/templates/{template-ts-ssr → js-plain-ssr}/package.json +8 -9
  51. package/templates/js-plain-ssr/server.js +62 -0
  52. package/templates/js-plain-ssr/src/app/counter.js +8 -0
  53. package/templates/js-plain-ssr/src/app/logos.js +18 -0
  54. package/templates/js-plain-ssr/src/app/main.js +25 -0
  55. package/templates/js-plain-ssr/src/entry-client.js +5 -0
  56. package/templates/js-plain-ssr/src/entry-server.js +5 -0
  57. package/templates/js-plain-ssr/vite.config.js +13 -0
  58. package/templates/tj-html-cli/index.html +13 -0
  59. package/templates/tj-html-cli/jsconfig.json +29 -0
  60. package/templates/tj-html-cli/package.json +21 -0
  61. package/templates/tj-html-cli/src/app/counter.js +16 -0
  62. package/templates/tj-html-cli/src/app/logos.js +24 -0
  63. package/templates/tj-html-cli/src/app/main.js +27 -0
  64. package/templates/tj-html-cli/src/run.js +5 -0
  65. package/templates/tj-html-cli/src/types/global.d.ts +13 -0
  66. package/templates/tj-html-cli/src/types/hyperapp-html.d.ts +101 -0
  67. package/templates/tj-html-cli/src/types/hyperapp-svg.d.ts +73 -0
  68. package/templates/tj-html-cli/src/types/hyperapp-tags.d.ts +34 -0
  69. package/templates/tj-html-cli/vite.config.js +12 -0
  70. package/templates/tj-html-ssr/index.html +13 -0
  71. package/templates/tj-html-ssr/jsconfig.json +31 -0
  72. package/templates/tj-html-ssr/package.json +29 -0
  73. package/templates/tj-html-ssr/server.js +63 -0
  74. package/templates/tj-html-ssr/src/app/counter.js +16 -0
  75. package/templates/tj-html-ssr/src/app/logos.js +24 -0
  76. package/templates/tj-html-ssr/src/app/main.js +27 -0
  77. package/templates/tj-html-ssr/src/entry-client.js +5 -0
  78. package/templates/tj-html-ssr/src/entry-server.js +5 -0
  79. package/templates/tj-html-ssr/src/types/global.d.ts +13 -0
  80. package/templates/tj-html-ssr/src/types/hyperapp-html.d.ts +101 -0
  81. package/templates/tj-html-ssr/src/types/hyperapp-svg.d.ts +73 -0
  82. package/templates/tj-html-ssr/src/types/hyperapp-tags.d.ts +34 -0
  83. package/templates/tj-html-ssr/vite.config.js +13 -0
  84. package/templates/tj-jsx-cli/index.html +13 -0
  85. package/templates/tj-jsx-cli/jsconfig.json +31 -0
  86. package/templates/tj-jsx-cli/package.json +19 -0
  87. package/templates/tj-jsx-cli/src/app/counter.jsx +18 -0
  88. package/templates/tj-jsx-cli/src/app/logos.jsx +15 -0
  89. package/templates/tj-jsx-cli/src/app/main.jsx +26 -0
  90. package/templates/tj-jsx-cli/src/run.js +5 -0
  91. package/templates/tj-jsx-cli/src/types/global.d.ts +13 -0
  92. package/templates/tj-jsx-cli/vite.config.js +12 -0
  93. package/templates/tj-jsx-ssr/index.html +13 -0
  94. package/templates/tj-jsx-ssr/jsconfig.json +33 -0
  95. package/templates/tj-jsx-ssr/package.json +27 -0
  96. package/templates/tj-jsx-ssr/server.js +63 -0
  97. package/templates/tj-jsx-ssr/src/app/counter.jsx +18 -0
  98. package/templates/tj-jsx-ssr/src/app/logos.jsx +15 -0
  99. package/templates/tj-jsx-ssr/src/app/main.jsx +26 -0
  100. package/templates/tj-jsx-ssr/src/entry-client.js +5 -0
  101. package/templates/tj-jsx-ssr/src/entry-server.js +5 -0
  102. package/templates/tj-jsx-ssr/src/types/global.d.ts +13 -0
  103. package/templates/tj-jsx-ssr/vite.config.js +13 -0
  104. package/templates/tj-plain-cli/index.html +13 -0
  105. package/templates/tj-plain-cli/jsconfig.json +29 -0
  106. package/templates/tj-plain-cli/package.json +19 -0
  107. package/templates/tj-plain-cli/src/app/counter.js +19 -0
  108. package/templates/tj-plain-cli/src/app/logos.js +18 -0
  109. package/templates/tj-plain-cli/src/app/main.js +28 -0
  110. package/templates/tj-plain-cli/src/run.js +5 -0
  111. package/templates/tj-plain-cli/src/types/global.d.ts +13 -0
  112. package/templates/tj-plain-cli/src/types/hyperapp-h.d.ts +37 -0
  113. package/templates/tj-plain-cli/vite.config.js +12 -0
  114. package/templates/tj-plain-ssr/index.html +13 -0
  115. package/templates/tj-plain-ssr/jsconfig.json +31 -0
  116. package/templates/tj-plain-ssr/package.json +27 -0
  117. package/templates/tj-plain-ssr/server.js +63 -0
  118. package/templates/tj-plain-ssr/src/app/counter.js +19 -0
  119. package/templates/tj-plain-ssr/src/app/logos.js +18 -0
  120. package/templates/tj-plain-ssr/src/app/main.js +28 -0
  121. package/templates/tj-plain-ssr/src/entry-client.js +5 -0
  122. package/templates/tj-plain-ssr/src/entry-server.js +5 -0
  123. package/templates/tj-plain-ssr/src/types/global.d.ts +13 -0
  124. package/templates/tj-plain-ssr/src/types/hyperapp-h.d.ts +37 -0
  125. package/templates/tj-plain-ssr/vite.config.js +13 -0
  126. package/templates/{template-ts → ts-html-cli}/index.html +3 -3
  127. package/templates/ts-html-cli/package.json +21 -0
  128. package/templates/ts-html-cli/src/app/counter.ts +12 -0
  129. package/templates/ts-html-cli/src/app/logos.ts +33 -0
  130. package/templates/ts-html-cli/src/app/main.ts +27 -0
  131. package/templates/{template-ts → ts-html-cli}/src/run.ts +2 -2
  132. package/templates/ts-html-cli/src/types/hyperapp-html.d.ts +101 -0
  133. package/templates/ts-html-cli/src/types/hyperapp-svg.d.ts +73 -0
  134. package/templates/ts-html-cli/src/types/hyperapp-tags.d.ts +34 -0
  135. package/templates/ts-html-cli/tsconfig.json +27 -0
  136. package/templates/ts-html-cli/vite.config.ts +12 -0
  137. package/templates/{template-ts-ssr → ts-html-ssr}/index.html +2 -2
  138. package/templates/ts-html-ssr/package.json +32 -0
  139. package/templates/ts-html-ssr/server.ts +63 -0
  140. package/templates/ts-html-ssr/src/app/counter.ts +12 -0
  141. package/templates/ts-html-ssr/src/app/logos.ts +33 -0
  142. package/templates/ts-html-ssr/src/app/main.ts +27 -0
  143. package/templates/{template-ts-ssr → ts-html-ssr}/src/entry-client.ts +2 -2
  144. package/templates/ts-html-ssr/src/entry-server.ts +5 -0
  145. package/templates/ts-html-ssr/src/types/hyperapp-html.d.ts +101 -0
  146. package/templates/ts-html-ssr/src/types/hyperapp-svg.d.ts +73 -0
  147. package/templates/ts-html-ssr/src/types/hyperapp-tags.d.ts +34 -0
  148. package/templates/ts-html-ssr/tsconfig.json +27 -0
  149. package/templates/ts-html-ssr/vite.config.ts +13 -0
  150. package/templates/ts-jsx-cli/index.html +13 -0
  151. package/templates/ts-jsx-cli/package.json +21 -0
  152. package/templates/ts-jsx-cli/src/app/counter.tsx +14 -0
  153. package/templates/ts-jsx-cli/src/app/logos.tsx +19 -0
  154. package/templates/ts-jsx-cli/src/app/main.tsx +26 -0
  155. package/templates/ts-jsx-cli/src/assets/typescript.svg +1 -0
  156. package/templates/ts-jsx-cli/src/run.ts +5 -0
  157. package/templates/{template-ts → ts-jsx-cli}/tsconfig.json +6 -3
  158. package/templates/ts-jsx-cli/vite.config.ts +12 -0
  159. package/templates/ts-jsx-ssr/index.html +13 -0
  160. package/templates/ts-jsx-ssr/package.json +30 -0
  161. package/templates/ts-jsx-ssr/server.ts +63 -0
  162. package/templates/ts-jsx-ssr/src/app/counter.tsx +14 -0
  163. package/templates/ts-jsx-ssr/src/app/logos.tsx +19 -0
  164. package/templates/ts-jsx-ssr/src/app/main.tsx +26 -0
  165. package/templates/ts-jsx-ssr/src/assets/typescript.svg +1 -0
  166. package/templates/ts-jsx-ssr/src/entry-client.ts +5 -0
  167. package/templates/ts-jsx-ssr/src/entry-server.ts +5 -0
  168. package/templates/{template-ts-ssr → ts-jsx-ssr}/tsconfig.json +7 -4
  169. package/templates/ts-jsx-ssr/vite.config.ts +13 -0
  170. package/templates/ts-plain-cli/index.html +13 -0
  171. package/templates/ts-plain-cli/package.json +21 -0
  172. package/templates/ts-plain-cli/src/app/counter.ts +13 -0
  173. package/templates/ts-plain-cli/src/app/logos.ts +30 -0
  174. package/templates/ts-plain-cli/src/app/main.ts +27 -0
  175. package/templates/ts-plain-cli/src/assets/typescript.svg +1 -0
  176. package/templates/ts-plain-cli/src/run.ts +5 -0
  177. package/templates/ts-plain-cli/src/types/hyperapp-h.d.ts +37 -0
  178. package/templates/ts-plain-cli/tsconfig.json +27 -0
  179. package/templates/ts-plain-cli/vite.config.ts +12 -0
  180. package/templates/ts-plain-ssr/index.html +13 -0
  181. package/templates/ts-plain-ssr/package.json +30 -0
  182. package/templates/ts-plain-ssr/server.ts +63 -0
  183. package/templates/ts-plain-ssr/src/app/counter.ts +13 -0
  184. package/templates/ts-plain-ssr/src/app/logos.ts +30 -0
  185. package/templates/ts-plain-ssr/src/app/main.ts +27 -0
  186. package/templates/ts-plain-ssr/src/assets/typescript.svg +1 -0
  187. package/templates/ts-plain-ssr/src/entry-client.ts +5 -0
  188. package/templates/ts-plain-ssr/src/entry-server.ts +5 -0
  189. package/templates/ts-plain-ssr/src/types/hyperapp-h.d.ts +37 -0
  190. package/templates/ts-plain-ssr/tsconfig.json +27 -0
  191. package/templates/ts-plain-ssr/vite.config.ts +13 -0
  192. package/index.js +0 -154
  193. package/templates/template/public/vite.svg +0 -1
  194. package/templates/template/src/hyperapp.svg +0 -4
  195. package/templates/template/src/style.css +0 -97
  196. package/templates/template/vite.config.js +0 -6
  197. package/templates/template-ssr/_gitignore +0 -24
  198. package/templates/template-ssr/src/entry-server.js +0 -5
  199. package/templates/template-ssr/src/style.css +0 -97
  200. package/templates/template-ssr/vite.config.js +0 -6
  201. package/templates/template-ts/_gitignore +0 -24
  202. package/templates/template-ts/public/vite.svg +0 -1
  203. package/templates/template-ts/src/counter.tsx +0 -14
  204. package/templates/template-ts/src/hyperapp.svg +0 -4
  205. package/templates/template-ts/src/main.tsx +0 -43
  206. package/templates/template-ts/src/vite-env.d.ts +0 -2
  207. package/templates/template-ts/vite.config.ts +0 -6
  208. package/templates/template-ts-ssr/_gitignore +0 -24
  209. package/templates/template-ts-ssr/public/vite.svg +0 -1
  210. package/templates/template-ts-ssr/src/counter.tsx +0 -14
  211. package/templates/template-ts-ssr/src/entry-server.ts +0 -5
  212. package/templates/template-ts-ssr/src/main.tsx +0 -43
  213. package/templates/template-ts-ssr/src/style.css +0 -97
  214. package/templates/template-ts-ssr/src/vite-env.d.ts +0 -2
  215. package/templates/template-ts-ssr/vite.config.ts +0 -6
  216. /package/templates/{template-ssr/src/hyperapp.svg → common/public/favicon.svg} +0 -0
  217. /package/templates/{template-ts-ssr/src → common/src/assets}/hyperapp.svg +0 -0
  218. /package/templates/{template-ssr/public → common/src/assets}/vite.svg +0 -0
  219. /package/templates/{template-ssr/src → js-jsx-cli/src/app}/counter.jsx +0 -0
  220. /package/templates/{template/src → js-jsx-ssr/src/app}/counter.jsx +0 -0
  221. /package/templates/{template-ts-ssr/src → ts-html-cli/src/assets}/typescript.svg +0 -0
  222. /package/templates/{template-ts/src → ts-html-ssr/src/assets}/typescript.svg +0 -0
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "__PROJECTNAME__",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "node server.ts",
8
+ "build:client": "vite build --outDir dist/client",
9
+ "build:server": "vite build --outDir dist/server --ssr src/entry-server.ts",
10
+ "build": "tsc && npm run build:client && npm run build:server",
11
+ "preview": "NODE_ENV=production node server.ts"
12
+ },
13
+ "engines": {
14
+ "node": ">=22.18.0"
15
+ },
16
+ "devDependencies": {
17
+ "@types/compression": "^1.8.1",
18
+ "@types/express": "^4.17.25",
19
+ "@types/node": "^22.20.5",
20
+ "typescript": "^7.0.2",
21
+ "vite": "^8.3.4"
22
+ },
23
+ "dependencies": {
24
+ "compression": "^1.7.4",
25
+ "express": "^4.19.2",
26
+ "hyperapp": "^2.0.22",
27
+ "sirv": "^2.0.4",
28
+ "vite-plugin-hyperapp": "^2.0.4"
29
+ }
30
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ ---------------------------------
3
+ Cribbed to large extent from template-ssr-solid/server.js
4
+ ---------------------------------
5
+ */
6
+ import fs from "node:fs/promises"
7
+ import express from "express"
8
+ import type { ViteDevServer } from "vite"
9
+
10
+ const isProduction = process.env.NODE_ENV === "production"
11
+ const port = process.env.PORT || 5173
12
+ const base = process.env.BASE || "/"
13
+
14
+ async function createServer() {
15
+ const app = express()
16
+
17
+ let vite: ViteDevServer | undefined
18
+ if (!isProduction) {
19
+ const { createServer } = await import("vite")
20
+ vite = await createServer({
21
+ server: { middlewareMode: true },
22
+ appType: "custom",
23
+ })
24
+ app.use(vite.middlewares)
25
+ } else {
26
+ const compression = (await import("compression")).default
27
+ const sirv = (await import("sirv")).default
28
+ app.use(compression())
29
+ app.use(base, sirv("./dist/client", { extensions: [] }))
30
+ }
31
+
32
+ app.use("*", async (req, res, next) => {
33
+ const url = req.originalUrl
34
+ if (!url.startsWith(base)) return next()
35
+ try {
36
+ let template
37
+ let render: () => string
38
+ if (!isProduction) {
39
+ if (!vite) throw new Error("Vite dev server is not initialized")
40
+ // Always read fresh template in development
41
+ template = await fs.readFile("./index.html", "utf-8")
42
+ template = await vite.transformIndexHtml(url, template)
43
+ render = (await vite.ssrLoadModule("/src/entry-server.ts")).render
44
+ } else {
45
+ template = await fs.readFile("./dist/client/index.html", "utf-8")
46
+ const serverEntry = "./dist/server/entry-server.js"
47
+ render = (await import(serverEntry)).render
48
+ }
49
+ const html = template.replace(`<!--ssr-outlet-->`, () => render())
50
+ res.status(200).set({ "Content-Type": "text/html" }).end(html)
51
+ } catch (e) {
52
+ if (e instanceof Error) vite?.ssrFixStacktrace(e)
53
+ console.error(e)
54
+ res.status(500).end()
55
+ }
56
+ })
57
+
58
+ app.listen(port, () => {
59
+ console.log(`Server started at http://localhost:${port}`)
60
+ })
61
+ }
62
+
63
+ createServer()
@@ -0,0 +1,13 @@
1
+ import { h, text, type Action } from "hyperapp"
2
+
3
+ type CounterProps<S> = {
4
+ clicks: number
5
+ onclick: Action<S>
6
+ }
7
+
8
+ const Counter = <S>({ clicks, onclick }: CounterProps<S>) =>
9
+ h("div", { class: "card" }, [
10
+ h("button", { onclick }, text("Clicks: " + clicks)),
11
+ ])
12
+
13
+ export default Counter
@@ -0,0 +1,30 @@
1
+ import { h } from "hyperapp"
2
+ import viteLogo from "@/assets/vite.svg"
3
+ import typescriptLogo from "@/assets/typescript.svg"
4
+ import hyperappLogo from "@/assets/hyperapp.svg"
5
+
6
+ const Logos = () => [
7
+ h("a", { href: "https://vitejs.dev" }, [
8
+ h("img", {
9
+ src: viteLogo,
10
+ class: "logo",
11
+ alt: "Vite logo",
12
+ }),
13
+ ]),
14
+ h("a", { href: "https://github.com/jorgebucaran/hyperapp" }, [
15
+ h("img", {
16
+ src: hyperappLogo,
17
+ class: "logo",
18
+ alt: "Hyperapp logo",
19
+ }),
20
+ ]),
21
+ h("a", { href: "https://www.typescriptlang.org/" }, [
22
+ h("img", {
23
+ src: typescriptLogo,
24
+ class: "logo",
25
+ alt: "TypeScript logo",
26
+ }),
27
+ ]),
28
+ ]
29
+
30
+ export default Logos
@@ -0,0 +1,27 @@
1
+ import "./style.css"
2
+ import { h, text, type Action } from "hyperapp"
3
+ import Counter from "./counter"
4
+ import Logos from "./logos"
5
+
6
+ type State = { counter: number }
7
+
8
+ export const init: Action<State> = () => ({
9
+ counter: 0,
10
+ })
11
+
12
+ const HandleClick: Action<State> = state => ({
13
+ ...state,
14
+ counter: state.counter + 1,
15
+ })
16
+
17
+ export const view = (state: State) =>
18
+ h("main", { id: "app" }, [
19
+ h("h1", {}, text("Vite (SSR) + Hyperapp + TypeScript")),
20
+ ...Logos(),
21
+ Counter({ clicks: state.counter, onclick: HandleClick }),
22
+ h(
23
+ "p",
24
+ { class: "read-the-docs" },
25
+ text("Click on the Vite, Hyperapp & TypeScript logos to learn more"),
26
+ ),
27
+ ])
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#007ACC" d="M0 128v128h256V0H0z"></path><path fill="#FFF" d="m56.612 128.85l-.081 10.483h33.32v94.68h23.568v-94.68h33.321v-10.28c0-5.69-.122-10.444-.284-10.566c-.122-.162-20.4-.244-44.983-.203l-44.74.122l-.121 10.443Zm149.955-10.742c6.501 1.625 11.459 4.51 16.01 9.224c2.357 2.52 5.851 7.111 6.136 8.208c.08.325-11.053 7.802-17.798 11.988c-.244.162-1.22-.894-2.317-2.52c-3.291-4.795-6.745-6.867-12.028-7.233c-7.76-.528-12.759 3.535-12.718 10.321c0 1.992.284 3.17 1.097 4.795c1.707 3.536 4.876 5.649 14.832 9.956c18.326 7.883 26.168 13.084 31.045 20.48c5.445 8.249 6.664 21.415 2.966 31.208c-4.063 10.646-14.14 17.879-28.323 20.276c-4.388.772-14.79.65-19.504-.203c-10.28-1.828-20.033-6.908-26.047-13.572c-2.357-2.6-6.949-9.387-6.664-9.874c.122-.163 1.178-.813 2.356-1.504c1.138-.65 5.446-3.129 9.509-5.485l7.355-4.267l1.544 2.276c2.154 3.29 6.867 7.801 9.712 9.305c8.167 4.307 19.383 3.698 24.909-1.26c2.357-2.153 3.332-4.388 3.332-7.68c0-2.966-.366-4.266-1.91-6.501c-1.99-2.845-6.054-5.242-17.595-10.24c-13.206-5.69-18.895-9.224-24.096-14.832c-3.007-3.25-5.852-8.452-7.03-12.8c-.975-3.617-1.22-12.678-.447-16.335c2.723-12.76 12.353-21.659 26.25-24.3c4.51-.853 14.994-.528 19.424.569Z"></path></svg>
@@ -0,0 +1,5 @@
1
+ import { app } from "hyperapp"
2
+ import { init, view } from "./app/main"
3
+ const node = document.querySelector("#app")
4
+ if (!node) throw new Error("mountpoint not found")
5
+ app({ init, view, node })
@@ -0,0 +1,5 @@
1
+ import { init, view } from "./app/main"
2
+ import { renderToString } from "vite-plugin-hyperapp/ssr"
3
+ export function render() {
4
+ return renderToString({ init, view })
5
+ }
@@ -0,0 +1,37 @@
1
+ // Action-free nodes can be used by an app with any state type.
2
+ type PassiveProps = import("hyperapp").Props<any> & {
3
+ [K in keyof import("hyperapp").EventActions<any>]?: never
4
+ }
5
+
6
+ type PassiveChild = boolean | null | undefined | import("hyperapp").TextVNode | PassiveVNode
7
+ type PassiveChildren = PassiveChild | readonly PassiveChild[]
8
+
9
+ type PassiveVNode = Omit<
10
+ import("hyperapp").ElementVNode<any>,
11
+ "props" | "children" | "events" | "tag" | "memo"
12
+ > & {
13
+ readonly props: PassiveProps
14
+ readonly children: readonly PassiveChild[]
15
+ readonly tag: string
16
+ events?: never
17
+ memo?: never
18
+ }
19
+
20
+ type HyperappChildren<S> =
21
+ | import("hyperapp").MaybeVNode<S>
22
+ | PassiveChild
23
+ | readonly (import("hyperapp").MaybeVNode<S> | PassiveChild)[]
24
+
25
+ declare module "hyperapp" {
26
+ function h<T extends string>(
27
+ tag: NonEmptyString<T>,
28
+ props: PassiveProps,
29
+ children?: PassiveChildren
30
+ ): PassiveVNode
31
+
32
+ function h<S, C = unknown, T extends string = string>(
33
+ tag: NonEmptyString<T>,
34
+ props: CustomPayloads<S, C> & Props<S>,
35
+ children?: HyperappChildren<S>
36
+ ): ElementVNode<S>
37
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "types": ["vite/client", "node"],
8
+ "skipLibCheck": true,
9
+
10
+ /* Bundler mode */
11
+ "moduleResolution": "bundler",
12
+ "paths": {
13
+ "@/*": ["./src/*"]
14
+ },
15
+ "allowImportingTsExtensions": true,
16
+ "resolveJsonModule": true,
17
+ "isolatedModules": true,
18
+ "noEmit": true,
19
+
20
+ /* Linting */
21
+ "strict": true,
22
+ "noUnusedLocals": true,
23
+ "noUnusedParameters": true,
24
+ "noFallthroughCasesInSwitch": true
25
+ },
26
+ "include": ["src", "server.ts"]
27
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from "vite"
2
+ import hyperapp from "vite-plugin-hyperapp"
3
+ import { fileURLToPath } from "node:url"
4
+
5
+ export default defineConfig({
6
+ base: process.env.BASE || "/",
7
+ plugins: [hyperapp()],
8
+ resolve: {
9
+ alias: {
10
+ "@": fileURLToPath(new URL("./src", import.meta.url)),
11
+ },
12
+ },
13
+ })
package/index.js DELETED
@@ -1,154 +0,0 @@
1
- #!/usr/bin/env node
2
- import minimist from "minimist"
3
- import prompts from "prompts"
4
- import fs from "node:fs"
5
- import path from "node:path"
6
- import { fileURLToPath } from "node:url"
7
-
8
- const args = minimist(process.argv.slice(2))
9
-
10
- if (args["h"] || args["help"]) {
11
- process.stdout.write(`
12
- Usage: npm create vite-hyperapp -- [TARGET_DIR] [OPTIONS]
13
-
14
- Options:
15
- -t, --typescript Use typescript
16
- -s, --ssr Use server-side rendering
17
- -n, --no-prompt Just do it, no questions asked
18
- -h, --help Show this message
19
-
20
- If no target dir is specified, the project name will be used.
21
- If --no-prompt option is used, project name will be target dir
22
- Default project-name/target-dir is 'hyperapp-project'
23
-
24
- `)
25
- process.exit(0)
26
- }
27
-
28
- async function collectOptions() {
29
- const flaggedTypescript = !!(args["t"] || args["typescript"])
30
- const flaggedSSR = !!(args["s"] || args["ssr"])
31
- const givenTargetDir = args._[0]
32
- const targetDirOrDefault = givenTargetDir || "hyperapp-project"
33
- if (args["n"] || args["no-prompt"]) {
34
- return {
35
- targetDir: targetDirOrDefault,
36
- projectName: targetDirOrDefault,
37
- useTypescript: flaggedTypescript,
38
- useSSR: flaggedSSR,
39
- }
40
- }
41
- const promptResponse = await prompts([
42
- {
43
- type: "text",
44
- name: "name",
45
- initial: targetDirOrDefault,
46
- message: "Name your project:",
47
- },
48
- !flaggedTypescript && {
49
- type: "confirm",
50
- name: "typescript",
51
- message: "Use Typescript?",
52
- initial: true,
53
- },
54
- !flaggedSSR && {
55
- type: "confirm",
56
- name: "ssr",
57
- message: "Use server-side rendering?",
58
- initial: false,
59
- },
60
- ])
61
- return {
62
- targetDir: givenTargetDir || promptResponse.name,
63
- projectName: promptResponse.name,
64
- useTypescript: promptResponse.typescript,
65
- useSSR: promptResponse.ssr,
66
- }
67
- }
68
-
69
- function copyDir(source, target) {
70
- if (fs.existsSync(target)) {
71
- process.stderr.write(`\n${target} already exists. Aborting!\n`)
72
- process.exit(1)
73
- }
74
- fs.mkdirSync(target, { recursive: true })
75
-
76
- const items = fs.readdirSync(source)
77
- items.forEach(item => {
78
- const sourceItem = path.join(source, item)
79
- const targetItem = path.join(target, item)
80
- const stats = fs.statSync(sourceItem)
81
-
82
- if (stats.isDirectory()) {
83
- copyDir(sourceItem, targetItem)
84
- } else {
85
- fs.copyFileSync(sourceItem, targetItem)
86
- }
87
- })
88
- }
89
-
90
- function isValidPackageName(projectName) {
91
- return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(
92
- projectName,
93
- )
94
- }
95
-
96
- function setPackageName(projectDir, packageName) {
97
- const packageJsonPath = path.join(projectDir, "package.json")
98
- const info = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"))
99
- info.name = packageName
100
- fs.writeFileSync(packageJsonPath, JSON.stringify(info, null, 2))
101
- }
102
-
103
- function fixGitignoreFilename(projectDir) {
104
- const currentName = path.join(projectDir, "_gitignore")
105
- const renameTo = path.join(projectDir, ".gitignore")
106
- fs.renameSync(currentName, renameTo)
107
- }
108
-
109
- async function main() {
110
- const setup = await collectOptions()
111
-
112
- if (!isValidPackageName(setup.projectName)) {
113
- process.stderr.write(
114
- `\n${setup.projectName} is not a valid package.json name\n`,
115
- )
116
- process.exit(1)
117
- }
118
-
119
- if (!isValidPackageName(setup.targetDir)) {
120
- process.stderr.write(`\n${setup.targetDir} is not a valid folder name\n`)
121
- process.exit(1)
122
- }
123
-
124
- const template = setup.useTypescript
125
- ? setup.useSSR
126
- ? "template-ts-ssr"
127
- : "template-ts"
128
- : setup.useSSR
129
- ? "template-ssr"
130
- : "template"
131
-
132
- const sourceDir = path.resolve(
133
- fileURLToPath(import.meta.url),
134
- "../templates/",
135
- template,
136
- )
137
- const targetDir = path.resolve(process.cwd(), "./" + setup.targetDir)
138
-
139
- process.stdout.write("Scaffolding project ...")
140
- copyDir(sourceDir, targetDir)
141
- setPackageName(targetDir, setup.projectName)
142
- fixGitignoreFilename(targetDir)
143
- process.stdout.write(`
144
- ...Done.
145
-
146
- To get started:
147
-
148
- > cd ${setup.targetDir}
149
- > npm install
150
- > npm run dev
151
- `)
152
- }
153
-
154
- main()
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -1,4 +0,0 @@
1
- <svg viewBox="-20 -20 230 160" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
2
- <rect x="-20" y="-20" width="100%" height="100%" fill="#0080FF" rx="15"/>
3
- <path d="M69.3175129,49.6122454 L109.331858,49.6122454 L118.942605,69.3176912 L69.3175129,69.3176912 L69.3175129,118.931378 L49.6154815,118.931378 L49.6154815,69.3176912 L0,69.3176912 L0,49.6122454 L49.6154815,49.6122454 L49.6154815,0 L69.3175129,0 L69.3175129,49.6122454 Z M192.738726,118.931378 L169.523967,118.931378 L111.518303,0 L134.733062,0 L192.738726,118.931378 Z" fill="#FFFFFF" fill-rule="nonzero"></path>
4
- </svg>
@@ -1,97 +0,0 @@
1
- :root {
2
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
4
- font-weight: 400;
5
-
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
9
-
10
- font-synthesis: none;
11
- text-rendering: optimizeLegibility;
12
- -webkit-font-smoothing: antialiased;
13
- -moz-osx-font-smoothing: grayscale;
14
- -webkit-text-size-adjust: 100%;
15
- }
16
-
17
- a {
18
- font-weight: 500;
19
- color: #646cff;
20
- text-decoration: inherit;
21
- }
22
- a:hover {
23
- color: #535bf2;
24
- }
25
-
26
- body {
27
- margin: 0;
28
- display: flex;
29
- place-items: center;
30
- min-width: 320px;
31
- min-height: 100vh;
32
- }
33
-
34
- h1 {
35
- font-size: 3.2em;
36
- line-height: 1.1;
37
- }
38
-
39
- #app {
40
- max-width: 1280px;
41
- margin: 0 auto;
42
- padding: 2rem;
43
- text-align: center;
44
- }
45
-
46
- .logo {
47
- height: 6em;
48
- padding: 1.5em;
49
- will-change: filter;
50
- transition: filter 300ms;
51
- }
52
- .logo:hover {
53
- filter: drop-shadow(0 0 2em #646cffaa);
54
- }
55
- .logo.vanilla:hover {
56
- filter: drop-shadow(0 0 2em #3178c6aa);
57
- }
58
-
59
- .card {
60
- padding: 2em;
61
- }
62
-
63
- .read-the-docs {
64
- color: #888;
65
- }
66
-
67
- button {
68
- border-radius: 8px;
69
- border: 1px solid transparent;
70
- padding: 0.6em 1.2em;
71
- font-size: 1em;
72
- font-weight: 500;
73
- font-family: inherit;
74
- background-color: #1a1a1a;
75
- cursor: pointer;
76
- transition: border-color 0.25s;
77
- }
78
- button:hover {
79
- border-color: #646cff;
80
- }
81
- button:focus,
82
- button:focus-visible {
83
- outline: 4px auto -webkit-focus-ring-color;
84
- }
85
-
86
- @media (prefers-color-scheme: light) {
87
- :root {
88
- color: #213547;
89
- background-color: #ffffff;
90
- }
91
- a:hover {
92
- color: #747bff;
93
- }
94
- button {
95
- background-color: #f9f9f9;
96
- }
97
- }
@@ -1,6 +0,0 @@
1
- import { defineConfig } from "vite"
2
- import hyperapp from "vite-plugin-hyperapp"
3
-
4
- export default defineConfig({
5
- plugins: [hyperapp()],
6
- })
@@ -1,24 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- pnpm-debug.log*
8
- lerna-debug.log*
9
-
10
- node_modules
11
- dist
12
- dist-ssr
13
- *.local
14
-
15
- # Editor directories and files
16
- .vscode/*
17
- !.vscode/extensions.json
18
- .idea
19
- .DS_Store
20
- *.suo
21
- *.ntvs*
22
- *.njsproj
23
- *.sln
24
- *.sw?
@@ -1,5 +0,0 @@
1
- import { init, view } from "./main"
2
- import renderApp from "vite-plugin-hyperapp/ssr"
3
- export async function render() {
4
- return await renderApp({ init, view })
5
- }
@@ -1,97 +0,0 @@
1
- :root {
2
- font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
4
- font-weight: 400;
5
-
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
9
-
10
- font-synthesis: none;
11
- text-rendering: optimizeLegibility;
12
- -webkit-font-smoothing: antialiased;
13
- -moz-osx-font-smoothing: grayscale;
14
- -webkit-text-size-adjust: 100%;
15
- }
16
-
17
- a {
18
- font-weight: 500;
19
- color: #646cff;
20
- text-decoration: inherit;
21
- }
22
- a:hover {
23
- color: #535bf2;
24
- }
25
-
26
- body {
27
- margin: 0;
28
- display: flex;
29
- place-items: center;
30
- min-width: 320px;
31
- min-height: 100vh;
32
- }
33
-
34
- h1 {
35
- font-size: 3.2em;
36
- line-height: 1.1;
37
- }
38
-
39
- #app {
40
- max-width: 1280px;
41
- margin: 0 auto;
42
- padding: 2rem;
43
- text-align: center;
44
- }
45
-
46
- .logo {
47
- height: 6em;
48
- padding: 1.5em;
49
- will-change: filter;
50
- transition: filter 300ms;
51
- }
52
- .logo:hover {
53
- filter: drop-shadow(0 0 2em #646cffaa);
54
- }
55
- .logo.vanilla:hover {
56
- filter: drop-shadow(0 0 2em #3178c6aa);
57
- }
58
-
59
- .card {
60
- padding: 2em;
61
- }
62
-
63
- .read-the-docs {
64
- color: #888;
65
- }
66
-
67
- button {
68
- border-radius: 8px;
69
- border: 1px solid transparent;
70
- padding: 0.6em 1.2em;
71
- font-size: 1em;
72
- font-weight: 500;
73
- font-family: inherit;
74
- background-color: #1a1a1a;
75
- cursor: pointer;
76
- transition: border-color 0.25s;
77
- }
78
- button:hover {
79
- border-color: #646cff;
80
- }
81
- button:focus,
82
- button:focus-visible {
83
- outline: 4px auto -webkit-focus-ring-color;
84
- }
85
-
86
- @media (prefers-color-scheme: light) {
87
- :root {
88
- color: #213547;
89
- background-color: #ffffff;
90
- }
91
- a:hover {
92
- color: #747bff;
93
- }
94
- button {
95
- background-color: #f9f9f9;
96
- }
97
- }
@@ -1,6 +0,0 @@
1
- import { defineConfig } from "vite"
2
- import hyperapp from "vite-plugin-hyperapp"
3
-
4
- export default defineConfig({
5
- plugins: [hyperapp()],
6
- })