Skip to content

Commit 694b38e

Browse files
committed
wip super preview
1 parent 2113ea2 commit 694b38e

17 files changed

+397
-174
lines changed

build.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const cp = async (a, b) => fs.cp(
1515
async function copy (target) {
1616
await cp('src/index.html', target)
1717
await cp('src/vm.js', target)
18+
await cp('src/preview.js', target)
19+
await cp('src/worker.js', target)
1820
await cp('icons/icon.png', target)
1921
await cp('src/templates', target)
2022
await cp('src/examples', target)
@@ -35,6 +37,7 @@ async function main (argv) {
3537
await esbuild.build({
3638
entryPoints: workerEntryPoints.map((entry) => `node_modules/monaco-editor/esm/${entry}`),
3739
bundle: true,
40+
minify: false,
3841
format: 'iife',
3942
outbase: 'node_modules/monaco-editor/esm/',
4043
outdir: 'src'
@@ -45,9 +48,8 @@ async function main (argv) {
4548
format: 'esm',
4649
bundle: true,
4750
minify: false,
48-
sourcemap: true,
51+
sourcemap: false,
4952
external: ['socket:*', 'node:*'],
50-
keepNames: true,
5153
loader: {
5254
'.ttf': 'file'
5355
}
@@ -57,10 +59,7 @@ async function main (argv) {
5759

5860
const opts = {
5961
...params,
60-
outdir: target,
61-
minifyWhitespace: false,
62-
minifyIdentifiers: true,
63-
minifySyntax: true
62+
outdir: target
6463
}
6564
await esbuild.build(opts)
6665
await copy(target)

socket.ini

+9-5
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ watch = true
8383
; default value: true
8484
reload = true
8585

86+
[webview.service-workers]
87+
88+
/ = /worker.js
8689

8790
; Mount file system paths in webview navigator
8891
[webview.navigator.mounts]
92+
$HOST_HOME = /user/home
8993
; $HOST_HOME/directory-in-home-folder/ = /mount/path/in/navigator
9094
; $HOST_CONTAINER/directory-app-container/ = /mount/path/in/navigator
9195
; $HOST_PROCESS_WORKING_DIRECTORY/directory-in-app-process-working-directory/ = /mount/path/in/navigator
@@ -267,6 +271,7 @@ codesign_paths = ""
267271
; default value: "13.0.0"
268272
; minimum_supported_version = "13.0.0"
269273

274+
trafficLightPosition = "10x24"
270275

271276
; The icon to use for identifying your app on MacOS.
272277
icon = "icons/icon.png"
@@ -323,11 +328,11 @@ width = 80%
323328

324329
; Minimum height of the window in pixels or as a percentage of the screen.
325330
; default value: 0
326-
; min_height = 0
331+
min_height = 500
327332

328333
; Minimum width of the window in pixels or as a percentage of the screen.
329334
; default value: 0
330-
; min_width = 0
335+
min_width = 700
331336

332337
; If the window is resizable or not.
333338
; default value: true
@@ -337,6 +342,8 @@ width = 80%
337342
; default value: false
338343
; frameless = false
339344

345+
titleBarStyle = "hiddenInset"
346+
340347
; If the window is utility window or not.
341348
; default value: false
342349
; utility = false
@@ -385,6 +392,3 @@ runner_mac_flags = ""
385392
runner_win32 = ""
386393
; The headless runner command flags for Windows
387394
runner_win32_flags = ""
388-
389-
[permissions]
390-
allow_service_worker = false

src/css/index.css

+11-3
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,28 @@ main-component {
253253

254254
header {
255255
display: grid;
256-
grid-template-columns: 34px 250px 34px 1fr 150px;
256+
grid-template-columns: 1fr 34px 250px 34px 1fr;
257257
gap: 12px;
258258
grid-template-rows: auto;
259259
align-content: center;
260-
height: 82px;
260+
height: 50px;
261261
padding: 0 12px;
262262
position: absolute;
263263
top: 0;
264264
left: 0;
265265
right: 0;
266+
cursor: default;
267+
app-region: drag; /* windows */
268+
--app-region: drag; /* mac/linux */
269+
}
270+
271+
header [platform="darwin"] {
272+
padding-left: 35%;
273+
padding-right: 35%;
266274
}
267275

268276
#split-main {
269-
top: 80px;
277+
top: 50px;
270278
border-top: 1px solid var(--tonic-border);
271279
}
272280

src/css/preview.css

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
app-preview {
2+
position: absolute;
3+
top: 0; bottom: 0; left: 0; right: 0;
4+
background: var(--tonic-background);
5+
}
6+
7+
app-preview .container {
8+
position: absolute;
9+
top: 0px; bottom: 0px; left: 0px; right: 0px;
10+
}
11+
12+
app-preview .device {
13+
position: relative;
14+
height: 100%;
15+
border: 1px solid var(--tonic-border);
16+
overflow: hidden;
17+
}
18+
19+
app-preview .device iframe {
20+
position: absolute;
21+
top: 0;
22+
bottom: 0;
23+
left: 0;
24+
right: 0;
25+
height: 100%;
26+
width: 100%;
27+
}
28+
29+
/* Source: https://github.com/kylebshr/ScreenCorners */
30+
31+
app-preview .device[device="ios"] {
32+
aspect-ratio: 9 / 19.5;
33+
border-radius: 39px;
34+
margin: 60px;
35+
}
36+
37+
app-preview .device[device="ipad"] {
38+
aspect-ratio: 3 / 4;
39+
border-radius: 18px;
40+
margin: 60px;
41+
}
42+
43+
app-preview .device[device="darwin"] {
44+
aspect-ratio: initial;
45+
border-radius: 12px;
46+
position: absolute;
47+
top: 60px;
48+
border-top: 1px solid var(--tonic-border);
49+
left: 60px;
50+
right: 60px;
51+
bottom: 60px;
52+
height: unset;
53+
}

src/css/tonic-overrides.css

+13
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ tonic-split .tonic--split-horizontal {
1414
border-top: 1px solid var(--tonic-border);
1515
}
1616

17+
tonic-select .tonic--select {
18+
overflow: hidden;
19+
border-radius: 8px;
20+
}
21+
22+
tonic-select select:not([multiple]) {
23+
padding: 6px 30px 6px 10px;
24+
}
25+
26+
tonic-select .tonic--arrow:before {
27+
top: 43%;
28+
}
29+
1730
tonic-split .tonic--split-handle {
1831
z-index: 20 !important;
1932
}

src/editor.js

+5
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,17 @@ class AppEditor extends Tonic {
102102

103103
async writeToDisk (projectNode, data) {
104104
const app = document.querySelector('app-view')
105+
const preview = document.querySelector('app-preview')
106+
107+
const zoom = this.props.parent.state.scaleFactor || '1'
105108

106109
try {
107110
await fs.promises.writeFile(projectNode.id, data)
108111
} catch (err) {
109112
console.error(`Unable to write to ${dest}`, err)
110113
}
114+
115+
this.props.parent.reloadPreviewWindows()
111116
}
112117

113118
async loadProjectNode (projectNode) {

src/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<link rel="stylesheet" href="css/editor.main.css">
1818
<link rel="stylesheet" href="css/tonic-overrides.css">
1919
<link rel="stylesheet" href="css/xterm.css">
20+
<link rel="stylesheet" href="css/preview.css">
2021
<link rel="stylesheet" href="css/project.css">
2122
<link rel="stylesheet" href="css/index.css">
2223
</head>

0 commit comments

Comments
 (0)