@innovatorved/code-lab 0.3.0 → 0.3.2
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/ARCHITECTURE.md +4 -2
- package/CHANGELOG.md +38 -0
- package/README.md +15 -5
- package/dist/code-lab.css +52 -2
- package/dist/code-lab.d.ts +1 -1
- package/dist/code-lab.esm.js +1533 -396
- package/dist/code-lab.js +1532 -395
- package/dist/diagnostics.d.ts +5 -0
- package/dist/extensions/cpp.d.ts +8 -0
- package/dist/extensions/cpp.esm.js +333 -10
- package/dist/extensions/cpp.js +333 -10
- package/dist/extensions/guided-lab.esm.js +1 -1
- package/dist/extensions/guided-lab.js +1 -1
- package/dist/extensions/python.esm.js +117 -104
- package/dist/extensions/python.js +117 -104
- package/dist/index.d.ts +1 -1
- package/dist/preview-sw.js +34 -17
- package/dist/runtime.esm.js +38 -31
- package/dist/runtime.js +38 -31
- package/dist/schemas.d.ts +4 -4
- package/dist/schemas.esm.js +1 -1
- package/dist/schemas.js +1 -1
- package/dist/scm.d.ts +13 -2
- package/dist/search.d.ts +5 -1
- package/dist/shell.esm.js +72 -16
- package/dist/shell.js +72 -16
- package/dist/terminal.esm.js +183 -54
- package/dist/terminal.js +183 -54
- package/dist/workbench/index.d.ts +1 -1
- package/dist/workbench/styles.d.ts +1 -1
- package/dist/zip.d.ts +4 -3
- package/package.json +1 -1
- package/src/code-lab.css +52 -2
- package/src/csp.ts +7 -10
- package/src/diagnostics.ts +42 -3
- package/src/extensions/cpp.ts +303 -9
- package/src/extensions/python.ts +128 -116
- package/src/index.ts +1 -1
- package/src/preview-sw.js +25 -5
- package/src/runtime.ts +36 -29
- package/src/schemas.ts +2 -2
- package/src/scm.ts +106 -19
- package/src/search.ts +71 -27
- package/src/shell.ts +70 -14
- package/src/terminal.ts +181 -52
- package/src/workbench/diff-editor.ts +41 -13
- package/src/workbench/drawer.ts +17 -8
- package/src/workbench/guided-pane.ts +12 -2
- package/src/workbench/share.ts +37 -8
- package/src/workbench/styles.ts +2 -1
- package/src/workbench/toolbar.ts +15 -4
- package/src/workbench.ts +484 -91
- package/src/zip.ts +29 -7
- package/dist/runtime/module-loader.d.ts +0 -11
- package/dist/runtime/vfs.d.ts +0 -31
- package/dist/runtime/wasi-host.d.ts +0 -33
- package/dist/shell/lexer-parser.d.ts +0 -26
package/src/workbench/toolbar.ts
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { CL_ICONS } from './icons';
|
|
6
6
|
|
|
7
|
+
function escapeHtml(str: unknown): string {
|
|
8
|
+
return String(str ?? '')
|
|
9
|
+
.replace(/&/g, '&')
|
|
10
|
+
.replace(/</g, '<')
|
|
11
|
+
.replace(/>/g, '>')
|
|
12
|
+
.replace(/"/g, '"')
|
|
13
|
+
.replace(/'/g, ''');
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
export interface ToolbarRenderOptions {
|
|
8
17
|
workbench: any;
|
|
9
18
|
title: string;
|
|
@@ -42,7 +51,9 @@ export function renderLanguageSwitcherHtml(workbench: any): string {
|
|
|
42
51
|
export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
|
|
43
52
|
const { workbench, title, backLabel, hasGuidedLab, mode, activeFile, hasWebContent, activeServerCount } = opts;
|
|
44
53
|
const isGuided = Boolean(hasGuidedLab && mode === 'guided');
|
|
45
|
-
const brandLabel = title || 'code-lab';
|
|
54
|
+
const brandLabel = escapeHtml(title || 'code-lab');
|
|
55
|
+
const safeBackLabel = escapeHtml(backLabel);
|
|
56
|
+
const safeActiveFile = escapeHtml(activeFile || 'active');
|
|
46
57
|
|
|
47
58
|
const testFileExists = Boolean(
|
|
48
59
|
workbench._findEntryFile && workbench._findEntryFile('test') !== null
|
|
@@ -52,9 +63,9 @@ export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
|
|
|
52
63
|
<div class="codelab-topbar codelab-toolbar">
|
|
53
64
|
<div class="codelab-topbar__left">
|
|
54
65
|
${workbench.onClose ? `
|
|
55
|
-
<button type="button" class="codelab-btn codelab-btn--back" data-cl-action="close-lab" title="${
|
|
66
|
+
<button type="button" class="codelab-btn codelab-btn--back" data-cl-action="close-lab" title="${safeBackLabel}">
|
|
56
67
|
${CL_ICONS.arrowLeft}
|
|
57
|
-
<span>${
|
|
68
|
+
<span>${safeBackLabel}</span>
|
|
58
69
|
</button>
|
|
59
70
|
` : ''}
|
|
60
71
|
<span class="codelab-brand ${workbench.onClose ? 'codelab-brand--with-back' : ''}" title="${brandLabel}">
|
|
@@ -118,7 +129,7 @@ export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
|
|
|
118
129
|
<span>▶ Run Entry / Demo</span> <kbd style="opacity:0.6">⌘↵</kbd>
|
|
119
130
|
</button>
|
|
120
131
|
<button type="button" class="codelab-split-menu__item" data-cl-action="run-active-file">
|
|
121
|
-
<span>▶ Run Active File (${
|
|
132
|
+
<span>▶ Run Active File (${safeActiveFile})</span> <kbd style="opacity:0.6">⇧⌘↵</kbd>
|
|
122
133
|
</button>
|
|
123
134
|
${testFileExists ? `
|
|
124
135
|
<button type="button" class="codelab-split-menu__item" data-cl-action="run-tests">
|