opencode-office 0.1.15 → 0.1.17
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/dist/assets/excel.xlsx +0 -0
- package/dist/index.js +553 -4
- package/package.json +6 -1
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,569 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __require = import.meta.require;
|
|
20
|
+
|
|
21
|
+
// node_modules/winreg/lib/registry.js
|
|
22
|
+
var require_registry = __commonJS((exports, module) => {
|
|
23
|
+
var util = __require("util");
|
|
24
|
+
var path = __require("path");
|
|
25
|
+
var spawn = __require("child_process").spawn;
|
|
26
|
+
var log = function() {};
|
|
27
|
+
var HKLM = "HKLM";
|
|
28
|
+
var HKCU = "HKCU";
|
|
29
|
+
var HKCR = "HKCR";
|
|
30
|
+
var HKU = "HKU";
|
|
31
|
+
var HKCC = "HKCC";
|
|
32
|
+
var HIVES = [HKLM, HKCU, HKCR, HKU, HKCC];
|
|
33
|
+
var REG_SZ = "REG_SZ";
|
|
34
|
+
var REG_MULTI_SZ = "REG_MULTI_SZ";
|
|
35
|
+
var REG_EXPAND_SZ = "REG_EXPAND_SZ";
|
|
36
|
+
var REG_DWORD = "REG_DWORD";
|
|
37
|
+
var REG_QWORD = "REG_QWORD";
|
|
38
|
+
var REG_BINARY = "REG_BINARY";
|
|
39
|
+
var REG_NONE = "REG_NONE";
|
|
40
|
+
var REG_TYPES = [REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY, REG_NONE];
|
|
41
|
+
var DEFAULT_VALUE = "";
|
|
42
|
+
var KEY_PATTERN = /(\\[a-zA-Z0-9_\s]+)*/;
|
|
43
|
+
var PATH_PATTERN = /^(HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER|HKEY_CLASSES_ROOT|HKEY_USERS|HKEY_CURRENT_CONFIG)(.*)$/;
|
|
44
|
+
var ITEM_PATTERN = /^(.*)\s(REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY|REG_NONE)\s+([^\s].*)$/;
|
|
45
|
+
function ProcessUncleanExitError(message, code) {
|
|
46
|
+
if (!(this instanceof ProcessUncleanExitError))
|
|
47
|
+
return new ProcessUncleanExitError(message, code);
|
|
48
|
+
Error.captureStackTrace(this, ProcessUncleanExitError);
|
|
49
|
+
this.__defineGetter__("name", function() {
|
|
50
|
+
return ProcessUncleanExitError.name;
|
|
51
|
+
});
|
|
52
|
+
this.__defineGetter__("message", function() {
|
|
53
|
+
return message;
|
|
54
|
+
});
|
|
55
|
+
this.__defineGetter__("code", function() {
|
|
56
|
+
return code;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
util.inherits(ProcessUncleanExitError, Error);
|
|
60
|
+
function captureOutput(child) {
|
|
61
|
+
var output = { stdout: "", stderr: "" };
|
|
62
|
+
child.stdout.on("data", function(data) {
|
|
63
|
+
output["stdout"] += data.toString();
|
|
64
|
+
});
|
|
65
|
+
child.stderr.on("data", function(data) {
|
|
66
|
+
output["stderr"] += data.toString();
|
|
67
|
+
});
|
|
68
|
+
return output;
|
|
69
|
+
}
|
|
70
|
+
function mkErrorMsg(registryCommand, code, output) {
|
|
71
|
+
var stdout = output["stdout"].trim();
|
|
72
|
+
var stderr = output["stderr"].trim();
|
|
73
|
+
var msg = util.format(`%s command exited with code %d:
|
|
74
|
+
%s
|
|
75
|
+
%s`, registryCommand, code, stdout, stderr);
|
|
76
|
+
return new ProcessUncleanExitError(msg, code);
|
|
77
|
+
}
|
|
78
|
+
function convertArchString(archString) {
|
|
79
|
+
if (archString == "x64") {
|
|
80
|
+
return "64";
|
|
81
|
+
} else if (archString == "x86") {
|
|
82
|
+
return "32";
|
|
83
|
+
} else {
|
|
84
|
+
throw new Error("illegal architecture: " + archString + " (use x86 or x64)");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function pushArch(args, arch) {
|
|
88
|
+
if (arch) {
|
|
89
|
+
args.push("/reg:" + convertArchString(arch));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function getRegExePath() {
|
|
93
|
+
if (process.platform === "win32") {
|
|
94
|
+
return path.join(process.env.windir, "system32", "reg.exe");
|
|
95
|
+
} else {
|
|
96
|
+
return "REG";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function RegistryItem(host, hive, key, name, type, value, arch) {
|
|
100
|
+
if (!(this instanceof RegistryItem))
|
|
101
|
+
return new RegistryItem(host, hive, key, name, type, value, arch);
|
|
102
|
+
var _host = host, _hive = hive, _key = key, _name = name, _type = type, _value = value, _arch = arch;
|
|
103
|
+
this.__defineGetter__("host", function() {
|
|
104
|
+
return _host;
|
|
105
|
+
});
|
|
106
|
+
this.__defineGetter__("hive", function() {
|
|
107
|
+
return _hive;
|
|
108
|
+
});
|
|
109
|
+
this.__defineGetter__("key", function() {
|
|
110
|
+
return _key;
|
|
111
|
+
});
|
|
112
|
+
this.__defineGetter__("name", function() {
|
|
113
|
+
return _name;
|
|
114
|
+
});
|
|
115
|
+
this.__defineGetter__("type", function() {
|
|
116
|
+
return _type;
|
|
117
|
+
});
|
|
118
|
+
this.__defineGetter__("value", function() {
|
|
119
|
+
return _value;
|
|
120
|
+
});
|
|
121
|
+
this.__defineGetter__("arch", function() {
|
|
122
|
+
return _arch;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
util.inherits(RegistryItem, Object);
|
|
126
|
+
function Registry(options) {
|
|
127
|
+
if (!(this instanceof Registry))
|
|
128
|
+
return new Registry(options);
|
|
129
|
+
var _options = options || {}, _host = "" + (_options.host || ""), _hive = "" + (_options.hive || HKLM), _key = "" + (_options.key || ""), _arch = _options.arch || null;
|
|
130
|
+
this.__defineGetter__("host", function() {
|
|
131
|
+
return _host;
|
|
132
|
+
});
|
|
133
|
+
this.__defineGetter__("hive", function() {
|
|
134
|
+
return _hive;
|
|
135
|
+
});
|
|
136
|
+
this.__defineGetter__("key", function() {
|
|
137
|
+
return _key;
|
|
138
|
+
});
|
|
139
|
+
this.__defineGetter__("path", function() {
|
|
140
|
+
return '"' + (_host.length == 0 ? "" : "\\\\" + _host + "\\") + _hive + _key + '"';
|
|
141
|
+
});
|
|
142
|
+
this.__defineGetter__("arch", function() {
|
|
143
|
+
return _arch;
|
|
144
|
+
});
|
|
145
|
+
this.__defineGetter__("parent", function() {
|
|
146
|
+
var i = _key.lastIndexOf("\\");
|
|
147
|
+
return new Registry({
|
|
148
|
+
host: this.host,
|
|
149
|
+
hive: this.hive,
|
|
150
|
+
key: i == -1 ? "" : _key.substring(0, i),
|
|
151
|
+
arch: this.arch
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
if (HIVES.indexOf(_hive) == -1)
|
|
155
|
+
throw new Error("illegal hive specified.");
|
|
156
|
+
if (!KEY_PATTERN.test(_key))
|
|
157
|
+
throw new Error("illegal key specified.");
|
|
158
|
+
if (_arch && _arch != "x64" && _arch != "x86")
|
|
159
|
+
throw new Error("illegal architecture specified (use x86 or x64)");
|
|
160
|
+
}
|
|
161
|
+
Registry.HKLM = HKLM;
|
|
162
|
+
Registry.HKCU = HKCU;
|
|
163
|
+
Registry.HKCR = HKCR;
|
|
164
|
+
Registry.HKU = HKU;
|
|
165
|
+
Registry.HKCC = HKCC;
|
|
166
|
+
Registry.HIVES = HIVES;
|
|
167
|
+
Registry.REG_SZ = REG_SZ;
|
|
168
|
+
Registry.REG_MULTI_SZ = REG_MULTI_SZ;
|
|
169
|
+
Registry.REG_EXPAND_SZ = REG_EXPAND_SZ;
|
|
170
|
+
Registry.REG_DWORD = REG_DWORD;
|
|
171
|
+
Registry.REG_QWORD = REG_QWORD;
|
|
172
|
+
Registry.REG_BINARY = REG_BINARY;
|
|
173
|
+
Registry.REG_NONE = REG_NONE;
|
|
174
|
+
Registry.REG_TYPES = REG_TYPES;
|
|
175
|
+
Registry.DEFAULT_VALUE = DEFAULT_VALUE;
|
|
176
|
+
Registry.prototype.values = function values(cb) {
|
|
177
|
+
if (typeof cb !== "function")
|
|
178
|
+
throw new TypeError("must specify a callback");
|
|
179
|
+
var args = ["QUERY", this.path];
|
|
180
|
+
pushArch(args, this.arch);
|
|
181
|
+
var proc = spawn(getRegExePath(), args, {
|
|
182
|
+
cwd: undefined,
|
|
183
|
+
env: process.env,
|
|
184
|
+
shell: true,
|
|
185
|
+
windowsHide: true,
|
|
186
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
187
|
+
}), buffer = "", self = this, error = null;
|
|
188
|
+
var output = captureOutput(proc);
|
|
189
|
+
proc.on("close", function(code) {
|
|
190
|
+
if (error) {
|
|
191
|
+
return;
|
|
192
|
+
} else if (code !== 0) {
|
|
193
|
+
log("process exited with code " + code);
|
|
194
|
+
cb(mkErrorMsg("QUERY", code, output), null);
|
|
195
|
+
} else {
|
|
196
|
+
var items = [], result = [], lines = buffer.split(`
|
|
197
|
+
`), lineNumber = 0;
|
|
198
|
+
for (var i = 0, l = lines.length;i < l; i++) {
|
|
199
|
+
var line = lines[i].trim();
|
|
200
|
+
if (line.length > 0) {
|
|
201
|
+
log(line);
|
|
202
|
+
if (lineNumber != 0) {
|
|
203
|
+
items.push(line);
|
|
204
|
+
}
|
|
205
|
+
++lineNumber;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
for (var i = 0, l = items.length;i < l; i++) {
|
|
209
|
+
var match = ITEM_PATTERN.exec(items[i]), name, type, value;
|
|
210
|
+
if (match) {
|
|
211
|
+
name = match[1].trim();
|
|
212
|
+
type = match[2].trim();
|
|
213
|
+
value = match[3];
|
|
214
|
+
result.push(new RegistryItem(self.host, self.hive, self.key, name, type, value, self.arch));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
cb(null, result);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
proc.stdout.on("data", function(data) {
|
|
221
|
+
buffer += data.toString();
|
|
222
|
+
});
|
|
223
|
+
proc.on("error", function(err) {
|
|
224
|
+
error = err;
|
|
225
|
+
cb(err);
|
|
226
|
+
});
|
|
227
|
+
return this;
|
|
228
|
+
};
|
|
229
|
+
Registry.prototype.keys = function keys(cb) {
|
|
230
|
+
if (typeof cb !== "function")
|
|
231
|
+
throw new TypeError("must specify a callback");
|
|
232
|
+
var args = ["QUERY", this.path];
|
|
233
|
+
pushArch(args, this.arch);
|
|
234
|
+
var proc = spawn(getRegExePath(), args, {
|
|
235
|
+
cwd: undefined,
|
|
236
|
+
env: process.env,
|
|
237
|
+
shell: true,
|
|
238
|
+
windowsHide: true,
|
|
239
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
240
|
+
}), buffer = "", self = this, error = null;
|
|
241
|
+
var output = captureOutput(proc);
|
|
242
|
+
proc.on("close", function(code) {
|
|
243
|
+
if (error) {
|
|
244
|
+
return;
|
|
245
|
+
} else if (code !== 0) {
|
|
246
|
+
log("process exited with code " + code);
|
|
247
|
+
cb(mkErrorMsg("QUERY", code, output), null);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
proc.stdout.on("data", function(data) {
|
|
251
|
+
buffer += data.toString();
|
|
252
|
+
});
|
|
253
|
+
proc.stdout.on("end", function() {
|
|
254
|
+
var items = [], result = [], lines = buffer.split(`
|
|
255
|
+
`);
|
|
256
|
+
for (var i = 0, l = lines.length;i < l; i++) {
|
|
257
|
+
var line = lines[i].trim();
|
|
258
|
+
if (line.length > 0) {
|
|
259
|
+
log(line);
|
|
260
|
+
items.push(line);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
for (var i = 0, l = items.length;i < l; i++) {
|
|
264
|
+
var match = PATH_PATTERN.exec(items[i]), hive, key;
|
|
265
|
+
if (match) {
|
|
266
|
+
hive = match[1];
|
|
267
|
+
key = match[2];
|
|
268
|
+
if (key && key !== self.key) {
|
|
269
|
+
result.push(new Registry({
|
|
270
|
+
host: self.host,
|
|
271
|
+
hive: self.hive,
|
|
272
|
+
key,
|
|
273
|
+
arch: self.arch
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
cb(null, result);
|
|
279
|
+
});
|
|
280
|
+
proc.on("error", function(err) {
|
|
281
|
+
error = err;
|
|
282
|
+
cb(err);
|
|
283
|
+
});
|
|
284
|
+
return this;
|
|
285
|
+
};
|
|
286
|
+
Registry.prototype.get = function get(name, cb) {
|
|
287
|
+
if (typeof cb !== "function")
|
|
288
|
+
throw new TypeError("must specify a callback");
|
|
289
|
+
var args = ["QUERY", this.path];
|
|
290
|
+
if (name == "")
|
|
291
|
+
args.push("/ve");
|
|
292
|
+
else
|
|
293
|
+
args = args.concat(["/v", name]);
|
|
294
|
+
pushArch(args, this.arch);
|
|
295
|
+
var proc = spawn(getRegExePath(), args, {
|
|
296
|
+
cwd: undefined,
|
|
297
|
+
env: process.env,
|
|
298
|
+
shell: true,
|
|
299
|
+
windowsHide: true,
|
|
300
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
301
|
+
}), buffer = "", self = this, error = null;
|
|
302
|
+
var output = captureOutput(proc);
|
|
303
|
+
proc.on("close", function(code) {
|
|
304
|
+
if (error) {
|
|
305
|
+
return;
|
|
306
|
+
} else if (code !== 0) {
|
|
307
|
+
log("process exited with code " + code);
|
|
308
|
+
cb(mkErrorMsg("QUERY", code, output), null);
|
|
309
|
+
} else {
|
|
310
|
+
var items = [], result = null, lines = buffer.split(`
|
|
311
|
+
`), lineNumber = 0;
|
|
312
|
+
for (var i = 0, l = lines.length;i < l; i++) {
|
|
313
|
+
var line = lines[i].trim();
|
|
314
|
+
if (line.length > 0) {
|
|
315
|
+
log(line);
|
|
316
|
+
if (lineNumber != 0) {
|
|
317
|
+
items.push(line);
|
|
318
|
+
}
|
|
319
|
+
++lineNumber;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
var item = items[items.length - 1] || "", match = ITEM_PATTERN.exec(item), name2, type, value;
|
|
323
|
+
if (match) {
|
|
324
|
+
name2 = match[1].trim();
|
|
325
|
+
type = match[2].trim();
|
|
326
|
+
value = match[3];
|
|
327
|
+
result = new RegistryItem(self.host, self.hive, self.key, name2, type, value, self.arch);
|
|
328
|
+
}
|
|
329
|
+
cb(null, result);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
proc.stdout.on("data", function(data) {
|
|
333
|
+
buffer += data.toString();
|
|
334
|
+
});
|
|
335
|
+
proc.on("error", function(err) {
|
|
336
|
+
error = err;
|
|
337
|
+
cb(err);
|
|
338
|
+
});
|
|
339
|
+
return this;
|
|
340
|
+
};
|
|
341
|
+
Registry.prototype.set = function set(name, type, value, cb) {
|
|
342
|
+
if (typeof cb !== "function")
|
|
343
|
+
throw new TypeError("must specify a callback");
|
|
344
|
+
if (REG_TYPES.indexOf(type) == -1)
|
|
345
|
+
throw Error("illegal type specified.");
|
|
346
|
+
var args = ["ADD", this.path];
|
|
347
|
+
if (name == "")
|
|
348
|
+
args.push("/ve");
|
|
349
|
+
else
|
|
350
|
+
args = args.concat(["/v", name]);
|
|
351
|
+
args = args.concat(["/t", type, "/d", value, "/f"]);
|
|
352
|
+
pushArch(args, this.arch);
|
|
353
|
+
var proc = spawn(getRegExePath(), args, {
|
|
354
|
+
cwd: undefined,
|
|
355
|
+
env: process.env,
|
|
356
|
+
shell: true,
|
|
357
|
+
windowsHide: true,
|
|
358
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
359
|
+
}), error = null;
|
|
360
|
+
var output = captureOutput(proc);
|
|
361
|
+
proc.on("close", function(code) {
|
|
362
|
+
if (error) {
|
|
363
|
+
return;
|
|
364
|
+
} else if (code !== 0) {
|
|
365
|
+
log("process exited with code " + code);
|
|
366
|
+
cb(mkErrorMsg("ADD", code, output, null));
|
|
367
|
+
} else {
|
|
368
|
+
cb(null);
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
proc.stdout.on("data", function(data) {
|
|
372
|
+
log("" + data);
|
|
373
|
+
});
|
|
374
|
+
proc.on("error", function(err) {
|
|
375
|
+
error = err;
|
|
376
|
+
cb(err);
|
|
377
|
+
});
|
|
378
|
+
return this;
|
|
379
|
+
};
|
|
380
|
+
Registry.prototype.remove = function remove(name, cb) {
|
|
381
|
+
if (typeof cb !== "function")
|
|
382
|
+
throw new TypeError("must specify a callback");
|
|
383
|
+
var args = name ? ["DELETE", this.path, "/f", "/v", name] : ["DELETE", this.path, "/f", "/ve"];
|
|
384
|
+
pushArch(args, this.arch);
|
|
385
|
+
var proc = spawn(getRegExePath(), args, {
|
|
386
|
+
cwd: undefined,
|
|
387
|
+
env: process.env,
|
|
388
|
+
shell: true,
|
|
389
|
+
windowsHide: true,
|
|
390
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
391
|
+
}), error = null;
|
|
392
|
+
var output = captureOutput(proc);
|
|
393
|
+
proc.on("close", function(code) {
|
|
394
|
+
if (error) {
|
|
395
|
+
return;
|
|
396
|
+
} else if (code !== 0) {
|
|
397
|
+
log("process exited with code " + code);
|
|
398
|
+
cb(mkErrorMsg("DELETE", code, output), null);
|
|
399
|
+
} else {
|
|
400
|
+
cb(null);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
proc.stdout.on("data", function(data) {
|
|
404
|
+
log("" + data);
|
|
405
|
+
});
|
|
406
|
+
proc.on("error", function(err) {
|
|
407
|
+
error = err;
|
|
408
|
+
cb(err);
|
|
409
|
+
});
|
|
410
|
+
return this;
|
|
411
|
+
};
|
|
412
|
+
Registry.prototype.clear = function clear(cb) {
|
|
413
|
+
if (typeof cb !== "function")
|
|
414
|
+
throw new TypeError("must specify a callback");
|
|
415
|
+
var args = ["DELETE", this.path, "/f", "/va"];
|
|
416
|
+
pushArch(args, this.arch);
|
|
417
|
+
var proc = spawn(getRegExePath(), args, {
|
|
418
|
+
cwd: undefined,
|
|
419
|
+
env: process.env,
|
|
420
|
+
shell: true,
|
|
421
|
+
windowsHide: true,
|
|
422
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
423
|
+
}), error = null;
|
|
424
|
+
var output = captureOutput(proc);
|
|
425
|
+
proc.on("close", function(code) {
|
|
426
|
+
if (error) {
|
|
427
|
+
return;
|
|
428
|
+
} else if (code !== 0) {
|
|
429
|
+
log("process exited with code " + code);
|
|
430
|
+
cb(mkErrorMsg("DELETE", code, output), null);
|
|
431
|
+
} else {
|
|
432
|
+
cb(null);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
proc.stdout.on("data", function(data) {
|
|
436
|
+
log("" + data);
|
|
437
|
+
});
|
|
438
|
+
proc.on("error", function(err) {
|
|
439
|
+
error = err;
|
|
440
|
+
cb(err);
|
|
441
|
+
});
|
|
442
|
+
return this;
|
|
443
|
+
};
|
|
444
|
+
Registry.prototype.erase = Registry.prototype.clear;
|
|
445
|
+
Registry.prototype.destroy = function destroy(cb) {
|
|
446
|
+
if (typeof cb !== "function")
|
|
447
|
+
throw new TypeError("must specify a callback");
|
|
448
|
+
var args = ["DELETE", this.path, "/f"];
|
|
449
|
+
pushArch(args, this.arch);
|
|
450
|
+
var proc = spawn(getRegExePath(), args, {
|
|
451
|
+
cwd: undefined,
|
|
452
|
+
env: process.env,
|
|
453
|
+
shell: true,
|
|
454
|
+
windowsHide: true,
|
|
455
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
456
|
+
}), error = null;
|
|
457
|
+
var output = captureOutput(proc);
|
|
458
|
+
proc.on("close", function(code) {
|
|
459
|
+
if (error) {
|
|
460
|
+
return;
|
|
461
|
+
} else if (code !== 0) {
|
|
462
|
+
log("process exited with code " + code);
|
|
463
|
+
cb(mkErrorMsg("DELETE", code, output), null);
|
|
464
|
+
} else {
|
|
465
|
+
cb(null);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
proc.stdout.on("data", function(data) {
|
|
469
|
+
log("" + data);
|
|
470
|
+
});
|
|
471
|
+
proc.on("error", function(err) {
|
|
472
|
+
error = err;
|
|
473
|
+
cb(err);
|
|
474
|
+
});
|
|
475
|
+
return this;
|
|
476
|
+
};
|
|
477
|
+
Registry.prototype.create = function create(cb) {
|
|
478
|
+
if (typeof cb !== "function")
|
|
479
|
+
throw new TypeError("must specify a callback");
|
|
480
|
+
var args = ["ADD", this.path, "/f"];
|
|
481
|
+
pushArch(args, this.arch);
|
|
482
|
+
var proc = spawn(getRegExePath(), args, {
|
|
483
|
+
cwd: undefined,
|
|
484
|
+
env: process.env,
|
|
485
|
+
shell: true,
|
|
486
|
+
windowsHide: true,
|
|
487
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
488
|
+
}), error = null;
|
|
489
|
+
var output = captureOutput(proc);
|
|
490
|
+
proc.on("close", function(code) {
|
|
491
|
+
if (error) {
|
|
492
|
+
return;
|
|
493
|
+
} else if (code !== 0) {
|
|
494
|
+
log("process exited with code " + code);
|
|
495
|
+
cb(mkErrorMsg("ADD", code, output), null);
|
|
496
|
+
} else {
|
|
497
|
+
cb(null);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
proc.stdout.on("data", function(data) {
|
|
501
|
+
log("" + data);
|
|
502
|
+
});
|
|
503
|
+
proc.on("error", function(err) {
|
|
504
|
+
error = err;
|
|
505
|
+
cb(err);
|
|
506
|
+
});
|
|
507
|
+
return this;
|
|
508
|
+
};
|
|
509
|
+
Registry.prototype.keyExists = function keyExists(cb) {
|
|
510
|
+
this.values(function(err, items) {
|
|
511
|
+
if (err) {
|
|
512
|
+
if (err.code == 1) {
|
|
513
|
+
return cb(null, false);
|
|
514
|
+
}
|
|
515
|
+
return cb(err);
|
|
516
|
+
}
|
|
517
|
+
cb(null, true);
|
|
518
|
+
});
|
|
519
|
+
return this;
|
|
520
|
+
};
|
|
521
|
+
Registry.prototype.valueExists = function valueExists(name, cb) {
|
|
522
|
+
this.get(name, function(err, item) {
|
|
523
|
+
if (err) {
|
|
524
|
+
if (err.code == 1) {
|
|
525
|
+
return cb(null, false);
|
|
526
|
+
}
|
|
527
|
+
return cb(err);
|
|
528
|
+
}
|
|
529
|
+
cb(null, true);
|
|
530
|
+
});
|
|
531
|
+
return this;
|
|
532
|
+
};
|
|
533
|
+
module.exports = Registry;
|
|
534
|
+
});
|
|
535
|
+
|
|
2
536
|
// src/utils.ts
|
|
3
537
|
import { homedir } from "os";
|
|
4
538
|
import { join } from "path";
|
|
539
|
+
var import_winreg = __toESM(require_registry(), 1);
|
|
5
540
|
var copyManifest = async () => {
|
|
6
541
|
console.log("Copying manifest...");
|
|
542
|
+
const manifestId = "dac8f4c2-ab45-4714-9e5b-eddc1457e727";
|
|
7
543
|
const sourcePath = join(import.meta.dir, "assets", "manifest.xml");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
544
|
+
const platform = process.platform;
|
|
545
|
+
if (platform === "darwin") {
|
|
546
|
+
const destPath = join(homedir(), "Library/Containers/com.microsoft.Excel/Data/Documents/wef", "manifest.xml");
|
|
547
|
+
await Bun.write(destPath, Bun.file(sourcePath), { createPath: true });
|
|
548
|
+
console.log("Manifest copied successfully!");
|
|
549
|
+
} else if (platform === "win32") {
|
|
550
|
+
new import_winreg.default({
|
|
551
|
+
hive: import_winreg.default.HKCU,
|
|
552
|
+
key: "\\SOFTWARE\\Microsoft\\Office\\16.0\\Wef\\Developer"
|
|
553
|
+
}).set(manifestId, import_winreg.default.REG_SZ, sourcePath, (e) => console.error(e));
|
|
554
|
+
console.log("Manifest registered in Windows registry successfully!");
|
|
555
|
+
} else {
|
|
556
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
557
|
+
}
|
|
11
558
|
};
|
|
12
559
|
|
|
13
560
|
// src/index.ts
|
|
14
561
|
var OfficePlugin = async (ctx) => {
|
|
15
562
|
console.log("Microsoft Office Plugin Loaded Successfully!");
|
|
16
563
|
await copyManifest();
|
|
17
|
-
return {
|
|
564
|
+
return {
|
|
565
|
+
event: async ({ event }) => {}
|
|
566
|
+
};
|
|
18
567
|
};
|
|
19
568
|
var src_default = OfficePlugin;
|
|
20
569
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-office",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Microsoft Office plugin for OpenCode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "al-scion",
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"@opencode-ai/plugin": "^1.1.16",
|
|
25
25
|
"@types/bun": "^1.3.5",
|
|
26
26
|
"@types/node": "^25.0.7",
|
|
27
|
+
"@types/winreg": "^1.2.36",
|
|
27
28
|
"ultracite": "^7.0.11"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"fflate": "^0.8.2",
|
|
32
|
+
"winreg": "^1.2.5"
|
|
28
33
|
}
|
|
29
34
|
}
|