moi-computer 0.5.1 → 0.5.2-next.0
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/client/features/applets/applet-cache.ts +10 -1
- package/client/features/applets/useApplet.ts +1 -1
- package/dist/{chunk-4tcmvefj.js → chunk-fhhv99bd.js} +1 -1
- package/dist/{chunk-gc2smzc9.js → chunk-rs9nb0fr.js} +7 -7
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/applets.ts +49 -7
|
@@ -30,11 +30,20 @@ export function appletVersion(segment: AppletSegment, workspaceId: string, name:
|
|
|
30
30
|
return versions.get(appletKey(segment, workspaceId, name)) ?? 0
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// The url segment the entry is served at. NOT `index.js`, which is only its name
|
|
34
|
+
// on disk: proxies in front of moi (Cloudflare, notably) pick cacheability from
|
|
35
|
+
// the url's extension rather than the content type, and on a `.js` url the
|
|
36
|
+
// zone's Browser Cache TTL — 4 hours by default — gets stamped over the server's
|
|
37
|
+
// `no-cache`, pinning a stale bundle in the browser with no way to revalidate it
|
|
38
|
+
// away. Extensionless keeps the server's headers intact. `parseAppletTail` in
|
|
39
|
+
// `server/applets.ts` maps this back to `index.js`; the two must agree.
|
|
40
|
+
const ENTRY_ROUTE = 'module'
|
|
41
|
+
|
|
33
42
|
// The cache-busting import URL for an applet's entry at its current version.
|
|
34
43
|
// Assets + chunks resolve module-relative from the entry (via import.meta.url),
|
|
35
44
|
// so they don't inherit `?v` and aren't re-fetched needlessly.
|
|
36
45
|
export function appletUrl(segment: AppletSegment, workspaceId: string, name: string): string {
|
|
37
|
-
return `/api/workspaces/${workspaceId}/${segment}/${name}
|
|
46
|
+
return `/api/workspaces/${workspaceId}/${segment}/${name}/${ENTRY_ROUTE}?v=${appletVersion(segment, workspaceId, name)}`
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
// The key an applet bundle registers its CSS under (`window.__moiAppletCss`):
|
|
@@ -66,7 +66,7 @@ function loadApplet(
|
|
|
66
66
|
const existing = getCachedApplet(key) as Promise<ComponentType<AppletComponentProps>> | undefined
|
|
67
67
|
if (existing) return existing
|
|
68
68
|
|
|
69
|
-
// Import the bundle dir's
|
|
69
|
+
// Import the bundle dir's entry at its current `?v`; the version is bumped
|
|
70
70
|
// (and this entry dropped) by `invalidateApplet` on every rebuild — including
|
|
71
71
|
// while this applet is unmounted — so a backgrounded tab never serves stale.
|
|
72
72
|
const promise = import(/* @vite-ignore */ appletUrl(segment, workspaceId, name)).then(mod => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Pc as a}from"/chunk-h3evrtyp.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function e(r){let{mount:t}=await import("/chunk-
|
|
1
|
+
import{Pc as a}from"/chunk-h3evrtyp.js";if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);async function e(r){let{mount:t}=await import("/chunk-rs9nb0fr.js");t(r)}globalThis.__init=e;
|