@salesforcedevs/dx-components 1.18.6 → 1.18.8-layoutfix-alpha

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.
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <!-- This is a utility module for Shiki syntax highlighting -->
3
+ </template>
@@ -0,0 +1,210 @@
1
+ import { createHighlighterCore, HighlighterCore } from "shiki/core";
2
+ import type { BundledLanguage, BundledTheme } from "shiki";
3
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma";
4
+ import { transformerColorizedBrackets } from "@shikijs/colorized-brackets";
5
+ interface ShikiSingleton {
6
+ highlighter: HighlighterCore | null;
7
+ initialized: boolean;
8
+ initPromise: Promise<HighlighterCore> | null;
9
+ }
10
+
11
+ const shikiInstance: ShikiSingleton = {
12
+ highlighter: null,
13
+ initialized: false,
14
+ initPromise: null
15
+ };
16
+
17
+ // Theme mapping for light/dark modes
18
+ const THEME_MAP: Record<string, BundledTheme> = {
19
+ light: "light-plus",
20
+ dark: "material-theme-darker"
21
+ };
22
+
23
+ const THEME_MAP_COLOR_REPLACEMENTS: Record<
24
+ string,
25
+ { colorReplacements: Record<string, string> }
26
+ > = {
27
+ light: {
28
+ colorReplacements: {}
29
+ },
30
+ dark: {
31
+ colorReplacements: {
32
+ "#545454": "#8A8A8A" // Replace comment color for WCAG 2.1 compliance
33
+ }
34
+ }
35
+ };
36
+
37
+ // Language mapping for custom languages to supported ones
38
+ const LANGUAGE_MAP: Record<string, BundledLanguage> = {
39
+ ssjs: "javascript", // Server-Side JavaScript
40
+ gtl: "handlebars", // Guide Template Language similar to Handlebars
41
+ lwc: "jsx",
42
+ sql_docs_template: "sql", // Custom SQL variant
43
+ visualforce: "html", // Visualforce uses HTML-like syntax
44
+ js: "javascript",
45
+ ts: "typescript",
46
+ yml: "yaml",
47
+ md: "markdown",
48
+ sh: "bash"
49
+ };
50
+
51
+ // Core languages that should be loaded immediately for best performance
52
+ const CORE_LANGUAGES = [
53
+ // @ts-ignore
54
+ () => import("@shikijs/langs/apex"),
55
+ // @ts-ignore
56
+ () => import("@shikijs/langs/javascript"),
57
+ // @ts-ignore
58
+ () => import("@shikijs/langs/html"),
59
+ // @ts-ignore
60
+ () => import("@shikijs/langs/css"),
61
+ // @ts-ignore
62
+ () => import("@shikijs/langs/json"),
63
+ // @ts-ignore
64
+ () => import("@shikijs/langs/sql"),
65
+ // @ts-ignore
66
+ () => import("@shikijs/langs/bash"),
67
+ // @ts-ignore
68
+ () => import("@shikijs/langs/xml"),
69
+ // @ts-ignore
70
+ () => import("@shikijs/langs/graphql"),
71
+ // @ts-ignore
72
+ () => import("@shikijs/langs/jsx"),
73
+ // @ts-ignore
74
+ () => import("./customLanguages/ampscript.tmLanguage.json")
75
+ ];
76
+
77
+ // Non-critical languages that can be loaded asynchronously when needed
78
+ const OPTIONAL_LANGUAGES: Record<string, () => Promise<any>> = {
79
+ // @ts-ignore
80
+ typescript: () => import("@shikijs/langs/typescript"),
81
+ // @ts-ignore
82
+ markdown: () => import("@shikijs/langs/markdown"),
83
+ // @ts-ignore
84
+ python: () => import("@shikijs/langs/python"),
85
+ // @ts-ignore
86
+ java: () => import("@shikijs/langs/java"),
87
+ // @ts-ignore
88
+ yaml: () => import("@shikijs/langs/yaml"),
89
+ // @ts-ignore
90
+ php: () => import("@shikijs/langs/php"),
91
+ // @ts-ignore
92
+ swift: () => import("@shikijs/langs/swift"),
93
+ // @ts-ignore
94
+ kotlin: () => import("@shikijs/langs/kotlin"),
95
+ // @ts-ignore
96
+ handlebars: () => import("@shikijs/langs/handlebars"),
97
+ // @ts-ignore
98
+ dataweave: () => import("./customLanguages/dataweave.tmLanguage.json"),
99
+ // @ts-ignore
100
+ afscript: () => import("./customLanguages/afscript.tmLanguage.json")
101
+ };
102
+
103
+ // Initialize Shiki highlighter with fine-grained modules for better performance
104
+ async function initializeShiki(): Promise<HighlighterCore> {
105
+ if (shikiInstance.highlighter) {
106
+ return shikiInstance.highlighter;
107
+ }
108
+
109
+ if (shikiInstance.initPromise) {
110
+ return shikiInstance.initPromise;
111
+ }
112
+
113
+ shikiInstance.initPromise = createHighlighterCore({
114
+ themes: [
115
+ // @ts-ignore
116
+ import("@shikijs/themes/light-plus"),
117
+ // @ts-ignore
118
+ import("@shikijs/themes/material-theme-darker")
119
+ ],
120
+ langs: CORE_LANGUAGES,
121
+ engine: createOnigurumaEngine(import("shiki/wasm"))
122
+ });
123
+
124
+ try {
125
+ shikiInstance.highlighter = await shikiInstance.initPromise;
126
+ shikiInstance.initialized = true;
127
+ return shikiInstance.highlighter;
128
+ } catch (error) {
129
+ console.error("Failed to initialize Shiki:", error);
130
+ shikiInstance.initPromise = null;
131
+ throw error;
132
+ }
133
+ }
134
+
135
+ // Async function to load additional languages when needed
136
+ async function loadLanguageIfNeeded(
137
+ highlighter: HighlighterCore,
138
+ language: string
139
+ ): Promise<void> {
140
+ const loadedLanguages = highlighter.getLoadedLanguages();
141
+
142
+ if (!loadedLanguages.includes(language as BundledLanguage)) {
143
+ // Check if it's an optional language that needs to be loaded
144
+ const languageLoader = OPTIONAL_LANGUAGES[language];
145
+
146
+ if (languageLoader) {
147
+ try {
148
+ const languageModule = await languageLoader();
149
+ await highlighter.loadLanguage(
150
+ languageModule.default || languageModule
151
+ );
152
+ } catch (error) {
153
+ console.warn(
154
+ `Failed to load optional language ${language}:`,
155
+ error
156
+ );
157
+ }
158
+ }
159
+ }
160
+ }
161
+
162
+ // Get the mapped language or fallback to the original
163
+ function getMappedLanguage(language: string): BundledLanguage {
164
+ const mapped =
165
+ LANGUAGE_MAP[language.toLowerCase()] || language.toLowerCase();
166
+ return mapped as BundledLanguage;
167
+ }
168
+
169
+ // Highlight code with Shiki
170
+ export async function highlightCode(
171
+ code: string,
172
+ language: string,
173
+ theme: "light" | "dark" = "light"
174
+ ): Promise<string> {
175
+ try {
176
+ const highlighter = await initializeShiki();
177
+ let mappedLanguage = getMappedLanguage(language);
178
+
179
+ // Try to load the language asynchronously if it's not already loaded
180
+ await loadLanguageIfNeeded(highlighter, mappedLanguage);
181
+
182
+ // Check if the language is supported after potential async loading
183
+ const loadedLanguages = highlighter.getLoadedLanguages();
184
+ if (!loadedLanguages.includes(mappedLanguage)) {
185
+ mappedLanguage = "text" as BundledLanguage;
186
+ }
187
+
188
+ return highlighter.codeToHtml(code, {
189
+ lang: mappedLanguage,
190
+ theme: THEME_MAP[theme],
191
+ transformers: [transformerColorizedBrackets()],
192
+ colorReplacements:
193
+ THEME_MAP_COLOR_REPLACEMENTS[theme].colorReplacements
194
+ });
195
+ } catch (error) {
196
+ console.error("Failed to highlight code with Shiki:", error);
197
+ // Fallback to plain text on error
198
+ return `<pre class="shiki ${theme}"><code>${escapeHtml(
199
+ code
200
+ )}</code></pre>`;
201
+ }
202
+ }
203
+
204
+ // Utility function to escape HTML
205
+ function escapeHtml(text: string): string {
206
+ const div = document.createElement("div");
207
+ div.textContent = text;
208
+ // eslint-disable-next-line @lwc/lwc/no-inner-html
209
+ return div.innerHTML;
210
+ }
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,48 +0,0 @@
1
- export const ampscript = {
2
- pattern: /%%=\s*([\s\S]*?)\s*=%%|%%\[([\s\S]*?)\]%%/,
3
- greedy: true,
4
- inside: {
5
- delimiter: {
6
- pattern: /%%=|=%%|%%\[|\]%%/,
7
- alias: "operator"
8
- },
9
- comment: {
10
- pattern: /(\/\/.*|\/\*[\s\S]*?\*\/)/,
11
- greedy: true
12
- },
13
- string: {
14
- pattern: /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
15
- greedy: true,
16
- inside: {
17
- escape: /\\./
18
- }
19
- },
20
- function: {
21
- pattern: /\b\w+\b(?=\()/i,
22
- greedy: true
23
- },
24
- boolean: /\b(true|false|null)\b/i,
25
- number: /\b(0(x|X)[0-9a-fA-F]+|([0-9]+(\.[0-9]+)?))\b/,
26
- keyword:
27
- /\b(do|else|elseif|for|if(?:\s+not)?|endif|next|then|to|downto|var|set)\b/i,
28
- operator: /==|!=|>|<|>=|<=|=/,
29
- variable: {
30
- pattern: /@\w+|\[\w+\]/,
31
- greedy: true
32
- },
33
- constant:
34
- /\b(xtmonth|xtmonthnumeric|xtday|xtdayofweek|xtyear|xtshortdate|xtlongdate)\b/i,
35
- logical: /\b(and|or|not)\b/i
36
- }
37
- };
38
-
39
- export const sqlDocsTemplate = {
40
- comment: /--.*/,
41
- variable: [
42
- /<[^>\s]+>/,
43
- { pattern: /(\s|\[|\[, ])\.\.\.(?=\]|\))/, lookbehind: true }
44
- ],
45
- keyword: /\b[A-Z_]+\b/,
46
- string: /'[^']*'/,
47
- punctuation: /[;[\]{}]/
48
- };
@@ -1,177 +0,0 @@
1
- /*
2
- A11y syntax highlighting comes from this npm package (release 1.2.0):
3
- https://github.com/ericwbailey/a11y-syntax-highlighting/releases
4
- The colors used are from the files prism/a11y-light.css and prism/a11y-dark.css with
5
- some minor modifications to work with our existing classes.
6
- */
7
-
8
- .dx-theme-dark {
9
- --prism-a11y-border-radius: 0.3em;
10
- --prism-a11y-font-family: "consolas", "monaco", "Andale Mono", "Ubuntu Mono",
11
- monospace;
12
- --prism-a11y-line-height: 1.5;
13
- --prism-a11y-code-block-margin: 0.5em 0;
14
- --prism-a11y-code-block-padding: 1em;
15
- --prism-a11y-code-inline-padding: 0.1em;
16
- --prism-a11y-width-border: 1px;
17
- --prism-a11y-width-tab: 2;
18
- --prism-a11y-color-background: hsl(0deg 0% 17% / 100%);
19
- --prism-a11y-color-text-no-token: hsl(60deg 30% 96% / 100%);
20
- --prism-a11y-color-text-comment: hsl(54deg 32% 75% / 100%);
21
- --prism-a11y-color-text-blue: hsl(180deg 100% 44% / 100%);
22
- --prism-a11y-color-text-green: hsl(80deg 75% 55% / 100%);
23
- --prism-a11y-color-text-gray: hsl(60deg 30% 96% / 100%);
24
- --prism-a11y-color-text-purple: hsl(291deg 30% 83% / 100%);
25
- --prism-a11y-color-text-red: hsl(17deg 100% 74% / 100%);
26
- --prism-a11y-color-text-yellow: hsl(51deg 100% 50% / 100%);
27
- --prism-a11y-plugin-color-border: hsl(51deg 100% 50% / 55%);
28
- --prism-a11y-plugin-color-background: hsl(51deg 100% 50% / 10%);
29
- }
30
-
31
- .dx-theme-light {
32
- --prism-a11y-border-radius: 0.3em;
33
- --prism-a11y-font-family: "consolas", "monaco", "Andale Mono", "Ubuntu Mono",
34
- monospace;
35
- --prism-a11y-line-height: 1.5;
36
- --prism-a11y-code-block-margin: 0.5em 0;
37
- --prism-a11y-code-block-padding: 1em;
38
- --prism-a11y-code-inline-padding: 0.1em;
39
- --prism-a11y-width-border: 1px;
40
- --prism-a11y-width-tab: 2;
41
- --prism-a11y-color-background: hsl(0deg 0% 100% / 100%);
42
- --prism-a11y-color-text-no-token: hsl(0deg 0% 33% / 100%);
43
- --prism-a11y-color-text-comment: hsl(16deg 100% 25% / 100%);
44
- --prism-a11y-color-text-blue: hsl(195deg 100% 30% / 100%);
45
- --prism-a11y-color-text-green: hsl(120deg 100% 25% / 100%);
46
- --prism-a11y-color-text-gray: hsl(0deg 0% 41% / 100%);
47
- --prism-a11y-color-text-purple: hsl(282deg 100% 41% / 100%);
48
- --prism-a11y-color-text-red: hsl(2deg 80% 47% / 100%);
49
- --prism-a11y-color-text-yellow: hsl(43deg 74% 30% / 100%);
50
- --prism-a11y-plugin-color-border: hsl(43deg 74% 30% / 55%);
51
- --prism-a11y-plugin-color-background: hsl(43deg 74% 30% / 10%);
52
- }
53
-
54
- .dx-theme-dark pre[class*="language-"] {
55
- background: var(--prism-a11y-color-background);
56
- }
57
-
58
- .dx-theme-light pre[class*="language-"] {
59
- background: var(--prism-a11y-color-background);
60
- }
61
-
62
- :where(code[class*="language-"], pre[class*="language-"]) {
63
- color: var(--prism-a11y-color-text-no-token);
64
- background: var(--prism-a11y-color-background);
65
- font-family: var(--prism-a11y-font-family);
66
- text-align: start;
67
- white-space: pre;
68
- word-spacing: normal;
69
- word-break: normal;
70
- word-wrap: normal;
71
- line-height: var(--prism-a11y-line-height);
72
- tab-size: var(--prism-a11y-width-tab);
73
- hyphens: none;
74
- }
75
-
76
- /* Code blocks */
77
- pre[class*="language-"] {
78
- padding: var(--prism-a11y-code-block-padding);
79
- margin: var(--prism-a11y-code-block-margin);
80
- overflow: auto;
81
- border-radius: var(--prism-a11y-border-radius);
82
- }
83
-
84
- :where(:not(pre) > code[class*="language-"], pre[class*="language-"]) {
85
- background: var(--prism-a11y-color-background);
86
- }
87
-
88
- /* Inline code */
89
- :not(pre) > code[class*="language-"] {
90
- padding: var(--prism-a11y-code-inline-padding);
91
- border-radius: var(--prism-a11y-border-radius);
92
- white-space: normal;
93
- }
94
-
95
- :where(.token.comment, .token.prolog, .token.doctype, .token.cdata) {
96
- color: var(--prism-a11y-color-text-comment);
97
- }
98
-
99
- .token.punctuation {
100
- color: var(--prism-a11y-color-text-gray);
101
- }
102
-
103
- :where(
104
- .token.property,
105
- .token.tag,
106
- .token.constant,
107
- .token.symbol,
108
- .token.deleted
109
- ) {
110
- color: var(--prism-a11y-color-text-red);
111
- }
112
-
113
- :where(
114
- .token.operator,
115
- .token.entity,
116
- .token.url,
117
- .language-css .token.string,
118
- .style .token.string,
119
- .token.variable,
120
- .token.keyword
121
- ) {
122
- color: var(--prism-a11y-color-text-blue);
123
- }
124
-
125
- :where(
126
- .token.selector,
127
- .token.attr-name,
128
- .token.string,
129
- .token.char,
130
- .token.builtin,
131
- .token.inserted
132
- ) {
133
- color: var(--prism-a11y-color-text-green);
134
- }
135
-
136
- :where(
137
- .token.atrule,
138
- .token.attr-value,
139
- .token.function,
140
- .token.regex,
141
- .token.important
142
- ) {
143
- color: var(--prism-a11y-color-text-yellow);
144
- }
145
-
146
- :where(.token.boolean, .token.number, .token.keyword) {
147
- color: var(--prism-a11y-color-text-purple);
148
- }
149
-
150
- :where(.token.important, .token.bold) {
151
- font-weight: bold;
152
- }
153
-
154
- .token.italic {
155
- font-style: italic;
156
- }
157
-
158
- .token.entity {
159
- cursor: help;
160
- }
161
-
162
- .line-highlight {
163
- background: var(--prism-a11y-plugin-color-background);
164
- border-top: var(--prism-a11y-width-border) solid
165
- var(--prism-a11y-plugin-color-border);
166
- border-bottom: var(--prism-a11y-width-border) solid
167
- var(--prism-a11y-plugin-color-border);
168
- }
169
-
170
- .line-numbers .line-numbers-rows {
171
- border-right: var(--prism-a11y-width-border) solid
172
- var(--prism-a11y-color-text-no-token);
173
- }
174
-
175
- .line-numbers-rows > span::before {
176
- color: var(--prism-a11y-color-text-comment);
177
- }
@@ -1,3 +0,0 @@
1
- <template>
2
- <!-- TODO: We don't need this file and have to figure why it's required by the build process. 🤷🏼‍♂️ -->
3
- </template>