@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
package/src/search.ts DELETED
@@ -1,433 +0,0 @@
1
- /**
2
- * @innovatorved/code-lab — High-Performance Cross-File Search & Replace Core
3
- * ============================================================================
4
- * Pure TypeScript implementation of workspace-wide text search and atomic multi-file
5
- * replacements. Supports regex, whole-word, case-sensitive matching, glob filtering,
6
- * line/column coordinate extraction, and match highlight snippets.
7
- *
8
- * Strict leaf module: fully typed, zero explicit any, zero empty catches.
9
- */
10
-
11
- export interface SearchOptions {
12
- query?: string;
13
- replacement?: string;
14
- caseSensitive?: boolean;
15
- wholeWord?: boolean;
16
- regex?: boolean;
17
- isRegex?: boolean;
18
- include?: string;
19
- includeGlob?: string;
20
- includePattern?: string | string[];
21
- exclude?: string;
22
- excludeGlob?: string;
23
- excludePattern?: string | string[];
24
- maxMatches?: number;
25
- maxMatchesPerFile?: number;
26
- targetFiles?: string[];
27
- }
28
-
29
- export interface SearchMatchItem {
30
- line: number;
31
- col: number;
32
- column?: number;
33
- length: number;
34
- matchText?: string;
35
- lineText: string;
36
- beforeSnippet?: string;
37
- afterSnippet?: string;
38
- matchIndex?: number;
39
- matchEndIndex?: number;
40
- }
41
-
42
- export interface SearchMatchGroup {
43
- file: string;
44
- matches: SearchMatchItem[];
45
- }
46
-
47
- export interface SearchResult extends Array<SearchMatchGroup> {
48
- matches: SearchMatchGroup[];
49
- totalMatches: number;
50
- fileCount: number;
51
- filesCount: number;
52
- query: string;
53
- durationMs?: number;
54
- error?: string;
55
- }
56
-
57
- export interface ReplaceResult {
58
- updatedFiles: Record<string, string>;
59
- files: Record<string, string>;
60
- replacedCount: number;
61
- filesAffected: string[];
62
- filesModified: number;
63
- }
64
-
65
- /**
66
- * Escapes regex special characters in a literal string.
67
- */
68
- export function escapeRegex(text: string): string {
69
- return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
70
- }
71
-
72
- /**
73
- * Normalizes a virtual workspace path (POSIX forward-slashes, no leading ./ or /).
74
- */
75
- export function normalizeSearchPath(filePath: string): string {
76
- let p = filePath.replace(/\\/g, '/');
77
- while (p.startsWith('./')) {
78
- p = p.slice(2);
79
- }
80
- while (p.startsWith('/')) {
81
- p = p.slice(1);
82
- }
83
- return p;
84
- }
85
-
86
- /**
87
- * Matches a file path against a glob or literal substring filter.
88
- * Supports comma-separated patterns (e.g. `*.ts, *.js`).
89
- */
90
- export function matchesGlob(filePath: string, pattern: string): boolean {
91
- if (!pattern || pattern === '*' || pattern === '**') return true;
92
- if (pattern.includes(',')) {
93
- const subPatterns = pattern
94
- .split(',')
95
- .map((s) => s.trim())
96
- .filter(Boolean);
97
- if (subPatterns.length > 1) {
98
- return subPatterns.some((sub) => matchesGlob(filePath, sub));
99
- }
100
- }
101
-
102
- const normPath = normalizeSearchPath(filePath);
103
- const normPattern = normalizeSearchPath(pattern.trim());
104
-
105
- if (normPattern === normPath) return true;
106
-
107
- // Plain substring match if no wildcards present
108
- if (!normPattern.includes('*') && !normPattern.includes('?')) {
109
- return normPath.includes(normPattern) || normPath.endsWith(normPattern);
110
- }
111
-
112
- // Convert glob pattern to regular expression
113
- let regexStr = '^';
114
- let i = 0;
115
- while (i < normPattern.length) {
116
- const c = normPattern[i];
117
- if (c === '*') {
118
- if (normPattern[i + 1] === '*') {
119
- i += 2;
120
- if (normPattern[i] === '/') {
121
- // `/**/` or leading `**/` matches zero or more directory segments
122
- regexStr += '(?:.*/)?';
123
- i++;
124
- } else {
125
- regexStr += '.*';
126
- }
127
- continue;
128
- } else {
129
- regexStr += '[^/]*';
130
- i++;
131
- continue;
132
- }
133
- } else if (c === '?') {
134
- regexStr += '[^/]';
135
- i++;
136
- continue;
137
- } else if ('./+^$()|[]{}\\'.includes(c)) {
138
- regexStr += '\\' + c;
139
- i++;
140
- continue;
141
- } else {
142
- regexStr += c;
143
- i++;
144
- }
145
- }
146
- regexStr += '$';
147
-
148
- try {
149
- const re = new RegExp(regexStr);
150
- if (re.test(normPath)) return true;
151
- // Also allow basename match when pattern has no directory separator (e.g. `*.ts` matching `src/app.ts`)
152
- if (!normPattern.includes('/')) {
153
- const baseName = normPath.split('/').pop() || normPath;
154
- if (re.test(baseName)) return true;
155
- }
156
- return false;
157
- } catch (err) {
158
- void err;
159
- return normPath.includes(normPattern.replace(/[*?]/g, ''));
160
- }
161
- }
162
-
163
- function checkFilter(path: string, filter?: string | string[]): boolean {
164
- if (!filter) return true;
165
- if (Array.isArray(filter)) {
166
- return filter.some((f) => matchesGlob(path, f));
167
- }
168
- return matchesGlob(path, filter);
169
- }
170
-
171
- function createSearchResult(
172
- groups: SearchMatchGroup[],
173
- totalMatches: number,
174
- fileCount: number,
175
- query: string,
176
- error?: string
177
- ): SearchResult {
178
- const arr = [...groups];
179
- const result = Object.assign(arr, {
180
- matches: groups,
181
- totalMatches,
182
- fileCount,
183
- filesCount: fileCount,
184
- query,
185
- durationMs: 0,
186
- error
187
- });
188
- return result as SearchResult;
189
- }
190
-
191
- /**
192
- * Searches across a map of virtual files for matching text or regex patterns.
193
- */
194
- export function searchInFiles(
195
- files: Record<string, string>,
196
- queryOrOptions: string | SearchOptions,
197
- optionsOrUndefined?: SearchOptions
198
- ): SearchResult {
199
- let query = '';
200
- let opts: SearchOptions = {};
201
-
202
- if (typeof queryOrOptions === 'string') {
203
- query = queryOrOptions;
204
- opts = optionsOrUndefined || {};
205
- } else if (queryOrOptions && typeof queryOrOptions === 'object') {
206
- opts = queryOrOptions;
207
- query = opts.query || '';
208
- }
209
-
210
- if (!query) {
211
- return createSearchResult([], 0, 0, query);
212
- }
213
-
214
- const isCaseSensitive = Boolean(opts.caseSensitive);
215
- const isWholeWord = Boolean(opts.wholeWord);
216
- const isRegex = Boolean(opts.regex || opts.isRegex);
217
- const maxMatches = opts.maxMatches ?? 10000;
218
- const maxMatchesPerFile = opts.maxMatchesPerFile ?? 1000;
219
-
220
- const includeFilter = opts.include || opts.includeGlob || opts.includePattern;
221
- const excludeFilter = opts.exclude || opts.excludeGlob || opts.excludePattern;
222
-
223
- let patternStr = isRegex ? query : escapeRegex(query);
224
- if (isWholeWord) {
225
- patternStr = `\\b${patternStr}\\b`;
226
- }
227
-
228
- let regex: RegExp = /(?:)/;
229
- try {
230
- regex = new RegExp(patternStr, isCaseSensitive ? 'g' : 'gi');
231
- } catch (err) {
232
- const _err = err;
233
- const msg =
234
- typeof _err === 'object' && _err && 'message' in _err
235
- ? String((_err as { message: unknown }).message)
236
- : 'Invalid regular expression';
237
- return createSearchResult([], 0, 0, query, msg);
238
- }
239
-
240
- const matchedGroups: SearchMatchGroup[] = [];
241
- let totalMatches = 0;
242
-
243
- for (const [filePath, content] of Object.entries(files)) {
244
- if (includeFilter && !checkFilter(filePath, includeFilter)) continue;
245
- if (excludeFilter && checkFilter(filePath, excludeFilter)) continue;
246
- if (opts.targetFiles && !opts.targetFiles.includes(filePath)) continue;
247
-
248
- const fileMatches: SearchMatchItem[] = [];
249
- const lines = content.split('\n');
250
-
251
- for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
252
- const lineText = lines[lineIndex];
253
- regex.lastIndex = 0;
254
- let m: RegExpExecArray | null = null;
255
-
256
- while ((m = regex.exec(lineText)) !== null) {
257
- const matchLen = m[0].length;
258
- const col = m.index + 1;
259
- fileMatches.push({
260
- line: lineIndex + 1,
261
- col,
262
- column: col,
263
- length: matchLen,
264
- matchText: m[0],
265
- lineText,
266
- beforeSnippet: lineText.slice(0, m.index),
267
- afterSnippet: lineText.slice(m.index + matchLen),
268
- matchIndex: m.index,
269
- matchEndIndex: m.index + matchLen
270
- });
271
- totalMatches++;
272
-
273
- if (fileMatches.length >= maxMatchesPerFile || totalMatches >= maxMatches) {
274
- break;
275
- }
276
-
277
- // Prevent infinite loop on zero-width match
278
- if (matchLen === 0) {
279
- regex.lastIndex++;
280
- if (regex.lastIndex > lineText.length) {
281
- break;
282
- }
283
- }
284
- }
285
-
286
- if (fileMatches.length >= maxMatchesPerFile || totalMatches >= maxMatches) {
287
- break;
288
- }
289
- }
290
-
291
- if (fileMatches.length > 0) {
292
- matchedGroups.push({
293
- file: filePath,
294
- matches: fileMatches
295
- });
296
- }
297
-
298
- if (totalMatches >= maxMatches) {
299
- break;
300
- }
301
- }
302
-
303
- return createSearchResult(matchedGroups, totalMatches, matchedGroups.length, query);
304
- }
305
-
306
- /**
307
- * Replaces occurrences of a query pattern across virtual workspace files.
308
- */
309
- export function replaceInFiles(
310
- files: Record<string, string>,
311
- arg2: string | SearchOptions,
312
- arg3?: string,
313
- arg4?: SearchOptions | string[]
314
- ): ReplaceResult {
315
- let query = '';
316
- let replacement = typeof arg3 === 'string' ? arg3 : '';
317
- let opts: SearchOptions = {};
318
- let targetFiles: string[] | undefined = undefined;
319
-
320
- if (typeof arg2 === 'string') {
321
- query = arg2;
322
- if (Array.isArray(arg4)) {
323
- targetFiles = arg4;
324
- } else if (arg4 && typeof arg4 === 'object') {
325
- opts = arg4;
326
- targetFiles = opts.targetFiles;
327
- }
328
- } else if (arg2 && typeof arg2 === 'object') {
329
- opts = arg2;
330
- query = opts.query || '';
331
- if (typeof arg3 !== 'string' && typeof opts.replacement === 'string') {
332
- replacement = opts.replacement;
333
- }
334
- if (Array.isArray(arg4)) {
335
- targetFiles = arg4;
336
- } else {
337
- targetFiles = opts.targetFiles;
338
- }
339
- }
340
-
341
- if (!query) {
342
- const copy = { ...files };
343
- return {
344
- updatedFiles: copy,
345
- files: copy,
346
- replacedCount: 0,
347
- filesAffected: [],
348
- filesModified: 0
349
- };
350
- }
351
-
352
- const isCaseSensitive = Boolean(opts.caseSensitive);
353
- const isWholeWord = Boolean(opts.wholeWord);
354
- const isRegex = Boolean(opts.regex || opts.isRegex);
355
-
356
- const includeFilter = opts.include || opts.includeGlob || opts.includePattern;
357
- const excludeFilter = opts.exclude || opts.excludeGlob || opts.excludePattern;
358
-
359
- let patternStr = isRegex ? query : escapeRegex(query);
360
- if (isWholeWord) {
361
- patternStr = `\\b${patternStr}\\b`;
362
- }
363
-
364
- let regex: RegExp = /(?:)/;
365
- try {
366
- regex = new RegExp(patternStr, isCaseSensitive ? 'g' : 'gi');
367
- } catch (err) {
368
- void err;
369
- const copy = { ...files };
370
- return {
371
- updatedFiles: copy,
372
- files: copy,
373
- replacedCount: 0,
374
- filesAffected: [],
375
- filesModified: 0
376
- };
377
- }
378
-
379
- const updatedFiles: Record<string, string> = { ...files };
380
- const filesAffected: string[] = [];
381
- let replacedCount = 0;
382
-
383
- for (const [filePath, content] of Object.entries(files)) {
384
- if (targetFiles && !targetFiles.includes(filePath)) continue;
385
- if (includeFilter && !checkFilter(filePath, includeFilter)) continue;
386
- if (excludeFilter && checkFilter(filePath, excludeFilter)) continue;
387
-
388
- const lines = content.split('\n');
389
- let countInFile = 0;
390
- const newLines: string[] = [];
391
-
392
- for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
393
- const lineText = lines[lineIdx];
394
- regex.lastIndex = 0;
395
- let lineMatches = 0;
396
- let m: RegExpExecArray | null;
397
- while ((m = regex.exec(lineText)) !== null) {
398
- lineMatches++;
399
- if (m[0].length === 0) {
400
- regex.lastIndex++;
401
- if (regex.lastIndex > lineText.length) {
402
- break;
403
- }
404
- }
405
- }
406
- if (lineMatches > 0) {
407
- countInFile += lineMatches;
408
- regex.lastIndex = 0;
409
- if (isRegex) {
410
- newLines.push(lineText.replace(regex, replacement));
411
- } else {
412
- newLines.push(lineText.replace(regex, () => replacement));
413
- }
414
- } else {
415
- newLines.push(lineText);
416
- }
417
- }
418
-
419
- if (countInFile > 0) {
420
- updatedFiles[filePath] = newLines.join('\n');
421
- filesAffected.push(filePath);
422
- replacedCount += countInFile;
423
- }
424
- }
425
-
426
- return {
427
- updatedFiles,
428
- files: updatedFiles,
429
- replacedCount,
430
- filesAffected,
431
- filesModified: filesAffected.length
432
- };
433
- }