eclipsa 0.1.0 → 0.1.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 (68) hide show
  1. package/action-DstcBFEm.mjs +6188 -0
  2. package/action-DstcBFEm.mjs.map +1 -0
  3. package/client-D1zMr8hs.mjs +307 -0
  4. package/client-D1zMr8hs.mjs.map +1 -0
  5. package/component-DjUmyVqL.d.mts +8 -0
  6. package/core/client/mod.d.mts +3 -0
  7. package/core/client/mod.mjs +5 -0
  8. package/core/dev-client/mod.d.mts +33 -0
  9. package/core/dev-client/mod.mjs +82 -0
  10. package/core/dev-client/mod.mjs.map +1 -0
  11. package/core/internal.d.mts +2 -0
  12. package/core/internal.mjs +2 -0
  13. package/core/prod-client/mod.d.mts +19 -0
  14. package/core/prod-client/mod.mjs +44 -0
  15. package/core/prod-client/mod.mjs.map +1 -0
  16. package/internal-Dmvt_AGE.d.mts +674 -0
  17. package/jsx/jsx-dev-runtime.d.mts +17 -0
  18. package/jsx/jsx-dev-runtime.mjs +2 -0
  19. package/jsx/jsx-runtime.d.mts +2 -0
  20. package/jsx/jsx-runtime.mjs +1 -0
  21. package/jsx/mod.d.mts +7 -0
  22. package/jsx/mod.mjs +7 -0
  23. package/jsx/mod.mjs.map +1 -0
  24. package/jsx-dev-runtime-CY60yQJY.mjs +28 -0
  25. package/jsx-dev-runtime-CY60yQJY.mjs.map +1 -0
  26. package/jsx-runtime-QIK6ADiK.d.mts +1 -0
  27. package/loader-DDVVUXBr.mjs +2 -0
  28. package/mod-CaLAdQcH.d.mts +18 -0
  29. package/mod.d.mts +164 -0
  30. package/mod.mjs +289 -0
  31. package/mod.mjs.map +1 -0
  32. package/package.json +69 -3
  33. package/resume-hmr-BRDojQNp.mjs +6 -0
  34. package/resume-hmr-BRDojQNp.mjs.map +1 -0
  35. package/signal-CosyYdtA.d.mts +22 -0
  36. package/signal-D1WmFjmJ.mjs +108 -0
  37. package/signal-D1WmFjmJ.mjs.map +1 -0
  38. package/snapshot-BG0kq9wt.mjs +39 -0
  39. package/snapshot-BG0kq9wt.mjs.map +1 -0
  40. package/types-DDeNM8UH.d.mts +11 -0
  41. package/types-WOJV0N2h.d.mts +282 -0
  42. package/vite/mod.d.mts +13 -0
  43. package/vite/mod.mjs +150297 -0
  44. package/vite/mod.mjs.map +1 -0
  45. package/web-utils/mod.d.mts +34 -0
  46. package/web-utils/mod.mjs +132 -0
  47. package/web-utils/mod.mjs.map +1 -0
  48. package/core/component.ts +0 -7
  49. package/core/dev-client/mod.ts +0 -17
  50. package/core/dev-client/renderer.ts +0 -5
  51. package/core/dev-client/types.ts +0 -3
  52. package/core/mod.ts +0 -4
  53. package/core/signal.ts +0 -20
  54. package/core/types.ts +0 -6
  55. package/deno.json +0 -23
  56. package/jsx/jsx-dev-runtime.ts +0 -19
  57. package/jsx/jsx-runtime.ts +0 -1
  58. package/jsx/mod.ts +0 -34
  59. package/jsx/shared.ts +0 -1
  60. package/jsx/types.ts +0 -23
  61. package/mod.ts +0 -2
  62. package/transformers/dev-client/mod.ts +0 -39
  63. package/transformers/dev-ssr/mod.ts +0 -52
  64. package/transformers/utils/jsx.ts +0 -77
  65. package/utils/node-connect.ts +0 -55
  66. package/vite/dev-app/mod.ts +0 -88
  67. package/vite/mod.ts +0 -76
  68. package/vite/utils/routing.ts +0 -26
