@innovatorved/code-lab 0.7.1 → 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.
- package/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +10 -0
- package/README.md +5 -5
- package/dist/code-lab-sql.esm.js +2 -2
- package/dist/code-lab-sql.umd.js +3 -3
- package/dist/code-lab.css +1 -1
- package/dist/code-lab.d.ts +47 -38
- package/dist/code-lab.esm.js +918 -884
- package/dist/code-lab.js +917 -881
- package/dist/extensions/cpp.esm.js +33 -33
- package/dist/extensions/cpp.js +33 -33
- package/dist/extensions/python.esm.js +79 -49
- package/dist/extensions/python.js +79 -49
- package/dist/index.d.ts +1 -1
- package/dist/logger.d.ts +4 -20
- package/dist/modular-kernel.d.ts +0 -1
- package/dist/packages/core/src/errors.d.ts +5 -1
- package/dist/packages/fs/src/backends.d.ts +0 -27
- package/dist/packages/fs/src/index.d.ts +1 -1
- package/dist/packages/ui/src/html.d.ts +1 -0
- package/dist/packages/ui/src/index.d.ts +1 -0
- package/dist/{apps/web/src/index.d.ts → packages/ui/src/kernel.d.ts} +3 -2
- package/dist/packages/ui/src/observability.d.ts +1 -1
- package/dist/packages/ui/src/settings-dialog.d.ts +0 -1
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.esm.js +2 -2
- package/dist/runtime.js +2 -2
- package/dist/schemas.d.ts +1 -1
- package/dist/shell.esm.js +277 -285
- package/dist/shell.js +277 -285
- package/dist/terminal.esm.js +2 -2
- package/dist/terminal.js +2 -2
- package/dist/workbench/editor.d.ts +0 -4
- package/dist/workbench/index.d.ts +0 -2
- package/dist/workbench/intellisense.d.ts +0 -1
- package/dist/workbench/xterm-adapter.d.ts +0 -1
- package/package.json +2 -4
- package/src/code-lab.css +0 -8086
- package/src/csp.ts +0 -590
- package/src/diagnostics.ts +0 -287
- package/src/extensions/cpp.ts +0 -2371
- package/src/extensions/guided-lab.ts +0 -68
- package/src/extensions/javascript.ts +0 -54
- package/src/extensions/python.ts +0 -1743
- package/src/extensions/typescript.ts +0 -85
- package/src/extensions/umbrella.ts +0 -5
- package/src/html.ts +0 -88
- package/src/index.ts +0 -129
- package/src/logger.ts +0 -139
- package/src/modular-kernel.ts +0 -7
- package/src/preview-sw.js +0 -296
- package/src/runtime/test-harness.ts +0 -57
- package/src/runtime.ts +0 -10565
- package/src/sample.html +0 -304
- package/src/schemas.ts +0 -366
- package/src/scm.ts +0 -2453
- package/src/search.ts +0 -433
- package/src/shell.ts +0 -10990
- package/src/storage.ts +0 -773
- package/src/terminal.ts +0 -1402
- package/src/workbench/command-palette.ts +0 -101
- package/src/workbench/diff-editor.ts +0 -472
- package/src/workbench/editor.ts +0 -49
- package/src/workbench/icons.ts +0 -255
- package/src/workbench/index.ts +0 -29
- package/src/workbench/intellisense.ts +0 -1884
- package/src/workbench/share.ts +0 -128
- package/src/workbench/xterm-adapter.ts +0 -1571
- package/src/workbench.ts +0 -21825
- package/src/zip.ts +0 -348
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript Language Extension for CodeLab
|
|
3
|
-
*
|
|
4
|
-
* Zero-dependency browser TypeScript extension powered by CodeLab's built-in
|
|
5
|
-
* `transpileTS` compiler and virtual Node.js / Bun runtime.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export interface TypeScriptExtensionOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Optional TypeScript workspace files (`tsFiles`).
|
|
11
|
-
*/
|
|
12
|
-
files?: Record<string, string>;
|
|
13
|
-
/**
|
|
14
|
-
* Optional Guided Lab TypeScript starter files (`tsStarterFiles`).
|
|
15
|
-
*/
|
|
16
|
-
starterFiles?: Record<string, string>;
|
|
17
|
-
/**
|
|
18
|
-
* Optional Guided Lab TypeScript reference solution files (`tsSolutionFiles`).
|
|
19
|
-
*/
|
|
20
|
-
solutionFiles?: Record<string, string>;
|
|
21
|
-
/**
|
|
22
|
-
* Optional entry file when TypeScript is active (e.g. 'src/demo.ts').
|
|
23
|
-
*/
|
|
24
|
-
entry?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Immediately switch the active workbench language to 'ts'.
|
|
27
|
-
*/
|
|
28
|
-
activate?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function typescriptExtension(workbench: any, options: TypeScriptExtensionOptions = {}) {
|
|
32
|
-
if (!workbench) return workbench;
|
|
33
|
-
|
|
34
|
-
if (!workbench.enabledLanguages || !(workbench.enabledLanguages instanceof Set)) {
|
|
35
|
-
workbench.enabledLanguages = new Set(['js', 'ts']);
|
|
36
|
-
} else {
|
|
37
|
-
workbench.enabledLanguages.add('ts');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (options.files && typeof options.files === 'object') {
|
|
41
|
-
workbench.tsFiles = { ...(workbench.tsFiles || {}), ...options.files };
|
|
42
|
-
if (workbench.guidedConfig) {
|
|
43
|
-
workbench.guidedConfig.tsFiles = { ...(workbench.guidedConfig.tsFiles || {}), ...options.files };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (options.starterFiles && typeof options.starterFiles === 'object') {
|
|
47
|
-
if (!workbench.guidedConfig) workbench.guidedConfig = {};
|
|
48
|
-
workbench.guidedConfig.tsStarterFiles = {
|
|
49
|
-
...(workbench.guidedConfig.tsStarterFiles || {}),
|
|
50
|
-
...options.starterFiles
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (options.solutionFiles && typeof options.solutionFiles === 'object') {
|
|
54
|
-
if (!workbench.guidedConfig) workbench.guidedConfig = {};
|
|
55
|
-
workbench.guidedConfig.tsSolutionFiles = {
|
|
56
|
-
...(workbench.guidedConfig.tsSolutionFiles || {}),
|
|
57
|
-
...options.solutionFiles
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
if (options.entry) {
|
|
61
|
-
workbench.tsEntry = options.entry;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
workbench.hasMultipleLanguages = workbench.enabledLanguages.size > 1;
|
|
65
|
-
|
|
66
|
-
if (options.activate && typeof workbench.setLanguage === 'function') {
|
|
67
|
-
workbench.setLanguage('ts');
|
|
68
|
-
} else if (typeof workbench._renderShell === 'function' && workbench.container) {
|
|
69
|
-
workbench._renderShell();
|
|
70
|
-
if (typeof workbench._bindEvents === 'function') workbench._bindEvents();
|
|
71
|
-
if (typeof workbench._renderFileLists === 'function') workbench._renderFileLists();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return workbench;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function createTypeScriptExtension(options: TypeScriptExtensionOptions = {}) {
|
|
78
|
-
const plugin = (workbench: any) => typescriptExtension(workbench, options);
|
|
79
|
-
plugin.extensionName = 'typescript';
|
|
80
|
-
plugin.languageId = 'ts' as const;
|
|
81
|
-
return plugin;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const tsExtension = typescriptExtension;
|
|
85
|
-
export default typescriptExtension;
|
package/src/html.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab — Safe HTML Tagged Template & Escaping Primitives
|
|
3
|
-
* ============================================================================
|
|
4
|
-
* Strict TypeScript leaf module. Every interpolated value in `html\`...\`` is
|
|
5
|
-
* HTML-escaped by default unless explicitly wrapped with `raw(...)` or
|
|
6
|
-
* produced by nested `html\`...\`` calls.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const SAFE_HTML_BRAND = Symbol.for('codelab.SafeHtml');
|
|
10
|
-
|
|
11
|
-
export interface SafeHtml {
|
|
12
|
-
readonly [SAFE_HTML_BRAND]: true;
|
|
13
|
-
readonly __html: string;
|
|
14
|
-
toString(): string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class SafeHtmlImpl implements SafeHtml {
|
|
18
|
-
readonly [SAFE_HTML_BRAND] = true as const;
|
|
19
|
-
readonly __html: string;
|
|
20
|
-
|
|
21
|
-
constructor(trusted: string) {
|
|
22
|
-
this.__html = String(trusted);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
toString(): string {
|
|
26
|
-
return this.__html;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function isSafeHtml(value: unknown): value is SafeHtml {
|
|
31
|
-
return Boolean(
|
|
32
|
-
value &&
|
|
33
|
-
typeof value === 'object' &&
|
|
34
|
-
(value as Record<symbol, unknown>)[SAFE_HTML_BRAND] === true &&
|
|
35
|
-
typeof (value as { __html?: unknown }).__html === 'string'
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function escapeHtml(value: unknown): string {
|
|
40
|
-
if (value === null || value === undefined) return '';
|
|
41
|
-
if (isSafeHtml(value)) return value.__html;
|
|
42
|
-
return String(value)
|
|
43
|
-
.replace(/&/g, '&')
|
|
44
|
-
.replace(/</g, '<')
|
|
45
|
-
.replace(/>/g, '>')
|
|
46
|
-
.replace(/"/g, '"')
|
|
47
|
-
.replace(/'/g, ''');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function raw(trustedHtml: string): SafeHtml {
|
|
51
|
-
return new SafeHtmlImpl(trustedHtml);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function renderInterpolation(value: unknown): string {
|
|
55
|
-
if (value === null || value === undefined || value === false) return '';
|
|
56
|
-
if (isSafeHtml(value)) return value.__html;
|
|
57
|
-
if (Array.isArray(value)) {
|
|
58
|
-
let out = '';
|
|
59
|
-
for (let i = 0; i < value.length; i++) {
|
|
60
|
-
out += renderInterpolation(value[i]);
|
|
61
|
-
}
|
|
62
|
-
return out;
|
|
63
|
-
}
|
|
64
|
-
return escapeHtml(value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function html(strings: TemplateStringsArray, ...values: unknown[]): SafeHtml {
|
|
68
|
-
let out = strings[0] ?? '';
|
|
69
|
-
for (let i = 0; i < values.length; i++) {
|
|
70
|
-
out += renderInterpolation(values[i]);
|
|
71
|
-
out += strings[i + 1] ?? '';
|
|
72
|
-
}
|
|
73
|
-
return new SafeHtmlImpl(out);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const _htmlNamespace = {
|
|
77
|
-
escapeHtml,
|
|
78
|
-
raw,
|
|
79
|
-
isSafeHtml,
|
|
80
|
-
html
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const _globalRoot = typeof globalThis !== 'undefined' ? (globalThis as Record<string, unknown>) : null;
|
|
84
|
-
if (_globalRoot && !_globalRoot.CodeLabHtml) {
|
|
85
|
-
_globalRoot.CodeLabHtml = _htmlNamespace;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default _htmlNamespace;
|
package/src/index.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab v0.7.0
|
|
3
|
-
* Browser-native IDE, POSIX Shell, Web Worker Node.js/Bun Runtime, WASI C++20 Toolchain, Python 3.12 WebAssembly, and Git Engine.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export * from './schemas';
|
|
7
|
-
export * from './logger';
|
|
8
|
-
export { type SafeHtml, isSafeHtml, raw, html } from './html';
|
|
9
|
-
export * from './csp';
|
|
10
|
-
export * from './zip';
|
|
11
|
-
export {
|
|
12
|
-
type StorageBackendType,
|
|
13
|
-
type ProjectSummary,
|
|
14
|
-
type WorkspaceStorageOptions,
|
|
15
|
-
WorkspaceStorage,
|
|
16
|
-
createWorkspaceStorage
|
|
17
|
-
} from './storage';
|
|
18
|
-
export {
|
|
19
|
-
type SearchMatchItem,
|
|
20
|
-
type SearchMatchGroup,
|
|
21
|
-
type SearchResult,
|
|
22
|
-
type ReplaceResult,
|
|
23
|
-
escapeRegex,
|
|
24
|
-
normalizeSearchPath,
|
|
25
|
-
matchesGlob,
|
|
26
|
-
searchInFiles,
|
|
27
|
-
replaceInFiles
|
|
28
|
-
} from './search';
|
|
29
|
-
export {
|
|
30
|
-
type DiagnosticListener,
|
|
31
|
-
DiagnosticsStore,
|
|
32
|
-
createDiagnosticsStore
|
|
33
|
-
} from './diagnostics';
|
|
34
|
-
export {
|
|
35
|
-
type GitCommitRecord,
|
|
36
|
-
type GitState,
|
|
37
|
-
type GitStatusResult,
|
|
38
|
-
computeShortCommitHash,
|
|
39
|
-
createGitState,
|
|
40
|
-
computeGitStatus,
|
|
41
|
-
stageFile,
|
|
42
|
-
unstageFile,
|
|
43
|
-
commitChanges
|
|
44
|
-
} from './scm';
|
|
45
|
-
export * from './runtime';
|
|
46
|
-
export {
|
|
47
|
-
createPosixShell,
|
|
48
|
-
cloneGitHubRepository,
|
|
49
|
-
parseGitHubRepoUrl,
|
|
50
|
-
CodeLabShell
|
|
51
|
-
} from './shell';
|
|
52
|
-
export * from './terminal';
|
|
53
|
-
export {
|
|
54
|
-
CodeLabWorkbench,
|
|
55
|
-
Workbench,
|
|
56
|
-
CodeLabElement,
|
|
57
|
-
CodeLab
|
|
58
|
-
} from './workbench';
|
|
59
|
-
export * from './workbench/index';
|
|
60
|
-
export { guidedLabExtension } from './extensions/guided-lab';
|
|
61
|
-
export {
|
|
62
|
-
type JavaScriptExtensionOptions,
|
|
63
|
-
javascriptExtension,
|
|
64
|
-
createJavaScriptExtension
|
|
65
|
-
} from './extensions/javascript';
|
|
66
|
-
export {
|
|
67
|
-
type TypeScriptExtensionOptions,
|
|
68
|
-
typescriptExtension,
|
|
69
|
-
createTypeScriptExtension
|
|
70
|
-
} from './extensions/typescript';
|
|
71
|
-
export {
|
|
72
|
-
type CppCompileOptions,
|
|
73
|
-
type CppCompileResult,
|
|
74
|
-
type CppCompilerAdapter,
|
|
75
|
-
type CppSymbolDoc,
|
|
76
|
-
DEFAULT_CPP_CDN_BASE_URL,
|
|
77
|
-
BUILTIN_CPP_HEADERS,
|
|
78
|
-
STANDARD_CPP20_HEADERS,
|
|
79
|
-
CPP_COMPLETIONS_AND_HOVERS,
|
|
80
|
-
extractTarToVfs,
|
|
81
|
-
createTarArchive,
|
|
82
|
-
seedCppHeadersIntoVfs,
|
|
83
|
-
parseCppCompilerFlags,
|
|
84
|
-
CppToolchainManager,
|
|
85
|
-
registerCppCompilerOnRuntime,
|
|
86
|
-
registerMonacoCppLanguageService,
|
|
87
|
-
analyzeCppSource,
|
|
88
|
-
applyClangStderrDiagnostics,
|
|
89
|
-
cppExtension,
|
|
90
|
-
createCppExtension
|
|
91
|
-
} from './extensions/cpp';
|
|
92
|
-
export {
|
|
93
|
-
type ExtendedPythonExtensionOptions,
|
|
94
|
-
type PythonCompileResult,
|
|
95
|
-
type PythonSymbolDoc,
|
|
96
|
-
DEFAULT_PYTHON_CDN_BASE_URL,
|
|
97
|
-
BUILTIN_PYTHON_MODULES,
|
|
98
|
-
PYTHON_COMPLETIONS_AND_HOVERS,
|
|
99
|
-
PythonToolchainManager,
|
|
100
|
-
seedPythonModulesIntoVfs,
|
|
101
|
-
registerPythonCompilerOnRuntime,
|
|
102
|
-
registerMonacoPythonLanguageService,
|
|
103
|
-
analyzePythonSource,
|
|
104
|
-
applyPythonTracebackDiagnostics,
|
|
105
|
-
formatPythonSource,
|
|
106
|
-
pythonExtension,
|
|
107
|
-
createPythonExtension
|
|
108
|
-
} from './extensions/python';
|
|
109
|
-
|
|
110
|
-
import { guidedLabExtension } from './extensions/guided-lab';
|
|
111
|
-
import { javascriptExtension } from './extensions/javascript';
|
|
112
|
-
import { typescriptExtension } from './extensions/typescript';
|
|
113
|
-
import { cppExtension } from './extensions/cpp';
|
|
114
|
-
import { pythonExtension } from './extensions/python';
|
|
115
|
-
|
|
116
|
-
declare const globalThis: any;
|
|
117
|
-
const root = typeof window !== 'undefined' ? window : (typeof globalThis !== 'undefined' ? globalThis : {});
|
|
118
|
-
|
|
119
|
-
// Attach extensions to CodeLab SDK
|
|
120
|
-
if (root.CodeLab) {
|
|
121
|
-
root.CodeLab.extensions = root.CodeLab.extensions || {};
|
|
122
|
-
root.CodeLab.extensions.guidedLab = guidedLabExtension;
|
|
123
|
-
root.CodeLab.extensions.javascript = javascriptExtension;
|
|
124
|
-
root.CodeLab.extensions.typescript = typescriptExtension;
|
|
125
|
-
root.CodeLab.extensions.cpp = cppExtension;
|
|
126
|
-
root.CodeLab.extensions.python = pythonExtension;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export default (root.CodeLab || {});
|
package/src/logger.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @innovatorved/code-lab — Shared Leveled Logger & Typed Error Hierarchy
|
|
3
|
-
* ============================================================================
|
|
4
|
-
* Bundled as `CodeLabLogger` into the runtime, shell, terminal, and workbench
|
|
5
|
-
* bundles so no subsystem needs empty `catch` blocks or ad-hoc console calls.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export const LOG_PREFIX = '[code-lab]';
|
|
9
|
-
|
|
10
|
-
export type CodeLabLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
11
|
-
|
|
12
|
-
export interface CodeLabLogSink {
|
|
13
|
-
debug?: (...args: unknown[]) => void;
|
|
14
|
-
info?: (...args: unknown[]) => void;
|
|
15
|
-
warn?: (...args: unknown[]) => void;
|
|
16
|
-
error?: (...args: unknown[]) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface CodeLabLoggerOptions {
|
|
20
|
-
logger?: CodeLabLogSink | null;
|
|
21
|
-
debug?: boolean;
|
|
22
|
-
prefix?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface CodeLabLogger {
|
|
26
|
-
debug: (...args: unknown[]) => void;
|
|
27
|
-
info: (...args: unknown[]) => void;
|
|
28
|
-
warn: (...args: unknown[]) => void;
|
|
29
|
-
error: (...args: unknown[]) => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type CodeLabErrorCode =
|
|
33
|
-
| 'E_SAVE'
|
|
34
|
-
| 'E_PERSISTENCE'
|
|
35
|
-
| 'E_INSTALL'
|
|
36
|
-
| 'E_PREVIEW'
|
|
37
|
-
| 'E_RUNTIME'
|
|
38
|
-
| 'E_SHELL'
|
|
39
|
-
| 'E_CLONE'
|
|
40
|
-
| 'E_CONFIG';
|
|
41
|
-
|
|
42
|
-
export interface CodeLabErrorOptions {
|
|
43
|
-
cause?: unknown;
|
|
44
|
-
recoverable?: boolean;
|
|
45
|
-
details?: Record<string, unknown>;
|
|
46
|
-
context?: Record<string, unknown>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Structured error surfaced through `wb.on('error', ...)` and `wb.on('save-state', ...)`.
|
|
51
|
-
*/
|
|
52
|
-
export class CodeLabError extends Error {
|
|
53
|
-
readonly code: CodeLabErrorCode;
|
|
54
|
-
readonly options: CodeLabErrorOptions;
|
|
55
|
-
override readonly cause?: unknown;
|
|
56
|
-
readonly recoverable: boolean;
|
|
57
|
-
readonly details?: Record<string, unknown>;
|
|
58
|
-
readonly context?: Record<string, unknown>;
|
|
59
|
-
|
|
60
|
-
constructor(code: CodeLabErrorCode, message: string, options: CodeLabErrorOptions = {}) {
|
|
61
|
-
super(message);
|
|
62
|
-
this.name = 'CodeLabError';
|
|
63
|
-
this.code = code;
|
|
64
|
-
this.options = options;
|
|
65
|
-
this.cause = options.cause;
|
|
66
|
-
this.recoverable = options.recoverable !== false;
|
|
67
|
-
const meta = options.details ?? options.context;
|
|
68
|
-
if (meta !== undefined) {
|
|
69
|
-
this.details = meta;
|
|
70
|
-
this.context = meta;
|
|
71
|
-
}
|
|
72
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function isCodeLabError(value: unknown): value is CodeLabError {
|
|
77
|
-
return Boolean(
|
|
78
|
-
value &&
|
|
79
|
-
typeof value === 'object' &&
|
|
80
|
-
(value instanceof CodeLabError ||
|
|
81
|
-
((value as { name?: unknown }).name === 'CodeLabError' &&
|
|
82
|
-
typeof (value as { code?: unknown }).code === 'string'))
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Small leveled logger. Hosts can pass `options.logger` to route diagnostics
|
|
88
|
-
* into their own telemetry; `options.debug` enables verbose output. Errors and
|
|
89
|
-
* warnings are never silently discarded.
|
|
90
|
-
*/
|
|
91
|
-
export function createLogger(options: CodeLabLoggerOptions = {}): CodeLabLogger {
|
|
92
|
-
const sink = options.logger ?? null;
|
|
93
|
-
const debugEnabled = options.debug === true;
|
|
94
|
-
const prefix = options.prefix || LOG_PREFIX;
|
|
95
|
-
|
|
96
|
-
const write = (level: CodeLabLogLevel, args: unknown[]): void => {
|
|
97
|
-
if (level === 'debug' && !debugEnabled) return;
|
|
98
|
-
if (sink && typeof sink[level] === 'function') {
|
|
99
|
-
let sinkError: unknown = null;
|
|
100
|
-
try {
|
|
101
|
-
(sink[level] as (...a: unknown[]) => void)(...args);
|
|
102
|
-
return;
|
|
103
|
-
} catch (err) {
|
|
104
|
-
// A broken host logger must not break the IDE; fall through to console.
|
|
105
|
-
sinkError = err;
|
|
106
|
-
}
|
|
107
|
-
void sinkError;
|
|
108
|
-
}
|
|
109
|
-
const consoleObj = typeof console !== 'undefined' ? console : null;
|
|
110
|
-
const fn = consoleObj ? consoleObj[level] : null;
|
|
111
|
-
if (typeof fn === 'function') {
|
|
112
|
-
fn.call(consoleObj, prefix, ...args);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
debug: (...args: unknown[]) => write('debug', args),
|
|
118
|
-
info: (...args: unknown[]) => write('info', args),
|
|
119
|
-
warn: (...args: unknown[]) => write('warn', args),
|
|
120
|
-
error: (...args: unknown[]) => write('error', args)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export const DEFAULT_LOGGER: CodeLabLogger = createLogger();
|
|
125
|
-
|
|
126
|
-
const _loggerNamespace = {
|
|
127
|
-
LOG_PREFIX,
|
|
128
|
-
CodeLabError,
|
|
129
|
-
isCodeLabError,
|
|
130
|
-
createLogger,
|
|
131
|
-
DEFAULT_LOGGER
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const _globalRoot = typeof globalThis !== 'undefined' ? (globalThis as Record<string, unknown>) : null;
|
|
135
|
-
if (_globalRoot && !_globalRoot.CodeLabLogger) {
|
|
136
|
-
_globalRoot.CodeLabLogger = _loggerNamespace;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export default _loggerNamespace;
|
package/src/modular-kernel.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from '../packages/core/src/index';
|
|
2
|
-
export * from '../packages/fs/src/index';
|
|
3
|
-
export * from '../packages/settings/src/index';
|
|
4
|
-
export * from '../packages/commands/src/index';
|
|
5
|
-
export * from '../packages/sql/src/index';
|
|
6
|
-
export * from '../packages/ui/src/index';
|
|
7
|
-
export * from '../apps/web/src/index';
|