@innovatorved/code-lab 0.1.1 → 0.1.3
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/dist/code-lab.css +78 -31
- package/dist/code-lab.d.ts +1 -0
- package/dist/code-lab.esm.js +226 -93
- package/dist/code-lab.js +226 -93
- package/dist/shell.esm.js +38 -8
- package/dist/shell.js +38 -8
- package/package.json +1 -1
- package/src/code-lab.css +78 -31
- package/src/shell.js +38 -8
- package/src/shell.ts +38 -8
- package/src/workbench.js +188 -85
- package/src/workbench.ts +188 -85
package/dist/shell.esm.js
CHANGED
|
@@ -2027,6 +2027,16 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2027
2027
|
const requestedBranch = options.branch || parsed.branch || null;
|
|
2028
2028
|
const { owner, repo } = parsed;
|
|
2029
2029
|
|
|
2030
|
+
const signal = options.signal || null;
|
|
2031
|
+
const throwIfAborted = () => {
|
|
2032
|
+
if (signal && signal.aborted) {
|
|
2033
|
+
const abortErr = new Error('fatal: clone cancelled (SIGINT)');
|
|
2034
|
+
abortErr.name = 'AbortError';
|
|
2035
|
+
throw abortErr;
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
throwIfAborted();
|
|
2039
|
+
|
|
2030
2040
|
let resolvedBranch = requestedBranch;
|
|
2031
2041
|
let rawTreeEntries = null;
|
|
2032
2042
|
let repoNotFound = false;
|
|
@@ -2039,7 +2049,8 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2039
2049
|
try {
|
|
2040
2050
|
if (!resolvedBranch) {
|
|
2041
2051
|
const metaRes = await fetchFn(`https://api.github.com/repos/${owner}/${repo}`, {
|
|
2042
|
-
headers: { Accept: 'application/vnd.github.v3+json' }
|
|
2052
|
+
headers: { Accept: 'application/vnd.github.v3+json' },
|
|
2053
|
+
signal
|
|
2043
2054
|
});
|
|
2044
2055
|
if (metaRes.status === 404) {
|
|
2045
2056
|
repoNotFound = true;
|
|
@@ -2057,9 +2068,10 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2057
2068
|
: Array.from(new Set([resolvedBranch, 'main', 'master'].filter(Boolean)));
|
|
2058
2069
|
|
|
2059
2070
|
for (const cand of branchCandidates) {
|
|
2071
|
+
throwIfAborted();
|
|
2060
2072
|
const treeRes = await fetchFn(
|
|
2061
2073
|
`https://api.github.com/repos/${owner}/${repo}/git/trees/${encodeURIComponent(cand)}?recursive=1`,
|
|
2062
|
-
{ headers: { Accept: 'application/vnd.github.v3+json' } }
|
|
2074
|
+
{ headers: { Accept: 'application/vnd.github.v3+json' }, signal }
|
|
2063
2075
|
);
|
|
2064
2076
|
if (treeRes.ok) {
|
|
2065
2077
|
const treeJson = await treeRes.json();
|
|
@@ -2085,8 +2097,10 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2085
2097
|
: Array.from(new Set([resolvedBranch, 'main', 'master'].filter(Boolean)));
|
|
2086
2098
|
|
|
2087
2099
|
for (const cand of branchCandidates) {
|
|
2100
|
+
throwIfAborted();
|
|
2088
2101
|
const flatRes = await fetchFn(
|
|
2089
|
-
`https://data.jsdelivr.com/v1/package/gh/${owner}/${repo}@${encodeURIComponent(cand)}/flat
|
|
2102
|
+
`https://data.jsdelivr.com/v1/package/gh/${owner}/${repo}@${encodeURIComponent(cand)}/flat`,
|
|
2103
|
+
{ signal }
|
|
2090
2104
|
);
|
|
2091
2105
|
if (flatRes && flatRes.ok) {
|
|
2092
2106
|
const flatJson = await flatRes.json();
|
|
@@ -2155,28 +2169,34 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2155
2169
|
const BATCH_SIZE = 12;
|
|
2156
2170
|
|
|
2157
2171
|
for (let i = 0; i < selectedFiles.length; i += BATCH_SIZE) {
|
|
2172
|
+
throwIfAborted();
|
|
2158
2173
|
const batch = selectedFiles.slice(i, i + BATCH_SIZE);
|
|
2159
2174
|
await Promise.all(
|
|
2160
2175
|
batch.map(async (entry) => {
|
|
2176
|
+
throwIfAborted();
|
|
2161
2177
|
const encodedPath = entry.repoPath.split('/').map(encodeURIComponent).join('/');
|
|
2162
2178
|
const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${encodeURIComponent(resolvedBranch)}/${encodedPath}`;
|
|
2163
2179
|
const cdnUrl = `https://cdn.jsdelivr.net/gh/${owner}/${repo}@${encodeURIComponent(resolvedBranch)}/${encodedPath}`;
|
|
2164
2180
|
|
|
2165
2181
|
let text = null;
|
|
2166
2182
|
try {
|
|
2167
|
-
const r1 = await fetchFn(rawUrl);
|
|
2183
|
+
const r1 = await fetchFn(rawUrl, { signal });
|
|
2168
2184
|
if (r1 && r1.ok) {
|
|
2169
2185
|
text = await r1.text();
|
|
2170
2186
|
}
|
|
2171
|
-
} catch (_) {
|
|
2187
|
+
} catch (_) {
|
|
2188
|
+
if (signal && signal.aborted) throw _;
|
|
2189
|
+
}
|
|
2172
2190
|
|
|
2173
2191
|
if (text === null) {
|
|
2174
2192
|
try {
|
|
2175
|
-
const r2 = await fetchFn(cdnUrl);
|
|
2193
|
+
const r2 = await fetchFn(cdnUrl, { signal });
|
|
2176
2194
|
if (r2 && r2.ok) {
|
|
2177
2195
|
text = await r2.text();
|
|
2178
2196
|
}
|
|
2179
|
-
} catch (_) {
|
|
2197
|
+
} catch (_) {
|
|
2198
|
+
if (signal && signal.aborted) throw _;
|
|
2199
|
+
}
|
|
2180
2200
|
}
|
|
2181
2201
|
|
|
2182
2202
|
if (text !== null && text.length <= maxFileSize) {
|
|
@@ -2200,6 +2220,8 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2200
2220
|
);
|
|
2201
2221
|
}
|
|
2202
2222
|
|
|
2223
|
+
throwIfAborted();
|
|
2224
|
+
|
|
2203
2225
|
if (onProgress) {
|
|
2204
2226
|
onProgress({ phase: 'mounting', message: `Mounting files and writing Git metadata into ${targetDir}...`, loaded: filesWritten, total: totalToDownload });
|
|
2205
2227
|
}
|
|
@@ -2220,7 +2242,7 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
2220
2242
|
try {
|
|
2221
2243
|
const commitsRes = await fetchFn(
|
|
2222
2244
|
`https://api.github.com/repos/${owner}/${repo}/commits?sha=${encodeURIComponent(resolvedBranch)}&per_page=10`,
|
|
2223
|
-
{ headers: { Accept: 'application/vnd.github.v3+json' } }
|
|
2245
|
+
{ headers: { Accept: 'application/vnd.github.v3+json' }, signal }
|
|
2224
2246
|
);
|
|
2225
2247
|
if (commitsRes && commitsRes.ok) {
|
|
2226
2248
|
const commitsJson = await commitsRes.json();
|
|
@@ -4467,6 +4489,7 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
4467
4489
|
targetDir,
|
|
4468
4490
|
branch: branchOpt,
|
|
4469
4491
|
fetchImpl: ctx.shell && ctx.shell.options ? ctx.shell.options.fetchImpl : undefined,
|
|
4492
|
+
signal: ctx.signal,
|
|
4470
4493
|
onFile: (absPath) => ctx.emitMutation('create', absPath),
|
|
4471
4494
|
onProgress: (ev) => {
|
|
4472
4495
|
if (!ev) return;
|
|
@@ -4507,6 +4530,9 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
4507
4530
|
`Receiving objects: 100% (${count}/${count}), ${kb} KiB, done.\n`;
|
|
4508
4531
|
return { code: 0, stdout, stderr: '' };
|
|
4509
4532
|
} catch (err) {
|
|
4533
|
+
if (ctx.signal && ctx.signal.aborted) {
|
|
4534
|
+
return { code: 130, stdout: '', stderr: '', aborted: true };
|
|
4535
|
+
}
|
|
4510
4536
|
const msg = err && err.message ? err.message : String(err);
|
|
4511
4537
|
if (canStream) streamLine(msg.endsWith('\n') ? msg : msg + '\n');
|
|
4512
4538
|
return { code: 128, stdout: '', stderr: (msg.endsWith('\n') ? msg : msg + '\n') };
|
|
@@ -4834,6 +4860,7 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
4834
4860
|
targetDir: repoRoot,
|
|
4835
4861
|
branch: gitState.branch,
|
|
4836
4862
|
fetchImpl: ctx.shell && ctx.shell.options ? ctx.shell.options.fetchImpl : undefined,
|
|
4863
|
+
signal: ctx.signal,
|
|
4837
4864
|
onFile: (absPath) => ctx.emitMutation('change', absPath)
|
|
4838
4865
|
});
|
|
4839
4866
|
gitState.headSnapshot = Object.assign({}, result.headSnapshot);
|
|
@@ -4843,6 +4870,9 @@ const _root = typeof globalThis !== 'undefined' ? globalThis : typeof window !==
|
|
|
4843
4870
|
stderr: ''
|
|
4844
4871
|
};
|
|
4845
4872
|
} catch (err) {
|
|
4873
|
+
if (ctx.signal && ctx.signal.aborted) {
|
|
4874
|
+
return { code: 130, stdout: '', stderr: '', aborted: true };
|
|
4875
|
+
}
|
|
4846
4876
|
const msg = err && err.message ? err.message : String(err);
|
|
4847
4877
|
return { code: 1, stdout: '', stderr: (msg.endsWith('\n') ? msg : msg + '\n') };
|
|
4848
4878
|
}
|
package/dist/shell.js
CHANGED
|
@@ -2028,6 +2028,16 @@
|
|
|
2028
2028
|
const requestedBranch = options.branch || parsed.branch || null;
|
|
2029
2029
|
const { owner, repo } = parsed;
|
|
2030
2030
|
|
|
2031
|
+
const signal = options.signal || null;
|
|
2032
|
+
const throwIfAborted = () => {
|
|
2033
|
+
if (signal && signal.aborted) {
|
|
2034
|
+
const abortErr = new Error('fatal: clone cancelled (SIGINT)');
|
|
2035
|
+
abortErr.name = 'AbortError';
|
|
2036
|
+
throw abortErr;
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
throwIfAborted();
|
|
2040
|
+
|
|
2031
2041
|
let resolvedBranch = requestedBranch;
|
|
2032
2042
|
let rawTreeEntries = null;
|
|
2033
2043
|
let repoNotFound = false;
|
|
@@ -2040,7 +2050,8 @@
|
|
|
2040
2050
|
try {
|
|
2041
2051
|
if (!resolvedBranch) {
|
|
2042
2052
|
const metaRes = await fetchFn(`https://api.github.com/repos/${owner}/${repo}`, {
|
|
2043
|
-
headers: { Accept: 'application/vnd.github.v3+json' }
|
|
2053
|
+
headers: { Accept: 'application/vnd.github.v3+json' },
|
|
2054
|
+
signal
|
|
2044
2055
|
});
|
|
2045
2056
|
if (metaRes.status === 404) {
|
|
2046
2057
|
repoNotFound = true;
|
|
@@ -2058,9 +2069,10 @@
|
|
|
2058
2069
|
: Array.from(new Set([resolvedBranch, 'main', 'master'].filter(Boolean)));
|
|
2059
2070
|
|
|
2060
2071
|
for (const cand of branchCandidates) {
|
|
2072
|
+
throwIfAborted();
|
|
2061
2073
|
const treeRes = await fetchFn(
|
|
2062
2074
|
`https://api.github.com/repos/${owner}/${repo}/git/trees/${encodeURIComponent(cand)}?recursive=1`,
|
|
2063
|
-
{ headers: { Accept: 'application/vnd.github.v3+json' } }
|
|
2075
|
+
{ headers: { Accept: 'application/vnd.github.v3+json' }, signal }
|
|
2064
2076
|
);
|
|
2065
2077
|
if (treeRes.ok) {
|
|
2066
2078
|
const treeJson = await treeRes.json();
|
|
@@ -2086,8 +2098,10 @@
|
|
|
2086
2098
|
: Array.from(new Set([resolvedBranch, 'main', 'master'].filter(Boolean)));
|
|
2087
2099
|
|
|
2088
2100
|
for (const cand of branchCandidates) {
|
|
2101
|
+
throwIfAborted();
|
|
2089
2102
|
const flatRes = await fetchFn(
|
|
2090
|
-
`https://data.jsdelivr.com/v1/package/gh/${owner}/${repo}@${encodeURIComponent(cand)}/flat
|
|
2103
|
+
`https://data.jsdelivr.com/v1/package/gh/${owner}/${repo}@${encodeURIComponent(cand)}/flat`,
|
|
2104
|
+
{ signal }
|
|
2091
2105
|
);
|
|
2092
2106
|
if (flatRes && flatRes.ok) {
|
|
2093
2107
|
const flatJson = await flatRes.json();
|
|
@@ -2156,28 +2170,34 @@
|
|
|
2156
2170
|
const BATCH_SIZE = 12;
|
|
2157
2171
|
|
|
2158
2172
|
for (let i = 0; i < selectedFiles.length; i += BATCH_SIZE) {
|
|
2173
|
+
throwIfAborted();
|
|
2159
2174
|
const batch = selectedFiles.slice(i, i + BATCH_SIZE);
|
|
2160
2175
|
await Promise.all(
|
|
2161
2176
|
batch.map(async (entry) => {
|
|
2177
|
+
throwIfAborted();
|
|
2162
2178
|
const encodedPath = entry.repoPath.split('/').map(encodeURIComponent).join('/');
|
|
2163
2179
|
const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${encodeURIComponent(resolvedBranch)}/${encodedPath}`;
|
|
2164
2180
|
const cdnUrl = `https://cdn.jsdelivr.net/gh/${owner}/${repo}@${encodeURIComponent(resolvedBranch)}/${encodedPath}`;
|
|
2165
2181
|
|
|
2166
2182
|
let text = null;
|
|
2167
2183
|
try {
|
|
2168
|
-
const r1 = await fetchFn(rawUrl);
|
|
2184
|
+
const r1 = await fetchFn(rawUrl, { signal });
|
|
2169
2185
|
if (r1 && r1.ok) {
|
|
2170
2186
|
text = await r1.text();
|
|
2171
2187
|
}
|
|
2172
|
-
} catch (_) {
|
|
2188
|
+
} catch (_) {
|
|
2189
|
+
if (signal && signal.aborted) throw _;
|
|
2190
|
+
}
|
|
2173
2191
|
|
|
2174
2192
|
if (text === null) {
|
|
2175
2193
|
try {
|
|
2176
|
-
const r2 = await fetchFn(cdnUrl);
|
|
2194
|
+
const r2 = await fetchFn(cdnUrl, { signal });
|
|
2177
2195
|
if (r2 && r2.ok) {
|
|
2178
2196
|
text = await r2.text();
|
|
2179
2197
|
}
|
|
2180
|
-
} catch (_) {
|
|
2198
|
+
} catch (_) {
|
|
2199
|
+
if (signal && signal.aborted) throw _;
|
|
2200
|
+
}
|
|
2181
2201
|
}
|
|
2182
2202
|
|
|
2183
2203
|
if (text !== null && text.length <= maxFileSize) {
|
|
@@ -2201,6 +2221,8 @@
|
|
|
2201
2221
|
);
|
|
2202
2222
|
}
|
|
2203
2223
|
|
|
2224
|
+
throwIfAborted();
|
|
2225
|
+
|
|
2204
2226
|
if (onProgress) {
|
|
2205
2227
|
onProgress({ phase: 'mounting', message: `Mounting files and writing Git metadata into ${targetDir}...`, loaded: filesWritten, total: totalToDownload });
|
|
2206
2228
|
}
|
|
@@ -2221,7 +2243,7 @@
|
|
|
2221
2243
|
try {
|
|
2222
2244
|
const commitsRes = await fetchFn(
|
|
2223
2245
|
`https://api.github.com/repos/${owner}/${repo}/commits?sha=${encodeURIComponent(resolvedBranch)}&per_page=10`,
|
|
2224
|
-
{ headers: { Accept: 'application/vnd.github.v3+json' } }
|
|
2246
|
+
{ headers: { Accept: 'application/vnd.github.v3+json' }, signal }
|
|
2225
2247
|
);
|
|
2226
2248
|
if (commitsRes && commitsRes.ok) {
|
|
2227
2249
|
const commitsJson = await commitsRes.json();
|
|
@@ -4468,6 +4490,7 @@
|
|
|
4468
4490
|
targetDir,
|
|
4469
4491
|
branch: branchOpt,
|
|
4470
4492
|
fetchImpl: ctx.shell && ctx.shell.options ? ctx.shell.options.fetchImpl : undefined,
|
|
4493
|
+
signal: ctx.signal,
|
|
4471
4494
|
onFile: (absPath) => ctx.emitMutation('create', absPath),
|
|
4472
4495
|
onProgress: (ev) => {
|
|
4473
4496
|
if (!ev) return;
|
|
@@ -4508,6 +4531,9 @@
|
|
|
4508
4531
|
`Receiving objects: 100% (${count}/${count}), ${kb} KiB, done.\n`;
|
|
4509
4532
|
return { code: 0, stdout, stderr: '' };
|
|
4510
4533
|
} catch (err) {
|
|
4534
|
+
if (ctx.signal && ctx.signal.aborted) {
|
|
4535
|
+
return { code: 130, stdout: '', stderr: '', aborted: true };
|
|
4536
|
+
}
|
|
4511
4537
|
const msg = err && err.message ? err.message : String(err);
|
|
4512
4538
|
if (canStream) streamLine(msg.endsWith('\n') ? msg : msg + '\n');
|
|
4513
4539
|
return { code: 128, stdout: '', stderr: (msg.endsWith('\n') ? msg : msg + '\n') };
|
|
@@ -4835,6 +4861,7 @@
|
|
|
4835
4861
|
targetDir: repoRoot,
|
|
4836
4862
|
branch: gitState.branch,
|
|
4837
4863
|
fetchImpl: ctx.shell && ctx.shell.options ? ctx.shell.options.fetchImpl : undefined,
|
|
4864
|
+
signal: ctx.signal,
|
|
4838
4865
|
onFile: (absPath) => ctx.emitMutation('change', absPath)
|
|
4839
4866
|
});
|
|
4840
4867
|
gitState.headSnapshot = Object.assign({}, result.headSnapshot);
|
|
@@ -4844,6 +4871,9 @@
|
|
|
4844
4871
|
stderr: ''
|
|
4845
4872
|
};
|
|
4846
4873
|
} catch (err) {
|
|
4874
|
+
if (ctx.signal && ctx.signal.aborted) {
|
|
4875
|
+
return { code: 130, stdout: '', stderr: '', aborted: true };
|
|
4876
|
+
}
|
|
4847
4877
|
const msg = err && err.message ? err.message : String(err);
|
|
4848
4878
|
return { code: 1, stdout: '', stderr: (msg.endsWith('\n') ? msg : msg + '\n') };
|
|
4849
4879
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovatorved/code-lab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Standalone browser-native IDE Workbench, POSIX Shell & Coreutils, PTY Terminal, and Web Worker Node.js/Bun Virtual Runtime.",
|
|
5
5
|
"main": "./dist/code-lab.js",
|
|
6
6
|
"module": "./dist/code-lab.esm.js",
|
package/src/code-lab.css
CHANGED
|
@@ -465,6 +465,24 @@ code-lab,
|
|
|
465
465
|
color: #ffffff;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
+
.codelab-btn--ctrl-c {
|
|
469
|
+
color: var(--cl-fg-muted);
|
|
470
|
+
border-color: transparent;
|
|
471
|
+
font-weight: 600;
|
|
472
|
+
letter-spacing: 0.02em;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.codelab-btn--ctrl-c:hover {
|
|
476
|
+
color: var(--cl-fg);
|
|
477
|
+
border-color: var(--cl-border);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.codelab-btn--ctrl-c.is-running {
|
|
481
|
+
color: var(--cl-red);
|
|
482
|
+
border-color: var(--cl-red);
|
|
483
|
+
background: var(--cl-red-muted);
|
|
484
|
+
}
|
|
485
|
+
|
|
468
486
|
.codelab-btn--test {
|
|
469
487
|
background: var(--cl-accent);
|
|
470
488
|
border-color: var(--cl-accent);
|
|
@@ -1018,14 +1036,33 @@ code-lab,
|
|
|
1018
1036
|
|
|
1019
1037
|
.codelab-workspace {
|
|
1020
1038
|
display: grid;
|
|
1021
|
-
grid-template-columns: 196px 1fr;
|
|
1039
|
+
grid-template-columns: var(--cl-explorer-width, 196px) 4px 1fr;
|
|
1022
1040
|
flex: 1;
|
|
1023
1041
|
min-height: 160px;
|
|
1024
1042
|
overflow: hidden;
|
|
1025
1043
|
}
|
|
1026
1044
|
|
|
1027
1045
|
.codelab.files-collapsed .codelab-workspace {
|
|
1028
|
-
grid-template-columns: 0px 1fr;
|
|
1046
|
+
grid-template-columns: 0px 0px 1fr;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
.codelab.files-collapsed .codelab-splitter-files {
|
|
1050
|
+
display: none;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/* Explorer Resize Splitter */
|
|
1054
|
+
.codelab-splitter-files {
|
|
1055
|
+
width: 4px;
|
|
1056
|
+
background: transparent;
|
|
1057
|
+
cursor: col-resize;
|
|
1058
|
+
position: relative;
|
|
1059
|
+
z-index: 6;
|
|
1060
|
+
transition: background 120ms ease;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
.codelab-splitter-files:hover,
|
|
1064
|
+
.codelab-splitter-files.is-dragging {
|
|
1065
|
+
background: var(--cl-border-strong);
|
|
1029
1066
|
}
|
|
1030
1067
|
|
|
1031
1068
|
/* File Explorer Sidebar */
|
|
@@ -1739,46 +1776,55 @@ code-lab,
|
|
|
1739
1776
|
margin: 0 0 20px;
|
|
1740
1777
|
}
|
|
1741
1778
|
|
|
1742
|
-
.codelab-empty-
|
|
1779
|
+
.codelab-empty-editor__watermark {
|
|
1780
|
+
font-family: var(--cl-font-sans);
|
|
1781
|
+
font-size: 40px;
|
|
1782
|
+
font-weight: 700;
|
|
1783
|
+
letter-spacing: -0.03em;
|
|
1784
|
+
color: var(--cl-fg-faint);
|
|
1785
|
+
opacity: 0.45;
|
|
1786
|
+
margin-bottom: 22px;
|
|
1787
|
+
user-select: none;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
.codelab-empty-editor__shortcuts {
|
|
1743
1791
|
display: flex;
|
|
1744
|
-
flex-
|
|
1745
|
-
gap:
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
width: 100%;
|
|
1792
|
+
flex-direction: column;
|
|
1793
|
+
gap: 6px;
|
|
1794
|
+
margin-bottom: 22px;
|
|
1795
|
+
min-width: 260px;
|
|
1749
1796
|
}
|
|
1750
1797
|
|
|
1751
|
-
.codelab-empty-
|
|
1752
|
-
display:
|
|
1798
|
+
.codelab-empty-shortcut {
|
|
1799
|
+
display: flex;
|
|
1753
1800
|
align-items: center;
|
|
1754
|
-
|
|
1755
|
-
|
|
1801
|
+
justify-content: space-between;
|
|
1802
|
+
gap: 16px;
|
|
1803
|
+
padding: 7px 12px;
|
|
1756
1804
|
border-radius: var(--cl-radius-sm);
|
|
1757
|
-
background:
|
|
1758
|
-
border: 1px solid
|
|
1759
|
-
color: var(--cl-fg);
|
|
1760
|
-
font-family: var(--cl-font-
|
|
1761
|
-
font-size:
|
|
1805
|
+
background: transparent;
|
|
1806
|
+
border: 1px solid transparent;
|
|
1807
|
+
color: var(--cl-fg-muted);
|
|
1808
|
+
font-family: var(--cl-font-sans);
|
|
1809
|
+
font-size: 12.5px;
|
|
1762
1810
|
cursor: pointer;
|
|
1763
1811
|
transition: all 120ms ease;
|
|
1764
|
-
user-select: none;
|
|
1765
1812
|
}
|
|
1766
1813
|
|
|
1767
|
-
.codelab-empty-
|
|
1814
|
+
.codelab-empty-shortcut:hover {
|
|
1768
1815
|
background: var(--cl-bg-hover);
|
|
1769
|
-
border-color: var(--cl-border
|
|
1816
|
+
border-color: var(--cl-border);
|
|
1770
1817
|
color: var(--cl-fg);
|
|
1771
1818
|
}
|
|
1772
1819
|
|
|
1773
|
-
.codelab-empty-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
justify-content: center;
|
|
1820
|
+
.codelab-empty-shortcut kbd {
|
|
1821
|
+
font-family: var(--cl-font-mono);
|
|
1822
|
+
font-size: 11px;
|
|
1823
|
+
color: var(--cl-fg-muted);
|
|
1824
|
+
background: var(--cl-bg-panel);
|
|
1825
|
+
border: 1px solid var(--cl-border);
|
|
1826
|
+
border-radius: 4px;
|
|
1827
|
+
padding: 1px 6px;
|
|
1782
1828
|
}
|
|
1783
1829
|
|
|
1784
1830
|
/* ── Bottom Drawer: Tests, Terminal REPL, Virtual Disk & Network ─────────── */
|
|
@@ -2933,7 +2979,7 @@ code-lab,
|
|
|
2933
2979
|
border-bottom: 1px solid var(--cl-border);
|
|
2934
2980
|
}
|
|
2935
2981
|
.codelab-workspace {
|
|
2936
|
-
grid-template-columns: 155px 1fr;
|
|
2982
|
+
grid-template-columns: 155px 4px 1fr;
|
|
2937
2983
|
}
|
|
2938
2984
|
.codelab-inspector-grid {
|
|
2939
2985
|
grid-template-columns: 1fr;
|
|
@@ -2947,7 +2993,8 @@ code-lab,
|
|
|
2947
2993
|
.codelab-workspace {
|
|
2948
2994
|
grid-template-columns: 1fr;
|
|
2949
2995
|
}
|
|
2950
|
-
.codelab-explorer
|
|
2996
|
+
.codelab-explorer,
|
|
2997
|
+
.codelab-splitter-files {
|
|
2951
2998
|
display: none;
|
|
2952
2999
|
}
|
|
2953
3000
|
.codelab-topbar__center {
|
package/src/shell.js
CHANGED
|
@@ -2009,6 +2009,16 @@
|
|
|
2009
2009
|
const requestedBranch = options.branch || parsed.branch || null;
|
|
2010
2010
|
const { owner, repo } = parsed;
|
|
2011
2011
|
|
|
2012
|
+
const signal = options.signal || null;
|
|
2013
|
+
const throwIfAborted = () => {
|
|
2014
|
+
if (signal && signal.aborted) {
|
|
2015
|
+
const abortErr = new Error('fatal: clone cancelled (SIGINT)');
|
|
2016
|
+
abortErr.name = 'AbortError';
|
|
2017
|
+
throw abortErr;
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
throwIfAborted();
|
|
2021
|
+
|
|
2012
2022
|
let resolvedBranch = requestedBranch;
|
|
2013
2023
|
let rawTreeEntries = null;
|
|
2014
2024
|
let repoNotFound = false;
|
|
@@ -2021,7 +2031,8 @@
|
|
|
2021
2031
|
try {
|
|
2022
2032
|
if (!resolvedBranch) {
|
|
2023
2033
|
const metaRes = await fetchFn(`https://api.github.com/repos/${owner}/${repo}`, {
|
|
2024
|
-
headers: { Accept: 'application/vnd.github.v3+json' }
|
|
2034
|
+
headers: { Accept: 'application/vnd.github.v3+json' },
|
|
2035
|
+
signal
|
|
2025
2036
|
});
|
|
2026
2037
|
if (metaRes.status === 404) {
|
|
2027
2038
|
repoNotFound = true;
|
|
@@ -2039,9 +2050,10 @@
|
|
|
2039
2050
|
: Array.from(new Set([resolvedBranch, 'main', 'master'].filter(Boolean)));
|
|
2040
2051
|
|
|
2041
2052
|
for (const cand of branchCandidates) {
|
|
2053
|
+
throwIfAborted();
|
|
2042
2054
|
const treeRes = await fetchFn(
|
|
2043
2055
|
`https://api.github.com/repos/${owner}/${repo}/git/trees/${encodeURIComponent(cand)}?recursive=1`,
|
|
2044
|
-
{ headers: { Accept: 'application/vnd.github.v3+json' } }
|
|
2056
|
+
{ headers: { Accept: 'application/vnd.github.v3+json' }, signal }
|
|
2045
2057
|
);
|
|
2046
2058
|
if (treeRes.ok) {
|
|
2047
2059
|
const treeJson = await treeRes.json();
|
|
@@ -2067,8 +2079,10 @@
|
|
|
2067
2079
|
: Array.from(new Set([resolvedBranch, 'main', 'master'].filter(Boolean)));
|
|
2068
2080
|
|
|
2069
2081
|
for (const cand of branchCandidates) {
|
|
2082
|
+
throwIfAborted();
|
|
2070
2083
|
const flatRes = await fetchFn(
|
|
2071
|
-
`https://data.jsdelivr.com/v1/package/gh/${owner}/${repo}@${encodeURIComponent(cand)}/flat
|
|
2084
|
+
`https://data.jsdelivr.com/v1/package/gh/${owner}/${repo}@${encodeURIComponent(cand)}/flat`,
|
|
2085
|
+
{ signal }
|
|
2072
2086
|
);
|
|
2073
2087
|
if (flatRes && flatRes.ok) {
|
|
2074
2088
|
const flatJson = await flatRes.json();
|
|
@@ -2137,28 +2151,34 @@
|
|
|
2137
2151
|
const BATCH_SIZE = 12;
|
|
2138
2152
|
|
|
2139
2153
|
for (let i = 0; i < selectedFiles.length; i += BATCH_SIZE) {
|
|
2154
|
+
throwIfAborted();
|
|
2140
2155
|
const batch = selectedFiles.slice(i, i + BATCH_SIZE);
|
|
2141
2156
|
await Promise.all(
|
|
2142
2157
|
batch.map(async (entry) => {
|
|
2158
|
+
throwIfAborted();
|
|
2143
2159
|
const encodedPath = entry.repoPath.split('/').map(encodeURIComponent).join('/');
|
|
2144
2160
|
const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${encodeURIComponent(resolvedBranch)}/${encodedPath}`;
|
|
2145
2161
|
const cdnUrl = `https://cdn.jsdelivr.net/gh/${owner}/${repo}@${encodeURIComponent(resolvedBranch)}/${encodedPath}`;
|
|
2146
2162
|
|
|
2147
2163
|
let text = null;
|
|
2148
2164
|
try {
|
|
2149
|
-
const r1 = await fetchFn(rawUrl);
|
|
2165
|
+
const r1 = await fetchFn(rawUrl, { signal });
|
|
2150
2166
|
if (r1 && r1.ok) {
|
|
2151
2167
|
text = await r1.text();
|
|
2152
2168
|
}
|
|
2153
|
-
} catch (_) {
|
|
2169
|
+
} catch (_) {
|
|
2170
|
+
if (signal && signal.aborted) throw _;
|
|
2171
|
+
}
|
|
2154
2172
|
|
|
2155
2173
|
if (text === null) {
|
|
2156
2174
|
try {
|
|
2157
|
-
const r2 = await fetchFn(cdnUrl);
|
|
2175
|
+
const r2 = await fetchFn(cdnUrl, { signal });
|
|
2158
2176
|
if (r2 && r2.ok) {
|
|
2159
2177
|
text = await r2.text();
|
|
2160
2178
|
}
|
|
2161
|
-
} catch (_) {
|
|
2179
|
+
} catch (_) {
|
|
2180
|
+
if (signal && signal.aborted) throw _;
|
|
2181
|
+
}
|
|
2162
2182
|
}
|
|
2163
2183
|
|
|
2164
2184
|
if (text !== null && text.length <= maxFileSize) {
|
|
@@ -2182,6 +2202,8 @@
|
|
|
2182
2202
|
);
|
|
2183
2203
|
}
|
|
2184
2204
|
|
|
2205
|
+
throwIfAborted();
|
|
2206
|
+
|
|
2185
2207
|
if (onProgress) {
|
|
2186
2208
|
onProgress({ phase: 'mounting', message: `Mounting files and writing Git metadata into ${targetDir}...`, loaded: filesWritten, total: totalToDownload });
|
|
2187
2209
|
}
|
|
@@ -2202,7 +2224,7 @@
|
|
|
2202
2224
|
try {
|
|
2203
2225
|
const commitsRes = await fetchFn(
|
|
2204
2226
|
`https://api.github.com/repos/${owner}/${repo}/commits?sha=${encodeURIComponent(resolvedBranch)}&per_page=10`,
|
|
2205
|
-
{ headers: { Accept: 'application/vnd.github.v3+json' } }
|
|
2227
|
+
{ headers: { Accept: 'application/vnd.github.v3+json' }, signal }
|
|
2206
2228
|
);
|
|
2207
2229
|
if (commitsRes && commitsRes.ok) {
|
|
2208
2230
|
const commitsJson = await commitsRes.json();
|
|
@@ -4449,6 +4471,7 @@
|
|
|
4449
4471
|
targetDir,
|
|
4450
4472
|
branch: branchOpt,
|
|
4451
4473
|
fetchImpl: ctx.shell && ctx.shell.options ? ctx.shell.options.fetchImpl : undefined,
|
|
4474
|
+
signal: ctx.signal,
|
|
4452
4475
|
onFile: (absPath) => ctx.emitMutation('create', absPath),
|
|
4453
4476
|
onProgress: (ev) => {
|
|
4454
4477
|
if (!ev) return;
|
|
@@ -4489,6 +4512,9 @@
|
|
|
4489
4512
|
`Receiving objects: 100% (${count}/${count}), ${kb} KiB, done.\n`;
|
|
4490
4513
|
return { code: 0, stdout, stderr: '' };
|
|
4491
4514
|
} catch (err) {
|
|
4515
|
+
if (ctx.signal && ctx.signal.aborted) {
|
|
4516
|
+
return { code: 130, stdout: '', stderr: '', aborted: true };
|
|
4517
|
+
}
|
|
4492
4518
|
const msg = err && err.message ? err.message : String(err);
|
|
4493
4519
|
if (canStream) streamLine(msg.endsWith('\n') ? msg : msg + '\n');
|
|
4494
4520
|
return { code: 128, stdout: '', stderr: (msg.endsWith('\n') ? msg : msg + '\n') };
|
|
@@ -4816,6 +4842,7 @@
|
|
|
4816
4842
|
targetDir: repoRoot,
|
|
4817
4843
|
branch: gitState.branch,
|
|
4818
4844
|
fetchImpl: ctx.shell && ctx.shell.options ? ctx.shell.options.fetchImpl : undefined,
|
|
4845
|
+
signal: ctx.signal,
|
|
4819
4846
|
onFile: (absPath) => ctx.emitMutation('change', absPath)
|
|
4820
4847
|
});
|
|
4821
4848
|
gitState.headSnapshot = Object.assign({}, result.headSnapshot);
|
|
@@ -4825,6 +4852,9 @@
|
|
|
4825
4852
|
stderr: ''
|
|
4826
4853
|
};
|
|
4827
4854
|
} catch (err) {
|
|
4855
|
+
if (ctx.signal && ctx.signal.aborted) {
|
|
4856
|
+
return { code: 130, stdout: '', stderr: '', aborted: true };
|
|
4857
|
+
}
|
|
4828
4858
|
const msg = err && err.message ? err.message : String(err);
|
|
4829
4859
|
return { code: 1, stdout: '', stderr: (msg.endsWith('\n') ? msg : msg + '\n') };
|
|
4830
4860
|
}
|