@innovatorved/code-lab 0.7.0 → 0.7.1

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 (129) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +20 -0
  3. package/README.md +2 -2
  4. package/dist/apps/web/src/index.d.ts +0 -9
  5. package/dist/code-lab-sql.esm.js +19 -19
  6. package/dist/code-lab-sql.umd.js +20 -20
  7. package/dist/code-lab.css +1 -1
  8. package/dist/code-lab.d.ts +1 -1
  9. package/dist/code-lab.esm.js +679 -1439
  10. package/dist/code-lab.js +678 -1438
  11. package/dist/extensions/cpp.esm.js +132 -8760
  12. package/dist/extensions/cpp.js +124 -8770
  13. package/dist/extensions/guided-lab.esm.js +33 -6836
  14. package/dist/extensions/guided-lab.js +33 -6854
  15. package/dist/extensions/javascript.esm.js +1 -36
  16. package/dist/extensions/javascript.js +1 -58
  17. package/dist/extensions/python.esm.js +79 -8118
  18. package/dist/extensions/python.js +79 -8136
  19. package/dist/extensions/typescript.esm.js +1 -55
  20. package/dist/extensions/typescript.js +1 -77
  21. package/dist/modular-kernel.d.ts +0 -4
  22. package/dist/preview-sw.js +1 -1
  23. package/dist/runtime.esm.js +77 -77
  24. package/dist/runtime.js +77 -77
  25. package/dist/schemas.d.ts +9 -0
  26. package/dist/schemas.esm.js +33 -6815
  27. package/dist/schemas.js +33 -6831
  28. package/dist/shell.esm.js +33 -33
  29. package/dist/shell.js +33 -33
  30. package/dist/terminal.esm.js +8 -6
  31. package/dist/terminal.js +6 -6
  32. package/dist/workbench/command-palette.d.ts +0 -4
  33. package/dist/workbench/index.d.ts +0 -20
  34. package/dist/workbench/intellisense.d.ts +1 -7
  35. package/package.json +3 -10
  36. package/src/code-lab.css +4 -502
  37. package/src/extensions/cpp.ts +11 -29
  38. package/src/extensions/guided-lab.ts +6 -2
  39. package/src/extensions/python.ts +9 -3
  40. package/src/modular-kernel.ts +0 -4
  41. package/src/runtime.ts +124 -39
  42. package/src/schemas.ts +2 -2
  43. package/src/shell.ts +3 -0
  44. package/src/terminal.ts +4 -2
  45. package/src/workbench/command-palette.ts +22 -302
  46. package/src/workbench/diff-editor.ts +2 -0
  47. package/src/workbench/icons.ts +1 -1
  48. package/src/workbench/index.ts +0 -15
  49. package/src/workbench/intellisense.ts +17 -4
  50. package/src/workbench.ts +68 -375
  51. package/dist/code-lab.umd.js +0 -6117
  52. package/dist/packages/editor/src/index.d.ts +0 -118
  53. package/dist/packages/preview/src/index.d.ts +0 -34
  54. package/dist/packages/runtime/src/index.d.ts +0 -47
  55. package/dist/packages/terminal/src/index.d.ts +0 -54
  56. package/dist/workbench/drawer.d.ts +0 -18
  57. package/dist/workbench/file-tree.d.ts +0 -11
  58. package/dist/workbench/guided-pane.d.ts +0 -11
  59. package/dist/workbench/styles.d.ts +0 -4
  60. package/dist/workbench/toolbar.d.ts +0 -17
  61. package/packages/commands/README.md +0 -7
  62. package/packages/commands/package.json +0 -16
  63. package/packages/commands/src/index.ts +0 -467
  64. package/packages/commands/tsconfig.json +0 -22
  65. package/packages/core/README.md +0 -12
  66. package/packages/core/package.json +0 -13
  67. package/packages/core/src/di.ts +0 -147
  68. package/packages/core/src/disposable.ts +0 -112
  69. package/packages/core/src/errors.ts +0 -205
  70. package/packages/core/src/events.ts +0 -157
  71. package/packages/core/src/index.ts +0 -49
  72. package/packages/core/src/path.ts +0 -118
  73. package/packages/core/src/registry.ts +0 -61
  74. package/packages/core/tsconfig.json +0 -19
  75. package/packages/editor/README.md +0 -9
  76. package/packages/editor/package.json +0 -18
  77. package/packages/editor/src/index.ts +0 -344
  78. package/packages/editor/tsconfig.json +0 -24
  79. package/packages/fs/README.md +0 -7
  80. package/packages/fs/package.json +0 -16
  81. package/packages/fs/src/backends.ts +0 -301
  82. package/packages/fs/src/index.ts +0 -18
  83. package/packages/fs/src/types.ts +0 -44
  84. package/packages/fs/src/vfs-service.ts +0 -257
  85. package/packages/fs/tsconfig.json +0 -22
  86. package/packages/preview/README.md +0 -3
  87. package/packages/preview/package.json +0 -16
  88. package/packages/preview/src/index.ts +0 -125
  89. package/packages/preview/tsconfig.json +0 -22
  90. package/packages/runtime/README.md +0 -3
  91. package/packages/runtime/package.json +0 -17
  92. package/packages/runtime/src/index.ts +0 -134
  93. package/packages/runtime/tsconfig.json +0 -23
  94. package/packages/settings/README.md +0 -7
  95. package/packages/settings/package.json +0 -16
  96. package/packages/settings/src/builtin-schemas.ts +0 -262
  97. package/packages/settings/src/configuration-service.ts +0 -609
  98. package/packages/settings/src/index.ts +0 -38
  99. package/packages/settings/src/jsonc.ts +0 -189
  100. package/packages/settings/src/schema.ts +0 -164
  101. package/packages/settings/tsconfig.json +0 -22
  102. package/packages/sql/README.md +0 -12
  103. package/packages/sql/package.json +0 -13
  104. package/packages/sql/src/completions.ts +0 -359
  105. package/packages/sql/src/diagnostics.ts +0 -200
  106. package/packages/sql/src/formatter.ts +0 -271
  107. package/packages/sql/src/index.ts +0 -54
  108. package/packages/sql/src/sql-editor.ts +0 -802
  109. package/packages/sql/src/styles.ts +0 -524
  110. package/packages/sql/src/tokenizer.ts +0 -457
  111. package/packages/sql/src/types.ts +0 -148
  112. package/packages/sql/tsconfig.json +0 -19
  113. package/packages/terminal/README.md +0 -3
  114. package/packages/terminal/package.json +0 -16
  115. package/packages/terminal/src/index.ts +0 -183
  116. package/packages/terminal/tsconfig.json +0 -22
  117. package/packages/ui/README.md +0 -8
  118. package/packages/ui/package.json +0 -18
  119. package/packages/ui/src/index.ts +0 -40
  120. package/packages/ui/src/observability.ts +0 -173
  121. package/packages/ui/src/plugin-registry.ts +0 -289
  122. package/packages/ui/src/settings-dialog.ts +0 -939
  123. package/packages/ui/src/themes.ts +0 -333
  124. package/packages/ui/tsconfig.json +0 -24
  125. package/src/workbench/drawer.ts +0 -157
  126. package/src/workbench/file-tree.ts +0 -51
  127. package/src/workbench/guided-pane.ts +0 -43
  128. package/src/workbench/styles.ts +0 -211
  129. package/src/workbench/toolbar.ts +0 -182
