@skathi-native/cli 0.0.0 → 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/aot-inputs.ts +294 -0
- package/ascii.ts +397 -0
- package/build.ts +1236 -0
- package/check/builtins.json +1219 -0
- package/check/builtins.ts +112 -0
- package/check/codes.ts +178 -0
- package/check/command.ts +105 -0
- package/check/config.ts +76 -0
- package/check/finding.ts +30 -0
- package/check/graph.ts +69 -0
- package/check/highlight.ts +40 -0
- package/check/index.ts +308 -0
- package/check/packages.ts +54 -0
- package/check/program.ts +209 -0
- package/check/report.ts +219 -0
- package/check/rules.ts +307 -0
- package/check/schema.ts +69 -0
- package/check/typing.ts +703 -0
- package/cli/assets.ts +114 -0
- package/cli/build-app.ts +587 -0
- package/cli/config.ts +646 -0
- package/cli/create.ts +327 -0
- package/cli/dev.ts +92 -0
- package/cli/elf.ts +142 -0
- package/cli/help.ts +160 -0
- package/cli/host-fetch.ts +178 -0
- package/cli/host.ts +378 -0
- package/cli/icon.ts +303 -0
- package/cli/macos-bundle.ts +451 -0
- package/cli/pe.ts +429 -0
- package/cli/platform.ts +74 -0
- package/cli/sk.ts +290 -0
- package/cli/skpk.ts +268 -0
- package/cli/stamp.ts +254 -0
- package/cli/term.ts +176 -0
- package/cli/versioninfo.ts +123 -0
- package/css-prefixes.ts +118 -0
- package/devtools/apps.ts +68 -0
- package/devtools/commands.ts +860 -0
- package/devtools/ctl.ts +166 -0
- package/package.json +52 -3
- package/prod.ts +701 -0
- package/runtime-path.ts +24 -0
- package/tailwind.ts +76 -0
- 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
- package/vitecompat.ts +1151 -0
package/runtime-path.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join, sep } from "node:path";
|
|
4
|
+
|
|
5
|
+
/** The `@skathi-native/runtime` package the builders bundle into every app. */
|
|
6
|
+
export const RUNTIME_DIR = realpathSync(
|
|
7
|
+
dirname(createRequire(import.meta.path).resolve("@skathi-native/runtime/package.json")),
|
|
8
|
+
);
|
|
9
|
+
export const RUNTIME_SRC_DIR = join(RUNTIME_DIR, "src");
|
|
10
|
+
export const RUNTIME_ENTRY = join(RUNTIME_SRC_DIR, "runtime.ts");
|
|
11
|
+
export const LOADER_ENTRY = join(RUNTIME_SRC_DIR, "loader.ts");
|
|
12
|
+
/** Resolves from the runtime package: its own vue-router and pinia, for an app that declares neither. */
|
|
13
|
+
export const runtimeRequire = createRequire(join(RUNTIME_DIR, "package.json"));
|
|
14
|
+
|
|
15
|
+
/** The node_modules the runtime's dependencies are installed in (hoisted to the workspace root in a checkout). */
|
|
16
|
+
export const RUNTIME_MODULES_DIR = (() => {
|
|
17
|
+
const dep = realpathSync(runtimeRequire.resolve("@vue/runtime-core"));
|
|
18
|
+
const at = dep.lastIndexOf(`${sep}node_modules${sep}`);
|
|
19
|
+
return at < 0 ? join(RUNTIME_DIR, "node_modules") : dep.slice(0, at + `${sep}node_modules`.length);
|
|
20
|
+
})();
|
|
21
|
+
|
|
22
|
+
/** Bare specifiers the builders serve from the runtime; an app cannot alias them. */
|
|
23
|
+
export const PRESEEDED: readonly string[] = ["vue", "@skathi-native/runtime", "vue-router", "pinia"];
|
|
24
|
+
export const isPreseeded = (spec: string) => PRESEEDED.includes(spec);
|
package/tailwind.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Tailwind CSS integration, shared by build.ts (dev) and prod.ts.
|
|
2
|
+
//
|
|
3
|
+
// Pinned to v3.4 (package.json): v4 emits `calc(var(--spacing) * 4)`, `color-mix`, `@property`,
|
|
4
|
+
// `@layer` and `@theme`, which sk-css cannot resolve completely yet; v3.4 emits literal
|
|
5
|
+
// declarations that render.
|
|
6
|
+
//
|
|
7
|
+
// We ask for `@tailwind base; @tailwind utilities`, not `components`. `base` carries the
|
|
8
|
+
// `*, ::before, ::after { --tw-*: … }` seeds that make compound utilities (shadows, rings,
|
|
9
|
+
// transforms, `space-*`) resolve; its ::before/::after halves are dropped with one advisory.
|
|
10
|
+
|
|
11
|
+
import { existsSync } from "fs";
|
|
12
|
+
import { dirname, join, resolve as resolvePath } from "path";
|
|
13
|
+
|
|
14
|
+
import postcss from "postcss";
|
|
15
|
+
import tailwindcss from "tailwindcss";
|
|
16
|
+
|
|
17
|
+
/// The synthetic module id the utilities sheet rides on. A leading "." sorts first, so utilities
|
|
18
|
+
/// land before component <style> and lose specificity ties, as in a browser project.
|
|
19
|
+
export const TW_ID = ".sk/tailwind.css";
|
|
20
|
+
|
|
21
|
+
const CONFIG_NAMES = ["tailwind.config.js", "tailwind.config.cjs", "tailwind.config.mjs", "tailwind.config.ts"];
|
|
22
|
+
|
|
23
|
+
/// Nearest `tailwind.config.*` at or above `startDir`, stopping after `stopDir` (the workspace root).
|
|
24
|
+
/// `null`: the app opts out and no synthetic module is emitted.
|
|
25
|
+
export function findConfig(startDir: string, stopDir: string): string | null {
|
|
26
|
+
let dir = startDir;
|
|
27
|
+
for (;;) {
|
|
28
|
+
for (const name of CONFIG_NAMES) {
|
|
29
|
+
const candidate = join(dir, name);
|
|
30
|
+
if (existsSync(candidate)) return candidate;
|
|
31
|
+
}
|
|
32
|
+
if (dir === stopDir) return null;
|
|
33
|
+
const parent = dirname(dir);
|
|
34
|
+
if (parent === dir) return null; // filesystem root — startDir was outside stopDir
|
|
35
|
+
dir = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Runs Tailwind's JIT over the config's `content` globs and returns the utilities sheet.
|
|
40
|
+
///
|
|
41
|
+
/// Runs with the config's directory as cwd (Tailwind v3 resolves a relative `content` glob against
|
|
42
|
+
/// `process.cwd()`); calls are serialized because cwd is process-global.
|
|
43
|
+
export function generate(configPath: string, source?: CssSource): Promise<string> {
|
|
44
|
+
const run = async () => {
|
|
45
|
+
const dir = dirname(configPath);
|
|
46
|
+
const prev = process.cwd();
|
|
47
|
+
const move = resolvePath(prev).toLowerCase() !== resolvePath(dir).toLowerCase();
|
|
48
|
+
if (move) process.chdir(dir);
|
|
49
|
+
try {
|
|
50
|
+
const result = await postcss([tailwindcss(configPath)]).process(
|
|
51
|
+
source?.text ?? "@tailwind base;\n@tailwind utilities;\n",
|
|
52
|
+
{ from: source?.from },
|
|
53
|
+
);
|
|
54
|
+
return result.css;
|
|
55
|
+
} finally {
|
|
56
|
+
if (move) process.chdir(prev);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const next = queue.then(run, run);
|
|
60
|
+
queue = next.catch(() => undefined);
|
|
61
|
+
return next;
|
|
62
|
+
}
|
|
63
|
+
let queue: Promise<unknown> = Promise.resolve();
|
|
64
|
+
|
|
65
|
+
/// A stylesheet the app owns, handed to Tailwind as its own entry so `@tailwind` and `@apply` expand in place.
|
|
66
|
+
export type CssSource = { text: string; from: string };
|
|
67
|
+
|
|
68
|
+
/// Does this stylesheet need Tailwind's PostCSS pass (`@tailwind` / `@layer` / `@apply` / `theme()`)? A plain sheet is emitted verbatim.
|
|
69
|
+
export function needsTailwindPass(css: string): boolean {
|
|
70
|
+
return /@tailwind\b|@layer\b|@apply\b|@screen\b|(?<![\w-])theme\(/.test(css);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Does this stylesheet declare the utilities layer itself? Then the synthetic `.sk/tailwind.css` module is redundant.
|
|
74
|
+
export function declaresUtilities(css: string): boolean {
|
|
75
|
+
return /@tailwind\s+utilities\s*;/.test(css);
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello from assets/hello.txt, packaged with {{productName}}.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onMounted, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
const productName = "{{productName}}";
|
|
5
|
+
const initial = productName.charAt(0).toUpperCase();
|
|
6
|
+
|
|
7
|
+
const count = ref(0);
|
|
8
|
+
const clicks = computed(() => `${count.value} ${count.value === 1 ? "click" : "clicks"}`);
|
|
9
|
+
|
|
10
|
+
// A relative URL resolves against the app root in dev and against the packaged assets in a build.
|
|
11
|
+
const greeting = ref("");
|
|
12
|
+
onMounted(async () => {
|
|
13
|
+
if (typeof fetch !== "function") return;
|
|
14
|
+
const res = await fetch("assets/hello.txt");
|
|
15
|
+
if (res.ok) greeting.value = (await res.text()).trim();
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<main class="page">
|
|
21
|
+
<section class="card">
|
|
22
|
+
<div class="logo">{{ initial }}</div>
|
|
23
|
+
<h1 class="title">{{ productName }}</h1>
|
|
24
|
+
<p class="lead">Vue on a native GPU renderer. Edit <span class="code">src/App.vue</span> and save.</p>
|
|
25
|
+
<div class="actions">
|
|
26
|
+
<button class="button" @click="count++">Count up</button>
|
|
27
|
+
<button class="button ghost" :disabled="count === 0" @click="count = 0">Reset</button>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="count">{{ clicks }}</div>
|
|
30
|
+
</section>
|
|
31
|
+
<p v-if="greeting" class="hint">{{ greeting }}</p>
|
|
32
|
+
</main>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.page {
|
|
37
|
+
height: 100%;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
gap: 20px;
|
|
43
|
+
padding: 32px;
|
|
44
|
+
color: #f4f4f5;
|
|
45
|
+
font-family: "Segoe UI", system-ui, sans-serif;
|
|
46
|
+
}
|
|
47
|
+
.card {
|
|
48
|
+
width: 380px;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 14px;
|
|
53
|
+
padding: 36px 32px 28px;
|
|
54
|
+
border-radius: 20px;
|
|
55
|
+
background: #18181bb3;
|
|
56
|
+
border: 1px solid #ffffff14;
|
|
57
|
+
box-shadow: 0 24px 60px #00000066;
|
|
58
|
+
}
|
|
59
|
+
.logo {
|
|
60
|
+
width: 64px;
|
|
61
|
+
height: 64px;
|
|
62
|
+
border-radius: 18px;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
font-size: 30px;
|
|
67
|
+
font-weight: 700;
|
|
68
|
+
color: #ffffff;
|
|
69
|
+
background: linear-gradient(135deg, #42b883, #2f6fd8);
|
|
70
|
+
box-shadow: 0 10px 28px #2f6fd855;
|
|
71
|
+
animation: float 4s ease-in-out infinite;
|
|
72
|
+
}
|
|
73
|
+
@keyframes float {
|
|
74
|
+
50% {
|
|
75
|
+
transform: translateY(-5px);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.title {
|
|
79
|
+
margin: 0;
|
|
80
|
+
font-size: 26px;
|
|
81
|
+
font-weight: 700;
|
|
82
|
+
}
|
|
83
|
+
.lead {
|
|
84
|
+
margin: 0;
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
line-height: 21px;
|
|
87
|
+
color: #a1a1aa;
|
|
88
|
+
text-align: center;
|
|
89
|
+
}
|
|
90
|
+
.code {
|
|
91
|
+
font-family: "Cascadia Mono", Consolas, monospace;
|
|
92
|
+
font-size: 13px;
|
|
93
|
+
color: #d4d4d8;
|
|
94
|
+
}
|
|
95
|
+
.actions {
|
|
96
|
+
display: flex;
|
|
97
|
+
gap: 10px;
|
|
98
|
+
margin-top: 8px;
|
|
99
|
+
}
|
|
100
|
+
.button {
|
|
101
|
+
padding: 9px 20px;
|
|
102
|
+
border-radius: 10px;
|
|
103
|
+
border-width: 0;
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
color: #ffffff;
|
|
107
|
+
background: linear-gradient(135deg, #42b883, #2f6fd8);
|
|
108
|
+
box-shadow: 0 6px 18px #2f6fd840;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
transition:
|
|
111
|
+
transform 120ms ease,
|
|
112
|
+
box-shadow 120ms ease;
|
|
113
|
+
}
|
|
114
|
+
.button:hover {
|
|
115
|
+
transform: translateY(-1px);
|
|
116
|
+
box-shadow: 0 10px 24px #2f6fd866;
|
|
117
|
+
}
|
|
118
|
+
.button:active {
|
|
119
|
+
transform: scale(0.97);
|
|
120
|
+
}
|
|
121
|
+
.button.ghost {
|
|
122
|
+
color: #d4d4d8;
|
|
123
|
+
background: #ffffff10;
|
|
124
|
+
box-shadow: none;
|
|
125
|
+
}
|
|
126
|
+
.button.ghost:hover {
|
|
127
|
+
background: #ffffff1c;
|
|
128
|
+
}
|
|
129
|
+
.button:disabled {
|
|
130
|
+
opacity: 0.4;
|
|
131
|
+
cursor: default;
|
|
132
|
+
}
|
|
133
|
+
.count {
|
|
134
|
+
font-size: 13px;
|
|
135
|
+
color: #71717a;
|
|
136
|
+
}
|
|
137
|
+
.hint {
|
|
138
|
+
margin: 0;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
color: #71717a;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Loaded at run time from assets/hello.txt, packaged with {{productName}}.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { appDevtools } from "@skathi-native/runtime";
|
|
3
|
+
import { computed } from "vue";
|
|
4
|
+
import { useRoute } from "vue-router";
|
|
5
|
+
import Icon from "./components/Icon.vue";
|
|
6
|
+
import Titlebar from "./components/Titlebar.vue";
|
|
7
|
+
import { pages } from "./router";
|
|
8
|
+
|
|
9
|
+
const devtools = appDevtools.available && appDevtools.isEnabled();
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const current = computed(() => pages.find((p) => p.path === route.path)?.title ?? "");
|
|
12
|
+
|
|
13
|
+
const sections = computed(() => {
|
|
14
|
+
const out = new Map<string, typeof pages>();
|
|
15
|
+
for (const page of pages) out.set(page.section, [...(out.get(page.section) ?? []), page]);
|
|
16
|
+
return [...out];
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div class="app">
|
|
22
|
+
<Titlebar :page="current" />
|
|
23
|
+
<div class="body">
|
|
24
|
+
<nav class="sidebar">
|
|
25
|
+
<div v-for="[section, items] in sections" :key="section" class="section">
|
|
26
|
+
<div v-if="section" class="section-title">{{ section }}</div>
|
|
27
|
+
<RouterLink v-for="page in items" :key="page.path" :to="page.path" class="link">
|
|
28
|
+
<Icon :name="page.icon" />
|
|
29
|
+
<span>{{ page.title }}</span>
|
|
30
|
+
</RouterLink>
|
|
31
|
+
</div>
|
|
32
|
+
<div v-if="devtools" class="foot">F12 opens the devtools</div>
|
|
33
|
+
</nav>
|
|
34
|
+
<main class="content">
|
|
35
|
+
<RouterView v-slot="{ Component }">
|
|
36
|
+
<Transition name="page" mode="out-in">
|
|
37
|
+
<component :is="Component" />
|
|
38
|
+
</Transition>
|
|
39
|
+
</RouterView>
|
|
40
|
+
</main>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.app {
|
|
47
|
+
height: 100%;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
background: #0b0b10a6;
|
|
51
|
+
color: var(--text);
|
|
52
|
+
font-family: var(--font);
|
|
53
|
+
}
|
|
54
|
+
.body {
|
|
55
|
+
flex: 1;
|
|
56
|
+
min-height: 0;
|
|
57
|
+
display: flex;
|
|
58
|
+
}
|
|
59
|
+
.sidebar {
|
|
60
|
+
width: 210px;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
gap: 14px;
|
|
64
|
+
padding: 14px 10px;
|
|
65
|
+
border-right: 1px solid var(--line);
|
|
66
|
+
background: #00000026;
|
|
67
|
+
overflow-y: auto;
|
|
68
|
+
}
|
|
69
|
+
.section {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: 2px;
|
|
73
|
+
}
|
|
74
|
+
.section-title {
|
|
75
|
+
padding: 0 10px 4px;
|
|
76
|
+
font-size: 11px;
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
letter-spacing: 0.6px;
|
|
79
|
+
text-transform: uppercase;
|
|
80
|
+
color: var(--text-faint);
|
|
81
|
+
}
|
|
82
|
+
.link {
|
|
83
|
+
height: 32px;
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 10px;
|
|
87
|
+
padding: 0 10px;
|
|
88
|
+
border-radius: 8px;
|
|
89
|
+
font-size: 13px;
|
|
90
|
+
color: var(--text-muted);
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
transition:
|
|
93
|
+
background-color 120ms ease,
|
|
94
|
+
color 120ms ease;
|
|
95
|
+
}
|
|
96
|
+
.link:hover {
|
|
97
|
+
background: var(--surface-hover);
|
|
98
|
+
color: var(--text);
|
|
99
|
+
}
|
|
100
|
+
.link.router-link-exact-active {
|
|
101
|
+
background: var(--accent-soft);
|
|
102
|
+
color: #ffffff;
|
|
103
|
+
}
|
|
104
|
+
.foot {
|
|
105
|
+
margin-top: auto;
|
|
106
|
+
padding: 8px 10px 0;
|
|
107
|
+
font-size: 11px;
|
|
108
|
+
color: var(--text-faint);
|
|
109
|
+
}
|
|
110
|
+
.content {
|
|
111
|
+
flex: 1;
|
|
112
|
+
min-width: 0;
|
|
113
|
+
overflow-y: auto;
|
|
114
|
+
}
|
|
115
|
+
.page-enter-active,
|
|
116
|
+
.page-leave-active {
|
|
117
|
+
transition:
|
|
118
|
+
opacity 140ms ease,
|
|
119
|
+
transform 140ms ease;
|
|
120
|
+
}
|
|
121
|
+
.page-enter-from {
|
|
122
|
+
opacity: 0;
|
|
123
|
+
transform: translateY(6px);
|
|
124
|
+
}
|
|
125
|
+
.page-leave-to {
|
|
126
|
+
opacity: 0;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{ title: string; api?: string }>();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div class="card">
|
|
7
|
+
<div class="top">
|
|
8
|
+
<span class="title">{{ title }}</span>
|
|
9
|
+
<span v-if="api" class="api">{{ api }}</span>
|
|
10
|
+
</div>
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<style scoped>
|
|
16
|
+
.card {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 12px;
|
|
20
|
+
padding: 18px;
|
|
21
|
+
border-radius: var(--radius);
|
|
22
|
+
border: 1px solid var(--line);
|
|
23
|
+
background: var(--surface);
|
|
24
|
+
}
|
|
25
|
+
.top {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
gap: 12px;
|
|
30
|
+
}
|
|
31
|
+
.title {
|
|
32
|
+
font-size: 14px;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
color: var(--text);
|
|
35
|
+
}
|
|
36
|
+
.api {
|
|
37
|
+
font-family: var(--mono);
|
|
38
|
+
font-size: 11px;
|
|
39
|
+
color: var(--text-faint);
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { icons, type IconName } from "../icons";
|
|
3
|
+
|
|
4
|
+
defineProps<{ name: IconName }>();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<svg
|
|
9
|
+
class="icon"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
width="16"
|
|
12
|
+
height="16"
|
|
13
|
+
viewBox="0 0 24 24"
|
|
14
|
+
fill="none"
|
|
15
|
+
stroke="currentColor"
|
|
16
|
+
stroke-width="1.8"
|
|
17
|
+
stroke-linecap="round"
|
|
18
|
+
stroke-linejoin="round"
|
|
19
|
+
>
|
|
20
|
+
<path :d="icons[name]" />
|
|
21
|
+
</svg>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<style scoped>
|
|
25
|
+
.icon {
|
|
26
|
+
width: 16px;
|
|
27
|
+
height: 16px;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{ part: string }>();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div class="missing">
|
|
7
|
+
<span class="pill warn">{{ part }} left out</span>
|
|
8
|
+
<span class="muted">
|
|
9
|
+
This build has no <span class="mono">{{ part }}</span> engine part: sk.config.json lists it under
|
|
10
|
+
<span class="mono">"windows": { "without": [...] }</span>, which keeps the exe smaller. Take it out of that list
|
|
11
|
+
to bring the API back.
|
|
12
|
+
</span>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style scoped>
|
|
17
|
+
.missing {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 12px;
|
|
21
|
+
padding: 14px;
|
|
22
|
+
border-radius: 10px;
|
|
23
|
+
border: 1px dashed #fbbf2440;
|
|
24
|
+
background: #fbbf240a;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{ title: string; lead: string }>();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<section class="page">
|
|
7
|
+
<header class="head">
|
|
8
|
+
<h1 class="title">{{ title }}</h1>
|
|
9
|
+
<p class="lead">{{ lead }}</p>
|
|
10
|
+
</header>
|
|
11
|
+
<slot />
|
|
12
|
+
</section>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<style scoped>
|
|
16
|
+
.page {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 16px;
|
|
20
|
+
padding: 28px 32px 40px;
|
|
21
|
+
}
|
|
22
|
+
.head {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: 6px;
|
|
26
|
+
margin-bottom: 4px;
|
|
27
|
+
}
|
|
28
|
+
.title {
|
|
29
|
+
margin: 0;
|
|
30
|
+
font-size: 24px;
|
|
31
|
+
font-weight: 700;
|
|
32
|
+
color: var(--text);
|
|
33
|
+
}
|
|
34
|
+
.lead {
|
|
35
|
+
margin: 0;
|
|
36
|
+
max-width: 640px;
|
|
37
|
+
font-size: 14px;
|
|
38
|
+
line-height: 21px;
|
|
39
|
+
color: var(--text-muted);
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// sk.config.json sets "titleBarStyle": "hidden", so the app paints its own caption: `window-drag: move` makes the
|
|
3
|
+
// strip drag the window, and `--window-control` on each button gives it the OS behaviour (snap layouts on maximize).
|
|
4
|
+
import { appWindow } from "@skathi-native/runtime";
|
|
5
|
+
import { onMounted, onUnmounted, ref } from "vue";
|
|
6
|
+
import { nav } from "../engine";
|
|
7
|
+
import { productName } from "../product";
|
|
8
|
+
|
|
9
|
+
defineProps<{ page: string }>();
|
|
10
|
+
|
|
11
|
+
const hostControls = ref(appWindow.chrome.hostControls);
|
|
12
|
+
const maximized = ref(appWindow.isMaximized());
|
|
13
|
+
const read = () => {
|
|
14
|
+
hostControls.value = appWindow.chrome.hostControls;
|
|
15
|
+
maximized.value = appWindow.isMaximized();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
onMounted(() => {
|
|
19
|
+
nav.windowControlsOverlay.addEventListener("geometrychange", read);
|
|
20
|
+
appWindow.addEventListener("maximize", read);
|
|
21
|
+
appWindow.addEventListener("unmaximize", read);
|
|
22
|
+
});
|
|
23
|
+
onUnmounted(() => {
|
|
24
|
+
nav.windowControlsOverlay.removeEventListener("geometrychange", read);
|
|
25
|
+
appWindow.removeEventListener("maximize", read);
|
|
26
|
+
appWindow.removeEventListener("unmaximize", read);
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<header class="titlebar">
|
|
32
|
+
<div class="brand">
|
|
33
|
+
<span class="mark">{{ productName.charAt(0) }}</span>
|
|
34
|
+
<span class="name">{{ productName }}</span>
|
|
35
|
+
<span class="sep">/</span>
|
|
36
|
+
<span class="page">{{ page }}</span>
|
|
37
|
+
</div>
|
|
38
|
+
<div v-if="!hostControls" class="controls">
|
|
39
|
+
<div class="control minimize" title="Minimize">
|
|
40
|
+
<svg width="10" height="10" viewBox="0 0 10 10"><path d="M0 5h10" stroke="currentColor" /></svg>
|
|
41
|
+
</div>
|
|
42
|
+
<div class="control maximize" :title="maximized ? 'Restore' : 'Maximize'">
|
|
43
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none">
|
|
44
|
+
<path v-if="maximized" d="M2.5 2.5V.5h7v7h-2 M.5 2.5h7v7h-7z" stroke="currentColor" />
|
|
45
|
+
<path v-else d="M.5 .5h9v9h-9z" stroke="currentColor" />
|
|
46
|
+
</svg>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="control close" title="Close">
|
|
49
|
+
<svg width="10" height="10" viewBox="0 0 10 10"><path d="M0 0l10 10M10 0 0 10" stroke="currentColor" /></svg>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</header>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<style scoped>
|
|
56
|
+
.titlebar {
|
|
57
|
+
height: env(titlebar-area-height, 40px);
|
|
58
|
+
padding-left: env(titlebar-area-x, 0px);
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
window-drag: move;
|
|
63
|
+
user-select: none;
|
|
64
|
+
border-bottom: 1px solid var(--line);
|
|
65
|
+
}
|
|
66
|
+
.brand {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: 10px;
|
|
70
|
+
padding-left: 14px;
|
|
71
|
+
font-size: 12px;
|
|
72
|
+
}
|
|
73
|
+
.mark {
|
|
74
|
+
width: 20px;
|
|
75
|
+
height: 20px;
|
|
76
|
+
border-radius: 6px;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
background: linear-gradient(135deg, var(--accent), #b48cff);
|
|
81
|
+
color: #ffffff;
|
|
82
|
+
font-size: 11px;
|
|
83
|
+
font-weight: 700;
|
|
84
|
+
}
|
|
85
|
+
.name {
|
|
86
|
+
font-weight: 600;
|
|
87
|
+
color: var(--text);
|
|
88
|
+
}
|
|
89
|
+
.sep {
|
|
90
|
+
color: var(--text-faint);
|
|
91
|
+
}
|
|
92
|
+
.page {
|
|
93
|
+
color: var(--text-muted);
|
|
94
|
+
}
|
|
95
|
+
.controls {
|
|
96
|
+
height: 100%;
|
|
97
|
+
display: flex;
|
|
98
|
+
window-drag: none;
|
|
99
|
+
}
|
|
100
|
+
.control {
|
|
101
|
+
width: 46px;
|
|
102
|
+
height: 100%;
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
color: var(--text-muted);
|
|
107
|
+
transition:
|
|
108
|
+
background-color 120ms ease,
|
|
109
|
+
color 120ms ease;
|
|
110
|
+
}
|
|
111
|
+
.control:hover {
|
|
112
|
+
background: var(--surface-strong);
|
|
113
|
+
color: var(--text);
|
|
114
|
+
}
|
|
115
|
+
.minimize {
|
|
116
|
+
--window-control: minimize;
|
|
117
|
+
}
|
|
118
|
+
.maximize {
|
|
119
|
+
--window-control: maximize;
|
|
120
|
+
}
|
|
121
|
+
.close {
|
|
122
|
+
--window-control: close;
|
|
123
|
+
}
|
|
124
|
+
.close:hover {
|
|
125
|
+
background: #c42b1c;
|
|
126
|
+
color: #ffffff;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The web surface the pages use, resolved once. Engine parts an app leaves out ("windows": { "without": [...] }
|
|
2
|
+
// in sk.config.json) are absent globals rather than stubs, so each one is `null` here when its part is out.
|
|
3
|
+
|
|
4
|
+
function required<T>(value: T | undefined, name: string): T {
|
|
5
|
+
if (value === undefined) throw new Error(`${name} is missing: this code runs in a Skathi window`);
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const nav = required(typeof navigator === "object" ? navigator : undefined, "navigator");
|
|
10
|
+
export const dom = required(
|
|
11
|
+
typeof document === "object" ? document : undefined,
|
|
12
|
+
"document",
|
|
13
|
+
) as unknown as SkDomDocument;
|
|
14
|
+
export const http = required(typeof fetch === "function" ? fetch : undefined, "fetch");
|
|
15
|
+
|
|
16
|
+
export const audio = typeof AudioContext === "function" ? AudioContext : null;
|
|
17
|
+
export const clipboard = typeof nav.clipboard === "object" ? nav.clipboard : null;
|
|
18
|
+
export const storage = typeof localStorage === "object" ? localStorage : null;
|
|
19
|
+
export const idb = typeof indexedDB === "object" ? indexedDB : null;
|
|
20
|
+
export const gpu = nav.gpu ?? null;
|
|
21
|
+
|
|
22
|
+
/** Calls `draw` once per painted frame until the returned function is called. */
|
|
23
|
+
export function everyFrame(draw: (time: number) => void): () => void {
|
|
24
|
+
const request = required(typeof requestAnimationFrame === "function" ? requestAnimationFrame : undefined, "rAF");
|
|
25
|
+
const cancel = required(typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : undefined, "cAF");
|
|
26
|
+
let handle = request(function frame(time) {
|
|
27
|
+
draw(time);
|
|
28
|
+
handle = request(frame);
|
|
29
|
+
});
|
|
30
|
+
return () => cancel(handle);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const describe = (e: unknown) => (e instanceof Error ? e.message : String(e));
|