First-pass EvenHub compatibility layer

This commit is contained in:
James Babcock committed 2026-08-11 22:52:32 -07:00
1 parent d7d12afcaa
commit 5d29d91133
19 files changed
+1668 -22

No files matched your search

+15 -1
View File
@@ -16,12 +16,15 @@ export const FILES_WINDOW_ID = "files";
export const FILES_SURFACE_ID = "window:files";
const TEXT_FILE = /\.(txt|md|log)$/i;
const EHPK_FILE = /\.ehpk$/i;
export type FilesAppOptions = InProcessAppOptions & {
/** Open a text document as its own shell window (also used by the share intent). */
openDocumentWindow: (title: string, text: string) => void;
/** Open an image file as its own shell window. */
openImageWindow: (title: string, path: string) => void;
/** Launch an EvenHub app package (.ehpk) through the EvenHub host. */
openEhpkApp: (path: string) => void;
};
/**
@@ -32,7 +35,7 @@ export type FilesAppOptions = InProcessAppOptions & {
export function createFilesAppWindow(options: FilesAppOptions): InProcessWindow {
let created: InProcessWindow | null = null;
const browser = new FileBrowserLayer({
isSupportedFile: (name) => TEXT_FILE.test(name) || isDecodableImageFile(name),
isSupportedFile: (name) => TEXT_FILE.test(name) || EHPK_FILE.test(name) || isDecodableImageFile(name),
// The browser handles double-click itself (up a level), so it is not
// wrapped in YieldAtRootLayer; it yields explicitly from the top level.
onLeave: () => shell.yieldFocusToSidebar(),
@@ -131,6 +134,17 @@ function fileOpenActions(entry: DirectoryEntry, options: FilesAppOptions): FileI
},
];
}
if (EHPK_FILE.test(entry.name)) {
return [
{
label: "Run app",
onSelect: (ctx) => {
ctx.stack.pop();
options.openEhpkApp(entry.path);
},
},
];
}
if (isDecodableImageFile(entry.name)) {
return [
{
+6
View File
@@ -1,4 +1,5 @@
import { type AppContext, type AppDefinition } from "../app-definition";
import { openEvenHubPackage } from "../evenhub";
import {
createFilesAppWindow,
createImageDocumentWindow,
@@ -43,6 +44,11 @@ const filesApp: AppDefinition = {
...options,
openDocumentWindow: (title, text) => openTextDocumentWindow(ctx, title, text),
openImageWindow: (title, path) => openImageDocumentWindow(ctx, title, path),
openEhpkApp: (path) => {
void openEvenHubPackage(ctx, path).catch((error) => {
ctx.appendLog(`evenhub launch failed: ${error}`);
});
},
}),
),
// A document arriving via Android's Share intent opens as its own window.