Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@expressive-code/plugin-shiki

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressive-code/plugin-shiki - npm Package Compare versions

Comparing version 0.30.0 to 0.30.1

32

dist/index.js

@@ -8,2 +8,3 @@ // src/index.ts

var highlighterPromiseByConfig = /* @__PURE__ */ new Map();
var promisesByHighlighter = /* @__PURE__ */ new WeakMap();
var themeCacheKeys = /* @__PURE__ */ new WeakMap();

@@ -17,14 +18,16 @@ async function getCachedHighlighter(config = {}) {

});
highlighterPromiseByConfig.set(configCacheKey, highlighterPromise);
}
return await highlighterPromise;
return highlighterPromise;
}
async function ensureThemeIsLoaded(highlighter, theme) {
let cacheKey = themeCacheKeys.get(theme);
if (!cacheKey) {
cacheKey = `${theme.name}-${getStableObjectHash({ bg: theme.bg, fg: theme.fg, settings: theme.settings })}`;
const existingCacheKey = themeCacheKeys.get(theme);
const cacheKey = existingCacheKey ?? `${theme.name}-${getStableObjectHash({ bg: theme.bg, fg: theme.fg, settings: theme.settings })}`;
if (!existingCacheKey)
themeCacheKeys.set(theme, cacheKey);
}
if (!highlighter.getLoadedThemes().includes(cacheKey)) {
const themeUsingCacheKey = { ...theme, name: cacheKey, settings: theme.settings };
await highlighter.loadTheme(themeUsingCacheKey);
await memoizeHighlighterTask(highlighter, `loadTheme:${cacheKey}`, () => {
const themeUsingCacheKey = { ...theme, name: cacheKey, settings: theme.settings };
return highlighter.loadTheme(themeUsingCacheKey);
});
}

@@ -39,6 +42,19 @@ return cacheKey;

}
await highlighter.loadLanguage(language);
await memoizeHighlighterTask(highlighter, `loadLanguage:${language}`, () => highlighter.loadLanguage(language));
}
return language;
}
function memoizeHighlighterTask(highlighter, taskId, taskFn) {
let promises = promisesByHighlighter.get(highlighter);
if (!promises) {
promises = /* @__PURE__ */ new Map();
promisesByHighlighter.set(highlighter, promises);
}
let promise = promises.get(taskId);
if (promise === void 0) {
promise = taskFn();
promises.set(taskId, promise);
}
return promise;
}

@@ -45,0 +61,0 @@ // src/index.ts

{
"name": "@expressive-code/plugin-shiki",
"version": "0.30.0",
"version": "0.30.1",
"description": "Shiki syntax highlighting plugin for Expressive Code, a text marking & annotation engine for presenting source code on the web.",

@@ -26,3 +26,3 @@ "keywords": [],

"dependencies": {
"@expressive-code/core": "^0.30.0",
"@expressive-code/core": "^0.30.1",
"shikiji": "^0.8.0"

@@ -29,0 +29,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc