源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
This commit is contained in:
commit
2ed3415fb7
8018 files changed
+1936476
No files matched your search
@@ -0,0 +1,49 @@
|
||||
// Module customization hooks for `node --test`.
|
||||
//
|
||||
// Renderer modules statically import static assets (png/svg/css/...), which the
|
||||
// bundler resolves at build time. Node's test runner has no such bundler, so a
|
||||
// real asset import throws ERR_UNKNOWN_FILE_EXTENSION. Stub asset imports with a
|
||||
// string URL so any module chain a test loads stays importable.
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { extname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const ASSET_MIME_TYPES = new Map([
|
||||
[".png", "image/png"],
|
||||
[".jpg", "image/jpeg"],
|
||||
[".jpeg", "image/jpeg"],
|
||||
[".gif", "image/gif"],
|
||||
[".svg", "image/svg+xml"],
|
||||
[".webp", "image/webp"],
|
||||
[".avif", "image/avif"],
|
||||
[".ico", "image/x-icon"],
|
||||
[".css", "text/css"],
|
||||
[".woff", "font/woff"],
|
||||
[".woff2", "font/woff2"]
|
||||
]);
|
||||
|
||||
export async function load(url, context, nextLoad) {
|
||||
const assetUrl = new URL(url);
|
||||
const extension = extname(assetUrl.pathname).toLowerCase();
|
||||
const mimeType = ASSET_MIME_TYPES.get(extension);
|
||||
if (mimeType) {
|
||||
if (assetUrl.searchParams.has("inline")) {
|
||||
assetUrl.search = "";
|
||||
assetUrl.hash = "";
|
||||
const bytes = await readFile(fileURLToPath(assetUrl));
|
||||
return {
|
||||
format: "module",
|
||||
shortCircuit: true,
|
||||
source: `export default ${JSON.stringify(
|
||||
`data:${mimeType};base64,${bytes.toString("base64")}`
|
||||
)};`
|
||||
};
|
||||
}
|
||||
return {
|
||||
format: "module",
|
||||
shortCircuit: true,
|
||||
source: `export default ${JSON.stringify(url)};`
|
||||
};
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
import { ipcRenderer } from "electron";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import type { BrowserNodeEvent } from "@tutti-os/browser-node";
|
||||
import { createBrowserWorkbenchLaunchHandler } from "@tutti-os/browser-node/workbench";
|
||||
import {
|
||||
createWorkbenchSnapshotFromState,
|
||||
WorkbenchHost,
|
||||
type WorkbenchHostHandle,
|
||||
type WorkbenchHostNodeDefinition
|
||||
} from "@tutti-os/workbench-surface";
|
||||
import { createBrowserDesktopApi } from "../../src/preload/api/browser.ts";
|
||||
import { createWorkspaceAppDesktopApi } from "../../src/preload/api/workspaceApp.ts";
|
||||
import { createTranslator } from "../../src/shared/i18n/index.ts";
|
||||
import { registerWorkspaceAppPopupNotifications } from "../../src/renderer/src/app/windows/workspace/workspaceAppPopupNotifications.ts";
|
||||
import { createWorkspaceBrowserService } from "../../src/renderer/src/features/workspace-workbench/services/internal/workspaceBrowserService.ts";
|
||||
import { createWorkspaceAppBrowserFeature } from "../../src/renderer/src/features/workspace-workbench/services/internal/contributions/workspaceAppBrowserFeature.ts";
|
||||
import { createWorkbenchWorkspaceBrowserPresenter } from "../../src/renderer/src/features/workspace-workbench/services/workbenchWorkspaceBrowserPresenter.ts";
|
||||
import { registerWorkspaceBrowserLaunchHandler } from "../../src/renderer/src/features/workspace-workbench/services/workspaceBrowserLaunchCoordinator.ts";
|
||||
|
||||
const rendererReadyChannel = "workspace-app-popup-test:renderer-ready";
|
||||
const rendererAckChannel = "workspace-app-popup-test:browser-event";
|
||||
const rendererObservationChannel = "workspace-app-popup-test:observation";
|
||||
const workspaceId = "workspace-app-popup-integration";
|
||||
const browserTypeId = "browser";
|
||||
|
||||
let browserEvents = 0;
|
||||
let rejectionNotifications = 0;
|
||||
let workbenchLaunches = 0;
|
||||
let workbenchHost: WorkbenchHostHandle | null = null;
|
||||
let releaseLaunchHandler: (() => void) | null = null;
|
||||
|
||||
const browserApi = createBrowserDesktopApi();
|
||||
const workspaceAppApi = createWorkspaceAppDesktopApi();
|
||||
|
||||
browserApi.onEvent((browserEvent: BrowserNodeEvent) => {
|
||||
browserEvents += 1;
|
||||
ipcRenderer.send(rendererAckChannel, browserEvent);
|
||||
reportObservation();
|
||||
void reportWhenBrowserSurfacesReach(browserEvents);
|
||||
});
|
||||
|
||||
const workspaceBrowserService = createWorkspaceBrowserService({ browserApi });
|
||||
createWorkspaceAppBrowserFeature({
|
||||
browserApi,
|
||||
browserService: workspaceBrowserService,
|
||||
runtimeApi: {
|
||||
logRendererDiagnostic() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
workspaceId
|
||||
});
|
||||
|
||||
registerWorkspaceAppPopupNotifications({
|
||||
notifications: {
|
||||
error() {
|
||||
rejectionNotifications += 1;
|
||||
}
|
||||
} as never,
|
||||
translate: createTranslator("en").t,
|
||||
workspaceAppApi
|
||||
});
|
||||
|
||||
const browserNodeDefinition: WorkbenchHostNodeDefinition = {
|
||||
frame: { height: 560, width: 900, x: 220, y: 130 },
|
||||
instance: { mode: "multi" },
|
||||
renderBody: () => null,
|
||||
title: "Browser",
|
||||
typeId: browserTypeId,
|
||||
window: {
|
||||
defaultOpen: false,
|
||||
restoreOnLoad: true
|
||||
}
|
||||
};
|
||||
const resolveBrowserLaunch = createBrowserWorkbenchLaunchHandler({
|
||||
browserInstancePrefix: "workspace-app-popup-integration",
|
||||
typeId: browserTypeId
|
||||
});
|
||||
|
||||
const rootElement = document.querySelector("#root");
|
||||
if (!(rootElement instanceof HTMLElement)) {
|
||||
throw new Error("Workspace App popup fixture root is unavailable");
|
||||
}
|
||||
|
||||
createRoot(rootElement).render(
|
||||
<WorkbenchHost
|
||||
nodes={[browserNodeDefinition]}
|
||||
onHandleReady={(host) => {
|
||||
workbenchHost = host;
|
||||
releaseLaunchHandler?.();
|
||||
releaseLaunchHandler = null;
|
||||
if (!host) {
|
||||
return;
|
||||
}
|
||||
const countingHost = {
|
||||
activateNode: host.activateNode.bind(host),
|
||||
focusNode: host.focusNode.bind(host),
|
||||
getSnapshot: host.getSnapshot.bind(host),
|
||||
async launchNode(request) {
|
||||
workbenchLaunches += 1;
|
||||
reportObservation();
|
||||
const nodeId = await host.launchNode(request);
|
||||
reportObservation();
|
||||
return nodeId;
|
||||
}
|
||||
} as WorkbenchHostHandle;
|
||||
releaseLaunchHandler = registerWorkspaceBrowserLaunchHandler(
|
||||
workspaceId,
|
||||
createWorkbenchWorkspaceBrowserPresenter({
|
||||
browserPages: {
|
||||
openPage: (request) => workspaceBrowserService.openPage(request)
|
||||
},
|
||||
host: countingHost
|
||||
})
|
||||
);
|
||||
ipcRenderer.send(rendererReadyChannel);
|
||||
}}
|
||||
onLaunchRequest={resolveBrowserLaunch}
|
||||
snapshotRepository={{
|
||||
async load() {
|
||||
return createWorkbenchSnapshotFromState(
|
||||
{ nodeStack: [], nodes: [] },
|
||||
{ metadata: { workbenchHostInitialized: true } }
|
||||
);
|
||||
},
|
||||
save(_workspaceId, snapshot) {
|
||||
return snapshot;
|
||||
}
|
||||
}}
|
||||
workspaceId={workspaceId}
|
||||
/>
|
||||
);
|
||||
|
||||
async function reportWhenBrowserSurfacesReach(
|
||||
expectedBrowserSurfaces: number
|
||||
): Promise<void> {
|
||||
const deadline = Date.now() + 5_000;
|
||||
while (
|
||||
workbenchLaunches < expectedBrowserSurfaces ||
|
||||
countBrowserSurfaces() < expectedBrowserSurfaces
|
||||
) {
|
||||
if (Date.now() >= deadline) {
|
||||
reportObservation();
|
||||
throw new Error("timed out waiting for Workbench Browser surfaces");
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
}
|
||||
reportObservation();
|
||||
}
|
||||
|
||||
function countBrowserSurfaces(): number {
|
||||
return (
|
||||
workbenchHost
|
||||
?.getSnapshot()
|
||||
.nodes.filter((node) => node.data.typeId === browserTypeId).length ?? 0
|
||||
);
|
||||
}
|
||||
|
||||
function reportObservation(): void {
|
||||
ipcRenderer.send(rendererObservationChannel, {
|
||||
browserEvents,
|
||||
browserSurfaces: countBrowserSurfaces(),
|
||||
rejectionNotifications,
|
||||
workbenchLaunches
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Loaded via `node --import` before the test entry so static asset imports
|
||||
// resolve to a stub string instead of throwing in the test runner.
|
||||
import { register } from "node:module";
|
||||
|
||||
register("./asset-stub-hooks.mjs", import.meta.url);
|
||||
Reference in new issue
Block a user