@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.
Files changed (81) hide show
  1. package/aot-inputs.ts +294 -0
  2. package/ascii.ts +397 -0
  3. package/build.ts +1236 -0
  4. package/check/builtins.json +1219 -0
  5. package/check/builtins.ts +112 -0
  6. package/check/codes.ts +178 -0
  7. package/check/command.ts +105 -0
  8. package/check/config.ts +76 -0
  9. package/check/finding.ts +30 -0
  10. package/check/graph.ts +69 -0
  11. package/check/highlight.ts +40 -0
  12. package/check/index.ts +308 -0
  13. package/check/packages.ts +54 -0
  14. package/check/program.ts +209 -0
  15. package/check/report.ts +219 -0
  16. package/check/rules.ts +307 -0
  17. package/check/schema.ts +69 -0
  18. package/check/typing.ts +703 -0
  19. package/cli/assets.ts +114 -0
  20. package/cli/build-app.ts +587 -0
  21. package/cli/config.ts +646 -0
  22. package/cli/create.ts +327 -0
  23. package/cli/dev.ts +92 -0
  24. package/cli/elf.ts +142 -0
  25. package/cli/help.ts +160 -0
  26. package/cli/host-fetch.ts +178 -0
  27. package/cli/host.ts +378 -0
  28. package/cli/icon.ts +303 -0
  29. package/cli/macos-bundle.ts +451 -0
  30. package/cli/pe.ts +429 -0
  31. package/cli/platform.ts +74 -0
  32. package/cli/sk.ts +290 -0
  33. package/cli/skpk.ts +268 -0
  34. package/cli/stamp.ts +254 -0
  35. package/cli/term.ts +176 -0
  36. package/cli/versioninfo.ts +123 -0
  37. package/css-prefixes.ts +118 -0
  38. package/devtools/apps.ts +68 -0
  39. package/devtools/commands.ts +860 -0
  40. package/devtools/ctl.ts +166 -0
  41. package/package.json +52 -3
  42. package/prod.ts +701 -0
  43. package/runtime-path.ts +24 -0
  44. package/tailwind.ts +76 -0
  45. package/templates/minimal/assets/hello.txt +1 -0
  46. package/templates/minimal/src/App.vue +142 -0
  47. package/templates/minimal/src/main.ts +4 -0
  48. package/templates/showcase/assets/hello.txt +1 -0
  49. package/templates/showcase/assets/media/aurora.png +0 -0
  50. package/templates/showcase/assets/media/clip.mp4 +0 -0
  51. package/templates/showcase/assets/media/sticker.tgs +0 -0
  52. package/templates/showcase/src/App.vue +128 -0
  53. package/templates/showcase/src/components/Card.vue +41 -0
  54. package/templates/showcase/src/components/Icon.vue +29 -0
  55. package/templates/showcase/src/components/Missing.vue +26 -0
  56. package/templates/showcase/src/components/Page.vue +41 -0
  57. package/templates/showcase/src/components/Titlebar.vue +128 -0
  58. package/templates/showcase/src/engine.ts +33 -0
  59. package/templates/showcase/src/icons.ts +22 -0
  60. package/templates/showcase/src/main.ts +7 -0
  61. package/templates/showcase/src/pages/AudioPage.vue +124 -0
  62. package/templates/showcase/src/pages/FilesPage.vue +91 -0
  63. package/templates/showcase/src/pages/FormsPage.vue +139 -0
  64. package/templates/showcase/src/pages/GraphicsPage.vue +156 -0
  65. package/templates/showcase/src/pages/HomePage.vue +141 -0
  66. package/templates/showcase/src/pages/LocalePage.vue +71 -0
  67. package/templates/showcase/src/pages/MediaPage.vue +85 -0
  68. package/templates/showcase/src/pages/MotionPage.vue +199 -0
  69. package/templates/showcase/src/pages/NetworkPage.vue +103 -0
  70. package/templates/showcase/src/pages/PermissionsPage.vue +80 -0
  71. package/templates/showcase/src/pages/StoragePage.vue +117 -0
  72. package/templates/showcase/src/pages/StylesPage.vue +199 -0
  73. package/templates/showcase/src/pages/SystemPage.vue +89 -0
  74. package/templates/showcase/src/pages/TrayPage.vue +66 -0
  75. package/templates/showcase/src/pages/WindowPage.vue +128 -0
  76. package/templates/showcase/src/product.ts +2 -0
  77. package/templates/showcase/src/router.ts +149 -0
  78. package/templates/showcase/src/stores/counter.ts +9 -0
  79. package/templates/showcase/src/stores/desktop.ts +115 -0
  80. package/templates/showcase/src/styles.css +140 -0
  81. package/vitecompat.ts +1151 -0
