@salesforcedevs/dx-components 1.20.7 → 1.20.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.8",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"node": "20.19.0",
|
|
48
48
|
"yarn": "1.22.19"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "1484bf6ed3cddd470239e60eabef43f53a798774"
|
|
51
51
|
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import type { BundledLanguage, BundledTheme } from "shiki";
|
|
4
|
-
import { transformerColorizedBrackets } from "@shikijs/colorized-brackets";
|
|
1
|
+
import type { BundledLanguage, BundledTheme, HighlighterCore } from "shiki";
|
|
5
2
|
import { getCustomLanguageGrammars } from "dxUtils/shikiGrammars";
|
|
6
3
|
|
|
4
|
+
let shikiModulePromise: Promise<typeof import("shiki")> | null = null;
|
|
5
|
+
let bracketsModulePromise: Promise<
|
|
6
|
+
typeof import("@shikijs/colorized-brackets")
|
|
7
|
+
> | null = null;
|
|
8
|
+
|
|
9
|
+
async function getShiki() {
|
|
10
|
+
return (shikiModulePromise ??= import("shiki"));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function getBrackets() {
|
|
14
|
+
return (bracketsModulePromise ??= import("@shikijs/colorized-brackets"));
|
|
15
|
+
}
|
|
16
|
+
|
|
7
17
|
interface ShikiSingleton {
|
|
8
|
-
highlighter:
|
|
18
|
+
highlighter: HighlighterCore | null;
|
|
9
19
|
initialized: boolean;
|
|
10
|
-
initPromise: Promise<
|
|
20
|
+
initPromise: Promise<HighlighterCore> | null;
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
const shikiInstance: ShikiSingleton = {
|
|
@@ -50,8 +60,8 @@ const LANGUAGE_MAP: Record<string, BundledLanguage> = {
|
|
|
50
60
|
sh: "bash"
|
|
51
61
|
};
|
|
52
62
|
|
|
53
|
-
// Core languages
|
|
54
|
-
const CORE_LANGUAGES = [
|
|
63
|
+
// Core languages loaded eagerly (keep minimal; load others on demand)
|
|
64
|
+
const CORE_LANGUAGES: BundledLanguage[] = [
|
|
55
65
|
"apex",
|
|
56
66
|
"javascript",
|
|
57
67
|
"html",
|
|
@@ -91,8 +101,8 @@ const OPTIONAL_LANGUAGES: Record<string, any> = {
|
|
|
91
101
|
agentscript: getCustomLanguageGrammars().agentscript
|
|
92
102
|
};
|
|
93
103
|
|
|
94
|
-
// Initialize Shiki highlighter
|
|
95
|
-
async function initializeShiki(): Promise<
|
|
104
|
+
// Initialize Shiki highlighter (lazy-load module and keep initial set minimal)
|
|
105
|
+
async function initializeShiki(): Promise<HighlighterCore> {
|
|
96
106
|
if (shikiInstance.highlighter) {
|
|
97
107
|
return shikiInstance.highlighter;
|
|
98
108
|
}
|
|
@@ -101,6 +111,7 @@ async function initializeShiki(): Promise<shiki.HighlighterCore> {
|
|
|
101
111
|
return shikiInstance.initPromise;
|
|
102
112
|
}
|
|
103
113
|
|
|
114
|
+
const shiki = await getShiki();
|
|
104
115
|
shikiInstance.initPromise = shiki.createHighlighter({
|
|
105
116
|
themes: ["light-plus", "material-theme-darker"],
|
|
106
117
|
langs: CORE_LANGUAGES
|
|
@@ -119,7 +130,7 @@ async function initializeShiki(): Promise<shiki.HighlighterCore> {
|
|
|
119
130
|
|
|
120
131
|
// Async function to load additional languages when needed
|
|
121
132
|
async function loadLanguageIfNeeded(
|
|
122
|
-
highlighter:
|
|
133
|
+
highlighter: HighlighterCore,
|
|
123
134
|
language: string
|
|
124
135
|
): Promise<void> {
|
|
125
136
|
const loadedLanguages = highlighter.getLoadedLanguages();
|
|
@@ -167,6 +178,8 @@ export async function highlightCode(
|
|
|
167
178
|
mappedLanguage = "text" as BundledLanguage;
|
|
168
179
|
}
|
|
169
180
|
|
|
181
|
+
const { transformerColorizedBrackets } = await getBrackets();
|
|
182
|
+
|
|
170
183
|
return highlighter.codeToHtml(code, {
|
|
171
184
|
lang: mappedLanguage,
|
|
172
185
|
theme: THEME_MAP[theme],
|