@loccal/ui 0.0.0-stage → 0.3.0
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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +38 -3
- package/dist/components/ui/accordion.d.ts +6 -0
- package/dist/components/ui/accordion.js +17 -0
- package/dist/components/ui/ai-panel.d.ts +47 -0
- package/dist/components/ui/ai-panel.js +74 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert-dialog.js +42 -0
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/alert.js +27 -0
- package/dist/components/ui/avatar.d.ts +11 -0
- package/dist/components/ui/avatar.js +23 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/badge.js +36 -0
- package/dist/components/ui/breadcrumb.d.ts +10 -0
- package/dist/components/ui/breadcrumb.js +36 -0
- package/dist/components/ui/button-group.d.ts +10 -0
- package/dist/components/ui/button-group.js +36 -0
- package/dist/components/ui/button.d.ts +8 -0
- package/dist/components/ui/button.js +34 -0
- package/dist/components/ui/calendar.d.ts +10 -0
- package/dist/components/ui/calendar.js +76 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/card.js +24 -0
- package/dist/components/ui/chart.d.ts +44 -0
- package/dist/components/ui/chart.js +132 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.js +9 -0
- package/dist/components/ui/code-view.d.ts +31 -0
- package/dist/components/ui/code-view.js +62 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +13 -0
- package/dist/components/ui/command-block.d.ts +28 -0
- package/dist/components/ui/command-block.js +58 -0
- package/dist/components/ui/command.d.ts +19 -0
- package/dist/components/ui/command.js +35 -0
- package/dist/components/ui/connection-status.d.ts +29 -0
- package/dist/components/ui/connection-status.js +26 -0
- package/dist/components/ui/context-menu.d.ts +29 -0
- package/dist/components/ui/context-menu.js +51 -0
- package/dist/components/ui/data-table.d.ts +49 -0
- package/dist/components/ui/data-table.js +100 -0
- package/dist/components/ui/dialog.d.ts +18 -0
- package/dist/components/ui/dialog.js +37 -0
- package/dist/components/ui/drawer.d.ts +16 -0
- package/dist/components/ui/drawer.js +75 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/dropdown-menu.js +51 -0
- package/dist/components/ui/dropzone.d.ts +11 -0
- package/dist/components/ui/dropzone.js +39 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/empty.js +33 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +68 -0
- package/dist/components/ui/file-tree.d.ts +42 -0
- package/dist/components/ui/file-tree.js +88 -0
- package/dist/components/ui/file-type-icon.d.ts +16 -0
- package/dist/components/ui/file-type-icon.js +19 -0
- package/dist/components/ui/hash-chain.d.ts +43 -0
- package/dist/components/ui/hash-chain.js +34 -0
- package/dist/components/ui/history-palette.d.ts +37 -0
- package/dist/components/ui/history-palette.js +44 -0
- package/dist/components/ui/hover-card.d.ts +5 -0
- package/dist/components/ui/hover-card.js +14 -0
- package/dist/components/ui/icon-base.d.ts +15 -0
- package/dist/components/ui/icon-base.js +18 -0
- package/dist/components/ui/icon.d.ts +15 -0
- package/dist/components/ui/icon.js +32 -0
- package/dist/components/ui/icons-compat.d.ts +32 -0
- package/dist/components/ui/icons-compat.js +34 -0
- package/dist/components/ui/icons.d.ts +1048 -0
- package/dist/components/ui/icons.js +264 -0
- package/dist/components/ui/input-group.d.ts +18 -0
- package/dist/components/ui/input-group.js +57 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +21 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +7 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +9 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.js +7 -0
- package/dist/components/ui/locale-switch.d.ts +9 -0
- package/dist/components/ui/locale-switch.js +31 -0
- package/dist/components/ui/log-panel.d.ts +28 -0
- package/dist/components/ui/log-panel.js +59 -0
- package/dist/components/ui/menubar.d.ts +29 -0
- package/dist/components/ui/menubar.js +56 -0
- package/dist/components/ui/metric-grid.d.ts +20 -0
- package/dist/components/ui/metric-grid.js +14 -0
- package/dist/components/ui/model-list.d.ts +33 -0
- package/dist/components/ui/model-list.js +69 -0
- package/dist/components/ui/navigation-menu.d.ts +11 -0
- package/dist/components/ui/navigation-menu.js +31 -0
- package/dist/components/ui/number-field.d.ts +29 -0
- package/dist/components/ui/number-field.js +65 -0
- package/dist/components/ui/pagination.d.ts +17 -0
- package/dist/components/ui/pagination.js +26 -0
- package/dist/components/ui/pane-tree.d.ts +18 -0
- package/dist/components/ui/pane-tree.js +65 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +23 -0
- package/dist/components/ui/progress.d.ts +7 -0
- package/dist/components/ui/progress.js +20 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +12 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +14 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +11 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +34 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.js +8 -0
- package/dist/components/ui/settings-layout.d.ts +31 -0
- package/dist/components/ui/settings-layout.js +45 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.js +37 -0
- package/dist/components/ui/shell-picker.d.ts +18 -0
- package/dist/components/ui/shell-picker.js +17 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/slider.d.ts +3 -0
- package/dist/components/ui/slider.js +12 -0
- package/dist/components/ui/sonner.d.ts +3 -0
- package/dist/components/ui/sonner.js +25 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +7 -0
- package/dist/components/ui/split-button.d.ts +21 -0
- package/dist/components/ui/split-button.js +14 -0
- package/dist/components/ui/stat.d.ts +10 -0
- package/dist/components/ui/stat.js +8 -0
- package/dist/components/ui/status-bar.d.ts +13 -0
- package/dist/components/ui/status-bar.js +15 -0
- package/dist/components/ui/stepper.d.ts +13 -0
- package/dist/components/ui/stepper.js +11 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.js +8 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +28 -0
- package/dist/components/ui/tabs.d.ts +10 -0
- package/dist/components/ui/tabs.js +29 -0
- package/dist/components/ui/terminal-tabs.d.ts +31 -0
- package/dist/components/ui/terminal-tabs.js +109 -0
- package/dist/components/ui/terminal-view.d.ts +51 -0
- package/dist/components/ui/terminal-view.js +189 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +6 -0
- package/dist/components/ui/timeline.d.ts +9 -0
- package/dist/components/ui/timeline.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +11 -0
- package/dist/components/ui/toggle-group.js +24 -0
- package/dist/components/ui/toggle.d.ts +8 -0
- package/dist/components/ui/toggle.js +26 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.js +17 -0
- package/dist/components/ui/tree-view.d.ts +20 -0
- package/dist/components/ui/tree-view.js +41 -0
- package/dist/components/ui/window-frame.d.ts +35 -0
- package/dist/components/ui/window-frame.js +49 -0
- package/dist/lib/ai-markdown.d.ts +13 -0
- package/dist/lib/ai-markdown.js +46 -0
- package/dist/lib/command-risk.d.ts +6 -0
- package/dist/lib/command-risk.js +42 -0
- package/dist/lib/file-icons.d.ts +18 -0
- package/dist/lib/file-icons.js +136 -0
- package/dist/lib/file-kind.d.ts +10 -0
- package/dist/lib/file-kind.js +63 -0
- package/dist/lib/format.d.ts +9 -0
- package/dist/lib/format.js +30 -0
- package/dist/lib/i18n-core.d.ts +20 -0
- package/dist/lib/i18n-core.js +36 -0
- package/dist/lib/i18n.d.ts +15 -0
- package/dist/lib/i18n.js +68 -0
- package/dist/lib/icon-data.d.ts +276 -0
- package/dist/lib/icon-data.js +307 -0
- package/dist/lib/icon-shapes.d.ts +14 -0
- package/dist/lib/icon-shapes.js +47 -0
- package/dist/lib/log-filter.d.ts +23 -0
- package/dist/lib/log-filter.js +44 -0
- package/dist/lib/number-field.d.ts +11 -0
- package/dist/lib/number-field.js +30 -0
- package/dist/lib/pane-tree.d.ts +39 -0
- package/dist/lib/pane-tree.js +92 -0
- package/dist/lib/platform.d.ts +10 -0
- package/dist/lib/platform.js +24 -0
- package/dist/lib/shell-meta.d.ts +7 -0
- package/dist/lib/shell-meta.js +70 -0
- package/dist/lib/syntax.d.ts +16 -0
- package/dist/lib/syntax.js +540 -0
- package/dist/lib/tab-order.d.ts +6 -0
- package/dist/lib/tab-order.js +24 -0
- package/dist/lib/table-sort.d.ts +16 -0
- package/dist/lib/table-sort.js +66 -0
- package/dist/lib/terminal-themes.d.ts +30 -0
- package/dist/lib/terminal-themes.js +90 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist-cdn/loccal-ui.css +971 -0
- package/dist-cdn/loccal-ui.min.js +1 -0
- package/dist-wc/base.d.ts +31 -0
- package/dist-wc/base.js +104 -0
- package/dist-wc/button.d.ts +12 -0
- package/dist-wc/button.js +47 -0
- package/dist-wc/calendar.d.ts +16 -0
- package/dist-wc/calendar.js +106 -0
- package/dist-wc/choice.d.ts +17 -0
- package/dist-wc/choice.js +76 -0
- package/dist-wc/command.d.ts +32 -0
- package/dist-wc/command.js +181 -0
- package/dist-wc/data-table.d.ts +22 -0
- package/dist-wc/data-table.js +128 -0
- package/dist-wc/dialog.d.ts +29 -0
- package/dist-wc/dialog.js +94 -0
- package/dist-wc/disclosure.d.ts +17 -0
- package/dist-wc/disclosure.js +91 -0
- package/dist-wc/fields2.d.ts +38 -0
- package/dist-wc/fields2.js +133 -0
- package/dist-wc/file-tree.d.ts +19 -0
- package/dist-wc/file-tree.js +97 -0
- package/dist-wc/floating.d.ts +32 -0
- package/dist-wc/floating.js +91 -0
- package/dist-wc/index.d.ts +23 -0
- package/dist-wc/index.js +24 -0
- package/dist-wc/input-otp.d.ts +14 -0
- package/dist-wc/input-otp.js +82 -0
- package/dist-wc/navigation-menu.d.ts +14 -0
- package/dist-wc/navigation-menu.js +75 -0
- package/dist-wc/number-field.d.ts +13 -0
- package/dist-wc/number-field.js +67 -0
- package/dist-wc/resizable.d.ts +14 -0
- package/dist-wc/resizable.js +57 -0
- package/dist-wc/select.d.ts +17 -0
- package/dist-wc/select.js +80 -0
- package/dist-wc/static.d.ts +1 -0
- package/dist-wc/static.js +175 -0
- package/dist-wc/status-bar.d.ts +11 -0
- package/dist-wc/status-bar.js +54 -0
- package/dist-wc/styles.css +971 -0
- package/dist-wc/tabs.d.ts +16 -0
- package/dist-wc/tabs.js +62 -0
- package/dist-wc/terminal-tabs.d.ts +16 -0
- package/dist-wc/terminal-tabs.js +79 -0
- package/dist-wc/toaster.d.ts +16 -0
- package/dist-wc/toaster.js +68 -0
- package/dist-wc/toggle.d.ts +30 -0
- package/dist-wc/toggle.js +101 -0
- package/dist-wc/tree.d.ts +17 -0
- package/dist-wc/tree.js +72 -0
- package/docs/ARQUITETURA-VANILLA.md +54 -0
- package/docs/VERSIONING.md +88 -0
- package/package.json +1078 -6
- package/styles.css +476 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Arvore de paineis imutavel (splits recursivos). Sem dependencias de React:
|
|
2
|
+
// toda operacao devolve uma nova raiz e preserva por referencia os nos inalterados.
|
|
3
|
+
export const MIN_RATIO = 0.1;
|
|
4
|
+
export const MAX_RATIO = 0.9;
|
|
5
|
+
export function clampRatio(ratio) {
|
|
6
|
+
if (!Number.isFinite(ratio))
|
|
7
|
+
return 0.5;
|
|
8
|
+
return Math.min(MAX_RATIO, Math.max(MIN_RATIO, ratio));
|
|
9
|
+
}
|
|
10
|
+
export function leaf(id) {
|
|
11
|
+
return { type: "leaf", id };
|
|
12
|
+
}
|
|
13
|
+
/** Ids das folhas na ordem visual (primeiro -> segundo). */
|
|
14
|
+
export function leaves(node) {
|
|
15
|
+
if (node.type === "leaf")
|
|
16
|
+
return [node.id];
|
|
17
|
+
return [...leaves(node.first), ...leaves(node.second)];
|
|
18
|
+
}
|
|
19
|
+
export function hasLeaf(node, id) {
|
|
20
|
+
if (node.type === "leaf")
|
|
21
|
+
return node.id === id;
|
|
22
|
+
return hasLeaf(node.first, id) || hasLeaf(node.second, id);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Divide a folha `leafId`: ela vira `first` e a nova folha `newLeafId` vira `second`.
|
|
26
|
+
* `splitId` identifica o novo no de divisao. Se `leafId` nao existir, devolve a mesma raiz.
|
|
27
|
+
*/
|
|
28
|
+
export function splitLeaf(root, leafId, direction, newLeafId, splitId = `split-${newLeafId}`) {
|
|
29
|
+
if (root.type === "leaf") {
|
|
30
|
+
if (root.id !== leafId)
|
|
31
|
+
return root;
|
|
32
|
+
return { type: "split", id: splitId, direction, ratio: 0.5, first: root, second: leaf(newLeafId) };
|
|
33
|
+
}
|
|
34
|
+
const first = splitLeaf(root.first, leafId, direction, newLeafId, splitId);
|
|
35
|
+
if (first !== root.first)
|
|
36
|
+
return { ...root, first };
|
|
37
|
+
const second = splitLeaf(root.second, leafId, direction, newLeafId, splitId);
|
|
38
|
+
if (second !== root.second)
|
|
39
|
+
return { ...root, second };
|
|
40
|
+
return root;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Remove a folha `leafId`; o irmao assume o lugar da divisao pai.
|
|
44
|
+
* Devolve `null` quando a ultima folha e removida.
|
|
45
|
+
*/
|
|
46
|
+
export function removeLeaf(root, leafId) {
|
|
47
|
+
if (root.type === "leaf")
|
|
48
|
+
return root.id === leafId ? null : root;
|
|
49
|
+
if (root.first.type === "leaf" && root.first.id === leafId)
|
|
50
|
+
return root.second;
|
|
51
|
+
if (root.second.type === "leaf" && root.second.id === leafId)
|
|
52
|
+
return root.first;
|
|
53
|
+
const first = removeLeaf(root.first, leafId);
|
|
54
|
+
if (first !== root.first)
|
|
55
|
+
return first === null ? root.second : { ...root, first };
|
|
56
|
+
const second = removeLeaf(root.second, leafId);
|
|
57
|
+
if (second !== root.second)
|
|
58
|
+
return second === null ? root.first : { ...root, second };
|
|
59
|
+
return root;
|
|
60
|
+
}
|
|
61
|
+
/** Ajusta a proporcao de uma divisao (com clamp). */
|
|
62
|
+
export function setRatio(root, splitId, ratio) {
|
|
63
|
+
if (root.type === "leaf")
|
|
64
|
+
return root;
|
|
65
|
+
if (root.id === splitId) {
|
|
66
|
+
const next = clampRatio(ratio);
|
|
67
|
+
return next === root.ratio ? root : { ...root, ratio: next };
|
|
68
|
+
}
|
|
69
|
+
const first = setRatio(root.first, splitId, ratio);
|
|
70
|
+
if (first !== root.first)
|
|
71
|
+
return { ...root, first };
|
|
72
|
+
const second = setRatio(root.second, splitId, ratio);
|
|
73
|
+
if (second !== root.second)
|
|
74
|
+
return { ...root, second };
|
|
75
|
+
return root;
|
|
76
|
+
}
|
|
77
|
+
/** Proxima folha (delta = 1) ou anterior (delta = -1), circular. */
|
|
78
|
+
export function cycleLeaf(root, currentId, delta) {
|
|
79
|
+
const ids = leaves(root);
|
|
80
|
+
const idx = ids.indexOf(currentId);
|
|
81
|
+
if (idx === -1)
|
|
82
|
+
return ids[0];
|
|
83
|
+
return ids[(idx + delta + ids.length) % ids.length];
|
|
84
|
+
}
|
|
85
|
+
/** Folha a ser focada depois de remover `removedId` (a vizinha na ordem visual). */
|
|
86
|
+
export function focusAfterRemoval(before, removedId) {
|
|
87
|
+
const ids = leaves(before);
|
|
88
|
+
const idx = ids.indexOf(removedId);
|
|
89
|
+
if (idx === -1 || ids.length <= 1)
|
|
90
|
+
return null;
|
|
91
|
+
return ids[idx === 0 ? 1 : idx - 1];
|
|
92
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Platform = "mac" | "windows" | "linux";
|
|
2
|
+
/** Detecta a plataforma pelo navegador/webview (Wails usa WebView2, WKWebView e WebKitGTK). Em SSR retorna `fallback`. */
|
|
3
|
+
export declare function detectPlatform(fallback?: Platform): Platform;
|
|
4
|
+
/** Rotulo da tecla modificadora principal: Command no macOS, Ctrl no Windows e Linux. */
|
|
5
|
+
export declare function modKeyLabel(platform: Platform): string;
|
|
6
|
+
/** Monta um atalho legivel: formatShortcut("linux", "K") => "Ctrl+K"; no macOS => "⌘K". */
|
|
7
|
+
export declare function formatShortcut(platform: Platform, key: string, opts?: {
|
|
8
|
+
shift?: boolean;
|
|
9
|
+
alt?: boolean;
|
|
10
|
+
}): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Detecta a plataforma pelo navegador/webview (Wails usa WebView2, WKWebView e WebKitGTK). Em SSR retorna `fallback`. */
|
|
2
|
+
export function detectPlatform(fallback = "windows") {
|
|
3
|
+
if (typeof navigator === "undefined")
|
|
4
|
+
return fallback;
|
|
5
|
+
const nav = navigator;
|
|
6
|
+
const raw = (nav.userAgentData?.platform ?? nav.platform ?? nav.userAgent ?? "").toLowerCase();
|
|
7
|
+
if (raw.includes("mac") || raw.includes("iphone") || raw.includes("ipad"))
|
|
8
|
+
return "mac";
|
|
9
|
+
if (raw.includes("win"))
|
|
10
|
+
return "windows";
|
|
11
|
+
if (raw.includes("linux") || raw.includes("x11") || raw.includes("cros"))
|
|
12
|
+
return "linux";
|
|
13
|
+
return fallback;
|
|
14
|
+
}
|
|
15
|
+
/** Rotulo da tecla modificadora principal: Command no macOS, Ctrl no Windows e Linux. */
|
|
16
|
+
export function modKeyLabel(platform) {
|
|
17
|
+
return platform === "mac" ? "⌘" : "Ctrl";
|
|
18
|
+
}
|
|
19
|
+
/** Monta um atalho legivel: formatShortcut("linux", "K") => "Ctrl+K"; no macOS => "⌘K". */
|
|
20
|
+
export function formatShortcut(platform, key, opts = {}) {
|
|
21
|
+
if (platform === "mac")
|
|
22
|
+
return `${opts.alt ? "⌥" : ""}${opts.shift ? "⇧" : ""}⌘${key}`;
|
|
23
|
+
return [modKeyLabel(platform), opts.alt ? "Alt" : "", opts.shift ? "Shift" : "", key].filter(Boolean).join("+");
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ShellKind = "powershell" | "pwsh" | "cmd" | "bash" | "wsl" | "zsh" | "fish" | "nu" | "other";
|
|
2
|
+
export declare function shellKind(shellPath: string): ShellKind;
|
|
3
|
+
export declare function shellLabel(shellPath: string): string;
|
|
4
|
+
/** Nome curto para titulo de aba. */
|
|
5
|
+
export declare function shellTabName(shellPath: string): string;
|
|
6
|
+
/** Escapa um caminho para uso em `cd` no shell indicado. */
|
|
7
|
+
export declare function quoteForShell(shellPath: string, target: string): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Rotulos amigaveis para os executaveis de shell detectados pelo backend.
|
|
2
|
+
function baseName(shellPath) {
|
|
3
|
+
return (shellPath.split(/[\\/]/).pop() || shellPath).toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
export function shellKind(shellPath) {
|
|
6
|
+
const base = baseName(shellPath);
|
|
7
|
+
if (base === "pwsh.exe" || base === "pwsh")
|
|
8
|
+
return "pwsh";
|
|
9
|
+
if (base === "powershell.exe" || base === "powershell")
|
|
10
|
+
return "powershell";
|
|
11
|
+
if (base === "cmd.exe" || base === "cmd")
|
|
12
|
+
return "cmd";
|
|
13
|
+
if (base === "wsl.exe" || base === "wsl")
|
|
14
|
+
return "wsl";
|
|
15
|
+
if (base === "nu.exe" || base === "nu")
|
|
16
|
+
return "nu";
|
|
17
|
+
if (base === "zsh")
|
|
18
|
+
return "zsh";
|
|
19
|
+
if (base === "fish")
|
|
20
|
+
return "fish";
|
|
21
|
+
if (base === "bash" || base === "bash.exe")
|
|
22
|
+
return "bash";
|
|
23
|
+
return "other";
|
|
24
|
+
}
|
|
25
|
+
export function shellLabel(shellPath) {
|
|
26
|
+
const lower = shellPath.toLowerCase();
|
|
27
|
+
const kind = shellKind(shellPath);
|
|
28
|
+
if (kind === "bash") {
|
|
29
|
+
if (lower.includes("git"))
|
|
30
|
+
return "Git Bash";
|
|
31
|
+
if (lower.includes("msys"))
|
|
32
|
+
return "MSYS2 Bash";
|
|
33
|
+
if (lower.includes("cygwin"))
|
|
34
|
+
return "Cygwin Bash";
|
|
35
|
+
return "Bash";
|
|
36
|
+
}
|
|
37
|
+
switch (kind) {
|
|
38
|
+
case "pwsh": return "PowerShell 7";
|
|
39
|
+
case "powershell": return "Windows PowerShell";
|
|
40
|
+
case "cmd": return "Command Prompt";
|
|
41
|
+
case "wsl": return "WSL";
|
|
42
|
+
case "nu": return "Nushell";
|
|
43
|
+
case "zsh": return "Zsh";
|
|
44
|
+
case "fish": return "Fish";
|
|
45
|
+
default: return shellPath.split(/[\\/]/).pop() || shellPath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Nome curto para titulo de aba. */
|
|
49
|
+
export function shellTabName(shellPath) {
|
|
50
|
+
const lower = shellPath.toLowerCase();
|
|
51
|
+
const base = (shellPath.split(/[\\/]/).pop() || "shell").replace(/\.exe$/i, "").toLowerCase();
|
|
52
|
+
if (base === "bash") {
|
|
53
|
+
if (lower.includes("git"))
|
|
54
|
+
return "git-bash";
|
|
55
|
+
if (lower.includes("msys"))
|
|
56
|
+
return "msys-bash";
|
|
57
|
+
if (lower.includes("cygwin"))
|
|
58
|
+
return "cygwin-bash";
|
|
59
|
+
}
|
|
60
|
+
return base;
|
|
61
|
+
}
|
|
62
|
+
/** Escapa um caminho para uso em `cd` no shell indicado. */
|
|
63
|
+
export function quoteForShell(shellPath, target) {
|
|
64
|
+
const kind = shellKind(shellPath);
|
|
65
|
+
if (kind === "cmd")
|
|
66
|
+
return `"${target.replace(/"/g, "")}"`;
|
|
67
|
+
if (kind === "pwsh" || kind === "powershell" || kind === "nu")
|
|
68
|
+
return `'${target.replace(/'/g, "''")}'`;
|
|
69
|
+
return `'${target.replace(/'/g, `'\\''`)}'`;
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type TokenType = "comment" | "string" | "number" | "keyword" | "type" | "function" | "constant" | "operator" | "punctuation" | "tag" | "attr" | "property" | "variable" | "meta" | "heading" | "inserted" | "deleted" | "plain";
|
|
2
|
+
export type Token = {
|
|
3
|
+
type: TokenType;
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
export type LanguageId = "javascript" | "typescript" | "jsx" | "tsx" | "json" | "html" | "xml" | "css" | "scss" | "less" | "go" | "rust" | "c" | "cpp" | "csharp" | "java" | "kotlin" | "swift" | "dart" | "php" | "python" | "ruby" | "lua" | "shell" | "powershell" | "batch" | "sql" | "yaml" | "toml" | "ini" | "markdown" | "dockerfile" | "makefile" | "diff" | "zig" | "scala" | "r" | "perl" | "elixir" | "haskell" | "plaintext";
|
|
7
|
+
/** Linguagem de um arquivo pelo nome (nome completo primeiro, depois extensao). */
|
|
8
|
+
export declare function languageForFile(name: string): LanguageId;
|
|
9
|
+
/** Normaliza um identificador de linguagem (aceita extensoes e apelidos). */
|
|
10
|
+
export declare function resolveLanguage(lang: string): LanguageId;
|
|
11
|
+
/** Tokeniza o texto inteiro. A concatenacao dos tokens sempre reproduz exatamente a entrada. */
|
|
12
|
+
export declare function tokenize(code: string, lang: LanguageId | string): Token[];
|
|
13
|
+
/** Divide os tokens por linha (sem o "\n"), preservando tokens que atravessam linhas (comentarios de bloco, strings). */
|
|
14
|
+
export declare function tokenizeLinesOf(code: string, lang: LanguageId | string): Token[][];
|
|
15
|
+
/** HTML com <span class="lt-<tipo">; as cores vem do CSS (ver --code-* nos tokens). */
|
|
16
|
+
export declare function highlightToHtml(code: string, lang: LanguageId | string): string;
|