@innovatorved/code-lab 0.4.0 → 0.6.0

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 (82) hide show
  1. package/ARCHITECTURE.md +4 -4
  2. package/CHANGELOG.md +36 -0
  3. package/README.md +6 -30
  4. package/dist/code-lab-sql.esm.js +1 -1
  5. package/dist/code-lab-sql.umd.js +2 -2
  6. package/dist/code-lab.css +32 -5818
  7. package/dist/code-lab.d.ts +1 -1
  8. package/dist/code-lab.esm.js +4655 -64400
  9. package/dist/code-lab.js +4540 -64286
  10. package/dist/code-lab.umd.js +4540 -64286
  11. package/dist/diagnostics.d.ts +3 -0
  12. package/dist/extensions/cpp.d.ts +2 -2
  13. package/dist/extensions/cpp.esm.js +1804 -14725
  14. package/dist/extensions/cpp.js +1804 -14725
  15. package/dist/extensions/guided-lab.esm.js +2938 -16127
  16. package/dist/extensions/guided-lab.js +2938 -16127
  17. package/dist/extensions/python.d.ts +2 -2
  18. package/dist/extensions/python.esm.js +1765 -14698
  19. package/dist/extensions/python.js +1765 -14698
  20. package/dist/index.d.ts +1 -1
  21. package/dist/packages/settings/src/configuration-service.d.ts +7 -0
  22. package/dist/packages/settings/src/index.d.ts +1 -1
  23. package/dist/packages/ui/src/index.d.ts +2 -2
  24. package/dist/packages/ui/src/plugin-registry.d.ts +1 -0
  25. package/dist/packages/ui/src/settings-dialog.d.ts +31 -3
  26. package/dist/packages/ui/src/themes.d.ts +5 -0
  27. package/dist/preview-sw.js +4 -188
  28. package/dist/runtime.esm.js +109 -10284
  29. package/dist/runtime.js +107 -10284
  30. package/dist/schemas.d.ts +2 -2
  31. package/dist/schemas.esm.js +2938 -16127
  32. package/dist/schemas.js +2941 -16130
  33. package/dist/scm.d.ts +296 -14
  34. package/dist/shell.esm.js +811 -9178
  35. package/dist/shell.js +811 -9178
  36. package/dist/storage.d.ts +56 -0
  37. package/dist/terminal.esm.js +20 -1347
  38. package/dist/terminal.js +20 -1347
  39. package/dist/workbench/command-palette.d.ts +16 -1
  40. package/dist/workbench/diff-editor.d.ts +27 -1
  41. package/dist/workbench/icons.d.ts +6 -2
  42. package/dist/workbench/index.d.ts +33 -1
  43. package/dist/workbench/intellisense.d.ts +194 -0
  44. package/dist/workbench/styles.d.ts +1 -1
  45. package/dist/workbench/xterm-adapter.d.ts +122 -0
  46. package/package.json +8 -2
  47. package/packages/commands/package.json +1 -1
  48. package/packages/core/package.json +1 -1
  49. package/packages/editor/package.json +1 -1
  50. package/packages/fs/package.json +1 -1
  51. package/packages/preview/package.json +1 -1
  52. package/packages/runtime/package.json +1 -1
  53. package/packages/settings/package.json +1 -1
  54. package/packages/settings/src/builtin-schemas.ts +17 -6
  55. package/packages/settings/src/configuration-service.ts +72 -6
  56. package/packages/settings/src/index.ts +1 -0
  57. package/packages/sql/package.json +1 -1
  58. package/packages/terminal/package.json +1 -1
  59. package/packages/ui/package.json +1 -1
  60. package/packages/ui/src/index.ts +4 -0
  61. package/packages/ui/src/plugin-registry.ts +17 -2
  62. package/packages/ui/src/settings-dialog.ts +393 -99
  63. package/packages/ui/src/themes.ts +183 -24
  64. package/src/code-lab.css +2763 -444
  65. package/src/diagnostics.ts +139 -7
  66. package/src/extensions/cpp.ts +337 -71
  67. package/src/extensions/python.ts +375 -75
  68. package/src/index.ts +1 -1
  69. package/src/runtime.ts +272 -43
  70. package/src/schemas.ts +2 -2
  71. package/src/scm.ts +2172 -74
  72. package/src/shell.ts +1999 -193
  73. package/src/storage.ts +401 -5
  74. package/src/terminal.ts +148 -12
  75. package/src/workbench/command-palette.ts +289 -48
  76. package/src/workbench/diff-editor.ts +240 -78
  77. package/src/workbench/icons.ts +250 -46
  78. package/src/workbench/index.ts +7 -1
  79. package/src/workbench/intellisense.ts +1859 -0
  80. package/src/workbench/styles.ts +25 -19
  81. package/src/workbench/xterm-adapter.ts +1566 -0
  82. package/src/workbench.ts +13446 -3881
