@innovatorved/code-lab 0.7.0 → 0.7.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.
Files changed (159) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +6 -6
  4. package/dist/code-lab-sql.esm.js +19 -19
  5. package/dist/code-lab-sql.umd.js +20 -20
  6. package/dist/code-lab.css +1 -1
  7. package/dist/code-lab.d.ts +47 -38
  8. package/dist/code-lab.esm.js +1183 -1909
  9. package/dist/code-lab.js +1182 -1906
  10. package/dist/extensions/cpp.esm.js +132 -8760
  11. package/dist/extensions/cpp.js +124 -8770
  12. package/dist/extensions/guided-lab.esm.js +33 -6836
  13. package/dist/extensions/guided-lab.js +33 -6854
  14. package/dist/extensions/javascript.esm.js +1 -36
  15. package/dist/extensions/javascript.js +1 -58
  16. package/dist/extensions/python.esm.js +113 -8122
  17. package/dist/extensions/python.js +113 -8140
  18. package/dist/extensions/typescript.esm.js +1 -55
  19. package/dist/extensions/typescript.js +1 -77
  20. package/dist/index.d.ts +1 -1
  21. package/dist/logger.d.ts +4 -20
  22. package/dist/modular-kernel.d.ts +0 -5
  23. package/dist/packages/core/src/errors.d.ts +5 -1
  24. package/dist/packages/fs/src/backends.d.ts +0 -27
  25. package/dist/packages/fs/src/index.d.ts +1 -1
  26. package/dist/packages/ui/src/html.d.ts +1 -0
  27. package/dist/packages/ui/src/index.d.ts +1 -0
  28. package/dist/{apps/web/src/index.d.ts → packages/ui/src/kernel.d.ts} +3 -11
  29. package/dist/packages/ui/src/observability.d.ts +1 -1
  30. package/dist/packages/ui/src/settings-dialog.d.ts +0 -1
  31. package/dist/preview-sw.js +1 -1
  32. package/dist/runtime.d.ts +3 -0
  33. package/dist/runtime.esm.js +78 -78
  34. package/dist/runtime.js +78 -78
  35. package/dist/schemas.d.ts +10 -1
  36. package/dist/schemas.esm.js +33 -6815
  37. package/dist/schemas.js +33 -6831
  38. package/dist/shell.esm.js +277 -285
  39. package/dist/shell.js +277 -285
  40. package/dist/terminal.esm.js +9 -7
  41. package/dist/terminal.js +7 -7
  42. package/dist/workbench/command-palette.d.ts +0 -4
  43. package/dist/workbench/editor.d.ts +0 -4
  44. package/dist/workbench/index.d.ts +0 -22
  45. package/dist/workbench/intellisense.d.ts +1 -8
  46. package/dist/workbench/xterm-adapter.d.ts +0 -1
  47. package/package.json +4 -13
  48. package/dist/code-lab.umd.js +0 -6117
  49. package/dist/packages/editor/src/index.d.ts +0 -118
  50. package/dist/packages/preview/src/index.d.ts +0 -34
  51. package/dist/packages/runtime/src/index.d.ts +0 -47
  52. package/dist/packages/terminal/src/index.d.ts +0 -54
  53. package/dist/workbench/drawer.d.ts +0 -18
  54. package/dist/workbench/file-tree.d.ts +0 -11
  55. package/dist/workbench/guided-pane.d.ts +0 -11
  56. package/dist/workbench/styles.d.ts +0 -4
  57. package/dist/workbench/toolbar.d.ts +0 -17
  58. package/packages/commands/README.md +0 -7
  59. package/packages/commands/package.json +0 -16
  60. package/packages/commands/src/index.ts +0 -467
  61. package/packages/commands/tsconfig.json +0 -22
  62. package/packages/core/README.md +0 -12
  63. package/packages/core/package.json +0 -13
  64. package/packages/core/src/di.ts +0 -147
  65. package/packages/core/src/disposable.ts +0 -112
  66. package/packages/core/src/errors.ts +0 -205
  67. package/packages/core/src/events.ts +0 -157
  68. package/packages/core/src/index.ts +0 -49
  69. package/packages/core/src/path.ts +0 -118
  70. package/packages/core/src/registry.ts +0 -61
  71. package/packages/core/tsconfig.json +0 -19
  72. package/packages/editor/README.md +0 -9
  73. package/packages/editor/package.json +0 -18
  74. package/packages/editor/src/index.ts +0 -344
  75. package/packages/editor/tsconfig.json +0 -24
  76. package/packages/fs/README.md +0 -7
  77. package/packages/fs/package.json +0 -16
  78. package/packages/fs/src/backends.ts +0 -301
  79. package/packages/fs/src/index.ts +0 -18
  80. package/packages/fs/src/types.ts +0 -44
  81. package/packages/fs/src/vfs-service.ts +0 -257
  82. package/packages/fs/tsconfig.json +0 -22
  83. package/packages/preview/README.md +0 -3
  84. package/packages/preview/package.json +0 -16
  85. package/packages/preview/src/index.ts +0 -125
  86. package/packages/preview/tsconfig.json +0 -22
  87. package/packages/runtime/README.md +0 -3
  88. package/packages/runtime/package.json +0 -17
  89. package/packages/runtime/src/index.ts +0 -134
  90. package/packages/runtime/tsconfig.json +0 -23
  91. package/packages/settings/README.md +0 -7
  92. package/packages/settings/package.json +0 -16
  93. package/packages/settings/src/builtin-schemas.ts +0 -262
  94. package/packages/settings/src/configuration-service.ts +0 -609
  95. package/packages/settings/src/index.ts +0 -38
  96. package/packages/settings/src/jsonc.ts +0 -189
  97. package/packages/settings/src/schema.ts +0 -164
  98. package/packages/settings/tsconfig.json +0 -22
  99. package/packages/sql/README.md +0 -12
  100. package/packages/sql/package.json +0 -13
  101. package/packages/sql/src/completions.ts +0 -359
  102. package/packages/sql/src/diagnostics.ts +0 -200
  103. package/packages/sql/src/formatter.ts +0 -271
  104. package/packages/sql/src/index.ts +0 -54
  105. package/packages/sql/src/sql-editor.ts +0 -802
  106. package/packages/sql/src/styles.ts +0 -524
  107. package/packages/sql/src/tokenizer.ts +0 -457
  108. package/packages/sql/src/types.ts +0 -148
  109. package/packages/sql/tsconfig.json +0 -19
  110. package/packages/terminal/README.md +0 -3
  111. package/packages/terminal/package.json +0 -16
  112. package/packages/terminal/src/index.ts +0 -183
  113. package/packages/terminal/tsconfig.json +0 -22
  114. package/packages/ui/README.md +0 -8
  115. package/packages/ui/package.json +0 -18
  116. package/packages/ui/src/index.ts +0 -40
  117. package/packages/ui/src/observability.ts +0 -173
  118. package/packages/ui/src/plugin-registry.ts +0 -289
  119. package/packages/ui/src/settings-dialog.ts +0 -939
  120. package/packages/ui/src/themes.ts +0 -333
  121. package/packages/ui/tsconfig.json +0 -24
  122. package/src/code-lab.css +0 -8584
  123. package/src/csp.ts +0 -590
  124. package/src/diagnostics.ts +0 -287
  125. package/src/extensions/cpp.ts +0 -2389
  126. package/src/extensions/guided-lab.ts +0 -64
  127. package/src/extensions/javascript.ts +0 -54
  128. package/src/extensions/python.ts +0 -1737
  129. package/src/extensions/typescript.ts +0 -85
  130. package/src/extensions/umbrella.ts +0 -5
  131. package/src/html.ts +0 -88
  132. package/src/index.ts +0 -129
  133. package/src/logger.ts +0 -139
  134. package/src/modular-kernel.ts +0 -11
  135. package/src/preview-sw.js +0 -296
  136. package/src/runtime/test-harness.ts +0 -57
  137. package/src/runtime.ts +0 -10480
  138. package/src/sample.html +0 -304
  139. package/src/schemas.ts +0 -366
  140. package/src/scm.ts +0 -2453
  141. package/src/search.ts +0 -433
  142. package/src/shell.ts +0 -10987
  143. package/src/storage.ts +0 -773
  144. package/src/terminal.ts +0 -1400
  145. package/src/workbench/command-palette.ts +0 -381
  146. package/src/workbench/diff-editor.ts +0 -470
  147. package/src/workbench/drawer.ts +0 -157
  148. package/src/workbench/editor.ts +0 -49
  149. package/src/workbench/file-tree.ts +0 -51
  150. package/src/workbench/guided-pane.ts +0 -43
  151. package/src/workbench/icons.ts +0 -255
  152. package/src/workbench/index.ts +0 -44
  153. package/src/workbench/intellisense.ts +0 -1871
  154. package/src/workbench/share.ts +0 -128
  155. package/src/workbench/styles.ts +0 -211
  156. package/src/workbench/toolbar.ts +0 -182
  157. package/src/workbench/xterm-adapter.ts +0 -1571
  158. package/src/workbench.ts +0 -22132
  159. package/src/zip.ts +0 -348
