wishforge-ide/apps/ide/policy/frontend.cjs
eust-w 0ef99b1e6d style: add Prettier and EditorConfig, format the codebase
Adds prettier 3.9.8 (exact) with a shared config (single quotes,
120 columns, trailing commas), .prettierignore, .editorconfig and the
`format` / `format:check` scripts, then formats all TypeScript,
JavaScript, CSS, JSON and YAML sources.

Purely mechanical: no behaviour change. Typecheck passes, the vitest
suite and the 74 IDE node tests produce the same results as before
(socket-binding tests still cannot run inside this sandbox).
Previously the longest source line was ~3000 characters; reviewing the
following semantic changes now produces readable diffs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:32:43 +08:00

61 lines
2.7 KiB
JavaScript

const { ContainerModule, injectable } = require('@theia/core/shared/inversify');
const {
CollaborationFrontendContribution,
} = require('@theia/collaboration/lib/browser/collaboration-frontend-contribution');
const { CollaborationWorkspaceService } = require('@theia/collaboration/lib/browser/collaboration-workspace-service');
const { FrontendApplicationConfigProvider } = require('@theia/core/lib/browser/frontend-application-config-provider');
const { ConnectionProvider, SocketIoTransport } = require('open-collaboration-protocol');
const { io } = require('socket.io-client');
const { collaborationBase, createPrefixConnectionProvider } = require('../collaboration/client-factory.cjs');
Object.defineProperty(exports, '__esModule', { value: true });
// Register room commands only for this workspace's authenticated gateway route.
// An absent/mismatched URL keeps collaboration disabled with no public fallback.
class ScopedCollaborationContribution extends CollaborationFrontendContribution {
async scopedUrl() {
const url = await this.getCollaborationServerUrl();
return collaborationBase(url, window.location.href).href;
}
init() {
this.scopedUrl()
.then(() => this.setStatusBarEntryDefault())
.catch(() => {});
}
registerCommands(commands) {
this.scopedUrl()
.then(() => super.registerCommands(commands))
.catch(() => {});
}
async createConnectionProvider() {
const url = await this.scopedUrl();
return createPrefixConnectionProvider(
{ ConnectionProvider, SocketIoTransport, io },
{
url,
browserLocation: window.location.href,
client: FrontendApplicationConfigProvider.get().applicationName,
fetch: window.fetch.bind(window),
authenticationHandler: (token, metadata) => this.handleAuth(url, token, metadata),
// OCT tokens are instance-local; never reuse a different workspace token
// from the upstream global localStorage key.
userToken: undefined,
},
);
}
}
injectable()(ScopedCollaborationContribution);
// Every backend already belongs to one provisioned project. A guest's virtual
// collaboration URI must not overwrite the backend-wide default for other tabs.
class DedicatedWorkspaceService extends CollaborationWorkspaceService {
isRemoteSession() {
return true;
}
}
injectable()(DedicatedWorkspaceService);
module.exports.default = new ContainerModule((_bind, _unbind, _isBound, rebind) => {
require('./plugin-install-frontend.cjs').bindManagedExtensionNotice(_bind);
require('./coordination-frontend.cjs').bindCoordination(_bind);
rebind(CollaborationWorkspaceService).to(DedicatedWorkspaceService).inSingletonScope();
rebind(CollaborationFrontendContribution).to(ScopedCollaborationContribution).inSingletonScope();
});