~repos /edge-city

#react#js#ssr

git clone https://pyrossh.dev/repos/edge-city.git

edge-city is a next level meta-framework for react that runs only on edge runtimes


ceccf1f1 Peter John

2 years ago
move to workspace
Files changed (32) hide show
  1. .gitignore +1 -172
  2. README.md +0 -15
  3. bun.lockb +0 -0
  4. package-lock.json +0 -261
  5. package.json +4 -20
  6. packages/example/.gitignore +3 -0
  7. {components → packages/example/components}/Todo.jsx +0 -0
  8. {containers → packages/example/containers}/TodoList.jsx +1 -1
  9. jsconfig.json → packages/example/jsconfig.json +0 -0
  10. packages/example/main.js +3 -0
  11. packages/example/package.json +12 -0
  12. {routes → packages/example/routes}/about/page.css +0 -0
  13. {routes → packages/example/routes}/about/page.jsx +0 -0
  14. {routes → packages/example/routes}/health/api.js +0 -0
  15. {routes → packages/example/routes}/index/page.css +0 -0
  16. {routes → packages/example/routes}/index/page.jsx +1 -1
  17. routes/todos/[id]/api.js → packages/example/routes/todos/[id]/server.js +3 -2
  18. {routes → packages/example/routes}/todos/api.js +1 -1
  19. packages/example/routes/todos/page.css +11 -0
  20. packages/example/routes/todos/page.jsx +16 -0
  21. {static → packages/example/static}/favicon.ico +0 -0
  22. {static → packages/example/static}/logo192.png +0 -0
  23. {static → packages/example/static}/logo512.png +0 -0
  24. {static → packages/example/static}/manifest.json +0 -0
  25. {static → packages/example/static}/robots.txt +0 -0
  26. packages/muffinjs/.gitignore +1 -0
  27. atom.js → packages/muffinjs/atom.js +0 -0
  28. packages/muffinjs/bin/muffin.js +5 -0
  29. index.js → packages/muffinjs/index.js +11 -9
  30. jsxPlugin.js → packages/muffinjs/jsxPlugin.js +0 -0
  31. packages/muffinjs/package.json +23 -0
  32. router.js → packages/muffinjs/router.js +3 -2
