@nextclaw/app-runtime 0.9.12 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{main.js → app/main.js} +2 -2
- package/dist/app/main.js.map +1 -0
- package/dist/{commands → controllers}/create.controller.d.ts +2 -2
- package/dist/controllers/create.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/create.controller.js +2 -2
- package/dist/controllers/create.controller.js.map +1 -0
- package/dist/{commands → controllers}/dev.controller.js +1 -1
- package/dist/controllers/dev.controller.js.map +1 -0
- package/dist/{commands → controllers}/grant.controller.d.ts +3 -3
- package/dist/controllers/grant.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/grant.controller.js +2 -2
- package/dist/controllers/grant.controller.js.map +1 -0
- package/dist/{commands → controllers}/info.controller.d.ts +2 -2
- package/dist/controllers/info.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/info.controller.js +2 -2
- package/dist/controllers/info.controller.js.map +1 -0
- package/dist/{commands → controllers}/inspect.controller.js +8 -2
- package/dist/controllers/inspect.controller.js.map +1 -0
- package/dist/{commands → controllers}/install.controller.d.ts +2 -2
- package/dist/controllers/install.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/install.controller.js +2 -2
- package/dist/controllers/install.controller.js.map +1 -0
- package/dist/{commands → controllers}/list.controller.d.ts +2 -2
- package/dist/controllers/list.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/list.controller.js +2 -2
- package/dist/controllers/list.controller.js.map +1 -0
- package/dist/controllers/pack.controller.d.ts +19 -0
- package/dist/controllers/pack.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/pack.controller.js +8 -4
- package/dist/controllers/pack.controller.js.map +1 -0
- package/dist/{commands → controllers}/permissions.controller.d.ts +2 -2
- package/dist/controllers/permissions.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/permissions.controller.js +2 -2
- package/dist/controllers/permissions.controller.js.map +1 -0
- package/dist/{commands → controllers}/publish.controller.d.ts +3 -3
- package/dist/controllers/publish.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/publish.controller.js +2 -2
- package/dist/controllers/publish.controller.js.map +1 -0
- package/dist/{commands → controllers}/registry.controller.d.ts +2 -2
- package/dist/controllers/registry.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/registry.controller.js +2 -2
- package/dist/controllers/registry.controller.js.map +1 -0
- package/dist/{commands → controllers}/revoke.controller.d.ts +2 -2
- package/dist/controllers/revoke.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/revoke.controller.js +2 -2
- package/dist/controllers/revoke.controller.js.map +1 -0
- package/dist/{commands → controllers}/run.controller.js +8 -6
- package/dist/controllers/run.controller.js.map +1 -0
- package/dist/{commands → controllers}/uninstall.controller.d.ts +2 -2
- package/dist/controllers/uninstall.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/uninstall.controller.js +2 -2
- package/dist/controllers/uninstall.controller.js.map +1 -0
- package/dist/{commands → controllers}/update.controller.d.ts +2 -2
- package/dist/controllers/update.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/update.controller.js +2 -2
- package/dist/controllers/update.controller.js.map +1 -0
- package/dist/{commands → controllers}/validate-publish.controller.d.ts +3 -3
- package/dist/controllers/validate-publish.controller.d.ts.map +1 -0
- package/dist/{commands → controllers}/validate-publish.controller.js +9 -5
- package/dist/controllers/validate-publish.controller.js.map +1 -0
- package/dist/index.d.ts +51 -51
- package/dist/index.js +46 -45
- package/dist/package.js +1 -1
- package/dist/{runtime → services}/app-build.service.d.ts +2 -2
- package/dist/services/app-build.service.d.ts.map +1 -0
- package/dist/{runtime → services}/app-build.service.js +4 -2
- package/dist/services/app-build.service.js.map +1 -0
- package/dist/{bundle → services}/app-bundle.service.d.ts +18 -6
- package/dist/services/app-bundle.service.d.ts.map +1 -0
- package/dist/services/app-bundle.service.js +305 -0
- package/dist/services/app-bundle.service.js.map +1 -0
- package/dist/{permissions → services}/app-grant.service.d.ts +4 -4
- package/dist/services/app-grant.service.d.ts.map +1 -0
- package/dist/{permissions → services}/app-grant.service.js +7 -4
- package/dist/services/app-grant.service.js.map +1 -0
- package/dist/{paths → services}/app-home.service.d.ts +1 -1
- package/dist/services/app-home.service.d.ts.map +1 -0
- package/dist/{paths → services}/app-home.service.js +1 -1
- package/dist/services/app-home.service.js.map +1 -0
- package/dist/{host → services}/app-host.service.d.ts +2 -2
- package/dist/services/app-host.service.d.ts.map +1 -0
- package/dist/{host → services}/app-host.service.js +3 -3
- package/dist/services/app-host.service.js.map +1 -0
- package/dist/services/app-install-source.service.js +72 -0
- package/dist/services/app-install-source.service.js.map +1 -0
- package/dist/{install → services}/app-installation.service.d.ts +15 -14
- package/dist/services/app-installation.service.d.ts.map +1 -0
- package/dist/services/app-installation.service.js +332 -0
- package/dist/services/app-installation.service.js.map +1 -0
- package/dist/services/app-instance.service.d.ts +34 -0
- package/dist/services/app-instance.service.d.ts.map +1 -0
- package/dist/{host → services}/app-instance.service.js +4 -4
- package/dist/services/app-instance.service.js.map +1 -0
- package/dist/{manifest → services}/app-manifest.service.d.ts +12 -2
- package/dist/services/app-manifest.service.d.ts.map +1 -0
- package/dist/services/app-manifest.service.js +271 -0
- package/dist/services/app-manifest.service.js.map +1 -0
- package/dist/{publish → services}/app-marketplace-client.service.d.ts +2 -2
- package/dist/services/app-marketplace-client.service.d.ts.map +1 -0
- package/dist/{publish → services}/app-marketplace-client.service.js +2 -2
- package/dist/services/app-marketplace-client.service.js.map +1 -0
- package/dist/{publish → services}/app-marketplace-metadata.service.d.ts +3 -3
- package/dist/services/app-marketplace-metadata.service.d.ts.map +1 -0
- package/dist/{publish → services}/app-marketplace-metadata.service.js +1 -1
- package/dist/services/app-marketplace-metadata.service.js.map +1 -0
- package/dist/{permissions → services}/app-permissions.service.d.ts +3 -3
- package/dist/services/app-permissions.service.d.ts.map +1 -0
- package/dist/{permissions → services}/app-permissions.service.js +4 -1
- package/dist/services/app-permissions.service.js.map +1 -0
- package/dist/{publish → services}/app-publish-validation.service.d.ts +9 -7
- package/dist/services/app-publish-validation.service.d.ts.map +1 -0
- package/dist/{publish → services}/app-publish-validation.service.js +14 -10
- package/dist/services/app-publish-validation.service.js.map +1 -0
- package/dist/{publish → services}/app-publish.service.d.ts +5 -5
- package/dist/services/app-publish.service.d.ts.map +1 -0
- package/dist/{publish → services}/app-publish.service.js +6 -6
- package/dist/services/app-publish.service.js.map +1 -0
- package/dist/{registry → services}/app-registry-config.service.d.ts +3 -3
- package/dist/{registry → services}/app-registry-config.service.d.ts.map +1 -1
- package/dist/{registry → services}/app-registry-config.service.js +3 -3
- package/dist/services/app-registry-config.service.js.map +1 -0
- package/dist/{registry → services}/app-registry.service.d.ts +18 -5
- package/dist/services/app-registry.service.d.ts.map +1 -0
- package/dist/services/app-registry.service.js +210 -0
- package/dist/services/app-registry.service.js.map +1 -0
- package/dist/{registry → services}/app-remote-registry-client.service.d.ts +6 -2
- package/dist/services/app-remote-registry-client.service.d.ts.map +1 -0
- package/dist/{registry → services}/app-remote-registry-client.service.js +54 -8
- package/dist/services/app-remote-registry-client.service.js.map +1 -0
- package/dist/{cli → services}/app-runtime-cli.service.d.ts +1 -1
- package/dist/services/app-runtime-cli.service.d.ts.map +1 -0
- package/dist/{cli → services}/app-runtime-cli.service.js +19 -19
- package/dist/services/app-runtime-cli.service.js.map +1 -0
- package/dist/{cli → services}/app-runtime-options.service.d.ts +6 -6
- package/dist/services/app-runtime-options.service.d.ts.map +1 -0
- package/dist/{cli → services}/app-runtime-options.service.js +3 -9
- package/dist/services/app-runtime-options.service.js.map +1 -0
- package/dist/{runtime → services}/app-runtime-toolchain.service.d.ts +1 -1
- package/dist/services/app-runtime-toolchain.service.d.ts.map +1 -0
- package/dist/{runtime → services}/app-runtime-toolchain.service.js +1 -1
- package/dist/services/app-runtime-toolchain.service.js.map +1 -0
- package/dist/{scaffold → services}/app-scaffold.service.d.ts +1 -1
- package/dist/{scaffold → services}/app-scaffold.service.d.ts.map +1 -1
- package/dist/{scaffold → services}/app-scaffold.service.js +1 -1
- package/dist/{scaffold → services}/app-scaffold.service.js.map +1 -1
- package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.d.ts +1 -1
- package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.d.ts.map +1 -1
- package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.js +1 -1
- package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.js.map +1 -1
- package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.d.ts +1 -1
- package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.d.ts.map +1 -1
- package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.js +1 -1
- package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.js.map +1 -1
- package/dist/{bridge → services}/host-bridge.service.d.ts +2 -2
- package/dist/services/host-bridge.service.d.ts.map +1 -0
- package/dist/{bridge → services}/host-bridge.service.js +1 -1
- package/dist/services/host-bridge.service.js.map +1 -0
- package/dist/services/main-runner.service.d.ts +9 -0
- package/dist/services/main-runner.service.d.ts.map +1 -0
- package/dist/services/main-runner.service.js +6 -0
- package/dist/services/main-runner.service.js.map +1 -0
- package/dist/{publish → services}/platform-auth-state.service.d.ts +1 -1
- package/dist/services/platform-auth-state.service.d.ts.map +1 -0
- package/dist/{publish → services}/platform-auth-state.service.js +1 -1
- package/dist/services/platform-auth-state.service.js.map +1 -0
- package/dist/{ui → services}/ui-server.service.d.ts +3 -3
- package/dist/services/ui-server.service.d.ts.map +1 -0
- package/dist/{ui → services}/ui-server.service.js +1 -1
- package/dist/services/ui-server.service.js.map +1 -0
- package/dist/{runtime → services}/wasm-main-runner.service.d.ts +3 -3
- package/dist/services/wasm-main-runner.service.d.ts.map +1 -0
- package/dist/{runtime → services}/wasm-main-runner.service.js +2 -2
- package/dist/services/wasm-main-runner.service.js.map +1 -0
- package/dist/{sidecar → services}/wasm-sidecar-client.service.d.ts +1 -1
- package/dist/services/wasm-sidecar-client.service.d.ts.map +1 -0
- package/dist/{sidecar → services}/wasm-sidecar-client.service.js +1 -1
- package/dist/services/wasm-sidecar-client.service.js.map +1 -0
- package/dist/{runtime → services}/wasmtime-wasi-http-component.service.d.ts +1 -1
- package/dist/services/wasmtime-wasi-http-component.service.d.ts.map +1 -0
- package/dist/{runtime → services}/wasmtime-wasi-http-component.service.js +1 -1
- package/dist/services/wasmtime-wasi-http-component.service.js.map +1 -0
- package/dist/{bundle → types}/app-bundle.types.d.ts +1 -1
- package/dist/types/app-bundle.types.d.ts.map +1 -0
- package/dist/{install → types}/app-installation.types.d.ts +27 -7
- package/dist/types/app-installation.types.d.ts.map +1 -0
- package/dist/types/app-manifest.types.d.ts +119 -0
- package/dist/types/app-manifest.types.d.ts.map +1 -0
- package/dist/types/app-manifest.types.js +11 -0
- package/dist/types/app-manifest.types.js.map +1 -0
- package/dist/{permissions → types}/app-permissions.types.d.ts +2 -2
- package/dist/types/app-permissions.types.d.ts.map +1 -0
- package/dist/{publish → types}/app-publish.types.d.ts +4 -4
- package/dist/types/app-publish.types.d.ts.map +1 -0
- package/dist/{publish → types}/app-publish.types.js +1 -1
- package/dist/types/app-publish.types.js.map +1 -0
- package/dist/{registry → types}/app-registry.types.d.ts +8 -4
- package/dist/types/app-registry.types.d.ts.map +1 -0
- package/dist/{registry → types}/app-remote-registry.types.d.ts +3 -3
- package/dist/types/app-remote-registry.types.d.ts.map +1 -0
- package/dist/{registry → types}/app-remote-registry.types.js +1 -1
- package/dist/types/app-remote-registry.types.js.map +1 -0
- package/dist/{runtime → types}/main-runner.types.d.ts +3 -3
- package/dist/types/main-runner.types.d.ts.map +1 -0
- package/package.json +10 -3
- package/dist/bridge/host-bridge.service.d.ts.map +0 -1
- package/dist/bridge/host-bridge.service.js.map +0 -1
- package/dist/bundle/app-bundle.service.d.ts.map +0 -1
- package/dist/bundle/app-bundle.service.js +0 -196
- package/dist/bundle/app-bundle.service.js.map +0 -1
- package/dist/bundle/app-bundle.types.d.ts.map +0 -1
- package/dist/cli/app-runtime-cli.service.d.ts.map +0 -1
- package/dist/cli/app-runtime-cli.service.js.map +0 -1
- package/dist/cli/app-runtime-options.service.d.ts.map +0 -1
- package/dist/cli/app-runtime-options.service.js.map +0 -1
- package/dist/commands/create.controller.d.ts.map +0 -1
- package/dist/commands/create.controller.js.map +0 -1
- package/dist/commands/dev.controller.js.map +0 -1
- package/dist/commands/grant.controller.d.ts.map +0 -1
- package/dist/commands/grant.controller.js.map +0 -1
- package/dist/commands/info.controller.d.ts.map +0 -1
- package/dist/commands/info.controller.js.map +0 -1
- package/dist/commands/inspect.controller.js.map +0 -1
- package/dist/commands/install.controller.d.ts.map +0 -1
- package/dist/commands/install.controller.js.map +0 -1
- package/dist/commands/list.controller.d.ts.map +0 -1
- package/dist/commands/list.controller.js.map +0 -1
- package/dist/commands/pack.controller.d.ts +0 -17
- package/dist/commands/pack.controller.d.ts.map +0 -1
- package/dist/commands/pack.controller.js.map +0 -1
- package/dist/commands/permissions.controller.d.ts.map +0 -1
- package/dist/commands/permissions.controller.js.map +0 -1
- package/dist/commands/publish.controller.d.ts.map +0 -1
- package/dist/commands/publish.controller.js.map +0 -1
- package/dist/commands/registry.controller.d.ts.map +0 -1
- package/dist/commands/registry.controller.js.map +0 -1
- package/dist/commands/revoke.controller.d.ts.map +0 -1
- package/dist/commands/revoke.controller.js.map +0 -1
- package/dist/commands/run.controller.js.map +0 -1
- package/dist/commands/uninstall.controller.d.ts.map +0 -1
- package/dist/commands/uninstall.controller.js.map +0 -1
- package/dist/commands/update.controller.d.ts.map +0 -1
- package/dist/commands/update.controller.js.map +0 -1
- package/dist/commands/validate-publish.controller.d.ts.map +0 -1
- package/dist/commands/validate-publish.controller.js.map +0 -1
- package/dist/host/app-host.service.d.ts.map +0 -1
- package/dist/host/app-host.service.js.map +0 -1
- package/dist/host/app-instance.service.d.ts +0 -34
- package/dist/host/app-instance.service.d.ts.map +0 -1
- package/dist/host/app-instance.service.js.map +0 -1
- package/dist/install/app-installation.service.d.ts.map +0 -1
- package/dist/install/app-installation.service.js +0 -276
- package/dist/install/app-installation.service.js.map +0 -1
- package/dist/install/app-installation.types.d.ts.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/manifest/app-manifest.service.d.ts.map +0 -1
- package/dist/manifest/app-manifest.service.js +0 -147
- package/dist/manifest/app-manifest.service.js.map +0 -1
- package/dist/manifest/app-manifest.types.d.ts +0 -68
- package/dist/manifest/app-manifest.types.d.ts.map +0 -1
- package/dist/paths/app-home.service.d.ts.map +0 -1
- package/dist/paths/app-home.service.js.map +0 -1
- package/dist/permissions/app-grant.service.d.ts.map +0 -1
- package/dist/permissions/app-grant.service.js.map +0 -1
- package/dist/permissions/app-permissions.service.d.ts.map +0 -1
- package/dist/permissions/app-permissions.service.js.map +0 -1
- package/dist/permissions/app-permissions.types.d.ts.map +0 -1
- package/dist/publish/app-marketplace-client.service.d.ts.map +0 -1
- package/dist/publish/app-marketplace-client.service.js.map +0 -1
- package/dist/publish/app-marketplace-metadata.service.d.ts.map +0 -1
- package/dist/publish/app-marketplace-metadata.service.js.map +0 -1
- package/dist/publish/app-publish-validation.service.d.ts.map +0 -1
- package/dist/publish/app-publish-validation.service.js.map +0 -1
- package/dist/publish/app-publish.service.d.ts.map +0 -1
- package/dist/publish/app-publish.service.js.map +0 -1
- package/dist/publish/app-publish.types.d.ts.map +0 -1
- package/dist/publish/app-publish.types.js.map +0 -1
- package/dist/publish/platform-auth-state.service.d.ts.map +0 -1
- package/dist/publish/platform-auth-state.service.js.map +0 -1
- package/dist/registry/app-registry-config.service.js.map +0 -1
- package/dist/registry/app-registry.service.d.ts.map +0 -1
- package/dist/registry/app-registry.service.js +0 -118
- package/dist/registry/app-registry.service.js.map +0 -1
- package/dist/registry/app-registry.types.d.ts.map +0 -1
- package/dist/registry/app-remote-registry-client.service.d.ts.map +0 -1
- package/dist/registry/app-remote-registry-client.service.js.map +0 -1
- package/dist/registry/app-remote-registry.types.d.ts.map +0 -1
- package/dist/registry/app-remote-registry.types.js.map +0 -1
- package/dist/runtime/app-build.service.d.ts.map +0 -1
- package/dist/runtime/app-build.service.js.map +0 -1
- package/dist/runtime/app-runtime-toolchain.service.d.ts.map +0 -1
- package/dist/runtime/app-runtime-toolchain.service.js.map +0 -1
- package/dist/runtime/main-runner.service.d.ts +0 -9
- package/dist/runtime/main-runner.service.d.ts.map +0 -1
- package/dist/runtime/main-runner.service.js +0 -6
- package/dist/runtime/main-runner.service.js.map +0 -1
- package/dist/runtime/main-runner.types.d.ts.map +0 -1
- package/dist/runtime/wasm-main-runner.service.d.ts.map +0 -1
- package/dist/runtime/wasm-main-runner.service.js.map +0 -1
- package/dist/runtime/wasmtime-wasi-http-component.service.d.ts.map +0 -1
- package/dist/runtime/wasmtime-wasi-http-component.service.js.map +0 -1
- package/dist/sidecar/wasm-sidecar-client.service.d.ts.map +0 -1
- package/dist/sidecar/wasm-sidecar-client.service.js.map +0 -1
- package/dist/ui/ui-server.service.d.ts.map +0 -1
- package/dist/ui/ui-server.service.js.map +0 -1
- /package/dist/{main.d.ts → app/main.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-instance.service.js","names":[],"sources":["../../src/host/app-instance.service.ts"],"sourcesContent":["import { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { AppManifestBundle } from \"../manifest/app-manifest.types.js\";\nimport { AppManifestService } from \"../manifest/app-manifest.service.js\";\nimport { AppPermissionsService } from \"../permissions/app-permissions.service.js\";\nimport type {\n AppDocumentGrantMap,\n AppPermissionSummary,\n ResolvedPermissions,\n} from \"../permissions/app-permissions.types.js\";\nimport { WasmMainRunnerService } from \"../runtime/wasm-main-runner.service.js\";\nimport type { MainRunResult, WasmDocumentSummaryInput } from \"../runtime/main-runner.types.js\";\n\nexport type AppRunResult = {\n action: string;\n input: WasmDocumentSummaryInput;\n output: MainRunResult;\n observedAt: string;\n};\n\nexport class AppInstanceService {\n private permissions?: ResolvedPermissions;\n\n constructor(\n readonly bundle: AppManifestBundle,\n private readonly permissionsService: AppPermissionsService = new AppPermissionsService(),\n private readonly mainRunner: WasmMainRunnerService = new WasmMainRunnerService(),\n private readonly manifestService: AppManifestService = new AppManifestService(),\n ) {}\n\n initialize = async (\n documentGrantMap: AppDocumentGrantMap,\n context?: {\n appId?: string;\n },\n ): Promise<void> => {\n this.permissions = await this.permissionsService.resolve(\n this.bundle,\n documentGrantMap,\n context,\n );\n };\n\n summarizeManifest = () => {\n return this.manifestService.summarize(this.bundle);\n };\n\n summarizePermissions = (): AppPermissionSummary => {\n return this.permissionsService.summarize(this.bundle, this.getPermissions());\n };\n\n runAction = async (action?: string): Promise<AppRunResult> => {\n if (this.bundle.manifest.main.kind !== \"wasm\") {\n throw new Error(\"当前应用不支持 __napp/run action,请通过 /api/* 调用 WASI HTTP 后端。\");\n }\n const expectedAction = this.bundle.manifest.main.action;\n if (action && action !== expectedAction) {\n throw new Error(`当前应用只支持动作 ${expectedAction}。`);\n }\n\n const input = await this.collectDocumentSummaryInput();\n const output = await this.mainRunner.runDocumentSummary({\n bundle: this.bundle,\n input,\n });\n\n return {\n action: expectedAction,\n input,\n output,\n observedAt: new Date().toISOString(),\n };\n };\n\n private collectDocumentSummaryInput = async (): Promise<WasmDocumentSummaryInput> => {\n const permissions = this.getPermissions();\n let documentCount = 0;\n let textBytes = 0;\n\n for (const grant of permissions.documentAccess) {\n const scopeSummary = await this.collectDirectorySummary(grant.path);\n documentCount += scopeSummary.documentCount;\n textBytes += scopeSummary.textBytes;\n }\n\n return {\n documentCount,\n textBytes,\n };\n };\n\n private collectDirectorySummary = async (\n directoryPath: string,\n ): Promise<WasmDocumentSummaryInput> => {\n const entries = await readdir(directoryPath, { withFileTypes: true });\n let documentCount = 0;\n let textBytes = 0;\n\n for (const entry of entries) {\n const entryPath = path.join(directoryPath, entry.name);\n if (entry.isDirectory()) {\n const childSummary = await this.collectDirectorySummary(entryPath);\n documentCount += childSummary.documentCount;\n textBytes += childSummary.textBytes;\n continue;\n }\n if (!entry.isFile()) {\n continue;\n }\n const content = await readFile(entryPath, \"utf-8\");\n documentCount += 1;\n textBytes += Buffer.byteLength(content, \"utf-8\");\n }\n\n return {\n documentCount,\n textBytes,\n };\n };\n\n private getPermissions = (): ResolvedPermissions => {\n if (!this.permissions) {\n throw new Error(\"应用实例尚未初始化权限。\");\n }\n return this.permissions;\n };\n}\n"],"mappings":";;;;;;AAoBA,IAAa,qBAAb,MAAgC;CAC9B;CAEA,YACE,QACA,qBAA6D,IAAI,uBAAuB,EACxF,aAAqD,IAAI,uBAAuB,EAChF,kBAAuD,IAAI,oBAAoB,EAC/E;AAJS,OAAA,SAAA;AACQ,OAAA,qBAAA;AACA,OAAA,aAAA;AACA,OAAA,kBAAA;;CAGnB,aAAa,OACX,kBACA,YAGkB;AAClB,OAAK,cAAc,MAAM,KAAK,mBAAmB,QAC/C,KAAK,QACL,kBACA,QACD;;CAGH,0BAA0B;AACxB,SAAO,KAAK,gBAAgB,UAAU,KAAK,OAAO;;CAGpD,6BAAmD;AACjD,SAAO,KAAK,mBAAmB,UAAU,KAAK,QAAQ,KAAK,gBAAgB,CAAC;;CAG9E,YAAY,OAAO,WAA2C;AAC5D,MAAI,KAAK,OAAO,SAAS,KAAK,SAAS,OACrC,OAAM,IAAI,MAAM,wDAAwD;EAE1E,MAAM,iBAAiB,KAAK,OAAO,SAAS,KAAK;AACjD,MAAI,UAAU,WAAW,eACvB,OAAM,IAAI,MAAM,aAAa,eAAe,GAAG;EAGjD,MAAM,QAAQ,MAAM,KAAK,6BAA6B;AAMtD,SAAO;GACL,QAAQ;GACR;GACA,QARa,MAAM,KAAK,WAAW,mBAAmB;IACtD,QAAQ,KAAK;IACb;IACD,CAAC;GAMA,6BAAY,IAAI,MAAM,EAAC,aAAa;GACrC;;CAGH,8BAAsC,YAA+C;EACnF,MAAM,cAAc,KAAK,gBAAgB;EACzC,IAAI,gBAAgB;EACpB,IAAI,YAAY;AAEhB,OAAK,MAAM,SAAS,YAAY,gBAAgB;GAC9C,MAAM,eAAe,MAAM,KAAK,wBAAwB,MAAM,KAAK;AACnE,oBAAiB,aAAa;AAC9B,gBAAa,aAAa;;AAG5B,SAAO;GACL;GACA;GACD;;CAGH,0BAAkC,OAChC,kBACsC;EACtC,MAAM,UAAU,MAAM,QAAQ,eAAe,EAAE,eAAe,MAAM,CAAC;EACrE,IAAI,gBAAgB;EACpB,IAAI,YAAY;AAEhB,OAAK,MAAM,SAAS,SAAS;GAC3B,MAAM,YAAY,KAAK,KAAK,eAAe,MAAM,KAAK;AACtD,OAAI,MAAM,aAAa,EAAE;IACvB,MAAM,eAAe,MAAM,KAAK,wBAAwB,UAAU;AAClE,qBAAiB,aAAa;AAC9B,iBAAa,aAAa;AAC1B;;AAEF,OAAI,CAAC,MAAM,QAAQ,CACjB;GAEF,MAAM,UAAU,MAAM,SAAS,WAAW,QAAQ;AAClD,oBAAiB;AACjB,gBAAa,OAAO,WAAW,SAAS,QAAQ;;AAGlD,SAAO;GACL;GACA;GACD;;CAGH,uBAAoD;AAClD,MAAI,CAAC,KAAK,YACR,OAAM,IAAI,MAAM,eAAe;AAEjC,SAAO,KAAK"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-installation.service.d.ts","names":[],"sources":["../../src/install/app-installation.service.ts"],"mappings":";;;;;;;;;;;cAoBa,sBAAA;EAAA,iBAEQ,cAAA;EAAA,iBACA,aAAA;EAAA,iBACA,eAAA;EAAA,iBACA,YAAA;EAAA,iBACA,eAAA;EAAA,iBACA,qBAAA;EAAA,iBAGA,oBAAA;cARA,cAAA,GAAgB,cAAA,EAChB,aAAA,GAAe,gBAAA,EACf,eAAA,GAAiB,kBAAA,EACjB,YAAA,GAAc,eAAA,EACd,eAAA,GAAiB,kBAAA,EACjB,qBAAA,GAAuB,wBAAA,EAGvB,oBAAA,GAAsB,8BAAA;EAKzC,OAAA,GACE,SAAA,UACA,OAAA;IACE,WAAA;EAAA,MAED,OAAA,CAAQ,gBAAA;EA6FX,MAAA,GACE,KAAA,UACA,OAAA;IACE,OAAA;IACA,WAAA;EAAA,MAED,OAAA,CAAQ,eAAA;EA8CX,SAAA,GACE,KAAA,UACA,SAAA,cACC,OAAA,CAAQ,kBAAA;EAuBX,IAAA,QAAiB,OAAA,CAAQ,oBAAA;EAazB,IAAA,GAAc,KAAA,aAAgB,OAAA,CAAQ,aAAA;EA+BtC,aAAA,GACE,YAAA,UACA,wBAAA,EAA0B,mBAAA,KACzB,OAAA,CAAQ,mBAAA;EA2BX,aAAA,GACE,KAAA,sBACA,gBAAA,EAAkB,mBAAA,KACjB,OAAA;EAAA,QAOK,oBAAA;EAAA,QAsDA,qBAAA;EAAA,QAiDA,iBAAA;EAAA,QAkBA,aAAA;EAAA,QAQA,uBAAA;AAAA"}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { AppManifestService } from "../manifest/app-manifest.service.js";
|
|
2
|
-
import { AppBundleService } from "../bundle/app-bundle.service.js";
|
|
3
|
-
import { AppHomeService } from "../paths/app-home.service.js";
|
|
4
|
-
import { AppBuildService } from "../runtime/app-build.service.js";
|
|
5
|
-
import { AppRegistryConfigService } from "../registry/app-registry-config.service.js";
|
|
6
|
-
import { AppRemoteRegistryClientService } from "../registry/app-remote-registry-client.service.js";
|
|
7
|
-
import { AppRegistryService } from "../registry/app-registry.service.js";
|
|
8
|
-
import { access, cp, mkdir, rm } from "node:fs/promises";
|
|
9
|
-
import path from "node:path";
|
|
10
|
-
//#region src/install/app-installation.service.ts
|
|
11
|
-
var AppInstallationService = class {
|
|
12
|
-
constructor(appHomeService = new AppHomeService(), bundleService = new AppBundleService(), manifestService = new AppManifestService(), buildService = new AppBuildService(), registryService = new AppRegistryService(appHomeService), registryConfigService = new AppRegistryConfigService(appHomeService), remoteRegistryClient = new AppRemoteRegistryClientService(new AppRegistryConfigService(appHomeService))) {
|
|
13
|
-
this.appHomeService = appHomeService;
|
|
14
|
-
this.bundleService = bundleService;
|
|
15
|
-
this.manifestService = manifestService;
|
|
16
|
-
this.buildService = buildService;
|
|
17
|
-
this.registryService = registryService;
|
|
18
|
-
this.registryConfigService = registryConfigService;
|
|
19
|
-
this.remoteRegistryClient = remoteRegistryClient;
|
|
20
|
-
}
|
|
21
|
-
install = async (appSource, options) => {
|
|
22
|
-
const source = await this.resolveInstallSource(appSource, options?.registryUrl);
|
|
23
|
-
const tempDirectory = await this.appHomeService.createTemporaryDirectory("napp-install-");
|
|
24
|
-
try {
|
|
25
|
-
const bundlePath = source.kind === "directory" ? (await this.bundleService.packAppDirectory({
|
|
26
|
-
appDirectory: source.appDirectory,
|
|
27
|
-
outputPath: path.join(tempDirectory, "app.napp")
|
|
28
|
-
})).bundlePath : source.kind === "bundle" ? source.bundlePath : (await this.remoteRegistryClient.downloadBundle({
|
|
29
|
-
resolution: source.registryResolution,
|
|
30
|
-
targetDirectory: tempDirectory
|
|
31
|
-
})).bundlePath;
|
|
32
|
-
const extractedDirectory = path.join(tempDirectory, "bundle");
|
|
33
|
-
const extractedMetadata = await this.bundleService.extractBundle({
|
|
34
|
-
bundlePath,
|
|
35
|
-
targetDirectory: extractedDirectory
|
|
36
|
-
});
|
|
37
|
-
await this.materializeDistribution({
|
|
38
|
-
appDirectory: extractedDirectory,
|
|
39
|
-
distributionMode: extractedMetadata.metadata.distributionMode
|
|
40
|
-
});
|
|
41
|
-
const manifestBundle = await this.manifestService.load(extractedDirectory);
|
|
42
|
-
const installDirectory = this.appHomeService.getInstallDirectory(manifestBundle.manifest.id, manifestBundle.manifest.version);
|
|
43
|
-
if (source.kind === "registry" && manifestBundle.manifest.id !== source.registryResolution.appId) throw new Error(`bundle manifest.appId 与 registry 请求不一致:期望 ${source.registryResolution.appId},实际 ${manifestBundle.manifest.id}`);
|
|
44
|
-
const dataDirectory = this.appHomeService.getAppDataDirectory(manifestBundle.manifest.id);
|
|
45
|
-
await rm(installDirectory, {
|
|
46
|
-
recursive: true,
|
|
47
|
-
force: true
|
|
48
|
-
});
|
|
49
|
-
await mkdir(path.dirname(installDirectory), { recursive: true });
|
|
50
|
-
await mkdir(dataDirectory, { recursive: true });
|
|
51
|
-
await cp(extractedDirectory, installDirectory, { recursive: true });
|
|
52
|
-
const registryRecord = await this.registryService.upsertInstallation({
|
|
53
|
-
appId: manifestBundle.manifest.id,
|
|
54
|
-
name: manifestBundle.manifest.name,
|
|
55
|
-
description: manifestBundle.manifest.description,
|
|
56
|
-
version: manifestBundle.manifest.version,
|
|
57
|
-
installDirectory,
|
|
58
|
-
dataDirectory,
|
|
59
|
-
sourceKind: source.kind,
|
|
60
|
-
distributionMode: source.kind === "registry" ? source.registryResolution.distributionMode : extractedMetadata.metadata.distributionMode,
|
|
61
|
-
sourceRef: source.sourceRef,
|
|
62
|
-
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
63
|
-
permissions: manifestBundle.manifest.permissions ?? {},
|
|
64
|
-
registryUrl: source.kind === "registry" ? source.registryResolution.registryUrl : void 0,
|
|
65
|
-
bundleUrl: source.kind === "registry" ? source.registryResolution.bundleUrl : void 0,
|
|
66
|
-
sha256: source.kind === "registry" ? source.registryResolution.sha256 : void 0,
|
|
67
|
-
publisher: source.kind === "registry" ? source.registryResolution.publisher : void 0
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
appId: registryRecord.appId,
|
|
71
|
-
name: registryRecord.name,
|
|
72
|
-
version: registryRecord.activeVersion,
|
|
73
|
-
installDirectory,
|
|
74
|
-
dataDirectory,
|
|
75
|
-
sourceKind: source.kind,
|
|
76
|
-
sourceRef: source.sourceRef,
|
|
77
|
-
distributionMode: registryRecord.installedVersions[registryRecord.activeVersion]?.distributionMode,
|
|
78
|
-
permissions: registryRecord.installedVersions[registryRecord.activeVersion]?.permissions ?? {},
|
|
79
|
-
registryUrl: registryRecord.installedVersions[registryRecord.activeVersion]?.registryUrl,
|
|
80
|
-
bundleUrl: registryRecord.installedVersions[registryRecord.activeVersion]?.bundleUrl,
|
|
81
|
-
sha256: registryRecord.installedVersions[registryRecord.activeVersion]?.sha256,
|
|
82
|
-
publisher: registryRecord.installedVersions[registryRecord.activeVersion]?.publisher
|
|
83
|
-
};
|
|
84
|
-
} finally {
|
|
85
|
-
await rm(tempDirectory, {
|
|
86
|
-
recursive: true,
|
|
87
|
-
force: true
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
update = async (appId, options) => {
|
|
92
|
-
const appRecord = await this.registryService.getApp(appId);
|
|
93
|
-
if (!appRecord) throw new Error(`未找到已安装应用:${appId}`);
|
|
94
|
-
const activeVersionRecord = appRecord.installedVersions[appRecord.activeVersion];
|
|
95
|
-
const registryUrl = options?.registryUrl ?? activeVersionRecord?.registryUrl ?? (await this.registryConfigService.getSnapshot()).currentUrl;
|
|
96
|
-
const resolution = await this.remoteRegistryClient.resolve({
|
|
97
|
-
appId,
|
|
98
|
-
version: options?.version,
|
|
99
|
-
registryUrl
|
|
100
|
-
});
|
|
101
|
-
if (resolution.version === appRecord.activeVersion) {
|
|
102
|
-
if (!activeVersionRecord) throw new Error(`已安装应用缺少激活版本:${appId}`);
|
|
103
|
-
return {
|
|
104
|
-
appId: appRecord.appId,
|
|
105
|
-
name: appRecord.name,
|
|
106
|
-
version: appRecord.activeVersion,
|
|
107
|
-
previousVersion: appRecord.activeVersion,
|
|
108
|
-
installDirectory: activeVersionRecord.installDirectory,
|
|
109
|
-
dataDirectory: appRecord.dataDirectory,
|
|
110
|
-
sourceKind: activeVersionRecord.sourceKind,
|
|
111
|
-
sourceRef: activeVersionRecord.sourceRef,
|
|
112
|
-
permissions: activeVersionRecord.permissions,
|
|
113
|
-
registryUrl: activeVersionRecord.registryUrl,
|
|
114
|
-
bundleUrl: activeVersionRecord.bundleUrl,
|
|
115
|
-
sha256: activeVersionRecord.sha256,
|
|
116
|
-
publisher: activeVersionRecord.publisher,
|
|
117
|
-
updated: false
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
...await this.install(`${appId}@${resolution.version}`, { registryUrl }),
|
|
122
|
-
previousVersion: appRecord.activeVersion,
|
|
123
|
-
updated: true
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
uninstall = async (appId, purgeData) => {
|
|
127
|
-
const appRecord = await this.registryService.removeApp(appId);
|
|
128
|
-
if (!appRecord) throw new Error(`未找到已安装应用:${appId}`);
|
|
129
|
-
const removedVersions = Object.keys(appRecord.installedVersions).sort((left, right) => left.localeCompare(right));
|
|
130
|
-
await Promise.all(Object.values(appRecord.installedVersions).map((versionRecord) => rm(versionRecord.installDirectory, {
|
|
131
|
-
recursive: true,
|
|
132
|
-
force: true
|
|
133
|
-
})));
|
|
134
|
-
if (purgeData) await rm(appRecord.dataDirectory, {
|
|
135
|
-
recursive: true,
|
|
136
|
-
force: true
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
appId,
|
|
140
|
-
removedVersions,
|
|
141
|
-
dataRemoved: purgeData
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
list = async () => {
|
|
145
|
-
return (await this.registryService.listApps()).map((appRecord) => ({
|
|
146
|
-
appId: appRecord.appId,
|
|
147
|
-
name: appRecord.name,
|
|
148
|
-
activeVersion: appRecord.activeVersion,
|
|
149
|
-
sourceKind: appRecord.installedVersions[appRecord.activeVersion]?.sourceKind ?? "directory",
|
|
150
|
-
distributionMode: appRecord.installedVersions[appRecord.activeVersion]?.distributionMode
|
|
151
|
-
}));
|
|
152
|
-
};
|
|
153
|
-
info = async (appId) => {
|
|
154
|
-
const appRecord = await this.registryService.getApp(appId);
|
|
155
|
-
if (!appRecord) throw new Error(`未找到已安装应用:${appId}`);
|
|
156
|
-
const installedVersions = Object.values(appRecord.installedVersions).sort((left, right) => left.version.localeCompare(right.version));
|
|
157
|
-
return {
|
|
158
|
-
appId: appRecord.appId,
|
|
159
|
-
name: appRecord.name,
|
|
160
|
-
description: appRecord.description,
|
|
161
|
-
activeVersion: appRecord.activeVersion,
|
|
162
|
-
dataDirectory: appRecord.dataDirectory,
|
|
163
|
-
installedVersions: installedVersions.map((versionRecord) => ({
|
|
164
|
-
version: versionRecord.version,
|
|
165
|
-
installDirectory: versionRecord.installDirectory,
|
|
166
|
-
sourceKind: versionRecord.sourceKind,
|
|
167
|
-
distributionMode: versionRecord.distributionMode,
|
|
168
|
-
sourceRef: versionRecord.sourceRef,
|
|
169
|
-
installedAt: versionRecord.installedAt,
|
|
170
|
-
permissions: versionRecord.permissions,
|
|
171
|
-
registryUrl: versionRecord.registryUrl,
|
|
172
|
-
bundleUrl: versionRecord.bundleUrl,
|
|
173
|
-
sha256: versionRecord.sha256,
|
|
174
|
-
publisher: versionRecord.publisher
|
|
175
|
-
})),
|
|
176
|
-
grants: appRecord.grants
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
resolveLaunch = async (appReference, explicitDocumentGrantMap) => {
|
|
180
|
-
const sourceType = await this.detectLocalSourceType(appReference, false);
|
|
181
|
-
if (sourceType.kind === "directory") return {
|
|
182
|
-
appDirectory: sourceType.appDirectory,
|
|
183
|
-
documentGrantMap: explicitDocumentGrantMap
|
|
184
|
-
};
|
|
185
|
-
const appRecord = await this.registryService.getApp(appReference);
|
|
186
|
-
if (!appRecord) throw new Error(`未找到应用目录,也未找到已安装应用:${appReference}`);
|
|
187
|
-
const activeVersion = appRecord.installedVersions[appRecord.activeVersion];
|
|
188
|
-
if (!activeVersion) throw new Error(`已安装应用缺少激活版本:${appReference}`);
|
|
189
|
-
return {
|
|
190
|
-
appDirectory: activeVersion.installDirectory,
|
|
191
|
-
appId: appRecord.appId,
|
|
192
|
-
dataDirectory: appRecord.dataDirectory,
|
|
193
|
-
documentGrantMap: {
|
|
194
|
-
...appRecord.grants,
|
|
195
|
-
...explicitDocumentGrantMap
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
persistGrants = async (appId, documentGrantMap) => {
|
|
200
|
-
if (!appId || Object.keys(documentGrantMap).length === 0) return;
|
|
201
|
-
await this.registryService.updateGrants(appId, documentGrantMap);
|
|
202
|
-
};
|
|
203
|
-
resolveInstallSource = async (appSource, registryUrl) => {
|
|
204
|
-
const localSource = await this.detectLocalSourceType(appSource);
|
|
205
|
-
if (localSource.kind === "directory") return {
|
|
206
|
-
kind: "directory",
|
|
207
|
-
appDirectory: localSource.appDirectory,
|
|
208
|
-
sourceRef: localSource.appDirectory
|
|
209
|
-
};
|
|
210
|
-
if (localSource.kind === "bundle") return {
|
|
211
|
-
kind: "bundle",
|
|
212
|
-
bundlePath: localSource.bundlePath,
|
|
213
|
-
sourceRef: localSource.bundlePath
|
|
214
|
-
};
|
|
215
|
-
const registrySpec = this.parseRegistrySpec(appSource);
|
|
216
|
-
if (!registrySpec) {
|
|
217
|
-
if (this.looksLikePath(appSource)) throw new Error(`本地安装源不存在:${appSource}`);
|
|
218
|
-
throw new Error(`无法识别安装源:${appSource}`);
|
|
219
|
-
}
|
|
220
|
-
const registryResolution = await this.remoteRegistryClient.resolve({
|
|
221
|
-
appId: registrySpec.appId,
|
|
222
|
-
version: registrySpec.version,
|
|
223
|
-
registryUrl
|
|
224
|
-
});
|
|
225
|
-
return {
|
|
226
|
-
kind: "registry",
|
|
227
|
-
sourceRef: `${registryResolution.appId}@${registryResolution.version}`,
|
|
228
|
-
registryResolution
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
detectLocalSourceType = async (sourcePath, allowBundle = true) => {
|
|
232
|
-
const normalizedSource = path.resolve(sourcePath);
|
|
233
|
-
try {
|
|
234
|
-
await access(normalizedSource);
|
|
235
|
-
if ((await this.manifestService.load(normalizedSource)).appDirectory) return {
|
|
236
|
-
kind: "directory",
|
|
237
|
-
appDirectory: normalizedSource
|
|
238
|
-
};
|
|
239
|
-
} catch {
|
|
240
|
-
if (allowBundle && normalizedSource.endsWith(".napp")) try {
|
|
241
|
-
await access(normalizedSource);
|
|
242
|
-
return {
|
|
243
|
-
kind: "bundle",
|
|
244
|
-
bundlePath: normalizedSource
|
|
245
|
-
};
|
|
246
|
-
} catch {
|
|
247
|
-
return { kind: "missing" };
|
|
248
|
-
}
|
|
249
|
-
return { kind: "missing" };
|
|
250
|
-
}
|
|
251
|
-
return { kind: "missing" };
|
|
252
|
-
};
|
|
253
|
-
parseRegistrySpec = (appSource) => {
|
|
254
|
-
const match = /^(?<appId>[a-z0-9][a-z0-9._-]*)(?:@(?<version>[A-Za-z0-9._+-]+))?$/i.exec(appSource.trim());
|
|
255
|
-
if (!match?.groups?.appId) return;
|
|
256
|
-
return {
|
|
257
|
-
appId: match.groups.appId,
|
|
258
|
-
version: match.groups.version
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
looksLikePath = (appSource) => {
|
|
262
|
-
return appSource.startsWith(".") || appSource.startsWith("/") || appSource.includes(path.sep);
|
|
263
|
-
};
|
|
264
|
-
materializeDistribution = async (params) => {
|
|
265
|
-
if (params.distributionMode !== "source") return;
|
|
266
|
-
if ((await this.manifestService.load(params.appDirectory)).manifest.main.kind !== "wasi-http-component") return;
|
|
267
|
-
await this.buildService.build({
|
|
268
|
-
appDirectory: params.appDirectory,
|
|
269
|
-
install: true
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
//#endregion
|
|
274
|
-
export { AppInstallationService };
|
|
275
|
-
|
|
276
|
-
//# sourceMappingURL=app-installation.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-installation.service.js","names":[],"sources":["../../src/install/app-installation.service.ts"],"sourcesContent":["import { access, cp, mkdir, rm } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { AppBundleService } from \"../bundle/app-bundle.service.js\";\nimport { AppManifestService } from \"../manifest/app-manifest.service.js\";\nimport { AppHomeService } from \"../paths/app-home.service.js\";\nimport { AppBuildService } from \"../runtime/app-build.service.js\";\nimport type { AppDistributionMode } from \"../bundle/app-bundle.types.js\";\nimport type { AppDocumentGrantMap } from \"../permissions/app-permissions.types.js\";\nimport { AppRegistryConfigService } from \"../registry/app-registry-config.service.js\";\nimport { AppRemoteRegistryClientService } from \"../registry/app-remote-registry-client.service.js\";\nimport { AppRegistryService } from \"../registry/app-registry.service.js\";\nimport type {\n AppInfoResult,\n AppInstallResult,\n AppLaunchResolution,\n AppUpdateResult,\n AppUninstallResult,\n InstalledAppListItem,\n} from \"./app-installation.types.js\";\n\nexport class AppInstallationService {\n constructor(\n private readonly appHomeService: AppHomeService = new AppHomeService(),\n private readonly bundleService: AppBundleService = new AppBundleService(),\n private readonly manifestService: AppManifestService = new AppManifestService(),\n private readonly buildService: AppBuildService = new AppBuildService(),\n private readonly registryService: AppRegistryService = new AppRegistryService(appHomeService),\n private readonly registryConfigService: AppRegistryConfigService = new AppRegistryConfigService(\n appHomeService,\n ),\n private readonly remoteRegistryClient: AppRemoteRegistryClientService = new AppRemoteRegistryClientService(\n new AppRegistryConfigService(appHomeService),\n ),\n ) {}\n\n install = async (\n appSource: string,\n options?: {\n registryUrl?: string;\n },\n ): Promise<AppInstallResult> => {\n const source = await this.resolveInstallSource(appSource, options?.registryUrl);\n const tempDirectory = await this.appHomeService.createTemporaryDirectory(\"napp-install-\");\n try {\n const bundlePath =\n source.kind === \"directory\"\n ? (await this.bundleService.packAppDirectory({\n appDirectory: source.appDirectory,\n outputPath: path.join(tempDirectory, \"app.napp\"),\n })).bundlePath\n : source.kind === \"bundle\"\n ? source.bundlePath\n : (\n await this.remoteRegistryClient.downloadBundle({\n resolution: source.registryResolution,\n targetDirectory: tempDirectory,\n })\n ).bundlePath;\n const extractedDirectory = path.join(tempDirectory, \"bundle\");\n const extractedMetadata = await this.bundleService.extractBundle({\n bundlePath,\n targetDirectory: extractedDirectory,\n });\n await this.materializeDistribution({\n appDirectory: extractedDirectory,\n distributionMode: extractedMetadata.metadata.distributionMode,\n });\n const manifestBundle = await this.manifestService.load(extractedDirectory);\n const installDirectory = this.appHomeService.getInstallDirectory(\n manifestBundle.manifest.id,\n manifestBundle.manifest.version,\n );\n if (\n source.kind === \"registry\" &&\n manifestBundle.manifest.id !== source.registryResolution.appId\n ) {\n throw new Error(\n `bundle manifest.appId 与 registry 请求不一致:期望 ${source.registryResolution.appId},实际 ${manifestBundle.manifest.id}`,\n );\n }\n const dataDirectory = this.appHomeService.getAppDataDirectory(manifestBundle.manifest.id);\n await rm(installDirectory, { recursive: true, force: true });\n await mkdir(path.dirname(installDirectory), { recursive: true });\n await mkdir(dataDirectory, { recursive: true });\n await cp(extractedDirectory, installDirectory, { recursive: true });\n const registryRecord = await this.registryService.upsertInstallation({\n appId: manifestBundle.manifest.id,\n name: manifestBundle.manifest.name,\n description: manifestBundle.manifest.description,\n version: manifestBundle.manifest.version,\n installDirectory,\n dataDirectory,\n sourceKind: source.kind,\n distributionMode:\n source.kind === \"registry\"\n ? source.registryResolution.distributionMode\n : extractedMetadata.metadata.distributionMode,\n sourceRef: source.sourceRef,\n installedAt: new Date().toISOString(),\n permissions: manifestBundle.manifest.permissions ?? {},\n registryUrl:\n source.kind === \"registry\" ? source.registryResolution.registryUrl : undefined,\n bundleUrl:\n source.kind === \"registry\" ? source.registryResolution.bundleUrl : undefined,\n sha256: source.kind === \"registry\" ? source.registryResolution.sha256 : undefined,\n publisher:\n source.kind === \"registry\" ? source.registryResolution.publisher : undefined,\n });\n return {\n appId: registryRecord.appId,\n name: registryRecord.name,\n version: registryRecord.activeVersion,\n installDirectory,\n dataDirectory,\n sourceKind: source.kind,\n sourceRef: source.sourceRef,\n distributionMode:\n registryRecord.installedVersions[registryRecord.activeVersion]?.distributionMode,\n permissions:\n registryRecord.installedVersions[registryRecord.activeVersion]?.permissions ?? {},\n registryUrl:\n registryRecord.installedVersions[registryRecord.activeVersion]?.registryUrl,\n bundleUrl:\n registryRecord.installedVersions[registryRecord.activeVersion]?.bundleUrl,\n sha256: registryRecord.installedVersions[registryRecord.activeVersion]?.sha256,\n publisher:\n registryRecord.installedVersions[registryRecord.activeVersion]?.publisher,\n };\n } finally {\n await rm(tempDirectory, { recursive: true, force: true });\n }\n };\n\n update = async (\n appId: string,\n options?: {\n version?: string;\n registryUrl?: string;\n },\n ): Promise<AppUpdateResult> => {\n const appRecord = await this.registryService.getApp(appId);\n if (!appRecord) {\n throw new Error(`未找到已安装应用:${appId}`);\n }\n const activeVersionRecord = appRecord.installedVersions[appRecord.activeVersion];\n const registryUrl =\n options?.registryUrl ??\n activeVersionRecord?.registryUrl ??\n (await this.registryConfigService.getSnapshot()).currentUrl;\n const resolution = await this.remoteRegistryClient.resolve({\n appId,\n version: options?.version,\n registryUrl,\n });\n if (resolution.version === appRecord.activeVersion) {\n if (!activeVersionRecord) {\n throw new Error(`已安装应用缺少激活版本:${appId}`);\n }\n return {\n appId: appRecord.appId,\n name: appRecord.name,\n version: appRecord.activeVersion,\n previousVersion: appRecord.activeVersion,\n installDirectory: activeVersionRecord.installDirectory,\n dataDirectory: appRecord.dataDirectory,\n sourceKind: activeVersionRecord.sourceKind,\n sourceRef: activeVersionRecord.sourceRef,\n permissions: activeVersionRecord.permissions,\n registryUrl: activeVersionRecord.registryUrl,\n bundleUrl: activeVersionRecord.bundleUrl,\n sha256: activeVersionRecord.sha256,\n publisher: activeVersionRecord.publisher,\n updated: false,\n };\n }\n const installResult = await this.install(`${appId}@${resolution.version}`, {\n registryUrl,\n });\n return {\n ...installResult,\n previousVersion: appRecord.activeVersion,\n updated: true,\n };\n };\n\n uninstall = async (\n appId: string,\n purgeData: boolean,\n ): Promise<AppUninstallResult> => {\n const appRecord = await this.registryService.removeApp(appId);\n if (!appRecord) {\n throw new Error(`未找到已安装应用:${appId}`);\n }\n const removedVersions = Object.keys(appRecord.installedVersions).sort((left, right) =>\n left.localeCompare(right),\n );\n await Promise.all(\n Object.values(appRecord.installedVersions).map((versionRecord) =>\n rm(versionRecord.installDirectory, { recursive: true, force: true }),\n ),\n );\n if (purgeData) {\n await rm(appRecord.dataDirectory, { recursive: true, force: true });\n }\n return {\n appId,\n removedVersions,\n dataRemoved: purgeData,\n };\n };\n\n list = async (): Promise<InstalledAppListItem[]> => {\n const appRecords = await this.registryService.listApps();\n return appRecords.map((appRecord) => ({\n appId: appRecord.appId,\n name: appRecord.name,\n activeVersion: appRecord.activeVersion,\n sourceKind:\n appRecord.installedVersions[appRecord.activeVersion]?.sourceKind ?? \"directory\",\n distributionMode:\n appRecord.installedVersions[appRecord.activeVersion]?.distributionMode,\n }));\n };\n\n info = async (appId: string): Promise<AppInfoResult> => {\n const appRecord = await this.registryService.getApp(appId);\n if (!appRecord) {\n throw new Error(`未找到已安装应用:${appId}`);\n }\n const installedVersions = Object.values(appRecord.installedVersions).sort((left, right) =>\n left.version.localeCompare(right.version),\n );\n return {\n appId: appRecord.appId,\n name: appRecord.name,\n description: appRecord.description,\n activeVersion: appRecord.activeVersion,\n dataDirectory: appRecord.dataDirectory,\n installedVersions: installedVersions.map((versionRecord) => ({\n version: versionRecord.version,\n installDirectory: versionRecord.installDirectory,\n sourceKind: versionRecord.sourceKind,\n distributionMode: versionRecord.distributionMode,\n sourceRef: versionRecord.sourceRef,\n installedAt: versionRecord.installedAt,\n permissions: versionRecord.permissions,\n registryUrl: versionRecord.registryUrl,\n bundleUrl: versionRecord.bundleUrl,\n sha256: versionRecord.sha256,\n publisher: versionRecord.publisher,\n })),\n grants: appRecord.grants,\n };\n };\n\n resolveLaunch = async (\n appReference: string,\n explicitDocumentGrantMap: AppDocumentGrantMap,\n ): Promise<AppLaunchResolution> => {\n const sourceType = await this.detectLocalSourceType(appReference, false);\n if (sourceType.kind === \"directory\") {\n return {\n appDirectory: sourceType.appDirectory,\n documentGrantMap: explicitDocumentGrantMap,\n };\n }\n const appRecord = await this.registryService.getApp(appReference);\n if (!appRecord) {\n throw new Error(`未找到应用目录,也未找到已安装应用:${appReference}`);\n }\n const activeVersion = appRecord.installedVersions[appRecord.activeVersion];\n if (!activeVersion) {\n throw new Error(`已安装应用缺少激活版本:${appReference}`);\n }\n return {\n appDirectory: activeVersion.installDirectory,\n appId: appRecord.appId,\n dataDirectory: appRecord.dataDirectory,\n documentGrantMap: {\n ...appRecord.grants,\n ...explicitDocumentGrantMap,\n },\n };\n };\n\n persistGrants = async (\n appId: string | undefined,\n documentGrantMap: AppDocumentGrantMap,\n ): Promise<void> => {\n if (!appId || Object.keys(documentGrantMap).length === 0) {\n return;\n }\n await this.registryService.updateGrants(appId, documentGrantMap);\n };\n\n private resolveInstallSource = async (\n appSource: string,\n registryUrl?: string,\n ): Promise<\n | {\n kind: \"directory\";\n appDirectory: string;\n sourceRef: string;\n }\n | {\n kind: \"bundle\";\n bundlePath: string;\n sourceRef: string;\n }\n | {\n kind: \"registry\";\n sourceRef: string;\n registryResolution: Awaited<ReturnType<AppRemoteRegistryClientService[\"resolve\"]>>;\n }\n > => {\n const localSource = await this.detectLocalSourceType(appSource);\n if (localSource.kind === \"directory\") {\n return {\n kind: \"directory\",\n appDirectory: localSource.appDirectory,\n sourceRef: localSource.appDirectory,\n };\n }\n if (localSource.kind === \"bundle\") {\n return {\n kind: \"bundle\",\n bundlePath: localSource.bundlePath,\n sourceRef: localSource.bundlePath,\n };\n }\n const registrySpec = this.parseRegistrySpec(appSource);\n if (!registrySpec) {\n if (this.looksLikePath(appSource)) {\n throw new Error(`本地安装源不存在:${appSource}`);\n }\n throw new Error(`无法识别安装源:${appSource}`);\n }\n const registryResolution = await this.remoteRegistryClient.resolve({\n appId: registrySpec.appId,\n version: registrySpec.version,\n registryUrl,\n });\n return {\n kind: \"registry\",\n sourceRef: `${registryResolution.appId}@${registryResolution.version}`,\n registryResolution,\n };\n };\n\n private detectLocalSourceType = async (\n sourcePath: string,\n allowBundle: boolean = true,\n ): Promise<\n | {\n kind: \"directory\";\n appDirectory: string;\n }\n | {\n kind: \"bundle\";\n bundlePath: string;\n }\n | {\n kind: \"missing\";\n }\n > => {\n const normalizedSource = path.resolve(sourcePath);\n try {\n await access(normalizedSource);\n const manifestBundle = await this.manifestService.load(normalizedSource);\n if (manifestBundle.appDirectory) {\n return {\n kind: \"directory\",\n appDirectory: normalizedSource,\n };\n }\n } catch {\n if (allowBundle && normalizedSource.endsWith(\".napp\")) {\n try {\n await access(normalizedSource);\n return {\n kind: \"bundle\",\n bundlePath: normalizedSource,\n };\n } catch {\n return {\n kind: \"missing\",\n };\n }\n }\n return {\n kind: \"missing\",\n };\n }\n return {\n kind: \"missing\",\n };\n };\n\n private parseRegistrySpec = (\n appSource: string,\n ): {\n appId: string;\n version?: string;\n } | undefined => {\n const match = /^(?<appId>[a-z0-9][a-z0-9._-]*)(?:@(?<version>[A-Za-z0-9._+-]+))?$/i.exec(\n appSource.trim(),\n );\n if (!match?.groups?.appId) {\n return undefined;\n }\n return {\n appId: match.groups.appId,\n version: match.groups.version,\n };\n };\n\n private looksLikePath = (appSource: string): boolean => {\n return (\n appSource.startsWith(\".\") ||\n appSource.startsWith(\"/\") ||\n appSource.includes(path.sep)\n );\n };\n\n private materializeDistribution = async (params: {\n appDirectory: string;\n distributionMode: AppDistributionMode;\n }): Promise<void> => {\n if (params.distributionMode !== \"source\") {\n return;\n }\n const manifestBundle = await this.manifestService.load(params.appDirectory);\n if (manifestBundle.manifest.main.kind !== \"wasi-http-component\") {\n return;\n }\n await this.buildService.build({\n appDirectory: params.appDirectory,\n install: true,\n });\n };\n}\n"],"mappings":";;;;;;;;;;AAoBA,IAAa,yBAAb,MAAoC;CAClC,YACE,iBAAkD,IAAI,gBAAgB,EACtE,gBAAmD,IAAI,kBAAkB,EACzE,kBAAuD,IAAI,oBAAoB,EAC/E,eAAiD,IAAI,iBAAiB,EACtE,kBAAuD,IAAI,mBAAmB,eAAe,EAC7F,wBAAmE,IAAI,yBACrE,eACD,EACD,uBAAwE,IAAI,+BAC1E,IAAI,yBAAyB,eAAe,CAC7C,EACD;AAXiB,OAAA,iBAAA;AACA,OAAA,gBAAA;AACA,OAAA,kBAAA;AACA,OAAA,eAAA;AACA,OAAA,kBAAA;AACA,OAAA,wBAAA;AAGA,OAAA,uBAAA;;CAKnB,UAAU,OACR,WACA,YAG8B;EAC9B,MAAM,SAAS,MA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AyB,cAA+B;AACtD,SACE,UAAU,WAAW,IAAI,IACzB,UAAU,WAAW,IAAI,IACzB,UAAU,SAAS,KAAK,IAAI;;CAIhC,0BAAkC,OAAO,WAGpB;AACnB,MAAI,OAAO,qBAAqB,SAC9B;AAGF,OADuB,MAAM,KAAK,gBAAgB,KAAK,OAAO,aAAa,EACxD,SAAS,KAAK,SAAS,sBACxC;AAEF,QAAM,KAAK,aAAa,MAAM;GAC5B,cAAc,OAAO;GACrB,SAAS;GACV,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-installation.types.d.ts","names":[],"sources":["../../src/install/app-installation.types.ts"],"mappings":";;;;;;;KAMY,gBAAA;EACV,KAAA;EACA,IAAA;EACA,OAAA;EACA,gBAAA;EACA,aAAA;EACA,UAAA,EAAY,oBAAA;EACZ,gBAAA,GAAmB,mBAAA;EACnB,SAAA;EACA,WAAA,EAAa,cAAA;EACb,WAAA;EACA,SAAA;EACA,MAAA;EACA,SAAA,GAAY,YAAA;AAAA;AAAA,KAGF,aAAA;EACV,KAAA;EACA,IAAA;EACA,WAAA;EACA,aAAA;EACA,aAAA;EACA,iBAAA,EAAmB,KAAA;IACjB,OAAA;IACA,gBAAA;IACA,UAAA,EAAY,oBAAA;IACZ,gBAAA,GAAmB,mBAAA;IACnB,SAAA;IACA,WAAA;IACA,WAAA,EAAa,cAAA;IACb,WAAA;IACA,SAAA;IACA,MAAA;IACA,SAAA,GAAY,YAAA;EAAA;EAEd,MAAA,EAAQ,mBAAA;AAAA;AAAA,KAGE,oBAAA;EACV,KAAA;EACA,IAAA;EACA,aAAA;EACA,UAAA,EAAY,oBAAA;EACZ,gBAAA,GAAmB,mBAAA;AAAA;AAAA,KAGT,kBAAA;EACV,KAAA;EACA,eAAA;EACA,WAAA;AAAA;AAAA,KAGU,mBAAA;EACV,YAAA;EACA,KAAA;EACA,aAAA;EACA,gBAAA,EAAkB,mBAAA;AAAA;AAAA,KAGR,eAAA,GAAkB,gBAAA;EAC5B,eAAA;EACA,OAAA;AAAA"}
|
package/dist/main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":[],"sources":["../src/main.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { AppRuntimeCliService } from \"./cli/app-runtime-cli.service.js\";\n\nvoid new AppRuntimeCliService().run().catch((error) => {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n});\n"],"mappings":";;;AAIK,IAAI,sBAAsB,CAAC,KAAK,CAAC,OAAO,UAAU;AACrD,SAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC,IAAI;AACnF,SAAQ,KAAK,EAAE;EACf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifest.service.d.ts","names":[],"sources":["../../src/manifest/app-manifest.service.ts"],"mappings":";;;cAUa,kBAAA;EACX,IAAA,GAAc,YAAA,aAAuB,OAAA,CAAQ,iBAAA;EAiC7C,SAAA,GAAa,MAAA,EAAQ,iBAAA,KAAoB,kBAAA;EAAA,QAiBjC,aAAA;EAAA,QA0BA,SAAA;EAAA,QAoBA,OAAA;EAAA,QAOA,gBAAA;EAAA,QAaA,mBAAA;EAAA,QA+BA,gBAAA;EAAA,QAeA,YAAA;EAAA,QAeA,iBAAA;EAAA,QAeA,kBAAA;EAAA,QAiBA,YAAA;EAAA,QAOA,kBAAA;EAAA,QAOA,kBAAA;EAAA,QAOA,UAAA;EAAA,QAOA,WAAA;AAAA"}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { access, readFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
//#region src/manifest/app-manifest.service.ts
|
|
4
|
-
var AppManifestService = class {
|
|
5
|
-
load = async (appDirectory) => {
|
|
6
|
-
const normalizedDirectory = path.resolve(appDirectory);
|
|
7
|
-
const manifestPath = path.join(normalizedDirectory, "manifest.json");
|
|
8
|
-
const rawManifest = JSON.parse(await readFile(manifestPath, "utf-8"));
|
|
9
|
-
const manifest = this.parseManifest(rawManifest);
|
|
10
|
-
const mainEntryPath = await this.assertResolvedFile(normalizedDirectory, manifest.main.entry, "main.entry");
|
|
11
|
-
const uiEntryPath = await this.assertResolvedFile(normalizedDirectory, manifest.ui.entry, "ui.entry");
|
|
12
|
-
return {
|
|
13
|
-
appDirectory: normalizedDirectory,
|
|
14
|
-
manifestPath,
|
|
15
|
-
manifest,
|
|
16
|
-
mainEntryPath,
|
|
17
|
-
uiEntryPath,
|
|
18
|
-
uiDirectoryPath: path.dirname(uiEntryPath),
|
|
19
|
-
assetsDirectoryPath: path.join(normalizedDirectory, "assets"),
|
|
20
|
-
iconPath: manifest.icon ? await this.assertResolvedFile(normalizedDirectory, manifest.icon, "icon") : void 0
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
summarize = (bundle) => {
|
|
24
|
-
const permissions = bundle.manifest.permissions ?? {};
|
|
25
|
-
return {
|
|
26
|
-
id: bundle.manifest.id,
|
|
27
|
-
name: bundle.manifest.name,
|
|
28
|
-
version: bundle.manifest.version,
|
|
29
|
-
description: bundle.manifest.description,
|
|
30
|
-
mainKind: bundle.manifest.main.kind,
|
|
31
|
-
action: bundle.manifest.main.kind === "wasm" ? bundle.manifest.main.action : void 0,
|
|
32
|
-
manifestPath: bundle.manifestPath,
|
|
33
|
-
mainEntryPath: bundle.mainEntryPath,
|
|
34
|
-
uiEntryPath: bundle.uiEntryPath,
|
|
35
|
-
iconPath: bundle.iconPath,
|
|
36
|
-
permissions
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
parseManifest = (rawManifest) => {
|
|
40
|
-
if (!rawManifest || typeof rawManifest !== "object" || Array.isArray(rawManifest)) throw new Error("manifest.json 必须是一个对象。");
|
|
41
|
-
const candidate = rawManifest;
|
|
42
|
-
if (this.readNumber(candidate.schemaVersion, "schemaVersion") !== 1) throw new Error("当前只支持 schemaVersion = 1。");
|
|
43
|
-
const permissions = this.parsePermissions(candidate.permissions);
|
|
44
|
-
return {
|
|
45
|
-
schemaVersion: 1,
|
|
46
|
-
id: this.readRequiredString(candidate.id, "id"),
|
|
47
|
-
name: this.readRequiredString(candidate.name, "name"),
|
|
48
|
-
version: this.readRequiredString(candidate.version, "version"),
|
|
49
|
-
description: this.readOptionalString(candidate.description, "description"),
|
|
50
|
-
icon: this.readOptionalString(candidate.icon, "icon"),
|
|
51
|
-
main: this.parseMain(candidate.main),
|
|
52
|
-
ui: this.parseUi(candidate.ui),
|
|
53
|
-
permissions
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
parseMain = (rawMain) => {
|
|
57
|
-
const candidate = this.assertObject(rawMain, "main");
|
|
58
|
-
const kind = this.readRequiredString(candidate.kind, "main.kind");
|
|
59
|
-
if (kind === "wasm") return {
|
|
60
|
-
kind: "wasm",
|
|
61
|
-
entry: this.readRequiredString(candidate.entry, "main.entry"),
|
|
62
|
-
export: this.readRequiredString(candidate.export, "main.export"),
|
|
63
|
-
action: this.readRequiredString(candidate.action, "main.action")
|
|
64
|
-
};
|
|
65
|
-
if (kind === "wasi-http-component") return {
|
|
66
|
-
kind: "wasi-http-component",
|
|
67
|
-
entry: this.readRequiredString(candidate.entry, "main.entry")
|
|
68
|
-
};
|
|
69
|
-
throw new Error("当前 main.kind 只支持 wasm 或 wasi-http-component。");
|
|
70
|
-
};
|
|
71
|
-
parseUi = (rawUi) => {
|
|
72
|
-
const candidate = this.assertObject(rawUi, "ui");
|
|
73
|
-
return { entry: this.readRequiredString(candidate.entry, "ui.entry") };
|
|
74
|
-
};
|
|
75
|
-
parsePermissions = (rawPermissions) => {
|
|
76
|
-
if (rawPermissions === void 0) return;
|
|
77
|
-
const candidate = this.assertObject(rawPermissions, "permissions");
|
|
78
|
-
return {
|
|
79
|
-
documentAccess: this.parseDocumentAccess(candidate.documentAccess),
|
|
80
|
-
allowedDomains: this.parseStringArray(candidate.allowedDomains, "permissions.allowedDomains"),
|
|
81
|
-
storage: this.parseStorage(candidate.storage),
|
|
82
|
-
capabilities: this.parseCapabilities(candidate.capabilities)
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
parseDocumentAccess = (rawDocumentAccess) => {
|
|
86
|
-
if (rawDocumentAccess === void 0) return;
|
|
87
|
-
if (!Array.isArray(rawDocumentAccess)) throw new Error("permissions.documentAccess 必须是数组。");
|
|
88
|
-
return rawDocumentAccess.map((scope, index) => {
|
|
89
|
-
const candidate = this.assertObject(scope, `permissions.documentAccess[${index}]`);
|
|
90
|
-
const mode = this.readRequiredString(candidate.mode, `permissions.documentAccess[${index}].mode`);
|
|
91
|
-
if (mode !== "read" && mode !== "read-write") throw new Error(`permissions.documentAccess[${index}].mode 只支持 read 或 read-write。`);
|
|
92
|
-
return {
|
|
93
|
-
id: this.readRequiredString(candidate.id, `permissions.documentAccess[${index}].id`),
|
|
94
|
-
mode,
|
|
95
|
-
description: this.readOptionalString(candidate.description, `permissions.documentAccess[${index}].description`)
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
parseStringArray = (rawValue, fieldName) => {
|
|
100
|
-
if (rawValue === void 0) return;
|
|
101
|
-
if (!Array.isArray(rawValue)) throw new Error(`${fieldName} 必须是字符串数组。`);
|
|
102
|
-
return rawValue.map((item, index) => this.readRequiredString(item, `${fieldName}[${index}]`));
|
|
103
|
-
};
|
|
104
|
-
parseStorage = (rawStorage) => {
|
|
105
|
-
if (rawStorage === void 0) return;
|
|
106
|
-
if (typeof rawStorage === "boolean") return rawStorage;
|
|
107
|
-
const candidate = this.assertObject(rawStorage, "permissions.storage");
|
|
108
|
-
return { namespace: this.readOptionalString(candidate.namespace, "permissions.storage.namespace") };
|
|
109
|
-
};
|
|
110
|
-
parseCapabilities = (rawCapabilities) => {
|
|
111
|
-
if (rawCapabilities === void 0) return;
|
|
112
|
-
const candidate = this.assertObject(rawCapabilities, "permissions.capabilities");
|
|
113
|
-
return { hostBridge: candidate.hostBridge === void 0 ? void 0 : this.readBoolean(candidate.hostBridge, "permissions.capabilities.hostBridge") };
|
|
114
|
-
};
|
|
115
|
-
assertResolvedFile = async (appDirectory, relativePath, fieldName) => {
|
|
116
|
-
if (path.isAbsolute(relativePath)) throw new Error(`${fieldName} 必须使用应用目录内的相对路径。`);
|
|
117
|
-
const resolvedPath = path.resolve(appDirectory, relativePath);
|
|
118
|
-
const relative = path.relative(appDirectory, resolvedPath);
|
|
119
|
-
if (relative.startsWith("..") || path.isAbsolute(relative)) throw new Error(`${fieldName} 不能指向应用目录之外。`);
|
|
120
|
-
await access(resolvedPath);
|
|
121
|
-
return resolvedPath;
|
|
122
|
-
};
|
|
123
|
-
assertObject = (value, fieldName) => {
|
|
124
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${fieldName} 必须是对象。`);
|
|
125
|
-
return value;
|
|
126
|
-
};
|
|
127
|
-
readRequiredString = (value, fieldName) => {
|
|
128
|
-
if (typeof value !== "string" || !value.trim()) throw new Error(`${fieldName} 必须是非空字符串。`);
|
|
129
|
-
return value.trim();
|
|
130
|
-
};
|
|
131
|
-
readOptionalString = (value, fieldName) => {
|
|
132
|
-
if (value === void 0) return;
|
|
133
|
-
return this.readRequiredString(value, fieldName);
|
|
134
|
-
};
|
|
135
|
-
readNumber = (value, fieldName) => {
|
|
136
|
-
if (typeof value !== "number" || Number.isNaN(value)) throw new Error(`${fieldName} 必须是数字。`);
|
|
137
|
-
return value;
|
|
138
|
-
};
|
|
139
|
-
readBoolean = (value, fieldName) => {
|
|
140
|
-
if (typeof value !== "boolean") throw new Error(`${fieldName} 必须是布尔值。`);
|
|
141
|
-
return value;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
//#endregion
|
|
145
|
-
export { AppManifestService };
|
|
146
|
-
|
|
147
|
-
//# sourceMappingURL=app-manifest.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifest.service.js","names":[],"sources":["../../src/manifest/app-manifest.service.ts"],"sourcesContent":["import { access, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type {\n AppDocumentAccessScope,\n AppManifest,\n AppManifestBundle,\n AppManifestSummary,\n AppPermissions,\n} from \"./app-manifest.types.js\";\n\nexport class AppManifestService {\n load = async (appDirectory: string): Promise<AppManifestBundle> => {\n const normalizedDirectory = path.resolve(appDirectory);\n const manifestPath = path.join(normalizedDirectory, \"manifest.json\");\n const rawManifest = JSON.parse(await readFile(manifestPath, \"utf-8\")) as unknown;\n const manifest = this.parseManifest(rawManifest);\n const mainEntryPath = await this.assertResolvedFile(\n normalizedDirectory,\n manifest.main.entry,\n \"main.entry\",\n );\n const uiEntryPath = await this.assertResolvedFile(\n normalizedDirectory,\n manifest.ui.entry,\n \"ui.entry\",\n );\n const uiDirectoryPath = path.dirname(uiEntryPath);\n const assetsDirectoryPath = path.join(normalizedDirectory, \"assets\");\n const iconPath = manifest.icon\n ? await this.assertResolvedFile(normalizedDirectory, manifest.icon, \"icon\")\n : undefined;\n\n return {\n appDirectory: normalizedDirectory,\n manifestPath,\n manifest,\n mainEntryPath,\n uiEntryPath,\n uiDirectoryPath,\n assetsDirectoryPath,\n iconPath,\n };\n };\n\n summarize = (bundle: AppManifestBundle): AppManifestSummary => {\n const permissions = bundle.manifest.permissions ?? {};\n return {\n id: bundle.manifest.id,\n name: bundle.manifest.name,\n version: bundle.manifest.version,\n description: bundle.manifest.description,\n mainKind: bundle.manifest.main.kind,\n action: bundle.manifest.main.kind === \"wasm\" ? bundle.manifest.main.action : undefined,\n manifestPath: bundle.manifestPath,\n mainEntryPath: bundle.mainEntryPath,\n uiEntryPath: bundle.uiEntryPath,\n iconPath: bundle.iconPath,\n permissions,\n };\n };\n\n private parseManifest = (rawManifest: unknown): AppManifest => {\n if (!rawManifest || typeof rawManifest !== \"object\" || Array.isArray(rawManifest)) {\n throw new Error(\"manifest.json 必须是一个对象。\");\n }\n\n const candidate = rawManifest as Record<string, unknown>;\n const schemaVersion = this.readNumber(candidate.schemaVersion, \"schemaVersion\");\n if (schemaVersion !== 1) {\n throw new Error(\"当前只支持 schemaVersion = 1。\");\n }\n\n const permissions = this.parsePermissions(candidate.permissions);\n\n return {\n schemaVersion: 1,\n id: this.readRequiredString(candidate.id, \"id\"),\n name: this.readRequiredString(candidate.name, \"name\"),\n version: this.readRequiredString(candidate.version, \"version\"),\n description: this.readOptionalString(candidate.description, \"description\"),\n icon: this.readOptionalString(candidate.icon, \"icon\"),\n main: this.parseMain(candidate.main),\n ui: this.parseUi(candidate.ui),\n permissions,\n };\n };\n\n private parseMain = (rawMain: unknown): AppManifest[\"main\"] => {\n const candidate = this.assertObject(rawMain, \"main\");\n const kind = this.readRequiredString(candidate.kind, \"main.kind\");\n if (kind === \"wasm\") {\n return {\n kind: \"wasm\",\n entry: this.readRequiredString(candidate.entry, \"main.entry\"),\n export: this.readRequiredString(candidate.export, \"main.export\"),\n action: this.readRequiredString(candidate.action, \"main.action\"),\n };\n }\n if (kind === \"wasi-http-component\") {\n return {\n kind: \"wasi-http-component\",\n entry: this.readRequiredString(candidate.entry, \"main.entry\"),\n };\n }\n throw new Error(\"当前 main.kind 只支持 wasm 或 wasi-http-component。\");\n };\n\n private parseUi = (rawUi: unknown): AppManifest[\"ui\"] => {\n const candidate = this.assertObject(rawUi, \"ui\");\n return {\n entry: this.readRequiredString(candidate.entry, \"ui.entry\"),\n };\n };\n\n private parsePermissions = (rawPermissions: unknown): AppPermissions | undefined => {\n if (rawPermissions === undefined) {\n return undefined;\n }\n const candidate = this.assertObject(rawPermissions, \"permissions\");\n return {\n documentAccess: this.parseDocumentAccess(candidate.documentAccess),\n allowedDomains: this.parseStringArray(candidate.allowedDomains, \"permissions.allowedDomains\"),\n storage: this.parseStorage(candidate.storage),\n capabilities: this.parseCapabilities(candidate.capabilities),\n };\n };\n\n private parseDocumentAccess = (\n rawDocumentAccess: unknown,\n ): AppDocumentAccessScope[] | undefined => {\n if (rawDocumentAccess === undefined) {\n return undefined;\n }\n if (!Array.isArray(rawDocumentAccess)) {\n throw new Error(\"permissions.documentAccess 必须是数组。\");\n }\n return rawDocumentAccess.map((scope, index) => {\n const candidate = this.assertObject(scope, `permissions.documentAccess[${index}]`);\n const mode = this.readRequiredString(\n candidate.mode,\n `permissions.documentAccess[${index}].mode`,\n );\n if (mode !== \"read\" && mode !== \"read-write\") {\n throw new Error(\n `permissions.documentAccess[${index}].mode 只支持 read 或 read-write。`,\n );\n }\n return {\n id: this.readRequiredString(candidate.id, `permissions.documentAccess[${index}].id`),\n mode,\n description: this.readOptionalString(\n candidate.description,\n `permissions.documentAccess[${index}].description`,\n ),\n };\n });\n };\n\n private parseStringArray = (\n rawValue: unknown,\n fieldName: string,\n ): string[] | undefined => {\n if (rawValue === undefined) {\n return undefined;\n }\n if (!Array.isArray(rawValue)) {\n throw new Error(`${fieldName} 必须是字符串数组。`);\n }\n return rawValue.map((item, index) =>\n this.readRequiredString(item, `${fieldName}[${index}]`),\n );\n };\n\n private parseStorage = (\n rawStorage: unknown,\n ): AppPermissions[\"storage\"] | undefined => {\n if (rawStorage === undefined) {\n return undefined;\n }\n if (typeof rawStorage === \"boolean\") {\n return rawStorage;\n }\n const candidate = this.assertObject(rawStorage, \"permissions.storage\");\n return {\n namespace: this.readOptionalString(candidate.namespace, \"permissions.storage.namespace\"),\n };\n };\n\n private parseCapabilities = (\n rawCapabilities: unknown,\n ): AppPermissions[\"capabilities\"] | undefined => {\n if (rawCapabilities === undefined) {\n return undefined;\n }\n const candidate = this.assertObject(rawCapabilities, \"permissions.capabilities\");\n return {\n hostBridge:\n candidate.hostBridge === undefined\n ? undefined\n : this.readBoolean(candidate.hostBridge, \"permissions.capabilities.hostBridge\"),\n };\n };\n\n private assertResolvedFile = async (\n appDirectory: string,\n relativePath: string,\n fieldName: string,\n ): Promise<string> => {\n if (path.isAbsolute(relativePath)) {\n throw new Error(`${fieldName} 必须使用应用目录内的相对路径。`);\n }\n const resolvedPath = path.resolve(appDirectory, relativePath);\n const relative = path.relative(appDirectory, resolvedPath);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n throw new Error(`${fieldName} 不能指向应用目录之外。`);\n }\n await access(resolvedPath);\n return resolvedPath;\n };\n\n private assertObject = (value: unknown, fieldName: string): Record<string, unknown> => {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(`${fieldName} 必须是对象。`);\n }\n return value as Record<string, unknown>;\n };\n\n private readRequiredString = (value: unknown, fieldName: string): string => {\n if (typeof value !== \"string\" || !value.trim()) {\n throw new Error(`${fieldName} 必须是非空字符串。`);\n }\n return value.trim();\n };\n\n private readOptionalString = (value: unknown, fieldName: string): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n return this.readRequiredString(value, fieldName);\n };\n\n private readNumber = (value: unknown, fieldName: string): number => {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n throw new Error(`${fieldName} 必须是数字。`);\n }\n return value;\n };\n\n private readBoolean = (value: unknown, fieldName: string): boolean => {\n if (typeof value !== \"boolean\") {\n throw new Error(`${fieldName} 必须是布尔值。`);\n }\n return value;\n };\n}\n"],"mappings":";;;AAUA,IAAa,qBAAb,MAAgC;CAC9B,OAAO,OAAO,iBAAqD;EACjE,MAAM,sBAAsB,KAAK,QAAQ,aAAa;EACtD,MAAM,eAAe,KAAK,KAAK,qBAAqB,gBAAgB;EACpE,MAAM,cAAc,KAAK,MAAM,MAAM,SAAS,cAAc,QAAQ,CAAC;EACrE,MAAM,WAAW,KAAK,cAAc,YAAY;EAChD,MAAM,gBAAgB,MAAM,KAAK,mBAC/B,qBACA,SAAS,KAAK,OACd,aACD;EACD,MAAM,cAAc,MAAM,KAAK,mBAC7B,qBACA,SAAS,GAAG,OACZ,WACD;AAOD,SAAO;GACL,cAAc;GACd;GACA;GACA;GACA;GACA,iBAZsB,KAAK,QAAQ,YAAY;GAa/C,qBAZ0B,KAAK,KAAK,qBAAqB,SAAS;GAalE,UAZe,SAAS,OACtB,MAAM,K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K,mBAAmB,OAAO,UAAU;;CAGlD,cAAsB,OAAgB,cAA8B;AAClE,MAAI,OAAO,UAAU,YAAY,OAAO,MAAM,MAAM,CAClD,OAAM,IAAI,MAAM,GAAG,UAAU,SAAS;AAExC,SAAO;;CAGT,eAAuB,OAAgB,cAA+B;AACpE,MAAI,OAAO,UAAU,UACnB,OAAM,IAAI,MAAM,GAAG,UAAU,UAAU;AAEzC,SAAO"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
//#region src/manifest/app-manifest.types.d.ts
|
|
2
|
-
type AppDocumentAccessMode = "read" | "read-write";
|
|
3
|
-
type AppDocumentAccessScope = {
|
|
4
|
-
id: string;
|
|
5
|
-
mode: AppDocumentAccessMode;
|
|
6
|
-
description?: string;
|
|
7
|
-
};
|
|
8
|
-
type AppPermissions = {
|
|
9
|
-
documentAccess?: AppDocumentAccessScope[];
|
|
10
|
-
allowedDomains?: string[];
|
|
11
|
-
storage?: boolean | {
|
|
12
|
-
namespace?: string;
|
|
13
|
-
};
|
|
14
|
-
capabilities?: {
|
|
15
|
-
hostBridge?: boolean;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
type AppCoreWasmMainManifest = {
|
|
19
|
-
kind: "wasm";
|
|
20
|
-
entry: string;
|
|
21
|
-
export: string;
|
|
22
|
-
action: string;
|
|
23
|
-
};
|
|
24
|
-
type AppWasiHttpComponentMainManifest = {
|
|
25
|
-
kind: "wasi-http-component";
|
|
26
|
-
entry: string;
|
|
27
|
-
};
|
|
28
|
-
type AppMainManifest = AppCoreWasmMainManifest | AppWasiHttpComponentMainManifest;
|
|
29
|
-
type AppUiManifest = {
|
|
30
|
-
entry: string;
|
|
31
|
-
};
|
|
32
|
-
type AppManifest = {
|
|
33
|
-
schemaVersion: 1;
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
version: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
icon?: string;
|
|
39
|
-
main: AppMainManifest;
|
|
40
|
-
ui: AppUiManifest;
|
|
41
|
-
permissions?: AppPermissions;
|
|
42
|
-
};
|
|
43
|
-
type AppManifestBundle = {
|
|
44
|
-
appDirectory: string;
|
|
45
|
-
manifestPath: string;
|
|
46
|
-
manifest: AppManifest;
|
|
47
|
-
mainEntryPath: string;
|
|
48
|
-
uiEntryPath: string;
|
|
49
|
-
uiDirectoryPath: string;
|
|
50
|
-
assetsDirectoryPath: string;
|
|
51
|
-
iconPath?: string;
|
|
52
|
-
};
|
|
53
|
-
type AppManifestSummary = {
|
|
54
|
-
id: string;
|
|
55
|
-
name: string;
|
|
56
|
-
version: string;
|
|
57
|
-
description?: string;
|
|
58
|
-
mainKind: AppMainManifest["kind"];
|
|
59
|
-
action?: string;
|
|
60
|
-
manifestPath: string;
|
|
61
|
-
mainEntryPath: string;
|
|
62
|
-
uiEntryPath: string;
|
|
63
|
-
iconPath?: string;
|
|
64
|
-
permissions: AppPermissions;
|
|
65
|
-
};
|
|
66
|
-
//#endregion
|
|
67
|
-
export { AppCoreWasmMainManifest, AppDocumentAccessMode, AppDocumentAccessScope, AppMainManifest, AppManifest, AppManifestBundle, AppManifestSummary, AppPermissions, AppUiManifest, AppWasiHttpComponentMainManifest };
|
|
68
|
-
//# sourceMappingURL=app-manifest.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifest.types.d.ts","names":[],"sources":["../../src/manifest/app-manifest.types.ts"],"mappings":";KAAY,qBAAA;AAAA,KAEA,sBAAA;EACV,EAAA;EACA,IAAA,EAAM,qBAAA;EACN,WAAA;AAAA;AAAA,KAGU,cAAA;EACV,cAAA,GAAiB,sBAAA;EACjB,cAAA;EACA,OAAA;IAAsB,SAAA;EAAA;EACtB,YAAA;IACE,UAAA;EAAA;AAAA;AAAA,KAIQ,uBAAA;EACV,IAAA;EACA,KAAA;EACA,MAAA;EACA,MAAA;AAAA;AAAA,KAGU,gCAAA;EACV,IAAA;EACA,KAAA;AAAA;AAAA,KAGU,eAAA,GAAkB,uBAAA,GAA0B,gCAAA;AAAA,KAE5C,aAAA;EACV,KAAA;AAAA;AAAA,KAGU,WAAA;EACV,aAAA;EACA,EAAA;EACA,IAAA;EACA,OAAA;EACA,WAAA;EACA,IAAA;EACA,IAAA,EAAM,eAAA;EACN,EAAA,EAAI,aAAA;EACJ,WAAA,GAAc,cAAA;AAAA;AAAA,KAGJ,iBAAA;EACV,YAAA;EACA,YAAA;EACA,QAAA,EAAU,WAAA;EACV,aAAA;EACA,WAAA;EACA,eAAA;EACA,mBAAA;EACA,QAAA;AAAA;AAAA,KAGU,kBAAA;EACV,EAAA;EACA,IAAA;EACA,OAAA;EACA,WAAA;EACA,QAAA,EAAU,eAAA;EACV,MAAA;EACA,YAAA;EACA,aAAA;EACA,WAAA;EACA,QAAA;EACA,WAAA,EAAa,cAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-home.service.d.ts","names":[],"sources":["../../src/paths/app-home.service.ts"],"mappings":";cAIa,cAAA;EAAA,iBAEQ,gBAAA;cAAA,gBAAA;EAKnB,mBAAA;EAIA,oBAAA;EAIA,gBAAA;EAIA,eAAA;EAIA,aAAA;EAIA,mBAAA,GAAuB,KAAA,UAAe,OAAA;EAItC,mBAAA,GAAuB,KAAA;EAIvB,qBAAA,QAAkC,OAAA;EAQlC,wBAAA,GAAkC,MAAA,aAAiB,OAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-home.service.js","names":[],"sources":["../../src/paths/app-home.service.ts"],"sourcesContent":["import { mkdir, mkdtemp } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\nexport class AppHomeService {\n constructor(\n private readonly appHomeDirectory: string = process.env.NEXTCLAW_APP_HOME\n ? path.resolve(process.env.NEXTCLAW_APP_HOME)\n : path.join(process.env.HOME ?? process.cwd(), \".nextclaw\", \"apps\"),\n ) {}\n\n getAppHomeDirectory = (): string => {\n return this.appHomeDirectory;\n };\n\n getPackagesDirectory = (): string => {\n return path.join(this.appHomeDirectory, \"packages\");\n };\n\n getDataDirectory = (): string => {\n return path.join(this.appHomeDirectory, \"data\");\n };\n\n getRegistryPath = (): string => {\n return path.join(this.appHomeDirectory, \"registry.json\");\n };\n\n getConfigPath = (): string => {\n return path.join(this.appHomeDirectory, \"config.json\");\n };\n\n getInstallDirectory = (appId: string, version: string): string => {\n return path.join(this.getPackagesDirectory(), appId, version);\n };\n\n getAppDataDirectory = (appId: string): string => {\n return path.join(this.getDataDirectory(), appId);\n };\n\n ensureBaseDirectories = async (): Promise<void> => {\n await Promise.all([\n mkdir(this.appHomeDirectory, { recursive: true }),\n mkdir(this.getPackagesDirectory(), { recursive: true }),\n mkdir(this.getDataDirectory(), { recursive: true }),\n ]);\n };\n\n createTemporaryDirectory = async (prefix: string): Promise<string> => {\n return mkdtemp(path.join(tmpdir(), prefix));\n };\n}\n"],"mappings":";;;;AAIA,IAAa,iBAAb,MAA4B;CAC1B,YACE,mBAA4C,QAAQ,IAAI,oBACpD,KAAK,QAAQ,QAAQ,IAAI,kBAAkB,GAC3C,KAAK,KAAK,QAAQ,IAAI,QAAQ,QAAQ,KAAK,EAAE,aAAa,OAAO,EACrE;AAHiB,OAAA,mBAAA;;CAKnB,4BAAoC;AAClC,SAAO,KAAK;;CAGd,6BAAqC;AACnC,SAAO,KAAK,KAAK,KAAK,kBAAkB,WAAW;;CAGrD,yBAAiC;AAC/B,SAAO,KAAK,KAAK,KAAK,kBAAkB,OAAO;;CAGjD,wBAAgC;AAC9B,SAAO,KAAK,KAAK,KAAK,kBAAkB,gBAAgB;;CAG1D,sBAA8B;AAC5B,SAAO,KAAK,KAAK,KAAK,kBAAkB,cAAc;;CAGxD,uBAAuB,OAAe,YAA4B;AAChE,SAAO,KAAK,KAAK,KAAK,sBAAsB,EAAE,OAAO,QAAQ;;CAG/D,uBAAuB,UAA0B;AAC/C,SAAO,KAAK,KAAK,KAAK,kBAAkB,EAAE,MAAM;;CAGlD,wBAAwB,YAA2B;AACjD,QAAM,QAAQ,IAAI;GAChB,MAAM,KAAK,kBAAkB,EAAE,WAAW,MAAM,CAAC;GACjD,MAAM,KAAK,sBAAsB,EAAE,EAAE,WAAW,MAAM,CAAC;GACvD,MAAM,KAAK,kBAAkB,EAAE,EAAE,WAAW,MAAM,CAAC;GACpD,CAAC;;CAGJ,2BAA2B,OAAO,WAAoC;AACpE,SAAO,QAAQ,KAAK,KAAK,QAAQ,EAAE,OAAO,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-grant.service.d.ts","names":[],"sources":["../../src/permissions/app-grant.service.ts"],"mappings":";;;;;cASa,eAAA;EAAA,iBAEQ,eAAA;EAAA,iBACA,eAAA;cADA,eAAA,GAAiB,kBAAA,EACjB,eAAA,GAAiB,kBAAA;EAGpC,SAAA,GAAmB,KAAA,aAAgB,OAAA,CAAQ,2BAAA;EAsC3C,kBAAA,GAA4B,MAAA;IAC1B,KAAA;IACA,OAAA;IACA,aAAA;EAAA,MACE,OAAA,CAAQ,8BAAA;EA2BZ,mBAAA,GAA6B,MAAA;IAC3B,KAAA;IACA,OAAA;EAAA,MACE,OAAA,CAAQ,8BAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-grant.service.js","names":[],"sources":["../../src/permissions/app-grant.service.ts"],"sourcesContent":["import { access } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { AppManifestService } from \"../manifest/app-manifest.service.js\";\nimport { AppRegistryService } from \"../registry/app-registry.service.js\";\nimport type {\n AppDocumentGrantMutationResult,\n AppInstalledPermissionState,\n} from \"./app-permissions.types.js\";\n\nexport class AppGrantService {\n constructor(\n private readonly registryService: AppRegistryService = new AppRegistryService(),\n private readonly manifestService: AppManifestService = new AppManifestService(),\n ) {}\n\n summarize = async (appId: string): Promise<AppInstalledPermissionState> => {\n const appRecord = await this.registryService.getApp(appId);\n if (!appRecord) {\n throw new Error(`未找到已安装应用:${appId}`);\n }\n const activeVersion = appRecord.installedVersions[appRecord.activeVersion];\n if (!activeVersion) {\n throw new Error(`已安装应用缺少激活版本:${appId}`);\n }\n const bundle = await this.manifestService.load(activeVersion.installDirectory);\n const requestedPermissions = bundle.manifest.permissions ?? {};\n return {\n appId: appRecord.appId,\n name: appRecord.name,\n activeVersion: appRecord.activeVersion,\n documentAccess: (requestedPermissions.documentAccess ?? []).map((scope) => ({\n id: scope.id,\n mode: scope.mode,\n description: scope.description,\n granted: Boolean(appRecord.grants[scope.id]),\n grantedPath: appRecord.grants[scope.id],\n })),\n allowedDomains: requestedPermissions.allowedDomains ?? [],\n storage: {\n enabled:\n requestedPermissions.storage !== undefined &&\n requestedPermissions.storage !== false,\n namespace:\n typeof requestedPermissions.storage === \"object\"\n ? requestedPermissions.storage.namespace\n : undefined,\n },\n capabilities: {\n hostBridge: requestedPermissions.capabilities?.hostBridge !== false,\n },\n };\n };\n\n grantDocumentScope = async (params: {\n appId: string;\n scopeId: string;\n directoryPath: string;\n }): Promise<AppDocumentGrantMutationResult> => {\n const { appId, scopeId, directoryPath } = params;\n const permissionState = await this.summarize(appId);\n const requestedScope = permissionState.documentAccess.find(\n (scope) => scope.id === scopeId,\n );\n if (!requestedScope) {\n throw new Error(`应用 ${appId} 未声明 documentAccess scope:${scopeId}`);\n }\n const normalizedDirectory = path.resolve(directoryPath);\n try {\n await access(normalizedDirectory);\n } catch {\n throw new Error(`授权目录不存在:${normalizedDirectory}`);\n }\n await this.registryService.setDocumentGrant(\n appId,\n scopeId,\n normalizedDirectory,\n );\n return {\n appId,\n scopeId,\n grantedPath: normalizedDirectory,\n };\n };\n\n revokeDocumentScope = async (params: {\n appId: string;\n scopeId: string;\n }): Promise<AppDocumentGrantMutationResult> => {\n const { appId, scopeId } = params;\n await this.summarize(appId);\n const removed = await this.registryService.removeDocumentGrant(\n appId,\n scopeId,\n );\n return {\n appId,\n scopeId,\n removed,\n };\n };\n}\n"],"mappings":";;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;AACN,SAAM,IAAI,MAAM,WAAW,sBAAsB;;AAEnD,QAAM,KAAK,gBAAgB,iBACzB,OACA,SACA,oBACD;AACD,SAAO;GACL;GACA;GACA,aAAa;GACd;;CAGH,sBAAsB,OAAO,WAGkB;EAC7C,MAAM,EAAE,OAAO,YAAY;AAC3B,QAAM,KAAK,UAAU,MAAM;AAK3B,SAAO;GACL;GACA;GACA,SAPc,MAAM,KAAK,gBAAgB,oBACzC,OACA,QACD;GAKA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-permissions.service.d.ts","names":[],"sources":["../../src/permissions/app-permissions.service.ts"],"mappings":";;;;cAaa,qBAAA;EACX,OAAA,GACE,MAAA,EAAQ,iBAAA,EACR,gBAAA,EAAkB,mBAAA,EAClB,OAAA;IACE,KAAA;EAAA,MAED,OAAA,CAAQ,mBAAA;EA2BX,SAAA,GACE,MAAA,EAAQ,iBAAA,EACR,WAAA,EAAa,mBAAA,KACZ,oBAAA;EAAA,QAUK,oBAAA;AAAA"}
|