murasaki 0.2.0 → 0.2.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.
- package/bin/murasaki.js +8 -3
- package/dist/cli/colors.d.ts +13 -0
- package/dist/cli/colors.d.ts.map +1 -0
- package/dist/cli/colors.js +14 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/log.d.ts +14 -0
- package/dist/cli/log.d.ts.map +1 -0
- package/dist/cli/log.js +25 -0
- package/dist/cli/log.js.map +1 -0
- package/dist/components/Link.d.ts +9 -0
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/Link.js +15 -0
- package/dist/components/Link.js.map +1 -0
- package/dist/dev.d.ts +2 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +41 -0
- package/dist/dev.js.map +1 -0
- package/dist/env.d.ts +15 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +43 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx/index.d.ts +3 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +3 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-dev-runtime.js +7 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +2 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/{src/jsx/jsx-runtime.ts → dist/jsx/jsx-runtime.js} +4 -3
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/runtime.d.ts +24 -0
- package/dist/jsx/runtime.d.ts.map +1 -0
- package/dist/jsx/runtime.js +273 -0
- package/dist/jsx/runtime.js.map +1 -0
- package/dist/jsx/types.d.ts +30 -0
- package/dist/jsx/types.d.ts.map +1 -0
- package/dist/jsx/types.js +3 -0
- package/dist/jsx/types.js.map +1 -0
- package/dist/runtime/hmr.d.ts +2 -0
- package/dist/runtime/hmr.d.ts.map +1 -0
- package/dist/runtime/hmr.js +28 -0
- package/dist/runtime/hmr.js.map +1 -0
- package/dist/runtime/render.d.ts +3 -0
- package/dist/runtime/render.d.ts.map +1 -0
- package/dist/runtime/render.js +208 -0
- package/dist/runtime/render.js.map +1 -0
- package/dist/runtime/routes.d.ts +10 -0
- package/dist/runtime/routes.d.ts.map +1 -0
- package/dist/runtime/routes.js +65 -0
- package/dist/runtime/routes.js.map +1 -0
- package/dist/runtime/shortcuts.d.ts +8 -0
- package/dist/runtime/shortcuts.d.ts.map +1 -0
- package/dist/runtime/shortcuts.js +29 -0
- package/dist/runtime/shortcuts.js.map +1 -0
- package/dist/runtime/window.d.ts +10 -0
- package/dist/runtime/window.d.ts.map +1 -0
- package/dist/runtime/window.js +93 -0
- package/dist/runtime/window.js.map +1 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +12 -10
- package/src/cli/colors.ts +0 -16
- package/src/cli/log.ts +0 -42
- package/src/components/Link.tsx +0 -25
- package/src/dev.tsx +0 -60
- package/src/env.ts +0 -48
- package/src/index.ts +0 -24
- package/src/jsx/index.ts +0 -21
- package/src/jsx/jsx-dev-runtime.ts +0 -6
- package/src/jsx/runtime.ts +0 -298
- package/src/jsx/types.ts +0 -36
- package/src/runtime/hmr.ts +0 -26
- package/src/runtime/render.tsx +0 -225
- package/src/runtime/routes.ts +0 -73
- package/src/runtime/shortcuts.ts +0 -31
- package/src/runtime/window.ts +0 -94
- package/src/types.ts +0 -22
package/src/runtime/window.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// Owns the Application + BrowserWindow lifecycle.
|
|
2
|
-
//
|
|
3
|
-
// The EventLoop is created exactly once (winit/tao limitation). ControlFlow.Wait
|
|
4
|
-
// keeps the loop alive even when no windows are open, so the user can press
|
|
5
|
-
// `o` in the terminal to re-open the window.
|
|
6
|
-
|
|
7
|
-
import { Application, ControlFlow } from '@webviewjs/webview'
|
|
8
|
-
import { printClosed, printError, printHint, printReloaded } from '../cli/log.ts'
|
|
9
|
-
import { DEFAULT_WIN_SIZE, DEFAULT_WIN_TITLE, projectRoot } from '../env.ts'
|
|
10
|
-
import type { Metadata } from '../index.ts'
|
|
11
|
-
import type { WindowConfig } from '../types.ts'
|
|
12
|
-
import { renderApp } from './render.tsx'
|
|
13
|
-
|
|
14
|
-
const config: WindowConfig = {
|
|
15
|
-
title: DEFAULT_WIN_TITLE,
|
|
16
|
-
width: DEFAULT_WIN_SIZE.width,
|
|
17
|
-
height: DEFAULT_WIN_SIZE.height,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const app = new Application({ controlFlow: ControlFlow.Wait })
|
|
21
|
-
let win: ReturnType<typeof app.createBrowserWindow> | null = null
|
|
22
|
-
let webview: ReturnType<NonNullable<typeof win>['createWebview']> | null = null
|
|
23
|
-
|
|
24
|
-
app.onEvent((event) => {
|
|
25
|
-
const kind = event && ((event as any).kind || (event as any).event)
|
|
26
|
-
if (kind === 'window-close-requested') {
|
|
27
|
-
// Dispose so the OS close completes — without this the close button hangs.
|
|
28
|
-
if (win) {
|
|
29
|
-
try {
|
|
30
|
-
win.dispose()
|
|
31
|
-
} catch {}
|
|
32
|
-
}
|
|
33
|
-
win = null
|
|
34
|
-
webview = null
|
|
35
|
-
printClosed()
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
function applyMetadata(metadata?: Metadata) {
|
|
40
|
-
if (!metadata) return
|
|
41
|
-
if (metadata.window?.title) config.title = metadata.window.title
|
|
42
|
-
else if (metadata.title) config.title = metadata.title
|
|
43
|
-
if (metadata.window?.width) config.width = metadata.window.width
|
|
44
|
-
if (metadata.window?.height) config.height = metadata.window.height
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function getConfig(): Readonly<WindowConfig> {
|
|
48
|
-
return config
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export async function openWindow(): Promise<void> {
|
|
52
|
-
if (win) {
|
|
53
|
-
printHint('Window is already open')
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
const { html, metadata } = await renderApp()
|
|
57
|
-
applyMetadata(metadata)
|
|
58
|
-
win = app.createBrowserWindow({
|
|
59
|
-
title: config.title,
|
|
60
|
-
width: config.width,
|
|
61
|
-
height: config.height,
|
|
62
|
-
})
|
|
63
|
-
webview = win.createWebview({ html })
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function closeWindow(): void {
|
|
67
|
-
if (!win) return
|
|
68
|
-
try {
|
|
69
|
-
win.dispose()
|
|
70
|
-
} catch {}
|
|
71
|
-
win = null
|
|
72
|
-
webview = null
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export async function reloadWindow(triggerFile: string): Promise<void> {
|
|
76
|
-
if (!webview) return
|
|
77
|
-
try {
|
|
78
|
-
const { html } = await renderApp()
|
|
79
|
-
webview.loadHtml(html)
|
|
80
|
-
printReloaded(triggerFile.replace(projectRoot + '/', ''))
|
|
81
|
-
} catch (e: any) {
|
|
82
|
-
printError(`Reload failed: ${e.message}`)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function runApp(): void {
|
|
87
|
-
app.run()
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function exitApp(): void {
|
|
91
|
-
try {
|
|
92
|
-
app.exit()
|
|
93
|
-
} catch {}
|
|
94
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Internal shared types (the public Metadata type is re-exported from index.ts).
|
|
2
|
-
|
|
3
|
-
import type { Metadata } from './index.ts'
|
|
4
|
-
import type { Component } from './jsx/types.ts'
|
|
5
|
-
|
|
6
|
-
export type AppComponent = Component
|
|
7
|
-
|
|
8
|
-
export type LayoutModule = {
|
|
9
|
-
component: AppComponent
|
|
10
|
-
metadata?: Metadata
|
|
11
|
-
} | null
|
|
12
|
-
|
|
13
|
-
export type WindowConfig = {
|
|
14
|
-
title: string
|
|
15
|
-
width: number
|
|
16
|
-
height: number
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type RenderResult = {
|
|
20
|
-
html: string
|
|
21
|
-
metadata?: Metadata
|
|
22
|
-
}
|