vscode-shiki-bridge 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,8 +48,6 @@ const html = highlighter.codeToHtml(
48
48
 
49
49
  A tuple containing a theme id, and an array containing the `ThemeRegistration`.
50
50
 
51
- If the theme cannot be found, [the special `"none"` theme](https://shiki.style/themes#special-themes) is returned.
52
-
53
51
  ```ts
54
52
  export type UserThemeResult = [id: string, themes: [ThemeRegistration]];
55
53
  ```
@@ -66,8 +64,6 @@ async function getUserTheme(): Promise<UserThemeResult>;
66
64
 
67
65
  Get a `UserThemeResult` for the given `themeName`. The `themeName` can be its `label` or `id`. VS Code themes will define at least on of these (usually the `label`), `vscode-shiki-bridge` will resolve it to the correct theme.
68
66
 
69
- If the theme cannot be found, [the special `"none"` theme](https://shiki.style/themes#special-themes) is returned.
70
-
71
67
  ```ts
72
68
  async function getTheme(themeName: string): Promise<UserThemeResult>;
73
69
  ```
package/dist/index.cjs CHANGED
@@ -294,10 +294,6 @@ async function getUserTheme() {
294
294
  const vscode = getVscode();
295
295
  const workbenchConfig = vscode.workspace.getConfiguration("workbench");
296
296
  const themeName = workbenchConfig.get("colorTheme");
297
- if (!themeName) {
298
- logger.debug("no theme name found under workbench.colorTheme");
299
- return THEME_NOT_FOUND_RESULT;
300
- }
301
297
  return await getTheme(themeName);
302
298
  }
303
299
  /**
@@ -313,13 +309,13 @@ async function getTheme(themeName) {
313
309
  const themeId = registry.resolveLabelToId(themeName);
314
310
  const contribution = registry.themes.get(themeId);
315
311
  if (!contribution) {
316
- logger.debug(`no theme contribution found for theme id ${themeId}`);
317
- return THEME_NOT_FOUND_RESULT;
312
+ const message = `no theme contribution found for theme id ${themeId}`;
313
+ logger.debug(message);
314
+ throw new Error(message);
318
315
  }
319
316
  const themeRegistration = await buildThemeRegistration(contribution, registry, fileReader, vscode.Uri);
320
317
  return [themeId, [themeRegistration]];
321
318
  }
322
- const THEME_NOT_FOUND_RESULT = ["none", ["none"]];
323
319
 
324
320
  //#endregion
325
321
  //#region src/language-registration-collection-builder.ts
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import "vscode";
2
- import { LanguageRegistration, SpecialTheme, ThemeRegistration } from "shiki";
2
+ import { LanguageRegistration, ThemeRegistration } from "shiki";
3
3
  import { ExtensionLanguage } from "vscode-extension-manifest";
4
4
 
5
5
  //#region src/user-theme.d.ts
6
- type UserThemeResult = [id: string, themes: [ThemeRegistration]] | [id: string, themes: [SpecialTheme]];
6
+ type UserThemeResult = [id: string, themes: [ThemeRegistration]];
7
7
  /**
8
8
  * Get the `ThemeRegistration` for the currently active theme.
9
9
  */
@@ -17,6 +17,7 @@ declare function getUserTheme(): Promise<UserThemeResult>;
17
17
  declare function getTheme(themeName: string): Promise<UserThemeResult>;
18
18
  //#endregion
19
19
  //#region src/language-registration-types.d.ts
20
+
20
21
  /**
21
22
  * To not lose the information about which files a language could apply, we keep the information language contributions provide
22
23
  */
package/dist/index.js CHANGED
@@ -1,11 +1,9 @@
1
+ import { createRequire } from "node:module";
1
2
  import { parse } from "fast-plist";
2
3
  import { parse as parse$1 } from "jsonc-parser";
3
4
 
4
5
  //#region rolldown:runtime
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
6
- if (typeof require !== "undefined") return require.apply(this, arguments);
7
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
8
- });
6
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
9
7
 
10
8
  //#endregion
11
9
  //#region src/vscode-utils.ts
@@ -278,10 +276,6 @@ async function getUserTheme() {
278
276
  const vscode = getVscode();
279
277
  const workbenchConfig = vscode.workspace.getConfiguration("workbench");
280
278
  const themeName = workbenchConfig.get("colorTheme");
281
- if (!themeName) {
282
- logger.debug("no theme name found under workbench.colorTheme");
283
- return THEME_NOT_FOUND_RESULT;
284
- }
285
279
  return await getTheme(themeName);
286
280
  }
287
281
  /**
@@ -297,13 +291,13 @@ async function getTheme(themeName) {
297
291
  const themeId = registry.resolveLabelToId(themeName);
298
292
  const contribution = registry.themes.get(themeId);
299
293
  if (!contribution) {
300
- logger.debug(`no theme contribution found for theme id ${themeId}`);
301
- return THEME_NOT_FOUND_RESULT;
294
+ const message = `no theme contribution found for theme id ${themeId}`;
295
+ logger.debug(message);
296
+ throw new Error(message);
302
297
  }
303
298
  const themeRegistration = await buildThemeRegistration(contribution, registry, fileReader, vscode.Uri);
304
299
  return [themeId, [themeRegistration]];
305
300
  }
306
- const THEME_NOT_FOUND_RESULT = ["none", ["none"]];
307
301
 
308
302
  //#endregion
309
303
  //#region src/language-registration-collection-builder.ts
package/dist/internals.js CHANGED
@@ -1,11 +1,9 @@
1
+ import { createRequire } from "node:module";
1
2
  import { parse } from "fast-plist";
2
3
  import { parse as parse$1 } from "jsonc-parser";
3
4
 
4
5
  //#region rolldown:runtime
5
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
6
- if (typeof require !== "undefined") return require.apply(this, arguments);
7
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
8
- });
6
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
9
7
 
10
8
  //#endregion
11
9
  //#region src/vscode-utils.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-shiki-bridge",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Embed Shiki code blocks in VS Code, inheriting the user's themes and languages",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -19,17 +19,18 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
- "main": "./dist/index.js",
22
+ "main": "./dist/index.cjs",
23
23
  "module": "./dist/index.js",
24
24
  "types": "./dist/index.d.ts",
25
25
  "exports": {
26
26
  ".": {
27
27
  "development": "./src/index.ts",
28
- "default": "./dist/index.js"
28
+ "require": "./dist/index.cjs",
29
+ "import": "./dist/index.js"
29
30
  },
30
31
  "./internals": {
31
32
  "development": "./src/internals.ts",
32
- "default": "./dist/internals.js"
33
+ "import": "./dist/internals.js"
33
34
  },
34
35
  "./package.json": "./package.json"
35
36
  },