@@ -0,0 +1,115 @@
1
+ // The tray icon and the global hotkey outlive the page that turns them on, so their state lives here.
2
+ import { appHotkeys, appTray, appWindow, type HotkeyChord, type TrayPixels } from "@skathi-native/runtime";
3
+ import { defineStore } from "pinia";
4
+ import { ref, watch } from "vue";
5
+ import { productName } from "../product";
6
+ import { useCounter } from "./counter";
7
+
8
+ const CTRL = 0x11;
9
+ const SHIFT = 0x10;
10
+ const KEY_K = 0x4b;
11
+ export const DEFAULT_CHORD: HotkeyChord = {
12
+ buttons: [
13
+ { device: 0, code: CTRL },
14
+ { device: 0, code: SHIFT },
15
+ { device: 0, code: KEY_K },
16
+ ],
17
+ };
18
+
19
+ const KEY_NAMES: Record<number, string> = {
20
+ 0x10: "Shift",
21
+ 0xa0: "Shift",
22
+ 0xa1: "Shift",
23
+ 0x11: "Ctrl",
24
+ 0xa2: "Ctrl",
25
+ 0xa3: "Ctrl",
26
+ 0x12: "Alt",
27
+ 0xa4: "Alt",
28
+ 0xa5: "Alt",
29
+ 0x5b: "Win",
30
+ 0x5c: "Win",
31
+ 0x20: "Space",
32
+ 0x0d: "Enter",
33
+ 0x09: "Tab",
34
+ };
35
+
36
+ /** Virtual-key codes on every platform: letters and digits are their ASCII codes, F1 is 0x70. */
37
+ export function chordLabel(chord: HotkeyChord): string {
38
+ return chord.buttons
39
+ .map(({ device, code }) => {
40
+ if (device === 1) return `Mouse ${code}`;
41
+ if ((code >= 0x30 && code <= 0x39) || (code >= 0x41 && code <= 0x5a)) return String.fromCharCode(code);
42
+ if (code >= 0x70 && code <= 0x87) return `F${code - 0x6f}`;
43
+ return KEY_NAMES[code] ?? `0x${code.toString(16)}`;
44
+ })
45
+ .join(" + ");
46
+ }
47
+
48
+ function trayIcon(): TrayPixels {
49
+ const size = 32;
50
+ const data = new Uint8Array(size * size * 4);
51
+ for (let y = 0; y < size; y++) {
52
+ for (let x = 0; x < size; x++) {
53
+ const dx = Math.max(0, Math.abs(x - 15.5) - 8);
54
+ const dy = Math.max(0, Math.abs(y - 15.5) - 8);
55
+ const t = (x + y) / (2 * size);
56
+ const o = (y * size + x) * 4;
57
+ data[o] = Math.round(0x8b - 0x1e * t);
58
+ data[o + 1] = Math.round(0x9d - 0x21 * t);
59
+ data[o + 2] = 0xff;
60
+ data[o + 3] = dx * dx + dy * dy <= 64 ? 255 : 0;
61
+ }
62
+ }
63
+ return { width: size, height: size, data };
64
+ }
65
+
66
+ export const useDesktop = defineStore("desktop", () => {
67
+ const counter = useCounter();
68
+ const trayShown = ref(false);
69
+ const chord = ref<HotkeyChord | null>(null);
70
+ const presses = ref(0);
71
+
72
+ function showTray(on: boolean) {
73
+ trayShown.value = on;
74
+ if (!on) {
75
+ appTray.set(null);
76
+ return;
77
+ }
78
+ appTray.set({
79
+ icon: trayIcon(),
80
+ tooltip: productName,
81
+ onClick: () => appWindow.show(),
82
+ menu: [
83
+ { label: `Open ${productName}`, default: true, onSelect: () => appWindow.show() },
84
+ { label: `Count up (${counter.count})`, onSelect: counter.increment },
85
+ { label: "Always on top", checked: appWindow.alwaysOnTop, onSelect: toggleOnTop },
86
+ { type: "separator" },
87
+ { role: "quit" },
88
+ ],
89
+ });
90
+ }
91
+
92
+ function toggleOnTop() {
93
+ appWindow.alwaysOnTop = !appWindow.alwaysOnTop;
94
+ showTray(true);
95
+ }
96
+
97
+ // The tray has no reactive model: a new menu is set whenever what it shows changes.
98
+ watch(
99
+ () => counter.count,
100
+ () => trayShown.value && showTray(true),
101
+ );
102
+
103
+ let unlisten: (() => void) | null = null;
104
+ function bindHotkey(next: HotkeyChord | null) {
105
+ appHotkeys.setBindings(next ? [{ id: "count-up", chord: next, triggerCooldownMs: 150 }] : []);
106
+ chord.value = next;
107
+ unlisten ??= appHotkeys.onFired((event) => {
108
+ if (event.id !== "count-up" || event.phase !== "down") return;
109
+ presses.value++;
110
+ counter.increment();
111
+ });
112
+ }
113
+
114
+ return { trayShown, chord, presses, showTray, bindHotkey };
115
+ });
@@ -0,0 +1,140 @@
1
+ :root {
2
+ --text: #ececf1;
3
+ --text-muted: #a1a1aa;
4
+ --text-faint: #71717a;
5
+ --surface: #ffffff08;
6
+ --surface-hover: #ffffff10;
7
+ --surface-strong: #ffffff18;
8
+ --line: #ffffff12;
9
+ --line-strong: #ffffff24;
10
+ --accent: #8b9dff;
11
+ --accent-strong: #6d7cff;
12
+ --accent-soft: #8b9dff24;
13
+ --ok: #4ade80;
14
+ --warn: #fbbf24;
15
+ --bad: #f87171;
16
+ --radius: 14px;
17
+ --font: "Segoe UI", system-ui, sans-serif;
18
+ --mono: "Cascadia Mono", Consolas, monospace;
19
+ }
20
+
21
+ .row {
22
+ display: flex;
23
+ flex-wrap: wrap;
24
+ align-items: center;
25
+ gap: 8px;
26
+ }
27
+ .stack {
28
+ display: flex;
29
+ flex-direction: column;
30
+ gap: 10px;
31
+ }
32
+ .muted {
33
+ font-size: 13px;
34
+ line-height: 19px;
35
+ color: var(--text-muted);
36
+ }
37
+ .faint {
38
+ font-size: 12px;
39
+ color: var(--text-faint);
40
+ }
41
+ .mono {
42
+ font-family: var(--mono);
43
+ font-size: 12px;
44
+ }
45
+
46
+ .btn {
47
+ height: 32px;
48
+ padding: 0 14px;
49
+ display: flex;
50
+ align-items: center;
51
+ justify-content: center;
52
+ gap: 6px;
53
+ border-radius: 9px;
54
+ border: 1px solid var(--line);
55
+ background: var(--surface-hover);
56
+ color: var(--text);
57
+ font-size: 13px;
58
+ cursor: pointer;
59
+ transition:
60
+ background-color 120ms ease,
61
+ border-color 120ms ease,
62
+ transform 120ms ease;
63
+ }
64
+ .btn:hover {
65
+ background: var(--surface-strong);
66
+ border-color: var(--line-strong);
67
+ }
68
+ .btn:active {
69
+ transform: scale(0.97);
70
+ }
71
+ .btn:disabled {
72
+ opacity: 0.45;
73
+ cursor: default;
74
+ }
75
+ .btn.primary {
76
+ border-color: #ffffff20;
77
+ background: linear-gradient(135deg, var(--accent), var(--accent-strong));
78
+ box-shadow: 0 6px 18px #6d7cff40;
79
+ color: #ffffff;
80
+ font-weight: 600;
81
+ }
82
+ .btn.primary:hover {
83
+ box-shadow: 0 8px 24px #6d7cff66;
84
+ }
85
+ .btn.on {
86
+ border-color: #8b9dff80;
87
+ background: var(--accent-soft);
88
+ color: #ffffff;
89
+ }
90
+
91
+ .input {
92
+ height: 34px;
93
+ padding: 0 12px;
94
+ border-radius: 9px;
95
+ border: 1px solid var(--line);
96
+ background: #00000040;
97
+ color: var(--text);
98
+ font-size: 13px;
99
+ transition: border-color 120ms ease;
100
+ }
101
+ .input:hover {
102
+ border-color: var(--line-strong);
103
+ }
104
+ .input:focus {
105
+ border-color: var(--accent);
106
+ }
107
+
108
+ .pill {
109
+ padding: 3px 9px;
110
+ border-radius: 999px;
111
+ background: var(--surface-strong);
112
+ color: var(--text-muted);
113
+ font-size: 11px;
114
+ }
115
+ .pill.ok {
116
+ background: #4ade8022;
117
+ color: var(--ok);
118
+ }
119
+ .pill.warn {
120
+ background: #fbbf2422;
121
+ color: var(--warn);
122
+ }
123
+ .pill.bad {
124
+ background: #f8717122;
125
+ color: var(--bad);
126
+ }
127
+
128
+ .kv {
129
+ display: flex;
130
+ gap: 12px;
131
+ font-size: 13px;
132
+ }
133
+ .kv .k {
134
+ width: 150px;
135
+ color: var(--text-faint);
136
+ }
137
+ .kv .v {
138
+ flex: 1;
139
+ color: var(--text);
140
+ }