@skathi-native/cli 0.1.0-beta.1 → 0.1.0-beta.2
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/cli/create.ts +100 -184
- package/cli/help.ts +160 -0
- package/cli/sk.ts +19 -85
- package/package.json +3 -2
- package/templates/minimal/assets/hello.txt +1 -0
- package/templates/minimal/src/App.vue +142 -0
- package/templates/minimal/src/main.ts +4 -0
- package/templates/showcase/assets/hello.txt +1 -0
- package/templates/showcase/assets/media/aurora.png +0 -0
- package/templates/showcase/assets/media/clip.mp4 +0 -0
- package/templates/showcase/assets/media/sticker.tgs +0 -0
- package/templates/showcase/src/App.vue +128 -0
- package/templates/showcase/src/components/Card.vue +41 -0
- package/templates/showcase/src/components/Icon.vue +29 -0
- package/templates/showcase/src/components/Missing.vue +26 -0
- package/templates/showcase/src/components/Page.vue +41 -0
- package/templates/showcase/src/components/Titlebar.vue +128 -0
- package/templates/showcase/src/engine.ts +33 -0
- package/templates/showcase/src/icons.ts +22 -0
- package/templates/showcase/src/main.ts +7 -0
- package/templates/showcase/src/pages/AudioPage.vue +124 -0
- package/templates/showcase/src/pages/FilesPage.vue +91 -0
- package/templates/showcase/src/pages/FormsPage.vue +139 -0
- package/templates/showcase/src/pages/GraphicsPage.vue +156 -0
- package/templates/showcase/src/pages/HomePage.vue +141 -0
- package/templates/showcase/src/pages/LocalePage.vue +71 -0
- package/templates/showcase/src/pages/MediaPage.vue +85 -0
- package/templates/showcase/src/pages/MotionPage.vue +199 -0
- package/templates/showcase/src/pages/NetworkPage.vue +103 -0
- package/templates/showcase/src/pages/PermissionsPage.vue +80 -0
- package/templates/showcase/src/pages/StoragePage.vue +117 -0
- package/templates/showcase/src/pages/StylesPage.vue +199 -0
- package/templates/showcase/src/pages/SystemPage.vue +89 -0
- package/templates/showcase/src/pages/TrayPage.vue +66 -0
- package/templates/showcase/src/pages/WindowPage.vue +128 -0
- package/templates/showcase/src/product.ts +2 -0
- package/templates/showcase/src/router.ts +149 -0
- package/templates/showcase/src/stores/counter.ts +9 -0
- package/templates/showcase/src/stores/desktop.ts +115 -0
- package/templates/showcase/src/styles.css +140 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onUnmounted, ref, shallowRef } from "vue";
|
|
3
|
+
import Card from "../components/Card.vue";
|
|
4
|
+
import Page from "../components/Page.vue";
|
|
5
|
+
import { describe, http, nav } from "../engine";
|
|
6
|
+
|
|
7
|
+
const quote = ref("");
|
|
8
|
+
const took = ref("");
|
|
9
|
+
async function load() {
|
|
10
|
+
const start = performance.now();
|
|
11
|
+
try {
|
|
12
|
+
const res = await http("https://api.github.com/zen");
|
|
13
|
+
quote.value = res.ok ? await res.text() : `HTTP ${res.status}`;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
quote.value = describe(e);
|
|
16
|
+
}
|
|
17
|
+
took.value = `${Math.round(performance.now() - start)} ms`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ECHO = "wss://echo.websocket.org";
|
|
21
|
+
const socket = shallowRef<SkWebSocket | null>(null);
|
|
22
|
+
const message = ref("Hello over a socket");
|
|
23
|
+
const log = ref<string[]>([]);
|
|
24
|
+
const note = (line: string) => (log.value = [line, ...log.value].slice(0, 6));
|
|
25
|
+
|
|
26
|
+
function connect() {
|
|
27
|
+
const ws = new WebSocket(ECHO);
|
|
28
|
+
ws.onopen = () => note("open");
|
|
29
|
+
ws.onmessage = (e) => note(`← ${String(e.data)}`);
|
|
30
|
+
ws.onclose = (e) => {
|
|
31
|
+
note(`closed (${e.code})`);
|
|
32
|
+
socket.value = null;
|
|
33
|
+
};
|
|
34
|
+
socket.value = ws;
|
|
35
|
+
}
|
|
36
|
+
function send(ws: SkWebSocket) {
|
|
37
|
+
ws.send(message.value);
|
|
38
|
+
note(`→ ${message.value}`);
|
|
39
|
+
}
|
|
40
|
+
onUnmounted(() => socket.value?.close());
|
|
41
|
+
|
|
42
|
+
const webView = skFeatures.iframe;
|
|
43
|
+
const embedded = ref(false);
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<Page
|
|
48
|
+
title="Network"
|
|
49
|
+
lead='fetch and WebSocket as in a browser; responses are cached on disk (sk.config.json "httpCache").'
|
|
50
|
+
>
|
|
51
|
+
<Card title="fetch" :api="nav.onLine ? 'online' : 'offline'">
|
|
52
|
+
<div class="row">
|
|
53
|
+
<button class="btn primary" @click="load">GET api.github.com/zen</button>
|
|
54
|
+
<span class="faint">{{ took }}</span>
|
|
55
|
+
</div>
|
|
56
|
+
<p v-if="quote" class="quote">{{ quote }}</p>
|
|
57
|
+
</Card>
|
|
58
|
+
|
|
59
|
+
<Card title="WebSocket" :api="ECHO">
|
|
60
|
+
<div class="row">
|
|
61
|
+
<button v-if="!socket" class="btn" @click="connect">Connect</button>
|
|
62
|
+
<template v-else>
|
|
63
|
+
<input v-model="message" class="input grow" @keyup.enter="send(socket)" />
|
|
64
|
+
<button class="btn primary" @click="send(socket)">Send</button>
|
|
65
|
+
<button class="btn" @click="socket.close()">Close</button>
|
|
66
|
+
</template>
|
|
67
|
+
</div>
|
|
68
|
+
<div v-for="(line, i) in log" :key="i" class="mono line">{{ line }}</div>
|
|
69
|
+
</Card>
|
|
70
|
+
|
|
71
|
+
<Card title="Embedded web page" api="<iframe>">
|
|
72
|
+
<template v-if="webView">
|
|
73
|
+
<div class="row">
|
|
74
|
+
<button class="btn" @click="embedded = !embedded">{{ embedded ? "Remove it" : "Embed example.com" }}</button>
|
|
75
|
+
</div>
|
|
76
|
+
<iframe v-if="embedded" class="frame" src="https://example.com" />
|
|
77
|
+
</template>
|
|
78
|
+
<p v-else class="muted">This platform has no web view for <iframe> (it needs WebView2 on Windows).</p>
|
|
79
|
+
<p class="faint">The page runs in the system web view, isolated from the app; postMessage talks across.</p>
|
|
80
|
+
</Card>
|
|
81
|
+
</Page>
|
|
82
|
+
</template>
|
|
83
|
+
|
|
84
|
+
<style scoped>
|
|
85
|
+
.grow {
|
|
86
|
+
flex: 1;
|
|
87
|
+
}
|
|
88
|
+
.quote {
|
|
89
|
+
margin: 0;
|
|
90
|
+
font-size: 16px;
|
|
91
|
+
font-style: italic;
|
|
92
|
+
color: var(--text);
|
|
93
|
+
}
|
|
94
|
+
.line {
|
|
95
|
+
color: var(--text-muted);
|
|
96
|
+
}
|
|
97
|
+
.frame {
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 260px;
|
|
100
|
+
border-radius: 10px;
|
|
101
|
+
border: 1px solid var(--line);
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { appPermissions } from "@skathi-native/runtime";
|
|
3
|
+
import { onMounted, onUnmounted, ref } from "vue";
|
|
4
|
+
import Card from "../components/Card.vue";
|
|
5
|
+
import Page from "../components/Page.vue";
|
|
6
|
+
import { describe, nav } from "../engine";
|
|
7
|
+
|
|
8
|
+
const rows = ref(appPermissions.list());
|
|
9
|
+
const asking = ref("");
|
|
10
|
+
const status = ref("");
|
|
11
|
+
|
|
12
|
+
const read = () => (rows.value = appPermissions.list());
|
|
13
|
+
onMounted(() => appPermissions.addEventListener("change", read));
|
|
14
|
+
onUnmounted(() => appPermissions.removeEventListener("change", read));
|
|
15
|
+
|
|
16
|
+
const tone = (state: string) => (state === "granted" ? "ok" : state === "prompt" ? "warn" : "bad");
|
|
17
|
+
|
|
18
|
+
// Resolves with a fresh read from the OS once the user answers (on Windows, once the Settings toggle moves).
|
|
19
|
+
async function request(name: string) {
|
|
20
|
+
asking.value = name;
|
|
21
|
+
try {
|
|
22
|
+
await appPermissions.request(name);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
status.value = describe(e);
|
|
25
|
+
} finally {
|
|
26
|
+
asking.value = "";
|
|
27
|
+
read();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function tryMicrophone() {
|
|
32
|
+
try {
|
|
33
|
+
const stream = await nav.mediaDevices.getUserMedia({ audio: true });
|
|
34
|
+
status.value = stream.getAudioTracks()[0]?.label ?? "a microphone";
|
|
35
|
+
for (const track of stream.getTracks()) track.stop();
|
|
36
|
+
} catch (e) {
|
|
37
|
+
status.value = describe(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<Page
|
|
44
|
+
title="Permissions"
|
|
45
|
+
lead="What the OS lets this app use, read live. Unlike a browser, an app can ask before it needs the device."
|
|
46
|
+
>
|
|
47
|
+
<Card :title="`On ${appPermissions.platform}`" api="appPermissions">
|
|
48
|
+
<div v-for="row in rows" :key="row.name" class="perm">
|
|
49
|
+
<span class="name">{{ row.name }}</span>
|
|
50
|
+
<span class="pill" :class="tone(row.state)">{{ row.state }}</span>
|
|
51
|
+
<button v-if="row.canRequest" class="btn" :disabled="asking === row.name" @click="request(row.name)">
|
|
52
|
+
{{ asking === row.name ? "Asking…" : "Ask" }}
|
|
53
|
+
</button>
|
|
54
|
+
</div>
|
|
55
|
+
</Card>
|
|
56
|
+
|
|
57
|
+
<Card title="Use it" api="getUserMedia()">
|
|
58
|
+
<div class="row">
|
|
59
|
+
<button class="btn" @click="tryMicrophone">Open the microphone</button>
|
|
60
|
+
<span class="faint">{{ status }}</span>
|
|
61
|
+
</div>
|
|
62
|
+
<p class="faint">
|
|
63
|
+
Opens and closes the device at once; the first use asks for consent if nothing was granted yet.
|
|
64
|
+
</p>
|
|
65
|
+
</Card>
|
|
66
|
+
</Page>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<style scoped>
|
|
70
|
+
.perm {
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
gap: 12px;
|
|
74
|
+
height: 34px;
|
|
75
|
+
}
|
|
76
|
+
.name {
|
|
77
|
+
width: 160px;
|
|
78
|
+
font-size: 13px;
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { appStorage } from "@skathi-native/runtime";
|
|
3
|
+
import { onMounted, ref } from "vue";
|
|
4
|
+
import Card from "../components/Card.vue";
|
|
5
|
+
import Missing from "../components/Missing.vue";
|
|
6
|
+
import Page from "../components/Page.vue";
|
|
7
|
+
import { describe, idb, storage } from "../engine";
|
|
8
|
+
import { appName } from "../product";
|
|
9
|
+
|
|
10
|
+
const visits = ref(0);
|
|
11
|
+
const note = ref("");
|
|
12
|
+
onMounted(() => {
|
|
13
|
+
if (!storage) return;
|
|
14
|
+
visits.value = Number(storage.getItem("visits") ?? 0) + 1;
|
|
15
|
+
storage.setItem("visits", String(visits.value));
|
|
16
|
+
note.value = storage.getItem("note") ?? "";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
interface Todo {
|
|
20
|
+
id: number;
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
const todos = ref<Todo[]>([]);
|
|
24
|
+
const draft = ref("");
|
|
25
|
+
const status = ref("");
|
|
26
|
+
|
|
27
|
+
const done = <T,>(request: SkIDBRequest<T>) =>
|
|
28
|
+
new Promise<T>((resolve, reject) => {
|
|
29
|
+
request.onsuccess = () => resolve(request.result);
|
|
30
|
+
request.onerror = () => reject(request.error);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
let db: SkIDBDatabase | null = null;
|
|
34
|
+
async function store(mode: "readonly" | "readwrite") {
|
|
35
|
+
if (!idb) throw new Error("no IndexedDB");
|
|
36
|
+
if (!db) {
|
|
37
|
+
const open = idb.open(appName, 1);
|
|
38
|
+
open.onupgradeneeded = () => open.result.createObjectStore("todos", { keyPath: "id", autoIncrement: true });
|
|
39
|
+
db = await done(open);
|
|
40
|
+
}
|
|
41
|
+
return db.transaction("todos", mode).objectStore("todos");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function update(change?: (todos: SkIDBObjectStore) => SkIDBRequest) {
|
|
45
|
+
try {
|
|
46
|
+
if (change) await done(change(await store("readwrite")));
|
|
47
|
+
todos.value = await done((await store("readonly")).getAll() as SkIDBRequest<Todo[]>);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
status.value = describe(e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
onMounted(() => idb && update());
|
|
53
|
+
|
|
54
|
+
function add() {
|
|
55
|
+
const text = draft.value.trim();
|
|
56
|
+
if (!text) return;
|
|
57
|
+
draft.value = "";
|
|
58
|
+
update((s) => s.add({ text }));
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<Page title="Storage" lead="The web's storage APIs, kept on disk in the app's own data folder between runs.">
|
|
64
|
+
<Card title="localStorage" api="localStorage">
|
|
65
|
+
<template v-if="storage">
|
|
66
|
+
<p class="muted">This page was opened {{ visits }} times, counting earlier runs.</p>
|
|
67
|
+
<input
|
|
68
|
+
v-model="note"
|
|
69
|
+
class="input"
|
|
70
|
+
placeholder="A note that survives a restart"
|
|
71
|
+
@input="storage.setItem('note', note)"
|
|
72
|
+
/>
|
|
73
|
+
</template>
|
|
74
|
+
<Missing v-else part="storages" />
|
|
75
|
+
</Card>
|
|
76
|
+
|
|
77
|
+
<Card title="IndexedDB" api="indexedDB">
|
|
78
|
+
<template v-if="idb">
|
|
79
|
+
<div class="row">
|
|
80
|
+
<input v-model="draft" class="input grow" placeholder="Something to do" @keyup.enter="add" />
|
|
81
|
+
<button class="btn primary" @click="add">Add</button>
|
|
82
|
+
</div>
|
|
83
|
+
<div v-for="todo in todos" :key="todo.id" class="todo">
|
|
84
|
+
<span>{{ todo.text }}</span>
|
|
85
|
+
<button class="btn" @click="update((s) => s.delete(todo.id))">Done</button>
|
|
86
|
+
</div>
|
|
87
|
+
<p v-if="!todos.length" class="faint">Nothing yet. Items are rows in a SQLite file under the data folder.</p>
|
|
88
|
+
<p v-if="status" class="faint">{{ status }}</p>
|
|
89
|
+
</template>
|
|
90
|
+
<Missing v-else part="indexeddb" />
|
|
91
|
+
</Card>
|
|
92
|
+
|
|
93
|
+
<Card title="Where it goes" api="appStorage">
|
|
94
|
+
<div class="kv">
|
|
95
|
+
<span class="k">folder</span><span class="v mono">{{ appStorage.folder || "in memory" }}</span>
|
|
96
|
+
</div>
|
|
97
|
+
<div class="kv">
|
|
98
|
+
<span class="k">encrypted</span><span class="v">{{ appStorage.encrypted ? "yes" : "no" }}</span>
|
|
99
|
+
</div>
|
|
100
|
+
</Card>
|
|
101
|
+
</Page>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<style scoped>
|
|
105
|
+
.grow {
|
|
106
|
+
flex: 1;
|
|
107
|
+
}
|
|
108
|
+
.todo {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
padding: 8px 8px 8px 12px;
|
|
113
|
+
border-radius: 9px;
|
|
114
|
+
background: var(--surface-hover);
|
|
115
|
+
font-size: 13px;
|
|
116
|
+
}
|
|
117
|
+
</style>
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import Card from "../components/Card.vue";
|
|
4
|
+
import Page from "../components/Page.vue";
|
|
5
|
+
|
|
6
|
+
const hot = ref(false);
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<Page
|
|
11
|
+
title="Styles"
|
|
12
|
+
lead="Ordinary CSS, mapped onto the GPU renderer. Add a tailwind.config.ts next to sk.config.json and Tailwind 3.4 classes work too."
|
|
13
|
+
>
|
|
14
|
+
<Card title="Gradients and shadows" api="background · box-shadow">
|
|
15
|
+
<div class="row gap">
|
|
16
|
+
<div class="swatch g1">linear</div>
|
|
17
|
+
<div class="swatch g2">radial</div>
|
|
18
|
+
<div class="swatch g3">conic</div>
|
|
19
|
+
<div class="swatch lifted">layered</div>
|
|
20
|
+
<div class="swatch ring">ring</div>
|
|
21
|
+
</div>
|
|
22
|
+
</Card>
|
|
23
|
+
|
|
24
|
+
<Card title="Glass" api="backdrop-filter: blur()">
|
|
25
|
+
<div class="scene">
|
|
26
|
+
<div class="blob b1" />
|
|
27
|
+
<div class="blob b2" />
|
|
28
|
+
<div class="blob b3" />
|
|
29
|
+
<div class="glass">Frosted panel over moving colour</div>
|
|
30
|
+
</div>
|
|
31
|
+
</Card>
|
|
32
|
+
|
|
33
|
+
<Card title="Engine shading" api="--shading">
|
|
34
|
+
<div class="row gap">
|
|
35
|
+
<div class="swatch frost">frost</div>
|
|
36
|
+
<div class="swatch noise">noise</div>
|
|
37
|
+
<div class="swatch glow" :class="{ hot }" @click="hot = !hot">glow · click</div>
|
|
38
|
+
</div>
|
|
39
|
+
<p class="faint">Skathi's own effects, in a custom property that a browser simply ignores.</p>
|
|
40
|
+
</Card>
|
|
41
|
+
|
|
42
|
+
<Card title="Layout" api="grid · ::before · :hover">
|
|
43
|
+
<div class="grid">
|
|
44
|
+
<div class="cell wide">grid-column: span 2</div>
|
|
45
|
+
<div class="cell">1fr</div>
|
|
46
|
+
<div class="cell status" data-state="online">online</div>
|
|
47
|
+
<div class="cell status" data-state="away">away</div>
|
|
48
|
+
<div class="cell hover">hover me</div>
|
|
49
|
+
</div>
|
|
50
|
+
</Card>
|
|
51
|
+
</Page>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<style scoped>
|
|
55
|
+
.gap {
|
|
56
|
+
gap: 14px;
|
|
57
|
+
}
|
|
58
|
+
.swatch {
|
|
59
|
+
width: 112px;
|
|
60
|
+
height: 64px;
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
border-radius: 12px;
|
|
65
|
+
font-size: 12px;
|
|
66
|
+
font-weight: 600;
|
|
67
|
+
color: #ffffff;
|
|
68
|
+
background: #1d1d2a;
|
|
69
|
+
}
|
|
70
|
+
.g1 {
|
|
71
|
+
background: linear-gradient(135deg, #8b9dff, #b48cff);
|
|
72
|
+
}
|
|
73
|
+
.g2 {
|
|
74
|
+
background: radial-gradient(circle at 30% 30%, #6ee7b7, #0f766e);
|
|
75
|
+
}
|
|
76
|
+
.g3 {
|
|
77
|
+
background: conic-gradient(#f472b6, #8b9dff, #6ee7b7, #f472b6);
|
|
78
|
+
}
|
|
79
|
+
.lifted {
|
|
80
|
+
box-shadow:
|
|
81
|
+
0 12px 24px -8px #000000cc,
|
|
82
|
+
0 2px 6px #00000080,
|
|
83
|
+
inset 0 1px 0 #ffffff26;
|
|
84
|
+
}
|
|
85
|
+
.ring {
|
|
86
|
+
box-shadow:
|
|
87
|
+
0 0 0 2px #0b0b10,
|
|
88
|
+
0 0 0 5px #8b9dff;
|
|
89
|
+
}
|
|
90
|
+
.scene {
|
|
91
|
+
position: relative;
|
|
92
|
+
z-index: 1;
|
|
93
|
+
height: 150px;
|
|
94
|
+
border-radius: 12px;
|
|
95
|
+
background: #101018;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
}
|
|
98
|
+
@keyframes drift {
|
|
99
|
+
50% {
|
|
100
|
+
transform: translateX(80px);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
.blob {
|
|
104
|
+
position: absolute;
|
|
105
|
+
width: 110px;
|
|
106
|
+
height: 110px;
|
|
107
|
+
border-radius: 55px;
|
|
108
|
+
animation: drift 6s ease-in-out infinite;
|
|
109
|
+
}
|
|
110
|
+
.b1 {
|
|
111
|
+
left: 40px;
|
|
112
|
+
top: 10px;
|
|
113
|
+
background: #8b9dff;
|
|
114
|
+
}
|
|
115
|
+
.b2 {
|
|
116
|
+
left: 230px;
|
|
117
|
+
top: 40px;
|
|
118
|
+
background: #f472b6;
|
|
119
|
+
animation-duration: 8s;
|
|
120
|
+
}
|
|
121
|
+
.b3 {
|
|
122
|
+
left: 420px;
|
|
123
|
+
top: 0px;
|
|
124
|
+
background: #34d399;
|
|
125
|
+
animation-duration: 7s;
|
|
126
|
+
}
|
|
127
|
+
.glass {
|
|
128
|
+
position: absolute;
|
|
129
|
+
left: 24px;
|
|
130
|
+
right: 24px;
|
|
131
|
+
top: 34px;
|
|
132
|
+
bottom: 34px;
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
border-radius: 12px;
|
|
137
|
+
border: 1px solid #ffffff26;
|
|
138
|
+
background: #ffffff14;
|
|
139
|
+
backdrop-filter: blur(18px);
|
|
140
|
+
font-size: 14px;
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
}
|
|
143
|
+
.frost {
|
|
144
|
+
background: linear-gradient(135deg, #3b82f6, #a855f7);
|
|
145
|
+
--shading: frost(0.85, 14px, #cfe9ff1f);
|
|
146
|
+
}
|
|
147
|
+
.noise {
|
|
148
|
+
background: linear-gradient(135deg, #f59e0b, #ef4444);
|
|
149
|
+
--shading: noise(0.4, 2px, 18);
|
|
150
|
+
}
|
|
151
|
+
.glow {
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
--shading: glow(#8b9dff, 10px, 0.35);
|
|
154
|
+
transition: --shading 420ms ease;
|
|
155
|
+
}
|
|
156
|
+
.glow.hot {
|
|
157
|
+
--shading: glow(#ff2d95, 30px, 1);
|
|
158
|
+
}
|
|
159
|
+
.grid {
|
|
160
|
+
display: grid;
|
|
161
|
+
grid-template-columns: 1fr 1fr 1fr;
|
|
162
|
+
gap: 8px;
|
|
163
|
+
}
|
|
164
|
+
.cell {
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
gap: 8px;
|
|
168
|
+
padding: 12px;
|
|
169
|
+
border-radius: 9px;
|
|
170
|
+
background: var(--surface-hover);
|
|
171
|
+
font-size: 12px;
|
|
172
|
+
color: var(--text-muted);
|
|
173
|
+
}
|
|
174
|
+
.wide {
|
|
175
|
+
grid-column: span 2;
|
|
176
|
+
}
|
|
177
|
+
.status::before {
|
|
178
|
+
content: "";
|
|
179
|
+
width: 8px;
|
|
180
|
+
height: 8px;
|
|
181
|
+
border-radius: 4px;
|
|
182
|
+
background: var(--text-faint);
|
|
183
|
+
}
|
|
184
|
+
.status[data-state="online"]::before {
|
|
185
|
+
background: var(--ok);
|
|
186
|
+
}
|
|
187
|
+
.status[data-state="away"]::before {
|
|
188
|
+
background: var(--warn);
|
|
189
|
+
}
|
|
190
|
+
.hover {
|
|
191
|
+
transition:
|
|
192
|
+
background-color 150ms ease,
|
|
193
|
+
color 150ms ease;
|
|
194
|
+
}
|
|
195
|
+
.hover:hover {
|
|
196
|
+
background: var(--accent-strong);
|
|
197
|
+
color: #ffffff;
|
|
198
|
+
}
|
|
199
|
+
</style>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { appDevtools, appHost, appLaunch, appShell, appStorage, type SkLaunchEvent } from "@skathi-native/runtime";
|
|
3
|
+
import { onMounted, onUnmounted, ref } from "vue";
|
|
4
|
+
import Card from "../components/Card.vue";
|
|
5
|
+
import Page from "../components/Page.vue";
|
|
6
|
+
import { describe, storage } from "../engine";
|
|
7
|
+
|
|
8
|
+
const status = ref("");
|
|
9
|
+
const launches = ref<string[]>([]);
|
|
10
|
+
const devtoolsOn = ref(appDevtools.available && appDevtools.isEnabled());
|
|
11
|
+
|
|
12
|
+
async function run(action: Promise<void>) {
|
|
13
|
+
try {
|
|
14
|
+
await action;
|
|
15
|
+
status.value = "";
|
|
16
|
+
} catch (e) {
|
|
17
|
+
status.value = describe(e);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Fires in the running app when the exe is started again under "singleInstance": true, or opened by a URL it owns.
|
|
22
|
+
const onLaunch = (event: SkEvent) => {
|
|
23
|
+
const { source, argv } = event as SkLaunchEvent;
|
|
24
|
+
launches.value = [`${source}: ${argv.join(" ")}`, ...launches.value].slice(0, 4);
|
|
25
|
+
};
|
|
26
|
+
onMounted(() => appLaunch.addEventListener("launch", onLaunch));
|
|
27
|
+
onUnmounted(() => appLaunch.removeEventListener("launch", onLaunch));
|
|
28
|
+
|
|
29
|
+
const off = appDevtools.onChange((on) => (devtoolsOn.value = on));
|
|
30
|
+
onUnmounted(off);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<Page title="System" lead="What a browser cannot do: open things with the system, read how the app was started.">
|
|
35
|
+
<Card title="Shell" api="appShell">
|
|
36
|
+
<div class="row">
|
|
37
|
+
<button class="btn" @click="run(appShell.openExternal('https://github.com/argon-chat/skathi'))">
|
|
38
|
+
Open the Skathi repository
|
|
39
|
+
</button>
|
|
40
|
+
<button v-if="storage" class="btn" @click="run(appShell.openPath(appStorage.folder))">
|
|
41
|
+
Open the data folder
|
|
42
|
+
</button>
|
|
43
|
+
<span class="faint">{{ status }}</span>
|
|
44
|
+
</div>
|
|
45
|
+
<p class="faint">openPath refuses programs and scripts unless asked, and openExternal refuses file: URLs.</p>
|
|
46
|
+
</Card>
|
|
47
|
+
|
|
48
|
+
<Card title="Launch" api="appLaunch">
|
|
49
|
+
<div class="kv">
|
|
50
|
+
<span class="k">arguments</span><span class="v mono">{{ appLaunch.argv.slice(1).join(" ") || "none" }}</span>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="kv">
|
|
53
|
+
<span class="k">working directory</span><span class="v mono">{{ appLaunch.cwd }}</span>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="kv">
|
|
56
|
+
<span class="k">single instance</span><span class="v">{{ appLaunch.singleInstance ? "yes" : "no" }}</span>
|
|
57
|
+
</div>
|
|
58
|
+
<div v-for="line in launches" :key="line" class="kv">
|
|
59
|
+
<span class="k">launch event</span><span class="v mono">{{ line }}</span>
|
|
60
|
+
</div>
|
|
61
|
+
<p class="faint">
|
|
62
|
+
Set "singleInstance": true and "protocols": ["myapp"] in sk.config.json to receive later launches and myapp://
|
|
63
|
+
links here.
|
|
64
|
+
</p>
|
|
65
|
+
</Card>
|
|
66
|
+
|
|
67
|
+
<Card title="Devtools" api="appDevtools">
|
|
68
|
+
<div v-if="appDevtools.available" class="row">
|
|
69
|
+
<span class="pill" :class="{ ok: devtoolsOn }">{{ devtoolsOn ? "on" : "off" }}</span>
|
|
70
|
+
<button class="btn" :disabled="!devtoolsOn" @click="appDevtools.open()">Open (F12)</button>
|
|
71
|
+
<button class="btn" @click="devtoolsOn ? appDevtools.disable() : appDevtools.enable()">
|
|
72
|
+
{{ devtoolsOn ? "Turn off" : "Turn on" }}
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
<p v-else class="muted">This build leaves the devtools out (sk publish does unless you keep them).</p>
|
|
76
|
+
<p class="faint">Element tree, styles, console and network, attached to this window.</p>
|
|
77
|
+
</Card>
|
|
78
|
+
|
|
79
|
+
<Card title="Embedding" api="appHost">
|
|
80
|
+
<p class="muted">
|
|
81
|
+
{{
|
|
82
|
+
appHost.available
|
|
83
|
+
? `Embedded in another program, which offers: ${appHost.functions.join(", ") || "no functions"}.`
|
|
84
|
+
: "Running as its own exe. A program that embeds Skathi as a library gives the app functions to call here."
|
|
85
|
+
}}
|
|
86
|
+
</p>
|
|
87
|
+
</Card>
|
|
88
|
+
</Page>
|
|
89
|
+
</template>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { appHotkeys, appTray } from "@skathi-native/runtime";
|
|
3
|
+
import { ref } from "vue";
|
|
4
|
+
import Card from "../components/Card.vue";
|
|
5
|
+
import Page from "../components/Page.vue";
|
|
6
|
+
import { describe } from "../engine";
|
|
7
|
+
import { useCounter } from "../stores/counter";
|
|
8
|
+
import { chordLabel, DEFAULT_CHORD, useDesktop } from "../stores/desktop";
|
|
9
|
+
|
|
10
|
+
const desktop = useDesktop();
|
|
11
|
+
const counter = useCounter();
|
|
12
|
+
const recording = ref(false);
|
|
13
|
+
const status = ref("");
|
|
14
|
+
|
|
15
|
+
// Records the next key combination anywhere on the system; Esc cancels.
|
|
16
|
+
async function record() {
|
|
17
|
+
recording.value = true;
|
|
18
|
+
status.value = "Press a combination…";
|
|
19
|
+
try {
|
|
20
|
+
const chord = await appHotkeys.captureOnce();
|
|
21
|
+
desktop.bindHotkey(chord);
|
|
22
|
+
status.value = "";
|
|
23
|
+
} catch (e) {
|
|
24
|
+
status.value = describe(e);
|
|
25
|
+
} finally {
|
|
26
|
+
recording.value = false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<Page title="Tray & hotkeys" lead="Desktop integration that keeps working while the window is in the background.">
|
|
33
|
+
<Card title="Tray icon" api="appTray.set()">
|
|
34
|
+
<template v-if="appTray.available">
|
|
35
|
+
<div class="row">
|
|
36
|
+
<button class="btn" :class="{ on: desktop.trayShown }" @click="desktop.showTray(!desktop.trayShown)">
|
|
37
|
+
{{ desktop.trayShown ? "Remove the tray icon" : "Show a tray icon" }}
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
<p class="faint">
|
|
41
|
+
Its menu counts up, toggles always-on-top and quits; the label follows the count ({{ counter.count }}). The
|
|
42
|
+
icon is drawn from RGBA pixels, so it works in dev as well as in a build.
|
|
43
|
+
</p>
|
|
44
|
+
</template>
|
|
45
|
+
<p v-else class="muted">This platform has no tray in Skathi yet (Windows and macOS do).</p>
|
|
46
|
+
</Card>
|
|
47
|
+
|
|
48
|
+
<Card title="Global hotkey" api="appHotkeys">
|
|
49
|
+
<template v-if="appHotkeys.available">
|
|
50
|
+
<div class="row">
|
|
51
|
+
<span class="pill" :class="{ ok: desktop.chord }">
|
|
52
|
+
{{ desktop.chord ? chordLabel(desktop.chord) : "not bound" }}
|
|
53
|
+
</span>
|
|
54
|
+
<button class="btn" @click="desktop.bindHotkey(desktop.chord ? null : DEFAULT_CHORD)">
|
|
55
|
+
{{ desktop.chord ? "Unbind" : `Bind ${chordLabel(DEFAULT_CHORD)}` }}
|
|
56
|
+
</button>
|
|
57
|
+
<button v-if="!recording" class="btn" @click="record">Record another…</button>
|
|
58
|
+
<button v-else class="btn" @click="appHotkeys.cancelCapture()">Cancel</button>
|
|
59
|
+
</div>
|
|
60
|
+
<p class="muted">Pressed {{ desktop.presses }} times; each press counts up, from any app.</p>
|
|
61
|
+
<p v-if="status" class="faint">{{ status }}</p>
|
|
62
|
+
</template>
|
|
63
|
+
<p v-else class="muted">Global hotkeys need Windows or macOS.</p>
|
|
64
|
+
</Card>
|
|
65
|
+
</Page>
|
|
66
|
+
</template>
|