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,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.validateYAML = validateYAML;
|
|
37
|
+
const YAML = __importStar(require("yaml"));
|
|
38
|
+
const zod_1 = require("zod");
|
|
39
|
+
const schema_1 = require("../models/schema");
|
|
40
|
+
const errors_1 = require("../utils/errors");
|
|
41
|
+
function parseYAML(yamlText) {
|
|
42
|
+
if (!yamlText || typeof yamlText !== "string") {
|
|
43
|
+
throw new errors_1.ValidationError("YAML text not provided", errors_1.ErrorCodes.CONFIG_PARSE_ERROR, {
|
|
44
|
+
received: typeof yamlText,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
return YAML.parse(yamlText);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new errors_1.ValidationError("Failed to parse YAML", errors_1.ErrorCodes.CONFIG_PARSE_ERROR, {
|
|
52
|
+
parseError: error instanceof Error ? error.message : String(error),
|
|
53
|
+
yamlSnippet: yamlText.substring(0, 200),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function validateConfigStructure(parsed) {
|
|
58
|
+
if (parsed === null || parsed === undefined || typeof parsed !== "object") {
|
|
59
|
+
throw new errors_1.ValidationError("YAML is empty or invalid format", errors_1.ErrorCodes.CONFIG_PARSE_ERROR, {
|
|
60
|
+
parsed: parsed,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const parsedObj = parsed;
|
|
64
|
+
if (!("presets" in parsedObj) || parsedObj.presets === undefined || parsedObj.presets === null) {
|
|
65
|
+
throw new errors_1.ValidationError("presets field is required", errors_1.ErrorCodes.INVALID_PRESET, {
|
|
66
|
+
availableFields: Object.keys(parsedObj),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const presetsObj = parsedObj.presets;
|
|
70
|
+
if (typeof presetsObj !== "object" || presetsObj === null || Object.keys(presetsObj).length === 0) {
|
|
71
|
+
throw new errors_1.ValidationError("At least one preset is required", errors_1.ErrorCodes.INVALID_PRESET, {
|
|
72
|
+
presets: presetsObj,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function formatZodErrors(error) {
|
|
77
|
+
return error.issues.map((issue) => {
|
|
78
|
+
const path = issue.path.join(".");
|
|
79
|
+
let message = issue.message;
|
|
80
|
+
if (issue.code === "invalid_type") {
|
|
81
|
+
if (issue.path.includes("command") && issue.expected === "string") {
|
|
82
|
+
message = "command field must be a string";
|
|
83
|
+
}
|
|
84
|
+
else if (issue.path.includes("workingDirectory") && issue.expected === "string") {
|
|
85
|
+
message = "workingDirectory field must be a string";
|
|
86
|
+
}
|
|
87
|
+
else if (issue.received === "number" && issue.expected === "string") {
|
|
88
|
+
message = `${path} must be a string`;
|
|
89
|
+
}
|
|
90
|
+
else if (issue.received === "array" && issue.expected === "string") {
|
|
91
|
+
message = `${path} must be a string`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else if (issue.code === "invalid_union") {
|
|
95
|
+
const unionIssue = issue;
|
|
96
|
+
if (unionIssue.unionErrors !== undefined) {
|
|
97
|
+
const terminalError = unionIssue.unionErrors.find((e) => e.issues?.some((i) => i.path.includes("command") && i.code === "invalid_type") === true);
|
|
98
|
+
if (terminalError !== undefined) {
|
|
99
|
+
message = "command field is required";
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const splitError = unionIssue.unionErrors.find((e) => e.issues?.some((i) => i.path.includes("panes") && i.code === "invalid_type") === true);
|
|
103
|
+
if (splitError !== undefined) {
|
|
104
|
+
message = "panes field is required";
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
message = 'Pane type must be "terminal" or "split"';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
message = 'Pane type must be "terminal" or "split"';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (issue.code === "invalid_literal") {
|
|
116
|
+
if (issue.path.includes("direction")) {
|
|
117
|
+
message = 'direction must be "horizontal" or "vertical"';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (issue.message.includes("required")) {
|
|
121
|
+
message = issue.message;
|
|
122
|
+
}
|
|
123
|
+
else if (issue.code === "custom" && issue.message.includes("ratio array")) {
|
|
124
|
+
message = issue.message;
|
|
125
|
+
}
|
|
126
|
+
else if (issue.code === "too_small" && issue.message.includes("Array must contain at least")) {
|
|
127
|
+
if (path.includes("panes")) {
|
|
128
|
+
message = "panes array must contain at least 2 elements";
|
|
129
|
+
}
|
|
130
|
+
else if (path.includes("ratio")) {
|
|
131
|
+
message = "ratio array must contain at least 2 elements";
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
message = issue.message;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
path,
|
|
139
|
+
message,
|
|
140
|
+
code: issue.code,
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function validateYAML(yamlText) {
|
|
145
|
+
const parsed = parseYAML(yamlText);
|
|
146
|
+
validateConfigStructure(parsed);
|
|
147
|
+
try {
|
|
148
|
+
const validated = schema_1.ConfigSchema.parse(parsed);
|
|
149
|
+
return validated;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
153
|
+
const issues = formatZodErrors(error);
|
|
154
|
+
const primaryMessage = issues.length > 0 && issues[0] ? issues[0].message : "Configuration validation failed";
|
|
155
|
+
throw new errors_1.ValidationError(primaryMessage, errors_1.ErrorCodes.CONFIG_PARSE_ERROR, {
|
|
156
|
+
issues,
|
|
157
|
+
rawErrors: error.issues,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (error instanceof errors_1.ValidationError) {
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
throw new errors_1.ValidationError("Unexpected validation error occurred", errors_1.ErrorCodes.CONFIG_PARSE_ERROR, {
|
|
164
|
+
error: error instanceof Error ? error.message : String(error),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2IA,oCAoCC;AA/KD,2CAA4B;AAC5B,6BAAuB;AACvB,6CAA+C;AAE/C,4CAA6D;AAQ7D,SAAS,SAAS,CAAC,QAAgB;IAEjC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAA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CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC,CAAA;YAE7G,MAAM,IAAI,wBAAe,CAAC,cAAc,EAAE,mBAAU,CAAC,kBAAkB,EAAE;gBACvE,MAAM;gBACN,SAAS,EAAE,KAAK,CAAC,MAAM;aACxB,CAAC,CAAA;QACJ,CAAC;QAGD,IAAI,KAAK,YAAY,wBAAe,EAAE,CAAC;YACrC,MAAM,KAAK,CAAA;QACb,CAAC;QAGD,MAAM,IAAI,wBAAe,CAAC,sCAAsC,EAAE,mBAAU,CAAC,kBAAkB,EAAE;YAC/F,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ICommandExecutor } from "../interfaces/command-executor";
|
|
2
|
+
export interface DryRunExecutorOptions {
|
|
3
|
+
verbose?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class DryRunExecutor implements ICommandExecutor {
|
|
6
|
+
private readonly verbose;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(options?: DryRunExecutorOptions);
|
|
9
|
+
execute(commandOrArgs: string | string[]): Promise<string>;
|
|
10
|
+
executeMany(commandsList: string[][]): Promise<void>;
|
|
11
|
+
isDryRun(): boolean;
|
|
12
|
+
logCommand(command: string): void;
|
|
13
|
+
private parseCommand;
|
|
14
|
+
private getCommandString;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=dry-run-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dry-run-executor.d.ts","sourceRoot":"","sources":["../../src/executor/dry-run-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAGtE,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAKD,qBAAa,cAAe,YAAW,gBAAgB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAEnB,OAAO,GAAE,qBAA0B;IAQzC,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAU1D,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D,QAAQ,IAAI,OAAO;IAInB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,gBAAgB;CAGzB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DryRunExecutor = void 0;
|
|
4
|
+
const logger_1 = require("../utils/logger");
|
|
5
|
+
class DryRunExecutor {
|
|
6
|
+
verbose;
|
|
7
|
+
logger;
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.verbose = options.verbose ?? false;
|
|
10
|
+
this.logger = new logger_1.Logger({
|
|
11
|
+
level: this.verbose ? logger_1.LogLevel.INFO : logger_1.LogLevel.WARN,
|
|
12
|
+
prefix: "[tmux] [DRY RUN]",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async execute(commandOrArgs) {
|
|
16
|
+
const args = this.parseCommand(commandOrArgs);
|
|
17
|
+
const commandString = this.getCommandString(args);
|
|
18
|
+
this.logCommand(commandString);
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
async executeMany(commandsList) {
|
|
22
|
+
for (const args of commandsList) {
|
|
23
|
+
await this.execute(args);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
isDryRun() {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
logCommand(command) {
|
|
30
|
+
this.logger.info(`Would execute: ${command}`);
|
|
31
|
+
}
|
|
32
|
+
parseCommand(commandOrArgs) {
|
|
33
|
+
return typeof commandOrArgs === "string"
|
|
34
|
+
? commandOrArgs
|
|
35
|
+
.split(" ")
|
|
36
|
+
.filter((s) => s.length > 0)
|
|
37
|
+
.slice(1)
|
|
38
|
+
: commandOrArgs;
|
|
39
|
+
}
|
|
40
|
+
getCommandString(args) {
|
|
41
|
+
return ["tmux", ...args].join(" ");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.DryRunExecutor = DryRunExecutor;
|
|
45
|
+
//# sourceMappingURL=dry-run-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dry-run-executor.js","sourceRoot":"","sources":["../../src/executor/dry-run-executor.ts"],"names":[],"mappings":";;;AACA,4CAAkD;AASlD,MAAa,cAAc;IACR,OAAO,CAAS;IAChB,MAAM,CAAQ;IAE/B,YAAY,UAAiC,EAAE;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAA;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC;YACvB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAQ,CAAC,IAAI;YACnD,MAAM,EAAE,kBAAkB;SAC3B,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,aAAgC;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;QAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAEjD,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;QAG9B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,YAAwB;QACxC,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,OAAe;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAA;IAC/C,CAAC;IAEO,YAAY,CAAC,aAAgC;QACnD,OAAO,OAAO,aAAa,KAAK,QAAQ;YACtC,CAAC,CAAC,aAAa;iBACV,KAAK,CAAC,GAAG,CAAC;iBACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;iBAC3B,KAAK,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,aAAa,CAAA;IACnB,CAAC;IAEO,gBAAgB,CAAC,IAAc;QACrC,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;CACF;AAhDD,wCAgDC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { RealExecutor } from "./real-executor";
|
|
2
|
+
export { DryRunExecutor } from "./dry-run-executor";
|
|
3
|
+
export { MockExecutor } from "./mock-executor";
|
|
4
|
+
export type { RealExecutorOptions } from "./real-executor";
|
|
5
|
+
export type { DryRunExecutorOptions } from "./dry-run-executor";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockExecutor = exports.DryRunExecutor = exports.RealExecutor = void 0;
|
|
4
|
+
var real_executor_1 = require("./real-executor");
|
|
5
|
+
Object.defineProperty(exports, "RealExecutor", { enumerable: true, get: function () { return real_executor_1.RealExecutor; } });
|
|
6
|
+
var dry_run_executor_1 = require("./dry-run-executor");
|
|
7
|
+
Object.defineProperty(exports, "DryRunExecutor", { enumerable: true, get: function () { return dry_run_executor_1.DryRunExecutor; } });
|
|
8
|
+
var mock_executor_1 = require("./mock-executor");
|
|
9
|
+
Object.defineProperty(exports, "MockExecutor", { enumerable: true, get: function () { return mock_executor_1.MockExecutor; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/executor/index.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAArC,6GAAA,YAAY,OAAA;AACrB,uDAAmD;AAA1C,kHAAA,cAAc,OAAA;AACvB,iDAA8C;AAArC,6GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ICommandExecutor } from "../interfaces/command-executor";
|
|
2
|
+
import type { ITmuxExecutor } from "../interfaces";
|
|
3
|
+
export declare class MockExecutor implements ICommandExecutor, ITmuxExecutor {
|
|
4
|
+
private mockPaneCounter;
|
|
5
|
+
private mockPaneIds;
|
|
6
|
+
private executedCommands;
|
|
7
|
+
execute(commandOrArgs: string | string[]): Promise<string>;
|
|
8
|
+
executeMany(commandsList: string[][]): Promise<void>;
|
|
9
|
+
isDryRun(): boolean;
|
|
10
|
+
logCommand(_command: string): void;
|
|
11
|
+
getExecutedCommands(): string[][];
|
|
12
|
+
clearExecutedCommands(): void;
|
|
13
|
+
setMockPaneIds(paneIds: string[]): void;
|
|
14
|
+
getPaneIds(): string[];
|
|
15
|
+
private parseCommand;
|
|
16
|
+
isInTmuxSession(): boolean;
|
|
17
|
+
verifyTmuxEnvironment(): Promise<void>;
|
|
18
|
+
getCommandString(args: string[]): string;
|
|
19
|
+
getCurrentSessionName(): Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=mock-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-executor.d.ts","sourceRoot":"","sources":["../../src/executor/mock-executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAMlD,qBAAa,YAAa,YAAW,gBAAgB,EAAE,aAAa;IAClE,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,gBAAgB,CAAiB;IAEnC,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAuB1D,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D,QAAQ,IAAI,OAAO;IAInB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKlC,mBAAmB,IAAI,MAAM,EAAE,EAAE;IAIjC,qBAAqB,IAAI,IAAI;IAI7B,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAIvC,UAAU,IAAI,MAAM,EAAE;IAItB,OAAO,CAAC,YAAY;IAUpB,eAAe,IAAI,OAAO;IAIpB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5C,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;IAIlC,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC;CAG/C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockExecutor = void 0;
|
|
4
|
+
const errors_1 = require("../utils/errors");
|
|
5
|
+
class MockExecutor {
|
|
6
|
+
mockPaneCounter = 0;
|
|
7
|
+
mockPaneIds = ["%0"];
|
|
8
|
+
executedCommands = [];
|
|
9
|
+
async execute(commandOrArgs) {
|
|
10
|
+
const args = this.parseCommand(commandOrArgs);
|
|
11
|
+
this.executedCommands.push(args);
|
|
12
|
+
if (args.includes("display-message") && args.includes("#{pane_id}")) {
|
|
13
|
+
return this.mockPaneIds[0] ?? "%0";
|
|
14
|
+
}
|
|
15
|
+
if (args.includes("list-panes") && args.includes("#{pane_id}")) {
|
|
16
|
+
return this.mockPaneIds.join("\n");
|
|
17
|
+
}
|
|
18
|
+
if (args.includes("split-window")) {
|
|
19
|
+
this.mockPaneCounter++;
|
|
20
|
+
const newPaneId = `%${this.mockPaneCounter}`;
|
|
21
|
+
this.mockPaneIds.push(newPaneId);
|
|
22
|
+
}
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
async executeMany(commandsList) {
|
|
26
|
+
for (const args of commandsList) {
|
|
27
|
+
await this.execute(args);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
isDryRun() {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
logCommand(_command) {
|
|
34
|
+
}
|
|
35
|
+
getExecutedCommands() {
|
|
36
|
+
return this.executedCommands;
|
|
37
|
+
}
|
|
38
|
+
clearExecutedCommands() {
|
|
39
|
+
this.executedCommands = [];
|
|
40
|
+
}
|
|
41
|
+
setMockPaneIds(paneIds) {
|
|
42
|
+
this.mockPaneIds = paneIds;
|
|
43
|
+
}
|
|
44
|
+
getPaneIds() {
|
|
45
|
+
return this.mockPaneIds;
|
|
46
|
+
}
|
|
47
|
+
parseCommand(commandOrArgs) {
|
|
48
|
+
return typeof commandOrArgs === "string"
|
|
49
|
+
? commandOrArgs
|
|
50
|
+
.split(" ")
|
|
51
|
+
.filter((s) => s.length > 0)
|
|
52
|
+
.slice(1)
|
|
53
|
+
: commandOrArgs;
|
|
54
|
+
}
|
|
55
|
+
isInTmuxSession() {
|
|
56
|
+
return Boolean(process.env.TMUX);
|
|
57
|
+
}
|
|
58
|
+
async verifyTmuxEnvironment() {
|
|
59
|
+
if (!this.isInTmuxSession()) {
|
|
60
|
+
throw new errors_1.EnvironmentError("Must be run inside a tmux session", errors_1.ErrorCodes.NOT_IN_TMUX, {
|
|
61
|
+
hint: "Please start a tmux session and try again",
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
getCommandString(args) {
|
|
66
|
+
return ["tmux", ...args].join(" ");
|
|
67
|
+
}
|
|
68
|
+
async getCurrentSessionName() {
|
|
69
|
+
return "mock-session";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MockExecutor = MockExecutor;
|
|
73
|
+
//# sourceMappingURL=mock-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-executor.js","sourceRoot":"","sources":["../../src/executor/mock-executor.ts"],"names":[],"mappings":";;;AAEA,4CAA8D;AAK9D,MAAa,YAAY;IACf,eAAe,GAAW,CAAC,CAAA;IAC3B,WAAW,GAAa,CAAC,IAAI,CAAC,CAAA;IAC9B,gBAAgB,GAAe,EAAE,CAAA;IAEzC,KAAK,CAAC,OAAO,CAAC,aAAgC;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;QAC7C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAGhC,IAAI,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YACpE,OAAO,IAAI,CAAC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,KAAK,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,aAAa,CAAA;IACnB,CAAC;IAGD,eAAe;QACb,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,yBAAgB,CAAC,mCAAmC,EAAE,mBAAU,CAAC,WAAW,EAAE;gBACtF,IAAI,EAAE,2CAA2C;aAClD,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,gBAAgB,CAAC,IAAc;QAC7B,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,qBAAqB;QACzB,OAAO,cAAc,CAAA;IACvB,CAAC;CACF;AAxFD,oCAwFC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ICommandExecutor } from "../interfaces/command-executor";
|
|
2
|
+
export interface RealExecutorOptions {
|
|
3
|
+
verbose?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class RealExecutor implements ICommandExecutor {
|
|
6
|
+
private readonly verbose;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(options?: RealExecutorOptions);
|
|
9
|
+
execute(commandOrArgs: string | string[]): Promise<string>;
|
|
10
|
+
executeMany(commandsList: string[][]): Promise<void>;
|
|
11
|
+
isDryRun(): boolean;
|
|
12
|
+
logCommand(command: string): void;
|
|
13
|
+
private parseCommand;
|
|
14
|
+
private getCommandString;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=real-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-executor.d.ts","sourceRoot":"","sources":["../../src/executor/real-executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAGtE,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAKD,qBAAa,YAAa,YAAW,gBAAgB;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAEnB,OAAO,GAAE,mBAAwB;IAQvC,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB1D,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D,QAAQ,IAAI,OAAO;IAInB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,gBAAgB;CAGzB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RealExecutor = void 0;
|
|
4
|
+
const execa_1 = require("execa");
|
|
5
|
+
const errors_1 = require("../utils/errors");
|
|
6
|
+
const logger_1 = require("../utils/logger");
|
|
7
|
+
class RealExecutor {
|
|
8
|
+
verbose;
|
|
9
|
+
logger;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.verbose = options.verbose ?? false;
|
|
12
|
+
this.logger = new logger_1.Logger({
|
|
13
|
+
level: this.verbose ? logger_1.LogLevel.INFO : logger_1.LogLevel.WARN,
|
|
14
|
+
prefix: "[tmux]",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async execute(commandOrArgs) {
|
|
18
|
+
const args = this.parseCommand(commandOrArgs);
|
|
19
|
+
const commandString = this.getCommandString(args);
|
|
20
|
+
this.logCommand(commandString);
|
|
21
|
+
try {
|
|
22
|
+
const result = await (0, execa_1.execa)("tmux", args);
|
|
23
|
+
return result.stdout;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const execaError = error;
|
|
27
|
+
throw new errors_1.TmuxError("Failed to execute tmux command", errors_1.ErrorCodes.TMUX_COMMAND_FAILED, {
|
|
28
|
+
command: commandString,
|
|
29
|
+
exitCode: execaError.exitCode,
|
|
30
|
+
stderr: execaError.stderr,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async executeMany(commandsList) {
|
|
35
|
+
for (const args of commandsList) {
|
|
36
|
+
await this.execute(args);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
isDryRun() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
logCommand(command) {
|
|
43
|
+
this.logger.info(`Executing: ${command}`);
|
|
44
|
+
}
|
|
45
|
+
parseCommand(commandOrArgs) {
|
|
46
|
+
return typeof commandOrArgs === "string"
|
|
47
|
+
? commandOrArgs
|
|
48
|
+
.split(" ")
|
|
49
|
+
.filter((s) => s.length > 0)
|
|
50
|
+
.slice(1)
|
|
51
|
+
: commandOrArgs;
|
|
52
|
+
}
|
|
53
|
+
getCommandString(args) {
|
|
54
|
+
return ["tmux", ...args].join(" ");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.RealExecutor = RealExecutor;
|
|
58
|
+
//# sourceMappingURL=real-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-executor.js","sourceRoot":"","sources":["../../src/executor/real-executor.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,4CAAuD;AAEvD,4CAAkD;AASlD,MAAa,YAAY;IACN,OAAO,CAAS;IAChB,MAAM,CAAQ;IAE/B,YAAY,UAA+B,EAAE;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAA;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC;YACvB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAQ,CAAC,IAAI,CAA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AAC,MAAM,GAAG,CAAC,CAAC;iBAC3B,KAAK,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,aAAa,CAAA;IACnB,CAAC;IAEO,gBAAgB,CAAC,IAAc;QACrC,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACpC,CAAC;CACF;AA1DD,oCA0DC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const cli_1 = require("./cli");
|
|
5
|
+
async function main() {
|
|
6
|
+
const cli = new cli_1.CLI();
|
|
7
|
+
try {
|
|
8
|
+
await cli.run(process.argv.slice(2));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error instanceof Error) {
|
|
12
|
+
console.error("Error:", error.message);
|
|
13
|
+
if (process.env.VDE_DEBUG === "true") {
|
|
14
|
+
console.error(error.stack);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.error("An unexpected error occurred:", String(error));
|
|
19
|
+
}
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
void main();
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,+BAA2B;AAM3B,KAAK,UAAU,IAAI;IACjB,MAAM,GAAG,GAAG,IAAI,SAAG,EAAE,CAAA;IACrB,IAAI,CAAC;QAEH,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAEf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;YAGtC,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;gBACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC/D,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAGD,KAAK,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-executor.d.ts","sourceRoot":"","sources":["../../src/interfaces/command-executor.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAM/B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAMpD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAKhD,QAAQ,IAAI,OAAO,CAAA;IAKnB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-executor.js","sourceRoot":"","sources":["../../src/interfaces/command-executor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Preset, PresetInfo } from "../models/types";
|
|
2
|
+
export interface IPresetManager {
|
|
3
|
+
loadConfig(): Promise<void>;
|
|
4
|
+
getPreset(name: string): Preset;
|
|
5
|
+
getDefaultPreset(): Preset;
|
|
6
|
+
listPresets(): PresetInfo[];
|
|
7
|
+
}
|
|
8
|
+
export interface IConfigLoader {
|
|
9
|
+
loadYAML(): Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
export interface ITmuxExecutor {
|
|
12
|
+
verifyTmuxEnvironment(): Promise<void>;
|
|
13
|
+
execute(command: string | string[]): Promise<string>;
|
|
14
|
+
getCurrentSessionName(): Promise<string>;
|
|
15
|
+
isInTmuxSession(): boolean;
|
|
16
|
+
getCommandString(args: string[]): string;
|
|
17
|
+
}
|
|
18
|
+
export interface ITmuxCommandGenerator {
|
|
19
|
+
newWindow(name?: string): string[];
|
|
20
|
+
splitWindow(direction: "horizontal" | "vertical", targetPane?: string, percentage?: number): string[];
|
|
21
|
+
sendKeys(paneId: string, command: string): string[];
|
|
22
|
+
selectPane(paneId: string): string[];
|
|
23
|
+
setPaneTitle(paneId: string, title: string): string[];
|
|
24
|
+
changeDirectory(paneId: string, directory: string): string[];
|
|
25
|
+
setEnvironment(paneId: string, env: Record<string, string>): string[][];
|
|
26
|
+
}
|
|
27
|
+
export interface ILayoutEngine {
|
|
28
|
+
createLayout(preset: Preset): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export type { ICommandExecutor } from "./command-executor";
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAKzD,MAAM,WAAW,cAAc;IAC7B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IAC/B,gBAAgB,IAAI,MAAM,CAAA;IAC1B,WAAW,IAAI,UAAU,EAAE,CAAA;CAC5B;AAKD,MAAM,WAAW,aAAa;IAC5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"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type TmuxExecutorOptions } from "../tmux/executor";
|
|
2
|
+
import type { Preset } from "../models/types";
|
|
3
|
+
import type { ILayoutEngine, ITmuxExecutor, ITmuxCommandGenerator, ICommandExecutor } from "../interfaces";
|
|
4
|
+
export interface LayoutEngineOptions extends Omit<TmuxExecutorOptions, "executor"> {
|
|
5
|
+
executor?: ITmuxExecutor | ICommandExecutor;
|
|
6
|
+
commandGenerator?: ITmuxCommandGenerator;
|
|
7
|
+
}
|
|
8
|
+
export declare class LayoutEngine implements ILayoutEngine {
|
|
9
|
+
private readonly executor;
|
|
10
|
+
private readonly commandGenerator;
|
|
11
|
+
constructor(options?: LayoutEngineOptions);
|
|
12
|
+
createLayout(preset: Preset): Promise<void>;
|
|
13
|
+
private createLayoutRecursive;
|
|
14
|
+
private applyPaneOptions;
|
|
15
|
+
private getCurrentPaneId;
|
|
16
|
+
private getAllPaneIds;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/layout/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEzE,OAAO,KAAK,EAAE,MAAM,EAA8B,MAAM,iBAAiB,CAAA;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAE1G,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC;IAChF,QAAQ,CAAC,EAAE,aAAa,GAAG,gBAAgB,CAAA;IAC3C,gBAAgB,CAAC,EAAE,qBAAqB,CAAA;CACzC;AAYD,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;gBAE5C,OAAO,GAAE,mBAAwB;IA2BvC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAsDnC,qBAAqB;YA6GrB,gBAAgB;YAqChB,gBAAgB;YAYhB,aAAa;CAU5B"}
|