@myrialabs/clopen 0.4.17 → 0.4.18
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/README.md +3 -3
- package/backend/auth/auth-service.ts +265 -13
- package/backend/auth/permissions.ts +3 -0
- package/backend/auth/rate-limiter.ts +1 -0
- package/backend/auth/session-cleanup.ts +5 -0
- package/backend/auth/tokens.ts +8 -1
- package/backend/chat/stream-manager.ts +8 -0
- package/backend/database/migrations/060_create_device_codes_table.ts +38 -0
- package/backend/database/migrations/061_add_session_device_metadata.ts +42 -0
- package/backend/database/migrations/062_add_session_source.ts +43 -0
- package/backend/database/migrations/063_add_invite_project_ids.ts +42 -0
- package/backend/database/migrations/064_create_messages_fts.ts +71 -0
- package/backend/database/migrations/index.ts +35 -0
- package/backend/database/queries/auth-queries.ts +100 -6
- package/backend/database/queries/message-queries.ts +44 -0
- package/backend/database/queries/session-queries.ts +117 -12
- package/backend/engine/README.md +21 -4
- package/backend/engine/adapters/claude/stream.ts +4 -2
- package/backend/engine/adapters/cline/agent-tool.ts +3 -2
- package/backend/engine/adapters/cline/ask-question-tool.ts +3 -2
- package/backend/engine/adapters/cline/credential.ts +2 -1
- package/backend/engine/adapters/cline/mcp-tools.ts +2 -1
- package/backend/engine/adapters/cline/models.ts +3 -1
- package/backend/engine/adapters/cline/presets.ts +5 -3
- package/backend/engine/adapters/cline/stream.ts +10 -7
- package/backend/engine/adapters/codex/stream.ts +3 -1
- package/backend/engine/adapters/copilot/stream.ts +8 -1
- package/backend/engine/adapters/cursor/environment.ts +4 -2
- package/backend/engine/adapters/cursor/models.ts +2 -1
- package/backend/engine/adapters/cursor/stream.ts +5 -3
- package/backend/engine/adapters/pi/presets.ts +3 -1
- package/backend/engine/adapters/pi/session-fork.ts +3 -1
- package/backend/engine/adapters/pi/stream.ts +11 -8
- package/backend/engine/bootstrap-default-engine.ts +69 -0
- package/backend/engine/docs/adding-an-engine.md +29 -6
- package/backend/engine/docs/frontend-and-chat.md +21 -5
- package/backend/engine/docs/lessons-learned.md +41 -0
- package/backend/engine/docs/quick-reference.md +3 -2
- package/backend/engine/docs/system-tools.md +65 -9
- package/backend/engine/docs/websocket-routes.md +4 -3
- package/backend/engine/engine-setup.ts +72 -0
- package/backend/engine/install-recipes.ts +82 -77
- package/backend/engine/install-runner.ts +27 -2
- package/backend/engine/sdk-loader.ts +180 -0
- package/backend/engine/version-check.ts +6 -6
- package/backend/http/files-upload.test.ts +4 -1
- package/backend/index.ts +32 -2
- package/backend/mcp/README.md +26 -8
- package/backend/mcp/index.ts +2 -2
- package/backend/mcp/internal/config.ts +54 -63
- package/backend/mcp/internal/remote-server.test.ts +4 -1
- package/backend/mcp/internal/servers/helper.ts +4 -34
- package/backend/mcp/internal/servers/index.ts +4 -13
- package/backend/tunnel/public-origin.ts +118 -0
- package/backend/utils/ws.ts +126 -1
- package/backend/ws/auth/device.ts +239 -0
- package/backend/ws/auth/index.ts +8 -0
- package/backend/ws/auth/invites.ts +16 -6
- package/backend/ws/auth/login.test.ts +2 -2
- package/backend/ws/auth/login.ts +12 -6
- package/backend/ws/engine/claude/status.ts +4 -4
- package/backend/ws/engine/cline/accounts.ts +3 -2
- package/backend/ws/engine/cline/status.ts +4 -12
- package/backend/ws/engine/codex/status.ts +4 -12
- package/backend/ws/engine/copilot/status.ts +5 -12
- package/backend/ws/engine/cursor/accounts.ts +2 -1
- package/backend/ws/engine/cursor/status.ts +5 -12
- package/backend/ws/engine/opencode/status.ts +4 -4
- package/backend/ws/engine/pi/status.ts +4 -12
- package/backend/ws/engine/qwen/status.ts +5 -12
- package/backend/ws/sessions/crud.ts +29 -4
- package/backend/ws/settings/crud.ts +10 -1
- package/backend/ws/system/operations.ts +34 -18
- package/backend/ws/system-tools/install.ts +3 -0
- package/backend/ws/system-tools/status.ts +7 -2
- package/backend/ws/tunnel/index.ts +3 -1
- package/backend/ws/tunnel/share.ts +27 -0
- package/bin/clopen.ts +1 -1
- package/dist/assets/{index-kME3THy5.js → index-Cz8HVhsm.js} +1 -1
- package/dist/assets/{index-Bu5loFQE.js → index-SI4Gcd0p.js} +1 -1
- package/dist/assets/main-Cry3pLcl.css +1 -0
- package/dist/assets/{main-HirJLquI.js → main-Dlba-fXF.js} +337 -330
- package/dist/index.html +2 -2
- package/package.json +15 -14
- package/shared/constants/engines.ts +39 -40
- package/shared/constants/tool-icons.ts +49 -0
- package/shared/types/stores/settings.ts +9 -0
- package/shared/utils/logger.ts +1 -0
- package/dist/assets/main-D7ATW8pp.css +0 -1
|
@@ -13,16 +13,7 @@ import { engineQueries } from '../../../database/queries';
|
|
|
13
13
|
import { resolveBinaryWithRefresh } from '../../../utils/cli';
|
|
14
14
|
import { getBackendOS } from '../../../utils/os';
|
|
15
15
|
import { debug } from '$shared/utils/logger';
|
|
16
|
-
|
|
17
|
-
function readSdkVersion(): string | null {
|
|
18
|
-
try {
|
|
19
|
-
const path = require.resolve('@openai/codex-sdk/package.json');
|
|
20
|
-
const pkg = require(path) as { version?: string };
|
|
21
|
-
return pkg.version ?? null;
|
|
22
|
-
} catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
16
|
+
import { readEngineSdkVersion } from '$backend/engine/sdk-loader';
|
|
26
17
|
|
|
27
18
|
async function readCliVersion(): Promise<string | null> {
|
|
28
19
|
const bin = await resolveBinaryWithRefresh('codex');
|
|
@@ -65,6 +56,7 @@ export const codexStatusHandler = createRouter()
|
|
|
65
56
|
const activeAccount = engineQueries.getActiveAccountForEngine('codex');
|
|
66
57
|
|
|
67
58
|
const cliVersion = await readCliVersion();
|
|
59
|
+
const sdkVersion = readEngineSdkVersion('@openai/codex-sdk');
|
|
68
60
|
|
|
69
61
|
// authMode parsing — defer the import to avoid initializing fs paths in
|
|
70
62
|
// the status hot path; only matters when an active account exists.
|
|
@@ -75,9 +67,9 @@ export const codexStatusHandler = createRouter()
|
|
|
75
67
|
}
|
|
76
68
|
|
|
77
69
|
return {
|
|
78
|
-
installed:
|
|
70
|
+
installed: sdkVersion !== null,
|
|
79
71
|
version: cliVersion,
|
|
80
|
-
sdkVersion
|
|
72
|
+
sdkVersion,
|
|
81
73
|
activeAccount: activeAccount
|
|
82
74
|
? { id: activeAccount.id, name: activeAccount.name, authMode }
|
|
83
75
|
: null,
|
|
@@ -10,16 +10,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
10
10
|
import { engineQueries } from '../../../database/queries';
|
|
11
11
|
import { debug } from '$shared/utils/logger';
|
|
12
12
|
import { getBackendOS } from '../../../utils/os';
|
|
13
|
-
|
|
14
|
-
function readSdkVersion(): string | null {
|
|
15
|
-
try {
|
|
16
|
-
const path = require.resolve('@github/copilot-sdk/package.json');
|
|
17
|
-
const pkg = require(path) as { version?: string };
|
|
18
|
-
return pkg.version ?? null;
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
13
|
+
import { readEngineSdkVersion } from '$backend/engine/sdk-loader';
|
|
23
14
|
|
|
24
15
|
export const copilotStatusHandler = createRouter()
|
|
25
16
|
.http('engine:copilot-status', {
|
|
@@ -44,9 +35,11 @@ export const copilotStatusHandler = createRouter()
|
|
|
44
35
|
const accounts = provider ? engineQueries.getAccountsByProvider(provider.id) : [];
|
|
45
36
|
const activeAccount = engineQueries.getActiveAccountForEngine('copilot');
|
|
46
37
|
|
|
38
|
+
const sdkVersion = readEngineSdkVersion('@github/copilot-sdk');
|
|
39
|
+
|
|
47
40
|
return {
|
|
48
|
-
installed:
|
|
49
|
-
version:
|
|
41
|
+
installed: sdkVersion !== null,
|
|
42
|
+
version: sdkVersion,
|
|
50
43
|
activeAccount: activeAccount ? { id: activeAccount.id, name: activeAccount.name } : null,
|
|
51
44
|
accountsCount: accounts.length,
|
|
52
45
|
backendOS: getBackendOS()
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { t } from 'elysia';
|
|
14
|
-
import { Cursor } from '@cursor/sdk';
|
|
15
14
|
import { createRouter } from '$shared/utils/ws-server';
|
|
15
|
+
import { loadEngineSdk } from '$backend/engine/sdk-loader';
|
|
16
16
|
import { engineQueries } from '../../../database/queries';
|
|
17
17
|
import { disposeAllProjectEnginesByType } from '../../../engine';
|
|
18
18
|
import { serializeCursorCredential } from '../../../engine/adapters/cursor/credential';
|
|
@@ -35,6 +35,7 @@ async function disposeCursorEngines(): Promise<void> {
|
|
|
35
35
|
*/
|
|
36
36
|
async function validateApiKey(apiKey: string): Promise<void> {
|
|
37
37
|
try {
|
|
38
|
+
const { Cursor } = await loadEngineSdk<typeof import('@cursor/sdk')>('cursor', '@cursor/sdk');
|
|
38
39
|
await Cursor.me({ apiKey });
|
|
39
40
|
} catch (error) {
|
|
40
41
|
const status = (error as { status?: number })?.status;
|
|
@@ -11,16 +11,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
11
11
|
import { engineQueries } from '../../../database/queries';
|
|
12
12
|
import { debug } from '$shared/utils/logger';
|
|
13
13
|
import { getBackendOS } from '../../../utils/os';
|
|
14
|
-
|
|
15
|
-
function readSdkVersion(): string | null {
|
|
16
|
-
try {
|
|
17
|
-
const path = require.resolve('@cursor/sdk/package.json');
|
|
18
|
-
const pkg = require(path) as { version?: string };
|
|
19
|
-
return pkg.version ?? null;
|
|
20
|
-
} catch {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
14
|
+
import { readEngineSdkVersion } from '$backend/engine/sdk-loader';
|
|
24
15
|
|
|
25
16
|
export const cursorStatusHandler = createRouter()
|
|
26
17
|
.http('engine:cursor-status', {
|
|
@@ -45,9 +36,11 @@ export const cursorStatusHandler = createRouter()
|
|
|
45
36
|
const accounts = provider ? engineQueries.getAccountsByProvider(provider.id) : [];
|
|
46
37
|
const activeAccount = engineQueries.getActiveAccountForEngine('cursor');
|
|
47
38
|
|
|
39
|
+
const sdkVersion = readEngineSdkVersion('@cursor/sdk');
|
|
40
|
+
|
|
48
41
|
return {
|
|
49
|
-
installed:
|
|
50
|
-
version:
|
|
42
|
+
installed: sdkVersion !== null,
|
|
43
|
+
version: sdkVersion,
|
|
51
44
|
activeAccount: activeAccount ? { id: activeAccount.id, name: activeAccount.name } : null,
|
|
52
45
|
accountsCount: accounts.length,
|
|
53
46
|
backendOS: getBackendOS()
|
|
@@ -8,7 +8,7 @@ import { t } from 'elysia';
|
|
|
8
8
|
import { createRouter } from '$shared/utils/ws-server';
|
|
9
9
|
import { debug } from '$shared/utils/logger';
|
|
10
10
|
import { getBackendOS } from '../../../utils/os';
|
|
11
|
-
import {
|
|
11
|
+
import { readEngineSdkVersion } from '$backend/engine/sdk-loader';
|
|
12
12
|
|
|
13
13
|
export const openCodeStatusHandler = createRouter()
|
|
14
14
|
.http('engine:opencode-status', {
|
|
@@ -21,11 +21,11 @@ export const openCodeStatusHandler = createRouter()
|
|
|
21
21
|
}, async () => {
|
|
22
22
|
debug.log('engine', 'Checking Open Code status...');
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const sdkVersion = readEngineSdkVersion('@opencode-ai/sdk');
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
|
-
installed,
|
|
28
|
-
version,
|
|
27
|
+
installed: sdkVersion !== null,
|
|
28
|
+
version: sdkVersion,
|
|
29
29
|
backendOS: getBackendOS()
|
|
30
30
|
};
|
|
31
31
|
});
|
|
@@ -11,16 +11,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
11
11
|
import { engineQueries } from '../../../database/queries';
|
|
12
12
|
import { debug } from '$shared/utils/logger';
|
|
13
13
|
import { getBackendOS } from '../../../utils/os';
|
|
14
|
-
|
|
15
|
-
function readSdkVersion(): string | null {
|
|
16
|
-
try {
|
|
17
|
-
const path = require.resolve('@earendil-works/pi-coding-agent/package.json');
|
|
18
|
-
const pkg = require(path) as { version?: string };
|
|
19
|
-
return pkg.version ?? null;
|
|
20
|
-
} catch {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
14
|
+
import { readEngineSdkVersion } from '$backend/engine/sdk-loader';
|
|
24
15
|
|
|
25
16
|
export const piStatusHandler = createRouter()
|
|
26
17
|
.http('engine:pi-status', {
|
|
@@ -40,9 +31,10 @@ export const piStatusHandler = createRouter()
|
|
|
40
31
|
const provider = engineQueries.getProviderBySlug('pi', 'pi');
|
|
41
32
|
const accounts = provider ? engineQueries.getAccountsByProvider(provider.id) : [];
|
|
42
33
|
const activeAccount = engineQueries.getActiveAccountForEngine('pi');
|
|
34
|
+
const sdkVersion = readEngineSdkVersion('@earendil-works/pi-coding-agent');
|
|
43
35
|
return {
|
|
44
|
-
installed:
|
|
45
|
-
version:
|
|
36
|
+
installed: sdkVersion !== null,
|
|
37
|
+
version: sdkVersion,
|
|
46
38
|
activeAccount: activeAccount ? { id: activeAccount.id, name: activeAccount.name } : null,
|
|
47
39
|
accountsCount: accounts.length,
|
|
48
40
|
backendOS: getBackendOS()
|
|
@@ -10,16 +10,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
10
10
|
import { engineQueries } from '../../../database/queries';
|
|
11
11
|
import { debug } from '$shared/utils/logger';
|
|
12
12
|
import { getBackendOS } from '../../../utils/os';
|
|
13
|
-
|
|
14
|
-
function readSdkVersion(): string | null {
|
|
15
|
-
try {
|
|
16
|
-
const path = require.resolve('@qwen-code/sdk/package.json');
|
|
17
|
-
const pkg = require(path) as { version?: string };
|
|
18
|
-
return pkg.version ?? null;
|
|
19
|
-
} catch {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
13
|
+
import { readEngineSdkVersion } from '$backend/engine/sdk-loader';
|
|
23
14
|
|
|
24
15
|
export const qwenStatusHandler = createRouter()
|
|
25
16
|
.http('engine:qwen-status', {
|
|
@@ -44,9 +35,11 @@ export const qwenStatusHandler = createRouter()
|
|
|
44
35
|
const accounts = provider ? engineQueries.getAccountsByProvider(provider.id) : [];
|
|
45
36
|
const activeAccount = engineQueries.getActiveAccountForEngine('qwen');
|
|
46
37
|
|
|
38
|
+
const sdkVersion = readEngineSdkVersion('@qwen-code/sdk');
|
|
39
|
+
|
|
47
40
|
return {
|
|
48
|
-
installed:
|
|
49
|
-
version:
|
|
41
|
+
installed: sdkVersion !== null,
|
|
42
|
+
version: sdkVersion,
|
|
50
43
|
activeAccount: activeAccount ? { id: activeAccount.id, name: activeAccount.name } : null,
|
|
51
44
|
accountsCount: accounts.length,
|
|
52
45
|
backendOS: getBackendOS()
|
|
@@ -50,6 +50,12 @@ const sessionSchema = t.Object({
|
|
|
50
50
|
last_message_at: t.Optional(t.String()),
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
/** sessionSchema plus a highlighted match snippet — global (cross-project) search only. */
|
|
54
|
+
const sessionSearchResultSchema = t.Object({
|
|
55
|
+
...sessionSchema.properties,
|
|
56
|
+
matchSnippet: t.Optional(t.String())
|
|
57
|
+
});
|
|
58
|
+
|
|
53
59
|
/** Convert ChatSession DB row → response (null → undefined for Elysia optional fields) */
|
|
54
60
|
function serializeSession(session: ChatSession) {
|
|
55
61
|
return {
|
|
@@ -416,16 +422,35 @@ export const crudHandler = createRouter()
|
|
|
416
422
|
debug.log('session', `[unread] Marked ALL sessions as READ for user ${userId} in project ${data.projectId}`);
|
|
417
423
|
})
|
|
418
424
|
|
|
419
|
-
// Search sessions by message content (deep search)
|
|
425
|
+
// Search sessions by message content within the current project (deep search)
|
|
420
426
|
.http('sessions:search', {
|
|
421
427
|
data: t.Object({
|
|
422
428
|
query: t.String({ minLength: 1 })
|
|
423
429
|
}),
|
|
424
430
|
response: t.Object({
|
|
425
|
-
|
|
431
|
+
results: t.Array(t.Object({
|
|
432
|
+
sessionId: t.String(),
|
|
433
|
+
snippet: t.String()
|
|
434
|
+
}))
|
|
426
435
|
})
|
|
427
436
|
}, async ({ data, conn }) => {
|
|
428
437
|
const { projectId } = requireCurrentProjectAccess(conn);
|
|
429
|
-
const
|
|
430
|
-
return {
|
|
438
|
+
const results = sessionQueries.searchByMessageContent(projectId, data.query);
|
|
439
|
+
return { results };
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
// Search sessions across every project the user has access to (Command Palette)
|
|
443
|
+
.http('sessions:search-global', {
|
|
444
|
+
data: t.Object({
|
|
445
|
+
query: t.String({ minLength: 1 })
|
|
446
|
+
}),
|
|
447
|
+
response: t.Object({
|
|
448
|
+
sessions: t.Array(sessionSearchResultSchema)
|
|
449
|
+
})
|
|
450
|
+
}, async ({ data, conn }) => {
|
|
451
|
+
const userId = ws.getUserId(conn);
|
|
452
|
+
const results = sessionQueries.searchGlobal(userId, data.query);
|
|
453
|
+
return {
|
|
454
|
+
sessions: results.map(r => ({ ...serializeSession(r), matchSnippet: r.matchSnippet }))
|
|
455
|
+
};
|
|
431
456
|
});
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
import { t } from 'elysia';
|
|
11
11
|
import { createRouter } from '$shared/utils/ws-server';
|
|
12
|
-
import { settingsQueries } from '../../database/queries';
|
|
12
|
+
import { settingsQueries, engineQueries } from '../../database/queries';
|
|
13
13
|
import { initializeEngine } from '../../engine';
|
|
14
|
+
import { checkEngineSetup } from '../../engine/engine-setup';
|
|
14
15
|
import { registerModels } from '$shared/constants/engines';
|
|
15
16
|
import type { EngineType } from '$shared/types/unified';
|
|
16
17
|
|
|
@@ -135,6 +136,14 @@ export const crudHandler = createRouter()
|
|
|
135
136
|
}, async ({ data }) => {
|
|
136
137
|
const engineType: EngineType = data.engine;
|
|
137
138
|
|
|
139
|
+
// Gate on engine readiness: don't surface a catalog for an engine whose
|
|
140
|
+
// SDK isn't installed / is out of date (→ Stack), or that requires an
|
|
141
|
+
// account and has none (→ Engines). Mirrors the chat pre-stream gate so
|
|
142
|
+
// the model picker reflects the same install/sign-in state as chat.
|
|
143
|
+
const activeAccount = engineQueries.getActiveAccountForEngine(engineType);
|
|
144
|
+
const setupIssue = checkEngineSetup(engineType, activeAccount?.id ?? 0);
|
|
145
|
+
if (setupIssue) throw new Error(setupIssue.message);
|
|
146
|
+
|
|
138
147
|
// Uniform path for every engine. Each adapter's getAvailableModels()
|
|
139
148
|
// owns the catalog logic (static array or dynamic fetch); this handler
|
|
140
149
|
// just initialises the engine, asks for the catalog, and registers it
|
|
@@ -21,8 +21,8 @@ import { resetEnvironment } from '$backend/engine/adapters/claude/environment';
|
|
|
21
21
|
/** In-memory flag: set after successful update, cleared on server restart */
|
|
22
22
|
let pendingUpdate: { fromVersion: string; toVersion: string } | null = null;
|
|
23
23
|
|
|
24
|
-
/** Read current version from package.json */
|
|
25
|
-
function
|
|
24
|
+
/** Read current version from package.json on disk (reflects the latest install, not necessarily what's loaded in memory) */
|
|
25
|
+
function readVersionFromDisk(): string {
|
|
26
26
|
try {
|
|
27
27
|
const packagePath = join(import.meta.dir, '..', '..', '..', 'package.json');
|
|
28
28
|
const pkg = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
|
@@ -32,6 +32,15 @@ function getCurrentVersion(): string {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Version actually loaded into this running process, captured once at module load.
|
|
37
|
+
* If a `clopen update` CLI run (a separate process) updates package.json on disk
|
|
38
|
+
* while this server keeps running, readVersionFromDisk() will report the new
|
|
39
|
+
* version immediately even though this process is still executing the old code —
|
|
40
|
+
* runningVersion lets us detect that drift and keep flagging "restart required".
|
|
41
|
+
*/
|
|
42
|
+
const runningVersion = readVersionFromDisk();
|
|
43
|
+
|
|
35
44
|
/** Fetch latest version from npm registry */
|
|
36
45
|
async function fetchLatestVersion(): Promise<string> {
|
|
37
46
|
const response = await fetch('https://registry.npmjs.org/@myrialabs/clopen/latest');
|
|
@@ -71,16 +80,23 @@ export const operationsHandler = createRouter()
|
|
|
71
80
|
}))
|
|
72
81
|
})
|
|
73
82
|
}, async () => {
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
debug.log('server', `Checking for updates... running version: ${runningVersion}`);
|
|
84
|
+
|
|
85
|
+
// If a `clopen update` CLI run (separate process) already updated package.json
|
|
86
|
+
// on disk while this server kept running, the disk version won't match what's
|
|
87
|
+
// actually loaded in memory. Treat that drift as an implicit pending restart.
|
|
88
|
+
const diskVersion = readVersionFromDisk();
|
|
89
|
+
if (pendingUpdate === null && diskVersion !== runningVersion) {
|
|
90
|
+
pendingUpdate = { fromVersion: runningVersion, toVersion: diskVersion };
|
|
91
|
+
}
|
|
76
92
|
|
|
77
93
|
const latestVersion = await fetchLatestVersion();
|
|
78
|
-
const updateAvailable = isNewerVersion(
|
|
94
|
+
const updateAvailable = isNewerVersion(runningVersion, latestVersion);
|
|
79
95
|
|
|
80
96
|
debug.log('server', `Latest version: ${latestVersion}, update available: ${updateAvailable}`);
|
|
81
97
|
|
|
82
98
|
return {
|
|
83
|
-
currentVersion,
|
|
99
|
+
currentVersion: runningVersion,
|
|
84
100
|
latestVersion,
|
|
85
101
|
updateAvailable,
|
|
86
102
|
pendingRestart: pendingUpdate !== null,
|
|
@@ -88,27 +104,27 @@ export const operationsHandler = createRouter()
|
|
|
88
104
|
};
|
|
89
105
|
})
|
|
90
106
|
|
|
91
|
-
// Fetch
|
|
107
|
+
// Fetch the last few releases (changelog) from GitHub
|
|
92
108
|
.http('system:get-release-notes', {
|
|
93
109
|
data: t.Object({}),
|
|
94
|
-
response: t.Object({
|
|
110
|
+
response: t.Array(t.Object({
|
|
95
111
|
tag_name: t.String(),
|
|
96
112
|
body: t.String(),
|
|
97
113
|
html_url: t.String(),
|
|
98
114
|
published_at: t.String()
|
|
99
|
-
})
|
|
115
|
+
}))
|
|
100
116
|
}, async () => {
|
|
101
|
-
const response = await fetch('https://api.github.com/repos/myrialabs/clopen/releases
|
|
117
|
+
const response = await fetch('https://api.github.com/repos/myrialabs/clopen/releases?per_page=3');
|
|
102
118
|
if (!response.ok) {
|
|
103
119
|
throw new Error(`GitHub API returned ${response.status}`);
|
|
104
120
|
}
|
|
105
|
-
const data = await response.json() as { tag_name: string; body: string; html_url: string; published_at: string }
|
|
106
|
-
return {
|
|
107
|
-
tag_name:
|
|
108
|
-
body:
|
|
109
|
-
html_url:
|
|
110
|
-
published_at:
|
|
111
|
-
};
|
|
121
|
+
const data = await response.json() as Array<{ tag_name: string; body: string; html_url: string; published_at: string }>;
|
|
122
|
+
return data.map(release => ({
|
|
123
|
+
tag_name: release.tag_name,
|
|
124
|
+
body: release.body || '',
|
|
125
|
+
html_url: release.html_url,
|
|
126
|
+
published_at: release.published_at
|
|
127
|
+
}));
|
|
112
128
|
})
|
|
113
129
|
|
|
114
130
|
// Run package update
|
|
@@ -139,7 +155,7 @@ export const operationsHandler = createRouter()
|
|
|
139
155
|
throw new Error(`Update failed (exit code ${exitCode}): ${output}`);
|
|
140
156
|
}
|
|
141
157
|
|
|
142
|
-
const fromVersion =
|
|
158
|
+
const fromVersion = runningVersion;
|
|
143
159
|
|
|
144
160
|
// Re-fetch to confirm new version
|
|
145
161
|
const newVersion = await fetchLatestVersion();
|
|
@@ -21,6 +21,9 @@ const TOOL_UNION = t.Union([
|
|
|
21
21
|
t.Literal('copilot'),
|
|
22
22
|
t.Literal('codex'),
|
|
23
23
|
t.Literal('qwen'),
|
|
24
|
+
t.Literal('pi'),
|
|
25
|
+
t.Literal('cline'),
|
|
26
|
+
t.Literal('cursor'),
|
|
24
27
|
t.Literal('chrome'),
|
|
25
28
|
]);
|
|
26
29
|
|
|
@@ -47,7 +50,9 @@ const STATUS_SCHEMA = t.Object({
|
|
|
47
50
|
tool: TOOL_UNION,
|
|
48
51
|
installed: t.Boolean(),
|
|
49
52
|
version: t.Union([t.String(), t.Null()]),
|
|
50
|
-
source: t.Union([t.String(), t.Null()])
|
|
53
|
+
source: t.Union([t.String(), t.Null()]),
|
|
54
|
+
requiredVersion: t.Optional(t.Union([t.String(), t.Null()])),
|
|
55
|
+
needsUpdate: t.Optional(t.Boolean())
|
|
51
56
|
});
|
|
52
57
|
|
|
53
58
|
const ACTIVE_SESSION_SCHEMA = t.Union([
|
|
@@ -126,7 +131,7 @@ export const systemToolsStatusHandler = createRouter()
|
|
|
126
131
|
})
|
|
127
132
|
}, async () => {
|
|
128
133
|
debug.log('path', 'system-tools:status-all');
|
|
129
|
-
const ids = ['git', 'claude', 'opencode', 'copilot', 'codex', 'qwen', 'chrome'] as const;
|
|
134
|
+
const ids = ['git', 'claude', 'opencode', 'copilot', 'codex', 'qwen', 'pi', 'cline', 'cursor', 'chrome'] as const;
|
|
130
135
|
const tools = await Promise.all(ids.map(async (id) => {
|
|
131
136
|
const [status, recipe] = await Promise.all([
|
|
132
137
|
getToolStatus(id),
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
import { createRouter } from '$shared/utils/ws-server';
|
|
11
11
|
import { operationsHandler } from './operations';
|
|
12
12
|
import { configHandler } from './config';
|
|
13
|
+
import { shareHandler } from './share';
|
|
13
14
|
|
|
14
15
|
export const tunnelRouter = createRouter()
|
|
15
16
|
.merge(operationsHandler)
|
|
16
|
-
.merge(configHandler)
|
|
17
|
+
.merge(configHandler)
|
|
18
|
+
.merge(shareHandler);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Access share handler.
|
|
3
|
+
*
|
|
4
|
+
* `share:ensure-origin` returns a public origin that Remote Access share links
|
|
5
|
+
* are built against, transparently starting a Cloudflare quick tunnel to
|
|
6
|
+
* Clopen's own port only when the app isn't already reachable on a real domain.
|
|
7
|
+
* Any authenticated user may call it (members add their own devices); invite
|
|
8
|
+
* creation stays admin-gated on its own route.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { t } from 'elysia';
|
|
12
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
13
|
+
import { resolvePublicOrigin } from '../../tunnel/public-origin';
|
|
14
|
+
|
|
15
|
+
export const shareHandler = createRouter()
|
|
16
|
+
.http('share:ensure-origin', {
|
|
17
|
+
data: t.Object({
|
|
18
|
+
/** The client's own window.location.origin — used to detect an already-public deployment. */
|
|
19
|
+
requestOrigin: t.Optional(t.String())
|
|
20
|
+
}),
|
|
21
|
+
response: t.Object({
|
|
22
|
+
origin: t.String(),
|
|
23
|
+
source: t.Union([t.Literal('configured'), t.Literal('domain'), t.Literal('tunnel')])
|
|
24
|
+
})
|
|
25
|
+
}, async ({ data }) => {
|
|
26
|
+
return resolvePublicOrigin(data.requestOrigin);
|
|
27
|
+
});
|
package/bin/clopen.ts
CHANGED
|
@@ -282,7 +282,7 @@ async function runUpdate() {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
console.log(`✓ Updated to v${latestVersion}`);
|
|
285
|
-
console.log(
|
|
285
|
+
console.log(`\n Update installed. Restart Clopen however you normally run it to apply v${latestVersion}.`);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
async function recoverAdminToken() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as ce}from"./main-HirJLquI.js";async function ot(s={}){var t,e=s,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,o=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(o){const{createRequire:n}=await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);var l=n(import.meta.url)}var p=(n,c)=>{throw c},m=import.meta.url,z="";function _(n){return e.locateFile?e.locateFile(n,z):z+n}var x,A;if(o){var a=l("node:fs");m.startsWith("file:")&&(z=l("node:path").dirname(l("node:url").fileURLToPath(m))+"/"),A=n=>{n=u(n)?new URL(n):n;var c=a.readFileSync(n);return c},x=async(n,c=!0)=>{n=u(n)?new URL(n):n;var f=a.readFileSync(n,c?void 0:"utf8");return f},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),p=(n,c)=>{throw process.exitCode=n,c}}else if(r||i){try{z=new URL(".",m).href}catch{}x=async n=>{var c=await fetch(n,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}}var R=console.log.bind(console),C=console.error.bind(console),U,M=!1,T,u=n=>n.startsWith("file://"),d,D,B=!1;function E(){var n=ae.buffer;e.HEAPU8=V=new Uint8Array(n),P=new Uint32Array(n),Q=new BigInt64Array(n),new BigUint64Array(n)}function te(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Me(e.preRun.shift());ze(ye)}function fe(){B=!0,L.m()}function Y(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Be(e.postRun.shift());ze(ge)}function X(n){e.onAbort?.(n),n=`Aborted(${n})`,C(n),M=!0,n+=". Build with -sASSERTIONS for more info.";var c=new WebAssembly.RuntimeError(n);throw D?.(c),c}var J;function ne(){return e.locateFile?_("zipkit-engine.wasm"):new URL("/assets/zipkit-engine-CaR0t_Uy.wasm",import.meta.url).href}function re(n){if(n==J&&U)return new Uint8Array(U);if(A)return A(n);throw"both async and sync fetching of the wasm failed"}async function K(n){if(!U)try{var c=await x(n);return new Uint8Array(c)}catch{}return re(n)}async function F(n,c){try{var f=await K(n),h=await WebAssembly.instantiate(f,c);return h}catch(b){C(`failed to asynchronously prepare wasm: ${b}`),X(b)}}async function _e(n,c,f){if(!n&&!o)try{var h=fetch(c,{credentials:"same-origin"}),b=await WebAssembly.instantiateStreaming(h,f);return b}catch(v){C(`wasm streaming compile failed: ${v}`),C("falling back to ArrayBuffer instantiation")}return F(c,f)}function se(){var n={a:rt};return n}async function ie(){function n(v,k){return L=v.exports,L=st(L),nt(L),E(),L}function c(v){return n(v.instance)}var f=se();if(e.instantiateWasm)return new Promise((v,k)=>{e.instantiateWasm(f,(I,N)=>{v(n(I))})});J??=ne();var h=await _e(U,J,f),b=c(h);return b}class oe{name="ExitStatus";constructor(c){this.message=`Program terminated with exit(${c})`,this.status=c}}var Q,P,V,ze=n=>{for(;n.length>0;)n.shift()(e)},ge=[],Be=n=>ge.push(n),ye=[],Me=n=>ye.push(n),me=!0,be=globalThis.TextDecoder&&new TextDecoder,Ie=(n,c,f,h)=>{for(var b=c+f;n[c]&&!(c>=b);)++c;return c},we=(n,c=0,f,h)=>{c>>>=0;var b=Ie(n,c,f);if(b-c>16&&n.buffer&&be)return be.decode(n.subarray(c,b));for(var v="";c<b;){var k=n[c++];if(!(k&128)){v+=String.fromCharCode(k);continue}var I=n[c++]&63;if((k&224)==192){v+=String.fromCharCode((k&31)<<6|I);continue}var N=n[c++]&63;if((k&240)==224?k=(k&15)<<12|I<<6|N:k=(k&7)<<18|I<<12|N<<6|n[c++]&63,k<65536)v+=String.fromCharCode(k);else{var Te=k-65536;v+=String.fromCharCode(55296|Te>>10,56320|Te&1023)}}return v},he=(n,c,f)=>(n>>>=0,n?we(V,n,c):"");function We(n,c,f,h){return n>>>=0,c>>>=0,h>>>=0,X(`Assertion failed: ${he(n)}, at: `+[c?he(c):"unknown filename",f,h?he(h):"unknown function"])}var Le=()=>X(""),ve=0,Ne=()=>{me=!1,ve=0},O={},ke=n=>{if(n instanceof oe||n=="unwind")return T;p(1,n)},xe=()=>me||ve>0,Ae=n=>{T=n,xe()||(e.onExit?.(n),M=!0),p(n,new oe(n))},He=(n,c)=>{T=n,Ae(n)},Se=He,Ke=()=>{if(!xe())try{Se(T)}catch(n){ke(n)}},Fe=n=>{if(!M)try{return n()}catch(c){ke(c)}finally{Ke()}},Re=()=>performance.now(),Ve=(n,c)=>{if(O[n]&&(clearTimeout(O[n].id),delete O[n]),!c)return 0;var f=setTimeout(()=>{delete O[n],Fe(()=>Ce(n,Re()))},c);return O[n]={id:f,timeout_ms:c},0},qe=()=>Date.now(),$e=n=>n>=0&&n<=3;function je(n,c,f){if(f>>>=0,!$e(n))return 28;var h;n===0?h=qe():h=Re();var b=Math.round(h*1e3*1e3);return Q[f>>>3>>>0]=BigInt(b),0}var Ze=()=>4294901760,Ge=(n,c)=>Math.ceil(n/c)*c,Ye=n=>{var c=ae.buffer.byteLength,f=(n-c+65535)/65536|0;try{return ae.grow(f),E(),1}catch{}};function Xe(n){n>>>=0;var c=V.length,f=Ze();if(n>f)return!1;for(var h=1;h<=4;h*=2){var b=c*(1+.2/h);b=Math.min(b,n+100663296);var v=Math.min(f,Ge(Math.max(n,b),65536)),k=Ye(v);if(k)return!0}return!1}var Je=n=>52;function Qe(n,c,f,h){return 70}var Oe=[null,[],[]],et=(n,c)=>{var f=Oe[n];c===0||c===10?((n===1?R:C)(we(f)),f.length=0):f.push(c)};function tt(n,c,f,h){c>>>=0,f>>>=0,h>>>=0;for(var b=0,v=0;v<f;v++){var k=P[c>>>2>>>0],I=P[c+4>>>2>>>0];c+=8;for(var N=0;N<I;N++)et(n,V[k+N>>>0]);b+=I}return P[h>>>2>>>0]=b,0}if(e.noExitRuntime&&(me=e.noExitRuntime),e.print&&(R=e.print),e.printErr&&(C=e.printErr),e.wasmBinary&&(U=e.wasmBinary),e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.shift()();var Ce,ae;function nt(n){e._zk_input_ptr=n.n,e._zk_result_ptr=n.o,e._zk_result_len=n.p,e._zk_gzip_compress=n.q,e._zk_gzip_decompress=n.r,e._zk_deflate_compress=n.s,e._zk_deflate_decompress=n.t,e._zk_zlib_compress=n.u,e._zk_zlib_decompress=n.v,e._zk_crc32=n.w,e._zk_lz4_compress=n.x,e._zk_lz4_decompress=n.y,e._zk_zstd_compress=n.z,e._zk_zstd_decompress=n.A,e._zk_brotli_compress=n.B,e._zk_brotli_decompress=n.C,e._zk_snappy_compress=n.D,e._zk_snappy_decompress=n.E,e._zk_zstd_max_compress=n.F,e._zk_set_aux=n.G,e._zk_zstd_train_dict=n.H,e._zk_zstd_compress_dict=n.I,e._zk_zstd_decompress_dict=n.J,e._zk_lzma_compress=n.K,e._zk_lzma_decompress=n.L,e._zk_xz_ok=n.M,e._zk_xz_compress=n.N,e._zk_xz_decompress=n.O,e._zk_lzma2_decompress=n.P,e._zk_bzip2_compress=n.Q,e._zk_bzip2_decompress=n.R,e._zk_qoi_encode=n.S,e._zk_qoi_decode=n.T,e._zk_frame_delta_encode=n.U,e._zk_frame_delta_decode=n.V,Ce=n.W,ae=n.l,n.__indirect_function_table}var rt={a:We,f:Le,e:Ne,k:Ve,h:je,c:Xe,b:Se,j:Je,g:Qe,i:tt,d:Ae};function st(n){n=Object.assign({},n);var c=h=>b=>h(b)>>>0,f=h=>()=>h()>>>0;return n._emscripten_stack_alloc=c(n._emscripten_stack_alloc),n.emscripten_stack_get_current=f(n.emscripten_stack_get_current),n}function it(){te();function n(){e.calledRun=!0,!M&&(fe(),d?.(e),e.onRuntimeInitialized?.(),Y())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}var L;return L=await ie(),it(),B?t=e:t=new Promise((n,c)=>{d=n,D=c}),t}class ue{m;constructor(t){this.m=t}static async load(){const t=await ot();return new ue(t)}call(t,e){const r=this.m,i=r._zk_input_ptr(e.length);r.HEAPU8.set(e,i),t(e.length);const o=r._zk_result_ptr(),l=r._zk_result_len()>>>0;return r.HEAPU8.slice(o,o+l)}gzipCompress(t,e=9){return this.call(r=>this.m._zk_gzip_compress(r,e),t)}gzipDecompress(t){return this.call(e=>this.m._zk_gzip_decompress(e),t)}deflateCompress(t,e=9){return this.call(r=>this.m._zk_deflate_compress(r,e),t)}deflateDecompress(t){return this.call(e=>this.m._zk_deflate_decompress(e,0),t)}zlibCompress(t,e=9){return this.call(r=>this.m._zk_zlib_compress(r,e),t)}zlibDecompress(t){return this.call(e=>this.m._zk_zlib_decompress(e,0),t)}crc32(t,e=0){const r=this.m,i=r._zk_input_ptr(t.length);return r.HEAPU8.set(t,i),r._zk_crc32(t.length,e>>>0)>>>0}lz4Compress(t){return this.call(e=>this.m._zk_lz4_compress(e),t)}lz4Decompress(t){return this.call(e=>this.m._zk_lz4_decompress(e),t)}zstdCompress(t,e=19){return this.call(r=>this.m._zk_zstd_compress(r,e),t)}zstdDecompress(t){return this.call(e=>this.m._zk_zstd_decompress(e),t)}brotliCompress(t,e=11){return this.call(r=>this.m._zk_brotli_compress(r,e),t)}brotliDecompress(t){return this.call(e=>this.m._zk_brotli_decompress(e),t)}snappyCompress(t){return this.call(e=>this.m._zk_snappy_compress(e),t)}snappyDecompress(t){return this.call(e=>this.m._zk_snappy_decompress(e),t)}zstdMaxCompress(t,e=22){return this.call(r=>this.m._zk_zstd_max_compress(r,e),t)}lzmaCompress(t,e=9){return this.call(r=>this.m._zk_lzma_compress(r,e),t)}lzmaDecompress(t){return this.call(e=>this.m._zk_lzma_decompress(e),t)}lzma2Decompress(t,e,r){return this.call(i=>this.m._zk_lzma2_decompress(i,e,r),t)}xzCompress(t,e=6){const r=this.call(i=>this.m._zk_xz_compress(i,e),t);if(!this.m._zk_xz_ok())throw new Error("xz compression failed");return r}xzDecompress(t){const e=this.call(r=>this.m._zk_xz_decompress(r),t);if(!this.m._zk_xz_ok())throw new Error("xz decompression failed (corrupt stream or unsupported filter)");return e}setAux(t){const e=this.m,r=e._zk_input_ptr(t.length);e.HEAPU8.set(t,r),e._zk_set_aux(t.length)}zstdTrainDict(t,e,r){const i=this.m,o=i._zk_input_ptr(t.length);i.HEAPU8.set(t,o),i._zk_zstd_train_dict(t.length,e,r);const l=i._zk_result_ptr(),p=i._zk_result_len()>>>0;return i.HEAPU8.slice(l,l+p)}zstdCompressDict(t,e=19){return this.call(r=>this.m._zk_zstd_compress_dict(r,e),t)}zstdDecompressDict(t){return this.call(e=>this.m._zk_zstd_decompress_dict(e),t)}bzip2Compress(t,e=9){return this.call(r=>this.m._zk_bzip2_compress(r,e),t)}bzip2Decompress(t){return this.call(e=>this.m._zk_bzip2_decompress(e),t)}qoiEncode(t,e,r,i){return this.call(o=>this.m._zk_qoi_encode(o,e,r,i),t)}qoiDecode(t){return this.call(e=>this.m._zk_qoi_decode(e),t)}frameDeltaEncode(t,e){return this.call(r=>this.m._zk_frame_delta_encode(r,e),t)}frameDeltaDecode(t,e){return this.call(r=>this.m._zk_frame_delta_decode(r,e),t)}}let at;function w(){return at??=ue.load()}const ct=Object.freeze(Object.defineProperty({__proto__:null,ZipKitEngine:ue,getEngine:w},Symbol.toStringTag,{value:"Module"}));class pe extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class ee extends Error{constructor(t){super(t),this.name="ZipKitError"}}function lt(s,t,e,r){return s===void 0||!Number.isFinite(s)?r:Math.max(t,Math.min(e,Math.round(s)))}function de(s){return s?.mode??"balanced"}function H(s,t,e,r){return lt(s?.level,t,e,r[de(s)])}function W(){return globalThis.Bun}function ut(s){if(s?.aborted)throw new pe}async function y(s,t,e){ut(t?.signal),t?.onProgress?.(0,0);const r=s();return t?.onProgress?.(1,e),r}function ft(s){return de(s)!=="ratio"&&!!W()?.gzipSync}async function _t(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ft(t))return y(()=>r.gzipSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.gzipCompress(s,e),t,s.length)}async function mt(s,t){const e=W();if(e?.gunzipSync)return y(()=>e.gunzipSync(s),t,s.length);const r=await w();return y(()=>r.gzipDecompress(s),t,s.length)}function ht(s){return de(s)!=="ratio"&&!!W()?.deflateSync}async function pt(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ht(t))return y(()=>r.deflateSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.deflateCompress(s,e),t,s.length)}async function dt(s,t){const e=W();if(e?.inflateSync)return y(()=>e.inflateSync(s),t,s.length);const r=await w();return y(()=>r.deflateDecompress(s),t,s.length)}async function zt(s,t){const e=await w(),r=H(t,0,9,{speed:1,balanced:6,ratio:9});return y(()=>e.zlibCompress(s,r),t,s.length)}async function gt(s,t){const e=await w();return y(()=>e.zlibDecompress(s),t,s.length)}async function yt(s,t){const e=H(t,1,22,{speed:1,balanced:3,ratio:19}),r=W();if(r?.zstdCompressSync)return y(()=>r.zstdCompressSync(s,{level:e}),t,s.length);const i=await w(),o=e>19?()=>i.zstdMaxCompress(s,e):()=>i.zstdCompress(s,e);return y(o,t,s.length)}async function bt(s,t){const e=W();if(e?.zstdDecompressSync)return y(()=>e.zstdDecompressSync(s),t,s.length);const r=await w();return y(()=>r.zstdDecompress(s),t,s.length)}async function wt(s,t){const e=await w();return y(()=>e.lz4Compress(s),t,s.length)}async function vt(s,t){const e=await w();return y(()=>e.lz4Decompress(s),t,s.length)}async function kt(s,t){const e=await w();return y(()=>e.snappyCompress(s),t,s.length)}async function xt(s,t){const e=await w();return y(()=>e.snappyDecompress(s),t,s.length)}async function At(s,t){const e=await w(),r=H(t,0,11,{speed:4,balanced:6,ratio:11});return y(()=>e.brotliCompress(s,r),t,s.length)}async function St(s,t){const e=await w();return y(()=>e.brotliDecompress(s),t,s.length)}async function Rt(s,t){const e=await w(),r=H(t,0,9,{speed:3,balanced:6,ratio:9});return y(()=>e.lzmaCompress(s,r),t,s.length)}async function Ct(s,t){const e=await w();return y(()=>e.lzmaDecompress(s),t,s.length)}async function Tt(s,t){const e=await w(),r=H(t,1,9,{speed:1,balanced:6,ratio:9});return y(()=>e.bzip2Compress(s,r),t,s.length)}async function Dt(s,t){const e=await w();return y(()=>e.bzip2Decompress(s),t,s.length)}const Pt={gzip:_t,deflate:pt,zlib:zt,zstd:yt,lz4:wt,snappy:kt,brotli:At,lzma:Rt,bzip2:Tt},Ut={gzip:mt,deflate:dt,zlib:gt,zstd:bt,lz4:vt,snappy:xt,brotli:St,lzma:Ct,bzip2:Dt};function Et(s,t,e){const r=Pt[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}function Bt(s,t,e){const r=Ut[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}const Mt=Object.freeze(Object.defineProperty({__proto__:null,compress:Et,decompressWith:Bt},Symbol.toStringTag,{value:"Module"})),It=new URL(import.meta.url.endsWith(".ts")?"./worker.ts":"./worker.js",import.meta.url);function Wt(){const s=globalThis.navigator?.hardwareConcurrency??4;return Math.max(1,Math.min(s,8))}async function Lt(){try{return await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[])}catch{return}}class Nt{size;workers=[];pending=new Map;next=0;seq=0;ready;usable=!0;refWhileBusy(){const t=this.pending.size>0;for(const e of this.workers)(t?e.ref:e.unref).call(e)}constructor(t={}){this.size=t.size??Wt()}async ensure(){return this.ready?this.ready:(this.ready=(async()=>{const t=await Lt();if(!t){this.usable=!1;return}for(let e=0;e<this.size;e++){const r=new t.Worker(It);r.on("message",i=>this.settle(i)),r.on("error",i=>this.failAll(i)),r.unref(),this.workers.push(r)}})(),this.ready)}settle(t){const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),this.refWhileBusy(),e.signal&&e.onAbort&&e.signal.removeEventListener("abort",e.onAbort),t.ok&&t.result?e.resolve(t.result):e.reject(new Error(t.error??"Worker operation failed")))}failAll(t){for(const[,e]of this.pending)e.reject(t);this.pending.clear(),this.refWhileBusy()}async run(t,e,r,i,o,l,p){if(l?.aborted)throw new pe;if(await this.ensure(),!this.usable){if(t==="zipCompress"){const{getEngine:A}=await ce(async()=>{const{getEngine:R}=await Promise.resolve().then(()=>ct);return{getEngine:R}},void 0),a=await A();return p==="zstd"?a.zstdCompress(e,i??19):a.deflateCompress(e,i??6)}const{compress:_,decompressWith:x}=await ce(async()=>{const{compress:A,decompressWith:a}=await Promise.resolve().then(()=>Mt);return{compress:A,decompressWith:a}},void 0);return t==="compress"?_(e,r,{level:i,mode:o}):x(e,r)}const m=this.seq++,z=this.workers[this.next++%this.workers.length];return new Promise((_,x)=>{const A={resolve:_,reject:x,signal:l};l&&(A.onAbort=()=>{this.pending.delete(m),this.refWhileBusy(),x(new pe)},l.addEventListener("abort",A.onAbort,{once:!0})),this.pending.set(m,A),this.refWhileBusy();const a=e.slice(),R={id:m,kind:t,codec:r,level:i,mode:o,method:p,data:a};z.postMessage(R,[a.buffer])})}compress(t,e,r){return this.run("compress",t,e,r?.level,r?.mode,r?.signal)}decompress(t,e,r){return this.run("decompress",t,e,void 0,void 0,r?.signal)}zipCompress(t,e,r){return this.run("zipCompress",t,e,r,void 0,void 0,e)}async destroy(){this.failAll(new Error("Worker pool destroyed")),await Promise.all(this.workers.map(t=>t.terminate())),this.workers=[],this.ready=void 0}}let Ht;function Kt(){return Ht??=new Nt}function Ft(s){const e=(Math.max(1980,s.getFullYear())-1980&127)<<9|s.getMonth()+1<<5|s.getDate(),r=s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1;return{date:e,time:r}}let g,$,j,Z,G;const Vt=new Uint32Array([16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,452984832,905969664]);function qt(){g=new Uint8Array(256);const s=new Uint8Array(256);let t=1,e=1;do t=t^t<<1^(t&128?283:0),t&=255,e^=e<<1,e^=e<<2,e^=e<<4,e&=255,e&128&&(e^=9),e&=255,s[t]=e;while(t!==1);g[0]=99;for(let r=0;r<256;r++){let i=s[r],o=i;for(let l=0;l<4;l++)o=(o<<1|o>>>7)&255,i^=o;i^=99,g[r]=r===0?99:i}$=new Uint32Array(256),j=new Uint32Array(256),Z=new Uint32Array(256),G=new Uint32Array(256);for(let r=0;r<256;r++){const i=g[r],o=$t(i),l=o^i;$[r]=(o<<24|i<<16|i<<8|l)>>>0,j[r]=(l<<24|o<<16|i<<8|i)>>>0,Z[r]=(i<<24|l<<16|o<<8|i)>>>0,G[r]=(i<<24|i<<16|l<<8|o)>>>0}}function $t(s){return(s<<1^(s&128?283:0))&255}class jt{rk;rounds;constructor(t){if(g||qt(),t.length!==16&&t.length!==24&&t.length!==32)throw new Error(`AES key must be 16/24/32 bytes, got ${t.length}`);const e=t.length/4;this.rounds=e+6;const r=4*(this.rounds+1),i=new Uint32Array(r);for(let o=0;o<e;o++)i[o]=(t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3])>>>0;for(let o=e;o<r;o++){let l=i[o-1];o%e===0?l=(De(l<<8|l>>>24)^Vt[o/e-1])>>>0:e>6&&o%e===4&&(l=De(l)),i[o]=(i[o-e]^l)>>>0}this.rk=i}encryptBlock(t,e,r,i){const o=this.rk;let l=(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])^o[0],p=(t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7])^o[1],m=(t[e+8]<<24|t[e+9]<<16|t[e+10]<<8|t[e+11])^o[2],z=(t[e+12]<<24|t[e+13]<<16|t[e+14]<<8|t[e+15])^o[3],_=4;for(let x=1;x<this.rounds;x++){const A=($[l>>>24&255]^j[p>>>16&255]^Z[m>>>8&255]^G[z&255]^o[_])>>>0,a=($[p>>>24&255]^j[m>>>16&255]^Z[z>>>8&255]^G[l&255]^o[_+1])>>>0,R=($[m>>>24&255]^j[z>>>16&255]^Z[l>>>8&255]^G[p&255]^o[_+2])>>>0,C=($[z>>>24&255]^j[l>>>16&255]^Z[p>>>8&255]^G[m&255]^o[_+3])>>>0;l=A,p=a,m=R,z=C,_+=4}r[i]=(g[l>>>24&255]^o[_]>>>24)&255,r[i+1]=(g[p>>>16&255]^o[_]>>>16)&255,r[i+2]=(g[m>>>8&255]^o[_]>>>8)&255,r[i+3]=(g[z&255]^o[_])&255,r[i+4]=(g[p>>>24&255]^o[_+1]>>>24)&255,r[i+5]=(g[m>>>16&255]^o[_+1]>>>16)&255,r[i+6]=(g[z>>>8&255]^o[_+1]>>>8)&255,r[i+7]=(g[l&255]^o[_+1])&255,r[i+8]=(g[m>>>24&255]^o[_+2]>>>24)&255,r[i+9]=(g[z>>>16&255]^o[_+2]>>>16)&255,r[i+10]=(g[l>>>8&255]^o[_+2]>>>8)&255,r[i+11]=(g[p&255]^o[_+2])&255,r[i+12]=(g[z>>>24&255]^o[_+3]>>>24)&255,r[i+13]=(g[l>>>16&255]^o[_+3]>>>16)&255,r[i+14]=(g[p>>>8&255]^o[_+3]>>>8)&255,r[i+15]=(g[m&255]^o[_+3])&255}}function De(s){return(g[s>>>24&255]<<24|g[s>>>16&255]<<16|g[s>>>8&255]<<8|g[s&255])>>>0}function Zt(s,t){const e=new Uint8Array(t.length),r=new Uint8Array(16),i=new Uint8Array(16);let o=1;for(let l=0;l<t.length;l+=16){r[0]=o&255,r[1]=o>>>8&255,r[2]=o>>>16&255,r[3]=o>>>24&255,s.encryptBlock(r,0,i,0);const p=Math.min(16,t.length-l);for(let m=0;m<p;m++)e[l+m]=t[l+m]^i[m];o++}return e}const Gt={1:16,2:24,3:32},Yt={1:8,2:12,3:16},Ee=10,Xt=1e3;function le(){const s=globalThis.crypto;if(!s?.subtle)throw new ee("WebCrypto (crypto.subtle) is required for ZIP AES encryption");return s.subtle}function Jt(s){const t=globalThis.crypto;if(!t?.getRandomValues)throw new ee("crypto.getRandomValues is required to create encrypted ZIPs");return t.getRandomValues(new Uint8Array(s))}async function Qt(s,t,e){const r=Gt[e],i=await le().importKey("raw",new TextEncoder().encode(s),"PBKDF2",!1,["deriveBits"]),o=await le().deriveBits({name:"PBKDF2",salt:t,iterations:Xt,hash:"SHA-1"},i,(r*2+2)*8),l=new Uint8Array(o);return{aesKey:l.subarray(0,r),macKey:l.subarray(r,r*2),verifier:l.subarray(r*2,r*2+2)}}async function Ot(s,t){const e=await le().importKey("raw",s,{name:"HMAC",hash:"SHA-1"},!1,["sign"]),r=await le().sign("HMAC",e,t);return new Uint8Array(r).subarray(0,Ee)}async function en(s,t,e=3){const r=Jt(Yt[e]),{aesKey:i,macKey:o,verifier:l}=await Qt(t,r,e),p=Zt(new jt(i),s),m=await Ot(o,p),z=new Uint8Array(r.length+2+p.length+Ee);return z.set(r,0),z.set(l,r.length),z.set(p,r.length+2),z.set(m,r.length+2+p.length),{payload:z,strength:e}}const tn=256*1024,nn=67324752,rn=33639248,sn=101010256,on=101075792,an=117853008,S=4294967295,q=65535,cn={store:0,deflate:8,zstd:93};class ln{buf=new Uint8Array(1024);view=new DataView(this.buf.buffer);len=0;grow(t){if(this.len+t<=this.buf.length)return;let e=this.buf.length*2;for(;e<this.len+t;)e*=2;const r=new Uint8Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r,this.view=new DataView(this.buf.buffer)}u16(t){this.grow(2),this.view.setUint16(this.len,t,!0),this.len+=2}u32(t){this.grow(4),this.view.setUint32(this.len,t>>>0,!0),this.len+=4}u64(t){this.grow(8),this.view.setBigUint64(this.len,BigInt(t),!0),this.len+=8}bytes(t){this.grow(t.length),this.buf.set(t,this.len),this.len+=t.length}done(){return this.buf.slice(0,this.len)}}function Pe(s,t,e){s.u16(39169),s.u16(7),s.u16(2),s.u16(17729),s.bytes(new Uint8Array([t])),s.u16(e)}async function un(s,t,e){if(t==="store")return s;const r=await w();if(t==="deflate")return r.deflateCompress(s,e??6);if(t==="zstd")return r.zstdCompress(s,e??19);throw new ee(`Unsupported ZIP method: ${t}`)}const Ue=new TextEncoder;async function _n(s,t={}){const e=await w(),r=s.reduce((u,d)=>u+d.data.length,0),o=t.parallel??(s.length>=2&&r>=tn)?Kt():void 0,l=s.map(u=>e.crc32(u.data));let p=0;const m=t.onProgress,z=await Promise.all(s.map(u=>{const d=u.method??"deflate",D=d==="store"?Promise.resolve(u.data):o?o.zipCompress(u.data,d,u.level??(d==="zstd"?19:6)):un(u.data,d,u.level);return m?D.then(B=>(m(++p,s.length),B)):D})),_=3,x=t.password?await Promise.all(z.map(u=>en(u,t.password,_))):void 0,A=x?x.map(u=>u.payload):z,a=new ln,R=[];let C=s.length>q;for(let u=0;u<s.length;u++){const d=s[u],D=d.method??"deflate",B=cn[D],E=x!==void 0,te=E?99:B,fe=2048|(E?1:0),Y=Ue.encode(d.name),X=d.comment?Ue.encode(d.comment):new Uint8Array(0),J=l[u],ne=E?0:J,re=A[u],K=d.data.length,F=re.length,_e=d.mtime===void 0?new Date:new Date(d.mtime),{date:se,time:ie}=Ft(_e),oe=d.unixPermissions!==void 0?(d.unixPermissions&65535)<<16:0,Q=a.len,P=C||K>S||F>S||Q>S;P&&(C=!0);const V=(P?20:0)+(E?11:0);a.u32(nn),a.u16(P?45:20),a.u16(fe),a.u16(te),a.u16(ie),a.u16(se),a.u32(ne),a.u32(P?S:F),a.u32(P?S:K),a.u16(Y.length),a.u16(V),a.bytes(Y),P&&(a.u16(1),a.u16(16),a.u64(K),a.u64(F)),E&&Pe(a,_,B),a.bytes(re),R.push({nameBytes:Y,commentBytes:X,method:te,actualMethod:B,encrypted:E,crc:ne,compSize:F,size:K,dosDate:se,dosTime:ie,offset:Q,externalAttrs:oe,zip64:P})}const U=a.len;for(const u of R){a.u32(rn),a.u16(u.zip64?45:20),a.u16(u.zip64?45:20),a.u16(2048|(u.encrypted?1:0)),a.u16(u.method),a.u16(u.dosTime),a.u16(u.dosDate),a.u32(u.crc);const d=u.zip64;a.u32(d?S:u.compSize),a.u32(d?S:u.size),a.u16(u.nameBytes.length);const D=[];d&&D.push(u.size,u.compSize,u.offset);const B=(d?4+D.length*8:0)+(u.encrypted?11:0);if(a.u16(B),a.u16(u.commentBytes.length),a.u16(0),a.u16(0),a.u32(u.externalAttrs),a.u32(d?S:u.offset),a.bytes(u.nameBytes),d){a.u16(1),a.u16(D.length*8);for(const E of D)a.u64(E)}u.encrypted&&Pe(a,3,u.actualMethod),a.bytes(u.commentBytes)}const M=a.len-U,T=R.length;if(C||T>q||M>S||U>S){const u=a.len;a.u32(on),a.u64(44),a.u16(45),a.u16(45),a.u32(0),a.u32(0),a.u64(T),a.u64(T),a.u64(M),a.u64(U),a.u32(an),a.u32(0),a.u64(u),a.u32(1)}return a.u32(sn),a.u16(0),a.u16(0),a.u16(T>q?q:T),a.u16(T>q?q:T),a.u32(M>S?S:M),a.u32(U>S?S:U),a.u16(0),a.done()}new TextDecoder("utf-8");export{pe as AbortError,Nt as WorkerPool,ue as ZipKitEngine,ee as ZipKitError,At as brotli,Tt as bzip2,Et as compress,Bt as decompressWith,pt as deflate,w as getEngine,mt as gunzip,_t as gzip,dt as inflate,wt as lz4,Rt as lzma,Kt as sharedPool,kt as snappy,St as unbrotli,Dt as unbzip2,vt as unlz4,Ct as unlzma,xt as unsnappy,gt as unzlib,bt as unzstd,_n as zip,zt as zlib,yt as zstd};
|
|
1
|
+
import{_ as ce}from"./main-Dlba-fXF.js";async function ot(s={}){var t,e=s,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,o=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(o){const{createRequire:n}=await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);var l=n(import.meta.url)}var p=(n,c)=>{throw c},m=import.meta.url,z="";function _(n){return e.locateFile?e.locateFile(n,z):z+n}var x,A;if(o){var a=l("node:fs");m.startsWith("file:")&&(z=l("node:path").dirname(l("node:url").fileURLToPath(m))+"/"),A=n=>{n=u(n)?new URL(n):n;var c=a.readFileSync(n);return c},x=async(n,c=!0)=>{n=u(n)?new URL(n):n;var f=a.readFileSync(n,c?void 0:"utf8");return f},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),p=(n,c)=>{throw process.exitCode=n,c}}else if(r||i){try{z=new URL(".",m).href}catch{}x=async n=>{var c=await fetch(n,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}}var R=console.log.bind(console),C=console.error.bind(console),U,M=!1,T,u=n=>n.startsWith("file://"),d,D,B=!1;function E(){var n=ae.buffer;e.HEAPU8=V=new Uint8Array(n),P=new Uint32Array(n),Q=new BigInt64Array(n),new BigUint64Array(n)}function te(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Me(e.preRun.shift());ze(ye)}function fe(){B=!0,L.m()}function Y(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Be(e.postRun.shift());ze(ge)}function X(n){e.onAbort?.(n),n=`Aborted(${n})`,C(n),M=!0,n+=". Build with -sASSERTIONS for more info.";var c=new WebAssembly.RuntimeError(n);throw D?.(c),c}var J;function ne(){return e.locateFile?_("zipkit-engine.wasm"):new URL("/assets/zipkit-engine-CaR0t_Uy.wasm",import.meta.url).href}function re(n){if(n==J&&U)return new Uint8Array(U);if(A)return A(n);throw"both async and sync fetching of the wasm failed"}async function K(n){if(!U)try{var c=await x(n);return new Uint8Array(c)}catch{}return re(n)}async function F(n,c){try{var f=await K(n),h=await WebAssembly.instantiate(f,c);return h}catch(b){C(`failed to asynchronously prepare wasm: ${b}`),X(b)}}async function _e(n,c,f){if(!n&&!o)try{var h=fetch(c,{credentials:"same-origin"}),b=await WebAssembly.instantiateStreaming(h,f);return b}catch(v){C(`wasm streaming compile failed: ${v}`),C("falling back to ArrayBuffer instantiation")}return F(c,f)}function se(){var n={a:rt};return n}async function ie(){function n(v,k){return L=v.exports,L=st(L),nt(L),E(),L}function c(v){return n(v.instance)}var f=se();if(e.instantiateWasm)return new Promise((v,k)=>{e.instantiateWasm(f,(I,N)=>{v(n(I))})});J??=ne();var h=await _e(U,J,f),b=c(h);return b}class oe{name="ExitStatus";constructor(c){this.message=`Program terminated with exit(${c})`,this.status=c}}var Q,P,V,ze=n=>{for(;n.length>0;)n.shift()(e)},ge=[],Be=n=>ge.push(n),ye=[],Me=n=>ye.push(n),me=!0,be=globalThis.TextDecoder&&new TextDecoder,Ie=(n,c,f,h)=>{for(var b=c+f;n[c]&&!(c>=b);)++c;return c},we=(n,c=0,f,h)=>{c>>>=0;var b=Ie(n,c,f);if(b-c>16&&n.buffer&&be)return be.decode(n.subarray(c,b));for(var v="";c<b;){var k=n[c++];if(!(k&128)){v+=String.fromCharCode(k);continue}var I=n[c++]&63;if((k&224)==192){v+=String.fromCharCode((k&31)<<6|I);continue}var N=n[c++]&63;if((k&240)==224?k=(k&15)<<12|I<<6|N:k=(k&7)<<18|I<<12|N<<6|n[c++]&63,k<65536)v+=String.fromCharCode(k);else{var Te=k-65536;v+=String.fromCharCode(55296|Te>>10,56320|Te&1023)}}return v},he=(n,c,f)=>(n>>>=0,n?we(V,n,c):"");function We(n,c,f,h){return n>>>=0,c>>>=0,h>>>=0,X(`Assertion failed: ${he(n)}, at: `+[c?he(c):"unknown filename",f,h?he(h):"unknown function"])}var Le=()=>X(""),ve=0,Ne=()=>{me=!1,ve=0},O={},ke=n=>{if(n instanceof oe||n=="unwind")return T;p(1,n)},xe=()=>me||ve>0,Ae=n=>{T=n,xe()||(e.onExit?.(n),M=!0),p(n,new oe(n))},He=(n,c)=>{T=n,Ae(n)},Se=He,Ke=()=>{if(!xe())try{Se(T)}catch(n){ke(n)}},Fe=n=>{if(!M)try{return n()}catch(c){ke(c)}finally{Ke()}},Re=()=>performance.now(),Ve=(n,c)=>{if(O[n]&&(clearTimeout(O[n].id),delete O[n]),!c)return 0;var f=setTimeout(()=>{delete O[n],Fe(()=>Ce(n,Re()))},c);return O[n]={id:f,timeout_ms:c},0},qe=()=>Date.now(),$e=n=>n>=0&&n<=3;function je(n,c,f){if(f>>>=0,!$e(n))return 28;var h;n===0?h=qe():h=Re();var b=Math.round(h*1e3*1e3);return Q[f>>>3>>>0]=BigInt(b),0}var Ze=()=>4294901760,Ge=(n,c)=>Math.ceil(n/c)*c,Ye=n=>{var c=ae.buffer.byteLength,f=(n-c+65535)/65536|0;try{return ae.grow(f),E(),1}catch{}};function Xe(n){n>>>=0;var c=V.length,f=Ze();if(n>f)return!1;for(var h=1;h<=4;h*=2){var b=c*(1+.2/h);b=Math.min(b,n+100663296);var v=Math.min(f,Ge(Math.max(n,b),65536)),k=Ye(v);if(k)return!0}return!1}var Je=n=>52;function Qe(n,c,f,h){return 70}var Oe=[null,[],[]],et=(n,c)=>{var f=Oe[n];c===0||c===10?((n===1?R:C)(we(f)),f.length=0):f.push(c)};function tt(n,c,f,h){c>>>=0,f>>>=0,h>>>=0;for(var b=0,v=0;v<f;v++){var k=P[c>>>2>>>0],I=P[c+4>>>2>>>0];c+=8;for(var N=0;N<I;N++)et(n,V[k+N>>>0]);b+=I}return P[h>>>2>>>0]=b,0}if(e.noExitRuntime&&(me=e.noExitRuntime),e.print&&(R=e.print),e.printErr&&(C=e.printErr),e.wasmBinary&&(U=e.wasmBinary),e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.shift()();var Ce,ae;function nt(n){e._zk_input_ptr=n.n,e._zk_result_ptr=n.o,e._zk_result_len=n.p,e._zk_gzip_compress=n.q,e._zk_gzip_decompress=n.r,e._zk_deflate_compress=n.s,e._zk_deflate_decompress=n.t,e._zk_zlib_compress=n.u,e._zk_zlib_decompress=n.v,e._zk_crc32=n.w,e._zk_lz4_compress=n.x,e._zk_lz4_decompress=n.y,e._zk_zstd_compress=n.z,e._zk_zstd_decompress=n.A,e._zk_brotli_compress=n.B,e._zk_brotli_decompress=n.C,e._zk_snappy_compress=n.D,e._zk_snappy_decompress=n.E,e._zk_zstd_max_compress=n.F,e._zk_set_aux=n.G,e._zk_zstd_train_dict=n.H,e._zk_zstd_compress_dict=n.I,e._zk_zstd_decompress_dict=n.J,e._zk_lzma_compress=n.K,e._zk_lzma_decompress=n.L,e._zk_xz_ok=n.M,e._zk_xz_compress=n.N,e._zk_xz_decompress=n.O,e._zk_lzma2_decompress=n.P,e._zk_bzip2_compress=n.Q,e._zk_bzip2_decompress=n.R,e._zk_qoi_encode=n.S,e._zk_qoi_decode=n.T,e._zk_frame_delta_encode=n.U,e._zk_frame_delta_decode=n.V,Ce=n.W,ae=n.l,n.__indirect_function_table}var rt={a:We,f:Le,e:Ne,k:Ve,h:je,c:Xe,b:Se,j:Je,g:Qe,i:tt,d:Ae};function st(n){n=Object.assign({},n);var c=h=>b=>h(b)>>>0,f=h=>()=>h()>>>0;return n._emscripten_stack_alloc=c(n._emscripten_stack_alloc),n.emscripten_stack_get_current=f(n.emscripten_stack_get_current),n}function it(){te();function n(){e.calledRun=!0,!M&&(fe(),d?.(e),e.onRuntimeInitialized?.(),Y())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}var L;return L=await ie(),it(),B?t=e:t=new Promise((n,c)=>{d=n,D=c}),t}class ue{m;constructor(t){this.m=t}static async load(){const t=await ot();return new ue(t)}call(t,e){const r=this.m,i=r._zk_input_ptr(e.length);r.HEAPU8.set(e,i),t(e.length);const o=r._zk_result_ptr(),l=r._zk_result_len()>>>0;return r.HEAPU8.slice(o,o+l)}gzipCompress(t,e=9){return this.call(r=>this.m._zk_gzip_compress(r,e),t)}gzipDecompress(t){return this.call(e=>this.m._zk_gzip_decompress(e),t)}deflateCompress(t,e=9){return this.call(r=>this.m._zk_deflate_compress(r,e),t)}deflateDecompress(t){return this.call(e=>this.m._zk_deflate_decompress(e,0),t)}zlibCompress(t,e=9){return this.call(r=>this.m._zk_zlib_compress(r,e),t)}zlibDecompress(t){return this.call(e=>this.m._zk_zlib_decompress(e,0),t)}crc32(t,e=0){const r=this.m,i=r._zk_input_ptr(t.length);return r.HEAPU8.set(t,i),r._zk_crc32(t.length,e>>>0)>>>0}lz4Compress(t){return this.call(e=>this.m._zk_lz4_compress(e),t)}lz4Decompress(t){return this.call(e=>this.m._zk_lz4_decompress(e),t)}zstdCompress(t,e=19){return this.call(r=>this.m._zk_zstd_compress(r,e),t)}zstdDecompress(t){return this.call(e=>this.m._zk_zstd_decompress(e),t)}brotliCompress(t,e=11){return this.call(r=>this.m._zk_brotli_compress(r,e),t)}brotliDecompress(t){return this.call(e=>this.m._zk_brotli_decompress(e),t)}snappyCompress(t){return this.call(e=>this.m._zk_snappy_compress(e),t)}snappyDecompress(t){return this.call(e=>this.m._zk_snappy_decompress(e),t)}zstdMaxCompress(t,e=22){return this.call(r=>this.m._zk_zstd_max_compress(r,e),t)}lzmaCompress(t,e=9){return this.call(r=>this.m._zk_lzma_compress(r,e),t)}lzmaDecompress(t){return this.call(e=>this.m._zk_lzma_decompress(e),t)}lzma2Decompress(t,e,r){return this.call(i=>this.m._zk_lzma2_decompress(i,e,r),t)}xzCompress(t,e=6){const r=this.call(i=>this.m._zk_xz_compress(i,e),t);if(!this.m._zk_xz_ok())throw new Error("xz compression failed");return r}xzDecompress(t){const e=this.call(r=>this.m._zk_xz_decompress(r),t);if(!this.m._zk_xz_ok())throw new Error("xz decompression failed (corrupt stream or unsupported filter)");return e}setAux(t){const e=this.m,r=e._zk_input_ptr(t.length);e.HEAPU8.set(t,r),e._zk_set_aux(t.length)}zstdTrainDict(t,e,r){const i=this.m,o=i._zk_input_ptr(t.length);i.HEAPU8.set(t,o),i._zk_zstd_train_dict(t.length,e,r);const l=i._zk_result_ptr(),p=i._zk_result_len()>>>0;return i.HEAPU8.slice(l,l+p)}zstdCompressDict(t,e=19){return this.call(r=>this.m._zk_zstd_compress_dict(r,e),t)}zstdDecompressDict(t){return this.call(e=>this.m._zk_zstd_decompress_dict(e),t)}bzip2Compress(t,e=9){return this.call(r=>this.m._zk_bzip2_compress(r,e),t)}bzip2Decompress(t){return this.call(e=>this.m._zk_bzip2_decompress(e),t)}qoiEncode(t,e,r,i){return this.call(o=>this.m._zk_qoi_encode(o,e,r,i),t)}qoiDecode(t){return this.call(e=>this.m._zk_qoi_decode(e),t)}frameDeltaEncode(t,e){return this.call(r=>this.m._zk_frame_delta_encode(r,e),t)}frameDeltaDecode(t,e){return this.call(r=>this.m._zk_frame_delta_decode(r,e),t)}}let at;function w(){return at??=ue.load()}const ct=Object.freeze(Object.defineProperty({__proto__:null,ZipKitEngine:ue,getEngine:w},Symbol.toStringTag,{value:"Module"}));class pe extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class ee extends Error{constructor(t){super(t),this.name="ZipKitError"}}function lt(s,t,e,r){return s===void 0||!Number.isFinite(s)?r:Math.max(t,Math.min(e,Math.round(s)))}function de(s){return s?.mode??"balanced"}function H(s,t,e,r){return lt(s?.level,t,e,r[de(s)])}function W(){return globalThis.Bun}function ut(s){if(s?.aborted)throw new pe}async function y(s,t,e){ut(t?.signal),t?.onProgress?.(0,0);const r=s();return t?.onProgress?.(1,e),r}function ft(s){return de(s)!=="ratio"&&!!W()?.gzipSync}async function _t(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ft(t))return y(()=>r.gzipSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.gzipCompress(s,e),t,s.length)}async function mt(s,t){const e=W();if(e?.gunzipSync)return y(()=>e.gunzipSync(s),t,s.length);const r=await w();return y(()=>r.gzipDecompress(s),t,s.length)}function ht(s){return de(s)!=="ratio"&&!!W()?.deflateSync}async function pt(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ht(t))return y(()=>r.deflateSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.deflateCompress(s,e),t,s.length)}async function dt(s,t){const e=W();if(e?.inflateSync)return y(()=>e.inflateSync(s),t,s.length);const r=await w();return y(()=>r.deflateDecompress(s),t,s.length)}async function zt(s,t){const e=await w(),r=H(t,0,9,{speed:1,balanced:6,ratio:9});return y(()=>e.zlibCompress(s,r),t,s.length)}async function gt(s,t){const e=await w();return y(()=>e.zlibDecompress(s),t,s.length)}async function yt(s,t){const e=H(t,1,22,{speed:1,balanced:3,ratio:19}),r=W();if(r?.zstdCompressSync)return y(()=>r.zstdCompressSync(s,{level:e}),t,s.length);const i=await w(),o=e>19?()=>i.zstdMaxCompress(s,e):()=>i.zstdCompress(s,e);return y(o,t,s.length)}async function bt(s,t){const e=W();if(e?.zstdDecompressSync)return y(()=>e.zstdDecompressSync(s),t,s.length);const r=await w();return y(()=>r.zstdDecompress(s),t,s.length)}async function wt(s,t){const e=await w();return y(()=>e.lz4Compress(s),t,s.length)}async function vt(s,t){const e=await w();return y(()=>e.lz4Decompress(s),t,s.length)}async function kt(s,t){const e=await w();return y(()=>e.snappyCompress(s),t,s.length)}async function xt(s,t){const e=await w();return y(()=>e.snappyDecompress(s),t,s.length)}async function At(s,t){const e=await w(),r=H(t,0,11,{speed:4,balanced:6,ratio:11});return y(()=>e.brotliCompress(s,r),t,s.length)}async function St(s,t){const e=await w();return y(()=>e.brotliDecompress(s),t,s.length)}async function Rt(s,t){const e=await w(),r=H(t,0,9,{speed:3,balanced:6,ratio:9});return y(()=>e.lzmaCompress(s,r),t,s.length)}async function Ct(s,t){const e=await w();return y(()=>e.lzmaDecompress(s),t,s.length)}async function Tt(s,t){const e=await w(),r=H(t,1,9,{speed:1,balanced:6,ratio:9});return y(()=>e.bzip2Compress(s,r),t,s.length)}async function Dt(s,t){const e=await w();return y(()=>e.bzip2Decompress(s),t,s.length)}const Pt={gzip:_t,deflate:pt,zlib:zt,zstd:yt,lz4:wt,snappy:kt,brotli:At,lzma:Rt,bzip2:Tt},Ut={gzip:mt,deflate:dt,zlib:gt,zstd:bt,lz4:vt,snappy:xt,brotli:St,lzma:Ct,bzip2:Dt};function Et(s,t,e){const r=Pt[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}function Bt(s,t,e){const r=Ut[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}const Mt=Object.freeze(Object.defineProperty({__proto__:null,compress:Et,decompressWith:Bt},Symbol.toStringTag,{value:"Module"})),It=new URL(import.meta.url.endsWith(".ts")?"./worker.ts":"./worker.js",import.meta.url);function Wt(){const s=globalThis.navigator?.hardwareConcurrency??4;return Math.max(1,Math.min(s,8))}async function Lt(){try{return await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[])}catch{return}}class Nt{size;workers=[];pending=new Map;next=0;seq=0;ready;usable=!0;refWhileBusy(){const t=this.pending.size>0;for(const e of this.workers)(t?e.ref:e.unref).call(e)}constructor(t={}){this.size=t.size??Wt()}async ensure(){return this.ready?this.ready:(this.ready=(async()=>{const t=await Lt();if(!t){this.usable=!1;return}for(let e=0;e<this.size;e++){const r=new t.Worker(It);r.on("message",i=>this.settle(i)),r.on("error",i=>this.failAll(i)),r.unref(),this.workers.push(r)}})(),this.ready)}settle(t){const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),this.refWhileBusy(),e.signal&&e.onAbort&&e.signal.removeEventListener("abort",e.onAbort),t.ok&&t.result?e.resolve(t.result):e.reject(new Error(t.error??"Worker operation failed")))}failAll(t){for(const[,e]of this.pending)e.reject(t);this.pending.clear(),this.refWhileBusy()}async run(t,e,r,i,o,l,p){if(l?.aborted)throw new pe;if(await this.ensure(),!this.usable){if(t==="zipCompress"){const{getEngine:A}=await ce(async()=>{const{getEngine:R}=await Promise.resolve().then(()=>ct);return{getEngine:R}},void 0),a=await A();return p==="zstd"?a.zstdCompress(e,i??19):a.deflateCompress(e,i??6)}const{compress:_,decompressWith:x}=await ce(async()=>{const{compress:A,decompressWith:a}=await Promise.resolve().then(()=>Mt);return{compress:A,decompressWith:a}},void 0);return t==="compress"?_(e,r,{level:i,mode:o}):x(e,r)}const m=this.seq++,z=this.workers[this.next++%this.workers.length];return new Promise((_,x)=>{const A={resolve:_,reject:x,signal:l};l&&(A.onAbort=()=>{this.pending.delete(m),this.refWhileBusy(),x(new pe)},l.addEventListener("abort",A.onAbort,{once:!0})),this.pending.set(m,A),this.refWhileBusy();const a=e.slice(),R={id:m,kind:t,codec:r,level:i,mode:o,method:p,data:a};z.postMessage(R,[a.buffer])})}compress(t,e,r){return this.run("compress",t,e,r?.level,r?.mode,r?.signal)}decompress(t,e,r){return this.run("decompress",t,e,void 0,void 0,r?.signal)}zipCompress(t,e,r){return this.run("zipCompress",t,e,r,void 0,void 0,e)}async destroy(){this.failAll(new Error("Worker pool destroyed")),await Promise.all(this.workers.map(t=>t.terminate())),this.workers=[],this.ready=void 0}}let Ht;function Kt(){return Ht??=new Nt}function Ft(s){const e=(Math.max(1980,s.getFullYear())-1980&127)<<9|s.getMonth()+1<<5|s.getDate(),r=s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1;return{date:e,time:r}}let g,$,j,Z,G;const Vt=new Uint32Array([16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,452984832,905969664]);function qt(){g=new Uint8Array(256);const s=new Uint8Array(256);let t=1,e=1;do t=t^t<<1^(t&128?283:0),t&=255,e^=e<<1,e^=e<<2,e^=e<<4,e&=255,e&128&&(e^=9),e&=255,s[t]=e;while(t!==1);g[0]=99;for(let r=0;r<256;r++){let i=s[r],o=i;for(let l=0;l<4;l++)o=(o<<1|o>>>7)&255,i^=o;i^=99,g[r]=r===0?99:i}$=new Uint32Array(256),j=new Uint32Array(256),Z=new Uint32Array(256),G=new Uint32Array(256);for(let r=0;r<256;r++){const i=g[r],o=$t(i),l=o^i;$[r]=(o<<24|i<<16|i<<8|l)>>>0,j[r]=(l<<24|o<<16|i<<8|i)>>>0,Z[r]=(i<<24|l<<16|o<<8|i)>>>0,G[r]=(i<<24|i<<16|l<<8|o)>>>0}}function $t(s){return(s<<1^(s&128?283:0))&255}class jt{rk;rounds;constructor(t){if(g||qt(),t.length!==16&&t.length!==24&&t.length!==32)throw new Error(`AES key must be 16/24/32 bytes, got ${t.length}`);const e=t.length/4;this.rounds=e+6;const r=4*(this.rounds+1),i=new Uint32Array(r);for(let o=0;o<e;o++)i[o]=(t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3])>>>0;for(let o=e;o<r;o++){let l=i[o-1];o%e===0?l=(De(l<<8|l>>>24)^Vt[o/e-1])>>>0:e>6&&o%e===4&&(l=De(l)),i[o]=(i[o-e]^l)>>>0}this.rk=i}encryptBlock(t,e,r,i){const o=this.rk;let l=(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])^o[0],p=(t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7])^o[1],m=(t[e+8]<<24|t[e+9]<<16|t[e+10]<<8|t[e+11])^o[2],z=(t[e+12]<<24|t[e+13]<<16|t[e+14]<<8|t[e+15])^o[3],_=4;for(let x=1;x<this.rounds;x++){const A=($[l>>>24&255]^j[p>>>16&255]^Z[m>>>8&255]^G[z&255]^o[_])>>>0,a=($[p>>>24&255]^j[m>>>16&255]^Z[z>>>8&255]^G[l&255]^o[_+1])>>>0,R=($[m>>>24&255]^j[z>>>16&255]^Z[l>>>8&255]^G[p&255]^o[_+2])>>>0,C=($[z>>>24&255]^j[l>>>16&255]^Z[p>>>8&255]^G[m&255]^o[_+3])>>>0;l=A,p=a,m=R,z=C,_+=4}r[i]=(g[l>>>24&255]^o[_]>>>24)&255,r[i+1]=(g[p>>>16&255]^o[_]>>>16)&255,r[i+2]=(g[m>>>8&255]^o[_]>>>8)&255,r[i+3]=(g[z&255]^o[_])&255,r[i+4]=(g[p>>>24&255]^o[_+1]>>>24)&255,r[i+5]=(g[m>>>16&255]^o[_+1]>>>16)&255,r[i+6]=(g[z>>>8&255]^o[_+1]>>>8)&255,r[i+7]=(g[l&255]^o[_+1])&255,r[i+8]=(g[m>>>24&255]^o[_+2]>>>24)&255,r[i+9]=(g[z>>>16&255]^o[_+2]>>>16)&255,r[i+10]=(g[l>>>8&255]^o[_+2]>>>8)&255,r[i+11]=(g[p&255]^o[_+2])&255,r[i+12]=(g[z>>>24&255]^o[_+3]>>>24)&255,r[i+13]=(g[l>>>16&255]^o[_+3]>>>16)&255,r[i+14]=(g[p>>>8&255]^o[_+3]>>>8)&255,r[i+15]=(g[m&255]^o[_+3])&255}}function De(s){return(g[s>>>24&255]<<24|g[s>>>16&255]<<16|g[s>>>8&255]<<8|g[s&255])>>>0}function Zt(s,t){const e=new Uint8Array(t.length),r=new Uint8Array(16),i=new Uint8Array(16);let o=1;for(let l=0;l<t.length;l+=16){r[0]=o&255,r[1]=o>>>8&255,r[2]=o>>>16&255,r[3]=o>>>24&255,s.encryptBlock(r,0,i,0);const p=Math.min(16,t.length-l);for(let m=0;m<p;m++)e[l+m]=t[l+m]^i[m];o++}return e}const Gt={1:16,2:24,3:32},Yt={1:8,2:12,3:16},Ee=10,Xt=1e3;function le(){const s=globalThis.crypto;if(!s?.subtle)throw new ee("WebCrypto (crypto.subtle) is required for ZIP AES encryption");return s.subtle}function Jt(s){const t=globalThis.crypto;if(!t?.getRandomValues)throw new ee("crypto.getRandomValues is required to create encrypted ZIPs");return t.getRandomValues(new Uint8Array(s))}async function Qt(s,t,e){const r=Gt[e],i=await le().importKey("raw",new TextEncoder().encode(s),"PBKDF2",!1,["deriveBits"]),o=await le().deriveBits({name:"PBKDF2",salt:t,iterations:Xt,hash:"SHA-1"},i,(r*2+2)*8),l=new Uint8Array(o);return{aesKey:l.subarray(0,r),macKey:l.subarray(r,r*2),verifier:l.subarray(r*2,r*2+2)}}async function Ot(s,t){const e=await le().importKey("raw",s,{name:"HMAC",hash:"SHA-1"},!1,["sign"]),r=await le().sign("HMAC",e,t);return new Uint8Array(r).subarray(0,Ee)}async function en(s,t,e=3){const r=Jt(Yt[e]),{aesKey:i,macKey:o,verifier:l}=await Qt(t,r,e),p=Zt(new jt(i),s),m=await Ot(o,p),z=new Uint8Array(r.length+2+p.length+Ee);return z.set(r,0),z.set(l,r.length),z.set(p,r.length+2),z.set(m,r.length+2+p.length),{payload:z,strength:e}}const tn=256*1024,nn=67324752,rn=33639248,sn=101010256,on=101075792,an=117853008,S=4294967295,q=65535,cn={store:0,deflate:8,zstd:93};class ln{buf=new Uint8Array(1024);view=new DataView(this.buf.buffer);len=0;grow(t){if(this.len+t<=this.buf.length)return;let e=this.buf.length*2;for(;e<this.len+t;)e*=2;const r=new Uint8Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r,this.view=new DataView(this.buf.buffer)}u16(t){this.grow(2),this.view.setUint16(this.len,t,!0),this.len+=2}u32(t){this.grow(4),this.view.setUint32(this.len,t>>>0,!0),this.len+=4}u64(t){this.grow(8),this.view.setBigUint64(this.len,BigInt(t),!0),this.len+=8}bytes(t){this.grow(t.length),this.buf.set(t,this.len),this.len+=t.length}done(){return this.buf.slice(0,this.len)}}function Pe(s,t,e){s.u16(39169),s.u16(7),s.u16(2),s.u16(17729),s.bytes(new Uint8Array([t])),s.u16(e)}async function un(s,t,e){if(t==="store")return s;const r=await w();if(t==="deflate")return r.deflateCompress(s,e??6);if(t==="zstd")return r.zstdCompress(s,e??19);throw new ee(`Unsupported ZIP method: ${t}`)}const Ue=new TextEncoder;async function _n(s,t={}){const e=await w(),r=s.reduce((u,d)=>u+d.data.length,0),o=t.parallel??(s.length>=2&&r>=tn)?Kt():void 0,l=s.map(u=>e.crc32(u.data));let p=0;const m=t.onProgress,z=await Promise.all(s.map(u=>{const d=u.method??"deflate",D=d==="store"?Promise.resolve(u.data):o?o.zipCompress(u.data,d,u.level??(d==="zstd"?19:6)):un(u.data,d,u.level);return m?D.then(B=>(m(++p,s.length),B)):D})),_=3,x=t.password?await Promise.all(z.map(u=>en(u,t.password,_))):void 0,A=x?x.map(u=>u.payload):z,a=new ln,R=[];let C=s.length>q;for(let u=0;u<s.length;u++){const d=s[u],D=d.method??"deflate",B=cn[D],E=x!==void 0,te=E?99:B,fe=2048|(E?1:0),Y=Ue.encode(d.name),X=d.comment?Ue.encode(d.comment):new Uint8Array(0),J=l[u],ne=E?0:J,re=A[u],K=d.data.length,F=re.length,_e=d.mtime===void 0?new Date:new Date(d.mtime),{date:se,time:ie}=Ft(_e),oe=d.unixPermissions!==void 0?(d.unixPermissions&65535)<<16:0,Q=a.len,P=C||K>S||F>S||Q>S;P&&(C=!0);const V=(P?20:0)+(E?11:0);a.u32(nn),a.u16(P?45:20),a.u16(fe),a.u16(te),a.u16(ie),a.u16(se),a.u32(ne),a.u32(P?S:F),a.u32(P?S:K),a.u16(Y.length),a.u16(V),a.bytes(Y),P&&(a.u16(1),a.u16(16),a.u64(K),a.u64(F)),E&&Pe(a,_,B),a.bytes(re),R.push({nameBytes:Y,commentBytes:X,method:te,actualMethod:B,encrypted:E,crc:ne,compSize:F,size:K,dosDate:se,dosTime:ie,offset:Q,externalAttrs:oe,zip64:P})}const U=a.len;for(const u of R){a.u32(rn),a.u16(u.zip64?45:20),a.u16(u.zip64?45:20),a.u16(2048|(u.encrypted?1:0)),a.u16(u.method),a.u16(u.dosTime),a.u16(u.dosDate),a.u32(u.crc);const d=u.zip64;a.u32(d?S:u.compSize),a.u32(d?S:u.size),a.u16(u.nameBytes.length);const D=[];d&&D.push(u.size,u.compSize,u.offset);const B=(d?4+D.length*8:0)+(u.encrypted?11:0);if(a.u16(B),a.u16(u.commentBytes.length),a.u16(0),a.u16(0),a.u32(u.externalAttrs),a.u32(d?S:u.offset),a.bytes(u.nameBytes),d){a.u16(1),a.u16(D.length*8);for(const E of D)a.u64(E)}u.encrypted&&Pe(a,3,u.actualMethod),a.bytes(u.commentBytes)}const M=a.len-U,T=R.length;if(C||T>q||M>S||U>S){const u=a.len;a.u32(on),a.u64(44),a.u16(45),a.u16(45),a.u32(0),a.u32(0),a.u64(T),a.u64(T),a.u64(M),a.u64(U),a.u32(an),a.u32(0),a.u64(u),a.u32(1)}return a.u32(sn),a.u16(0),a.u16(0),a.u16(T>q?q:T),a.u16(T>q?q:T),a.u32(M>S?S:M),a.u32(U>S?S:U),a.u16(0),a.done()}new TextDecoder("utf-8");export{pe as AbortError,Nt as WorkerPool,ue as ZipKitEngine,ee as ZipKitError,At as brotli,Tt as bzip2,Et as compress,Bt as decompressWith,pt as deflate,w as getEngine,mt as gunzip,_t as gzip,dt as inflate,wt as lz4,Rt as lzma,Kt as sharedPool,kt as snappy,St as unbrotli,Dt as unbzip2,vt as unlz4,Ct as unlzma,xt as unsnappy,gt as unzlib,bt as unzstd,_n as zip,zt as zlib,yt as zstd};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as _,_ as d,r as s,a as u}from"./main-
|
|
1
|
+
import{s as _,_ as d,r as s,a as u}from"./main-Dlba-fXF.js";import{C as T,P as y,W as E,d as L,b as g,c as v,h as P,l as b,m as k,e as D,n as O,f as R,g as S,t as V}from"./main-Dlba-fXF.js";async function h(o,e={}){const i=e.loading===!1?void 0:_(o,e.loadingText??"Loading…"),[{Terminal:l},{FitAddon:c}]=await Promise.all([d(()=>import("./xterm-B-qIQCd3.js"),[]),d(()=>import("./addon-fit-DX4qG4td.js"),[])]).catch(r=>{throw i?.(),r}),a=new l({scrollback:e.scrollback??5e3,fontSize:e.fontSize??13,fontFamily:e.fontFamily??"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:e.lineHeight??1,cursorBlink:e.cursorBlink??!1,cursorStyle:e.cursorStyle??"block",disableStdin:e.stdin!==!0,allowProposedApi:!0,convertEol:!0,theme:s(e.theme),...e.cols?{cols:e.cols}:{},...e.rows?{rows:e.rows}:{},...e.terminalOptions??{}}),t=e.fit===!1?void 0:new c;if(t&&a.loadAddon(t),e.clipboard)try{const{ClipboardAddon:r}=await d(()=>import("./addon-clipboard-wHJhZAA4.js"),[]);a.loadAddon(new r)}catch{}if(e.webLinks)try{const{WebLinksAddon:r}=await d(()=>import("./addon-web-links-DIbG5aQx.js"),[]);a.loadAddon(new r)}catch{}if(e.unicode11)try{const{Unicode11Addon:r}=await d(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]);a.loadAddon(new r),a.unicode.activeVersion="11"}catch{}for(const r of e.addons??[])a.loadAddon(r);if(a.open(o),e.ligatures)try{const{LigaturesAddon:r}=await d(()=>import("./addon-ligatures-DpDY8N_X.js"),[]);a.loadAddon(new r)}catch{}const m=t?u({resize:async()=>{}},a,t,{debounceMs:e.fitDebounceMs??100}):void 0;e.onReady?.(a),i?.();let n=!1;return{terminal:a,fitAddon:t,write:r=>a.write(r),clear:()=>{a.clear(),a.reset()},fit:()=>t?.fit(),setTheme:r=>{a.options.theme=s(r)},dispose(){n||(n=!0,m?.(),a.dispose())}}}export{T as ClientSession,y as PtyKitClient,E as WsCore,u as attachFit,L as darkTheme,g as defaultPersistence,v as draculaTheme,P as hostSocket,b as lightTheme,k as matrixTheme,D as mountTerminal,h as mountViewer,O as nordTheme,s as resolveTheme,_ as showLoadingOverlay,R as solarizedDarkTheme,S as solarizedLightTheme,V as themes};
|