.gitignore CHANGED
@@ -1,172 +1 @@
1
- # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2
-
3
- # Logs
4
-
5
- logs
6
- _.log
7
- npm-debug.log_
8
- yarn-debug.log*
9
- yarn-error.log*
10
- lerna-debug.log*
11
- .pnpm-debug.log*
12
-
13
- # Diagnostic reports (https://nodejs.org/api/report.html)
14
-
15
- report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
16
-
17
- # Runtime data
18
-
19
- pids
20
- _.pid
21
- _.seed
22
- \*.pid.lock
23
-
24
- # Directory for instrumented libs generated by jscoverage/JSCover
25
-
26
- lib-cov
27
-
28
- # Coverage directory used by tools like istanbul
29
-
30
- coverage
31
- \*.lcov
32
-
33
- # nyc test coverage
34
-
35
- .nyc_output
36
-
37
- # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38
-
39
- .grunt
40
-
41
- # Bower dependency directory (https://bower.io/)
42
-
43
- bower_components
44
-
45
- # node-waf configuration
46
-
47
- .lock-wscript
48
-
49
- # Compiled binary addons (https://nodejs.org/api/addons.html)
50
-
51
- build/Release
52
-
53
- # Dependency directories
54
-
55
- node_modules/
1
+ node_modules
56
- jspm_packages/
57
-
58
- # Snowpack dependency directory (https://snowpack.dev/)
59
-
60
- web_modules/
61
-
62
- # TypeScript cache
63
-
64
- \*.tsbuildinfo
65
-
66
- # Optional npm cache directory
67
-
68
- .npm
69
-
70
- # Optional eslint cache
71
-
72
- .eslintcache
73
-
74
- # Optional stylelint cache
75
-
76
- .stylelintcache
77
-
78
- # Microbundle cache
79
-
80
- .rpt2_cache/
81
- .rts2_cache_cjs/
82
- .rts2_cache_es/
83
- .rts2_cache_umd/
84
-
85
- # Optional REPL history
86
-
87
- .node_repl_history
88
-
89
- # Output of 'npm pack'
90
-
91
- \*.tgz
92
-
93
- # Yarn Integrity file
94
-
95
- .yarn-integrity
96
-
97
- # dotenv environment variable files
98
-
99
- .env
100
- .env.development.local
101
- .env.test.local
102
- .env.production.local
103
- .env.local
104
-
105
- # parcel-bundler cache (https://parceljs.org/)
106
-
107
- .cache
108
- .parcel-cache
109
-
110
- # Next.js build output
111
-
112
- .next
113
- out
114
-
115
- # Nuxt.js build / generate output
116
-
117
- .nuxt
118
- dist
119
-
120
- # Gatsby files
121
-
122
- .cache/
123
-
124
- # Comment in the public line in if your project uses Gatsby and not Next.js
125
-
126
- # https://nextjs.org/blog/next-9-1#public-directory-support
127
-
128
- # public
129
-
130
- # vuepress build output
131
-
132
- .vuepress/dist
133
-
134
- # vuepress v2.x temp and cache directory
135
-
136
- .temp
137
- .cache
138
-
139
- # Docusaurus cache and generated files
140
-
141
- .docusaurus
142
-
143
- # Serverless directories
144
-
145
- .serverless/
146
-
147
- # FuseBox cache
148
-
149
- .fusebox/
150
-
151
- # DynamoDB Local files
152
-
153
- .dynamodb/
154
-
155
- # TernJS port file
156
-
157
- .tern-port
158
-
159
- # Stores VSCode versions used for testing VSCode extensions
160
-
161
- .vscode-test
162
-
163
- # yarn v2
164
-
165
- .yarn/cache
166
- .yarn/unplugged
167
- .yarn/build-state.yml
168
- .yarn/install-state.gz
169
- .pnp.\*
170
- .cache
171
- dist
172
- .vercel
README.md DELETED
@@ -1,15 +0,0 @@
1
- # quickstart
2
-
3
- To install dependencies:
4
-
5
- ```bash
6
- bun install
7
- ```
8
-
9
- To run:
10
-
11
- ```bash
12
- bun run index.js
13
- ```
14
-
15
- This project was created using `bun init` in bun v0.5.7. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
bun.lockb CHANGED
Binary file
package-lock.json DELETED
@@ -1,261 +0,0 @@
1
- {
2
- "name": "quickstart",
3
- "lockfileVersion": 2,
4
- "requires": true,
5
- "packages": {
6
- "": {
7
- "name": "quickstart",
8
- "dependencies": {
9
- "postcss": "^8.4.21",
10
- "postcss-js": "^4.0.1",
11
- "react": "18.2.0",
12
- "react-dom": "^18.2.0",
13
- "swr": "^2.1.0",
14
- "zod": "^3.21.0"
15
- },
16
- "devDependencies": {
17
- "bun-types": "^0.5.0"
18
- }
19
- },
20
- "node_modules/bun-types": {
21
- "version": "0.5.7",
22
- "dev": true
23
- },
24
- "node_modules/camelcase-css": {
25
- "version": "2.0.1",
26
- "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz",
27
- "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==",
28
- "engines": {
29
- "node": ">= 6"
30
- }
31
- },
32
- "node_modules/js-tokens": {
33
- "version": "4.0.0",
34
- "license": "MIT"
35
- },
36
- "node_modules/loose-envify": {
37
- "version": "1.4.0",
38
- "license": "MIT",
39
- "dependencies": {
40
- "js-tokens": "^3.0.0 || ^4.0.0"
41
- },
42
- "bin": {
43
- "loose-envify": "cli.js"
44
- }
45
- },
46
- "node_modules/nanoid": {
47
- "version": "3.3.4",
48
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
49
- "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
50
- "bin": {
51
- "nanoid": "bin/nanoid.cjs"
52
- },
53
- "engines": {
54
- "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
55
- }
56
- },
57
- "node_modules/picocolors": {
58
- "version": "1.0.0",
59
- "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
60
- "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
61
- },
62
- "node_modules/postcss": {
63
- "version": "8.4.21",
64
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz",
65
- "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==",
66
- "funding": [
67
- {
68
- "type": "opencollective",
69
- "url": "https://opencollective.com/postcss/"
70
- },
71
- {
72
- "type": "tidelift",
73
- "url": "https://tidelift.com/funding/github/npm/postcss"
74
- }
75
- ],
76
- "dependencies": {
77
- "nanoid": "^3.3.4",
78
- "picocolors": "^1.0.0",
79
- "source-map-js": "^1.0.2"
80
- },
81
- "engines": {
82
- "node": "^10 || ^12 || >=14"
83
- }
84
- },
85
- "node_modules/postcss-js": {
86
- "version": "4.0.1",
87
- "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz",
88
- "integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==",
89
- "dependencies": {
90
- "camelcase-css": "^2.0.1"
91
- },
92
- "engines": {
93
- "node": "^12 || ^14 || >= 16"
94
- },
95
- "funding": {
96
- "type": "opencollective",
97
- "url": "https://opencollective.com/postcss/"
98
- },
99
- "peerDependencies": {
100
- "postcss": "^8.4.21"
101
- }
102
- },
103
- "node_modules/react": {
104
- "version": "18.2.0",
105
- "license": "MIT",
106
- "dependencies": {
107
- "loose-envify": "^1.1.0"
108
- },
109
- "engines": {
110
- "node": ">=0.10.0"
111
- }
112
- },
113
- "node_modules/react-dom": {
114
- "version": "18.2.0",
115
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
116
- "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
117
- "dependencies": {
118
- "loose-envify": "^1.1.0",
119
- "scheduler": "^0.23.0"
120
- },
121
- "peerDependencies": {
122
- "react": "^18.2.0"
123
- }
124
- },
125
- "node_modules/scheduler": {
126
- "version": "0.23.0",
127
- "license": "MIT",
128
- "dependencies": {
129
- "loose-envify": "^1.1.0"
130
- }
131
- },
132
- "node_modules/source-map-js": {
133
- "version": "1.0.2",
134
- "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
135
- "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
136
- "engines": {
137
- "node": ">=0.10.0"
138
- }
139
- },
140
- "node_modules/swr": {
141
- "version": "2.1.0",
142
- "resolved": "https://registry.npmjs.org/swr/-/swr-2.1.0.tgz",
143
- "integrity": "sha512-4hYl5p3/KalQ1MORealM79g/DtLohmud6yyfXw5l4wjtFksYUnocRFudvyaoUtgj3FrVNK9lS25Av9dsZYvz0g==",
144
- "dependencies": {
145
- "use-sync-external-store": "^1.2.0"
146
- },
147
- "engines": {
148
- "pnpm": "7"
149
- },
150
- "peerDependencies": {
151
- "react": "^16.11.0 || ^17.0.0 || ^18.0.0"
152
- }
153
- },
154
- "node_modules/use-sync-external-store": {
155
- "version": "1.2.0",
156
- "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
157
- "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==",
158
- "peerDependencies": {
159
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
160
- }
161
- },
162
- "node_modules/zod": {
163
- "version": "3.21.0",
164
- "license": "MIT",
165
- "funding": {
166
- "url": "https://github.com/sponsors/colinhacks"
167
- }
168
- }
169
- },
170
- "dependencies": {
171
- "bun-types": {
172
- "version": "0.5.7",
173
- "dev": true
174
- },
175
- "camelcase-css": {
176
- "version": "2.0.1",
177
- "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz",
178
- "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA=="
179
- },
180
- "js-tokens": {
181
- "version": "4.0.0"
182
- },
183
- "loose-envify": {
184
- "version": "1.4.0",
185
- "requires": {
186
- "js-tokens": "^3.0.0 || ^4.0.0"
187
- }
188
- },
189
- "nanoid": {
190
- "version": "3.3.4",
191
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
192
- "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw=="
193
- },
194
- "picocolors": {
195
- "version": "1.0.0",
196
- "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
197
- "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
198
- },
199
- "postcss": {
200
- "version": "8.4.21",
201
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz",
202
- "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==",
203
- "requires": {
204
- "nanoid": "^3.3.4",
205
- "picocolors": "^1.0.0",
206
- "source-map-js": "^1.0.2"
207
- }
208
- },
209
- "postcss-js": {
210
- "version": "4.0.1",
211
- "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz",
212
- "integrity": "sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==",
213
- "requires": {
214
- "camelcase-css": "^2.0.1"
215
- }
216
- },
217
- "react": {
218
- "version": "18.2.0",
219
- "requires": {
220
- "loose-envify": "^1.1.0"
221
- }
222
- },
223
- "react-dom": {
224
- "version": "18.2.0",
225
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
226
- "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
227
- "requires": {
228
- "loose-envify": "^1.1.0",
229
- "scheduler": "^0.23.0"
230
- }
231
- },
232
- "scheduler": {
233
- "version": "0.23.0",
234
- "requires": {
235
- "loose-envify": "^1.1.0"
236
- }
237
- },
238
- "source-map-js": {
239
- "version": "1.0.2",
240
- "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
241
- "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw=="
242
- },
243
- "swr": {
244
- "version": "2.1.0",
245
- "resolved": "https://registry.npmjs.org/swr/-/swr-2.1.0.tgz",
246
- "integrity": "sha512-4hYl5p3/KalQ1MORealM79g/DtLohmud6yyfXw5l4wjtFksYUnocRFudvyaoUtgj3FrVNK9lS25Av9dsZYvz0g==",
247
- "requires": {
248
- "use-sync-external-store": "^1.2.0"
249
- }
250
- },
251
- "use-sync-external-store": {
252
- "version": "1.2.0",
253
- "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz",
254
- "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==",
255
- "requires": {}
256
- },
257
- "zod": {
258
- "version": "3.21.0"
259
- }
260
- }
261
- }
package.json CHANGED
@@ -1,24 +1,8 @@
1
1
  {
2
- "name": "quickstart",
2
+ "name": "my-project",
3
- "module": "index.js",
4
- "type": "module",
3
+ "version": "1.0.0",
4
+ "workspaces": ["packages/example", "packages/muffinjs"],
5
5
  "scripts": {
6
- "dev": "bun --hot index.js",
7
- "start": "bun index.js"
6
+ "start": "muffin"
8
- },
9
- "devDependencies": {
10
- "bun-types": "^0.5.0"
11
- },
12
- "dependencies": {
13
- "@blueprintjs/core": "^4.17.6",
14
- "autoprefixer": "^10.4.14",
15
- "postcss": "^8.4.21",
16
- "postcss-custom-media": "^9.1.2",
17
- "postcss-nesting": "^11.2.1",
18
- "postcss-normalize": "^10.0.1",
19
- "react": "18.2.0",
20
- "react-dom": "^18.2.0",
21
- "react-streaming": "^0.3.5",
22
- "zod": "^3.21.0"
23
7
  }
24
8
  }
