项目文件夹

文件
caorushizi f04989e973 feat(extension): bundle into desktop app with settings entry and docs
Ship the MediaGo browser extension alongside the Desktop installer so
users can "Load unpacked" it from Chrome / Edge without building the
repo or downloading a separate zip. Adds a discovery path from inside
the app, a three-language doc page, and fixes the Desktop HTTP port
the extension was pointing at.

Packaging:
- `pnpm build:electron` now also builds `@mediago/extension` (turbo
  filter), and `apps/electron/scripts/build.ts` copies the dist to
  `app/build/extension/` and declares it in electron-builder
  `extraResources` → installers land `resources/extension/`.

Runtime:
- `resolveExtensionDir()` in binaryResolver — dev points at the
  monorepo dist, prod at `process.resourcesPath/extension`, env
  override via `MEDIAGO_EXTENSION_DIR`.
- New IPC `app.getExtensionDir()` returns the resolved path. UI pairs
  it with the existing `shell.open()` (no dedicated open-folder IPC)
  so the pattern matches configDir / binDir / localDir.

Settings UI:
- New "Browser extension directory" button in Settings → More Settings,
  right next to the existing folder shortcuts. Web/server mode hides
  the row behind `isWeb` and the stub returns "".
- New i18n key `extensionDir` in shared zh/en resources; duplicate
  `currentVersion` key removed from zh.ts along the way.

Port fix:
- Extension `DESKTOP_HTTP_BASE` corrected from `:9900` → `:39719` to
  match the Electron-side `preferredPort`. 9900 is the standalone
  Go Core / web-server port — two separate deployments.

Docs:
- New `docs/extension.md` + `docs/en/extension.md` + `docs/jp/extension.md`
  covering what the extension does, how to install the unpacked
  build, the three dispatch modes (schema / desktop-http / docker-http),
  import-behaviour toggles, language switching, and common pitfalls.
- Sidebar entries registered in `.vitepress/config.ts` for all three
  locales.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 13:56:05 +08:00
..
2025-11-01 16:23:35 +08:00
2025-11-03 03:50:35 +08:00
2026-04-02 00:15:20 +08:00

@mediago/electron-preload

Electron preload script package for MediaGo application.

Overview

This package contains the preload script that bridges the communication between the Electron main process and renderer process. It exposes safe APIs to the frontend through Electron's contextBridge.

Features

  • Safe IPC communication between main and renderer processes
  • Type-safe API definitions
  • Centralized preload logic for better maintainability
  • Optimized build with esbuild

Usage

In your Electron main process:

import { join } from "path";
import { BrowserWindow } from "electron";

const win = new BrowserWindow({
  webPreferences: {
    nodeIntegration: false,
    contextIsolation: true,
    preload: join(
      __dirname,
      "../node_modules/@mediago/electron-preload/dist/preload.js",
    ),
  },
});

Development

# Build the package
pnpm build

# Watch mode for development
pnpm dev

# Type checking
pnpm types

API

The preload script exposes all Electron APIs through window.electron object, providing type-safe access to:

  • File system operations
  • Download management
  • Browser window controls
  • Settings management
  • And much more...

See the MediaGoApi type definition for complete API reference.