@@ -1,88 +0,0 @@
1
- import { Hono, type Context } from 'hono'
2
- import type { DevEnvironment, ResolvedConfig, ViteDevServer } from 'vite'
3
- import type { ModuleRunner } from 'vite/module-runner'
4
- import { renderToString } from '../../jsx/mod.ts'
5
- import type { SSRRootProps } from '../../core/types.ts'
6
- import { Fragment } from '../../jsx/jsx-dev-runtime.ts'
7
- import { createRoutes, type RouteEntry } from '../utils/routing.ts'
8
- import type { DevClientInfo } from '../../core/dev-client/types.ts'
9
-
10
- interface DevAppInit {
11
- resolvedConfig: ResolvedConfig
12
- devServer: ViteDevServer
13
- runner: ModuleRunner
14
- ssrEnv: DevEnvironment
15
- }
16
-
17
- const createDevApp = async (init: DevAppInit) => {
18
- const app = new Hono()
19
-
20
- const createHandler = (entry: RouteEntry) => async (c: Context) => {
21
- const [
22
- { default: Page },
23
- { default: SSRRoot }
24
- ] = await Promise.all([
25
- await init.runner.import(entry.filePath),
26
- await init.runner.import('/app/+ssr-root.tsx')
27
- ])
28
-
29
- const page = Page()
30
- const parent = SSRRoot({
31
- children: page,
32
- head: {
33
- type: Fragment,
34
- isStatic: true,
35
- props: {
36
- children: [
37
- {
38
- type: 'script',
39
- isStatic: true,
40
- props: {
41
- children: 'import("/@vite/client")'
42
- }
43
- },
44
- {
45
- type: 'script',
46
- props: {
47
- type: 'module',
48
- src: '/app/+client.dev.tsx'
49
- }
50
- },
51
- {
52
- type: 'script',
53
- isStatic: true,
54
- props: {
55
- type: 'text/eclipsa+devinfo',
56
- id: 'eclipsa-devinfo',
57
- children: JSON.stringify({
58
- filePath: entry.filePath
59
- } satisfies DevClientInfo)
60
- }
61
- }
62
- ]
63
- }
64
- }
65
- } satisfies SSRRootProps)
66
-
67
- return c.html(renderToString(parent))
68
- }
69
-
70
- for (const entry of await createRoutes(init.resolvedConfig.root)) {
71
- app.get(entry.honoPath, createHandler(entry))
72
- }
73
-
74
- return app
75
- }
76
- export const createDevFetch = (
77
- init: DevAppInit,
78
- ): (req: Request) => Promise<Response | undefined> => {
79
- let app = createDevApp(init)
80
-
81
- return async (req) => {
82
- const fetched = await (await app).fetch(req)
83
- if (fetched.status === 404) {
84
- return
85
- }
86
- return fetched
87
- }
88
- }
package/vite/mod.ts DELETED
@@ -1,76 +0,0 @@
1
- import {
2
- createServerModuleRunner,
3
- DevEnvironment,
4
- type Plugin,
5
- type ResolvedConfig,
6
- } from 'vite'
7
- import { createDevFetch } from './dev-app/mod.ts'
8
- import {
9
- incomingMessageToRequest,
10
- responseForServerResponse,
11
- } from '../utils/node-connect.ts'
12
- import { transformJSX } from '../transformers/dev-ssr/mod.ts'
13
- import { transformClientDevJSX } from '../transformers/dev-client/mod.ts'
14
-
15
- export const eclipsa = (): Plugin => {
16
- let config: ResolvedConfig
17
- return {
18
- name: 'vite-plugin-eclipsa',
19
- config() {
20
- return {
21
- esbuild: {
22
- jsxFactory: 'jsx',
23
- jsxImportSource: '@xely/eclipsa',
24
- jsx: 'preserve',
25
- },
26
- //environments: {
27
- /* ssr: {
28
- dev: {
29
- createEnvironment(name, config, _context) {
30
- return new DevEnvironment(name, config, {
31
- hot: false,
32
- })
33
- },
34
- },
35
- },*/
36
- // },
37
- }
38
- },
39
- configResolved(resolvedConfig) {
40
- config = resolvedConfig
41
- },
42
- configureServer(server) {
43
- const ssrEnv = server.environments.ssr
44
- const runner = createServerModuleRunner(ssrEnv, {
45
- hmr: false,
46
- })
47
- const devFetch = createDevFetch({
48
- resolvedConfig: config,
49
- devServer: server,
50
- runner,
51
- ssrEnv,
52
- })
53
- server.middlewares.use(async (req, res, next) => {
54
- const webReq = incomingMessageToRequest(req)
55
- const webRes = await devFetch(webReq)
56
- if (webRes) {
57
- responseForServerResponse(webRes, res)
58
- return
59
- }
60
- next()
61
- })
62
- },
63
- hotUpdate(options) {
64
- options.server.hot.send({ type: 'full-reload' })
65
- },
66
- transform(code, id) {
67
- if (id.endsWith('.tsx')) {
68
- const result = (this.environment.name === 'ssr' ? transformJSX : transformClientDevJSX)(code)
69
- return {
70
- code: result
71
- }
72
- }
73
- return
74
- },
75
- }
76
- }
@@ -1,26 +0,0 @@
1
- import fg from 'fast-glob'
2
- import path from 'node:path'
3
-
4
- // WIP
5
- const filePathToHonoPath = (filePath: string) => {
6
- const segments = filePath.split('/').slice(0, -1)
7
-
8
- return segments.join('/') || '/'
9
- }
10
-
11
- export interface RouteEntry {
12
- filePath: string
13
- honoPath: string
14
- }
15
- export const createRoutes = async (root: string): Promise<RouteEntry[]> => {
16
- const appDir = path.join(root, 'app')
17
- const result = []
18
- for await (const entry of fg.stream(path.join(root, '/**/+page.tsx'))) {
19
- const relativePath = path.relative(appDir, entry.toString())
20
- result.push({
21
- filePath: entry.toString(),
22
- honoPath: filePathToHonoPath(relativePath)
23
- })
24
- }
25
- return result
26
- }