packages/example/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .cache
2
+ .dist
3
+ node_modules
{components → packages/example/components}/Todo.jsx RENAMED
File without changes
{containers → packages/example/containers}/TodoList.jsx RENAMED
@@ -1,4 +1,4 @@
1
- import Todo from "@/components/Todo.jsx";
1
+ import Todo from "@/example/components/Todo.jsx";
2
2
 
3
3
  const todos = [
4
4
  { id: '1', text: "123" },
jsconfig.json → packages/example/jsconfig.json RENAMED
File without changes
packages/example/main.js ADDED
@@ -0,0 +1,3 @@
1
+ import server from "muffinjs/index.js";
2
+
3
+ export default server;
packages/example/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "quickstart",
3
+ "type": "module",
4
+ "scripts": {
5
+ "dev": "bun --hot main.js"
6
+ },
7
+ "dependencies": {
8
+ "muffinjs": "0.1.0",
9
+ "react": "18.2.0",
10
+ "react-dom": "^18.2.0"
11
+ }
12
+ }
{routes → packages/example/routes}/about/page.css RENAMED
File without changes
{routes → packages/example/routes}/about/page.jsx RENAMED
File without changes
{routes → packages/example/routes}/health/api.js RENAMED
File without changes
{routes → packages/example/routes}/index/page.css RENAMED
File without changes
{routes → packages/example/routes}/index/page.jsx RENAMED
@@ -1,5 +1,5 @@
1
1
  import { useState } from "react";
