vde-layout 0.0.1
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/LICENSE +21 -0
- package/README.md +194 -0
- package/bin/vde-layout +2 -0
- package/dist/cli.d.ts +27 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +138 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/loader.d.ts +14 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +117 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/validator.d.ts +3 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +168 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/executor/dry-run-executor.d.ts +16 -0
- package/dist/executor/dry-run-executor.d.ts.map +1 -0
- package/dist/executor/dry-run-executor.js +45 -0
- package/dist/executor/dry-run-executor.js.map +1 -0
- package/dist/executor/index.d.ts +6 -0
- package/dist/executor/index.d.ts.map +1 -0
- package/dist/executor/index.js +10 -0
- package/dist/executor/index.js.map +1 -0
- package/dist/executor/mock-executor.d.ts +21 -0
- package/dist/executor/mock-executor.d.ts.map +1 -0
- package/dist/executor/mock-executor.js +73 -0
- package/dist/executor/mock-executor.js.map +1 -0
- package/dist/executor/real-executor.d.ts +16 -0
- package/dist/executor/real-executor.d.ts.map +1 -0
- package/dist/executor/real-executor.js +58 -0
- package/dist/executor/real-executor.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/command-executor.d.ts +7 -0
- package/dist/interfaces/command-executor.d.ts.map +1 -0
- package/dist/interfaces/command-executor.js +3 -0
- package/dist/interfaces/command-executor.js.map +1 -0
- package/dist/interfaces/index.d.ts +31 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/layout/engine.d.ts +18 -0
- package/dist/layout/engine.d.ts.map +1 -0
- package/dist/layout/engine.js +174 -0
- package/dist/layout/engine.js.map +1 -0
- package/dist/layout/preset.d.ts +13 -0
- package/dist/layout/preset.d.ts.map +1 -0
- package/dist/layout/preset.js +55 -0
- package/dist/layout/preset.js.map +1 -0
- package/dist/models/schema.d.ts +144 -0
- package/dist/models/schema.d.ts.map +1 -0
- package/dist/models/schema.js +95 -0
- package/dist/models/schema.js.map +1 -0
- package/dist/models/types.d.ts +34 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +16 -0
- package/dist/models/types.js.map +1 -0
- package/dist/tmux/commands.d.ts +14 -0
- package/dist/tmux/commands.d.ts.map +1 -0
- package/dist/tmux/commands.js +59 -0
- package/dist/tmux/commands.js.map +1 -0
- package/dist/tmux/executor.d.ts +20 -0
- package/dist/tmux/executor.d.ts.map +1 -0
- package/dist/tmux/executor.js +64 -0
- package/dist/tmux/executor.js.map +1 -0
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +131 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +67 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/ratio.d.ts +3 -0
- package/dist/utils/ratio.d.ts.map +1 -0
- package/dist/utils/ratio.js +44 -0
- package/dist/utils/ratio.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LayoutEngine = void 0;
|
|
4
|
+
const executor_1 = require("../tmux/executor");
|
|
5
|
+
const commands_1 = require("../tmux/commands");
|
|
6
|
+
const ratio_1 = require("../utils/ratio");
|
|
7
|
+
class LayoutEngine {
|
|
8
|
+
executor;
|
|
9
|
+
commandGenerator;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
if (options.executor && "verifyTmuxEnvironment" in options.executor) {
|
|
12
|
+
this.executor = options.executor;
|
|
13
|
+
}
|
|
14
|
+
else if (options.executor) {
|
|
15
|
+
const executorOptions = {
|
|
16
|
+
verbose: options.verbose,
|
|
17
|
+
dryRun: options.dryRun,
|
|
18
|
+
executor: options.executor,
|
|
19
|
+
};
|
|
20
|
+
this.executor = new executor_1.TmuxExecutor(executorOptions);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const executorOptions = {
|
|
24
|
+
verbose: options.verbose,
|
|
25
|
+
dryRun: options.dryRun,
|
|
26
|
+
};
|
|
27
|
+
this.executor = new executor_1.TmuxExecutor(executorOptions);
|
|
28
|
+
}
|
|
29
|
+
this.commandGenerator = options.commandGenerator || new commands_1.TmuxCommandGenerator();
|
|
30
|
+
}
|
|
31
|
+
async createLayout(preset) {
|
|
32
|
+
await this.executor.verifyTmuxEnvironment();
|
|
33
|
+
const windowName = preset.name || "vde-layout";
|
|
34
|
+
await this.executor.execute(this.commandGenerator.newWindow(windowName));
|
|
35
|
+
const initialPaneId = await this.getCurrentPaneId();
|
|
36
|
+
let paneInfos;
|
|
37
|
+
if (preset.layout) {
|
|
38
|
+
paneInfos = await this.createLayoutRecursive(preset.layout, initialPaneId);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const terminalPane = {
|
|
42
|
+
name: preset.name,
|
|
43
|
+
command: preset.command,
|
|
44
|
+
};
|
|
45
|
+
paneInfos = [
|
|
46
|
+
{
|
|
47
|
+
pane: terminalPane,
|
|
48
|
+
paneId: initialPaneId,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
for (const paneInfo of paneInfos) {
|
|
53
|
+
await this.applyPaneOptions(paneInfo);
|
|
54
|
+
}
|
|
55
|
+
const focusedPane = paneInfos.find((info) => {
|
|
56
|
+
const terminalPane = info.pane;
|
|
57
|
+
return terminalPane.focus === true;
|
|
58
|
+
});
|
|
59
|
+
if (focusedPane !== undefined) {
|
|
60
|
+
await this.executor.execute(this.commandGenerator.selectPane(focusedPane.paneId));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async createLayoutRecursive(layout, parentPaneId, _isFirst = true) {
|
|
64
|
+
const isLayout = (l) => {
|
|
65
|
+
return (typeof l === "object" &&
|
|
66
|
+
l !== null &&
|
|
67
|
+
"type" in l &&
|
|
68
|
+
"panes" in l &&
|
|
69
|
+
"ratio" in l &&
|
|
70
|
+
(l.type === "horizontal" || l.type === "vertical"));
|
|
71
|
+
};
|
|
72
|
+
if (!isLayout(layout)) {
|
|
73
|
+
return [
|
|
74
|
+
{
|
|
75
|
+
pane: layout,
|
|
76
|
+
paneId: parentPaneId,
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
const paneInfos = [];
|
|
81
|
+
const currentPaneId = parentPaneId;
|
|
82
|
+
let paneIndex = 0;
|
|
83
|
+
if (parentPaneId && parentPaneId.startsWith("%")) {
|
|
84
|
+
paneIndex = parseInt(parentPaneId.slice(1), 10) || 0;
|
|
85
|
+
}
|
|
86
|
+
const normalizedRatio = (0, ratio_1.normalizeRatio)(layout.ratio ?? []);
|
|
87
|
+
const paneIds = [parentPaneId];
|
|
88
|
+
for (let i = 1; i < layout.panes.length; i++) {
|
|
89
|
+
let percentage;
|
|
90
|
+
if (i === 1) {
|
|
91
|
+
const firstPaneRatio = normalizedRatio[0];
|
|
92
|
+
const totalRatio = normalizedRatio.reduce((sum, r) => sum + r, 0);
|
|
93
|
+
const remainingRatiosSum = totalRatio - firstPaneRatio;
|
|
94
|
+
percentage = Math.round((remainingRatiosSum / totalRatio) * 100);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const currentSpaceRatios = normalizedRatio.slice(i - 1);
|
|
98
|
+
const currentSpaceTotal = currentSpaceRatios.reduce((sum, r) => sum + r, 0);
|
|
99
|
+
const newPaneRatios = normalizedRatio.slice(i);
|
|
100
|
+
const newPaneTotal = newPaneRatios.reduce((sum, r) => sum + r, 0);
|
|
101
|
+
percentage = Math.round((newPaneTotal / currentSpaceTotal) * 100);
|
|
102
|
+
}
|
|
103
|
+
const beforePaneIds = await this.getAllPaneIds();
|
|
104
|
+
const targetPaneId = i === 1 ? currentPaneId : paneIds[paneIds.length - 1];
|
|
105
|
+
await this.executor.execute(this.commandGenerator.splitWindow(layout.type, targetPaneId, percentage));
|
|
106
|
+
const afterPaneIds = await this.getAllPaneIds();
|
|
107
|
+
const newPaneId = afterPaneIds.find((id) => !beforePaneIds.includes(id));
|
|
108
|
+
if (newPaneId === undefined) {
|
|
109
|
+
const fallbackPaneId = `%${paneIndex + i}`;
|
|
110
|
+
paneIds.push(fallbackPaneId);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
paneIds.push(newPaneId);
|
|
114
|
+
}
|
|
115
|
+
paneIndex++;
|
|
116
|
+
}
|
|
117
|
+
for (let i = 0; i < layout.panes.length; i++) {
|
|
118
|
+
const pane = layout.panes[i];
|
|
119
|
+
const paneId = paneIds[i];
|
|
120
|
+
const childPaneInfos = await this.createLayoutRecursive(pane, paneId, false);
|
|
121
|
+
for (const childInfo of childPaneInfos) {
|
|
122
|
+
if (childInfo.paneId && childInfo.paneId.startsWith("%")) {
|
|
123
|
+
const childIndex = parseInt(childInfo.paneId.slice(1), 10);
|
|
124
|
+
if (!isNaN(childIndex) && childIndex > paneIndex) {
|
|
125
|
+
paneIndex = childIndex;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
paneInfos.push(...childPaneInfos);
|
|
130
|
+
}
|
|
131
|
+
return paneInfos;
|
|
132
|
+
}
|
|
133
|
+
async applyPaneOptions(paneInfo) {
|
|
134
|
+
const pane = paneInfo.pane;
|
|
135
|
+
const paneId = paneInfo.paneId;
|
|
136
|
+
if (pane.cwd !== undefined) {
|
|
137
|
+
await this.executor.execute(this.commandGenerator.changeDirectory(paneId, pane.cwd));
|
|
138
|
+
}
|
|
139
|
+
if (pane.env !== undefined) {
|
|
140
|
+
const envCommands = this.commandGenerator.setEnvironment(paneId, pane.env);
|
|
141
|
+
for (const command of envCommands) {
|
|
142
|
+
await this.executor.execute(command);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (pane.name !== undefined) {
|
|
146
|
+
await this.executor.execute(this.commandGenerator.setPaneTitle(paneId, pane.name));
|
|
147
|
+
}
|
|
148
|
+
if (pane.delay !== undefined && pane.delay > 0) {
|
|
149
|
+
await new Promise((resolve) => setTimeout(resolve, pane.delay));
|
|
150
|
+
}
|
|
151
|
+
if (pane.command !== undefined) {
|
|
152
|
+
await this.executor.execute(this.commandGenerator.sendKeys(paneId, pane.command));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async getCurrentPaneId() {
|
|
156
|
+
const result = await this.executor.execute(["display-message", "-p", "#{pane_id}"]);
|
|
157
|
+
if (!result || typeof result !== "string") {
|
|
158
|
+
return "%0";
|
|
159
|
+
}
|
|
160
|
+
return result.trim() || "%0";
|
|
161
|
+
}
|
|
162
|
+
async getAllPaneIds() {
|
|
163
|
+
const result = await this.executor.execute(["list-panes", "-F", "#{pane_id}"]);
|
|
164
|
+
if (!result || typeof result !== "string") {
|
|
165
|
+
return ["%0"];
|
|
166
|
+
}
|
|
167
|
+
return result
|
|
168
|
+
.trim()
|
|
169
|
+
.split("\n")
|
|
170
|
+
.filter((id) => id.trim() !== "");
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.LayoutEngine = LayoutEngine;
|
|
174
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/layout/engine.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AACzE,+CAAuD;AAEvD,0CAA+C;AAkB/C,MAAa,YAAY;IACN,QAAQ,CAAe;IACvB,gBAAgB,CAAuB;IAExD,YAAY,UAA+B,EAAE;QAE3C,IAAI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,IAAI,EAAE,YAAY,CAAC,CAAC,CAAA;QAC9E,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC;QACD,OAAO,MAAM;aACV,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACrC,CAAC;CACF;AA7PD,oCA6PC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ConfigLoaderOptions } from "../config/loader";
|
|
2
|
+
import type { Preset, PresetInfo } from "../models/types";
|
|
3
|
+
import type { IPresetManager } from "../interfaces";
|
|
4
|
+
export declare class PresetManager implements IPresetManager {
|
|
5
|
+
private config;
|
|
6
|
+
private configLoaderOptions;
|
|
7
|
+
constructor(options?: ConfigLoaderOptions);
|
|
8
|
+
loadConfig(): Promise<void>;
|
|
9
|
+
getPreset(name: string): Preset;
|
|
10
|
+
listPresets(): PresetInfo[];
|
|
11
|
+
getDefaultPreset(): Preset;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=preset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../../src/layout/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAGzE,OAAO,KAAK,EAAU,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAMnD,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,mBAAmB,CAAqB;gBAEpC,OAAO,GAAE,mBAAwB;IAQvC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAYjC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAmB/B,WAAW,IAAI,UAAU,EAAE;IAkB3B,gBAAgB,IAAI,MAAM;CAkB3B"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresetManager = void 0;
|
|
4
|
+
const loader_1 = require("../config/loader");
|
|
5
|
+
const validator_1 = require("../config/validator");
|
|
6
|
+
const errors_1 = require("../utils/errors");
|
|
7
|
+
class PresetManager {
|
|
8
|
+
config = null;
|
|
9
|
+
configLoaderOptions;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.configLoaderOptions = options;
|
|
12
|
+
}
|
|
13
|
+
async loadConfig() {
|
|
14
|
+
const loader = new loader_1.ConfigLoader(this.configLoaderOptions);
|
|
15
|
+
const yamlContent = await loader.loadYAML();
|
|
16
|
+
this.config = (0, validator_1.validateYAML)(yamlContent);
|
|
17
|
+
}
|
|
18
|
+
getPreset(name) {
|
|
19
|
+
if (!this.config) {
|
|
20
|
+
throw new errors_1.ConfigError("Configuration not loaded", errors_1.ErrorCodes.CONFIG_NOT_FOUND);
|
|
21
|
+
}
|
|
22
|
+
const preset = this.config.presets[name];
|
|
23
|
+
if (!preset) {
|
|
24
|
+
throw new errors_1.ConfigError(`Preset "${name}" not found`, errors_1.ErrorCodes.PRESET_NOT_FOUND, {
|
|
25
|
+
availablePresets: Object.keys(this.config.presets),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return preset;
|
|
29
|
+
}
|
|
30
|
+
listPresets() {
|
|
31
|
+
if (!this.config) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
return Object.entries(this.config.presets).map(([key, preset]) => ({
|
|
35
|
+
key,
|
|
36
|
+
name: preset.name,
|
|
37
|
+
description: preset.description,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
getDefaultPreset() {
|
|
41
|
+
if (!this.config) {
|
|
42
|
+
throw new errors_1.ConfigError("Configuration not loaded", errors_1.ErrorCodes.CONFIG_NOT_FOUND);
|
|
43
|
+
}
|
|
44
|
+
if (this.config.presets.default) {
|
|
45
|
+
return this.config.presets.default;
|
|
46
|
+
}
|
|
47
|
+
const firstKey = Object.keys(this.config.presets)[0];
|
|
48
|
+
if (firstKey === undefined) {
|
|
49
|
+
throw new errors_1.ConfigError("No presets defined", errors_1.ErrorCodes.PRESET_NOT_FOUND);
|
|
50
|
+
}
|
|
51
|
+
return this.config.presets[firstKey];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.PresetManager = PresetManager;
|
|
55
|
+
//# sourceMappingURL=preset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../src/layout/preset.ts"],"names":[],"mappings":";;;AAAA,6CAAyE;AACzE,mDAAkD;AAClD,4CAAyD;AAQzD,MAAa,aAAa;IAChB,MAAM,GAAkB,IAAI,CAAA;IAC5B,mBAAmB,CAAqB;IAEhD,YAAY,UAA+B,EAAE;QAC3C,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAA;IACpC,CAAC;IAMD,KAAK,CAAC,UAAU;QACd,MAAM,MAAM,GAAG,IAAI,qBAAY,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;QACzD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAA,wBAAY,EAAC,WAAW,CAAC,CAAA;IACzC,CAAC;IAQD,SAAS,CAAC,IAAY;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,oBAAW,CAAC,0BAA0B,EAAE,mBAAU,CAAC,gBAAgB,CAAC,CAAA;QAChF,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACxC,I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AC;CACF;AA/ED,sCA+EC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const PaneSchema: z.ZodType<unknown>;
|
|
3
|
+
export declare const LayoutSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
type: z.ZodEnum<["horizontal", "vertical"]>;
|
|
5
|
+
ratio: z.ZodArray<z.ZodNumber, "many">;
|
|
6
|
+
panes: z.ZodArray<z.ZodType<unknown, z.ZodTypeDef, unknown>, "many">;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
type: "horizontal" | "vertical";
|
|
9
|
+
ratio: number[];
|
|
10
|
+
panes: unknown[];
|
|
11
|
+
}, {
|
|
12
|
+
type: "horizontal" | "vertical";
|
|
13
|
+
ratio: number[];
|
|
14
|
+
panes: unknown[];
|
|
15
|
+
}>, {
|
|
16
|
+
type: "horizontal" | "vertical";
|
|
17
|
+
ratio: number[];
|
|
18
|
+
panes: unknown[];
|
|
19
|
+
}, {
|
|
20
|
+
type: "horizontal" | "vertical";
|
|
21
|
+
ratio: number[];
|
|
22
|
+
panes: unknown[];
|
|
23
|
+
}>;
|
|
24
|
+
export declare const PresetSchema: z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
description: z.ZodOptional<z.ZodString>;
|
|
27
|
+
layout: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
28
|
+
type: z.ZodEnum<["horizontal", "vertical"]>;
|
|
29
|
+
ratio: z.ZodArray<z.ZodNumber, "many">;
|
|
30
|
+
panes: z.ZodArray<z.ZodType<unknown, z.ZodTypeDef, unknown>, "many">;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
type: "horizontal" | "vertical";
|
|
33
|
+
ratio: number[];
|
|
34
|
+
panes: unknown[];
|
|
35
|
+
}, {
|
|
36
|
+
type: "horizontal" | "vertical";
|
|
37
|
+
ratio: number[];
|
|
38
|
+
panes: unknown[];
|
|
39
|
+
}>, {
|
|
40
|
+
type: "horizontal" | "vertical";
|
|
41
|
+
ratio: number[];
|
|
42
|
+
panes: unknown[];
|
|
43
|
+
}, {
|
|
44
|
+
type: "horizontal" | "vertical";
|
|
45
|
+
ratio: number[];
|
|
46
|
+
panes: unknown[];
|
|
47
|
+
}>>;
|
|
48
|
+
command: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
name: string;
|
|
51
|
+
command?: string | undefined;
|
|
52
|
+
description?: string | undefined;
|
|
53
|
+
layout?: {
|
|
54
|
+
type: "horizontal" | "vertical";
|
|
55
|
+
ratio: number[];
|
|
56
|
+
panes: unknown[];
|
|
57
|
+
} | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
name: string;
|
|
60
|
+
command?: string | undefined;
|
|
61
|
+
description?: string | undefined;
|
|
62
|
+
layout?: {
|
|
63
|
+
type: "horizontal" | "vertical";
|
|
64
|
+
ratio: number[];
|
|
65
|
+
panes: unknown[];
|
|
66
|
+
} | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
69
|
+
presets: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
description: z.ZodOptional<z.ZodString>;
|
|
72
|
+
layout: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
73
|
+
type: z.ZodEnum<["horizontal", "vertical"]>;
|
|
74
|
+
ratio: z.ZodArray<z.ZodNumber, "many">;
|
|
75
|
+
panes: z.ZodArray<z.ZodType<unknown, z.ZodTypeDef, unknown>, "many">;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
type: "horizontal" | "vertical";
|
|
78
|
+
ratio: number[];
|
|
79
|
+
panes: unknown[];
|
|
80
|
+
}, {
|
|
81
|
+
type: "horizontal" | "vertical";
|
|
82
|
+
ratio: number[];
|
|
83
|
+
panes: unknown[];
|
|
84
|
+
}>, {
|
|
85
|
+
type: "horizontal" | "vertical";
|
|
86
|
+
ratio: number[];
|
|
87
|
+
panes: unknown[];
|
|
88
|
+
}, {
|
|
89
|
+
type: "horizontal" | "vertical";
|
|
90
|
+
ratio: number[];
|
|
91
|
+
panes: unknown[];
|
|
92
|
+
}>>;
|
|
93
|
+
command: z.ZodOptional<z.ZodString>;
|
|
94
|
+
}, "strip", z.ZodTypeAny, {
|
|
95
|
+
name: string;
|
|
96
|
+
command?: string | undefined;
|
|
97
|
+
description?: string | undefined;
|
|
98
|
+
layout?: {
|
|
99
|
+
type: "horizontal" | "vertical";
|
|
100
|
+
ratio: number[];
|
|
101
|
+
panes: unknown[];
|
|
102
|
+
} | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
name: string;
|
|
105
|
+
command?: string | undefined;
|
|
106
|
+
description?: string | undefined;
|
|
107
|
+
layout?: {
|
|
108
|
+
type: "horizontal" | "vertical";
|
|
109
|
+
ratio: number[];
|
|
110
|
+
panes: unknown[];
|
|
111
|
+
} | undefined;
|
|
112
|
+
}>>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
presets: Record<string, {
|
|
115
|
+
name: string;
|
|
116
|
+
command?: string | undefined;
|
|
117
|
+
description?: string | undefined;
|
|
118
|
+
layout?: {
|
|
119
|
+
type: "horizontal" | "vertical";
|
|
120
|
+
ratio: number[];
|
|
121
|
+
panes: unknown[];
|
|
122
|
+
} | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
}, {
|
|
125
|
+
presets: Record<string, {
|
|
126
|
+
name: string;
|
|
127
|
+
command?: string | undefined;
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
layout?: {
|
|
130
|
+
type: "horizontal" | "vertical";
|
|
131
|
+
ratio: number[];
|
|
132
|
+
panes: unknown[];
|
|
133
|
+
} | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
}>;
|
|
136
|
+
export interface ValidationResult<T> {
|
|
137
|
+
success: boolean;
|
|
138
|
+
data?: T;
|
|
139
|
+
error?: string;
|
|
140
|
+
}
|
|
141
|
+
export declare function validateConfig(data: unknown): ValidationResult<z.infer<typeof ConfigSchema>>;
|
|
142
|
+
export declare function validatePreset(data: unknown): ValidationResult<z.infer<typeof PresetSchema>>;
|
|
143
|
+
export declare function validatePane(data: unknown): ValidationResult<z.infer<typeof PaneSchema>>;
|
|
144
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/models/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA8BvB,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAgE,CAAA;AAG1G,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;EAQrB,CAAA;AAGJ,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKvB,CAAA;AAGF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEvB,CAAA;AAGF,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAoBD,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC,CAU5F;AAGD,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC,CAU5F;AAGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC,CAUxF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigSchema = exports.PresetSchema = exports.LayoutSchema = exports.PaneSchema = void 0;
|
|
4
|
+
exports.validateConfig = validateConfig;
|
|
5
|
+
exports.validatePreset = validatePreset;
|
|
6
|
+
exports.validatePane = validatePane;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const TerminalPaneSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
name: zod_1.z.string().min(1),
|
|
11
|
+
command: zod_1.z.string().optional(),
|
|
12
|
+
cwd: zod_1.z.string().optional(),
|
|
13
|
+
env: zod_1.z.record(zod_1.z.string()).optional(),
|
|
14
|
+
delay: zod_1.z.number().int().positive().optional(),
|
|
15
|
+
title: zod_1.z.string().optional(),
|
|
16
|
+
focus: zod_1.z.boolean().optional(),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
19
|
+
const SplitPaneSchema = zod_1.z.lazy(() => zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
type: zod_1.z.enum(["horizontal", "vertical"]),
|
|
22
|
+
ratio: zod_1.z.array(zod_1.z.number().positive()).min(1),
|
|
23
|
+
panes: zod_1.z.array(exports.PaneSchema).min(1),
|
|
24
|
+
})
|
|
25
|
+
.strict()
|
|
26
|
+
.refine((data) => data.ratio.length === data.panes.length, {
|
|
27
|
+
message: "Number of elements in ratio array does not match number of elements in panes array",
|
|
28
|
+
}));
|
|
29
|
+
exports.PaneSchema = zod_1.z.lazy(() => zod_1.z.union([SplitPaneSchema, TerminalPaneSchema]));
|
|
30
|
+
exports.LayoutSchema = zod_1.z
|
|
31
|
+
.object({
|
|
32
|
+
type: zod_1.z.enum(["horizontal", "vertical"]),
|
|
33
|
+
ratio: zod_1.z.array(zod_1.z.number().positive()).min(1),
|
|
34
|
+
panes: zod_1.z.array(exports.PaneSchema).min(1),
|
|
35
|
+
})
|
|
36
|
+
.refine((data) => data.ratio.length === data.panes.length, {
|
|
37
|
+
message: "Number of elements in ratio array does not match number of elements in panes array",
|
|
38
|
+
});
|
|
39
|
+
exports.PresetSchema = zod_1.z.object({
|
|
40
|
+
name: zod_1.z.string().min(1),
|
|
41
|
+
description: zod_1.z.string().optional(),
|
|
42
|
+
layout: exports.LayoutSchema.optional(),
|
|
43
|
+
command: zod_1.z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
exports.ConfigSchema = zod_1.z.object({
|
|
46
|
+
presets: zod_1.z.record(exports.PresetSchema),
|
|
47
|
+
});
|
|
48
|
+
function formatValidationError(error) {
|
|
49
|
+
const messages = error.errors.map((e) => {
|
|
50
|
+
const path = e.path.join(".");
|
|
51
|
+
const message = e.message;
|
|
52
|
+
if (path === "layout.panes" && message.includes("at least 2 element")) {
|
|
53
|
+
return `${path}: panes array must have at least 2 elements`;
|
|
54
|
+
}
|
|
55
|
+
return `${path}: ${message}`;
|
|
56
|
+
});
|
|
57
|
+
return messages.join("\n");
|
|
58
|
+
}
|
|
59
|
+
function validateConfig(data) {
|
|
60
|
+
try {
|
|
61
|
+
const parsed = exports.ConfigSchema.parse(data);
|
|
62
|
+
return { success: true, data: parsed };
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
66
|
+
return { success: false, error: formatValidationError(error) };
|
|
67
|
+
}
|
|
68
|
+
return { success: false, error: String(error) };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function validatePreset(data) {
|
|
72
|
+
try {
|
|
73
|
+
const parsed = exports.PresetSchema.parse(data);
|
|
74
|
+
return { success: true, data: parsed };
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
78
|
+
return { success: false, error: formatValidationError(error) };
|
|
79
|
+
}
|
|
80
|
+
return { success: false, error: String(error) };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function validatePane(data) {
|
|
84
|
+
try {
|
|
85
|
+
const parsed = exports.PaneSchema.parse(data);
|
|
86
|
+
return { success: true, data: parsed };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
90
|
+
return { success: false, error: formatValidationError(error) };
|
|
91
|
+
}
|
|
92
|
+
return { success: false, error: String(error) };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/models/schema.ts"],"names":[],"mappings":";;;AAiFA,wCAUC;AAGD,wCAUC;AAGD,oCAUC;AArHD,6BAAuB;AAGvB,MAAM,kBAAkB,GAAG,OAAC;KACzB,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,GAAG,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC7C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAA;AAGX,MAAM,eAAe,GAAuB,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACtD,OAAC;KACE,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACx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,CAAC,KAAK,CAAC,EAAE,CAAA;IACjD,CAAC;AACH,CAAC;AAGD,SAAgB,cAAc,CAAC,IAAa;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,oBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;YAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAA;QAChE,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;IACjD,CAAC;AACH,CAAC;AAGD,SAAgB,YAAY,CAAC,IAAa;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;YAChC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAAE,CAAA;QAChE,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ConfigSchema, PresetSchema, LayoutSchema, PaneSchema } from "./schema";
|
|
3
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
4
|
+
export type Preset = z.infer<typeof PresetSchema>;
|
|
5
|
+
export type Layout = z.infer<typeof LayoutSchema>;
|
|
6
|
+
export type Pane = z.infer<typeof PaneSchema>;
|
|
7
|
+
export type SplitPane = Pane & {
|
|
8
|
+
type: "horizontal" | "vertical";
|
|
9
|
+
ratio: number[];
|
|
10
|
+
panes: Pane[];
|
|
11
|
+
};
|
|
12
|
+
export type TerminalPane = Pane & {
|
|
13
|
+
name: string;
|
|
14
|
+
command?: string;
|
|
15
|
+
cwd?: string;
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
delay?: number;
|
|
18
|
+
title?: string;
|
|
19
|
+
focus?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function isSplitPane(pane: unknown): pane is SplitPane;
|
|
22
|
+
export declare function isTerminalPane(pane: unknown): pane is TerminalPane;
|
|
23
|
+
export interface CLIOptions {
|
|
24
|
+
preset?: string;
|
|
25
|
+
list?: boolean;
|
|
26
|
+
dryRun?: boolean;
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface PresetInfo {
|
|
30
|
+
key: string;
|
|
31
|
+
name: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/models/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG/E,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA;AAG7C,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG;IAC7B,IAAI,EAAE,YAAY,GAAG,UAAU,CAAA;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,IAAI,EAAE,CAAA;CACd,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,SAAS,CAS5D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAElE;AAGD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAGD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSplitPane = isSplitPane;
|
|
4
|
+
exports.isTerminalPane = isTerminalPane;
|
|
5
|
+
function isSplitPane(pane) {
|
|
6
|
+
return (typeof pane === "object" &&
|
|
7
|
+
pane !== null &&
|
|
8
|
+
"type" in pane &&
|
|
9
|
+
"panes" in pane &&
|
|
10
|
+
"ratio" in pane &&
|
|
11
|
+
(pane.type === "horizontal" || pane.type === "vertical"));
|
|
12
|
+
}
|
|
13
|
+
function isTerminalPane(pane) {
|
|
14
|
+
return typeof pane === "object" && pane !== null && "name" in pane && !("panes" in pane);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/models/types.ts"],"names":[],"mappings":";;AA2BA,kCASC;AAED,wCAEC;AAbD,SAAgB,WAAW,CAAC,IAAa;IACvC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,MAAM,IAAI,IAAI;QACd,OAAO,IAAI,IAAI;QACf,OAAO,IAAI,IAAI;QACf,CAAE,IAAY,CAAC,IAAI,KAAK,YAAY,IAAK,IAAY,CAAC,IAAI,KAAK,UAAU,CAAC,CAC3E,CAAA;AACH,CAAC;AAED,SAAgB,cAAc,CAAC,IAAa;IAC1C,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,CAAA;AAC1F,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ITmuxCommandGenerator } from "../interfaces";
|
|
2
|
+
export declare class TmuxCommandGenerator implements ITmuxCommandGenerator {
|
|
3
|
+
splitWindow(direction: "horizontal" | "vertical", targetPane?: string, percentage?: number): string[];
|
|
4
|
+
resizePane(paneId: string, direction: "horizontal" | "vertical", percentage: number): string[];
|
|
5
|
+
sendKeys(paneId: string, command: string): string[];
|
|
6
|
+
selectPane(paneId: string): string[];
|
|
7
|
+
setPaneOption(paneId: string, option: string, value: string): string[];
|
|
8
|
+
setEnvironment(paneId: string, env: Record<string, string>): string[][];
|
|
9
|
+
setPaneTitle(paneId: string, title: string): string[];
|
|
10
|
+
changeDirectory(paneId: string, directory: string): string[];
|
|
11
|
+
newWindow(windowName?: string, workingDirectory?: string): string[];
|
|
12
|
+
killAllPanes(): string[];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/tmux/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAM1D,qBAAa,oBAAqB,YAAW,qBAAqB;IAQhE,WAAW,CAAC,SAAS,EAAE,YAAY,GAAG,UAAU,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IA0BrG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,GAAG,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAW9F,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IASnD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAWpC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAUtE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,EAAE;IAmBvE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAUrD,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAU5D,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAkBnE,YAAY,IAAI,MAAM,EAAE;CAIzB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TmuxCommandGenerator = void 0;
|
|
4
|
+
class TmuxCommandGenerator {
|
|
5
|
+
splitWindow(direction, targetPane, percentage) {
|
|
6
|
+
const args = ["split-window"];
|
|
7
|
+
args.push(direction === "horizontal" ? "-h" : "-v");
|
|
8
|
+
if (targetPane !== undefined) {
|
|
9
|
+
args.push("-t", targetPane);
|
|
10
|
+
}
|
|
11
|
+
if (percentage !== undefined) {
|
|
12
|
+
args.push("-p", percentage.toString());
|
|
13
|
+
}
|
|
14
|
+
return args;
|
|
15
|
+
}
|
|
16
|
+
resizePane(paneId, direction, percentage) {
|
|
17
|
+
const size = Math.floor(percentage);
|
|
18
|
+
return ["resize-pane", "-t", paneId, direction === "horizontal" ? "-x" : "-y", `${size}%`];
|
|
19
|
+
}
|
|
20
|
+
sendKeys(paneId, command) {
|
|
21
|
+
return ["send-keys", "-t", paneId, command, "Enter"];
|
|
22
|
+
}
|
|
23
|
+
selectPane(paneId) {
|
|
24
|
+
return ["select-pane", "-t", paneId];
|
|
25
|
+
}
|
|
26
|
+
setPaneOption(paneId, option, value) {
|
|
27
|
+
return ["set-option", "-p", "-t", paneId, option, value];
|
|
28
|
+
}
|
|
29
|
+
setEnvironment(paneId, env) {
|
|
30
|
+
const commands = [];
|
|
31
|
+
for (const [key, value] of Object.entries(env)) {
|
|
32
|
+
const escapedValue = value.replace(/"/g, '\\"');
|
|
33
|
+
const exportCommand = `export ${key}="${escapedValue}"`;
|
|
34
|
+
commands.push(this.sendKeys(paneId, exportCommand));
|
|
35
|
+
}
|
|
36
|
+
return commands;
|
|
37
|
+
}
|
|
38
|
+
setPaneTitle(paneId, title) {
|
|
39
|
+
return ["select-pane", "-t", paneId, "-T", title];
|
|
40
|
+
}
|
|
41
|
+
changeDirectory(paneId, directory) {
|
|
42
|
+
return this.sendKeys(paneId, `cd "${directory}"`);
|
|
43
|
+
}
|
|
44
|
+
newWindow(windowName, workingDirectory) {
|
|
45
|
+
const args = ["new-window"];
|
|
46
|
+
if (windowName !== undefined && windowName !== "") {
|
|
47
|
+
args.push("-n", windowName);
|
|
48
|
+
}
|
|
49
|
+
if (workingDirectory !== undefined && workingDirectory !== "") {
|
|
50
|
+
args.push("-c", workingDirectory);
|
|
51
|
+
}
|
|
52
|
+
return args;
|
|
53
|
+
}
|
|
54
|
+
killAllPanes() {
|
|
55
|
+
return ["kill-pane", "-a"];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.TmuxCommandGenerator = TmuxCommandGenerator;
|
|
59
|
+
//# sourceMappingURL=commands.js.map
|