wdio-obsidian-service 0.1.7 → 0.1.8

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/index.cjs CHANGED
@@ -113,6 +113,14 @@ var browserCommands = {
113
113
  pluginId
114
114
  );
115
115
  },
116
+ /** Sets the theme. Pass "default" to reset to the Obsidian theme. */
117
+ async setTheme(themeName) {
118
+ themeName = themeName == "default" ? "" : themeName;
119
+ await this.executeObsidian(
120
+ async ({ app }, themeName2) => await app.customCss.setTheme(themeName2),
121
+ themeName
122
+ );
123
+ },
116
124
  /**
117
125
  * Executes an Obsidian command.
118
126
  * @param id Id of the command to run.
@@ -126,6 +134,11 @@ var browserCommands = {
126
134
  };
127
135
  var browserCommands_default = browserCommands;
128
136
 
137
+ // src/utils.ts
138
+ async function sleep(ms) {
139
+ return new Promise((resolve) => setTimeout(resolve, ms));
140
+ }
141
+
129
142
  // src/service.ts
130
143
  var import_lodash = __toESM(require("lodash"), 1);
131
144
  var log = (0, import_logger.default)("wdio-obsidian-service");
@@ -307,33 +320,60 @@ var ObsidianWorkerService = class {
307
320
  browser2.setMaxListeners(1e3);
308
321
  if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;
309
322
  const service = this;
310
- const openVault = async function({ vault, plugins, theme } = {}) {
323
+ const reloadObsidian = async function({ vault, plugins, theme } = {}) {
311
324
  const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];
312
- const newObsidianOptions = {
313
- ...oldObsidianOptions,
314
- vault: vault != void 0 ? import_path.default.resolve(vault) : oldObsidianOptions.vault,
315
- plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),
316
- themes: service.selectThemes(oldObsidianOptions.themes, theme)
317
- };
318
- const configDir = await service.setupObsidian(newObsidianOptions);
319
- const newArgs = [
320
- `--user-data-dir=${configDir}`,
321
- ...this.requestedCapabilities["goog:chromeOptions"].args.filter((arg) => {
322
- const match = arg.match(/^--user-data-dir=(.*)$/);
323
- return !match || !service.tmpDirs.includes(match[1]);
324
- })
325
- ];
326
- const sessionId = await this.reloadSession({
327
- [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,
328
- "goog:chromeOptions": {
329
- ...this.requestedCapabilities["goog:chromeOptions"],
330
- args: newArgs
325
+ let newCapabilities;
326
+ if (vault) {
327
+ const newObsidianOptions = {
328
+ ...oldObsidianOptions,
329
+ vault: import_path.default.resolve(vault),
330
+ plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),
331
+ themes: service.selectThemes(oldObsidianOptions.themes, theme)
332
+ };
333
+ const configDir = await service.setupObsidian(newObsidianOptions);
334
+ const newArgs = [
335
+ `--user-data-dir=${configDir}`,
336
+ ...this.requestedCapabilities["goog:chromeOptions"].args.filter((arg) => {
337
+ const match = arg.match(/^--user-data-dir=(.*)$/);
338
+ return !match || !service.tmpDirs.includes(match[1]);
339
+ })
340
+ ];
341
+ newCapabilities = {
342
+ [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,
343
+ "goog:chromeOptions": {
344
+ ...this.requestedCapabilities["goog:chromeOptions"],
345
+ args: newArgs
346
+ }
347
+ };
348
+ } else {
349
+ newCapabilities = {};
350
+ if (plugins) {
351
+ const enabledPlugins = await browser2.executeObsidian(
352
+ ({ app }) => [...app.plugins.enabledPlugins].sort()
353
+ );
354
+ for (const pluginId of import_lodash.default.difference(enabledPlugins, plugins, ["wdio-obsidian-service-plugin"])) {
355
+ await browser2.disablePlugin(pluginId);
356
+ }
357
+ for (const pluginId of import_lodash.default.difference(plugins, enabledPlugins)) {
358
+ await browser2.enablePlugin(pluginId);
359
+ }
360
+ await browser2.executeObsidian(async ({ app }) => await app.plugins.saveConfig());
331
361
  }
362
+ if (theme) {
363
+ await browser2.setTheme(theme);
364
+ await browser2.executeObsidian(async ({ app }) => await app.vault.saveConfig());
365
+ }
366
+ await sleep(2e3);
367
+ }
368
+ const sessionId = await browser2.reloadSession({
369
+ // if browserName is set, reloadSession tries to restart the driver entirely, so unset those
370
+ ...import_lodash.default.omit(this.requestedCapabilities, ["browserName", "browserVersion"]),
371
+ ...newCapabilities
332
372
  });
333
373
  await service.waitForReady(this);
334
374
  return sessionId;
335
375
  };
336
- await browser2.addCommand("openVault", openVault);
376
+ await browser2.addCommand("reloadObsidian", reloadObsidian);
337
377
  for (const [name, cmd] of Object.entries(browserCommands_default)) {
338
378
  await browser2.addCommand(name, cmd);
339
379
  }
@@ -351,7 +391,8 @@ var index_default = ObsidianWorkerService;
351
391
  var launcher = ObsidianLauncherService;
352
392
  async function obsidianBetaAvailable(cacheDir) {
353
393
  const launcher2 = new import_obsidian_launcher2.default({ cacheDir });
354
- return await launcher2.isAvailable("latest-beta");
394
+ const versionInfo = await launcher2.getVersionInfo("latest-beta");
395
+ return versionInfo.isBeta && await launcher2.isAvailable(versionInfo.version);
355
396
  }
356
397
  // Annotate the CommonJS export names for ESM import in node:
357
398
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../../../node_modules/tsup/assets/cjs_shims.js","../src/service.ts","../src/types.ts","../src/browserCommands.ts"],"sourcesContent":["import ObsidianLauncher from \"obsidian-launcher\"\nimport { ObsidianLauncherService, ObsidianWorkerService } from \"./service.js\";\n\nexport default ObsidianWorkerService;\nexport const launcher = ObsidianLauncherService;\n\nexport type { ObsidianServiceOptions, ObsidianCapabilityOptions } from \"./types.js\";\n\nexport type {\n LocalPluginEntry, GitHubPluginEntry, CommunityPluginEntry, PluginEntry,\n LocalThemeEntry, GitHubThemeEntry, CommunityThemeEntry, ThemeEntry,\n} from \"obsidian-launcher\"\n\n/**\n * Returns true if we either have the credentails to download the latest Obsidian beta or it's already in cache.\n */\nexport async function obsidianBetaAvailable(cacheDir?: string) {\n const launcher = new ObsidianLauncher({cacheDir: cacheDir});\n return await launcher.isAvailable(\"latest-beta\");\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import fsAsync from \"fs/promises\"\nimport path from \"path\"\nimport { SevereServiceError } from 'webdriverio'\nimport type { Capabilities, Options, Services } from '@wdio/types'\nimport logger from '@wdio/logger'\nimport { fileURLToPath } from \"url\"\nimport ObsidianLauncher, { DownloadedPluginEntry, DownloadedThemeEntry } from \"obsidian-launcher\"\nimport browserCommands from \"./browserCommands.js\"\nimport { ObsidianCapabilityOptions, ObsidianServiceOptions, OBSIDIAN_CAPABILITY_KEY } from \"./types.js\"\nimport _ from \"lodash\"\n\n\nconst log = logger(\"wdio-obsidian-service\");\n\nfunction getDefaultCacheDir() {\n return path.resolve(process.env.WEBDRIVER_CACHE_DIR ?? \"./.obsidian-cache\")\n}\n\nexport class ObsidianLauncherService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n private readonly helperPluginPath: string\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.helperPluginPath = path.resolve(path.join(fileURLToPath(import.meta.url), '../../helper-plugin'));\n }\n\n async onPrepare(config: Options.Testrunner, capabilities: Capabilities.TestrunnerCapabilities) {\n if (!Array.isArray(capabilities)) {\n capabilities = Object.values(capabilities as Capabilities.RequestedMultiremoteCapabilities).map(\n (multiremoteOption) => (multiremoteOption as Capabilities.WithRequestedCapabilities).capabilities,\n );\n }\n\n const obsidianCapabilities = capabilities.flatMap((cap) => {\n if ((\"browserName\" in cap) && cap.browserName === \"obsidian\") {\n return [cap as WebdriverIO.Capabilities];\n } else {\n return [];\n }\n });\n\n try {\n for (const cap of obsidianCapabilities) {\n const obsidianOptions = cap[OBSIDIAN_CAPABILITY_KEY] ?? {};\n \n const vault = obsidianOptions.vault != undefined ? path.resolve(obsidianOptions.vault) : undefined;\n \n const [appVersion, installerVersion] = await this.obsidianLauncher.resolveVersions(\n cap.browserVersion ?? \"latest\",\n obsidianOptions.installerVersion ?? \"earliest\",\n );\n const installerVersionInfo = await this.obsidianLauncher.getVersionInfo(installerVersion);\n\n let installerPath = obsidianOptions.binaryPath;\n if (!installerPath) {\n installerPath = await this.obsidianLauncher.downloadInstaller(installerVersion);\n }\n let appPath = obsidianOptions.appPath;\n if (!appPath) {\n appPath = await this.obsidianLauncher.downloadApp(appVersion);\n }\n let chromedriverPath = cap['wdio:chromedriverOptions']?.binary\n // wdio can download chromedriver for versions greater than 115 automatically\n if (!chromedriverPath && Number(installerVersionInfo.chromeVersion!.split(\".\")[0]) <= 115) {\n chromedriverPath = await this.obsidianLauncher.downloadChromedriver(installerVersion);\n }\n\n let plugins = obsidianOptions.plugins ?? [\".\"];\n plugins.push(this.helperPluginPath); // Always install the helper plugin\n plugins = await this.obsidianLauncher.downloadPlugins(plugins);\n\n const themes = await this.obsidianLauncher.downloadThemes(obsidianOptions.themes ?? []);\n\n const args = [\n // Workaround for SUID issue on AppImages. See https://github.com/electron/electron/issues/42510\n ...(process.platform == 'linux' ? [\"--no-sandbox\"] : []),\n ...(cap['goog:chromeOptions']?.args ?? [])\n ];\n\n cap.browserName = \"chrome\";\n cap.browserVersion = installerVersionInfo.chromeVersion;\n cap[OBSIDIAN_CAPABILITY_KEY] = {\n ...obsidianOptions,\n plugins: plugins,\n themes: themes,\n binaryPath: installerPath,\n appPath: appPath,\n vault: vault,\n appVersion: appVersion, // Resolve the versions\n installerVersion: installerVersion,\n };\n cap['goog:chromeOptions'] = {\n binary: installerPath,\n windowTypes: [\"app\", \"webview\"],\n ...cap['goog:chromeOptions'],\n args: args,\n }\n cap['wdio:chromedriverOptions'] = {\n // allowedIps is not included in the types, but gets passed as --allowed-ips to chromedriver.\n // It defaults to [\"0.0.0.0\"] which makes Windows Firewall complain, and we don't need remote\n // connections anyways.\n allowedIps: [],\n ...cap['wdio:chromedriverOptions'],\n binary: chromedriverPath,\n } as any\n cap[\"wdio:enforceWebDriverClassic\"] = true;\n }\n } catch (e: any) {\n // By default wdio just logs service errors, throwing this makes it bail if anything goes wrong.\n throw new SevereServiceError(`Failed to download and setup Obsidian. Caused by: ${e.stack}\\n`+\n ` ------The above causes:-----`);\n }\n }\n}\n\nexport class ObsidianWorkerService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n /** Directories to clean up after the tests */\n private tmpDirs: string[]\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.tmpDirs = [];\n }\n\n private async setupObsidian(obsidianOptions: ObsidianCapabilityOptions) {\n let vault = obsidianOptions.vault;\n if (vault != undefined) {\n log.info(`Opening vault ${obsidianOptions.vault}`);\n vault = await this.obsidianLauncher.setupVault({\n vault,\n copy: true,\n plugins: obsidianOptions.plugins,\n themes: obsidianOptions.themes,\n });\n this.tmpDirs.push(vault);\n } else {\n log.info(`Opening Obsidian without a vault`)\n }\n\n const configDir = await this.obsidianLauncher.setupConfigDir({\n appVersion: obsidianOptions.appVersion!, installerVersion: obsidianOptions.installerVersion!,\n appPath: obsidianOptions.appPath!,\n vault: vault,\n });\n this.tmpDirs.push(configDir);\n\n return configDir;\n }\n\n private async waitForReady(browser: WebdriverIO.Browser) {\n if (browser.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault != undefined) {\n await browser.waitUntil( // wait until the helper plugin is loaded\n () => browser.execute(() => !!(window as any).wdioObsidianService),\n {timeout: 30 * 1000, interval: 100},\n );\n await browser.executeObsidian(async ({app}) => {\n await new Promise<void>((resolve) => app.workspace.onLayoutReady(resolve) );\n })\n }\n }\n\n async beforeSession(config: Options.Testrunner, capabilities: WebdriverIO.Capabilities) {\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const configDir = await this.setupObsidian(capabilities[OBSIDIAN_CAPABILITY_KEY]);\n\n capabilities['goog:chromeOptions']!.args = [\n `--user-data-dir=${configDir}`,\n ...(capabilities['goog:chromeOptions']!.args ?? [])\n ];\n }\n\n private selectPlugins(currentPlugins: DownloadedPluginEntry[], selection?: string[]) {\n if (selection !== undefined) {\n const unknownPlugins = _.difference(selection, currentPlugins.map(p => p.id));\n if (unknownPlugins.length > 0) {\n throw Error(`Unknown plugin ids: ${unknownPlugins.join(', ')}`)\n }\n return currentPlugins.map(p => ({\n ...p,\n enabled: selection.includes(p.id) || p.id == \"wdio-obsidian-service-plugin\",\n }));\n } else {\n return currentPlugins;\n }\n }\n\n private selectThemes(currentThemes: DownloadedThemeEntry[], selection?: string) {\n if (selection !== undefined) {\n if (selection != \"default\" && currentThemes.every((t: any) => t.name != selection)) {\n throw Error(`Unknown theme: ${selection}`);\n }\n return currentThemes.map((t: any) => ({...t, enabled: selection != 'default' && t.name === selection}));\n } else {\n return currentThemes;\n }\n }\n\n async before(capabilities: WebdriverIO.Capabilities, specs: never, browser: WebdriverIO.Browser) {\n // There's a slow event listener link on the browser \"command\" event when you reloadSession that causes some\n // warnings. This will silence them. TODO: Make issue or PR to wdio to fix this.\n browser.setMaxListeners(1000);\n\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const service = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const openVault: typeof browser['openVault'] = async function(\n this: WebdriverIO.Browser,\n {vault, plugins, theme} = {},\n ) {\n const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];\n\n const newObsidianOptions = {\n ...oldObsidianOptions,\n vault: vault != undefined ? path.resolve(vault) : oldObsidianOptions.vault,\n plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),\n themes: service.selectThemes(oldObsidianOptions.themes, theme),\n }\n\n const configDir = await service.setupObsidian(newObsidianOptions);\n \n const newArgs = [\n `--user-data-dir=${configDir}`,\n ...this.requestedCapabilities['goog:chromeOptions'].args.filter((arg: string) => {\n const match = arg.match(/^--user-data-dir=(.*)$/);\n return !match || !service.tmpDirs.includes(match[1]);\n }),\n ]\n\n // Reload session already merges with existing settings, and tries to restart the driver entirely if\n // you set browserName explicitly..\n const sessionId = await this.reloadSession({\n [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,\n 'goog:chromeOptions': {\n ...this.requestedCapabilities['goog:chromeOptions'],\n args: newArgs,\n },\n });\n await service.waitForReady(this);\n\n return sessionId;\n }\n await browser.addCommand(\"openVault\", openVault);\n\n for (const [name, cmd] of Object.entries(browserCommands)) {\n await browser.addCommand(name, cmd);\n }\n\n await service.waitForReady(browser);\n }\n\n async afterSession() {\n for (const tmpDir of this.tmpDirs) {\n await fsAsync.rm(tmpDir, { recursive: true, force: true });\n }\n }\n}\n","import type { ObsidianBrowserCommands } from \"./browserCommands.js\";\nimport type { PluginEntry, ThemeEntry } from \"obsidian-launcher\";\n\nexport const OBSIDIAN_CAPABILITY_KEY = \"wdio:obsidianOptions\" as const;\n\nexport interface ObsidianServiceOptions {\n /**\n * Override the `obsidian-versions.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n versionsUrl?: string,\n /**\n * Override the `community-plugins.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityPluginsUrl?: string,\n /**\n * Override the `community-css-themes.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityThemesUrl?: string,\n}\n\nexport interface ObsidianCapabilityOptions {\n /**\n * Version of Obsidian to run.\n * \n * Can be set to \"latest\", \"latest-beta\", or a specific version. Defaults to \"latest\". To download beta versions\n * you'll need to be an Obsidian insider and set the OBSIDIAN_USERNAME and OBSIDIAN_PASSWORD environment\n * variables.\n * \n * You can also use the wdio capability `browserVersion` field to set the Obsidian version.\n */\n appVersion?: string\n\n /**\n * Version of the Obsidian Installer to download.\n * \n * Note that Obsidian is distributed in two parts, the \"installer\", which is the executable containing Electron, and\n * the \"app\" which is a bundle of JavaScript containing the Obsidian code. Obsidian's self-update system only\n * updates the JavaScript bundle, and not the base installer/Electron version. This makes Obsidian's auto-update\n * fast as it only needs to download a few MiB of JS instead of all of Electron. But, it means different users with\n * the same Obsidian version may be running on different versions of Electron, which could cause subtle differences\n * in plugin behavior if you are using newer JavaScript features and the like in your plugin.\n * \n * If passed \"latest\", it will use the maximum installer version compatible with the selected Obsidian version. If\n * passed \"earliest\" it will use the oldest installer version compatible with the selected Obsidian version. The \n * default is \"earliest\".\n */\n installerVersion?: string,\n\n /**\n * List of plugins to install.\n * \n * Each entry is a path to the local plugin to install, e.g. [\".\"] or [\"dist\"] depending on your build setup. You\n * can also pass objects. If you pass an object it can contain one of either `path` (to install a local plugin),\n * `repo` (to install a plugin from github), or `id` (to install a community plugin). You can set `enabled: false`\n * to install the plugin but start it disabled. You can enable the plugin later using `openVault` or the\n * `enablePlugin` command.\n */\n plugins?: PluginEntry[],\n\n /**\n * List of themes to install.\n * \n * Each entry is a path to the local theme to install. You can also pass an object. If you pass an object it can\n * contain one of either `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to\n * install a community theme). You can set `enabled: false` to install the theme, but start it disabled. You can\n * only have one enabled theme, so if you pass multiple you'll have to disable all but one.\n */\n themes?: ThemeEntry[],\n\n /**\n * The path to the vault to open.\n * \n * The vault will be copied, so any changes made in your tests won't affect the original. If omitted, no vault will\n * be opened and you'll need to call `browser.openVault` to open a vault during your tests.\n */\n vault?: string,\n\n /** Path to the Obsidian binary to use. If omitted it will download Obsidian automatically. */\n binaryPath?: string,\n\n /** Path to the app asar to load into obsidian. If omitted it will be downloaded automatically. */\n appPath?: string,\n}\n\n\ndeclare global {\n namespace WebdriverIO {\n interface Capabilities {\n [OBSIDIAN_CAPABILITY_KEY]?: ObsidianCapabilityOptions,\n }\n\n interface Browser extends ObsidianBrowserCommands {\n /**\n * Relaunch obsidian. Can be used to switch to a new vault, change the plugin list, or just to reboot\n * Obsidian.\n * \n * The vault will be copied, so any changes made in your tests won't be persited to the original. This\n * does require rebooting Obsidian, so avoid calling this too often so you don't slow your tests down.\n * You can also set the vault in the `wdio.conf.ts` capabilities section which may be useful if all\n * your tests use the same vault.\n * \n * @param vault path to the vault to open. If omitted it will re-open the current vault.\n * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list.\n * Note, all the plugins must be defined in your wdio.conf.ts capabilities. You can use openVault to\n * toggle which plugins are enabled and which are disabled.\n * @param theme Name of the theme to enable. If omitted it will keep the current theme. Pass \"default\" to\n * switch back to the default theme. Like with plugins, the theme must be defined in wdio.conf.ts.\n * @returns Returns the new sessionId (same as reloadSession()).\n */\n openVault(params?: {\n vault?: string,\n plugins?: string[], theme?: string,\n }): Promise<string>;\n }\n }\n}\n","import { OBSIDIAN_CAPABILITY_KEY } from \"./types.js\";\nimport type * as obsidian from \"obsidian\"\n\n\ntype ExecuteObsidianArg = {\n /**\n * There is a global \"app\" instance, but that may be removed in the future so you can use this to access it from\n * tests. See https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines#Avoid+using+global+app+instance\n */\n app: obsidian.App,\n\n /**\n * The full obsidian API. See https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts\n */\n obsidian: typeof obsidian,\n}\n\nconst browserCommands = {\n /** Returns the Obsidian version this test is running under. */\n async getObsidianVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].appVersion;\n },\n\n /** Returns the Obsidian installer version this test is running under. */\n async getObsidianInstallerVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].installerVersion;\n },\n\n /**\n * Wrapper around browser.execute that passes the Obsidian API to the function. The function will be run inside\n * Obsidian. The first argument to the function is an object containing keys:\n * - app: Obsidian app instance\n * - obsidian: Full Obsidian API\n * See also: https://webdriver.io/docs/api/browser/execute\n * \n * Example usage\n * ```ts\n * const file = browser.executeObsidian(({app, obsidian}, path) => {\n * return app.vault.getMarkdownFiles().find(f => f.path == path)\n * })\n * ```\n */\n async executeObsidian<Return, Params extends unknown[]>(\n func: (obs: ExecuteObsidianArg, ...params: Params) => Return,\n ...params: Params\n ): Promise<Return> {\n return await browser.execute<Return, Params>(\n `return (${func.toString()}).call(null, {...window.wdioObsidianService}, ...arguments )`,\n ...params,\n )\n },\n\n /** Returns the path to the vault opened in Obsidian */\n async getVaultPath(this: WebdriverIO.Browser): Promise<string|undefined> {\n if (this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault == undefined) {\n return undefined; // no vault open\n } else { // return the actual path to the vault\n return await this.executeObsidian(({app, obsidian}) => {\n if (app.vault.adapter instanceof obsidian.FileSystemAdapter) {\n return app.vault.adapter.getBasePath()\n } else { // TODO handle CapacitorAdapater\n throw new Error(`Unrecognized DataAdapater type`)\n };\n })\n }\n },\n\n /** Enables a plugin */\n async enablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.enablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /** Disables a plugin */\n async disablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.disablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /**\n * Executes an Obsidian command.\n * @param id Id of the command to run.\n */\n async executeObsidianCommand(this: WebdriverIO.Browser, id: string) {\n const result = await this.executeObsidian(({app}, id) => (app as any).commands.executeCommandById(id), id);\n if (!result) {\n throw Error(`Obsidian command ${id} not found or failed.`);\n }\n },\n} as const\n\nexport type Obs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EAAE,KAAK,OAAO,CAAC,QAAgB;AAC7E,gBAAM,QAAQ,IAAI,MAAM,wBAAwB;AAChD,iBAAO,CAAC,SAAS,CAAC,QAAQ,QAAQ,SAAS,MAAM,CAAC,CAAC;AAAA,QACvD,CAAC;AAAA,MACL;AAIA,YAAM,YAAY,MAAM,KAAK,cAAc;AAAA,QACvC,CAAC,uBAAuB,GAAG;AAAA,QAC3B,sBAAsB;AAAA,UAClB,GAAG,KAAK,sBAAsB,oBAAoB;AAAA,UAClD,MAAM;AAAA,QACV;AAAA,MACJ,CAAC;AACD,YAAM,QAAQ,aAAa,IAAI;AAE/B,aAAO;AAAA,IACX;AACA,UAAME,SAAQ,WAAW,aAAa,SAAS;AAE/C,eAAW,CAAC,MAAM,GAAG,KAAK,OAAO,QAAQ,uBAAe,GAAG;AACvD,YAAMA,SAAQ,WAAW,MAAM,GAAG;AAAA,IACtC;AAEA,UAAM,QAAQ,aAAaA,QAAO;AAAA,EACtC;AAAA,EAEA,MAAM,eAAe;AACjB,eAAW,UAAU,KAAK,SAAS;AAC/B,YAAM,gBAAAE,QAAQ,GAAG,QAAQ,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IAC7D;AAAA,EACJ;AACJ;;;AF/QA,IAAO,gBAAQ;AACR,IAAM,WAAW;AAYxB,eAAsB,sBAAsB,UAAmB;AAC3D,QAAMC,YAAW,IAAI,0BAAAC,QAAiB,EAAC,SAAkB,CAAC;AAC1D,SAAO,MAAMD,UAAS,YAAY,aAAa;AACnD;","names":["import_obsidian_launcher","pluginId","id","logger","path","ObsidianLauncher","browser","_","fsAsync","launcher","ObsidianLauncher"]}
1
+ {"version":3,"sources":["../src/index.ts","../../../node_modules/tsup/assets/cjs_shims.js","../src/service.ts","../src/types.ts","../src/browserCommands.ts","../src/utils.ts"],"sourcesContent":["import ObsidianLauncher from \"obsidian-launcher\"\nimport { ObsidianLauncherService, ObsidianWorkerService } from \"./service.js\";\n\nexport default ObsidianWorkerService;\nexport const launcher = ObsidianLauncherService;\n\nexport type { ObsidianServiceOptions, ObsidianCapabilityOptions } from \"./types.js\";\n\nexport type {\n LocalPluginEntry, GitHubPluginEntry, CommunityPluginEntry, PluginEntry,\n LocalThemeEntry, GitHubThemeEntry, CommunityThemeEntry, ThemeEntry,\n} from \"obsidian-launcher\"\n\n/**\n * Returns true if there's currently an Obsidian beta and we have the credentials to download it or it's already in the\n * cache.\n */\nexport async function obsidianBetaAvailable(cacheDir?: string) {\n const launcher = new ObsidianLauncher({cacheDir: cacheDir});\n const versionInfo = await launcher.getVersionInfo(\"latest-beta\");\n return versionInfo.isBeta && await launcher.isAvailable(versionInfo.version);\n}\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import fsAsync from \"fs/promises\"\nimport path from \"path\"\nimport { SevereServiceError } from 'webdriverio'\nimport type { Capabilities, Options, Services } from '@wdio/types'\nimport logger from '@wdio/logger'\nimport { fileURLToPath } from \"url\"\nimport ObsidianLauncher, { DownloadedPluginEntry, DownloadedThemeEntry } from \"obsidian-launcher\"\nimport browserCommands from \"./browserCommands.js\"\nimport { ObsidianCapabilityOptions, ObsidianServiceOptions, OBSIDIAN_CAPABILITY_KEY } from \"./types.js\"\nimport { sleep } from \"./utils.js\"\nimport _ from \"lodash\"\n\n\nconst log = logger(\"wdio-obsidian-service\");\n\nfunction getDefaultCacheDir() {\n return path.resolve(process.env.WEBDRIVER_CACHE_DIR ?? \"./.obsidian-cache\")\n}\n\nexport class ObsidianLauncherService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n private readonly helperPluginPath: string\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.helperPluginPath = path.resolve(path.join(fileURLToPath(import.meta.url), '../../helper-plugin'));\n }\n\n async onPrepare(config: Options.Testrunner, capabilities: Capabilities.TestrunnerCapabilities) {\n if (!Array.isArray(capabilities)) {\n capabilities = Object.values(capabilities as Capabilities.RequestedMultiremoteCapabilities).map(\n (multiremoteOption) => (multiremoteOption as Capabilities.WithRequestedCapabilities).capabilities,\n );\n }\n\n const obsidianCapabilities = capabilities.flatMap((cap) => {\n if ((\"browserName\" in cap) && cap.browserName === \"obsidian\") {\n return [cap as WebdriverIO.Capabilities];\n } else {\n return [];\n }\n });\n\n try {\n for (const cap of obsidianCapabilities) {\n const obsidianOptions = cap[OBSIDIAN_CAPABILITY_KEY] ?? {};\n \n const vault = obsidianOptions.vault != undefined ? path.resolve(obsidianOptions.vault) : undefined;\n \n const [appVersion, installerVersion] = await this.obsidianLauncher.resolveVersions(\n cap.browserVersion ?? \"latest\",\n obsidianOptions.installerVersion ?? \"earliest\",\n );\n const installerVersionInfo = await this.obsidianLauncher.getVersionInfo(installerVersion);\n\n let installerPath = obsidianOptions.binaryPath;\n if (!installerPath) {\n installerPath = await this.obsidianLauncher.downloadInstaller(installerVersion);\n }\n let appPath = obsidianOptions.appPath;\n if (!appPath) {\n appPath = await this.obsidianLauncher.downloadApp(appVersion);\n }\n let chromedriverPath = cap['wdio:chromedriverOptions']?.binary\n // wdio can download chromedriver for versions greater than 115 automatically\n if (!chromedriverPath && Number(installerVersionInfo.chromeVersion!.split(\".\")[0]) <= 115) {\n chromedriverPath = await this.obsidianLauncher.downloadChromedriver(installerVersion);\n }\n\n let plugins = obsidianOptions.plugins ?? [\".\"];\n plugins.push(this.helperPluginPath); // Always install the helper plugin\n plugins = await this.obsidianLauncher.downloadPlugins(plugins);\n\n const themes = await this.obsidianLauncher.downloadThemes(obsidianOptions.themes ?? []);\n\n const args = [\n // Workaround for SUID issue on AppImages. See https://github.com/electron/electron/issues/42510\n ...(process.platform == 'linux' ? [\"--no-sandbox\"] : []),\n ...(cap['goog:chromeOptions']?.args ?? [])\n ];\n\n cap.browserName = \"chrome\";\n cap.browserVersion = installerVersionInfo.chromeVersion;\n cap[OBSIDIAN_CAPABILITY_KEY] = {\n ...obsidianOptions,\n plugins: plugins,\n themes: themes,\n binaryPath: installerPath,\n appPath: appPath,\n vault: vault,\n appVersion: appVersion, // Resolve the versions\n installerVersion: installerVersion,\n };\n cap['goog:chromeOptions'] = {\n binary: installerPath,\n windowTypes: [\"app\", \"webview\"],\n ...cap['goog:chromeOptions'],\n args: args,\n }\n cap['wdio:chromedriverOptions'] = {\n // allowedIps is not included in the types, but gets passed as --allowed-ips to chromedriver.\n // It defaults to [\"0.0.0.0\"] which makes Windows Firewall complain, and we don't need remote\n // connections anyways.\n allowedIps: [],\n ...cap['wdio:chromedriverOptions'],\n binary: chromedriverPath,\n } as any\n cap[\"wdio:enforceWebDriverClassic\"] = true;\n }\n } catch (e: any) {\n // By default wdio just logs service errors, throwing this makes it bail if anything goes wrong.\n throw new SevereServiceError(`Failed to download and setup Obsidian. Caused by: ${e.stack}\\n`+\n ` ------The above causes:-----`);\n }\n }\n}\n\nexport class ObsidianWorkerService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n /** Directories to clean up after the tests */\n private tmpDirs: string[]\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.tmpDirs = [];\n }\n\n private async setupObsidian(obsidianOptions: ObsidianCapabilityOptions) {\n let vault = obsidianOptions.vault;\n if (vault != undefined) {\n log.info(`Opening vault ${obsidianOptions.vault}`);\n vault = await this.obsidianLauncher.setupVault({\n vault,\n copy: true,\n plugins: obsidianOptions.plugins,\n themes: obsidianOptions.themes,\n });\n this.tmpDirs.push(vault);\n } else {\n log.info(`Opening Obsidian without a vault`)\n }\n\n const configDir = await this.obsidianLauncher.setupConfigDir({\n appVersion: obsidianOptions.appVersion!, installerVersion: obsidianOptions.installerVersion!,\n appPath: obsidianOptions.appPath!,\n vault: vault,\n });\n this.tmpDirs.push(configDir);\n\n return configDir;\n }\n\n private async waitForReady(browser: WebdriverIO.Browser) {\n if (browser.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault != undefined) {\n await browser.waitUntil( // wait until the helper plugin is loaded\n () => browser.execute(() => !!(window as any).wdioObsidianService),\n {timeout: 30 * 1000, interval: 100},\n );\n await browser.executeObsidian(async ({app}) => {\n await new Promise<void>((resolve) => app.workspace.onLayoutReady(resolve) );\n })\n }\n }\n\n async beforeSession(config: Options.Testrunner, capabilities: WebdriverIO.Capabilities) {\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const configDir = await this.setupObsidian(capabilities[OBSIDIAN_CAPABILITY_KEY]);\n\n capabilities['goog:chromeOptions']!.args = [\n `--user-data-dir=${configDir}`,\n ...(capabilities['goog:chromeOptions']!.args ?? [])\n ];\n }\n\n private selectPlugins(currentPlugins: DownloadedPluginEntry[], selection?: string[]) {\n if (selection !== undefined) {\n const unknownPlugins = _.difference(selection, currentPlugins.map(p => p.id));\n if (unknownPlugins.length > 0) {\n throw Error(`Unknown plugin ids: ${unknownPlugins.join(', ')}`)\n }\n return currentPlugins.map(p => ({\n ...p,\n enabled: selection.includes(p.id) || p.id == \"wdio-obsidian-service-plugin\",\n }));\n } else {\n return currentPlugins;\n }\n }\n\n private selectThemes(currentThemes: DownloadedThemeEntry[], selection?: string) {\n if (selection !== undefined) {\n if (selection != \"default\" && currentThemes.every((t: any) => t.name != selection)) {\n throw Error(`Unknown theme: ${selection}`);\n }\n return currentThemes.map((t: any) => ({...t, enabled: selection != 'default' && t.name === selection}));\n } else {\n return currentThemes;\n }\n }\n\n async before(capabilities: WebdriverIO.Capabilities, specs: never, browser: WebdriverIO.Browser) {\n // There's a slow event listener link on the browser \"command\" event when you reloadSession that causes some\n // warnings. This will silence them. TODO: Make issue or PR to wdio to fix this.\n browser.setMaxListeners(1000);\n\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const service = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const reloadObsidian: typeof browser['reloadObsidian'] = async function(\n this: WebdriverIO.Browser,\n {vault, plugins, theme} = {},\n ) {\n const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];\n let newCapabilities: WebdriverIO.Capabilities\n\n if (vault) {\n const newObsidianOptions = {\n ...oldObsidianOptions,\n vault: path.resolve(vault),\n plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),\n themes: service.selectThemes(oldObsidianOptions.themes, theme),\n }\n \n const configDir = await service.setupObsidian(newObsidianOptions);\n \n const newArgs = [\n `--user-data-dir=${configDir}`,\n ...this.requestedCapabilities['goog:chromeOptions'].args.filter((arg: string) => {\n const match = arg.match(/^--user-data-dir=(.*)$/);\n return !match || !service.tmpDirs.includes(match[1]);\n }),\n ]\n \n newCapabilities = {\n [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,\n 'goog:chromeOptions': {\n ...this.requestedCapabilities['goog:chromeOptions'],\n args: newArgs,\n },\n };\n } else {\n // preserve vault and config dir\n newCapabilities = {};\n // Since we aren't recreating the vault, we'll need to reset plugins and themes here if specified.\n if (plugins) {\n const enabledPlugins = await browser.executeObsidian(({app}) =>\n [...(app as any).plugins.enabledPlugins].sort()\n )\n for (const pluginId of _.difference(enabledPlugins, plugins, ['wdio-obsidian-service-plugin'])) {\n await browser.disablePlugin(pluginId);\n }\n for (const pluginId of _.difference(plugins, enabledPlugins)) {\n await browser.enablePlugin(pluginId);\n }\n await browser.executeObsidian(async ({app}) => await (app as any).plugins.saveConfig())\n }\n if (theme) {\n await browser.setTheme(theme);\n await browser.executeObsidian(async ({app}) => await (app.vault as any).saveConfig())\n }\n // Obsidian debounces saves to the config dir, and so changes to plugin list, themes, and anything else\n // you set in your tests may not get saved to disk before the reboot. I haven't found a better way to\n // make sure everything's saved then just waiting a bit.\n await sleep(2000);\n }\n\n const sessionId = await browser.reloadSession({\n // if browserName is set, reloadSession tries to restart the driver entirely, so unset those\n ..._.omit(this.requestedCapabilities, ['browserName', 'browserVersion']),\n ...newCapabilities,\n });\n await service.waitForReady(this);\n return sessionId;\n }\n\n await browser.addCommand(\"reloadObsidian\", reloadObsidian);\n\n for (const [name, cmd] of Object.entries(browserCommands)) {\n await browser.addCommand(name, cmd);\n }\n\n await service.waitForReady(browser);\n }\n\n async afterSession() {\n for (const tmpDir of this.tmpDirs) {\n await fsAsync.rm(tmpDir, { recursive: true, force: true });\n }\n }\n}\n","import type { ObsidianBrowserCommands } from \"./browserCommands.js\";\nimport type { PluginEntry, ThemeEntry } from \"obsidian-launcher\";\n\nexport const OBSIDIAN_CAPABILITY_KEY = \"wdio:obsidianOptions\" as const;\n\nexport interface ObsidianServiceOptions {\n /**\n * Override the `obsidian-versions.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n versionsUrl?: string,\n /**\n * Override the `community-plugins.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityPluginsUrl?: string,\n /**\n * Override the `community-css-themes.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityThemesUrl?: string,\n}\n\nexport interface ObsidianCapabilityOptions {\n /**\n * Version of Obsidian to run.\n * \n * Can be set to \"latest\", \"latest-beta\", or a specific version. Defaults to \"latest\". To download beta versions\n * you'll need to be an Obsidian insider and set the OBSIDIAN_USERNAME and OBSIDIAN_PASSWORD environment\n * variables.\n * \n * You can also use the wdio capability `browserVersion` field to set the Obsidian version.\n */\n appVersion?: string\n\n /**\n * Version of the Obsidian Installer to download.\n * \n * Note that Obsidian is distributed in two parts, the \"installer\", which is the executable containing Electron, and\n * the \"app\" which is a bundle of JavaScript containing the Obsidian code. Obsidian's self-update system only\n * updates the JavaScript bundle, and not the base installer/Electron version. This makes Obsidian's auto-update\n * fast as it only needs to download a few MiB of JS instead of all of Electron. But, it means different users with\n * the same Obsidian version may be running on different versions of Electron, which could cause subtle differences\n * in plugin behavior if you are using newer JavaScript features and the like in your plugin.\n * \n * If passed \"latest\", it will use the maximum installer version compatible with the selected Obsidian version. If\n * passed \"earliest\" it will use the oldest installer version compatible with the selected Obsidian version. The \n * default is \"earliest\".\n */\n installerVersion?: string,\n\n /**\n * List of plugins to install.\n * \n * Each entry is a path to the local plugin to install, e.g. [\".\"] or [\"dist\"] depending on your build setup. You\n * can also pass objects. If you pass an object it can contain one of either `path` (to install a local plugin),\n * `repo` (to install a plugin from github), or `id` (to install a community plugin). You can set `enabled: false`\n * to install the plugin but start it disabled. You can enable the plugin later using `reloadObsidian` or the\n * `enablePlugin` command.\n */\n plugins?: PluginEntry[],\n\n /**\n * List of themes to install.\n * \n * Each entry is a path to the local theme to install. You can also pass an object. If you pass an object it can\n * contain one of either `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to\n * install a community theme). You can set `enabled: false` to install the theme, but start it disabled. You can\n * only have one enabled theme, so if you pass multiple you'll have to disable all but one.\n */\n themes?: ThemeEntry[],\n\n /**\n * The path to the vault to open.\n * \n * The vault will be copied, so any changes made in your tests won't affect the original. If omitted, no vault will\n * be opened and you'll need to call `browser.reloadObsidian` to open a vault during your tests.\n */\n vault?: string,\n\n /** Path to the Obsidian binary to use. If omitted it will download Obsidian automatically. */\n binaryPath?: string,\n\n /** Path to the app asar to load into obsidian. If omitted it will be downloaded automatically. */\n appPath?: string,\n}\n\n\ndeclare global {\n namespace WebdriverIO {\n interface Capabilities {\n [OBSIDIAN_CAPABILITY_KEY]?: ObsidianCapabilityOptions,\n }\n\n interface Browser extends ObsidianBrowserCommands {\n /**\n * Relaunch obsidian. Can be used to switch to a new vault, change the plugin list, or just to reboot\n * Obsidian.\n * \n * As this does a full reboot of Obsidian, avoid calling this too often so you don't slow your tests down.\n * You can also set the vault in the `wdio.conf.ts` capabilities section which may be useful if all\n * your tests use the same vault.\n * \n * @param vault Path to the vault to open. The vault will be copied, so any changes made in your tests won't\n * be persited to the original. If omitted, it will reboot Obsidian with the current vault, without\n * creating a new copy of the vault.\n * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list. Note, all the\n * plugins must be defined in your wdio.conf.ts capabilities. You can also use the enablePlugin and \n * disablePlugin commands to change plugins without relaunching Obsidian.\n * @param theme Name of the theme to enable. If omitted it will keep the current theme. Pass \"default\" to\n * switch back to the default theme. Like with plugins, the theme must be defined in wdio.conf.ts.\n * @returns Returns the new sessionId (same as browser.reloadSession()).\n */\n reloadObsidian(params?: {\n vault?: string,\n plugins?: string[], theme?: string,\n }): Promise<string>;\n }\n }\n}\n","import { OBSIDIAN_CAPABILITY_KEY } from \"./types.js\";\nimport type * as obsidian from \"obsidian\"\n\n\ntype ExecuteObsidianArg = {\n /**\n * There is a global \"app\" instance, but that may be removed in the future so you can use this to access it from\n * tests. See https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines#Avoid+using+global+app+instance\n */\n app: obsidian.App,\n\n /**\n * The full obsidian API. See https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts\n */\n obsidian: typeof obsidian,\n}\n\nconst browserCommands = {\n /** Returns the Obsidian version this test is running under. */\n async getObsidianVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].appVersion;\n },\n\n /** Returns the Obsidian installer version this test is running under. */\n async getObsidianInstallerVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].installerVersion;\n },\n\n /**\n * Wrapper around browser.execute that passes the Obsidian API to the function. The function will be run inside\n * Obsidian. The first argument to the function is an object containing keys:\n * - app: Obsidian app instance\n * - obsidian: Full Obsidian API\n * See also: https://webdriver.io/docs/api/browser/execute\n * \n * Example usage\n * ```ts\n * const file = browser.executeObsidian(({app, obsidian}, path) => {\n * return app.vault.getMarkdownFiles().find(f => f.path == path)\n * })\n * ```\n */\n async executeObsidian<Return, Params extends unknown[]>(\n func: (obs: ExecuteObsidianArg, ...params: Params) => Return,\n ...params: Params\n ): Promise<Return> {\n return await browser.execute<Return, Params>(\n `return (${func.toString()}).call(null, {...window.wdioObsidianService}, ...arguments )`,\n ...params,\n )\n },\n\n /** Returns the path to the vault opened in Obsidian */\n async getVaultPath(this: WebdriverIO.Browser): Promise<string|undefined> {\n if (this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault == undefined) {\n return undefined; // no vault open\n } else { // return the actual path to the vault\n return await this.executeObsidian(({app, obsidian}) => {\n if (app.vault.adapter instanceof obsidian.FileSystemAdapter) {\n return app.vault.adapter.getBasePath()\n } else { // TODO handle CapacitorAdapater\n throw new Error(`Unrecognized DataAdapater type`)\n };\n })\n }\n },\n\n /** Enables a plugin */\n async enablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.enablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /** Disables a plugin */\n async disablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.disablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /** Sets the theme. Pass \"default\" to reset to the Obsidian theme. */\n async setTheme(this: WebdriverIO.Browser, themeName: string): Promise<void> {\n themeName = themeName == 'default' ? '' : themeName;\n await this.executeObsidian(\n async ({app}, themeName) => await (app as any).customCss.setTheme(themeName),\n themeName,\n )\n },\n\n /**\n * Executes an Obsidian command.\n * @param id Id of the command to run.\n */\n async executeObsidianCommand(this: WebdriverIO.Browser, id: string) {\n const result = await this.executeObsidian(({app}, id) => (app as any).commands.executeCommandById(id), id);\n if (!result) {\n throw Error(`Obsidian command ${id} not found or failed.`);\n }\n },\n} as const\n\nexport type ObsidianBrowserCommands = typeof browserCommands;\nexport default browserCommands;\n","export async function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;;;ADX9D,IAAAA,4BAA6B;;;AEA7B,sBAAoB;AACpB,kBAAiB;AACjB,yBAAmC;AAEnC,oBAAmB;AACnB,iBAA8B;AAC9B,+BAA8E;;;ACHvE,IAAM,0BAA0B;;;ACcvC,IAAM,kBAAkB;AAAA;AAAA,EAEpB,MAAM,qBAA+D;AACjE,WAAO,KAAK,sBAAsB,uBAAuB,EAAE;AAAA,EAC/D;AAAA;AAAA,EAGA,MAAM,8BAAwE;AAC1E,WAAO,KAAK,sBAAsB,uBAAuB,EAAE;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,gBACF,SACG,QACY;AACf,WAAO,MAAM,QAAQ;AAAA,MACjB,WAAW,KAAK,SAAS,CAAC;AAAA,MAC1B,GAAG;AAAA,IACP;AAAA,EACJ;AAAA;AAAA,EAGA,MAAM,eAAmE;AACrE,QAAI,KAAK,sBAAsB,uBAAuB,EAAE,SAAS,QAAW;AACxE,aAAO;AAAA,IACX,OAAO;AACH,aAAO,MAAM,KAAK,gBAAgB,CAA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;AACA,gBAAMA,SAAQ,gBAAgB,OAAO,EAAC,IAAG,MAAM,MAAO,IAAY,QAAQ,WAAW,CAAC;AAAA,QAC1F;AACA,YAAI,OAAO;AACP,gBAAMA,SAAQ,SAAS,KAAK;AAC5B,gBAAMA,SAAQ,gBAAgB,OAAO,EAAC,IAAG,MAAM,MAAO,IAAI,MAAc,WAAW,CAAC;AAAA,QACxF;AAIA,cAAM,MAAM,GAAI;AAAA,MACpB;AAEA,YAAM,YAAY,MAAMA,SAAQ,cAAc;AAAA;AAAA,QAE1C,GAAG,cAAAC,QAAE,KAAK,KAAK,uBAAuB,CAAC,eAAe,gBAAgB,CAAC;AAAA,QACvE,GAAG;AAAA,MACP,CAAC;AACD,YAAM,QAAQ,aAAa,IAAI;AAC/B,aAAO;AAAA,IACX;AAEA,UAAMD,SAAQ,WAAW,kBAAkB,cAAc;AAEzD,eAAW,CAAC,MAAM,GAAG,KAAK,OAAO,QAAQ,uBAAe,GAAG;AACvD,YAAMA,SAAQ,WAAW,MAAM,GAAG;AAAA,IACtC;AAEA,UAAM,QAAQ,aAAaA,QAAO;AAAA,EACtC;AAAA,EAEA,MAAM,eAAe;AACjB,eAAW,UAAU,KAAK,SAAS;AAC/B,YAAM,gBAAAE,QAAQ,GAAG,QAAQ,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IAC7D;AAAA,EACJ;AACJ;;;AF/SA,IAAO,gBAAQ;AACR,IAAM,WAAW;AAaxB,eAAsB,sBAAsB,UAAmB;AAC3D,QAAMC,YAAW,IAAI,0BAAAC,QAAiB,EAAC,SAAkB,CAAC;AAC1D,QAAM,cAAc,MAAMD,UAAS,eAAe,aAAa;AAC/D,SAAO,YAAY,UAAU,MAAMA,UAAS,YAAY,YAAY,OAAO;AAC/E;","names":["import_obsidian_launcher","pluginId","themeName","id","logger","path","ObsidianLauncher","browser","_","fsAsync","launcher","ObsidianLauncher"]}
package/dist/index.d.cts CHANGED
@@ -40,6 +40,8 @@ declare const browserCommands: {
40
40
  readonly enablePlugin: (this: WebdriverIO.Browser, pluginId: string) => Promise<void>;
41
41
  /** Disables a plugin */
42
42
  readonly disablePlugin: (this: WebdriverIO.Browser, pluginId: string) => Promise<void>;
43
+ /** Sets the theme. Pass "default" to reset to the Obsidian theme. */
44
+ readonly setTheme: (this: WebdriverIO.Browser, themeName: string) => Promise<void>;
43
45
  /**
44
46
  * Executes an Obsidian command.
45
47
  * @param id Id of the command to run.
@@ -98,7 +100,7 @@ interface ObsidianCapabilityOptions {
98
100
  * Each entry is a path to the local plugin to install, e.g. ["."] or ["dist"] depending on your build setup. You
99
101
  * can also pass objects. If you pass an object it can contain one of either `path` (to install a local plugin),
100
102
  * `repo` (to install a plugin from github), or `id` (to install a community plugin). You can set `enabled: false`
101
- * to install the plugin but start it disabled. You can enable the plugin later using `openVault` or the
103
+ * to install the plugin but start it disabled. You can enable the plugin later using `reloadObsidian` or the
102
104
  * `enablePlugin` command.
103
105
  */
104
106
  plugins?: PluginEntry[];
@@ -115,7 +117,7 @@ interface ObsidianCapabilityOptions {
115
117
  * The path to the vault to open.
116
118
  *
117
119
  * The vault will be copied, so any changes made in your tests won't affect the original. If omitted, no vault will
118
- * be opened and you'll need to call `browser.openVault` to open a vault during your tests.
120
+ * be opened and you'll need to call `browser.reloadObsidian` to open a vault during your tests.
119
121
  */
120
122
  vault?: string;
121
123
  /** Path to the Obsidian binary to use. If omitted it will download Obsidian automatically. */
@@ -133,20 +135,21 @@ declare global {
133
135
  * Relaunch obsidian. Can be used to switch to a new vault, change the plugin list, or just to reboot
134
136
  * Obsidian.
135
137
  *
136
- * The vault will be copied, so any changes made in your tests won't be persited to the original. This
137
- * does require rebooting Obsidian, so avoid calling this too often so you don't slow your tests down.
138
+ * As this does a full reboot of Obsidian, avoid calling this too often so you don't slow your tests down.
138
139
  * You can also set the vault in the `wdio.conf.ts` capabilities section which may be useful if all
139
140
  * your tests use the same vault.
140
141
  *
141
- * @param vault path to the vault to open. If omitted it will re-open the current vault.
142
- * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list.
143
- * Note, all the plugins must be defined in your wdio.conf.ts capabilities. You can use openVault to
144
- * toggle which plugins are enabled and which are disabled.
142
+ * @param vault Path to the vault to open. The vault will be copied, so any changes made in your tests won't
143
+ * be persited to the original. If omitted, it will reboot Obsidian with the current vault, without
144
+ * creating a new copy of the vault.
145
+ * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list. Note, all the
146
+ * plugins must be defined in your wdio.conf.ts capabilities. You can also use the enablePlugin and
147
+ * disablePlugin commands to change plugins without relaunching Obsidian.
145
148
  * @param theme Name of the theme to enable. If omitted it will keep the current theme. Pass "default" to
146
149
  * switch back to the default theme. Like with plugins, the theme must be defined in wdio.conf.ts.
147
- * @returns Returns the new sessionId (same as reloadSession()).
150
+ * @returns Returns the new sessionId (same as browser.reloadSession()).
148
151
  */
149
- openVault(params?: {
152
+ reloadObsidian(params?: {
150
153
  vault?: string;
151
154
  plugins?: string[];
152
155
  theme?: string;
@@ -184,7 +187,8 @@ declare class ObsidianWorkerService implements Services.ServiceInstance {
184
187
  declare const launcher: typeof ObsidianLauncherService;
185
188
 
186
189
  /**
187
- * Returns true if we either have the credentails to download the latest Obsidian beta or it's already in cache.
190
+ * Returns true if there's currently an Obsidian beta and we have the credentials to download it or it's already in the
191
+ * cache.
188
192
  */
189
193
  declare function obsidianBetaAvailable(cacheDir?: string): Promise<boolean>;
190
194
 
package/dist/index.d.ts CHANGED
@@ -40,6 +40,8 @@ declare const browserCommands: {
40
40
  readonly enablePlugin: (this: WebdriverIO.Browser, pluginId: string) => Promise<void>;
41
41
  /** Disables a plugin */
42
42
  readonly disablePlugin: (this: WebdriverIO.Browser, pluginId: string) => Promise<void>;
43
+ /** Sets the theme. Pass "default" to reset to the Obsidian theme. */
44
+ readonly setTheme: (this: WebdriverIO.Browser, themeName: string) => Promise<void>;
43
45
  /**
44
46
  * Executes an Obsidian command.
45
47
  * @param id Id of the command to run.
@@ -98,7 +100,7 @@ interface ObsidianCapabilityOptions {
98
100
  * Each entry is a path to the local plugin to install, e.g. ["."] or ["dist"] depending on your build setup. You
99
101
  * can also pass objects. If you pass an object it can contain one of either `path` (to install a local plugin),
100
102
  * `repo` (to install a plugin from github), or `id` (to install a community plugin). You can set `enabled: false`
101
- * to install the plugin but start it disabled. You can enable the plugin later using `openVault` or the
103
+ * to install the plugin but start it disabled. You can enable the plugin later using `reloadObsidian` or the
102
104
  * `enablePlugin` command.
103
105
  */
104
106
  plugins?: PluginEntry[];
@@ -115,7 +117,7 @@ interface ObsidianCapabilityOptions {
115
117
  * The path to the vault to open.
116
118
  *
117
119
  * The vault will be copied, so any changes made in your tests won't affect the original. If omitted, no vault will
118
- * be opened and you'll need to call `browser.openVault` to open a vault during your tests.
120
+ * be opened and you'll need to call `browser.reloadObsidian` to open a vault during your tests.
119
121
  */
120
122
  vault?: string;
121
123
  /** Path to the Obsidian binary to use. If omitted it will download Obsidian automatically. */
@@ -133,20 +135,21 @@ declare global {
133
135
  * Relaunch obsidian. Can be used to switch to a new vault, change the plugin list, or just to reboot
134
136
  * Obsidian.
135
137
  *
136
- * The vault will be copied, so any changes made in your tests won't be persited to the original. This
137
- * does require rebooting Obsidian, so avoid calling this too often so you don't slow your tests down.
138
+ * As this does a full reboot of Obsidian, avoid calling this too often so you don't slow your tests down.
138
139
  * You can also set the vault in the `wdio.conf.ts` capabilities section which may be useful if all
139
140
  * your tests use the same vault.
140
141
  *
141
- * @param vault path to the vault to open. If omitted it will re-open the current vault.
142
- * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list.
143
- * Note, all the plugins must be defined in your wdio.conf.ts capabilities. You can use openVault to
144
- * toggle which plugins are enabled and which are disabled.
142
+ * @param vault Path to the vault to open. The vault will be copied, so any changes made in your tests won't
143
+ * be persited to the original. If omitted, it will reboot Obsidian with the current vault, without
144
+ * creating a new copy of the vault.
145
+ * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list. Note, all the
146
+ * plugins must be defined in your wdio.conf.ts capabilities. You can also use the enablePlugin and
147
+ * disablePlugin commands to change plugins without relaunching Obsidian.
145
148
  * @param theme Name of the theme to enable. If omitted it will keep the current theme. Pass "default" to
146
149
  * switch back to the default theme. Like with plugins, the theme must be defined in wdio.conf.ts.
147
- * @returns Returns the new sessionId (same as reloadSession()).
150
+ * @returns Returns the new sessionId (same as browser.reloadSession()).
148
151
  */
149
- openVault(params?: {
152
+ reloadObsidian(params?: {
150
153
  vault?: string;
151
154
  plugins?: string[];
152
155
  theme?: string;
@@ -184,7 +187,8 @@ declare class ObsidianWorkerService implements Services.ServiceInstance {
184
187
  declare const launcher: typeof ObsidianLauncherService;
185
188
 
186
189
  /**
187
- * Returns true if we either have the credentails to download the latest Obsidian beta or it's already in cache.
190
+ * Returns true if there's currently an Obsidian beta and we have the credentials to download it or it's already in the
191
+ * cache.
188
192
  */
189
193
  declare function obsidianBetaAvailable(cacheDir?: string): Promise<boolean>;
190
194
 
package/dist/index.js CHANGED
@@ -71,6 +71,14 @@ var browserCommands = {
71
71
  pluginId
72
72
  );
73
73
  },
74
+ /** Sets the theme. Pass "default" to reset to the Obsidian theme. */
75
+ async setTheme(themeName) {
76
+ themeName = themeName == "default" ? "" : themeName;
77
+ await this.executeObsidian(
78
+ async ({ app }, themeName2) => await app.customCss.setTheme(themeName2),
79
+ themeName
80
+ );
81
+ },
74
82
  /**
75
83
  * Executes an Obsidian command.
76
84
  * @param id Id of the command to run.
@@ -84,6 +92,11 @@ var browserCommands = {
84
92
  };
85
93
  var browserCommands_default = browserCommands;
86
94
 
95
+ // src/utils.ts
96
+ async function sleep(ms) {
97
+ return new Promise((resolve) => setTimeout(resolve, ms));
98
+ }
99
+
87
100
  // src/service.ts
88
101
  import _ from "lodash";
89
102
  var log = logger("wdio-obsidian-service");
@@ -265,33 +278,60 @@ var ObsidianWorkerService = class {
265
278
  browser2.setMaxListeners(1e3);
266
279
  if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;
267
280
  const service = this;
268
- const openVault = async function({ vault, plugins, theme } = {}) {
281
+ const reloadObsidian = async function({ vault, plugins, theme } = {}) {
269
282
  const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];
270
- const newObsidianOptions = {
271
- ...oldObsidianOptions,
272
- vault: vault != void 0 ? path.resolve(vault) : oldObsidianOptions.vault,
273
- plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),
274
- themes: service.selectThemes(oldObsidianOptions.themes, theme)
275
- };
276
- const configDir = await service.setupObsidian(newObsidianOptions);
277
- const newArgs = [
278
- `--user-data-dir=${configDir}`,
279
- ...this.requestedCapabilities["goog:chromeOptions"].args.filter((arg) => {
280
- const match = arg.match(/^--user-data-dir=(.*)$/);
281
- return !match || !service.tmpDirs.includes(match[1]);
282
- })
283
- ];
284
- const sessionId = await this.reloadSession({
285
- [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,
286
- "goog:chromeOptions": {
287
- ...this.requestedCapabilities["goog:chromeOptions"],
288
- args: newArgs
283
+ let newCapabilities;
284
+ if (vault) {
285
+ const newObsidianOptions = {
286
+ ...oldObsidianOptions,
287
+ vault: path.resolve(vault),
288
+ plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),
289
+ themes: service.selectThemes(oldObsidianOptions.themes, theme)
290
+ };
291
+ const configDir = await service.setupObsidian(newObsidianOptions);
292
+ const newArgs = [
293
+ `--user-data-dir=${configDir}`,
294
+ ...this.requestedCapabilities["goog:chromeOptions"].args.filter((arg) => {
295
+ const match = arg.match(/^--user-data-dir=(.*)$/);
296
+ return !match || !service.tmpDirs.includes(match[1]);
297
+ })
298
+ ];
299
+ newCapabilities = {
300
+ [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,
301
+ "goog:chromeOptions": {
302
+ ...this.requestedCapabilities["goog:chromeOptions"],
303
+ args: newArgs
304
+ }
305
+ };
306
+ } else {
307
+ newCapabilities = {};
308
+ if (plugins) {
309
+ const enabledPlugins = await browser2.executeObsidian(
310
+ ({ app }) => [...app.plugins.enabledPlugins].sort()
311
+ );
312
+ for (const pluginId of _.difference(enabledPlugins, plugins, ["wdio-obsidian-service-plugin"])) {
313
+ await browser2.disablePlugin(pluginId);
314
+ }
315
+ for (const pluginId of _.difference(plugins, enabledPlugins)) {
316
+ await browser2.enablePlugin(pluginId);
317
+ }
318
+ await browser2.executeObsidian(async ({ app }) => await app.plugins.saveConfig());
289
319
  }
320
+ if (theme) {
321
+ await browser2.setTheme(theme);
322
+ await browser2.executeObsidian(async ({ app }) => await app.vault.saveConfig());
323
+ }
324
+ await sleep(2e3);
325
+ }
326
+ const sessionId = await browser2.reloadSession({
327
+ // if browserName is set, reloadSession tries to restart the driver entirely, so unset those
328
+ ..._.omit(this.requestedCapabilities, ["browserName", "browserVersion"]),
329
+ ...newCapabilities
290
330
  });
291
331
  await service.waitForReady(this);
292
332
  return sessionId;
293
333
  };
294
- await browser2.addCommand("openVault", openVault);
334
+ await browser2.addCommand("reloadObsidian", reloadObsidian);
295
335
  for (const [name, cmd] of Object.entries(browserCommands_default)) {
296
336
  await browser2.addCommand(name, cmd);
297
337
  }
@@ -309,7 +349,8 @@ var index_default = ObsidianWorkerService;
309
349
  var launcher = ObsidianLauncherService;
310
350
  async function obsidianBetaAvailable(cacheDir) {
311
351
  const launcher2 = new ObsidianLauncher2({ cacheDir });
312
- return await launcher2.isAvailable("latest-beta");
352
+ const versionInfo = await launcher2.getVersionInfo("latest-beta");
353
+ return versionInfo.isBeta && await launcher2.isAvailable(versionInfo.version);
313
354
  }
314
355
  export {
315
356
  index_default as default,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/service.ts","../src/types.ts","../src/browserCommands.ts"],"sourcesContent":["import ObsidianLauncher from \"obsidian-launcher\"\nimport { ObsidianLauncherService, ObsidianWorkerService } from \"./service.js\";\n\nexport default ObsidianWorkerService;\nexport const launcher = ObsidianLauncherService;\n\nexport type { ObsidianServiceOptions, ObsidianCapabilityOptions } from \"./types.js\";\n\nexport type {\n LocalPluginEntry, GitHubPluginEntry, CommunityPluginEntry, PluginEntry,\n LocalThemeEntry, GitHubThemeEntry, CommunityThemeEntry, ThemeEntry,\n} from \"obsidian-launcher\"\n\n/**\n * Returns true if we either have the credentails to download the latest Obsidian beta or it's already in cache.\n */\nexport async function obsidianBetaAvailable(cacheDir?: string) {\n const launcher = new ObsidianLauncher({cacheDir: cacheDir});\n return await launcher.isAvailable(\"latest-beta\");\n}\n","import fsAsync from \"fs/promises\"\nimport path from \"path\"\nimport { SevereServiceError } from 'webdriverio'\nimport type { Capabilities, Options, Services } from '@wdio/types'\nimport logger from '@wdio/logger'\nimport { fileURLToPath } from \"url\"\nimport ObsidianLauncher, { DownloadedPluginEntry, DownloadedThemeEntry } from \"obsidian-launcher\"\nimport browserCommands from \"./browserCommands.js\"\nimport { ObsidianCapabilityOptions, ObsidianServiceOptions, OBSIDIAN_CAPABILITY_KEY } from \"./types.js\"\nimport _ from \"lodash\"\n\n\nconst log = logger(\"wdio-obsidian-service\");\n\nfunction getDefaultCacheDir() {\n return path.resolve(process.env.WEBDRIVER_CACHE_DIR ?? \"./.obsidian-cache\")\n}\n\nexport class ObsidianLauncherService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n private readonly helperPluginPath: string\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.helperPluginPath = path.resolve(path.join(fileURLToPath(import.meta.url), '../../helper-plugin'));\n }\n\n async onPrepare(config: Options.Testrunner, capabilities: Capabilities.TestrunnerCapabilities) {\n if (!Array.isArray(capabilities)) {\n capabilities = Object.values(capabilities as Capabilities.RequestedMultiremoteCapabilities).map(\n (multiremoteOption) => (multiremoteOption as Capabilities.WithRequestedCapabilities).capabilities,\n );\n }\n\n const obsidianCapabilities = capabilities.flatMap((cap) => {\n if ((\"browserName\" in cap) && cap.browserName === \"obsidian\") {\n return [cap as WebdriverIO.Capabilities];\n } else {\n return [];\n }\n });\n\n try {\n for (const cap of obsidianCapabilities) {\n const obsidianOptions = cap[OBSIDIAN_CAPABILITY_KEY] ?? {};\n \n const vault = obsidianOptions.vault != undefined ? path.resolve(obsidianOptions.vault) : undefined;\n \n const [appVersion, installerVersion] = await this.obsidianLauncher.resolveVersions(\n cap.browserVersion ?? \"latest\",\n obsidianOptions.installerVersion ?? \"earliest\",\n );\n const installerVersionInfo = await this.obsidianLauncher.getVersionInfo(installerVersion);\n\n let installerPath = obsidianOptions.binaryPath;\n if (!installerPath) {\n installerPath = await this.obsidianLauncher.downloadInstaller(installerVersion);\n }\n let appPath = obsidianOptions.appPath;\n if (!appPath) {\n appPath = await this.obsidianLauncher.downloadApp(appVersion);\n }\n let chromedriverPath = cap['wdio:chromedriverOptions']?.binary\n // wdio can download chromedriver for versions greater than 115 automatically\n if (!chromedriverPath && Number(installerVersionInfo.chromeVersion!.split(\".\")[0]) <= 115) {\n chromedriverPath = await this.obsidianLauncher.downloadChromedriver(installerVersion);\n }\n\n let plugins = obsidianOptions.plugins ?? [\".\"];\n plugins.push(this.helperPluginPath); // Always install the helper plugin\n plugins = await this.obsidianLauncher.downloadPlugins(plugins);\n\n const themes = await this.obsidianLauncher.downloadThemes(obsidianOptions.themes ?? []);\n\n const args = [\n // Workaround for SUID issue on AppImages. See https://github.com/electron/electron/issues/42510\n ...(process.platform == 'linux' ? [\"--no-sandbox\"] : []),\n ...(cap['goog:chromeOptions']?.args ?? [])\n ];\n\n cap.browserName = \"chrome\";\n cap.browserVersion = installerVersionInfo.chromeVersion;\n cap[OBSIDIAN_CAPABILITY_KEY] = {\n ...obsidianOptions,\n plugins: plugins,\n themes: themes,\n binaryPath: installerPath,\n appPath: appPath,\n vault: vault,\n appVersion: appVersion, // Resolve the versions\n installerVersion: installerVersion,\n };\n cap['goog:chromeOptions'] = {\n binary: installerPath,\n windowTypes: [\"app\", \"webview\"],\n ...cap['goog:chromeOptions'],\n args: args,\n }\n cap['wdio:chromedriverOptions'] = {\n // allowedIps is not included in the types, but gets passed as --allowed-ips to chromedriver.\n // It defaults to [\"0.0.0.0\"] which makes Windows Firewall complain, and we don't need remote\n // connections anyways.\n allowedIps: [],\n ...cap['wdio:chromedriverOptions'],\n binary: chromedriverPath,\n } as any\n cap[\"wdio:enforceWebDriverClassic\"] = true;\n }\n } catch (e: any) {\n // By default wdio just logs service errors, throwing this makes it bail if anything goes wrong.\n throw new SevereServiceError(`Failed to download and setup Obsidian. Caused by: ${e.stack}\\n`+\n ` ------The above causes:-----`);\n }\n }\n}\n\nexport class ObsidianWorkerService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n /** Directories to clean up after the tests */\n private tmpDirs: string[]\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.tmpDirs = [];\n }\n\n private async setupObsidian(obsidianOptions: ObsidianCapabilityOptions) {\n let vault = obsidianOptions.vault;\n if (vault != undefined) {\n log.info(`Opening vault ${obsidianOptions.vault}`);\n vault = await this.obsidianLauncher.setupVault({\n vault,\n copy: true,\n plugins: obsidianOptions.plugins,\n themes: obsidianOptions.themes,\n });\n this.tmpDirs.push(vault);\n } else {\n log.info(`Opening Obsidian without a vault`)\n }\n\n const configDir = await this.obsidianLauncher.setupConfigDir({\n appVersion: obsidianOptions.appVersion!, installerVersion: obsidianOptions.installerVersion!,\n appPath: obsidianOptions.appPath!,\n vault: vault,\n });\n this.tmpDirs.push(configDir);\n\n return configDir;\n }\n\n private async waitForReady(browser: WebdriverIO.Browser) {\n if (browser.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault != undefined) {\n await browser.waitUntil( // wait until the helper plugin is loaded\n () => browser.execute(() => !!(window as any).wdioObsidianService),\n {timeout: 30 * 1000, interval: 100},\n );\n await browser.executeObsidian(async ({app}) => {\n await new Promise<void>((resolve) => app.workspace.onLayoutReady(resolve) );\n })\n }\n }\n\n async beforeSession(config: Options.Testrunner, capabilities: WebdriverIO.Capabilities) {\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const configDir = await this.setupObsidian(capabilities[OBSIDIAN_CAPABILITY_KEY]);\n\n capabilities['goog:chromeOptions']!.args = [\n `--user-data-dir=${configDir}`,\n ...(capabilities['goog:chromeOptions']!.args ?? [])\n ];\n }\n\n private selectPlugins(currentPlugins: DownloadedPluginEntry[], selection?: string[]) {\n if (selection !== undefined) {\n const unknownPlugins = _.difference(selection, currentPlugins.map(p => p.id));\n if (unknownPlugins.length > 0) {\n throw Error(`Unknown plugin ids: ${unknownPlugins.join(', ')}`)\n }\n return currentPlugins.map(p => ({\n ...p,\n enabled: selection.includes(p.id) || p.id == \"wdio-obsidian-service-plugin\",\n }));\n } else {\n return currentPlugins;\n }\n }\n\n private selectThemes(currentThemes: DownloadedThemeEntry[], selection?: string) {\n if (selection !== undefined) {\n if (selection != \"default\" && currentThemes.every((t: any) => t.name != selection)) {\n throw Error(`Unknown theme: ${selection}`);\n }\n return currentThemes.map((t: any) => ({...t, enabled: selection != 'default' && t.name === selection}));\n } else {\n return currentThemes;\n }\n }\n\n async before(capabilities: WebdriverIO.Capabilities, specs: never, browser: WebdriverIO.Browser) {\n // There's a slow event listener link on the browser \"command\" event when you reloadSession that causes some\n // warnings. This will silence them. TODO: Make issue or PR to wdio to fix this.\n browser.setMaxListeners(1000);\n\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const service = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const openVault: typeof browser['openVault'] = async function(\n this: WebdriverIO.Browser,\n {vault, plugins, theme} = {},\n ) {\n const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];\n\n const newObsidianOptions = {\n ...oldObsidianOptions,\n vault: vault != undefined ? path.resolve(vault) : oldObsidianOptions.vault,\n plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),\n themes: service.selectThemes(oldObsidianOptions.themes, theme),\n }\n\n const configDir = await service.setupObsidian(newObsidianOptions);\n \n const newArgs = [\n `--user-data-dir=${configDir}`,\n ...this.requestedCapabilities['goog:chromeOptions'].args.filter((arg: string) => {\n const match = arg.match(/^--user-data-dir=(.*)$/);\n return !match || !service.tmpDirs.includes(match[1]);\n }),\n ]\n\n // Reload session already merges with existing settings, and tries to restart the driver entirely if\n // you set browserName explicitly..\n const sessionId = await this.reloadSession({\n [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,\n 'goog:chromeOptions': {\n ...this.requestedCapabilities['goog:chromeOptions'],\n args: newArgs,\n },\n });\n await service.waitForReady(this);\n\n return sessionId;\n }\n await browser.addCommand(\"openVault\", openVault);\n\n for (const [name, cmd] of Object.entries(browserCommands)) {\n await browser.addCommand(name, cmd);\n }\n\n await service.waitForReady(browser);\n }\n\n async afterSession() {\n for (const tmpDir of this.tmpDirs) {\n await fsAsync.rm(tmpDir, { recursive: true, force: true });\n }\n }\n}\n","import type { ObsidianBrowserCommands } from \"./browserCommands.js\";\nimport type { PluginEntry, ThemeEntry } from \"obsidian-launcher\";\n\nexport const OBSIDIAN_CAPABILITY_KEY = \"wdio:obsidianOptions\" as const;\n\nexport interface ObsidianServiceOptions {\n /**\n * Override the `obsidian-versions.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n versionsUrl?: string,\n /**\n * Override the `community-plugins.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityPluginsUrl?: string,\n /**\n * Override the `community-css-themes.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityThemesUrl?: string,\n}\n\nexport interface ObsidianCapabilityOptions {\n /**\n * Version of Obsidian to run.\n * \n * Can be set to \"latest\", \"latest-beta\", or a specific version. Defaults to \"latest\". To download beta versions\n * you'll need to be an Obsidian insider and set the OBSIDIAN_USERNAME and OBSIDIAN_PASSWORD environment\n * variables.\n * \n * You can also use the wdio capability `browserVersion` field to set the Obsidian version.\n */\n appVersion?: string\n\n /**\n * Version of the Obsidian Installer to download.\n * \n * Note that Obsidian is distributed in two parts, the \"installer\", which is the executable containing Electron, and\n * the \"app\" which is a bundle of JavaScript containing the Obsidian code. Obsidian's self-update system only\n * updates the JavaScript bundle, and not the base installer/Electron version. This makes Obsidian's auto-update\n * fast as it only needs to download a few MiB of JS instead of all of Electron. But, it means different users with\n * the same Obsidian version may be running on different versions of Electron, which could cause subtle differences\n * in plugin behavior if you are using newer JavaScript features and the like in your plugin.\n * \n * If passed \"latest\", it will use the maximum installer version compatible with the selected Obsidian version. If\n * passed \"earliest\" it will use the oldest installer version compatible with the selected Obsidian version. The \n * default is \"earliest\".\n */\n installerVersion?: string,\n\n /**\n * List of plugins to install.\n * \n * Each entry is a path to the local plugin to install, e.g. [\".\"] or [\"dist\"] depending on your build setup. You\n * can also pass objects. If you pass an object it can contain one of either `path` (to install a local plugin),\n * `repo` (to install a plugin from github), or `id` (to install a community plugin). You can set `enabled: false`\n * to install the plugin but start it disabled. You can enable the plugin later using `openVault` or the\n * `enablePlugin` command.\n */\n plugins?: PluginEntry[],\n\n /**\n * List of themes to install.\n * \n * Each entry is a path to the local theme to install. You can also pass an object. If you pass an object it can\n * contain one of either `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to\n * install a community theme). You can set `enabled: false` to install the theme, but start it disabled. You can\n * only have one enabled theme, so if you pass multiple you'll have to disable all but one.\n */\n themes?: ThemeEntry[],\n\n /**\n * The path to the vault to open.\n * \n * The vault will be copied, so any changes made in your tests won't affect the original. If omitted, no vault will\n * be opened and you'll need to call `browser.openVault` to open a vault during your tests.\n */\n vault?: string,\n\n /** Path to the Obsidian binary to use. If omitted it will download Obsidian automatically. */\n binaryPath?: string,\n\n /** Path to the app asar to load into obsidian. If omitted it will be downloaded automatically. */\n appPath?: string,\n}\n\n\ndeclare global {\n namespace WebdriverIO {\n interface Capabilities {\n [OBSIDIAN_CAPABILITY_KEY]?: ObsidianCapabilityOptions,\n }\n\n interface Browser extends ObsidianBrowserCommands {\n /**\n * Relaunch obsidian. Can be used to switch to a new vault, change the plugin list, or just to reboot\n * Obsidian.\n * \n * The vault will be copied, so any changes made in your tests won't be persited to the original. This\n * does require rebooting Obsidian, so avoid calling this too often so you don't slow your tests down.\n * You can also set the vault in the `wdio.conf.ts` capabilities section which may be useful if all\n * your tests use the same vault.\n * \n * @param vault path to the vault to open. If omitted it will re-open the current vault.\n * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list.\n * Note, all the plugins must be defined in your wdio.conf.ts capabilities. You can use openVault to\n * toggle which plugins are enabled and which are disabled.\n * @param theme Name of the theme to enable. If omitted it will keep the current theme. Pass \"default\" to\n * switch back to the default theme. Like with plugins, the theme must be defined in wdio.conf.ts.\n * @returns Returns the new sessionId (same as reloadSession()).\n */\n openVault(params?: {\n vault?: string,\n plugins?: string[], theme?: string,\n }): Promise<string>;\n }\n }\n}\n","import { OBSIDIAN_CAPABILITY_KEY } from \"./types.js\";\nimport type * as obsidian from \"obsidian\"\n\n\ntype ExecuteObsidianArg = {\n /**\n * There is a global \"app\" instance, but that may be removed in the future so you can use this to access it from\n * tests. See https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines#Avoid+using+global+app+instance\n */\n app: obsidian.App,\n\n /**\n * The full obsidian API. See https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts\n */\n obsidian: typeof obsidian,\n}\n\nconst browserCommands = {\n /** Returns the Obsidian version this test is running under. */\n async getObsidianVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].appVersion;\n },\n\n /** Returns the Obsidian installer version this test is running under. */\n async getObsidianInstallerVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].installerVersion;\n },\n\n /**\n * Wrapper around browser.execute that passes the Obsidian API to the function. The function will be run inside\n * Obsidian. The first argument to the function is an object containing keys:\n * - app: Obsidian app instance\n * - obsidian: Full Obsidian API\n * See also: https://webdriver.io/docs/api/browser/execute\n * \n * Example usage\n * ```ts\n * const file = browser.executeObsidian(({app, obsidian}, path) => {\n * return app.vault.getMarkdownFiles().find(f => f.path == path)\n * })\n * ```\n */\n async executeObsidian<Return, Params extends unknown[]>(\n func: (obs: ExecuteObsidianArg, ...params: Params) => Return,\n ...params: Params\n ): Promise<Return> {\n return await browser.execute<Return, Params>(\n `return (${func.toString()}).call(null, {...window.wdioObsidianService}, ...arguments )`,\n ...params,\n )\n },\n\n /** Returns the path to the vault opened in Obsidian */\n async getVaultPath(this: WebdriverIO.Browser): Promise<string|undefined> {\n if (this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault == undefined) {\n return undefined; // no vault open\n } else { // return the actual path to the vault\n return await this.executeObsidian(({app, obsidian}) => {\n if (app.vault.adapter instanceof obsidian.FileSystemAdapter) {\n return app.vault.adapter.getBasePath()\n } else { // TODO handle CapacitorAdapater\n throw new Error(`Unrecognized DataAdapater type`)\n };\n })\n }\n },\n\n /** Enables a plugin */\n async enablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.enablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /** Disables a plugin */\n async disablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.disablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /**\n * Executes an Obsidian command.\n * @param id Id of the command to run.\n */\n async executeObsidianCommand(this: WebdriverIO.Browser, id: string) {\n const result = await this.executeObsidian(({app}, id) => (app as any).commands.executeCommandById(id), id);\n if (!result) {\n throw Error(`Obsidian command ${id} not found or failed.`);\n }\n },\n} as const\n\nexport type ObsidianBrowserCommands = typeof browserCommands;\nexport default browserCommands;\n"],"mappings":";AAAA,OAAOA,uBAAsB;;;ACA7B,OAAO,aAAa;AACpB,OAAO,UAAU;AACjB,SAAS,0BAA0B;AAEnC,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,OAAO,sBAAuE;;;ACHvE,IAAM,0BAA0B;;;ACcvC,IAAM,kBAAkB;AAAA;AAAA,EAEpB,MAAM,qBAA+D;AACjE,WAAO,KAAK,sBAAsB,uBAAuB,EAAE;AAAA,EAC/D;AAAA;AAAA,EAGA,MAAM,8BAAwE;AAC1E,WAAO,KAAK,sBAAsB,uBAAuB,EAAE;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,gBACF,SACG,QACY;AACf,WAAO,MAAM,QAAQ;AAAA,MACjB,WAAW,KAAK,SAAS,CAAC;AAAA,MAC1B,GAAG;AAAA,IACP;AAAA,EACJ;AAAA;AAAA,EAGA,MAAM,eAAmE;AACrE,QAAI,KAAK,sBAAsB,uBAAuB,EAAE,SAAS,QAAW;AACxE,aAAO;AAAA,IACX,OAAO;AACH,aAAO,MAAM,KAAK,gBAAgB,CAAC,EAAC,KAAK,SAAQ,MAAM;AACnD,YAAI,IAAI,MAAM,mBAAmB,SAAS,mBAAmB;AACzD,iBAAO,IAAI,MAAM,QAAQ,YAAY;AAAA,QACzC,OAAO;AACH,gBAAM,IAAI,MAAM,gCAAgC;AAAA,QACpD;AAAC;AAAA,MACL,CAAC;AAAA,IACL;AAAA,EACJ;AAAA;AAAA,EAGA,MAAM,aAAwC,UAAiC;AAC3E,UAAM,KAAK;AAAA,MACP,OAAO,EAAC,IAAG,GAAGC,cAAa,MAAO,IA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AAM,YAAY,MAAM,KAAK,cAAc;AAAA,QACvC,CAAC,uBAAuB,GAAG;AAAA,QAC3B,sBAAsB;AAAA,UAClB,GAAG,KAAK,sBAAsB,oBAAoB;AAAA,UAClD,MAAM;AAAA,QACV;AAAA,MACJ,CAAC;AACD,YAAM,QAAQ,aAAa,IAAI;AAE/B,aAAO;AAAA,IACX;AACA,UAAMA,SAAQ,WAAW,aAAa,SAAS;AAE/C,eAAW,CAAC,MAAM,GAAG,KAAK,OAAO,QAAQ,uBAAe,GAAG;AACvD,YAAMA,SAAQ,WAAW,MAAM,GAAG;AAAA,IACtC;AAEA,UAAM,QAAQ,aAAaA,QAAO;AAAA,EACtC;AAAA,EAEA,MAAM,eAAe;AACjB,eAAW,UAAU,KAAK,SAAS;AAC/B,YAAM,QAAQ,GAAG,QAAQ,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAAA,IAC7D;AAAA,EACJ;AACJ;;;AD/QA,IAAO,gBAAQ;AACR,IAAM,WAAW;AAYxB,eAAsB,sBAAsB,UAAmB;AAC3D,QAAMC,YAAW,IAAIC,kBAAiB,EAAC,SAAkB,CAAC;AAC1D,SAAO,MAAMD,UAAS,YAAY,aAAa;AACnD;","names":["ObsidianLauncher","pluginId","id","browser","launcher","ObsidianLauncher"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/service.ts","../src/types.ts","../src/browserCommands.ts","../src/utils.ts"],"sourcesContent":["import ObsidianLauncher from \"obsidian-launcher\"\nimport { ObsidianLauncherService, ObsidianWorkerService } from \"./service.js\";\n\nexport default ObsidianWorkerService;\nexport const launcher = ObsidianLauncherService;\n\nexport type { ObsidianServiceOptions, ObsidianCapabilityOptions } from \"./types.js\";\n\nexport type {\n LocalPluginEntry, GitHubPluginEntry, CommunityPluginEntry, PluginEntry,\n LocalThemeEntry, GitHubThemeEntry, CommunityThemeEntry, ThemeEntry,\n} from \"obsidian-launcher\"\n\n/**\n * Returns true if there's currently an Obsidian beta and we have the credentials to download it or it's already in the\n * cache.\n */\nexport async function obsidianBetaAvailable(cacheDir?: string) {\n const launcher = new ObsidianLauncher({cacheDir: cacheDir});\n const versionInfo = await launcher.getVersionInfo(\"latest-beta\");\n return versionInfo.isBeta && await launcher.isAvailable(versionInfo.version);\n}\n","import fsAsync from \"fs/promises\"\nimport path from \"path\"\nimport { SevereServiceError } from 'webdriverio'\nimport type { Capabilities, Options, Services } from '@wdio/types'\nimport logger from '@wdio/logger'\nimport { fileURLToPath } from \"url\"\nimport ObsidianLauncher, { DownloadedPluginEntry, DownloadedThemeEntry } from \"obsidian-launcher\"\nimport browserCommands from \"./browserCommands.js\"\nimport { ObsidianCapabilityOptions, ObsidianServiceOptions, OBSIDIAN_CAPABILITY_KEY } from \"./types.js\"\nimport { sleep } from \"./utils.js\"\nimport _ from \"lodash\"\n\n\nconst log = logger(\"wdio-obsidian-service\");\n\nfunction getDefaultCacheDir() {\n return path.resolve(process.env.WEBDRIVER_CACHE_DIR ?? \"./.obsidian-cache\")\n}\n\nexport class ObsidianLauncherService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n private readonly helperPluginPath: string\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.helperPluginPath = path.resolve(path.join(fileURLToPath(import.meta.url), '../../helper-plugin'));\n }\n\n async onPrepare(config: Options.Testrunner, capabilities: Capabilities.TestrunnerCapabilities) {\n if (!Array.isArray(capabilities)) {\n capabilities = Object.values(capabilities as Capabilities.RequestedMultiremoteCapabilities).map(\n (multiremoteOption) => (multiremoteOption as Capabilities.WithRequestedCapabilities).capabilities,\n );\n }\n\n const obsidianCapabilities = capabilities.flatMap((cap) => {\n if ((\"browserName\" in cap) && cap.browserName === \"obsidian\") {\n return [cap as WebdriverIO.Capabilities];\n } else {\n return [];\n }\n });\n\n try {\n for (const cap of obsidianCapabilities) {\n const obsidianOptions = cap[OBSIDIAN_CAPABILITY_KEY] ?? {};\n \n const vault = obsidianOptions.vault != undefined ? path.resolve(obsidianOptions.vault) : undefined;\n \n const [appVersion, installerVersion] = await this.obsidianLauncher.resolveVersions(\n cap.browserVersion ?? \"latest\",\n obsidianOptions.installerVersion ?? \"earliest\",\n );\n const installerVersionInfo = await this.obsidianLauncher.getVersionInfo(installerVersion);\n\n let installerPath = obsidianOptions.binaryPath;\n if (!installerPath) {\n installerPath = await this.obsidianLauncher.downloadInstaller(installerVersion);\n }\n let appPath = obsidianOptions.appPath;\n if (!appPath) {\n appPath = await this.obsidianLauncher.downloadApp(appVersion);\n }\n let chromedriverPath = cap['wdio:chromedriverOptions']?.binary\n // wdio can download chromedriver for versions greater than 115 automatically\n if (!chromedriverPath && Number(installerVersionInfo.chromeVersion!.split(\".\")[0]) <= 115) {\n chromedriverPath = await this.obsidianLauncher.downloadChromedriver(installerVersion);\n }\n\n let plugins = obsidianOptions.plugins ?? [\".\"];\n plugins.push(this.helperPluginPath); // Always install the helper plugin\n plugins = await this.obsidianLauncher.downloadPlugins(plugins);\n\n const themes = await this.obsidianLauncher.downloadThemes(obsidianOptions.themes ?? []);\n\n const args = [\n // Workaround for SUID issue on AppImages. See https://github.com/electron/electron/issues/42510\n ...(process.platform == 'linux' ? [\"--no-sandbox\"] : []),\n ...(cap['goog:chromeOptions']?.args ?? [])\n ];\n\n cap.browserName = \"chrome\";\n cap.browserVersion = installerVersionInfo.chromeVersion;\n cap[OBSIDIAN_CAPABILITY_KEY] = {\n ...obsidianOptions,\n plugins: plugins,\n themes: themes,\n binaryPath: installerPath,\n appPath: appPath,\n vault: vault,\n appVersion: appVersion, // Resolve the versions\n installerVersion: installerVersion,\n };\n cap['goog:chromeOptions'] = {\n binary: installerPath,\n windowTypes: [\"app\", \"webview\"],\n ...cap['goog:chromeOptions'],\n args: args,\n }\n cap['wdio:chromedriverOptions'] = {\n // allowedIps is not included in the types, but gets passed as --allowed-ips to chromedriver.\n // It defaults to [\"0.0.0.0\"] which makes Windows Firewall complain, and we don't need remote\n // connections anyways.\n allowedIps: [],\n ...cap['wdio:chromedriverOptions'],\n binary: chromedriverPath,\n } as any\n cap[\"wdio:enforceWebDriverClassic\"] = true;\n }\n } catch (e: any) {\n // By default wdio just logs service errors, throwing this makes it bail if anything goes wrong.\n throw new SevereServiceError(`Failed to download and setup Obsidian. Caused by: ${e.stack}\\n`+\n ` ------The above causes:-----`);\n }\n }\n}\n\nexport class ObsidianWorkerService implements Services.ServiceInstance {\n private obsidianLauncher: ObsidianLauncher\n /** Directories to clean up after the tests */\n private tmpDirs: string[]\n\n constructor (\n public options: ObsidianServiceOptions,\n public capabilities: WebdriverIO.Capabilities,\n public config: Options.Testrunner\n ) {\n this.obsidianLauncher = new ObsidianLauncher({\n cacheDir: config.cacheDir ?? getDefaultCacheDir(),\n versionsUrl: options.versionsUrl,\n communityPluginsUrl: options.communityPluginsUrl, communityThemesUrl: options.communityThemesUrl,\n });\n this.tmpDirs = [];\n }\n\n private async setupObsidian(obsidianOptions: ObsidianCapabilityOptions) {\n let vault = obsidianOptions.vault;\n if (vault != undefined) {\n log.info(`Opening vault ${obsidianOptions.vault}`);\n vault = await this.obsidianLauncher.setupVault({\n vault,\n copy: true,\n plugins: obsidianOptions.plugins,\n themes: obsidianOptions.themes,\n });\n this.tmpDirs.push(vault);\n } else {\n log.info(`Opening Obsidian without a vault`)\n }\n\n const configDir = await this.obsidianLauncher.setupConfigDir({\n appVersion: obsidianOptions.appVersion!, installerVersion: obsidianOptions.installerVersion!,\n appPath: obsidianOptions.appPath!,\n vault: vault,\n });\n this.tmpDirs.push(configDir);\n\n return configDir;\n }\n\n private async waitForReady(browser: WebdriverIO.Browser) {\n if (browser.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault != undefined) {\n await browser.waitUntil( // wait until the helper plugin is loaded\n () => browser.execute(() => !!(window as any).wdioObsidianService),\n {timeout: 30 * 1000, interval: 100},\n );\n await browser.executeObsidian(async ({app}) => {\n await new Promise<void>((resolve) => app.workspace.onLayoutReady(resolve) );\n })\n }\n }\n\n async beforeSession(config: Options.Testrunner, capabilities: WebdriverIO.Capabilities) {\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const configDir = await this.setupObsidian(capabilities[OBSIDIAN_CAPABILITY_KEY]);\n\n capabilities['goog:chromeOptions']!.args = [\n `--user-data-dir=${configDir}`,\n ...(capabilities['goog:chromeOptions']!.args ?? [])\n ];\n }\n\n private selectPlugins(currentPlugins: DownloadedPluginEntry[], selection?: string[]) {\n if (selection !== undefined) {\n const unknownPlugins = _.difference(selection, currentPlugins.map(p => p.id));\n if (unknownPlugins.length > 0) {\n throw Error(`Unknown plugin ids: ${unknownPlugins.join(', ')}`)\n }\n return currentPlugins.map(p => ({\n ...p,\n enabled: selection.includes(p.id) || p.id == \"wdio-obsidian-service-plugin\",\n }));\n } else {\n return currentPlugins;\n }\n }\n\n private selectThemes(currentThemes: DownloadedThemeEntry[], selection?: string) {\n if (selection !== undefined) {\n if (selection != \"default\" && currentThemes.every((t: any) => t.name != selection)) {\n throw Error(`Unknown theme: ${selection}`);\n }\n return currentThemes.map((t: any) => ({...t, enabled: selection != 'default' && t.name === selection}));\n } else {\n return currentThemes;\n }\n }\n\n async before(capabilities: WebdriverIO.Capabilities, specs: never, browser: WebdriverIO.Browser) {\n // There's a slow event listener link on the browser \"command\" event when you reloadSession that causes some\n // warnings. This will silence them. TODO: Make issue or PR to wdio to fix this.\n browser.setMaxListeners(1000);\n\n if (!capabilities[OBSIDIAN_CAPABILITY_KEY]) return;\n\n const service = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const reloadObsidian: typeof browser['reloadObsidian'] = async function(\n this: WebdriverIO.Browser,\n {vault, plugins, theme} = {},\n ) {\n const oldObsidianOptions = this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY];\n let newCapabilities: WebdriverIO.Capabilities\n\n if (vault) {\n const newObsidianOptions = {\n ...oldObsidianOptions,\n vault: path.resolve(vault),\n plugins: service.selectPlugins(oldObsidianOptions.plugins, plugins),\n themes: service.selectThemes(oldObsidianOptions.themes, theme),\n }\n \n const configDir = await service.setupObsidian(newObsidianOptions);\n \n const newArgs = [\n `--user-data-dir=${configDir}`,\n ...this.requestedCapabilities['goog:chromeOptions'].args.filter((arg: string) => {\n const match = arg.match(/^--user-data-dir=(.*)$/);\n return !match || !service.tmpDirs.includes(match[1]);\n }),\n ]\n \n newCapabilities = {\n [OBSIDIAN_CAPABILITY_KEY]: newObsidianOptions,\n 'goog:chromeOptions': {\n ...this.requestedCapabilities['goog:chromeOptions'],\n args: newArgs,\n },\n };\n } else {\n // preserve vault and config dir\n newCapabilities = {};\n // Since we aren't recreating the vault, we'll need to reset plugins and themes here if specified.\n if (plugins) {\n const enabledPlugins = await browser.executeObsidian(({app}) =>\n [...(app as any).plugins.enabledPlugins].sort()\n )\n for (const pluginId of _.difference(enabledPlugins, plugins, ['wdio-obsidian-service-plugin'])) {\n await browser.disablePlugin(pluginId);\n }\n for (const pluginId of _.difference(plugins, enabledPlugins)) {\n await browser.enablePlugin(pluginId);\n }\n await browser.executeObsidian(async ({app}) => await (app as any).plugins.saveConfig())\n }\n if (theme) {\n await browser.setTheme(theme);\n await browser.executeObsidian(async ({app}) => await (app.vault as any).saveConfig())\n }\n // Obsidian debounces saves to the config dir, and so changes to plugin list, themes, and anything else\n // you set in your tests may not get saved to disk before the reboot. I haven't found a better way to\n // make sure everything's saved then just waiting a bit.\n await sleep(2000);\n }\n\n const sessionId = await browser.reloadSession({\n // if browserName is set, reloadSession tries to restart the driver entirely, so unset those\n ..._.omit(this.requestedCapabilities, ['browserName', 'browserVersion']),\n ...newCapabilities,\n });\n await service.waitForReady(this);\n return sessionId;\n }\n\n await browser.addCommand(\"reloadObsidian\", reloadObsidian);\n\n for (const [name, cmd] of Object.entries(browserCommands)) {\n await browser.addCommand(name, cmd);\n }\n\n await service.waitForReady(browser);\n }\n\n async afterSession() {\n for (const tmpDir of this.tmpDirs) {\n await fsAsync.rm(tmpDir, { recursive: true, force: true });\n }\n }\n}\n","import type { ObsidianBrowserCommands } from \"./browserCommands.js\";\nimport type { PluginEntry, ThemeEntry } from \"obsidian-launcher\";\n\nexport const OBSIDIAN_CAPABILITY_KEY = \"wdio:obsidianOptions\" as const;\n\nexport interface ObsidianServiceOptions {\n /**\n * Override the `obsidian-versions.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n versionsUrl?: string,\n /**\n * Override the `community-plugins.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityPluginsUrl?: string,\n /**\n * Override the `community-css-themes.json` used by the service. Can be a file URL.\n * This is only really useful for this package's own internal tests.\n */\n communityThemesUrl?: string,\n}\n\nexport interface ObsidianCapabilityOptions {\n /**\n * Version of Obsidian to run.\n * \n * Can be set to \"latest\", \"latest-beta\", or a specific version. Defaults to \"latest\". To download beta versions\n * you'll need to be an Obsidian insider and set the OBSIDIAN_USERNAME and OBSIDIAN_PASSWORD environment\n * variables.\n * \n * You can also use the wdio capability `browserVersion` field to set the Obsidian version.\n */\n appVersion?: string\n\n /**\n * Version of the Obsidian Installer to download.\n * \n * Note that Obsidian is distributed in two parts, the \"installer\", which is the executable containing Electron, and\n * the \"app\" which is a bundle of JavaScript containing the Obsidian code. Obsidian's self-update system only\n * updates the JavaScript bundle, and not the base installer/Electron version. This makes Obsidian's auto-update\n * fast as it only needs to download a few MiB of JS instead of all of Electron. But, it means different users with\n * the same Obsidian version may be running on different versions of Electron, which could cause subtle differences\n * in plugin behavior if you are using newer JavaScript features and the like in your plugin.\n * \n * If passed \"latest\", it will use the maximum installer version compatible with the selected Obsidian version. If\n * passed \"earliest\" it will use the oldest installer version compatible with the selected Obsidian version. The \n * default is \"earliest\".\n */\n installerVersion?: string,\n\n /**\n * List of plugins to install.\n * \n * Each entry is a path to the local plugin to install, e.g. [\".\"] or [\"dist\"] depending on your build setup. You\n * can also pass objects. If you pass an object it can contain one of either `path` (to install a local plugin),\n * `repo` (to install a plugin from github), or `id` (to install a community plugin). You can set `enabled: false`\n * to install the plugin but start it disabled. You can enable the plugin later using `reloadObsidian` or the\n * `enablePlugin` command.\n */\n plugins?: PluginEntry[],\n\n /**\n * List of themes to install.\n * \n * Each entry is a path to the local theme to install. You can also pass an object. If you pass an object it can\n * contain one of either `path` (to install a local theme), `repo` (to install a theme from github), or `name` (to\n * install a community theme). You can set `enabled: false` to install the theme, but start it disabled. You can\n * only have one enabled theme, so if you pass multiple you'll have to disable all but one.\n */\n themes?: ThemeEntry[],\n\n /**\n * The path to the vault to open.\n * \n * The vault will be copied, so any changes made in your tests won't affect the original. If omitted, no vault will\n * be opened and you'll need to call `browser.reloadObsidian` to open a vault during your tests.\n */\n vault?: string,\n\n /** Path to the Obsidian binary to use. If omitted it will download Obsidian automatically. */\n binaryPath?: string,\n\n /** Path to the app asar to load into obsidian. If omitted it will be downloaded automatically. */\n appPath?: string,\n}\n\n\ndeclare global {\n namespace WebdriverIO {\n interface Capabilities {\n [OBSIDIAN_CAPABILITY_KEY]?: ObsidianCapabilityOptions,\n }\n\n interface Browser extends ObsidianBrowserCommands {\n /**\n * Relaunch obsidian. Can be used to switch to a new vault, change the plugin list, or just to reboot\n * Obsidian.\n * \n * As this does a full reboot of Obsidian, avoid calling this too often so you don't slow your tests down.\n * You can also set the vault in the `wdio.conf.ts` capabilities section which may be useful if all\n * your tests use the same vault.\n * \n * @param vault Path to the vault to open. The vault will be copied, so any changes made in your tests won't\n * be persited to the original. If omitted, it will reboot Obsidian with the current vault, without\n * creating a new copy of the vault.\n * @param plugins List of plugin ids to enable. If omitted it will keep current plugin list. Note, all the\n * plugins must be defined in your wdio.conf.ts capabilities. You can also use the enablePlugin and \n * disablePlugin commands to change plugins without relaunching Obsidian.\n * @param theme Name of the theme to enable. If omitted it will keep the current theme. Pass \"default\" to\n * switch back to the default theme. Like with plugins, the theme must be defined in wdio.conf.ts.\n * @returns Returns the new sessionId (same as browser.reloadSession()).\n */\n reloadObsidian(params?: {\n vault?: string,\n plugins?: string[], theme?: string,\n }): Promise<string>;\n }\n }\n}\n","import { OBSIDIAN_CAPABILITY_KEY } from \"./types.js\";\nimport type * as obsidian from \"obsidian\"\n\n\ntype ExecuteObsidianArg = {\n /**\n * There is a global \"app\" instance, but that may be removed in the future so you can use this to access it from\n * tests. See https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines#Avoid+using+global+app+instance\n */\n app: obsidian.App,\n\n /**\n * The full obsidian API. See https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts\n */\n obsidian: typeof obsidian,\n}\n\nconst browserCommands = {\n /** Returns the Obsidian version this test is running under. */\n async getObsidianVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].appVersion;\n },\n\n /** Returns the Obsidian installer version this test is running under. */\n async getObsidianInstallerVersion(this: WebdriverIO.Browser): Promise<string> {\n return this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].installerVersion;\n },\n\n /**\n * Wrapper around browser.execute that passes the Obsidian API to the function. The function will be run inside\n * Obsidian. The first argument to the function is an object containing keys:\n * - app: Obsidian app instance\n * - obsidian: Full Obsidian API\n * See also: https://webdriver.io/docs/api/browser/execute\n * \n * Example usage\n * ```ts\n * const file = browser.executeObsidian(({app, obsidian}, path) => {\n * return app.vault.getMarkdownFiles().find(f => f.path == path)\n * })\n * ```\n */\n async executeObsidian<Return, Params extends unknown[]>(\n func: (obs: ExecuteObsidianArg, ...params: Params) => Return,\n ...params: Params\n ): Promise<Return> {\n return await browser.execute<Return, Params>(\n `return (${func.toString()}).call(null, {...window.wdioObsidianService}, ...arguments )`,\n ...params,\n )\n },\n\n /** Returns the path to the vault opened in Obsidian */\n async getVaultPath(this: WebdriverIO.Browser): Promise<string|undefined> {\n if (this.requestedCapabilities[OBSIDIAN_CAPABILITY_KEY].vault == undefined) {\n return undefined; // no vault open\n } else { // return the actual path to the vault\n return await this.executeObsidian(({app, obsidian}) => {\n if (app.vault.adapter instanceof obsidian.FileSystemAdapter) {\n return app.vault.adapter.getBasePath()\n } else { // TODO handle CapacitorAdapater\n throw new Error(`Unrecognized DataAdapater type`)\n };\n })\n }\n },\n\n /** Enables a plugin */\n async enablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.enablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /** Disables a plugin */\n async disablePlugin(this: WebdriverIO.Browser, pluginId: string): Promise<void> {\n await this.executeObsidian(\n async ({app}, pluginId) => await (app as any).plugins.disablePluginAndSave(pluginId),\n pluginId,\n );\n },\n\n /** Sets the theme. Pass \"default\" to reset to the Obsidian theme. */\n async setTheme(this: WebdriverIO.Browser, themeName: string): Promise<void> {\n themeName = themeName == 'default' ? '' : themeName;\n await this.executeObsidian(\n async ({app}, themeName) => await (app as any).customCss.setTheme(themeName),\n themeName,\n )\n },\n\n /**\n * Executes an Obsidian command.\n * @param id Id of the command to run.\n */\n async executeObsidianCommand(this: WebdriverIO.Browser, id: string) {\n const result = await this.executeObsidian(({app}, id) => (app as any).commands.executeCommandById(id), id);\n if (!result) {\n throw Error(`Obsidian command ${id} not found or failed.`);\n }\n },\n} as const\n\nexport type ObsidianBrowserCommands = typeof browserCommands;\nexport default browserCommands;\n","export async function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}"],"mappings":";AAAA,OAAOA,uBAAsB;;;ACA7B,OAAO,aAAa;AACpB,OAAO,UAAU;AACjB,SAAS,0BAA0B;AAEnC,OAAO,YAAY;AACnB,SAAS,qBAAqB;AAC9B,OAAO,sBAAuE;;;ACHvE,IAAM,0BAA0B;;;ACcvC,IAAM,kBAAkB;AAAA;AAAA,EAEpB,MAAM,qBAA+D;AACjE,WAAO,KAAK,sBAA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AAA,IAC7D;AAAA,EACJ;AACJ;;;AD/SA,IAAO,gBAAQ;AACR,IAAM,WAAW;AAaxB,eAAsB,sBAAsB,UAAmB;AAC3D,QAAMC,YAAW,IAAIC,kBAAiB,EAAC,SAAkB,CAAC;AAC1D,QAAM,cAAc,MAAMD,UAAS,eAAe,aAAa;AAC/D,SAAO,YAAY,UAAU,MAAMA,UAAS,YAAY,YAAY,OAAO;AAC/E;","names":["ObsidianLauncher","pluginId","themeName","id","browser","launcher","ObsidianLauncher"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdio-obsidian-service",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "TODO",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "lodash": "^4.17.21",
52
- "obsidian-launcher": "^0.1.7"
52
+ "obsidian-launcher": "^0.1.8"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@wdio/cli": "^9.5.0",