@shikijs/core 1.24.2 → 1.24.4

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.
Files changed (2) hide show
  1. package/dist/index.mjs +31 -50
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -50,11 +50,10 @@ function isSpecialTheme(theme) {
50
50
  return isNoneTheme(theme);
51
51
  }
52
52
  function addClassToHast(node, className) {
53
- var _a;
54
53
  if (!className)
55
54
  return node;
56
- node.properties || (node.properties = {});
57
- (_a = node.properties).class || (_a.class = []);
55
+ node.properties ||= {};
56
+ node.properties.class ||= [];
58
57
  if (typeof node.properties.class === "string")
59
58
  node.properties.class = node.properties.class.split(/\s+/g);
60
59
  if (!Array.isArray(node.properties.class))
@@ -181,12 +180,6 @@ class ShikiError extends Error {
181
180
  }
182
181
  }
183
182
 
184
- var __defProp$2 = Object.defineProperty;
185
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
186
- var __publicField$2 = (obj, key, value) => {
187
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
188
- return value;
189
- };
190
183
  const _grammarStateMap = /* @__PURE__ */ new WeakMap();
191
184
  function setLastGrammarStateToMap(keys, state) {
192
185
  _grammarStateMap.set(keys, state);
@@ -195,22 +188,11 @@ function getLastGrammarStateFromMap(keys) {
195
188
  return _grammarStateMap.get(keys);
196
189
  }
197
190
  class GrammarState {
198
- constructor(...args) {
199
- /**
200
- * Theme to Stack mapping
201
- */
202
- __publicField$2(this, "_stacks", {});
203
- __publicField$2(this, "lang");
204
- if (args.length === 2) {
205
- const [stacksMap, lang] = args;
206
- this.lang = lang;
207
- this._stacks = stacksMap;
208
- } else {
209
- const [stack, lang, theme] = args;
210
- this.lang = lang;
211
- this._stacks = { [theme]: stack };
212
- }
213
- }
191
+ /**
192
+ * Theme to Stack mapping
193
+ */
194
+ _stacks = {};
195
+ lang;
214
196
  get themes() {
215
197
  return Object.keys(this._stacks);
216
198
  }
@@ -229,6 +211,17 @@ class GrammarState {
229
211
  lang
230
212
  );
231
213
  }
214
+ constructor(...args) {
215
+ if (args.length === 2) {
216
+ const [stacksMap, lang] = args;
217
+ this.lang = lang;
218
+ this._stacks = stacksMap;
219
+ } else {
220
+ const [stack, lang, theme] = args;
221
+ this.lang = lang;
222
+ this._stacks = { [theme]: stack };
223
+ }
224
+ }
232
225
  /**
233
226
  * Get the internal stack object.
234
227
  * @internal
@@ -1409,9 +1402,9 @@ function normalizeTheme(rawTheme) {
1409
1402
  theme.settings = theme.tokenColors;
1410
1403
  delete theme.tokenColors;
1411
1404
  }
1412
- theme.type || (theme.type = "dark");
1405
+ theme.type ||= "dark";
1413
1406
  theme.colorReplacements = { ...theme.colorReplacements };
1414
- theme.settings || (theme.settings = []);
1407
+ theme.settings ||= [];
1415
1408
  let { bg, fg } = theme;
1416
1409
  if (!bg || !fg) {
1417
1410
  const globalSetting = theme.settings ? theme.settings.find((s) => !s.name && !s.scope) : void 0;
@@ -1504,12 +1497,6 @@ async function resolveThemes(themes) {
1504
1497
  return resolved.filter((i) => !!i);
1505
1498
  }
1506
1499
 
1507
- var __defProp$1 = Object.defineProperty;
1508
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1509
- var __publicField$1 = (obj, key, value) => {
1510
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1511
- return value;
1512
- };
1513
1500
  class Registry extends Registry$1 {
1514
1501
  constructor(_resolver, _themes, _langs, _alias = {}) {
1515
1502
  super(_resolver);
@@ -1517,16 +1504,16 @@ class Registry extends Registry$1 {
1517
1504
  this._themes = _themes;
1518
1505
  this._langs = _langs;
1519
1506
  this._alias = _alias;
1520
- __publicField$1(this, "_resolvedThemes", /* @__PURE__ */ new Map());
1521
- __publicField$1(this, "_resolvedGrammars", /* @__PURE__ */ new Map());
1522
- __publicField$1(this, "_langMap", /* @__PURE__ */ new Map());
1523
- __publicField$1(this, "_langGraph", /* @__PURE__ */ new Map());
1524
- __publicField$1(this, "_textmateThemeCache", /* @__PURE__ */ new WeakMap());
1525
- __publicField$1(this, "_loadedThemesCache", null);
1526
- __publicField$1(this, "_loadedLanguagesCache", null);
1527
1507
  this._themes.map((t) => this.loadTheme(t));
1528
1508
  this.loadLanguages(this._langs);
1529
1509
  }
1510
+ _resolvedThemes = /* @__PURE__ */ new Map();
1511
+ _resolvedGrammars = /* @__PURE__ */ new Map();
1512
+ _langMap = /* @__PURE__ */ new Map();
1513
+ _langGraph = /* @__PURE__ */ new Map();
1514
+ _textmateThemeCache = /* @__PURE__ */ new WeakMap();
1515
+ _loadedThemesCache = null;
1516
+ _loadedLanguagesCache = null;
1530
1517
  getTheme(theme) {
1531
1518
  if (typeof theme === "string")
1532
1519
  return this._resolvedThemes.get(theme);
@@ -1642,18 +1629,12 @@ class Registry extends Registry$1 {
1642
1629
  }
1643
1630
  }
1644
1631
 
1645
- var __defProp = Object.defineProperty;
1646
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1647
- var __publicField = (obj, key, value) => {
1648
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1649
- return value;
1650
- };
1651
1632
  class Resolver {
1633
+ _langs = /* @__PURE__ */ new Map();
1634
+ _scopeToLang = /* @__PURE__ */ new Map();
1635
+ _injections = /* @__PURE__ */ new Map();
1636
+ _onigLib;
1652
1637
  constructor(engine, langs) {
1653
- __publicField(this, "_langs", /* @__PURE__ */ new Map());
1654
- __publicField(this, "_scopeToLang", /* @__PURE__ */ new Map());
1655
- __publicField(this, "_injections", /* @__PURE__ */ new Map());
1656
- __publicField(this, "_onigLib");
1657
1638
  this._onigLib = {
1658
1639
  createOnigScanner: (patterns) => engine.createScanner(patterns),
1659
1640
  createOnigString: (s) => engine.createString(s)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/core",
3
3
  "type": "module",
4
- "version": "1.24.2",
4
+ "version": "1.24.4",
5
5
  "description": "Core of Shiki",
6
6
  "author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -60,12 +60,12 @@
60
60
  "dist"
61
61
  ],
62
62
  "dependencies": {
63
- "@shikijs/vscode-textmate": "^9.3.0",
63
+ "@shikijs/vscode-textmate": "^9.3.1",
64
64
  "@types/hast": "^3.0.4",
65
- "hast-util-to-html": "^9.0.3",
66
- "@shikijs/engine-javascript": "1.24.2",
67
- "@shikijs/types": "1.24.2",
68
- "@shikijs/engine-oniguruma": "1.24.2"
65
+ "hast-util-to-html": "^9.0.4",
66
+ "@shikijs/engine-javascript": "1.24.4",
67
+ "@shikijs/engine-oniguruma": "1.24.4",
68
+ "@shikijs/types": "1.24.4"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "unbuild",