@@ -1,189 +0,0 @@
1
- /**
2
- * @code-lab/settings — Resilient JSON with Comments (JSONC) parser.
3
- * Supports `//` line comments, `/* ... * /` block comments, and trailing commas,
4
- * returning structured 1-based line/column diagnostics instead of throwing.
5
- */
6
-
7
- export interface JsoncParseError {
8
- readonly message: string;
9
- readonly offset: number;
10
- readonly line: number;
11
- readonly column: number;
12
- }
13
-
14
- export interface JsoncParseResult<T = unknown> {
15
- readonly value: T | undefined;
16
- readonly errors: readonly JsoncParseError[];
17
- }
18
-
19
- function offsetToLineCol(text: string, offset: number): { line: number; column: number } {
20
- let line = 1;
21
- let col = 1;
22
- const limit = Math.min(Math.max(0, offset), text.length);
23
- for (let i = 0; i < limit; i++) {
24
- if (text[i] === '\n') {
25
- line++;
26
- col = 1;
27
- } else {
28
- col++;
29
- }
30
- }
31
- return { line, column: col };
32
- }
33
-
34
- export function stripJsonCommentsAndTrailingCommas(input: string): {
35
- cleaned: string;
36
- errors: JsoncParseError[];
37
- } {
38
- const errors: JsoncParseError[] = [];
39
- const chars: string[] = [];
40
- let i = 0;
41
- const len = input.length;
42
-
43
- while (i < len) {
44
- const ch = input[i];
45
- const next = input[i + 1];
46
-
47
- // String literal — preserve verbatim (handling escapes)
48
- if (ch === '"') {
49
- const start = i;
50
- chars.push(ch);
51
- i++;
52
- let closed = false;
53
- while (i < len) {
54
- const c = input[i];
55
- if (c === '\\') {
56
- chars.push(c);
57
- if (i + 1 < len) {
58
- chars.push(input[i + 1]);
59
- i += 2;
60
- } else {
61
- i++;
62
- }
63
- continue;
64
- }
65
- chars.push(c);
66
- i++;
67
- if (c === '"') {
68
- closed = true;
69
- break;
70
- }
71
- if (c === '\n' || c === '\r') {
72
- break;
73
- }
74
- }
75
- if (!closed) {
76
- const lc = offsetToLineCol(input, start);
77
- errors.push({
78
- message: 'Unterminated string literal in JSONC',
79
- offset: start,
80
- line: lc.line,
81
- column: lc.column
82
- });
83
- }
84
- continue;
85
- }
86
-
87
- // Line comment //
88
- if (ch === '/' && next === '/') {
89
- chars.push(' ', ' ');
90
- i += 2;
91
- while (i < len && input[i] !== '\n') {
92
- chars.push(input[i] === '\r' ? '\r' : ' ');
93
- i++;
94
- }
95
- continue;
96
- }
97
-
98
- // Block comment /* ... */
99
- if (ch === '/' && next === '*') {
100
- const start = i;
101
- chars.push(' ', ' ');
102
- i += 2;
103
- let closed = false;
104
- while (i < len) {
105
- if (input[i] === '*' && input[i + 1] === '/') {
106
- chars.push(' ', ' ');
107
- i += 2;
108
- closed = true;
109
- break;
110
- }
111
- chars.push(input[i] === '\n' ? '\n' : input[i] === '\r' ? '\r' : ' ');
112
- i++;
113
- }
114
- if (!closed) {
115
- const lc = offsetToLineCol(input, start);
116
- errors.push({
117
- message: 'Unterminated block comment in JSONC',
118
- offset: start,
119
- line: lc.line,
120
- column: lc.column
121
- });
122
- }
123
- continue;
124
- }
125
-
126
- chars.push(ch);
127
- i++;
128
- }
129
-
130
- // Second pass: replace trailing commas before `}` or `]` with spaces (preserving offsets)
131
- for (let idx = 0; idx < chars.length; idx++) {
132
- if (chars[idx] === '"') {
133
- idx++;
134
- while (idx < chars.length) {
135
- if (chars[idx] === '\\') {
136
- idx += 2;
137
- continue;
138
- }
139
- if (chars[idx] === '"') break;
140
- idx++;
141
- }
142
- continue;
143
- }
144
- if (chars[idx] === ',') {
145
- let look = idx + 1;
146
- while (look < chars.length && /\s/.test(chars[look])) {
147
- look++;
148
- }
149
- if (look < chars.length && (chars[look] === '}' || chars[look] === ']')) {
150
- chars[idx] = ' ';
151
- }
152
- }
153
- }
154
-
155
- return { cleaned: chars.join(''), errors };
156
- }
157
-
158
- export function parseJsonc<T = unknown>(raw: string): JsoncParseResult<T> {
159
- if (!raw || !raw.trim()) {
160
- return { value: undefined, errors: [] };
161
- }
162
- const { cleaned, errors } = stripJsonCommentsAndTrailingCommas(raw);
163
- try {
164
- const parsed = JSON.parse(cleaned) as T;
165
- return { value: parsed, errors };
166
- } catch (err) {
167
- const msg = err instanceof Error ? err.message : String(err);
168
- const posMatch = /position\s+(\d+)/i.exec(msg);
169
- const lineColMatch = /line\s+(\d+)\s+column\s+(\d+)/i.exec(msg);
170
- const offset = posMatch ? Number(posMatch[1]) : 0;
171
- const lc = posMatch
172
- ? offsetToLineCol(raw, offset)
173
- : lineColMatch
174
- ? { line: Number(lineColMatch[1]), column: Number(lineColMatch[2]) }
175
- : offsetToLineCol(raw, raw.length);
176
- return {
177
- value: undefined,
178
- errors: [
179
- ...errors,
180
- {
181
- message: msg,
182
- offset,
183
- line: lc.line,
184
- column: lc.column
185
- }
186
- ]
187
- };
188
- }
189
- }
@@ -1,164 +0,0 @@
1
- /**
2
- * @code-lab/settings — CSP-safe zero-dependency JSON Schema (Draft-07 subset) validator.
3
- * Never uses `new Function` or `eval`.
4
- */
5
-
6
- export type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
7
-
8
- export interface JsonSchema {
9
- readonly $schema?: string;
10
- readonly title?: string;
11
- readonly description?: string;
12
- readonly type?: JsonSchemaType | readonly JsonSchemaType[];
13
- readonly enum?: readonly unknown[];
14
- readonly default?: unknown;
15
- readonly minimum?: number;
16
- readonly maximum?: number;
17
- readonly minLength?: number;
18
- readonly maxLength?: number;
19
- readonly pattern?: string;
20
- readonly items?: JsonSchema;
21
- readonly properties?: Readonly<Record<string, JsonSchema>>;
22
- readonly required?: readonly string[];
23
- readonly additionalProperties?: boolean | JsonSchema;
24
- }
25
-
26
- export interface SchemaValidationIssue {
27
- readonly path: string;
28
- readonly message: string;
29
- readonly expected?: string;
30
- }
31
-
32
- function matchesSingleType(value: unknown, expected: JsonSchemaType): boolean {
33
- switch (expected) {
34
- case 'null':
35
- return value === null;
36
- case 'boolean':
37
- return typeof value === 'boolean';
38
- case 'string':
39
- return typeof value === 'string';
40
- case 'number':
41
- return typeof value === 'number' && Number.isFinite(value);
42
- case 'integer':
43
- return typeof value === 'number' && Number.isInteger(value);
44
- case 'array':
45
- return Array.isArray(value);
46
- case 'object':
47
- return typeof value === 'object' && value !== null && !Array.isArray(value);
48
- }
49
- }
50
-
51
- export function validateJsonSchema(
52
- value: unknown,
53
- schema: JsonSchema,
54
- path = '$'
55
- ): SchemaValidationIssue[] {
56
- const issues: SchemaValidationIssue[] = [];
57
-
58
- if (schema.type !== undefined) {
59
- const allowed = Array.isArray(schema.type) ? schema.type : [schema.type];
60
- const ok = allowed.some((t) => matchesSingleType(value, t as JsonSchemaType));
61
- if (!ok) {
62
- issues.push({
63
- path,
64
- message: `Expected type ${allowed.join(' | ')}, received ${value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value}`,
65
- expected: allowed.join(' | ')
66
- });
67
- return issues;
68
- }
69
- }
70
-
71
- if (schema.enum !== undefined) {
72
- const matched = schema.enum.some((candidate) => Object.is(candidate, value));
73
- if (!matched) {
74
- const formatted = schema.enum.map((v) => JSON.stringify(v)).join(', ');
75
- issues.push({
76
- path,
77
- message: `Value ${JSON.stringify(value)} must be one of: ${formatted}`,
78
- expected: formatted
79
- });
80
- }
81
- }
82
-
83
- if (typeof value === 'number') {
84
- if (schema.minimum !== undefined && value < schema.minimum) {
85
- issues.push({
86
- path,
87
- message: `Value ${value} is less than minimum ${schema.minimum}`,
88
- expected: `>= ${schema.minimum}`
89
- });
90
- }
91
- if (schema.maximum !== undefined && value > schema.maximum) {
92
- issues.push({
93
- path,
94
- message: `Value ${value} exceeds maximum ${schema.maximum}`,
95
- expected: `<= ${schema.maximum}`
96
- });
97
- }
98
- }
99
-
100
- if (typeof value === 'string') {
101
- if (schema.minLength !== undefined && value.length < schema.minLength) {
102
- issues.push({
103
- path,
104
- message: `String length ${value.length} is shorter than minLength ${schema.minLength}`
105
- });
106
- }
107
- if (schema.maxLength !== undefined && value.length > schema.maxLength) {
108
- issues.push({
109
- path,
110
- message: `String length ${value.length} exceeds maxLength ${schema.maxLength}`
111
- });
112
- }
113
- if (schema.pattern !== undefined) {
114
- try {
115
- if (!new RegExp(schema.pattern).test(value)) {
116
- issues.push({
117
- path,
118
- message: `String does not match pattern /${schema.pattern}/`
119
- });
120
- }
121
- } catch (err) {
122
- issues.push({
123
- path,
124
- message: `Invalid schema pattern /${schema.pattern}/: ${err instanceof Error ? err.message : String(err)}`
125
- });
126
- }
127
- }
128
- }
129
-
130
- if (Array.isArray(value) && schema.items) {
131
- for (let i = 0; i < value.length; i++) {
132
- issues.push(...validateJsonSchema(value[i], schema.items, `${path}[${i}]`));
133
- }
134
- }
135
-
136
- if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
137
- const record = value as Record<string, unknown>;
138
- if (schema.required) {
139
- for (const reqKey of schema.required) {
140
- if (!(reqKey in record) || record[reqKey] === undefined) {
141
- issues.push({
142
- path: `${path}.${reqKey}`,
143
- message: `Missing required property "${reqKey}"`
144
- });
145
- }
146
- }
147
- }
148
- for (const [k, propVal] of Object.entries(record)) {
149
- const propSchema = schema.properties?.[k];
150
- if (propSchema) {
151
- issues.push(...validateJsonSchema(propVal, propSchema, `${path}.${k}`));
152
- } else if (schema.additionalProperties === false) {
153
- issues.push({
154
- path: `${path}.${k}`,
155
- message: `Unknown property "${k}" is not allowed`
156
- });
157
- } else if (typeof schema.additionalProperties === 'object' && schema.additionalProperties !== null) {
158
- issues.push(...validateJsonSchema(propVal, schema.additionalProperties, `${path}.${k}`));
159
- }
160
- }
161
- }
162
-
163
- return issues;
164
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022"],
7
- "strict": true,
8
- "noImplicitAny": true,
9
- "strictNullChecks": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "noImplicitReturns": true,
13
- "noFallthroughCasesInSwitch": true,
14
- "noEmit": true,
15
- "skipLibCheck": true,
16
- "forceConsistentCasingInFileNames": true,
17
- "paths": {
18
- "@code-lab/core": ["../core/src/index.ts"]
19
- }
20
- },
21
- "include": ["src/**/*.ts"]
22
- }
@@ -1,12 +0,0 @@
1
- # `@code-lab/sql` (`@innovatorved/code-lab/sql`)
2
-
3
- Zero-dependency lightweight SQL playground & inline editor (`< 35 KB` gzipped JS + CSS combined, zero WASM boot of its own) built for **PostgreSQL 18** and **SQLite 3**.
4
-
5
- ## Features
6
-
7
- - **Chrome Modes**: `'inline'` (compact auto-height lesson blocks, safe for 5+ mounts per page) and `'playground'` (responsive split pane stacking `< 768px`, `>= 16px` touch font size on `pointer: coarse` devices).
8
- - **Dialect Language Pack**: PostgreSQL 18 (`::type`, `$1`, `$$` dollar quotes, `ILIKE`, `LATERAL`, `RETURNING`, `FILTER`, JSONB `->`/`->>`/`@>`) and SQLite 3 (`PRAGMA`, `WITHOUT ROWID`, `ON CONFLICT DO UPDATE`, `GLOB`, backtick/bracket identifiers).
9
- - **Zero-Dep Formatter**: `formatSql(sql, { dialect, indent: 2, keywordCase: 'upper' })`.
10
- - **Schema-Aware Alias Autocomplete**: Resolves `FROM customers c JOIN orders o` so typing `o.` suggests `orders` columns with `type`, `PK`, and `FK→...` badges.
11
- - **Inline Error Diagnostics**: `parseSqlEngineError(err, sql, dialect)` + `setDiagnostics()` renders wavy token underlines, gutter dots, and `aria-describedby` / `aria-invalid` status banners.
12
- - **WCAG 2.1 AA Keyboard Navigation**: `Esc` toggles `Tab moves focus` mode (zero keyboard trap) + IME-safe `Enter` handling.
@@ -1,13 +0,0 @@
1
- {
2
- "name": "@code-lab/sql",
3
- "version": "0.7.0",
4
- "description": "Zero-dependency lightweight SQL editor & PostgreSQL 18 / SQLite 3 language pack (<35 KB gzipped) with schema-aware alias autocomplete, formatter, and inline error diagnostics.",
5
- "type": "module",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts"
10
- },
11
- "sideEffects": false,
12
- "license": "MIT"
13
- }