2
- import { useRouter } from "@/router.js";
2
+ import { useRouter } from "muffinjs/router.js";
3
3
  import TodoList from "@/containers/TodoList.jsx";
4
4
  // import "./index.css";
5
5
 
routes/todos/[id]/api.js → packages/example/routes/todos/[id]/server.js RENAMED
@@ -1,4 +1,4 @@
1
- import tigrisDB from "./db.js.js";
1
+ import tigrisDB from "./db.js.js.js";
2
2
 
3
3
  export const todosCollection = tigrisDB.getCollection("todoItems");
4
4
 
@@ -17,8 +17,9 @@ export const onGet = async (req) => {
17
17
  }
18
18
 
19
19
  export const onPut = async (req) => {
20
+ const item = await req.body();
20
21
  const updated = await todosCollection.insertOrReplaceOne(item);
21
- const data = JSON.stringify(updated);
22
+ const data = JSON.stringify(updated);``
22
23
  return new Response(data, {
23
24
  headers: {
24
25
  "Content-Type": "application/json",
{routes → packages/example/routes}/todos/api.js RENAMED
@@ -1,4 +1,4 @@
1
- import tigrisDB from "./db.js.js";
1
+ import tigrisDB from "./db.js.js.js";
2
2
 
3
3
  export const todosCollection = tigrisDB.getCollection("todoItems");
4
4
 
packages/example/routes/todos/page.css ADDED
@@ -0,0 +1,11 @@
1
+ .home-page {
2
+ padding: 10px;
3
+ background-color: turquoise;
4
+
5
+ & .count {
6
+ color: black;
7
+ padding: 40px;
8
+ font-size: 30px;
9
+ font-weight: 600;
10
+ }
11
+ }
packages/example/routes/todos/page.jsx ADDED
@@ -0,0 +1,16 @@
1
+ import { Suspense } from "react";
2
+ import { useRouter } from "muffinjs/router.js";
3
+ import TodoList from "@/containers/TodoList.jsx";
4
+ // import "./index.css";
5
+
6
+ export default () => {
7
+ const router = useRouter();
8
+ const { data: todos, isRevalidating } = usePromise("/todos");
9
+ return (
10
+ <div className="todos-page">
11
+ <Suspense>
12
+ <TodoList todos={todos} />
13
+ </Suspense>
14
+ </div>
15
+ )
16
+ }
{static → packages/example/static}/favicon.ico RENAMED
File without changes
{static → packages/example/static}/logo192.png RENAMED
File without changes
{static → packages/example/static}/logo512.png RENAMED
File without changes
{static → packages/example/static}/manifest.json RENAMED
File without changes
{static → packages/example/static}/robots.txt RENAMED
File without changes
packages/muffinjs/.gitignore ADDED
@@ -0,0 +1 @@
1
+ node_modules
atom.js → packages/muffinjs/atom.js RENAMED
File without changes
packages/muffinjs/bin/muffin.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import server from "../index.js";
4
+
5
+ Bun.serve(server);
index.js → packages/muffinjs/index.js RENAMED
@@ -1,8 +1,10 @@
1
1
  import './jsxPlugin.js';
2
+ import React from 'react';
2
3
  import path from 'path';
3
4
  import { renderToReadableStream } from 'react-dom/server';
4
5
  import { routerAtom } from './router.js';
6
+
5
- import packageJson from "./package.json";
7
+ console.log("running in", process.cwd());
6
8
 
7
9
  const transpiler = new Bun.Transpiler({
8
10
  loader: "jsx",
@@ -15,11 +17,6 @@ const renderApi = async (route, req) => {
15
17
  console.log('routeImport', routeImport);
16
18
  }
17
19
 
18
- const deps = Object.keys(packageJson.dependencies).reduce((acc, dep) => {
19
- acc[dep] = `https://esm.sh/${dep}@${packageJson.dependencies[dep]}?dev`;
20
- return acc;
21
- }, {})
22
-
23
20
  const renderPage = async (filePath, url, params) => {
24
21
  const query = {};
25
22
  for (const key of url.searchParams.keys()) {
@@ -30,9 +27,14 @@ const renderPage = async (filePath, url, params) => {
30
27
  params: params,
31
28
  pathname: url.pathname,
32
29
  }
33
- console.log('filePath', filePath);
34
30
  routerAtom.update(() => initialRouteValue);
35
31
  const routeImport = await import(filePath);
32
+ const packageJson = await import(path.join(process.cwd(), "package.json"));
33
+ const dependencies = packageJson.default.dependencies;
34
+ const imports = Object.keys(dependencies).reduce((acc, dep) => {
35
+ acc[dep] = `https://esm.sh/${dep}@${dependencies[dep]}?dev`;
36
+ return acc;
37
+ }, {})
36
38
  const Page = routeImport.default;
37
39
  const stream = await renderToReadableStream(
38
40
  <html lang="en">
@@ -42,7 +44,7 @@ const renderPage = async (filePath, url, params) => {
42
44
  __html: JSON.stringify(
43
45
  {
44
46
  "imports": {
45
- ...deps,
47
+ ...imports,
46
48
  "react-dom/client": "https://esm.sh/react-dom@18.2.0/client?dev",
47
49
  "react/jsx-dev-runtime": "https://esm.sh/react@18.2.0/jsx-dev-runtime?dev",
48
50
  "@/atom.js": "/assets/js/src/atom.js",
@@ -126,7 +128,7 @@ export default {
126
128
  });
127
129
  }
128
130
  if (url.pathname.includes("/")) {
129
- return renderPage("./routes/index/page.jsx", url, {});
131
+ return renderPage(process.cwd() + "/routes/index/page.jsx", url, {});
130
132
  }
131
133
  return new Response(`Not Found`, {
132
134
  headers: { 'Content-Type': 'text/html' },
jsxPlugin.js → packages/muffinjs/jsxPlugin.js RENAMED
File without changes
packages/muffinjs/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "muffinjs",
3
+ "version": "0.1.0",
4
+ "module": "index.js",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "bun --hot index.js",
8
+ "start": "bun index.js"
9
+ },
10
+ "devDependencies": {
11
+ "bun-types": "^0.5.0"
12
+ },
13
+ "dependencies": {
14
+ "autoprefixer": "^10.4.14",
15
+ "postcss": "^8.4.21",
16
+ "postcss-custom-media": "^9.1.2",
17
+ "postcss-nesting": "^11.2.1",
18
+ "postcss-normalize": "^10.0.1"
19
+ },
20
+ "bin": {
21
+ "muffin": "./bin/muffin"
22
+ }
23
+ }
router.js → packages/muffinjs/router.js RENAMED
@@ -1,10 +1,11 @@
1
+ // import { signal, useSignal } from "@preact/signals-react";
1
- import { atom, useAtom } from "@/atom.js";
2
+ import { atom, useAtom } from "./atom.js";
2
3
 
3
4
  export const routerAtom = atom({
4
5
  pathname: "/",
5
6
  query: {},
6
7
  params: {},
7
- })
8
+ });
8
9
 
9
10
  export const useRouter = () => useAtom(routerAtom);
10
11