wdio-obsidian-service 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/README.md +3 -0
- package/dist/index.cjs +1454 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +191 -0
- package/dist/index.d.ts +191 -0
- package/dist/index.js +1436 -0
- package/dist/index.js.map +1 -0
- package/helper-plugin/main.js +13 -0
- package/helper-plugin/manifest.json +9 -0
- package/package.json +68 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1454 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// ../../node_modules/tsup/assets/cjs_shims.js
|
|
37
|
+
var getImportMetaUrl, importMetaUrl;
|
|
38
|
+
var init_cjs_shims = __esm({
|
|
39
|
+
"../../node_modules/tsup/assets/cjs_shims.js"() {
|
|
40
|
+
"use strict";
|
|
41
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
42
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// ../../node_modules/loglevel/lib/loglevel.js
|
|
47
|
+
var require_loglevel = __commonJS({
|
|
48
|
+
"../../node_modules/loglevel/lib/loglevel.js"(exports2, module2) {
|
|
49
|
+
"use strict";
|
|
50
|
+
init_cjs_shims();
|
|
51
|
+
(function(root, definition) {
|
|
52
|
+
"use strict";
|
|
53
|
+
if (typeof define === "function" && define.amd) {
|
|
54
|
+
define(definition);
|
|
55
|
+
} else if (typeof module2 === "object" && module2.exports) {
|
|
56
|
+
module2.exports = definition();
|
|
57
|
+
} else {
|
|
58
|
+
root.log = definition();
|
|
59
|
+
}
|
|
60
|
+
})(exports2, function() {
|
|
61
|
+
"use strict";
|
|
62
|
+
var noop = function() {
|
|
63
|
+
};
|
|
64
|
+
var undefinedType = "undefined";
|
|
65
|
+
var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
|
|
66
|
+
var logMethods = [
|
|
67
|
+
"trace",
|
|
68
|
+
"debug",
|
|
69
|
+
"info",
|
|
70
|
+
"warn",
|
|
71
|
+
"error"
|
|
72
|
+
];
|
|
73
|
+
var _loggersByName = {};
|
|
74
|
+
var defaultLogger = null;
|
|
75
|
+
function bindMethod(obj, methodName) {
|
|
76
|
+
var method = obj[methodName];
|
|
77
|
+
if (typeof method.bind === "function") {
|
|
78
|
+
return method.bind(obj);
|
|
79
|
+
} else {
|
|
80
|
+
try {
|
|
81
|
+
return Function.prototype.bind.call(method, obj);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return function() {
|
|
84
|
+
return Function.prototype.apply.apply(method, [obj, arguments]);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function traceForIE() {
|
|
90
|
+
if (console.log) {
|
|
91
|
+
if (console.log.apply) {
|
|
92
|
+
console.log.apply(console, arguments);
|
|
93
|
+
} else {
|
|
94
|
+
Function.prototype.apply.apply(console.log, [console, arguments]);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (console.trace) console.trace();
|
|
98
|
+
}
|
|
99
|
+
function realMethod(methodName) {
|
|
100
|
+
if (methodName === "debug") {
|
|
101
|
+
methodName = "log";
|
|
102
|
+
}
|
|
103
|
+
if (typeof console === undefinedType) {
|
|
104
|
+
return false;
|
|
105
|
+
} else if (methodName === "trace" && isIE) {
|
|
106
|
+
return traceForIE;
|
|
107
|
+
} else if (console[methodName] !== void 0) {
|
|
108
|
+
return bindMethod(console, methodName);
|
|
109
|
+
} else if (console.log !== void 0) {
|
|
110
|
+
return bindMethod(console, "log");
|
|
111
|
+
} else {
|
|
112
|
+
return noop;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function replaceLoggingMethods() {
|
|
116
|
+
var level = this.getLevel();
|
|
117
|
+
for (var i = 0; i < logMethods.length; i++) {
|
|
118
|
+
var methodName = logMethods[i];
|
|
119
|
+
this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
|
|
120
|
+
}
|
|
121
|
+
this.log = this.debug;
|
|
122
|
+
if (typeof console === undefinedType && level < this.levels.SILENT) {
|
|
123
|
+
return "No console available for logging";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function enableLoggingWhenConsoleArrives(methodName) {
|
|
127
|
+
return function() {
|
|
128
|
+
if (typeof console !== undefinedType) {
|
|
129
|
+
replaceLoggingMethods.call(this);
|
|
130
|
+
this[methodName].apply(this, arguments);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function defaultMethodFactory(methodName, _level, _loggerName) {
|
|
135
|
+
return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
|
|
136
|
+
}
|
|
137
|
+
function Logger(name, factory) {
|
|
138
|
+
var self = this;
|
|
139
|
+
var inheritedLevel;
|
|
140
|
+
var defaultLevel;
|
|
141
|
+
var userLevel;
|
|
142
|
+
var storageKey = "loglevel";
|
|
143
|
+
if (typeof name === "string") {
|
|
144
|
+
storageKey += ":" + name;
|
|
145
|
+
} else if (typeof name === "symbol") {
|
|
146
|
+
storageKey = void 0;
|
|
147
|
+
}
|
|
148
|
+
function persistLevelIfPossible(levelNum) {
|
|
149
|
+
var levelName = (logMethods[levelNum] || "silent").toUpperCase();
|
|
150
|
+
if (typeof window === undefinedType || !storageKey) return;
|
|
151
|
+
try {
|
|
152
|
+
window.localStorage[storageKey] = levelName;
|
|
153
|
+
return;
|
|
154
|
+
} catch (ignore) {
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
|
|
158
|
+
} catch (ignore) {
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function getPersistedLevel() {
|
|
162
|
+
var storedLevel;
|
|
163
|
+
if (typeof window === undefinedType || !storageKey) return;
|
|
164
|
+
try {
|
|
165
|
+
storedLevel = window.localStorage[storageKey];
|
|
166
|
+
} catch (ignore) {
|
|
167
|
+
}
|
|
168
|
+
if (typeof storedLevel === undefinedType) {
|
|
169
|
+
try {
|
|
170
|
+
var cookie = window.document.cookie;
|
|
171
|
+
var cookieName = encodeURIComponent(storageKey);
|
|
172
|
+
var location = cookie.indexOf(cookieName + "=");
|
|
173
|
+
if (location !== -1) {
|
|
174
|
+
storedLevel = /^([^;]+)/.exec(
|
|
175
|
+
cookie.slice(location + cookieName.length + 1)
|
|
176
|
+
)[1];
|
|
177
|
+
}
|
|
178
|
+
} catch (ignore) {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (self.levels[storedLevel] === void 0) {
|
|
182
|
+
storedLevel = void 0;
|
|
183
|
+
}
|
|
184
|
+
return storedLevel;
|
|
185
|
+
}
|
|
186
|
+
function clearPersistedLevel() {
|
|
187
|
+
if (typeof window === undefinedType || !storageKey) return;
|
|
188
|
+
try {
|
|
189
|
+
window.localStorage.removeItem(storageKey);
|
|
190
|
+
} catch (ignore) {
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
194
|
+
} catch (ignore) {
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function normalizeLevel(input) {
|
|
198
|
+
var level = input;
|
|
199
|
+
if (typeof level === "string" && self.levels[level.toUpperCase()] !== void 0) {
|
|
200
|
+
level = self.levels[level.toUpperCase()];
|
|
201
|
+
}
|
|
202
|
+
if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
|
|
203
|
+
return level;
|
|
204
|
+
} else {
|
|
205
|
+
throw new TypeError("log.setLevel() called with invalid level: " + input);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
self.name = name;
|
|
209
|
+
self.levels = {
|
|
210
|
+
"TRACE": 0,
|
|
211
|
+
"DEBUG": 1,
|
|
212
|
+
"INFO": 2,
|
|
213
|
+
"WARN": 3,
|
|
214
|
+
"ERROR": 4,
|
|
215
|
+
"SILENT": 5
|
|
216
|
+
};
|
|
217
|
+
self.methodFactory = factory || defaultMethodFactory;
|
|
218
|
+
self.getLevel = function() {
|
|
219
|
+
if (userLevel != null) {
|
|
220
|
+
return userLevel;
|
|
221
|
+
} else if (defaultLevel != null) {
|
|
222
|
+
return defaultLevel;
|
|
223
|
+
} else {
|
|
224
|
+
return inheritedLevel;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
self.setLevel = function(level, persist) {
|
|
228
|
+
userLevel = normalizeLevel(level);
|
|
229
|
+
if (persist !== false) {
|
|
230
|
+
persistLevelIfPossible(userLevel);
|
|
231
|
+
}
|
|
232
|
+
return replaceLoggingMethods.call(self);
|
|
233
|
+
};
|
|
234
|
+
self.setDefaultLevel = function(level) {
|
|
235
|
+
defaultLevel = normalizeLevel(level);
|
|
236
|
+
if (!getPersistedLevel()) {
|
|
237
|
+
self.setLevel(level, false);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
self.resetLevel = function() {
|
|
241
|
+
userLevel = null;
|
|
242
|
+
clearPersistedLevel();
|
|
243
|
+
replaceLoggingMethods.call(self);
|
|
244
|
+
};
|
|
245
|
+
self.enableAll = function(persist) {
|
|
246
|
+
self.setLevel(self.levels.TRACE, persist);
|
|
247
|
+
};
|
|
248
|
+
self.disableAll = function(persist) {
|
|
249
|
+
self.setLevel(self.levels.SILENT, persist);
|
|
250
|
+
};
|
|
251
|
+
self.rebuild = function() {
|
|
252
|
+
if (defaultLogger !== self) {
|
|
253
|
+
inheritedLevel = normalizeLevel(defaultLogger.getLevel());
|
|
254
|
+
}
|
|
255
|
+
replaceLoggingMethods.call(self);
|
|
256
|
+
if (defaultLogger === self) {
|
|
257
|
+
for (var childName in _loggersByName) {
|
|
258
|
+
_loggersByName[childName].rebuild();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
inheritedLevel = normalizeLevel(
|
|
263
|
+
defaultLogger ? defaultLogger.getLevel() : "WARN"
|
|
264
|
+
);
|
|
265
|
+
var initialLevel = getPersistedLevel();
|
|
266
|
+
if (initialLevel != null) {
|
|
267
|
+
userLevel = normalizeLevel(initialLevel);
|
|
268
|
+
}
|
|
269
|
+
replaceLoggingMethods.call(self);
|
|
270
|
+
}
|
|
271
|
+
defaultLogger = new Logger();
|
|
272
|
+
defaultLogger.getLogger = function getLogger2(name) {
|
|
273
|
+
if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
|
|
274
|
+
throw new TypeError("You must supply a name when creating a logger.");
|
|
275
|
+
}
|
|
276
|
+
var logger = _loggersByName[name];
|
|
277
|
+
if (!logger) {
|
|
278
|
+
logger = _loggersByName[name] = new Logger(
|
|
279
|
+
name,
|
|
280
|
+
defaultLogger.methodFactory
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return logger;
|
|
284
|
+
};
|
|
285
|
+
var _log = typeof window !== undefinedType ? window.log : void 0;
|
|
286
|
+
defaultLogger.noConflict = function() {
|
|
287
|
+
if (typeof window !== undefinedType && window.log === defaultLogger) {
|
|
288
|
+
window.log = _log;
|
|
289
|
+
}
|
|
290
|
+
return defaultLogger;
|
|
291
|
+
};
|
|
292
|
+
defaultLogger.getLoggers = function getLoggers() {
|
|
293
|
+
return _loggersByName;
|
|
294
|
+
};
|
|
295
|
+
defaultLogger["default"] = defaultLogger;
|
|
296
|
+
return defaultLogger;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// ../../node_modules/loglevel-plugin-prefix/lib/loglevel-plugin-prefix.js
|
|
302
|
+
var require_loglevel_plugin_prefix = __commonJS({
|
|
303
|
+
"../../node_modules/loglevel-plugin-prefix/lib/loglevel-plugin-prefix.js"(exports2, module2) {
|
|
304
|
+
"use strict";
|
|
305
|
+
init_cjs_shims();
|
|
306
|
+
(function(root, factory) {
|
|
307
|
+
if (typeof define === "function" && define.amd) {
|
|
308
|
+
define(factory);
|
|
309
|
+
} else if (typeof module2 === "object" && module2.exports) {
|
|
310
|
+
module2.exports = factory();
|
|
311
|
+
} else {
|
|
312
|
+
root.prefix = factory(root);
|
|
313
|
+
}
|
|
314
|
+
})(exports2, function(root) {
|
|
315
|
+
"use strict";
|
|
316
|
+
var merge = function(target) {
|
|
317
|
+
var i = 1;
|
|
318
|
+
var length = arguments.length;
|
|
319
|
+
var key;
|
|
320
|
+
for (; i < length; i++) {
|
|
321
|
+
for (key in arguments[i]) {
|
|
322
|
+
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
|
|
323
|
+
target[key] = arguments[i][key];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return target;
|
|
328
|
+
};
|
|
329
|
+
var defaults = {
|
|
330
|
+
template: "[%t] %l:",
|
|
331
|
+
levelFormatter: function(level) {
|
|
332
|
+
return level.toUpperCase();
|
|
333
|
+
},
|
|
334
|
+
nameFormatter: function(name) {
|
|
335
|
+
return name || "root";
|
|
336
|
+
},
|
|
337
|
+
timestampFormatter: function(date) {
|
|
338
|
+
return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
|
|
339
|
+
},
|
|
340
|
+
format: void 0
|
|
341
|
+
};
|
|
342
|
+
var loglevel;
|
|
343
|
+
var configs = {};
|
|
344
|
+
var reg = function(rootLogger) {
|
|
345
|
+
if (!rootLogger || !rootLogger.getLogger) {
|
|
346
|
+
throw new TypeError("Argument is not a root logger");
|
|
347
|
+
}
|
|
348
|
+
loglevel = rootLogger;
|
|
349
|
+
};
|
|
350
|
+
var apply = function(logger, config) {
|
|
351
|
+
if (!logger || !logger.setLevel) {
|
|
352
|
+
throw new TypeError("Argument is not a logger");
|
|
353
|
+
}
|
|
354
|
+
var originalFactory2 = logger.methodFactory;
|
|
355
|
+
var name = logger.name || "";
|
|
356
|
+
var parent = configs[name] || configs[""] || defaults;
|
|
357
|
+
function methodFactory(methodName, logLevel, loggerName) {
|
|
358
|
+
var originalMethod = originalFactory2(methodName, logLevel, loggerName);
|
|
359
|
+
var options = configs[loggerName] || configs[""];
|
|
360
|
+
var hasTimestamp = options.template.indexOf("%t") !== -1;
|
|
361
|
+
var hasLevel = options.template.indexOf("%l") !== -1;
|
|
362
|
+
var hasName = options.template.indexOf("%n") !== -1;
|
|
363
|
+
return function() {
|
|
364
|
+
var content = "";
|
|
365
|
+
var length = arguments.length;
|
|
366
|
+
var args = Array(length);
|
|
367
|
+
var key = 0;
|
|
368
|
+
for (; key < length; key++) {
|
|
369
|
+
args[key] = arguments[key];
|
|
370
|
+
}
|
|
371
|
+
if (name || !configs[loggerName]) {
|
|
372
|
+
var timestamp = options.timestampFormatter(/* @__PURE__ */ new Date());
|
|
373
|
+
var level = options.levelFormatter(methodName);
|
|
374
|
+
var lname = options.nameFormatter(loggerName);
|
|
375
|
+
if (options.format) {
|
|
376
|
+
content += options.format(level, lname, timestamp);
|
|
377
|
+
} else {
|
|
378
|
+
content += options.template;
|
|
379
|
+
if (hasTimestamp) {
|
|
380
|
+
content = content.replace(/%t/, timestamp);
|
|
381
|
+
}
|
|
382
|
+
if (hasLevel) content = content.replace(/%l/, level);
|
|
383
|
+
if (hasName) content = content.replace(/%n/, lname);
|
|
384
|
+
}
|
|
385
|
+
if (args.length && typeof args[0] === "string") {
|
|
386
|
+
args[0] = content + " " + args[0];
|
|
387
|
+
} else {
|
|
388
|
+
args.unshift(content);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
originalMethod.apply(void 0, args);
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
if (!configs[name]) {
|
|
395
|
+
logger.methodFactory = methodFactory;
|
|
396
|
+
}
|
|
397
|
+
config = config || {};
|
|
398
|
+
if (config.template) config.format = void 0;
|
|
399
|
+
configs[name] = merge({}, parent, config);
|
|
400
|
+
logger.setLevel(logger.getLevel());
|
|
401
|
+
if (!loglevel) {
|
|
402
|
+
logger.warn(
|
|
403
|
+
"It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md"
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
return logger;
|
|
407
|
+
};
|
|
408
|
+
var api = {
|
|
409
|
+
reg,
|
|
410
|
+
apply
|
|
411
|
+
};
|
|
412
|
+
var save;
|
|
413
|
+
if (root) {
|
|
414
|
+
save = root.prefix;
|
|
415
|
+
api.noConflict = function() {
|
|
416
|
+
if (root.prefix === api) {
|
|
417
|
+
root.prefix = save;
|
|
418
|
+
}
|
|
419
|
+
return api;
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return api;
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// src/index.ts
|
|
428
|
+
var index_exports = {};
|
|
429
|
+
__export(index_exports, {
|
|
430
|
+
ObsidianLauncherService: () => ObsidianLauncherService,
|
|
431
|
+
ObsidianWorkerService: () => ObsidianWorkerService,
|
|
432
|
+
default: () => index_default,
|
|
433
|
+
launcher: () => launcher,
|
|
434
|
+
obsidianBetaAvailable: () => obsidianBetaAvailable
|
|
435
|
+
});
|
|
436
|
+
module.exports = __toCommonJS(index_exports);
|
|
437
|
+
init_cjs_shims();
|
|
438
|
+
var import_obsidian_launcher2 = __toESM(require("obsidian-launcher"), 1);
|
|
439
|
+
|
|
440
|
+
// src/service.ts
|
|
441
|
+
init_cjs_shims();
|
|
442
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
443
|
+
var import_path = __toESM(require("path"), 1);
|
|
444
|
+
var import_webdriverio = require("webdriverio");
|
|
445
|
+
|
|
446
|
+
// ../../node_modules/@wdio/logger/build/index.js
|
|
447
|
+
init_cjs_shims();
|
|
448
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
449
|
+
var import_node_util = __toESM(require("util"), 1);
|
|
450
|
+
var import_loglevel = __toESM(require_loglevel(), 1);
|
|
451
|
+
|
|
452
|
+
// ../../node_modules/chalk/source/index.js
|
|
453
|
+
init_cjs_shims();
|
|
454
|
+
|
|
455
|
+
// ../../node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
456
|
+
init_cjs_shims();
|
|
457
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
458
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
459
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
460
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
461
|
+
var styles = {
|
|
462
|
+
modifier: {
|
|
463
|
+
reset: [0, 0],
|
|
464
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
465
|
+
bold: [1, 22],
|
|
466
|
+
dim: [2, 22],
|
|
467
|
+
italic: [3, 23],
|
|
468
|
+
underline: [4, 24],
|
|
469
|
+
overline: [53, 55],
|
|
470
|
+
inverse: [7, 27],
|
|
471
|
+
hidden: [8, 28],
|
|
472
|
+
strikethrough: [9, 29]
|
|
473
|
+
},
|
|
474
|
+
color: {
|
|
475
|
+
black: [30, 39],
|
|
476
|
+
red: [31, 39],
|
|
477
|
+
green: [32, 39],
|
|
478
|
+
yellow: [33, 39],
|
|
479
|
+
blue: [34, 39],
|
|
480
|
+
magenta: [35, 39],
|
|
481
|
+
cyan: [36, 39],
|
|
482
|
+
white: [37, 39],
|
|
483
|
+
// Bright color
|
|
484
|
+
blackBright: [90, 39],
|
|
485
|
+
gray: [90, 39],
|
|
486
|
+
// Alias of `blackBright`
|
|
487
|
+
grey: [90, 39],
|
|
488
|
+
// Alias of `blackBright`
|
|
489
|
+
redBright: [91, 39],
|
|
490
|
+
greenBright: [92, 39],
|
|
491
|
+
yellowBright: [93, 39],
|
|
492
|
+
blueBright: [94, 39],
|
|
493
|
+
magentaBright: [95, 39],
|
|
494
|
+
cyanBright: [96, 39],
|
|
495
|
+
whiteBright: [97, 39]
|
|
496
|
+
},
|
|
497
|
+
bgColor: {
|
|
498
|
+
bgBlack: [40, 49],
|
|
499
|
+
bgRed: [41, 49],
|
|
500
|
+
bgGreen: [42, 49],
|
|
501
|
+
bgYellow: [43, 49],
|
|
502
|
+
bgBlue: [44, 49],
|
|
503
|
+
bgMagenta: [45, 49],
|
|
504
|
+
bgCyan: [46, 49],
|
|
505
|
+
bgWhite: [47, 49],
|
|
506
|
+
// Bright color
|
|
507
|
+
bgBlackBright: [100, 49],
|
|
508
|
+
bgGray: [100, 49],
|
|
509
|
+
// Alias of `bgBlackBright`
|
|
510
|
+
bgGrey: [100, 49],
|
|
511
|
+
// Alias of `bgBlackBright`
|
|
512
|
+
bgRedBright: [101, 49],
|
|
513
|
+
bgGreenBright: [102, 49],
|
|
514
|
+
bgYellowBright: [103, 49],
|
|
515
|
+
bgBlueBright: [104, 49],
|
|
516
|
+
bgMagentaBright: [105, 49],
|
|
517
|
+
bgCyanBright: [106, 49],
|
|
518
|
+
bgWhiteBright: [107, 49]
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
522
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
523
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
524
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
525
|
+
function assembleStyles() {
|
|
526
|
+
const codes = /* @__PURE__ */ new Map();
|
|
527
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
528
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
529
|
+
styles[styleName] = {
|
|
530
|
+
open: `\x1B[${style[0]}m`,
|
|
531
|
+
close: `\x1B[${style[1]}m`
|
|
532
|
+
};
|
|
533
|
+
group[styleName] = styles[styleName];
|
|
534
|
+
codes.set(style[0], style[1]);
|
|
535
|
+
}
|
|
536
|
+
Object.defineProperty(styles, groupName, {
|
|
537
|
+
value: group,
|
|
538
|
+
enumerable: false
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
Object.defineProperty(styles, "codes", {
|
|
542
|
+
value: codes,
|
|
543
|
+
enumerable: false
|
|
544
|
+
});
|
|
545
|
+
styles.color.close = "\x1B[39m";
|
|
546
|
+
styles.bgColor.close = "\x1B[49m";
|
|
547
|
+
styles.color.ansi = wrapAnsi16();
|
|
548
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
549
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
550
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
551
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
552
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
553
|
+
Object.defineProperties(styles, {
|
|
554
|
+
rgbToAnsi256: {
|
|
555
|
+
value(red, green, blue) {
|
|
556
|
+
if (red === green && green === blue) {
|
|
557
|
+
if (red < 8) {
|
|
558
|
+
return 16;
|
|
559
|
+
}
|
|
560
|
+
if (red > 248) {
|
|
561
|
+
return 231;
|
|
562
|
+
}
|
|
563
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
564
|
+
}
|
|
565
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
566
|
+
},
|
|
567
|
+
enumerable: false
|
|
568
|
+
},
|
|
569
|
+
hexToRgb: {
|
|
570
|
+
value(hex) {
|
|
571
|
+
const matches2 = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
572
|
+
if (!matches2) {
|
|
573
|
+
return [0, 0, 0];
|
|
574
|
+
}
|
|
575
|
+
let [colorString] = matches2;
|
|
576
|
+
if (colorString.length === 3) {
|
|
577
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
578
|
+
}
|
|
579
|
+
const integer = Number.parseInt(colorString, 16);
|
|
580
|
+
return [
|
|
581
|
+
/* eslint-disable no-bitwise */
|
|
582
|
+
integer >> 16 & 255,
|
|
583
|
+
integer >> 8 & 255,
|
|
584
|
+
integer & 255
|
|
585
|
+
/* eslint-enable no-bitwise */
|
|
586
|
+
];
|
|
587
|
+
},
|
|
588
|
+
enumerable: false
|
|
589
|
+
},
|
|
590
|
+
hexToAnsi256: {
|
|
591
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
592
|
+
enumerable: false
|
|
593
|
+
},
|
|
594
|
+
ansi256ToAnsi: {
|
|
595
|
+
value(code) {
|
|
596
|
+
if (code < 8) {
|
|
597
|
+
return 30 + code;
|
|
598
|
+
}
|
|
599
|
+
if (code < 16) {
|
|
600
|
+
return 90 + (code - 8);
|
|
601
|
+
}
|
|
602
|
+
let red;
|
|
603
|
+
let green;
|
|
604
|
+
let blue;
|
|
605
|
+
if (code >= 232) {
|
|
606
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
607
|
+
green = red;
|
|
608
|
+
blue = red;
|
|
609
|
+
} else {
|
|
610
|
+
code -= 16;
|
|
611
|
+
const remainder = code % 36;
|
|
612
|
+
red = Math.floor(code / 36) / 5;
|
|
613
|
+
green = Math.floor(remainder / 6) / 5;
|
|
614
|
+
blue = remainder % 6 / 5;
|
|
615
|
+
}
|
|
616
|
+
const value = Math.max(red, green, blue) * 2;
|
|
617
|
+
if (value === 0) {
|
|
618
|
+
return 30;
|
|
619
|
+
}
|
|
620
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
621
|
+
if (value === 2) {
|
|
622
|
+
result += 60;
|
|
623
|
+
}
|
|
624
|
+
return result;
|
|
625
|
+
},
|
|
626
|
+
enumerable: false
|
|
627
|
+
},
|
|
628
|
+
rgbToAnsi: {
|
|
629
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
630
|
+
enumerable: false
|
|
631
|
+
},
|
|
632
|
+
hexToAnsi: {
|
|
633
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
634
|
+
enumerable: false
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
return styles;
|
|
638
|
+
}
|
|
639
|
+
var ansiStyles = assembleStyles();
|
|
640
|
+
var ansi_styles_default = ansiStyles;
|
|
641
|
+
|
|
642
|
+
// ../../node_modules/chalk/source/vendor/supports-color/index.js
|
|
643
|
+
init_cjs_shims();
|
|
644
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
645
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
646
|
+
var import_node_tty = __toESM(require("tty"), 1);
|
|
647
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
648
|
+
const prefix2 = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
649
|
+
const position = argv.indexOf(prefix2 + flag);
|
|
650
|
+
const terminatorPosition = argv.indexOf("--");
|
|
651
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
652
|
+
}
|
|
653
|
+
var { env } = import_node_process.default;
|
|
654
|
+
var flagForceColor;
|
|
655
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
656
|
+
flagForceColor = 0;
|
|
657
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
658
|
+
flagForceColor = 1;
|
|
659
|
+
}
|
|
660
|
+
function envForceColor() {
|
|
661
|
+
if ("FORCE_COLOR" in env) {
|
|
662
|
+
if (env.FORCE_COLOR === "true") {
|
|
663
|
+
return 1;
|
|
664
|
+
}
|
|
665
|
+
if (env.FORCE_COLOR === "false") {
|
|
666
|
+
return 0;
|
|
667
|
+
}
|
|
668
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function translateLevel(level) {
|
|
672
|
+
if (level === 0) {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
level,
|
|
677
|
+
hasBasic: true,
|
|
678
|
+
has256: level >= 2,
|
|
679
|
+
has16m: level >= 3
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
683
|
+
const noFlagForceColor = envForceColor();
|
|
684
|
+
if (noFlagForceColor !== void 0) {
|
|
685
|
+
flagForceColor = noFlagForceColor;
|
|
686
|
+
}
|
|
687
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
688
|
+
if (forceColor === 0) {
|
|
689
|
+
return 0;
|
|
690
|
+
}
|
|
691
|
+
if (sniffFlags) {
|
|
692
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
693
|
+
return 3;
|
|
694
|
+
}
|
|
695
|
+
if (hasFlag("color=256")) {
|
|
696
|
+
return 2;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
700
|
+
return 1;
|
|
701
|
+
}
|
|
702
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
703
|
+
return 0;
|
|
704
|
+
}
|
|
705
|
+
const min = forceColor || 0;
|
|
706
|
+
if (env.TERM === "dumb") {
|
|
707
|
+
return min;
|
|
708
|
+
}
|
|
709
|
+
if (import_node_process.default.platform === "win32") {
|
|
710
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
711
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
712
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
713
|
+
}
|
|
714
|
+
return 1;
|
|
715
|
+
}
|
|
716
|
+
if ("CI" in env) {
|
|
717
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
718
|
+
return 3;
|
|
719
|
+
}
|
|
720
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
721
|
+
return 1;
|
|
722
|
+
}
|
|
723
|
+
return min;
|
|
724
|
+
}
|
|
725
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
726
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
727
|
+
}
|
|
728
|
+
if (env.COLORTERM === "truecolor") {
|
|
729
|
+
return 3;
|
|
730
|
+
}
|
|
731
|
+
if (env.TERM === "xterm-kitty") {
|
|
732
|
+
return 3;
|
|
733
|
+
}
|
|
734
|
+
if ("TERM_PROGRAM" in env) {
|
|
735
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
736
|
+
switch (env.TERM_PROGRAM) {
|
|
737
|
+
case "iTerm.app": {
|
|
738
|
+
return version >= 3 ? 3 : 2;
|
|
739
|
+
}
|
|
740
|
+
case "Apple_Terminal": {
|
|
741
|
+
return 2;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
746
|
+
return 2;
|
|
747
|
+
}
|
|
748
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
749
|
+
return 1;
|
|
750
|
+
}
|
|
751
|
+
if ("COLORTERM" in env) {
|
|
752
|
+
return 1;
|
|
753
|
+
}
|
|
754
|
+
return min;
|
|
755
|
+
}
|
|
756
|
+
function createSupportsColor(stream, options = {}) {
|
|
757
|
+
const level = _supportsColor(stream, {
|
|
758
|
+
streamIsTTY: stream && stream.isTTY,
|
|
759
|
+
...options
|
|
760
|
+
});
|
|
761
|
+
return translateLevel(level);
|
|
762
|
+
}
|
|
763
|
+
var supportsColor = {
|
|
764
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
765
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
766
|
+
};
|
|
767
|
+
var supports_color_default = supportsColor;
|
|
768
|
+
|
|
769
|
+
// ../../node_modules/chalk/source/utilities.js
|
|
770
|
+
init_cjs_shims();
|
|
771
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
772
|
+
let index = string.indexOf(substring);
|
|
773
|
+
if (index === -1) {
|
|
774
|
+
return string;
|
|
775
|
+
}
|
|
776
|
+
const substringLength = substring.length;
|
|
777
|
+
let endIndex = 0;
|
|
778
|
+
let returnValue = "";
|
|
779
|
+
do {
|
|
780
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
781
|
+
endIndex = index + substringLength;
|
|
782
|
+
index = string.indexOf(substring, endIndex);
|
|
783
|
+
} while (index !== -1);
|
|
784
|
+
returnValue += string.slice(endIndex);
|
|
785
|
+
return returnValue;
|
|
786
|
+
}
|
|
787
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix2, postfix, index) {
|
|
788
|
+
let endIndex = 0;
|
|
789
|
+
let returnValue = "";
|
|
790
|
+
do {
|
|
791
|
+
const gotCR = string[index - 1] === "\r";
|
|
792
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix2 + (gotCR ? "\r\n" : "\n") + postfix;
|
|
793
|
+
endIndex = index + 1;
|
|
794
|
+
index = string.indexOf("\n", endIndex);
|
|
795
|
+
} while (index !== -1);
|
|
796
|
+
returnValue += string.slice(endIndex);
|
|
797
|
+
return returnValue;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// ../../node_modules/chalk/source/index.js
|
|
801
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
802
|
+
var GENERATOR = Symbol("GENERATOR");
|
|
803
|
+
var STYLER = Symbol("STYLER");
|
|
804
|
+
var IS_EMPTY = Symbol("IS_EMPTY");
|
|
805
|
+
var levelMapping = [
|
|
806
|
+
"ansi",
|
|
807
|
+
"ansi",
|
|
808
|
+
"ansi256",
|
|
809
|
+
"ansi16m"
|
|
810
|
+
];
|
|
811
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
812
|
+
var applyOptions = (object, options = {}) => {
|
|
813
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
814
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
815
|
+
}
|
|
816
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
817
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
818
|
+
};
|
|
819
|
+
var chalkFactory = (options) => {
|
|
820
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
821
|
+
applyOptions(chalk2, options);
|
|
822
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
823
|
+
return chalk2;
|
|
824
|
+
};
|
|
825
|
+
function createChalk(options) {
|
|
826
|
+
return chalkFactory(options);
|
|
827
|
+
}
|
|
828
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
829
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
830
|
+
styles2[styleName] = {
|
|
831
|
+
get() {
|
|
832
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
833
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
834
|
+
return builder;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
styles2.visible = {
|
|
839
|
+
get() {
|
|
840
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
841
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
842
|
+
return builder;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
846
|
+
if (model === "rgb") {
|
|
847
|
+
if (level === "ansi16m") {
|
|
848
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
849
|
+
}
|
|
850
|
+
if (level === "ansi256") {
|
|
851
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
852
|
+
}
|
|
853
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
854
|
+
}
|
|
855
|
+
if (model === "hex") {
|
|
856
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
857
|
+
}
|
|
858
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
859
|
+
};
|
|
860
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
861
|
+
for (const model of usedModels) {
|
|
862
|
+
styles2[model] = {
|
|
863
|
+
get() {
|
|
864
|
+
const { level } = this;
|
|
865
|
+
return function(...arguments_) {
|
|
866
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
867
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
872
|
+
styles2[bgModel] = {
|
|
873
|
+
get() {
|
|
874
|
+
const { level } = this;
|
|
875
|
+
return function(...arguments_) {
|
|
876
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
877
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
var proto = Object.defineProperties(() => {
|
|
883
|
+
}, {
|
|
884
|
+
...styles2,
|
|
885
|
+
level: {
|
|
886
|
+
enumerable: true,
|
|
887
|
+
get() {
|
|
888
|
+
return this[GENERATOR].level;
|
|
889
|
+
},
|
|
890
|
+
set(level) {
|
|
891
|
+
this[GENERATOR].level = level;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
var createStyler = (open, close, parent) => {
|
|
896
|
+
let openAll;
|
|
897
|
+
let closeAll;
|
|
898
|
+
if (parent === void 0) {
|
|
899
|
+
openAll = open;
|
|
900
|
+
closeAll = close;
|
|
901
|
+
} else {
|
|
902
|
+
openAll = parent.openAll + open;
|
|
903
|
+
closeAll = close + parent.closeAll;
|
|
904
|
+
}
|
|
905
|
+
return {
|
|
906
|
+
open,
|
|
907
|
+
close,
|
|
908
|
+
openAll,
|
|
909
|
+
closeAll,
|
|
910
|
+
parent
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
914
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
915
|
+
Object.setPrototypeOf(builder, proto);
|
|
916
|
+
builder[GENERATOR] = self;
|
|
917
|
+
builder[STYLER] = _styler;
|
|
918
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
919
|
+
return builder;
|
|
920
|
+
};
|
|
921
|
+
var applyStyle = (self, string) => {
|
|
922
|
+
if (self.level <= 0 || !string) {
|
|
923
|
+
return self[IS_EMPTY] ? "" : string;
|
|
924
|
+
}
|
|
925
|
+
let styler = self[STYLER];
|
|
926
|
+
if (styler === void 0) {
|
|
927
|
+
return string;
|
|
928
|
+
}
|
|
929
|
+
const { openAll, closeAll } = styler;
|
|
930
|
+
if (string.includes("\x1B")) {
|
|
931
|
+
while (styler !== void 0) {
|
|
932
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
933
|
+
styler = styler.parent;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
const lfIndex = string.indexOf("\n");
|
|
937
|
+
if (lfIndex !== -1) {
|
|
938
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
939
|
+
}
|
|
940
|
+
return openAll + string + closeAll;
|
|
941
|
+
};
|
|
942
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
943
|
+
var chalk = createChalk();
|
|
944
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
945
|
+
var source_default = chalk;
|
|
946
|
+
|
|
947
|
+
// ../../node_modules/@wdio/logger/build/index.js
|
|
948
|
+
var import_loglevel_plugin_prefix = __toESM(require_loglevel_plugin_prefix(), 1);
|
|
949
|
+
|
|
950
|
+
// ../../node_modules/strip-ansi/index.js
|
|
951
|
+
init_cjs_shims();
|
|
952
|
+
|
|
953
|
+
// ../../node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
954
|
+
init_cjs_shims();
|
|
955
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
956
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
957
|
+
const pattern = [
|
|
958
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
959
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
960
|
+
].join("|");
|
|
961
|
+
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// ../../node_modules/strip-ansi/index.js
|
|
965
|
+
var regex = ansiRegex();
|
|
966
|
+
function stripAnsi(string) {
|
|
967
|
+
if (typeof string !== "string") {
|
|
968
|
+
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
969
|
+
}
|
|
970
|
+
return string.replace(regex, "");
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// ../../node_modules/@wdio/logger/build/index.js
|
|
974
|
+
import_loglevel_plugin_prefix.default.reg(import_loglevel.default);
|
|
975
|
+
var DEFAULT_LEVEL = process.env.WDIO_DEBUG ? "trace" : "info";
|
|
976
|
+
var COLORS = {
|
|
977
|
+
error: "red",
|
|
978
|
+
warn: "yellow",
|
|
979
|
+
info: "cyanBright",
|
|
980
|
+
debug: "green",
|
|
981
|
+
trace: "cyan",
|
|
982
|
+
progress: "magenta"
|
|
983
|
+
};
|
|
984
|
+
var matches = {
|
|
985
|
+
COMMAND: "COMMAND",
|
|
986
|
+
BIDICOMMAND: "BIDI COMMAND",
|
|
987
|
+
DATA: "DATA",
|
|
988
|
+
RESULT: "RESULT",
|
|
989
|
+
BIDIRESULT: "BIDI RESULT"
|
|
990
|
+
};
|
|
991
|
+
var SERIALIZERS = [{
|
|
992
|
+
/**
|
|
993
|
+
* display error stack
|
|
994
|
+
*/
|
|
995
|
+
matches: (err) => err instanceof Error,
|
|
996
|
+
serialize: (err) => err.stack
|
|
997
|
+
}, {
|
|
998
|
+
/**
|
|
999
|
+
* color commands blue
|
|
1000
|
+
*/
|
|
1001
|
+
matches: (log22) => log22 === matches.COMMAND || log22 === matches.BIDICOMMAND,
|
|
1002
|
+
serialize: (log22) => source_default.magenta(log22)
|
|
1003
|
+
}, {
|
|
1004
|
+
/**
|
|
1005
|
+
* color data yellow
|
|
1006
|
+
*/
|
|
1007
|
+
matches: (log22) => log22 === matches.DATA,
|
|
1008
|
+
serialize: (log22) => source_default.yellow(log22)
|
|
1009
|
+
}, {
|
|
1010
|
+
/**
|
|
1011
|
+
* color result cyan
|
|
1012
|
+
*/
|
|
1013
|
+
matches: (log22) => log22 === matches.RESULT || log22 === matches.BIDIRESULT,
|
|
1014
|
+
serialize: (log22) => source_default.cyan(log22)
|
|
1015
|
+
}];
|
|
1016
|
+
var loggers = import_loglevel.default.getLoggers();
|
|
1017
|
+
var logLevelsConfig = {};
|
|
1018
|
+
var logCache = /* @__PURE__ */ new Set();
|
|
1019
|
+
var logFile;
|
|
1020
|
+
var originalFactory = import_loglevel.default.methodFactory;
|
|
1021
|
+
var wdioLoggerMethodFactory = function(methodName, logLevel, loggerName) {
|
|
1022
|
+
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
1023
|
+
return (...args) => {
|
|
1024
|
+
if (!logFile && process.env.WDIO_LOG_PATH) {
|
|
1025
|
+
logFile = import_node_fs.default.createWriteStream(process.env.WDIO_LOG_PATH);
|
|
1026
|
+
}
|
|
1027
|
+
const match = Object.values(matches).filter((x) => args[0].endsWith(`: ${x}`))[0];
|
|
1028
|
+
if (match) {
|
|
1029
|
+
const prefixStr = args.shift().slice(0, -match.length - 1);
|
|
1030
|
+
args.unshift(prefixStr, match);
|
|
1031
|
+
}
|
|
1032
|
+
args = args.map((arg) => {
|
|
1033
|
+
for (const s of SERIALIZERS) {
|
|
1034
|
+
if (s.matches(arg)) {
|
|
1035
|
+
return s.serialize(arg);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
return arg;
|
|
1039
|
+
});
|
|
1040
|
+
const logText = stripAnsi(`${import_node_util.default.format.apply(this, args)}
|
|
1041
|
+
`);
|
|
1042
|
+
if (logFile && logFile.writable) {
|
|
1043
|
+
if (logCache.size) {
|
|
1044
|
+
logCache.forEach((log22) => {
|
|
1045
|
+
if (logFile) {
|
|
1046
|
+
logFile.write(log22);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
logCache.clear();
|
|
1050
|
+
}
|
|
1051
|
+
if (!logsContainInitPackageError(logText)) {
|
|
1052
|
+
return logFile.write(logText);
|
|
1053
|
+
}
|
|
1054
|
+
logFile.write(logText);
|
|
1055
|
+
}
|
|
1056
|
+
logCache.add(logText);
|
|
1057
|
+
rawMethod(...args);
|
|
1058
|
+
};
|
|
1059
|
+
};
|
|
1060
|
+
var progress = function(data) {
|
|
1061
|
+
if (process.stdout.isTTY && this.getLevel() <= import_loglevel.default.levels.INFO) {
|
|
1062
|
+
const level = "progress";
|
|
1063
|
+
const timestampFormatter = source_default.gray((/* @__PURE__ */ new Date()).toISOString());
|
|
1064
|
+
const levelFormatter = source_default[COLORS[level]](level.toUpperCase());
|
|
1065
|
+
const nameFormatter = source_default.whiteBright(this.name);
|
|
1066
|
+
const _data = data.length > 0 ? `${timestampFormatter} ${levelFormatter} ${nameFormatter}: ${data}` : "\r\x1B[K\x1B[?25h";
|
|
1067
|
+
process.stdout.write("\x1B[?25l");
|
|
1068
|
+
process.stdout.write(`${_data}\r`);
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
function getLogger(name) {
|
|
1072
|
+
if (loggers[name]) {
|
|
1073
|
+
return loggers[name];
|
|
1074
|
+
}
|
|
1075
|
+
let logLevel = process.env.WDIO_LOG_LEVEL || DEFAULT_LEVEL;
|
|
1076
|
+
const logLevelName = getLogLevelName(name);
|
|
1077
|
+
if (logLevelsConfig[logLevelName]) {
|
|
1078
|
+
logLevel = logLevelsConfig[logLevelName];
|
|
1079
|
+
}
|
|
1080
|
+
loggers[name] = import_loglevel.default.getLogger(name);
|
|
1081
|
+
loggers[name].setLevel(logLevel);
|
|
1082
|
+
loggers[name].methodFactory = wdioLoggerMethodFactory;
|
|
1083
|
+
loggers[name].progress = progress;
|
|
1084
|
+
import_loglevel_plugin_prefix.default.apply(loggers[name], {
|
|
1085
|
+
template: "%t %l %n:",
|
|
1086
|
+
timestampFormatter: (date) => source_default.gray(date.toISOString()),
|
|
1087
|
+
levelFormatter: (level) => source_default[COLORS[level]](level.toUpperCase()),
|
|
1088
|
+
nameFormatter: (name2) => source_default.whiteBright(name2)
|
|
1089
|
+
});
|
|
1090
|
+
return loggers[name];
|
|
1091
|
+
}
|
|
1092
|
+
getLogger.waitForBuffer = async () => new Promise((resolve) => {
|
|
1093
|
+
if (logFile && Array.isArray(logFile.writableBuffer) && logFile.writableBuffer.length !== 0) {
|
|
1094
|
+
return setTimeout(async () => {
|
|
1095
|
+
await getLogger.waitForBuffer();
|
|
1096
|
+
resolve();
|
|
1097
|
+
}, 20);
|
|
1098
|
+
}
|
|
1099
|
+
resolve();
|
|
1100
|
+
});
|
|
1101
|
+
getLogger.setLevel = (name, level) => loggers[name].setLevel(level);
|
|
1102
|
+
getLogger.clearLogger = () => {
|
|
1103
|
+
if (logFile) {
|
|
1104
|
+
logFile.end();
|
|
1105
|
+
}
|
|
1106
|
+
logFile = null;
|
|
1107
|
+
};
|
|
1108
|
+
getLogger.setLogLevelsConfig = (logLevels = {}, wdioLogLevel = DEFAULT_LEVEL) => {
|
|
1109
|
+
if (process.env.WDIO_LOG_LEVEL === void 0) {
|
|
1110
|
+
process.env.WDIO_LOG_LEVEL = wdioLogLevel;
|
|
1111
|
+
}
|
|
1112
|
+
logLevelsConfig = {};
|
|
1113
|
+
Object.entries(logLevels).forEach(([logName, logLevel]) => {
|
|
1114
|
+
const logLevelName = getLogLevelName(logName);
|
|
1115
|
+
logLevelsConfig[logLevelName] = logLevel;
|
|
1116
|
+
});
|
|
1117
|
+
Object.keys(loggers).forEach((logName) => {
|
|
1118
|
+
const logLevelName = getLogLevelName(logName);
|
|
1119
|
+
const logLevel = typeof logLevelsConfig[logLevelName] !== "undefined" ? logLevelsConfig[logLevelName] : process.env.WDIO_LOG_LEVEL;
|
|
1120
|
+
loggers[logName].setLevel(logLevel);
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
var getLogLevelName = (logName) => logName.split(":").shift();
|
|
1124
|
+
function logsContainInitPackageError(logText) {
|
|
1125
|
+
return ERROR_LOG_VALIDATOR.every((pattern) => logText.includes(pattern));
|
|
1126
|
+
}
|
|
1127
|
+
var ERROR_LOG_VALIDATOR = [
|
|
1128
|
+
"Couldn't find plugin",
|
|
1129
|
+
"neither as wdio scoped package",
|
|
1130
|
+
"nor as community package",
|
|
1131
|
+
"Please make sure you have it installed"
|
|
1132
|
+
];
|
|
1133
|
+
|
|
1134
|
+
// src/service.ts
|
|
1135
|
+
var import_url = require("url");
|
|
1136
|
+
var import_obsidian_launcher = __toESM(require("obsidian-launcher"), 1);
|
|
1137
|
+
|
|
1138
|
+
// src/browserCommands.ts
|
|
1139
|
+
init_cjs_shims();
|
|
1140
|
+
|
|
1141
|
+
// src/types.ts
|
|
1142
|
+
init_cjs_shims();
|
|
1143
|
+
var OBSIDIAN_CAPABILITY_KEY = "wdio:obsidianOptions";
|
|
1144
|
+
|
|
1145
|
+
// src/browserCommands.ts
|
|
1146
|
+
var browserCommands = {
|
|
1147
|
+
/** Returns the Obsidian version this test is running under. */
|
|
1148
|
+
async getObsidianVersion() {
|
|
1149
|
+
return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].appVersion;
|
|
1150
|
+
},
|
|
1151
|
+
/** Returns the Obsidian installer version this test is running under. */
|
|
1152
|
+
async getObsidianInstallerVersion() {
|
|
1153
|
+
return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].installerVersion;
|
|
1154
|
+
},
|
|
1155
|
+
/**
|
|
1156
|
+
* Wrapper around browser.execute that passes the Obsidian API to the function. The function will be run inside
|
|
1157
|
+
* Obsidian. The first argument to the function is an object containing keys:
|
|
1158
|
+
* - app: Obsidian app instance
|
|
1159
|
+
* - obsidian: Full Obsidian API
|
|
1160
|
+
* See also: https://webdriver.io/docs/api/browser/execute
|
|
1161
|
+
*
|
|
1162
|
+
* Example usage
|
|
1163
|
+
* ```ts
|
|
1164
|
+
* const file = browser.executeObsidian(({app, obsidian}, path) => {
|
|
1165
|
+
* return app.vault.getMarkdownFiles().find(f => f.path == path)
|
|
1166
|
+
* })
|
|
1167
|
+
* ```
|
|
1168
|
+
*/
|
|
1169
|
+
async executeObsidian(func, ...params) {
|
|
1170
|
+
return await browser.execute(
|
|
1171
|
+
`return (${func.toString()}).call(null,
|
|
1172
|
+
{
|
|
1173
|
+
app: window._wdioObsidianService.app,
|
|
1174
|
+
obsidian: window._wdioObsidianService.obsidian,
|
|
1175
|
+
},
|
|
1176
|
+
...arguments,
|
|
1177
|
+
)`,
|
|
1178
|
+
...params
|
|
1179
|
+
);
|
|
1180
|
+
},
|
|
1181
|
+
/** Returns the path to the vault opened in Obsidian */
|
|
1182
|
+
async getVaultPath() {
|
|
1183
|
+
if (this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault == void 0) {
|
|
1184
|
+
return void 0;
|
|
1185
|
+
} else {
|
|
1186
|
+
return await this.executeObsidian(({ app, obsidian }) => {
|
|
1187
|
+
if (app.vault.adapter instanceof obsidian.FileSystemAdapter) {
|
|
1188
|
+
return app.vault.adapter.getBasePath();
|
|
1189
|
+
} else {
|
|
1190
|
+
throw new Error(`Unrecognized DataAdapater type`);
|
|
1191
|
+
}
|
|
1192
|
+
;
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
},
|
|
1196
|
+
/** Enables a plugin */
|
|
1197
|
+
async enablePlugin(pluginId) {
|
|
1198
|
+
await this.executeObsidian(
|
|
1199
|
+
async ({ app }, pluginId2) => await app.plugins.enablePluginAndSave(pluginId2),
|
|
1200
|
+
pluginId
|
|
1201
|
+
);
|
|
1202
|
+
},
|
|
1203
|
+
/** Disables a plugin */
|
|
1204
|
+
async disablePlugin(pluginId) {
|
|
1205
|
+
await this.executeObsidian(
|
|
1206
|
+
async ({ app }, pluginId2) => await app.plugins.disablePluginAndSave(pluginId2),
|
|
1207
|
+
pluginId
|
|
1208
|
+
);
|
|
1209
|
+
},
|
|
1210
|
+
/**
|
|
1211
|
+
* Executes an Obsidian command.
|
|
1212
|
+
* @param id Id of the command to run.
|
|
1213
|
+
*/
|
|
1214
|
+
async executeObsidianCommand(id) {
|
|
1215
|
+
const result = await this.executeObsidian(({ app }, id2) => app.commands.executeCommandById(id2), id);
|
|
1216
|
+
if (!result) {
|
|
1217
|
+
throw Error(`Obsidian command ${id} not found or failed.`);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
var browserCommands_default = browserCommands;
|
|
1222
|
+
|
|
1223
|
+
// src/service.ts
|
|
1224
|
+
var import_lodash = __toESM(require("lodash"), 1);
|
|
1225
|
+
var log2 = getLogger("wdio-obsidian-service");
|
|
1226
|
+
function getDefaultCacheDir() {
|
|
1227
|
+
return import_path.default.resolve(process.env.WEBDRIVER_CACHE_DIR ?? "./.obsidian-cache");
|
|
1228
|
+
}
|
|
1229
|
+
var ObsidianLauncherService = class {
|
|
1230
|
+
constructor(options, capabilities, config) {
|
|
1231
|
+
this.options = options;
|
|
1232
|
+
this.capabilities = capabilities;
|
|
1233
|
+
this.config = config;
|
|
1234
|
+
this.obsidianLauncher = new import_obsidian_launcher.default({
|
|
1235
|
+
cacheDir: config.cacheDir ?? getDefaultCacheDir(),
|
|
1236
|
+
versionsUrl: options.versionsUrl,
|
|
1237
|
+
communityPluginsUrl: options.communityPluginsUrl,
|
|
1238
|
+
communityThemesUrl: options.communityThemesUrl
|
|
1239
|
+
});
|
|
1240
|
+
this.helperPluginPath = import_path.default.resolve(import_path.default.join((0, import_url.fileURLToPath)(importMetaUrl), "../../helper-plugin"));
|
|
1241
|
+
}
|
|
1242
|
+
async onPrepare(config, capabilities) {
|
|
1243
|
+
if (!Array.isArray(capabilities)) {
|
|
1244
|
+
capabilities = Object.values(capabilities).map(
|
|
1245
|
+
(multiremoteOption) => multiremoteOption.capabilities
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
const obsidianCapabilities = capabilities.flatMap((cap) => {
|
|
1249
|
+
if ("browserName" in cap && cap.browserName === "obsidian") {
|
|
1250
|
+
return [cap];
|
|
1251
|
+
} else {
|
|
1252
|
+
return [];
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
try {
|
|
1256
|
+
for (const cap of obsidianCapabilities) {
|
|
1257
|
+
const obsidianOptions = cap[OBSIDIAN_CAPABILITY_KEY] ?? {};
|
|
1258
|
+
const vault = obsidianOptions.vault != void 0 ? import_path.default.resolve(obsidianOptions.vault) : void 0;
|
|
1259
|
+
const [appVersion, installerVersion] = await this.obsidianLauncher.resolveVersions(
|
|
1260
|
+
cap.browserVersion ?? "latest",
|
|
1261
|
+
obsidianOptions.installerVersion ?? "earliest"
|
|
1262
|
+
);
|
|
1263
|
+
const installerVersionInfo = await this.obsidianLauncher.getVersionInfo(installerVersion);
|
|
1264
|
+
let installerPath = obsidianOptions.binaryPath;
|
|
1265
|
+
if (!installerPath) {
|
|
1266
|
+
installerPath = await this.obsidianLauncher.downloadInstaller(installerVersion);
|
|
1267
|
+
}
|
|
1268
|
+
let appPath = obsidianOptions.appPath;
|
|
1269
|
+
if (!appPath) {
|
|
1270
|
+
appPath = await this.obsidianLauncher.downloadApp(appVersion);
|
|
1271
|
+
}
|
|
1272
|
+
let chromedriverPath = cap["wdio:chromedriverOptions"]?.binary;
|
|
1273
|
+
if (!chromedriverPath && Number(installerVersionInfo.chromeVersion.split(".")[0]) <= 115) {
|
|
1274
|
+
chromedriverPath = await this.obsidianLauncher.downloadChromedriver(installerVersion);
|
|
1275
|
+
}
|
|
1276
|
+
let plugins = obsidianOptions.plugins ?? ["."];
|
|
1277
|
+
plugins.push(this.helperPluginPath);
|
|
1278
|
+
plugins = await this.obsidianLauncher.downloadPlugins(plugins);
|
|
1279
|
+
const themes = await this.obsidianLauncher.downloadThemes(obsidianOptions.themes ?? []);
|
|
1280
|
+
const args = [
|
|
1281
|
+
// Workaround for SUID issue on AppImages. See https://github.com/electron/electron/issues/42510
|
|
1282
|
+
...process.platform == "linux" ? ["--no-sandbox"] : [],
|
|
1283
|
+
...cap["goog:chromeOptions"]?.args ?? []
|
|
1284
|
+
];
|
|
1285
|
+
cap.browserName = "chrome";
|
|
1286
|
+
cap.browserVersion = installerVersionInfo.chromeVersion;
|
|
1287
|
+
cap[OBSIDIAN_CAPABILITY_KEY] = {
|
|
1288
|
+
...obsidianOptions,
|
|
1289
|
+
plugins,
|
|
1290
|
+
themes,
|
|
1291
|
+
binaryPath: installerPath,
|
|
1292
|
+
appPath,
|
|
1293
|
+
vault,
|
|
1294
|
+
appVersion,
|
|
1295
|
+
// Resolve the versions
|
|
1296
|
+
installerVersion
|
|
1297
|
+
};
|
|
1298
|
+
cap["goog:chromeOptions"] = {
|
|
1299
|
+
binary: installerPath,
|
|
1300
|
+
windowTypes: ["app", "webview"],
|
|
1301
|
+
...cap["goog:chromeOptions"],
|
|
1302
|
+
args
|
|
1303
|
+
};
|
|
1304
|
+
cap["wdio:chromedriverOptions"] = {
|
|
1305
|
+
// allowedIps is not included in the types, but gets passed as --allowed-ips to chromedriver.
|
|
1306
|
+
// It defaults to ["0.0.0.0"] which makes Windows Firewall complain, and we don't need remote
|
|
1307
|
+
// connections anyways.
|
|
1308
|
+
allowedIps: [],
|
|
1309
|
+
...cap["wdio:chromedriverOptions"],
|
|
1310
|
+
binary: chromedriverPath
|
|
1311
|
+
};
|
|
1312
|
+
cap["wdio:enforceWebDriverClassic"] = true;
|
|
1313
|
+
}
|
|
1314
|
+
} catch (e) {
|
|
1315
|
+
throw new import_webdriverio.SevereServiceError(`Failed to download and setup Obsidian. Caused by: ${e.stack}
|
|
1316
|
+
------The above causes:-----`);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
var ObsidianWorkerService = class {
|
|
1321
|
+
constructor(options, capabilities, config) {
|
|
1322
|
+
this.options = options;
|
|
1323
|
+
this.capabilities = capabilities;
|
|
1324
|
+
this.config = config;
|
|
1325
|
+
this.obsidianLauncher = new import_obsidian_launcher.default({
|
|
1326
|
+
cacheDir: config.cacheDir ?? getDefaultCacheDir(),
|
|
1327
|
+
versionsUrl: options.versionsUrl,
|
|
1328
|
+
communityPluginsUrl: options.communityPluginsUrl,
|
|
1329
|
+
communityThemesUrl: options.communityThemesUrl
|
|
1330
|
+
});
|
|
1331
|
+
this.tmpDirs = [];
|
|
1332
|
+
}
|
|
1333
|
+
async setupObsidian(obsidianOptions) {
|
|
1334
|
+
let vault = obsidianOptions.vault;
|
|
1335
|
+
if (vault != void 0) {
|
|
1336
|
+
log2.info(`Opening vault ${obsidianOptions.vault}`);
|
|
1337
|
+
vault = await this.obsidianLauncher.copyVault(vault);
|
|
1338
|
+
this.tmpDirs.push(vault);
|
|
1339
|
+
} else {
|
|
1340
|
+
log2.info(`Opening Obsidian without a vault`);
|
|
1341
|
+
}
|
|
1342
|
+
const configDir = await this.obsidianLauncher.setupConfigDir({
|
|
1343
|
+
appVersion: obsidianOptions.appVersion,
|
|
1344
|
+
installerVersion: obsidianOptions.installerVersion,
|
|
1345
|
+
appPath: obsidianOptions.appPath,
|
|
1346
|
+
vault,
|
|
1347
|
+
plugins: obsidianOptions.plugins,
|
|
1348
|
+
themes: obsidianOptions.themes
|
|
1349
|
+
});
|
|
1350
|
+
this.tmpDirs.push(configDir);
|
|
1351
|
+
return configDir;
|
|
1352
|
+
}
|
|
1353
|
+
async waitForReady(browser2) {
|
|
1354
|
+
if (browser2.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault != void 0) {
|
|
1355
|
+
await browser2.waitUntil(
|
|
1356
|
+
// wait until the helper plugin is loaded
|
|
1357
|
+
() => browser2.execute(() => !!window._wdioObsidianService?.app?.workspace?.onLayoutReady),
|
|
1358
|
+
{ timeout: 30 * 1e3, interval: 100 }
|
|
1359
|
+
);
|
|
1360
|
+
await browser2.executeObsidian(async ({ app }) => {
|
|
1361
|
+
await new Promise((resolve) => app.workspace.onLayoutReady(resolve));
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
async beforeSession(config, capabilities) {
|
|
1366
|
+
if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;
|
|
1367
|
+
const configDir = await this.setupObsidian(capabilities[OBSIDIAN_CAPABILITY_KEY]);
|
|
1368
|
+
capabilities["goog:chromeOptions"].args = [
|
|
1369
|
+
`--user-data-dir=${configDir}`,
|
|
1370
|
+
...capabilities["goog:chromeOptions"].args ?? []
|
|
1371
|
+
];
|
|
1372
|
+
}
|
|
1373
|
+
selectPlugins(currentPlugins, selection) {
|
|
1374
|
+
if (selection !== void 0) {
|
|
1375
|
+
const unknownPlugins = import_lodash.default.difference(selection, currentPlugins.map((p) => p.id));
|
|
1376
|
+
if (unknownPlugins.length > 0) {
|
|
1377
|
+
throw Error(`Unknown plugin ids: ${unknownPlugins.join(", ")}`);
|
|
1378
|
+
}
|
|
1379
|
+
return currentPlugins.map((p) => ({
|
|
1380
|
+
...p,
|
|
1381
|
+
enabled: selection.includes(p.id) || p.id == "wdio-obsidian-service-plugin"
|
|
1382
|
+
}));
|
|
1383
|
+
} else {
|
|
1384
|
+
return currentPlugins;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
selectThemes(currentThemes, selection) {
|
|
1388
|
+
if (selection !== void 0) {
|
|
1389
|
+
if (selection != "default" && currentThemes.every((t) => t.name != selection)) {
|
|
1390
|
+
throw Error(`Unknown theme: ${selection}`);
|
|
1391
|
+
}
|
|
1392
|
+
return currentThemes.map((t) => ({ ...t, enabled: selection != "default" && t.name === selection }));
|
|
1393
|
+
} else {
|
|
1394
|
+
return currentThemes;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
async before(capabilities, specs, browser2) {
|
|
1398
|
+
browser2.setMaxListeners(1e3);
|
|
1399
|
+
if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;
|
|
1400
|
+
const service = this;
|
|
1401
|
+
const openVault = async function({ vault, plugins, theme } = {}) {
|
|
1402
|
+
const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];
|
|
1403
|
+
const newObsidianOptions = {
|
|
1404
|
+
...oldObsidianOptions,
|
|
1405
|
+
vault: vault != void 0 ? import_path.default.resolve(vault) : oldObsidianOptions.vault,
|
|
1406
|
+
plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),
|
|
1407
|
+
themes: service.selectThemes(oldObsidianOptions.themes, theme)
|
|
1408
|
+
};
|
|
1409
|
+
const configDir = await service.setupObsidian(newObsidianOptions);
|
|
1410
|
+
const newArgs = [
|
|
1411
|
+
`--user-data-dir=${configDir}`,
|
|
1412
|
+
...this.requestedCapabilities["goog:chromeOptions"].args.filter((arg) => {
|
|
1413
|
+
const match = arg.match(/^--user-data-dir=(.*)$/);
|
|
1414
|
+
return !match || !service.tmpDirs.includes(match[1]);
|
|
1415
|
+
})
|
|
1416
|
+
];
|
|
1417
|
+
const sessionId = await this.reloadSession({
|
|
1418
|
+
[OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,
|
|
1419
|
+
"goog:chromeOptions": {
|
|
1420
|
+
...this.requestedCapabilities["goog:chromeOptions"],
|
|
1421
|
+
args: newArgs
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
await service.waitForReady(this);
|
|
1425
|
+
return sessionId;
|
|
1426
|
+
};
|
|
1427
|
+
await browser2.addCommand("openVault", openVault);
|
|
1428
|
+
for (const [name, cmd] of Object.entries(browserCommands_default)) {
|
|
1429
|
+
await browser2.addCommand(name, cmd);
|
|
1430
|
+
}
|
|
1431
|
+
await service.waitForReady(browser2);
|
|
1432
|
+
}
|
|
1433
|
+
async afterSession() {
|
|
1434
|
+
for (const tmpDir of this.tmpDirs) {
|
|
1435
|
+
await import_promises.default.rm(tmpDir, { recursive: true, force: true });
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1440
|
+
// src/index.ts
|
|
1441
|
+
var index_default = ObsidianWorkerService;
|
|
1442
|
+
var launcher = ObsidianLauncherService;
|
|
1443
|
+
async function obsidianBetaAvailable(cacheDir) {
|
|
1444
|
+
const launcher2 = new import_obsidian_launcher2.default({ cacheDir });
|
|
1445
|
+
return await launcher2.isAvailable("latest-beta");
|
|
1446
|
+
}
|
|
1447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1448
|
+
0 && (module.exports = {
|
|
1449
|
+
ObsidianLauncherService,
|
|
1450
|
+
ObsidianWorkerService,
|
|
1451
|
+
launcher,
|
|
1452
|
+
obsidianBetaAvailable
|
|
1453
|
+
});
|
|
1454
|
+
//# sourceMappingURL=index.cjs.map
|