package/dist/scm.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * @innovatorved/code-lab — Interactive Git Source Control (SCM) Engine
3
3
  * ============================================================================
4
- * Pure TypeScript in-browser Git status, staging, unstaging, and commit engine
5
- * backed by workspace VFS state. Powers both the interactive Source Control UI
6
- * and shell/CLI Git operations.
4
+ * Browser-native Git engine combining synchronous deterministic VFS/SCM state
5
+ * with `isomorphic-git` `.git/` object-store synchronization, Myers O(ND)
6
+ * 3-line hunk diffs, `.gitignore` pattern matching, real branch file checkout,
7
+ * stash, reset (`--soft`/`--mixed`/`--hard` `HEAD~N`), merge, tags, show & blame.
7
8
  *
8
9
  * Strict leaf module: fully typed, zero explicit any, zero empty catches.
9
10
  */
11
+ import { init as isoInit, add as isoAdd, commit as isoCommit, currentBranch as isoCurrentBranch, listBranches as isoListBranches, log as isoLog } from 'isomorphic-git';
10
12
  export type GitFileChangeType = 'modified' | 'added' | 'deleted' | 'untracked';
11
13
  export interface GitFileStatus {
12
14
  path: string;
@@ -15,20 +17,81 @@ export interface GitFileStatus {
15
17
  oldContent?: string;
16
18
  newContent?: string;
17
19
  }
20
+ export interface GitStatLike {
21
+ size?: number;
22
+ mtimeMs?: number;
23
+ mode?: number;
24
+ isDirectory(): boolean;
25
+ isFile?(): boolean;
26
+ isSymbolicLink?(): boolean;
27
+ }
28
+ export interface GitVfsLike {
29
+ existsSync?(path: string): boolean;
30
+ statSync?(path: string): GitStatLike;
31
+ lstatSync?(path: string): GitStatLike;
32
+ readdirSync?(path: string): string[];
33
+ readFileSync?(path: string, encoding?: string): string | Uint8Array;
34
+ writeFileSync?(path: string, data: string | Uint8Array): void;
35
+ mkdirSync?(path: string, options?: {
36
+ recursive?: boolean;
37
+ }): unknown;
38
+ rmdirSync?(path: string, options?: {
39
+ recursive?: boolean;
40
+ }): void;
41
+ unlinkSync?(path: string): void;
42
+ rmSync?(path: string, options?: {
43
+ recursive?: boolean;
44
+ force?: boolean;
45
+ }): void;
46
+ symlinkSync?(target: string, path: string): void;
47
+ readlinkSync?(path: string): string;
48
+ files?: Map<string, unknown>;
49
+ }
50
+ export interface GitShellLike {
51
+ cwd?: string;
52
+ vfs?: GitVfsLike | null;
53
+ gitState?: GitState | null;
54
+ _emitVfsMutation?(type: string, absPath: string): void;
55
+ }
18
56
  export interface GitCommitRecord {
19
57
  hash: string;
20
58
  message: string;
21
59
  timestamp: number;
22
60
  author?: string;
23
- files: Record<string, string>;
61
+ date?: string;
62
+ files?: Record<string, string>;
63
+ parents?: string[];
64
+ }
65
+ export interface GitBranchTip {
66
+ headCommit: string;
67
+ headFiles: Record<string, string>;
68
+ commits: GitCommitRecord[];
69
+ }
70
+ export interface GitStashEntry {
71
+ id: number;
72
+ branch: string;
73
+ headCommit: string;
74
+ message: string;
75
+ timestamp: number;
76
+ worktreeFiles: Record<string, string>;
77
+ stagedEntries: Array<[string, string | null]>;
78
+ untrackedFiles: Record<string, string>;
24
79
  }
25
80
  export interface GitState {
81
+ initialized?: boolean;
82
+ repoRoot?: string;
26
83
  branch: string;
27
- branches?: string[];
84
+ branches?: string[] | Set<string>;
85
+ branchHeads?: Record<string, GitBranchTip>;
86
+ tags?: Record<string, string>;
87
+ stashes?: GitStashEntry[];
88
+ remoteUrl?: string | null;
89
+ remotes?: Record<string, string>;
28
90
  headCommit: string;
29
91
  headFiles: Record<string, string>;
30
92
  headSnapshot?: Record<string, string>;
31
93
  staged: Map<string, string | null> | Set<string>;
94
+ stagedFiles?: Map<string, string | null>;
32
95
  commits: GitCommitRecord[];
33
96
  }
34
97
  export interface GitStatusEntry {
@@ -50,39 +113,258 @@ export interface GitStatusResult {
50
113
  hasChanges: boolean;
51
114
  isClean: boolean;
52
115
  }
116
+ export interface CreateGitStateOptions {
117
+ initialized?: boolean;
118
+ repoRoot?: string;
119
+ }
120
+ export interface InitRepositoryOptions {
121
+ branch?: string;
122
+ repoRoot?: string;
123
+ snapshotExisting?: boolean;
124
+ initialFiles?: Record<string, string>;
125
+ }
126
+ export interface DiscardChangesOptions {
127
+ keepStaged?: boolean;
128
+ }
129
+ export interface DiffLineOp {
130
+ type: 'common' | 'added' | 'removed';
131
+ line: string;
132
+ oldLineNumber?: number;
133
+ newLineNumber?: number;
134
+ }
135
+ export interface GitGutterRange {
136
+ line: number;
137
+ endLine: number;
138
+ kind: 'added' | 'modified' | 'deleted';
139
+ }
140
+ export interface GitIgnoreRule {
141
+ negated: boolean;
142
+ dirOnly: boolean;
143
+ regex: RegExp;
144
+ }
145
+ export interface BlameLineEntry {
146
+ lineNumber: number;
147
+ hash: string;
148
+ author: string;
149
+ timestamp: number;
150
+ content: string;
151
+ }
53
152
  /**
54
153
  * Computes a deterministic 7-character short hash for a commit payload.
55
154
  */
56
155
  export declare function computeShortCommitHash(input: string): string;
57
156
  /**
58
- * Initializes a fresh in-memory Git repository state from initial VFS files.
157
+ * Compiles `.gitignore` text into ordered glob/negation match rules.
158
+ */
159
+ export declare function parseGitignoreRules(gitignoreContent: string | undefined): GitIgnoreRule[];
160
+ export declare function isIgnoredByRules(relPath: string, rules: ReadonlyArray<GitIgnoreRule>): boolean;
161
+ export declare function isIgnoredScmPath(relPath: string, gitignoreRules?: ReadonlyArray<GitIgnoreRule>): boolean;
162
+ export declare function normalizeScmRelPath(rawPath: string, repoRoot?: string): string;
163
+ export declare function isUnbornGitHead(gitState: GitState | null | undefined): boolean;
164
+ export declare function isEffectiveStagedChange(gitState: GitState | null | undefined, relPath: string, stagedVal: string | null | undefined, resolvedHeadFiles?: Record<string, string>): boolean;
165
+ /**
166
+ * Synchronizes `gitState.headFiles` and `gitState.headSnapshot` so both
167
+ * properties reference the exact same clean `Record<string, string>` object.
168
+ */
169
+ export declare function syncGitHead(gitState: GitState, nextHead?: Record<string, string>): Record<string, string>;
170
+ export declare function saveBranchTip(gitState: GitState, branchName?: string): void;
171
+ /**
172
+ * Initializes an in-memory Git repository state from initial VFS files,
173
+ * keeping `headFiles` / `headSnapshot` and `staged` / `stagedFiles` synchronized.
174
+ */
175
+ export declare function createGitState(initialFiles?: Record<string, string>, branch?: string, options?: CreateGitStateOptions): GitState;
176
+ export declare function readVfsTree(vfs: GitVfsLike, rootDir: string): Record<string, string>;
177
+ /**
178
+ * Initializes a Git repository on a `PosixShell` (writing `.git/HEAD` & `.git/config`)
179
+ * or directly on a `GitState` object. Defaults `snapshotExisting` to `false` so
180
+ * existing workspace files appear as untracked until staged and committed.
59
181
  */
60
- export declare function createGitState(initialFiles?: Record<string, string>, branch?: string): GitState;
182
+ export declare function initRepository(target: GitShellLike | GitState, options?: InitRepositoryOptions): GitState;
61
183
  /**
62
- * Computes working-tree and staging-area Git status against `gitState`.
63
- * Supports both `computeGitStatus(vfsFiles, repoRoot, gitState)` and
64
- * `computeGitStatus(gitState, vfsFiles)` calling conventions.
184
+ * Computes working-tree and staging-area Git status against `gitState`,
185
+ * honoring `.gitignore` rules for untracked files while keeping tracked files visible.
65
186
  */
66
187
  export declare function computeGitStatus(arg1: Record<string, string> | GitState, arg2?: string | Record<string, string>, gitState?: GitState): GitStatusResult;
67
188
  /**
68
189
  * Stages a file addition, modification, or deletion (`currentContent === null`).
69
190
  */
70
191
  export declare function stageFile(gitState: GitState, relativePath: string, currentContent: string | null): void;
192
+ /**
193
+ * Stages all modified, untracked (non-gitignored), and deleted tracked files.
194
+ */
195
+ export declare function stageAll(gitState: GitState, vfsFiles: Record<string, string>, repoRoot?: string): void;
71
196
  /**
72
197
  * Removes a file from the staging index.
73
198
  */
74
199
  export declare function unstageFile(gitState: GitState, relativePath: string): void;
75
200
  /**
76
- * Commits all staged changes to `gitState`, advancing `headCommit` and `headFiles`,
77
- * and clearing the staging area. Throws if message is empty or staging area is empty.
201
+ * Clears all staged entries from `gitState`.
202
+ */
203
+ export declare function unstageAll(gitState: GitState): void;
204
+ /**
205
+ * Commits all staged changes to `gitState`, advancing `headCommit`, updating
206
+ * `branchHeads[branch]`, synchronizing `headFiles` & `headSnapshot`, and clearing staging.
207
+ */
208
+ export declare function commitChanges(gitState: GitState, message: string, author?: string): string;
209
+ /**
210
+ * Discards working-tree changes for `filePath`.
211
+ * - When `options?.keepStaged === true` and `filePath` has a staged snapshot (`MM` / `AM`),
212
+ * restores the working tree to the staged index snapshot without unstaging!
213
+ * - Otherwise restores `headFiles[relPath]` (if tracked) or deletes the untracked file,
214
+ * and unstages `relPath`.
215
+ */
216
+ export declare function discardChanges(shell: GitShellLike, filePath: string, workspaceFiles?: Record<string, string>, options?: DiscardChangesOptions): boolean;
217
+ export declare function computeMyersDiffOps(oldText: string, newText: string): DiffLineOp[];
218
+ export declare function computeUnifiedHunkDiff(file1Name: string, file2Name: string, oldText: string, newText: string, contextLines?: number): string;
219
+ export declare function computeGitGutterChanges(headContent: string | undefined, liveContent: string): GitGutterRange[];
220
+ export interface CheckoutBranchOptions {
221
+ create?: boolean;
222
+ force?: boolean;
223
+ workspaceFiles?: Record<string, string>;
224
+ }
225
+ export declare function checkoutBranch(target: GitShellLike | GitState, branchName: string, options?: CheckoutBranchOptions): {
226
+ ok: boolean;
227
+ created: boolean;
228
+ error?: string;
229
+ };
230
+ export declare function resolveCommitRef(gitState: GitState, refSpec?: string): {
231
+ commit: GitCommitRecord | null;
232
+ index: number;
233
+ };
234
+ export declare function resetToRef(shell: GitShellLike, refSpec?: string, mode?: 'soft' | 'mixed' | 'hard', workspaceFiles?: Record<string, string>): {
235
+ ok: boolean;
236
+ headCommit: string;
237
+ message?: string;
238
+ error?: string;
239
+ };
240
+ export declare function stashPush(shell: GitShellLike, message?: string, includeUntracked?: boolean, workspaceFiles?: Record<string, string>): {
241
+ ok: boolean;
242
+ created: boolean;
243
+ label: string;
244
+ };
245
+ export declare function stashApply(shell: GitShellLike, stashIndex?: number, dropAfter?: boolean, workspaceFiles?: Record<string, string>): {
246
+ ok: boolean;
247
+ error?: string;
248
+ message?: string;
249
+ };
250
+ export declare function mergeBranch(shell: GitShellLike, sourceBranch: string, workspaceFiles?: Record<string, string>): {
251
+ ok: boolean;
252
+ fastForward: boolean;
253
+ conflicts: string[];
254
+ commitHash?: string;
255
+ message: string;
256
+ };
257
+ export declare function showCommit(gitState: GitState, refSpec?: string): {
258
+ ok: boolean;
259
+ output: string;
260
+ };
261
+ export declare function blameFile(gitState: GitState, relPath: string, liveContent?: string): {
262
+ ok: boolean;
263
+ entries: BlameLineEntry[];
264
+ output: string;
265
+ };
266
+ export declare function createIsoGitFsAdapter(vfs: GitVfsLike): {
267
+ promises: {
268
+ readFile: (p: string, opts?: {
269
+ encoding?: string;
270
+ } | string) => Promise<Uint8Array | string>;
271
+ writeFile: (p: string, data: Uint8Array | string) => Promise<void>;
272
+ unlink: (p: string) => Promise<void>;
273
+ readdir: (p: string) => Promise<string[]>;
274
+ mkdir: (p: string) => Promise<void>;
275
+ rmdir: (p: string) => Promise<void>;
276
+ stat: (p: string) => Promise<{
277
+ type: 'file' | 'dir';
278
+ mode: number;
279
+ size: number;
280
+ ino: number;
281
+ mtimeMs: number;
282
+ ctimeMs: number;
283
+ uid: number;
284
+ gid: number;
285
+ dev: number;
286
+ isFile: () => boolean;
287
+ isDirectory: () => boolean;
288
+ isSymbolicLink: () => boolean;
289
+ }>;
290
+ lstat: (p: string) => Promise<{
291
+ type: 'file' | 'dir';
292
+ mode: number;
293
+ size: number;
294
+ ino: number;
295
+ mtimeMs: number;
296
+ ctimeMs: number;
297
+ uid: number;
298
+ gid: number;
299
+ dev: number;
300
+ isFile: () => boolean;
301
+ isDirectory: () => boolean;
302
+ isSymbolicLink: () => boolean;
303
+ }>;
304
+ readlink: (p: string) => Promise<string>;
305
+ symlink: (target: string, p: string) => Promise<void>;
306
+ };
307
+ };
308
+ /**
309
+ * Mirrors `gitState` branch & HEAD state into a real `isomorphic-git` `.git/`
310
+ * directory inside `vfs` so real Git objects/refs/HEAD live on disk for IndexedDB persistence.
311
+ */
312
+ export declare function syncToIsoGitRepo(vfs: GitVfsLike, gitState: GitState): Promise<void>;
313
+ /**
314
+ * Hydrates a `GitState` from an existing `isomorphic-git` `.git/` object store
315
+ * in `vfs` (for example after restoring `.git/**` from IndexedDB).
78
316
  */
79
- export declare function commitChanges(gitState: GitState, message: string): string;
317
+ export declare function hydrateFromIsoGitRepo(vfs: GitVfsLike, repoRoot?: string): Promise<GitState | null>;
318
+ declare const isoGit: {
319
+ init: typeof isoInit;
320
+ add: typeof isoAdd;
321
+ commit: typeof isoCommit;
322
+ currentBranch: typeof isoCurrentBranch;
323
+ listBranches: typeof isoListBranches;
324
+ log: typeof isoLog;
325
+ };
326
+ export { isoGit };
80
327
  declare const _default: {
328
+ computeShortCommitHash: typeof computeShortCommitHash;
329
+ parseGitignoreRules: typeof parseGitignoreRules;
330
+ isIgnoredByRules: typeof isIgnoredByRules;
331
+ isIgnoredScmPath: typeof isIgnoredScmPath;
332
+ normalizeScmRelPath: typeof normalizeScmRelPath;
333
+ isUnbornGitHead: typeof isUnbornGitHead;
334
+ isEffectiveStagedChange: typeof isEffectiveStagedChange;
335
+ syncGitHead: typeof syncGitHead;
336
+ saveBranchTip: typeof saveBranchTip;
81
337
  createGitState: typeof createGitState;
338
+ readVfsTree: typeof readVfsTree;
339
+ initRepository: typeof initRepository;
82
340
  computeGitStatus: typeof computeGitStatus;
83
341
  stageFile: typeof stageFile;
342
+ stageAll: typeof stageAll;
84
343
  unstageFile: typeof unstageFile;
344
+ unstageAll: typeof unstageAll;
85
345
  commitChanges: typeof commitChanges;
86
- computeShortCommitHash: typeof computeShortCommitHash;
346
+ discardChanges: typeof discardChanges;
347
+ computeMyersDiffOps: typeof computeMyersDiffOps;
348
+ computeUnifiedHunkDiff: typeof computeUnifiedHunkDiff;
349
+ computeGitGutterChanges: typeof computeGitGutterChanges;
350
+ checkoutBranch: typeof checkoutBranch;
351
+ resolveCommitRef: typeof resolveCommitRef;
352
+ resetToRef: typeof resetToRef;
353
+ stashPush: typeof stashPush;
354
+ stashApply: typeof stashApply;
355
+ mergeBranch: typeof mergeBranch;
356
+ showCommit: typeof showCommit;
357
+ blameFile: typeof blameFile;
358
+ createIsoGitFsAdapter: typeof createIsoGitFsAdapter;
359
+ syncToIsoGitRepo: typeof syncToIsoGitRepo;
360
+ hydrateFromIsoGitRepo: typeof hydrateFromIsoGitRepo;
361
+ isoGit: {
362
+ init: typeof isoInit;
363
+ add: typeof isoAdd;
364
+ commit: typeof isoCommit;
365
+ currentBranch: typeof isoCurrentBranch;
366
+ listBranches: typeof isoListBranches;
367
+ log: typeof isoLog;
368
+ };
87
369
  };
88
370
  export default _default;