設定
murasaki.config.ts の完全なリファレンス。
プロジェクトルートの murasaki.config.ts(または .js / .mjs)は、アプリの識別情
報、ウィンドウ、ビルド設定を記述します:
import { defineConfig } from 'murasaki'
export default defineConfig({
appId: 'app.murasaki.example',
productName: 'Murasaki App',
version: '0.1.0',
icon: 'assets/icon.png',
window: {
title: 'Murasaki App',
width: 1000,
height: 700,
},
capabilities: ['dialog:openFile', 'clipboard:writeText'],
})defineConfig は型推論用に同じobjectを返し、宣言windowのlabel / routeを同期的に
検証します。awaitは不要です。
トップレベルのフィールド
| フィールド | 型 | 説明 |
|---|---|---|
appId | string | 必須。 バンドル識別子(例: com.example.my-app)— macOS では CFBundleIdentifier になります。 |
productName | string | 必須。 表示名 — .app のファイル名、Dock/メニューバーのラベル、DMG のボリューム名です。 |
version | string? | アプリのバージョン。ネイティブの About パネルに表示され、.dmg のファイル名にも使われます。デフォルトは 0.0.0。 |
description | string? | ネイティブの「About <app>」パネルに表示される短い説明。 |
copyright | string? | About パネルに表示される著作権表示。 |
homepage | string? | About パネルに表示されるホームページ URL。 |
authors | string[]? | About パネルに表示される作者名(Windows/Linux のみ)。 |
window | WindowConfig? | ウィンドウの形 — 下記を参照。 |
windows | Record<string, SecondaryWindowConfig>? | 安定したlabelをkeyにしたsecondary window — 下記を参照。 |
capabilities | NativeCapability[]? | primary window向けnative command。window.capabilities省略時だけ利用。既定deny-all。 |
systemPermissions | SystemPermissionsConfig? | host OS同意とpackaged macOSの起動時prompt — 下記を参照。 |
main | false | object? | 長寿命 Node Main entry と shutdown 上限 — 下記を参照。 |
bundle | object? | Node dependency と non-code resource packaging — 下記を参照。 |
build | object? | pre-build command とclient公開env prefix — 下記を参照。 |
security | object? | rendererのContent Security Policy — 下記を参照。 |
updater | UpdaterConfig? | 自動更新のソース — 下記を参照。 |
locales | string[]? | アプリが対応する BCP-47 の UI 言語(例: ['en', 'ja'])。macOS バンドルの CFBundleLocalizations に反映され、Murasaki のデフォルトのネイティブメニュー翻訳を制約します。デフォルトは Murasaki がメニュー翻訳を提供しているすべての言語: en、ja、zh-Hans、ko、es、fr、de。 |
devPort | number? | murasaki dev 実行時の Vite 開発サーバーのポート。デフォルトは 5178(使用中なら自動インクリメント)。 |
targets | Target[]? | ビルドターゲット。デフォルトはホストプラットフォーム。darwin-arm64、darwin-x64、win32-x64、win32-arm64、linux-x64、linux-arm64 のうち1つ以上。 |
icon | string? | ソースとなる PNG(理想は 1024px)へのパス。murasaki icon / murasaki bundle がこれを .icns / .ico / PNG セットに展開します。 |
protocols | ProtocolConfig[]? | packaged macOS app / Windows installer が登録する custom URL scheme — 下記を参照。 |
fileAssociations | FileAssociationConfig[]? | packaged macOS app / Windows installer が登録する document extension — 下記を参照。 |
installer | object? | macOS DMG / Windows installer option — 下記を参照。 |
sign | object? | macOS Developer ID / Windows Authenticode 署名 — 下記を参照。 |
window
| フィールド | 型 | 説明 |
|---|---|---|
title | string? | ウィンドウのタイトルバーのテキスト。起動時に一度だけ設定されます。 |
width / height | number? | 初期ウィンドウサイズ。 |
minWidth / minHeight | number? | 最小ウィンドウサイズ。 |
resizable | boolean? | ウィンドウをリサイズ可能にするかどうか。 |
transparent | boolean? | 透明なウィンドウ背景。 |
vibrancy | 'hud' | 'sidebar' | 'popover' | null | macOS の半透明なウィンドウビブランシー。 |
console | boolean? | Windows のみ: backend Node console window を表示。既定 false。 |
route | string? | windowに読み込むsame-origin path。既定/。完全URL / protocol-relative URLは拒否。 |
visible | boolean? | 初期表示。mainは既定true、secondaryは既定false。 |
capabilities | NativeCapability[]? | window別native command allowlist。secondaryは既定deny-all。 |
vibrancy は宣言できますが、ネイティブバインディングにはまだ適用されていません —
設定しても現時点では no-op です(サポート予定)。
windows
window は予約label main を持つprimaryです。secondaryは windows に宣言し、
primary専用の console を除く同じshapeでroute、初期表示、command allowlistを
個別設定します。
window: {
route: '/',
capabilities: ['window:open', 'window:list', 'window:manage'],
},
windows: {
settings: {
route: '/settings',
width: 720,
height: 560,
capabilities: [],
},
},labelは安全な1〜64文字で、mainは予約済みです。secondaryは非表示で作成され、
top-level permissionを継承しません。console はWindows backend console全体を制御する
ため、secondaryに書くと拒否されます。lifecycle / renderer APIは
ウィンドウと権限を参照してください。
capabilities
レンダラー向けネイティブAPIはデフォルトですべて拒否されます。アプリが実際に使う コマンドだけを追加してください。未知のpermissionは何も許可しません。
capabilities: [
'app:quit',
'dialog:openFile',
'clipboard:readText',
'clipboard:writeText',
'notification:show',
'shell:openExternal',
'window:setTitle',
]完全な型付き一覧は NativeCapability です。primaryは
window.capabilities ?? capabilities ?? []、secondaryは自身のlistまたは[]を使い、
call元rendererごとに評価します。別originのページはnative bridgeを利用できません。
window管理では window:getLabel、window:open、window:list、window:manage を使います。
applicationのprogrammatic shutdownには app:quit が必要です。built-in updaterを有効に
すると、検証済みrestart handshake用としてprimary windowへ自動付与されます。
systemPermissions
これは信頼するrenderer commandではなく、host OSの同意を宣言するconfigです。packaged
macOS appではcamera / microphoneの用途説明をInfo.plistへ書き込み、選択した権限を起動時
に要求できます。
systemPermissions: {
macOS: {
camera: {
usageDescription: 'ビデオ通話でカメラを使用します。',
requestOnLaunch: true,
},
microphone: {
usageDescription: '音声通話でマイクを使用します。',
},
screenRecording: { requestOnLaunch: false },
accessibility: { requestOnLaunch: false },
},
},| フィールド | 型 | 説明 |
|---|---|---|
macOS.camera | { usageDescription: string; requestOnLaunch?: boolean } | NSCameraUsageDescriptionを書き込み、任意でpackaged launch時にprompt。 |
macOS.microphone | { usageDescription: string; requestOnLaunch?: boolean } | NSMicrophoneUsageDescriptionを書き込み、任意でpackaged launch時にprompt。 |
macOS.screenRecording | { requestOnLaunch?: boolean } | 任意でpackaged launch時にscreen capture同意を要求。 |
macOS.accessibility | { requestOnLaunch?: boolean } | 任意でpackaged launch時にmacOS accessibility trust promptを表示。 |
機能の必要性をuserが理解できる場合は、起動時promptより文脈に沿った
systemPermission.request()を優先してください。runtime callにはrenderer capabilityの
systemPermission:status / systemPermission:requestも必要です。Windows unpackaged
desktopの同意は利用時に発生するため、汎用的な起動時promptはありません。macOS TCCの
実動作はmurasaki devのterminal / Node identityではなくpackaged appで確認してください。
main
src/main.ts が存在すると Murasaki が読み込みます。別 entry、graceful cleanup deadline、
Main discovery の無効化を設定できます。
main: {
entry: 'src/backend/main.ts',
shutdownTimeoutMs: 15_000,
}
// main: false| フィールド | 型 | 説明 |
|---|---|---|
entry | string? | project root からの相対 path。既定 src/main.ts。 |
shutdownTimeoutMs | number? | host exit前の beforeQuit() + shutdown() 全体の上限。既定 10_000。 |
lifecycle hook と 'use main' は Node Mainを参照してください。
protocols
custom URL scheme を登録し、一致する URL を Node Main の openRequested() hook で
受け取ります。
protocols: [
{ scheme: 'violet', name: 'Violet Link' },
]| フィールド | 型 | 説明 |
|---|---|---|
scheme | string | 必須。 violet://open/42 の violet のような RFC 3986-style scheme。trim 後 lowercase に正規化。1〜63文字の有効な scheme character が必要。blob、file、http、https、javascript、mailto、ms-settings、tel、murasaki などのbrowser/OS schemeは予約済み。 |
name | string? | package metadata に使う human-readable handler name。既定は `${productName} URL`。 |
重複または不正な scheme は build error になります。macOS は packaged .app の
Info.plist に登録情報を書き込みます。Windows は NSIS / MSI installer が OS へ登録し、
portable Windows archive は登録しません。Linux registration は未実装です。
fileAssociations
1つ以上の extension を document type として登録します。
fileAssociations: [
{
extensions: ['vnote', 'violet-note'],
name: 'Violet Note',
description: 'Violet で作成したノート',
role: 'editor',
mimeType: 'application/x-violet-note',
},
]| フィールド | 型 | 説明 |
|---|---|---|
extensions | string[] | 必須。 1つ以上の extension。先頭のドットは指定しても削除され、lowercase に正規化。各値は1〜32文字の英数字、underscore、hyphenで、先頭は英数字。 |
name | string? | document type name。既定は `${productName} document`。 |
description | string? | package / Windows registration metadata に保存する説明。既定は name。 |
role | 'viewer' | 'editor' | 'shell' | 'none' | macOS document role。既定 viewer。 |
mimeType | string? | document metadata に保存する任意の MIME type。 |
extension は全 entry 間で一意である必要があり、不正な extension / MIME type は build
error になります。一致した file は Node Main の openRequested() hook に届きます。
artifact の制約は protocols と同じです。packaged macOS .app と install 済み Windows
NSIS / MSI をサポートし、portable Windows archive、Linux、murasaki dev は
association を install しません。
delivery semantics、testing、untrusted-input requirement は Deep Link と File Associationを参照してください。
bundle
server / Main code は本番向けに compile されます。static bare npm import は自動検出・ stage されます。runtime behavior を静的検出できない dependency / asset に次を使います。
bundle: {
external: ['computed-plugin'],
noExternal: ['small-js-only-package'],
resources: [
'prisma/schema.prisma',
{ from: 'prisma/migrations', to: 'database/migrations' },
],
}| フィールド | 型 | 説明 |
|---|---|---|
external | string[]? | app node_modules に stage。computed / dynamic package load を追加。native addon / runtime data を持つ package はこちらを優先。 |
noExternal | string[]? | compiled server bundle に強制的に含める。runtime asset のない JS-only package 向け。 |
resources | Array<string | { from: string; to?: string }>? | packaged resources に file / directory を copy。string は source basename、object は相対 destination を指定。 |
resources に secret を置かないでください。app bundle 内は user が読めます。native addon
は全 target architecture でテストしてください。
build
build: {
before: 'pnpm --filter @acme/database build && pnpm prisma generate',
envPrefix: ['VITE_', 'NEXT_PUBLIC_'],
}| フィールド | 型 | 説明 |
|---|---|---|
before | string? | client / Node buildの前に一度実行するshell command。非0終了ならpackagingを停止。workspace prerequisiteやcode generation向け。 |
envPrefix | string[]? | Viteがrenderer codeへ公開できるenv prefix。既定はVITE_とNEXT_PUBLIC_。 |
prefix付き変数はclient公開用ですが、secretを置かないでください。Viteが値を配布JavaScriptへ
埋め込みます。packaged Node Mainはlauncherの環境を継承し、Murasakiは.envをappへ
コピーしません。end-user runtime設定はcontext.paths.dataかdeployment環境を使います。
security
Murasakiはframework shellとuser-owned index.htmlの両方へ、環境別のContent
Security Policyを1つ注入します。完全な置き換え、または明示的なopt-outを設定できます。
security: {
csp: "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' https: wss:; object-src 'none'; base-uri 'none'; frame-src 'none'",
},
// 別layerがpolicyを管理する場合のescape hatch:
// security: { csp: false },| 値 | 動作 |
|---|---|
| 省略 | Murasakiのproduction / development既定値を使用。 |
string | 既定値を完全に置換。directiveはmergeされない。 |
false | framework注入を無効化。user-authored CSPは削除しない。 |
index.htmlにCSPの<meta http-equiv>がすでにあれば、そのuser-owned policyを維持しつつ
script / resourceより先に適用されるよう<head>先頭へ移動します。policyは必ず1か所で
管理してください。既存tagとsecurity.csp stringの併用はbuild errorです。設定値は空でない
1行のstringに限り、control character、double quote、
<、>は使えません。既定値、migration、meta配信CSPの制約は
セキュリティを参照してください。
updater
true は、通常の OSS アプリにとって完全に動作する設定です — GitHub リポジトリは
package.json の repository フィールドから、公開鍵は .murasaki/update-key.pub
から推論され、チャンネルはデフォルトで 'stable'、起動時に一度だけチェックします。
オブジェクト形式では、これらのデフォルトに合わない部分だけを上書きすればよいです:
type UpdaterConfig =
| boolean
| {
repo?: string // "owner/repo" — デフォルトは package.json#repository
endpoint?: string // セルフホストのマニフェスト URL — repo とは排他
channel?: string // リリースチャンネル、デフォルト 'stable'
checkOnStart?: boolean // 起動時に一度チェック、デフォルト true
checkInterval?: string | false // 例 '6h' — タイマーで再チェック、デフォルト '6h'
publicKey?: string // base64 の Ed25519 公開鍵 — デフォルトは .murasaki/update-key.pub
}意図的に provider フィールドはありません — GitHub かセルフホストかは、repo と
endpoint のどちらが設定されているかから推論されるため、設定の他の部分とずれることが
ありません。また、署名検証を無効化する方法もありません。
checkOnStart と checkInterval は更新エンジン自身が処理するため、UI 側で
check() を呼ばなくても機能します。useUpdate().check() を手動で呼ぶこともできます —
チェックが実行中のときに二重に走ることはありません。
useUpdate() と <UpdateButton />(いずれも murasaki から)から利用されます —
マニフェストの形式、署名、リリースの公開については、完全な
自動更新ガイドを参照してください。
installer
macOS DMG styling と Windows NSIS / MSI installer option です。省略時は Murasaki の 既定値を使います。
| フィールド | 型 | 説明 |
|---|---|---|
background | string? | カスタム DMG 背景 PNG への(プロジェクトルートからの相対)パス。Murasaki のデフォルトを上書きします。 |
window | { width: number; height: number }? | DMG ウィンドウのコンテンツサイズ(ポイント単位)。デフォルトは { width: 640, height: 420 }(デフォルトの背景に合わせています)。 |
iconSize | number? | DMG ウィンドウ内のアイコンサイズ。デフォルトは 128。 |
installer.windows
| フィールド | 型 | 説明 |
|---|---|---|
installMode | 'perUser' | 'perMachine' | NSIS install scope。既定 perUser。MSI は常に per-machine。 |
publisher | string? | installer / Add-Remove Programs の publisher。authors、copyright、productName の順に fallback。 |
upgradeCode | string? | 安定した MSI GUID。既定は appId 由来。release 後は変更しない。 |
icon | string? | installer / uninstaller / Add-Remove Programs 用 .ico。既定は生成済み app icon。 |
banner | string? | wizard header BMP。NSIS は 150×57、MSI は 493×58 を期待。 |
sidebar | string? | welcome / finish BMP。NSIS は 164×314、MSI は 493×312 を期待。 |
license | string? | NSIS .txt / .rtf または MSI .rtf license file。 |
sign
Murasaki はあなた自身の証明書または signing provider で署名し、独自の証明書は 一切同梱しません。公証の認証情報と PFX password はこの設定ではなく、常に環境変数から 読み取ります — 詳しくは Distribution → Signingを参照 してください。
macOS fields
| フィールド | 型 | 説明 |
|---|---|---|
identity | string? | 署名 identity、例: "Developer ID Application: Name (TEAMID)"。デフォルトは $MURASAKI_SIGN_IDENTITY、次にキーチェーン内の最初の "Developer ID Application" identity。 |
entitlements | string? | カスタムの entitlements .plist へのパス。デフォルトは、Node に優しいハードンドランタイムのセット(JIT + 未署名実行可能メモリ + ライブラリ検証の無効化)です。 |
sign.windows
murasaki bundle --sign --target win32-x64 は portable ZIP 作成前に app executable を
署名します。murasaki installer --sign --target win32-x64 は生成した NSIS setup と
MSI も署名し、すべてを Authenticode policy で検証します。Windows と SignTool が必要です。
| フィールド | 型 | 説明 |
|---|---|---|
certificateFile | string? | PFX/P12 のパス。password は $MURASAKI_WINDOWS_CERTIFICATE_PASSWORD からのみ読み取ります。 |
certificateSubjectName | string? | Windows の My store に import 済みの証明書を subject name で選択します。 |
certificateSha1 | string? | My store 内の証明書の40文字 thumbprint。file / subject selector とは排他的です。 |
certificateStore | 'currentUser' | 'localMachine' | subject / thumbprint / 自動選択を行う store。デフォルトは currentUser。 |
timestampUrl | string | false | RFC 3161 timestamp URL。false で無効。通常は DigiCert、Artifact Signing は Microsoft service がデフォルトです。 |
signToolPath | string? | 明示的な signtool.exe。未指定なら PATH と Windows SDK から探索します。 |
artifactSigning | { dlib: string; metadata: string }? | Microsoft Artifact Signing の provider path (Azure.CodeSigning.Dlib.dll と非secretの account/profile metadata JSON)。証明書 selector とは排他的です。 |
CI 用の環境変数 override は Windows installer と signingを参照してください。