@@ -1,128 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — Zero-Backend URL Snapshot Compressor & Decompressor
3
- *
4
- * Serializes workspace state { lang, activeFile, files, stdin }, compresses it
5
- * with browser-native `CompressionStream('deflate-raw')`, and encodes as Base64url
6
- * in the URL hash `#codelab=<base64url>`.
7
- */
8
-
9
- export interface WorkspaceSharePayload {
10
- lang?: string;
11
- activeFile?: string | null;
12
- files: Record<string, string>;
13
- stdin?: string;
14
- }
15
-
16
- function bufferToBase64Url(uint8: Uint8Array): string {
17
- let binary = '';
18
- for (let i = 0; i < uint8.length; i++) {
19
- binary += String.fromCharCode(uint8[i]);
20
- }
21
- const base64 = typeof btoa !== 'undefined' ? btoa(binary) : Buffer.from(uint8).toString('base64');
22
- return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
23
- }
24
-
25
- function base64UrlToBuffer(base64url: string): Uint8Array {
26
- let base64 = base64url.replace(/-/g, '+').replace(/_/g, '/');
27
- while (base64.length % 4) {
28
- base64 += '=';
29
- }
30
- if (typeof atob !== 'undefined') {
31
- const binary = atob(base64);
32
- const bytes = new Uint8Array(binary.length);
33
- for (let i = 0; i < binary.length; i++) {
34
- bytes[i] = binary.charCodeAt(i);
35
- }
36
- return bytes;
37
- }
38
- return new Uint8Array(Buffer.from(base64, 'base64'));
39
- }
40
-
41
- /**
42
- * Compresses workspace payload into a compact Base64url string.
43
- */
44
- export async function compressWorkspaceSnapshot(payload: WorkspaceSharePayload): Promise<string> {
45
- const jsonStr = JSON.stringify(payload);
46
- const encoder = new TextEncoder();
47
- const rawBytes = encoder.encode(jsonStr);
48
-
49
- if (typeof CompressionStream !== 'undefined') {
50
- const cs = new CompressionStream('deflate-raw');
51
- const writer = cs.writable.getWriter();
52
- writer.write(rawBytes);
53
- writer.close();
54
-
55
- const response = new Response(cs.readable);
56
- const compressedBuffer = await response.arrayBuffer();
57
- return bufferToBase64Url(new Uint8Array(compressedBuffer));
58
- }
59
-
60
- // Fallback: uncompressed Base64url if CompressionStream unsupported
61
- return bufferToBase64Url(rawBytes);
62
- }
63
-
64
- const MAX_DECOMPRESSED_SNAPSHOT_BYTES = 5 * 1024 * 1024; // 5 MB
65
-
66
- /**
67
- * Decompresses a Base64url string into workspace snapshot payload.
68
- */
69
- export async function decompressWorkspaceSnapshot(encoded: string): Promise<WorkspaceSharePayload | null> {
70
- if (!encoded || typeof encoded !== 'string') return null;
71
- try {
72
- const bytes = base64UrlToBuffer(encoded);
73
- if (bytes.byteLength > MAX_DECOMPRESSED_SNAPSHOT_BYTES) {
74
- throw new Error('Snapshot payload exceeds maximum allowed size');
75
- }
76
-
77
- if (typeof DecompressionStream !== 'undefined') {
78
- try {
79
- const ds = new DecompressionStream('deflate-raw');
80
- const writer = ds.writable.getWriter();
81
- const writeInput = new Uint8Array(bytes.byteLength);
82
- writeInput.set(bytes);
83
- writer.write(writeInput).catch(() => {});
84
- writer.close().catch(() => {});
85
-
86
- const reader = ds.readable.getReader();
87
- const chunks: Uint8Array[] = [];
88
- let totalLength = 0;
89
- while (true) {
90
- const step = await reader.read();
91
- if (step.done) break;
92
- const chunk = step.value;
93
- if (chunk) {
94
- totalLength += chunk.byteLength;
95
- if (totalLength > MAX_DECOMPRESSED_SNAPSHOT_BYTES) {
96
- await reader.cancel().catch(() => {});
97
- throw new Error('Decompressed snapshot exceeds 5 MB safety limit');
98
- }
99
- chunks.push(chunk);
100
- }
101
- }
102
- const decompressed = new Uint8Array(totalLength);
103
- let offset = 0;
104
- for (const chunk of chunks) {
105
- decompressed.set(chunk, offset);
106
- offset += chunk.byteLength;
107
- }
108
- const text = new TextDecoder().decode(decompressed);
109
- return JSON.parse(text) as WorkspaceSharePayload;
110
- } catch (err) {
111
- if (err instanceof Error && err.message.includes('safety limit')) {
112
- throw err;
113
- }
114
- // Fallback for uncompressed raw JSON payload
115
- const rawText = new TextDecoder().decode(bytes);
116
- return JSON.parse(rawText) as WorkspaceSharePayload;
117
- }
118
- }
119
-
120
- const rawText = new TextDecoder().decode(bytes);
121
- return JSON.parse(rawText) as WorkspaceSharePayload;
122
- } catch (err) {
123
- if (typeof console !== 'undefined' && console.warn) {
124
- console.warn('[CodeLab Share Snapshot Restore Error]:', err);
125
- }
126
- return null;
127
- }
128
- }
@@ -1,211 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — Workbench CSS Tokens, Themes & Styles
3
- */
4
-
5
- export const WORKBENCH_STYLES = `
6
- /* ── Split Run Button ── */
7
- .codelab-btn-split {
8
- display: inline-flex;
9
- align-items: stretch;
10
- border-radius: var(--cl-radius-md, 6px);
11
- overflow: visible;
12
- position: relative;
13
- }
14
- .codelab-btn-split .codelab-btn-split__main {
15
- border-top-right-radius: 0;
16
- border-bottom-right-radius: 0;
17
- border-right: 1px solid rgba(0, 0, 0, 0.18);
18
- }
19
- .codelab-btn-split .codelab-btn-split__trigger {
20
- border-top-left-radius: 0;
21
- border-bottom-left-radius: 0;
22
- padding: 0 6px;
23
- min-width: 24px;
24
- }
25
- .codelab-split-menu {
26
- position: absolute;
27
- top: calc(100% + 4px);
28
- right: 0;
29
- background: var(--cl-bg-panel, #18181a);
30
- border: 1px solid var(--cl-border-strong, var(--cl-border, #27272a));
31
- border-radius: var(--cl-radius-md, 6px);
32
- box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
33
- z-index: 1200;
34
- min-width: 220px;
35
- padding: 4px;
36
- display: none;
37
- }
38
- .codelab-split-menu.open,
39
- .codelab-split-menu.active {
40
- display: block;
41
- }
42
- .codelab-split-menu__item {
43
- display: flex;
44
- align-items: center;
45
- justify-content: space-between;
46
- width: 100%;
47
- padding: 6px 10px;
48
- border-radius: var(--cl-radius-sm, 4px);
49
- background: none;
50
- border: none;
51
- color: var(--cl-fg, #f4f4f5);
52
- font-family: var(--cl-font-sans);
53
- font-size: var(--cl-text-xs, 0.75rem);
54
- cursor: pointer;
55
- text-align: left;
56
- }
57
- .codelab-split-menu__item:hover,
58
- .codelab-split-menu__item:focus-visible {
59
- background: var(--cl-list-active, #28282b);
60
- color: var(--cl-list-active-fg, #f4f4f5);
61
- outline: none;
62
- }
63
-
64
- /* ── Command Palette Trigger Pill ── */
65
- .codelab-cmd-trigger {
66
- display: inline-flex;
67
- align-items: center;
68
- gap: 6px;
69
- padding: 3px 12px;
70
- min-width: 200px;
71
- justify-content: center;
72
- border-radius: var(--cl-radius-md, 6px);
73
- background: var(--cl-input-bg, #141415);
74
- border: 1px solid var(--cl-border, #27272a);
75
- color: var(--cl-fg-muted, #a1a1aa);
76
- font-family: var(--cl-font-sans);
77
- font-size: var(--cl-text-xs, 0.75rem);
78
- cursor: pointer;
79
- transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
80
- }
81
- .codelab-cmd-trigger:hover,
82
- .codelab-cmd-trigger:focus-visible {
83
- background: var(--cl-bg-hover, #1f1f22);
84
- color: var(--cl-fg, #f4f4f5);
85
- border-color: var(--cl-border-strong, #3a3a3e);
86
- outline: none;
87
- }
88
-
89
- /* ── HUD Telemetry Pill ── */
90
- .codelab-hud-pill {
91
- display: inline-flex;
92
- align-items: center;
93
- gap: 8px;
94
- padding: 2px 10px;
95
- border-radius: 999px;
96
- background: var(--cl-bg-panel, #18181a);
97
- border: 1px solid var(--cl-border, #27272a);
98
- color: var(--cl-fg-muted, #a1a1aa);
99
- font-family: var(--cl-font-mono);
100
- font-size: var(--cl-text-2xs, 0.6875rem);
101
- font-variant-numeric: tabular-nums;
102
- font-weight: 500;
103
- margin-left: auto;
104
- user-select: none;
105
- }
106
- .codelab-hud-pill__metric {
107
- display: inline-flex;
108
- align-items: center;
109
- gap: 4px;
110
- }
111
-
112
- /* ── Stdin / Custom Input Panel ── */
113
- .codelab-stdin-panel {
114
- display: flex;
115
- flex-direction: column;
116
- height: 100%;
117
- padding: 8px 12px;
118
- background: var(--cl-bg-editor, #0f0f10);
119
- box-sizing: border-box;
120
- }
121
- .codelab-stdin-panel__header {
122
- display: flex;
123
- align-items: center;
124
- justify-content: space-between;
125
- margin-bottom: 6px;
126
- font-family: var(--cl-font-sans);
127
- font-size: var(--cl-text-xs, 0.75rem);
128
- color: var(--cl-fg-muted, #a1a1aa);
129
- font-weight: 500;
130
- }
131
- .codelab-stdin-panel__textarea {
132
- flex: 1;
133
- width: 100%;
134
- background: var(--cl-input-bg, #141415);
135
- border: 1px solid var(--cl-border, #27272a);
136
- border-radius: var(--cl-radius-md, 6px);
137
- color: var(--cl-fg, #f4f4f5);
138
- font-family: var(--cl-font-mono);
139
- font-size: var(--cl-text-xs, 0.75rem);
140
- line-height: 1.5;
141
- padding: 8px 10px;
142
- resize: none;
143
- outline: none;
144
- box-sizing: border-box;
145
- }
146
- .codelab-stdin-panel__textarea:focus {
147
- border-color: var(--cl-focus-border, #a1a1aa);
148
- }
149
-
150
- /* ── Problems Drawer Tab ── */
151
- .codelab-problems-list {
152
- display: flex;
153
- flex-direction: column;
154
- overflow-y: auto;
155
- height: 100%;
156
- padding: 4px 0;
157
- }
158
- .codelab-problem-item {
159
- display: flex;
160
- align-items: center;
161
- gap: 8px;
162
- padding: 5px 12px;
163
- font-size: var(--cl-text-xs, 0.75rem);
164
- font-family: var(--cl-font-mono);
165
- cursor: pointer;
166
- border-bottom: 1px solid var(--cl-border-subtle, #1d1d20);
167
- }
168
- .codelab-problem-item:hover {
169
- background: var(--cl-bg-hover, #1f1f22);
170
- }
171
- .codelab-problem-item--error {
172
- color: var(--cl-red, #f87171);
173
- }
174
- .codelab-problem-item--warning {
175
- color: var(--cl-amber, #fbbf24);
176
- }
177
- .codelab-problem-item--info {
178
- color: var(--cl-fg, #f4f4f5);
179
- }
180
- .codelab-problem-item__location {
181
- color: var(--cl-fg-muted, #a1a1aa);
182
- font-size: var(--cl-text-2xs, 0.6875rem);
183
- font-variant-numeric: tabular-nums;
184
- margin-left: auto;
185
- }
186
-
187
- /* ── Monaco Side-by-Side Diff Editor ── */
188
- .codelab-diff-container {
189
- display: flex;
190
- flex-direction: column;
191
- width: 100%;
192
- height: 100%;
193
- background: var(--cl-bg-editor, #0f0f10);
194
- }
195
- .codelab-diff-toolbar {
196
- display: flex;
197
- align-items: center;
198
- gap: 8px;
199
- padding: 6px 12px;
200
- background: var(--cl-bg-elevated, #141415);
201
- border-bottom: 1px solid var(--cl-border, #27272a);
202
- font-family: var(--cl-font-sans);
203
- font-size: var(--cl-text-xs, 0.75rem);
204
- }
205
- .codelab-diff-host {
206
- flex: 1;
207
- width: 100%;
208
- height: calc(100% - 36px);
209
- position: relative;
210
- }
211
- `;
@@ -1,182 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — Topbar Navigation & Contextual Execution Controls
3
- */
4
-
5
- import { CL_ICONS } from './icons';
6
-
7
- function escapeHtml(str: unknown): string {
8
- return String(str ?? '')
9
- .replace(/&/g, '&amp;')
10
- .replace(/</g, '&lt;')
11
- .replace(/>/g, '&gt;')
12
- .replace(/"/g, '&quot;')
13
- .replace(/'/g, '&#39;');
14
- }
15
-
16
- export interface ToolbarRenderOptions {
17
- workbench: any;
18
- title: string;
19
- backLabel: string;
20
- hasGuidedLab: boolean;
21
- mode: string;
22
- activeFile: string | null;
23
- enabledLanguages: Set<string>;
24
- currentLang: string;
25
- hasWebContent: boolean;
26
- activeServerCount: number;
27
- }
28
-
29
- export function renderLanguageSwitcherHtml(workbench: any): string {
30
- const enabled = workbench.enabledLanguages || new Set(['js']);
31
- const showTs = enabled.has('ts');
32
- const showCpp = enabled.has('cpp');
33
- const showPy = enabled.has('py');
34
-
35
- const count = (enabled.has('js') ? 1 : 0) + (showTs ? 1 : 0) + (showCpp ? 1 : 0) + (showPy ? 1 : 0);
36
- if (count <= 1) return '';
37
-
38
- const activeLang = workbench.lang || 'js';
39
-
40
- return `
41
- <span class="codelab-toolbar__sep" aria-hidden="true"></span>
42
- <div class="codelab-lang-switch codelab-segmented" role="tablist" aria-label="Language">
43
- <button type="button" role="tab" aria-selected="${activeLang === 'js'}" class="codelab-segmented__btn ${activeLang === 'js' ? 'active' : ''}" data-cl-lang="js" title="JavaScript (Node.js &amp; Bun runtime)">JS</button>
44
- ${showTs ? `<button type="button" role="tab" aria-selected="${activeLang === 'ts'}" class="codelab-segmented__btn ${activeLang === 'ts' ? 'active' : ''}" data-cl-lang="ts" title="TypeScript (Instant in-browser transpile)">TS</button>` : ''}
45
- ${showCpp ? `<button type="button" role="tab" aria-selected="${activeLang === 'cpp'}" class="codelab-segmented__btn ${activeLang === 'cpp' ? 'active' : ''}" data-cl-lang="cpp" title="C++20 (WASI Clang/LLVM WebAssembly compiler)">C++</button>` : ''}
46
- ${showPy ? `<button type="button" role="tab" aria-selected="${activeLang === 'py'}" class="codelab-segmented__btn ${activeLang === 'py' ? 'active' : ''}" data-cl-lang="py" title="Python 3.12 (CPython WebAssembly via Pyodide)">PY</button>` : ''}
47
- </div>
48
- `;
49
- }
50
-
51
- export function renderToolbarHtml(opts: ToolbarRenderOptions): string {
52
- const { workbench, title, backLabel, hasGuidedLab, mode, activeFile, hasWebContent, activeServerCount } = opts;
53
- const isGuided = Boolean(hasGuidedLab && mode === 'guided');
54
- const brandLabel = escapeHtml(title || 'code-lab');
55
- const safeBackLabel = escapeHtml(backLabel);
56
- const safeActiveFile = escapeHtml(activeFile || 'active');
57
-
58
- const testFileExists = Boolean(
59
- workbench._findEntryFile && workbench._findEntryFile('test') !== null
60
- );
61
-
62
- return `
63
- <div class="codelab-topbar codelab-toolbar">
64
- <div class="codelab-topbar__left">
65
- ${workbench.onClose ? `
66
- <button type="button" class="codelab-btn codelab-btn--back" data-cl-action="close-lab" title="${safeBackLabel}">
67
- ${CL_ICONS.arrowLeft}
68
- <span>${safeBackLabel}</span>
69
- </button>
70
- ` : ''}
71
- <span class="codelab-brand ${workbench.onClose ? 'codelab-brand--with-back' : ''}" title="${brandLabel}">
72
- <span class="codelab-brand__dot"></span>
73
- <span>${brandLabel}</span>
74
- </span>
75
-
76
- ${hasGuidedLab ? `
77
- <span class="codelab-toolbar__sep" aria-hidden="true"></span>
78
- <div class="codelab-mode-switch" role="tablist" aria-label="Lab Mode">
79
- <button type="button" role="tab" aria-selected="${mode === 'guided'}" class="codelab-mode-btn ${mode === 'guided' ? 'active' : ''}" data-cl-mode="guided">
80
- ${CL_ICONS.target}
81
- <span>Guided Challenge</span>
82
- </button>
83
- <button type="button" role="tab" aria-selected="${mode === 'sandbox'}" class="codelab-mode-btn ${mode === 'sandbox' ? 'active' : ''}" data-cl-mode="sandbox">
84
- ${CL_ICONS.code}
85
- <span>Reference Sandbox</span>
86
- </button>
87
- </div>
88
- ` : ''}
89
-
90
- ${renderLanguageSwitcherHtml(workbench)}
91
-
92
- <span class="codelab-toolbar__sep" aria-hidden="true"></span>
93
- <button type="button" class="codelab-cmd-trigger" data-cl-action="command-palette" title="Open Command Palette (⌘K / ⇧⌘P)">
94
- ${CL_ICONS.search}
95
- <span>Command Palette</span>
96
- <kbd style="opacity:0.7">⇧⌘P</kbd>
97
- </button>
98
- </div>
99
-
100
- <div class="codelab-topbar__right">
101
- <button type="button" class="codelab-btn codelab-btn--stop" id="cl-stop-btn" data-cl-action="stop-run" title="Stop Running Execution" style="display:none">
102
- ${CL_ICONS.stop}
103
- <span>Stop</span>
104
- </button>
105
-
106
- ${isGuided ? `
107
- <button type="button" class="codelab-btn codelab-btn--run" data-cl-action="run-demo" title="Run Demo Script (⇧⌘↵)">
108
- ${CL_ICONS.play}
109
- <span>Run Demo</span>
110
- <span class="codelab-btn__kbd">⇧⌘↵</span>
111
- </button>
112
- <button type="button" class="codelab-btn codelab-btn--test" id="cl-primary-exec-btn" data-cl-action="verify-step" title="Verify Current Step (⌘↵)">
113
- ${CL_ICONS.check}
114
- <span>Verify Step</span>
115
- <span class="codelab-btn__kbd">⌘↵</span>
116
- </button>
117
- ` : `
118
- <div class="codelab-btn-split">
119
- <button type="button" class="codelab-btn codelab-btn--run codelab-btn-split__main" data-cl-action="run-code" title="Run Code (⌘↵)">
120
- ${CL_ICONS.play}
121
- <span>Run Code</span>
122
- <span class="codelab-btn__kbd">⌘↵</span>
123
- </button>
124
- <button type="button" class="codelab-btn codelab-btn--run codelab-btn-split__trigger" id="cl-split-run-trigger" title="More Execution Options" aria-haspopup="true">
125
- ${CL_ICONS.chevronDown}
126
- </button>
127
- <div class="codelab-split-menu" id="cl-split-run-menu">
128
- <button type="button" class="codelab-split-menu__item" data-cl-action="run-entry">
129
- <span>▶ Run Entry / Demo</span> <kbd style="opacity:0.6">⌘↵</kbd>
130
- </button>
131
- <button type="button" class="codelab-split-menu__item" data-cl-action="run-active-file">
132
- <span>▶ Run Active File (${safeActiveFile})</span> <kbd style="opacity:0.6">⇧⌘↵</kbd>
133
- </button>
134
- ${testFileExists ? `
135
- <button type="button" class="codelab-split-menu__item" data-cl-action="run-tests">
136
- <span>✓ Run Test Suite</span>
137
- </button>
138
- ` : ''}
139
- <button type="button" class="codelab-split-menu__item" data-cl-action="open-stdin">
140
- <span>⌨ Configure Stdin / Input...</span>
141
- </button>
142
- </div>
143
- </div>
144
- `}
145
-
146
- ${hasWebContent ? `
147
- <button type="button" class="codelab-btn codelab-btn--icon" id="cl-preview-app-btn" data-cl-action="preview-app" title="Run &amp; Preview in Browser" aria-label="Run and Preview in Browser">
148
- ${CL_ICONS.globe}
149
- ${activeServerCount > 0 ? `<span class="codelab-port-badge">${activeServerCount}</span>` : ''}
150
- </button>
151
- ` : ''}
152
-
153
- <button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="share-snapshot" title="Share Snapshot Link (#codelab=...)" aria-label="Share Snapshot Link">
154
- ${CL_ICONS.share}
155
- </button>
156
-
157
- <span class="codelab-toolbar__sep" aria-hidden="true"></span>
158
-
159
- ${hasGuidedLab ? `
160
- <button type="button" class="codelab-btn codelab-btn--icon" id="cl-toggle-guide-btn" data-cl-action="toggle-guide" title="Toggle Guide Panel" aria-label="Toggle Guide Panel">
161
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M9 3v18"/></svg>
162
- </button>
163
- ` : ''}
164
-
165
- <button type="button" class="codelab-btn codelab-btn--icon" id="cl-toggle-drawer-btn" data-cl-action="toggle-drawer" title="Toggle Bottom Drawer" aria-label="Toggle Bottom Drawer">
166
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 15h18"/></svg>
167
- </button>
168
-
169
- <button type="button" class="codelab-btn codelab-btn--icon" id="cl-fullscreen-btn" data-cl-action="toggle-fullscreen" title="Toggle Fullscreen IDE (Esc to exit)" aria-label="Toggle Fullscreen IDE">
170
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>
171
- </button>
172
-
173
- ${workbench.onClose ? `
174
- <button type="button" class="codelab-btn codelab-btn--exit-lab codelab-btn--close-ide" id="cl-close-ide-btn" data-cl-action="close-lab" title="Exit Lab" aria-label="Exit Lab">
175
- <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
176
- <span class="codelab-btn__label">Exit</span>
177
- </button>
178
- ` : ''}
179
- </div>
180
- </div>
181
- `;
182
- }