@codexhost/cli-win32-x64 0.31.0 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +225 -20
- package/app/console-web.js +285 -25
- package/app/desktop-controller.mjs +534 -143
- package/app/host-runtime.mjs +2651 -913
- package/app/plugins/antigravity/plugin.mjs +20 -22
- package/app/plugins/claude-code/plugin.mjs +21 -0
- package/app/plugins/codebuddy/plugin.mjs +29 -2
- package/app/plugins/codex-usage/plugin.mjs +18 -0
- package/app/plugins/copilot/plugin.mjs +18 -0
- package/app/plugins/cursor-cli/plugin.mjs +18 -0
- package/app/plugins/deepseek-harness/plugin.mjs +18 -0
- package/app/plugins/devin/plugin.mjs +18 -0
- package/app/plugins/grok/plugin.mjs +18 -0
- package/app/plugins/hermes/plugin.mjs +18 -0
- package/app/plugins/kimi-code/plugin.mjs +18 -0
- package/app/plugins/kiro-cli/plugin.mjs +18 -0
- package/app/plugins/omp/plugin.mjs +18 -0
- package/app/plugins/opencode/plugin.mjs +18 -0
- package/app/plugins/pi/plugin.mjs +18 -0
- package/app/plugins/qoder/plugin.mjs +18 -0
- package/app/plugins/qoder-cn/plugin.mjs +18 -0
- package/app/plugins/qwen-code/plugin.mjs +18 -0
- package/app/plugins/workbuddy/plugin.mjs +29 -2
- package/app/plugins/zcode/plugin.mjs +18 -0
- package/app/renderer-extension.js +424 -129
- package/app/web/assets/{abnfDiagram-XWFEHMT6-Bqy7uOSy.js → abnfDiagram-XWFEHMT6-7XITZmBH.js} +1 -1
- package/app/web/assets/{architectureDiagram-CSQXQB3N-6aaP1YoM.js → architectureDiagram-CSQXQB3N-C8Usdzd8.js} +1 -1
- package/app/web/assets/{blockDiagram-BEDRHYPZ-B4QSFXe0.js → blockDiagram-BEDRHYPZ-CyN9yE_Q.js} +1 -1
- package/app/web/assets/{c4Diagram-M2UUVUY5-BYE-C8Gq.js → c4Diagram-M2UUVUY5-CjhY1l3g.js} +1 -1
- package/app/web/assets/{chunk-2Q5K7J3B-CiEM-GTd.js → chunk-2Q5K7J3B-o24_rh4_.js} +1 -1
- package/app/web/assets/{chunk-3GCGMST5-hzY9BiB1.js → chunk-3GCGMST5-D7bw3E1a.js} +1 -1
- package/app/web/assets/{chunk-5VM5RSS4-DYXznY0H.js → chunk-5VM5RSS4-D0v4acf7.js} +1 -1
- package/app/web/assets/{chunk-7U7NFRK5-Bzw5MDPr.js → chunk-7U7NFRK5-CYJxP4rV.js} +1 -1
- package/app/web/assets/{chunk-CNRTWJTD-DMbxMfi3.js → chunk-CNRTWJTD-DTgCtcCl.js} +1 -1
- package/app/web/assets/{chunk-D5HYT7QG-By0ZVBtD.js → chunk-D5HYT7QG-qRNelehW.js} +1 -1
- package/app/web/assets/{chunk-EBZ3SEQC-Yyu_sMV7.js → chunk-EBZ3SEQC-BgJPPYdu.js} +2 -2
- package/app/web/assets/{chunk-JWPE2WC7-DDzqxIPT.js → chunk-JWPE2WC7-C50ZnSQQ.js} +1 -1
- package/app/web/assets/{chunk-KTR4FSNJ-GlKqhtpl.js → chunk-KTR4FSNJ-Cifh4XHc.js} +1 -1
- package/app/web/assets/{chunk-XXDRQBXY-DNc-CvYu.js → chunk-XXDRQBXY-D23WAHPW.js} +1 -1
- package/app/web/assets/{classDiagram-v2-KXABOMEV-4_PFS2N_.js → classDiagram-v2-KXABOMEV-B3cezFGj.js} +1 -1
- package/app/web/assets/{cose-bilkent-JH36ORCC-BE3foHUY.js → cose-bilkent-JH36ORCC-VSMi4La2.js} +1 -1
- package/app/web/assets/{cynefin-EF2NZ3EQ-D2PqrYZ3.js → cynefin-EF2NZ3EQ-qQnfHq16.js} +1 -1
- package/app/web/assets/{cynefinDiagram-NJNITYFG-DOObpTbq.js → cynefinDiagram-NJNITYFG-BJELApXD.js} +1 -1
- package/app/web/assets/{dagre-KIHZ2IZ3-Znm2jin9.js → dagre-KIHZ2IZ3-C8B5ZMVs.js} +1 -1
- package/app/web/assets/{diagram-7YQZDPLS-ByZMD-uA.js → diagram-7YQZDPLS-HIWoNpzV.js} +1 -1
- package/app/web/assets/{diagram-QBROCOUO-BiRShpnN.js → diagram-QBROCOUO-3_vS1jbp.js} +1 -1
- package/app/web/assets/{diagram-RJJCUUZO-D9wLVoK2.js → diagram-RJJCUUZO-C_Kndn_e.js} +1 -1
- package/app/web/assets/{diagram-WERXNKYE-BSbIh-yC.js → diagram-WERXNKYE-BLWdOwya.js} +1 -1
- package/app/web/assets/{diagram-YHHI257C-DMWrHMc8.js → diagram-YHHI257C-DJeOs6eS.js} +1 -1
- package/app/web/assets/{diagram-YR4HJLHV-C4sBAFb1.js → diagram-YR4HJLHV-BKNULu-g.js} +1 -1
- package/app/web/assets/{ebnfDiagram-N527522P-BZLloaoQ.js → ebnfDiagram-N527522P-Bu8aReoF.js} +1 -1
- package/app/web/assets/{elk-O5DQBFGD-Da3e5tn5.js → elk-O5DQBFGD-CIp7Z0ER.js} +1 -1
- package/app/web/assets/{erDiagram-K3K3BIDK-B2lKAIZF.js → erDiagram-K3K3BIDK-BTsor1Lp.js} +1 -1
- package/app/web/assets/{flowDiagram-Z6JWZHQI-q2EY_kmB.js → flowDiagram-Z6JWZHQI-p_h5PKQr.js} +1 -1
- package/app/web/assets/{ganttDiagram-3PRQTZWP-BGrNZ20b.js → ganttDiagram-3PRQTZWP-DKjfPPJ1.js} +1 -1
- package/app/web/assets/{gitGraphDiagram-VXDFKS5L-DIZNXREy.js → gitGraphDiagram-VXDFKS5L-RnPOf2fj.js} +1 -1
- package/app/web/assets/{grid-E2QIVN74-0cUkPG69.js → grid-E2QIVN74-C96GnBO1.js} +1 -1
- package/app/web/assets/{index-PN7K-15_.js → index-CDRWzs-u.js} +99 -99
- package/app/web/assets/index-Dwdnvinl.css +1 -0
- package/app/web/assets/{infoDiagram-EZ3ZOAHP-BHhUTQCn.js → infoDiagram-EZ3ZOAHP-B68eZHsb.js} +1 -1
- package/app/web/assets/{ishikawaDiagram-S3EKX5GW-DPOxtl4c.js → ishikawaDiagram-S3EKX5GW-BLj7PFLt.js} +1 -1
- package/app/web/assets/{journeyDiagram-POQNLL5X-D8RyXckG.js → journeyDiagram-POQNLL5X-Bo-_In0d.js} +1 -1
- package/app/web/assets/{kanban-definition-BH5XI6FM-COJv3Hyh.js → kanban-definition-BH5XI6FM-BpHvxprW.js} +1 -1
- package/app/web/assets/{mermaid.core-DYdcDKIt.js → mermaid.core-COb9i2Gl.js} +4 -4
- package/app/web/assets/{mindmap-definition-WVAN44T4-DnYIM4ja.js → mindmap-definition-WVAN44T4-DG15AlXd.js} +1 -1
- package/app/web/assets/{pegDiagram-D4NLKWP3-Ds3GAEJ6.js → pegDiagram-D4NLKWP3-GMBk8RM6.js} +1 -1
- package/app/web/assets/{pieDiagram-36ENHN4W-BhLUJGEB.js → pieDiagram-36ENHN4W-BzeJgVnn.js} +1 -1
- package/app/web/assets/{quadrantDiagram-ZQUDMS73-DwtX-IxK.js → quadrantDiagram-ZQUDMS73-C--Kif6a.js} +1 -1
- package/app/web/assets/{railroadDiagram-JIZHGYPL-D2vmTTnJ.js → railroadDiagram-JIZHGYPL-NPLVu_R7.js} +1 -1
- package/app/web/assets/{render-VIF2ZAQL-DGU1ql-Z.js → render-VIF2ZAQL-DdpQ8E0J.js} +2 -2
- package/app/web/assets/{requirementDiagram-AXW2TVFA-u3j1sKkI.js → requirementDiagram-AXW2TVFA-WWRwRbkA.js} +1 -1
- package/app/web/assets/{sankeyDiagram-FBCJTAIF-k-An9VHW.js → sankeyDiagram-FBCJTAIF-hBr6pZ0V.js} +1 -1
- package/app/web/assets/{sequenceDiagram-3LA2ROMG-DUjbYb4R.js → sequenceDiagram-3LA2ROMG-DvzZWy5J.js} +1 -1
- package/app/web/assets/{sizeCapture-2Q2CQKSF-DATTL7FZ.js → sizeCapture-2Q2CQKSF-C2B86W70.js} +1 -1
- package/app/web/assets/{stateDiagram-v2-ATKHQDJO-cCJX5M2u.js → stateDiagram-v2-ATKHQDJO-Jwj3XqMx.js} +1 -1
- package/app/web/assets/{swimlanes-YQL5WMAO-B7grWEWt.js → swimlanes-YQL5WMAO-DxI0hC09.js} +1 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-CR0nv8kJ.js +8 -0
- package/app/web/assets/{timeline-definition-7Z437IG3-BhsLa6l1.js → timeline-definition-7Z437IG3-m8Ew8iuN.js} +1 -1
- package/app/web/assets/{usecaseDiagram-RDK6N6HP-CkPQYmQw.js → usecaseDiagram-RDK6N6HP-BsiPSzIT.js} +1 -1
- package/app/web/assets/{vennDiagram-SHRQU5PJ-CufZSwvw.js → vennDiagram-SHRQU5PJ-yYfXhiGp.js} +1 -1
- package/app/web/assets/{wardleyDiagram-F3OXNVQS-CSkfpFOA.js → wardleyDiagram-F3OXNVQS-DHLEfnsg.js} +1 -1
- package/app/web/assets/{xychartDiagram-GDYJKCDI-BhZf9scK.js → xychartDiagram-GDYJKCDI-Drn_UxYt.js} +1 -1
- package/app/web/codexhost-settings.js +123 -55
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +75 -75
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -65
- package/app/web/plugins/deepseek-ai__dsh-client-ui-commands/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-plan/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +7 -7
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +69 -69
- package/app/web/sw.js +230 -16
- package/app/web-modules/node_modules/@deepseek-ai/dsh-client-modules/index.js +7 -7
- package/app/web-modules/server.mjs +1144 -185
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-screenshot.exe +0 -0
- package/libexec/codexhost-shell.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BbmB5VLj.css +0 -1
- package/app/web/assets/swimlanesDiagram-UCCPES4V-B8Jem9gq.js +0 -8
package/app/web/sw.js
CHANGED
|
@@ -1,39 +1,253 @@
|
|
|
1
|
-
/* CodexHost service worker: offline navigation, Web Push and notification clicks. */
|
|
1
|
+
/* CodexHost service worker: instant App Shell recovery, offline navigation, Web Push and notification clicks. */
|
|
2
|
+
|
|
3
|
+
const SHELL_CACHE = "codexhost-shell-v1";
|
|
4
|
+
const ASSET_CACHE = "codexhost-assets-v1";
|
|
5
|
+
const MAX_ASSET_ENTRIES = 96;
|
|
6
|
+
const requestTimeout = 10_000;
|
|
7
|
+
let shellCacheGeneration = 0;
|
|
8
|
+
let shellCacheQueue = Promise.resolve();
|
|
9
|
+
const inFlightRevalidations = new Set();
|
|
10
|
+
|
|
11
|
+
function cachesStore() {
|
|
12
|
+
return typeof caches !== "undefined" ? caches : self.caches;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function scopeBaseUrl() {
|
|
16
|
+
return new URL(self.registration?.scope || "./", self.location?.href || "https://localhost/");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function enqueueShellCache(task) {
|
|
20
|
+
const next = shellCacheQueue.then(task, task);
|
|
21
|
+
shellCacheQueue = next.catch(() => undefined);
|
|
22
|
+
return next;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function clearShellCache() {
|
|
26
|
+
shellCacheGeneration += 1;
|
|
27
|
+
for (const controller of inFlightRevalidations) {
|
|
28
|
+
controller.abort();
|
|
29
|
+
}
|
|
30
|
+
inFlightRevalidations.clear();
|
|
31
|
+
return enqueueShellCache(async () => {
|
|
32
|
+
const store = cachesStore();
|
|
33
|
+
if (!store) return;
|
|
34
|
+
await store.delete(SHELL_CACHE).catch(() => false);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
2
37
|
|
|
3
38
|
self.addEventListener("install", () => {
|
|
4
39
|
self.skipWaiting();
|
|
5
40
|
});
|
|
6
41
|
|
|
7
42
|
self.addEventListener("activate", (event) => {
|
|
8
|
-
event.waitUntil(
|
|
43
|
+
event.waitUntil(
|
|
44
|
+
(async () => {
|
|
45
|
+
const store = cachesStore();
|
|
46
|
+
if (store && typeof store.keys === "function") {
|
|
47
|
+
const keys = await store.keys().catch(() => []);
|
|
48
|
+
await Promise.all(
|
|
49
|
+
keys
|
|
50
|
+
.filter(
|
|
51
|
+
(key) => key.startsWith("codexhost-") && key !== SHELL_CACHE && key !== ASSET_CACHE,
|
|
52
|
+
)
|
|
53
|
+
.map((key) => store.delete(key).catch(() => false)),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
await self.clients.claim();
|
|
57
|
+
})(),
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
self.addEventListener("message", (event) => {
|
|
62
|
+
if (event.data?.type === "codexhost/clear-shell-cache") {
|
|
63
|
+
event.waitUntil?.(clearShellCache());
|
|
64
|
+
}
|
|
9
65
|
});
|
|
10
66
|
|
|
11
67
|
self.addEventListener("fetch", (event) => {
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
68
|
+
const { request } = event;
|
|
69
|
+
const method = request.method ?? "GET";
|
|
70
|
+
const url = new URL(request.url);
|
|
71
|
+
const scope = scopeBaseUrl();
|
|
72
|
+
if (url.origin !== scope.origin) return;
|
|
73
|
+
const apiPrefix = new URL("api/", scope).pathname;
|
|
17
74
|
// Never intercept API navigations (such as file downloads) with the offline timeout wrapper.
|
|
18
|
-
if (pathname.startsWith(apiPrefix)) return;
|
|
19
|
-
|
|
75
|
+
if (url.pathname.startsWith(apiPrefix)) return;
|
|
76
|
+
|
|
77
|
+
if (request.mode === "navigate") {
|
|
78
|
+
event.respondWith(navigate(event));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (method === "GET" && cachesStore() && isImmutableBundle(url, scope)) {
|
|
83
|
+
event.respondWith(serveImmutableAsset(event));
|
|
84
|
+
}
|
|
20
85
|
});
|
|
21
86
|
|
|
22
|
-
|
|
87
|
+
function isImmutableBundle(url, scope) {
|
|
88
|
+
const assetsPrefix = new URL("assets/", scope).pathname;
|
|
89
|
+
const pluginsPrefix = new URL("plugins/", scope).pathname;
|
|
90
|
+
return (
|
|
91
|
+
url.pathname.startsWith(assetsPrefix) ||
|
|
92
|
+
(url.pathname.startsWith(pluginsPrefix) && url.searchParams.has("rev"))
|
|
93
|
+
);
|
|
94
|
+
}
|
|
23
95
|
|
|
24
|
-
|
|
25
|
-
|
|
96
|
+
function isCacheableShellNavigation(request, url, scope) {
|
|
97
|
+
if ((request.method ?? "GET") !== "GET") return false;
|
|
98
|
+
if (url.searchParams.has("token") || url.searchParams.has("extensions")) return false;
|
|
99
|
+
const indexPathname = new URL("index.html", scope).pathname;
|
|
100
|
+
return url.pathname === scope.pathname || url.pathname === indexPathname;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isHtmlShellResponse(response) {
|
|
104
|
+
if (!response || response.status !== 200 || response.redirected) return false;
|
|
105
|
+
if (typeof response.clone !== "function") return false;
|
|
106
|
+
const contentType = response.headers?.get?.("content-type") ?? "";
|
|
107
|
+
return contentType.includes("text/html");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function putShellCache(shellKey, response, expectedGeneration) {
|
|
111
|
+
const store = cachesStore();
|
|
112
|
+
if (!store || !isHtmlShellResponse(response)) return Promise.resolve();
|
|
113
|
+
if (expectedGeneration !== shellCacheGeneration) return Promise.resolve();
|
|
114
|
+
const copy = response.clone();
|
|
115
|
+
return enqueueShellCache(async () => {
|
|
116
|
+
if (expectedGeneration !== shellCacheGeneration) return;
|
|
117
|
+
try {
|
|
118
|
+
const cache = await store.open(SHELL_CACHE);
|
|
119
|
+
if (expectedGeneration !== shellCacheGeneration) return;
|
|
120
|
+
await cache.put(shellKey, copy);
|
|
121
|
+
} catch {
|
|
122
|
+
// Quota or private-browsing storage restrictions must never break navigation.
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function fetchWithTimeout(request, init, controller = new AbortController()) {
|
|
26
128
|
const timer = setTimeout(() => controller.abort(), requestTimeout);
|
|
27
129
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return offlineResponse();
|
|
130
|
+
return init === undefined
|
|
131
|
+
? await fetch(request, { signal: controller.signal })
|
|
132
|
+
: await fetch(request, { ...init, signal: controller.signal });
|
|
32
133
|
} finally {
|
|
33
134
|
clearTimeout(timer);
|
|
34
135
|
}
|
|
35
136
|
}
|
|
36
137
|
|
|
138
|
+
async function revalidateShell(request, shellKey) {
|
|
139
|
+
const generation = shellCacheGeneration;
|
|
140
|
+
const controller = new AbortController();
|
|
141
|
+
inFlightRevalidations.add(controller);
|
|
142
|
+
try {
|
|
143
|
+
const response = await fetchWithTimeout(request, { cache: "no-cache" }, controller);
|
|
144
|
+
if (generation !== shellCacheGeneration) return;
|
|
145
|
+
if (response.status === 401) {
|
|
146
|
+
await clearShellCache();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
await putShellCache(shellKey, response, generation);
|
|
150
|
+
} catch {
|
|
151
|
+
// Keep the cached shell while cellular/VPN wakes up; WebSocket recovery handles live state.
|
|
152
|
+
} finally {
|
|
153
|
+
inFlightRevalidations.delete(controller);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function navigate(event) {
|
|
158
|
+
const { request } = event;
|
|
159
|
+
const url = new URL(request.url);
|
|
160
|
+
const scope = scopeBaseUrl();
|
|
161
|
+
const store = cachesStore();
|
|
162
|
+
const shellEligible = Boolean(store) && isCacheableShellNavigation(request, url, scope);
|
|
163
|
+
const shellKey = scope.href;
|
|
164
|
+
const explicitReload = request.cache === "reload" || request.cache === "no-cache";
|
|
165
|
+
|
|
166
|
+
if (shellEligible && !explicitReload) {
|
|
167
|
+
const cached = await store
|
|
168
|
+
.open(SHELL_CACHE)
|
|
169
|
+
.then((cache) => cache.match(shellKey))
|
|
170
|
+
.catch(() => undefined);
|
|
171
|
+
if (cached) {
|
|
172
|
+
event.waitUntil?.(revalidateShell(request, shellKey));
|
|
173
|
+
return cached;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const generation = shellCacheGeneration;
|
|
178
|
+
try {
|
|
179
|
+
const response = await fetchWithTimeout(request);
|
|
180
|
+
if (response.status === 401) {
|
|
181
|
+
event.waitUntil?.(clearShellCache());
|
|
182
|
+
return response;
|
|
183
|
+
}
|
|
184
|
+
if ([502, 503, 504].includes(response.status)) {
|
|
185
|
+
if (shellEligible) {
|
|
186
|
+
const cached = await store
|
|
187
|
+
.open(SHELL_CACHE)
|
|
188
|
+
.then((cache) => cache.match(shellKey))
|
|
189
|
+
.catch(() => undefined);
|
|
190
|
+
if (cached) return cached;
|
|
191
|
+
}
|
|
192
|
+
return offlineResponse();
|
|
193
|
+
}
|
|
194
|
+
if (shellEligible && isHtmlShellResponse(response)) {
|
|
195
|
+
event.waitUntil?.(putShellCache(shellKey, response, generation));
|
|
196
|
+
}
|
|
197
|
+
return response;
|
|
198
|
+
} catch {
|
|
199
|
+
if (shellEligible) {
|
|
200
|
+
const cached = await store
|
|
201
|
+
.open(SHELL_CACHE)
|
|
202
|
+
.then((cache) => cache.match(shellKey))
|
|
203
|
+
.catch(() => undefined);
|
|
204
|
+
if (cached) return cached;
|
|
205
|
+
}
|
|
206
|
+
return offlineResponse();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function serveImmutableAsset(event) {
|
|
211
|
+
const store = cachesStore();
|
|
212
|
+
const { request } = event;
|
|
213
|
+
const cached = await store
|
|
214
|
+
.open(ASSET_CACHE)
|
|
215
|
+
.then((cache) => cache.match(request))
|
|
216
|
+
.catch(() => undefined);
|
|
217
|
+
if (cached) return cached;
|
|
218
|
+
|
|
219
|
+
const response = await fetch(request);
|
|
220
|
+
if (
|
|
221
|
+
response &&
|
|
222
|
+
response.status === 200 &&
|
|
223
|
+
!response.redirected &&
|
|
224
|
+
typeof response.clone === "function"
|
|
225
|
+
) {
|
|
226
|
+
const copy = response.clone();
|
|
227
|
+
event.waitUntil?.(
|
|
228
|
+
(async () => {
|
|
229
|
+
try {
|
|
230
|
+
const cache = await store.open(ASSET_CACHE);
|
|
231
|
+
await cache.put(request, copy);
|
|
232
|
+
if (typeof cache.keys === "function") {
|
|
233
|
+
const keys = await cache.keys();
|
|
234
|
+
if (keys.length > MAX_ASSET_ENTRIES) {
|
|
235
|
+
await Promise.all(
|
|
236
|
+
keys
|
|
237
|
+
.slice(0, keys.length - MAX_ASSET_ENTRIES)
|
|
238
|
+
.map((oldKey) => cache.delete(oldKey)),
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
// Best-effort immutable bundle cache.
|
|
244
|
+
}
|
|
245
|
+
})(),
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return response;
|
|
249
|
+
}
|
|
250
|
+
|
|
37
251
|
function offlineResponse() {
|
|
38
252
|
const zh = navigator.language.startsWith("zh");
|
|
39
253
|
const title = zh ? "正在连接…" : "Connecting…";
|
|
@@ -114,6 +114,7 @@ var ClientPackageCompositionError = class extends AggregateError {
|
|
|
114
114
|
};
|
|
115
115
|
var IMMUTABLE_CACHE = "public, max-age=31536000, immutable";
|
|
116
116
|
var MAX_COMBO_URL_BYTES = 3 * 1024;
|
|
117
|
+
var MAX_CACHED_CHUNK_RESPONSE_BYTES = 256 * 1024;
|
|
117
118
|
var HASH_REVISION_LENGTH = 12;
|
|
118
119
|
var COMBO_REVISION_PLACEHOLDER = "0".repeat(HASH_REVISION_LENGTH);
|
|
119
120
|
var SOURCE_MAP_TRAILER = /(?:^|\r?\n)\/\/# sourceMappingURL=[^\r\n]*(?:\r?\n)?$/;
|
|
@@ -881,13 +882,12 @@ var ClientModuleRegistry = class extends Service {
|
|
|
881
882
|
fileName,
|
|
882
883
|
bundle
|
|
883
884
|
});
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
};
|
|
885
|
+
const buildBody = sourceMap ? () => buildComboSourceMap([resource()], this.readSourceMap, fileName) : () => buildComboScript([resource()], sourceMapUrl);
|
|
886
|
+
const contentType = sourceMap ? "application/json; charset=utf-8" : "text/javascript; charset=utf-8";
|
|
887
|
+
if (bundle.length > MAX_CACHED_CHUNK_RESPONSE_BYTES) {
|
|
888
|
+
return { body: buildBody, contentType };
|
|
889
|
+
}
|
|
890
|
+
const response = { body: lazyBody(buildBody), contentType };
|
|
891
891
|
this.responses.set(resourceUrl, response);
|
|
892
892
|
return response;
|
|
893
893
|
}
|