@nextclaw/app-runtime 0.9.13 → 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.
Files changed (306) hide show
  1. package/README.md +2 -2
  2. package/dist/{main.js → app/main.js} +2 -2
  3. package/dist/app/main.js.map +1 -0
  4. package/dist/{commands → controllers}/create.controller.d.ts +2 -2
  5. package/dist/controllers/create.controller.d.ts.map +1 -0
  6. package/dist/{commands → controllers}/create.controller.js +2 -2
  7. package/dist/controllers/create.controller.js.map +1 -0
  8. package/dist/{commands → controllers}/dev.controller.js +1 -1
  9. package/dist/controllers/dev.controller.js.map +1 -0
  10. package/dist/{commands → controllers}/grant.controller.d.ts +3 -3
  11. package/dist/controllers/grant.controller.d.ts.map +1 -0
  12. package/dist/{commands → controllers}/grant.controller.js +2 -2
  13. package/dist/controllers/grant.controller.js.map +1 -0
  14. package/dist/{commands → controllers}/info.controller.d.ts +2 -2
  15. package/dist/controllers/info.controller.d.ts.map +1 -0
  16. package/dist/{commands → controllers}/info.controller.js +2 -2
  17. package/dist/controllers/info.controller.js.map +1 -0
  18. package/dist/{commands → controllers}/inspect.controller.js +8 -2
  19. package/dist/controllers/inspect.controller.js.map +1 -0
  20. package/dist/{commands → controllers}/install.controller.d.ts +2 -2
  21. package/dist/controllers/install.controller.d.ts.map +1 -0
  22. package/dist/{commands → controllers}/install.controller.js +2 -2
  23. package/dist/controllers/install.controller.js.map +1 -0
  24. package/dist/{commands → controllers}/list.controller.d.ts +2 -2
  25. package/dist/controllers/list.controller.d.ts.map +1 -0
  26. package/dist/{commands → controllers}/list.controller.js +2 -2
  27. package/dist/controllers/list.controller.js.map +1 -0
  28. package/dist/controllers/pack.controller.d.ts +19 -0
  29. package/dist/controllers/pack.controller.d.ts.map +1 -0
  30. package/dist/{commands → controllers}/pack.controller.js +8 -4
  31. package/dist/controllers/pack.controller.js.map +1 -0
  32. package/dist/{commands → controllers}/permissions.controller.d.ts +2 -2
  33. package/dist/controllers/permissions.controller.d.ts.map +1 -0
  34. package/dist/{commands → controllers}/permissions.controller.js +2 -2
  35. package/dist/controllers/permissions.controller.js.map +1 -0
  36. package/dist/{commands → controllers}/publish.controller.d.ts +3 -3
  37. package/dist/controllers/publish.controller.d.ts.map +1 -0
  38. package/dist/{commands → controllers}/publish.controller.js +2 -2
  39. package/dist/controllers/publish.controller.js.map +1 -0
  40. package/dist/{commands → controllers}/registry.controller.d.ts +2 -2
  41. package/dist/controllers/registry.controller.d.ts.map +1 -0
  42. package/dist/{commands → controllers}/registry.controller.js +2 -2
  43. package/dist/controllers/registry.controller.js.map +1 -0
  44. package/dist/{commands → controllers}/revoke.controller.d.ts +2 -2
  45. package/dist/controllers/revoke.controller.d.ts.map +1 -0
  46. package/dist/{commands → controllers}/revoke.controller.js +2 -2
  47. package/dist/controllers/revoke.controller.js.map +1 -0
  48. package/dist/{commands → controllers}/run.controller.js +8 -6
  49. package/dist/controllers/run.controller.js.map +1 -0
  50. package/dist/{commands → controllers}/uninstall.controller.d.ts +2 -2
  51. package/dist/controllers/uninstall.controller.d.ts.map +1 -0
  52. package/dist/{commands → controllers}/uninstall.controller.js +2 -2
  53. package/dist/controllers/uninstall.controller.js.map +1 -0
  54. package/dist/{commands → controllers}/update.controller.d.ts +2 -2
  55. package/dist/controllers/update.controller.d.ts.map +1 -0
  56. package/dist/{commands → controllers}/update.controller.js +2 -2
  57. package/dist/controllers/update.controller.js.map +1 -0
  58. package/dist/{commands → controllers}/validate-publish.controller.d.ts +3 -3
  59. package/dist/controllers/validate-publish.controller.d.ts.map +1 -0
  60. package/dist/{commands → controllers}/validate-publish.controller.js +9 -5
  61. package/dist/controllers/validate-publish.controller.js.map +1 -0
  62. package/dist/index.d.ts +51 -51
  63. package/dist/index.js +46 -45
  64. package/dist/package.js +1 -1
  65. package/dist/{runtime → services}/app-build.service.d.ts +2 -2
  66. package/dist/services/app-build.service.d.ts.map +1 -0
  67. package/dist/{runtime → services}/app-build.service.js +4 -2
  68. package/dist/services/app-build.service.js.map +1 -0
  69. package/dist/{bundle → services}/app-bundle.service.d.ts +18 -6
  70. package/dist/services/app-bundle.service.d.ts.map +1 -0
  71. package/dist/services/app-bundle.service.js +305 -0
  72. package/dist/services/app-bundle.service.js.map +1 -0
  73. package/dist/{permissions → services}/app-grant.service.d.ts +4 -4
  74. package/dist/services/app-grant.service.d.ts.map +1 -0
  75. package/dist/{permissions → services}/app-grant.service.js +7 -4
  76. package/dist/services/app-grant.service.js.map +1 -0
  77. package/dist/{paths → services}/app-home.service.d.ts +1 -1
  78. package/dist/services/app-home.service.d.ts.map +1 -0
  79. package/dist/{paths → services}/app-home.service.js +1 -1
  80. package/dist/services/app-home.service.js.map +1 -0
  81. package/dist/{host → services}/app-host.service.d.ts +2 -2
  82. package/dist/services/app-host.service.d.ts.map +1 -0
  83. package/dist/{host → services}/app-host.service.js +3 -3
  84. package/dist/services/app-host.service.js.map +1 -0
  85. package/dist/services/app-install-source.service.js +72 -0
  86. package/dist/services/app-install-source.service.js.map +1 -0
  87. package/dist/{install → services}/app-installation.service.d.ts +15 -14
  88. package/dist/services/app-installation.service.d.ts.map +1 -0
  89. package/dist/services/app-installation.service.js +332 -0
  90. package/dist/services/app-installation.service.js.map +1 -0
  91. package/dist/services/app-instance.service.d.ts +34 -0
  92. package/dist/services/app-instance.service.d.ts.map +1 -0
  93. package/dist/{host → services}/app-instance.service.js +4 -4
  94. package/dist/services/app-instance.service.js.map +1 -0
  95. package/dist/{manifest → services}/app-manifest.service.d.ts +12 -2
  96. package/dist/services/app-manifest.service.d.ts.map +1 -0
  97. package/dist/services/app-manifest.service.js +271 -0
  98. package/dist/services/app-manifest.service.js.map +1 -0
  99. package/dist/{publish → services}/app-marketplace-client.service.d.ts +2 -2
  100. package/dist/services/app-marketplace-client.service.d.ts.map +1 -0
  101. package/dist/{publish → services}/app-marketplace-client.service.js +2 -2
  102. package/dist/services/app-marketplace-client.service.js.map +1 -0
  103. package/dist/{publish → services}/app-marketplace-metadata.service.d.ts +3 -3
  104. package/dist/services/app-marketplace-metadata.service.d.ts.map +1 -0
  105. package/dist/{publish → services}/app-marketplace-metadata.service.js +1 -1
  106. package/dist/services/app-marketplace-metadata.service.js.map +1 -0
  107. package/dist/{permissions → services}/app-permissions.service.d.ts +3 -3
  108. package/dist/services/app-permissions.service.d.ts.map +1 -0
  109. package/dist/{permissions → services}/app-permissions.service.js +4 -1
  110. package/dist/services/app-permissions.service.js.map +1 -0
  111. package/dist/{publish → services}/app-publish-validation.service.d.ts +9 -7
  112. package/dist/services/app-publish-validation.service.d.ts.map +1 -0
  113. package/dist/{publish → services}/app-publish-validation.service.js +14 -10
  114. package/dist/services/app-publish-validation.service.js.map +1 -0
  115. package/dist/{publish → services}/app-publish.service.d.ts +5 -5
  116. package/dist/services/app-publish.service.d.ts.map +1 -0
  117. package/dist/{publish → services}/app-publish.service.js +6 -6
  118. package/dist/services/app-publish.service.js.map +1 -0
  119. package/dist/{registry → services}/app-registry-config.service.d.ts +3 -3
  120. package/dist/{registry → services}/app-registry-config.service.d.ts.map +1 -1
  121. package/dist/{registry → services}/app-registry-config.service.js +3 -3
  122. package/dist/services/app-registry-config.service.js.map +1 -0
  123. package/dist/{registry → services}/app-registry.service.d.ts +18 -5
  124. package/dist/services/app-registry.service.d.ts.map +1 -0
  125. package/dist/services/app-registry.service.js +210 -0
  126. package/dist/services/app-registry.service.js.map +1 -0
  127. package/dist/{registry → services}/app-remote-registry-client.service.d.ts +6 -2
  128. package/dist/services/app-remote-registry-client.service.d.ts.map +1 -0
  129. package/dist/{registry → services}/app-remote-registry-client.service.js +54 -8
  130. package/dist/services/app-remote-registry-client.service.js.map +1 -0
  131. package/dist/{cli → services}/app-runtime-cli.service.d.ts +1 -1
  132. package/dist/services/app-runtime-cli.service.d.ts.map +1 -0
  133. package/dist/{cli → services}/app-runtime-cli.service.js +19 -19
  134. package/dist/services/app-runtime-cli.service.js.map +1 -0
  135. package/dist/{cli → services}/app-runtime-options.service.d.ts +6 -6
  136. package/dist/services/app-runtime-options.service.d.ts.map +1 -0
  137. package/dist/{cli → services}/app-runtime-options.service.js +3 -9
  138. package/dist/services/app-runtime-options.service.js.map +1 -0
  139. package/dist/{runtime → services}/app-runtime-toolchain.service.d.ts +1 -1
  140. package/dist/services/app-runtime-toolchain.service.d.ts.map +1 -0
  141. package/dist/{runtime → services}/app-runtime-toolchain.service.js +1 -1
  142. package/dist/services/app-runtime-toolchain.service.js.map +1 -0
  143. package/dist/{scaffold → services}/app-scaffold.service.d.ts +1 -1
  144. package/dist/{scaffold → services}/app-scaffold.service.d.ts.map +1 -1
  145. package/dist/{scaffold → services}/app-scaffold.service.js +1 -1
  146. package/dist/{scaffold → services}/app-scaffold.service.js.map +1 -1
  147. package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.d.ts +1 -1
  148. package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.d.ts.map +1 -1
  149. package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.js +1 -1
  150. package/dist/{scaffold → services}/app-ts-http-lite-scaffold-template.service.js.map +1 -1
  151. package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.d.ts +1 -1
  152. package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.d.ts.map +1 -1
  153. package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.js +1 -1
  154. package/dist/{scaffold → services}/app-ts-http-scaffold-template.service.js.map +1 -1
  155. package/dist/{bridge → services}/host-bridge.service.d.ts +2 -2
  156. package/dist/services/host-bridge.service.d.ts.map +1 -0
  157. package/dist/{bridge → services}/host-bridge.service.js +1 -1
  158. package/dist/services/host-bridge.service.js.map +1 -0
  159. package/dist/services/main-runner.service.d.ts +9 -0
  160. package/dist/services/main-runner.service.d.ts.map +1 -0
  161. package/dist/services/main-runner.service.js +6 -0
  162. package/dist/services/main-runner.service.js.map +1 -0
  163. package/dist/{publish → services}/platform-auth-state.service.d.ts +1 -1
  164. package/dist/services/platform-auth-state.service.d.ts.map +1 -0
  165. package/dist/{publish → services}/platform-auth-state.service.js +1 -1
  166. package/dist/services/platform-auth-state.service.js.map +1 -0
  167. package/dist/{ui → services}/ui-server.service.d.ts +3 -3
  168. package/dist/services/ui-server.service.d.ts.map +1 -0
  169. package/dist/{ui → services}/ui-server.service.js +1 -1
  170. package/dist/services/ui-server.service.js.map +1 -0
  171. package/dist/{runtime → services}/wasm-main-runner.service.d.ts +3 -3
  172. package/dist/services/wasm-main-runner.service.d.ts.map +1 -0
  173. package/dist/{runtime → services}/wasm-main-runner.service.js +2 -2
  174. package/dist/services/wasm-main-runner.service.js.map +1 -0
  175. package/dist/{sidecar → services}/wasm-sidecar-client.service.d.ts +1 -1
  176. package/dist/services/wasm-sidecar-client.service.d.ts.map +1 -0
  177. package/dist/{sidecar → services}/wasm-sidecar-client.service.js +1 -1
  178. package/dist/services/wasm-sidecar-client.service.js.map +1 -0
  179. package/dist/{runtime → services}/wasmtime-wasi-http-component.service.d.ts +1 -1
  180. package/dist/services/wasmtime-wasi-http-component.service.d.ts.map +1 -0
  181. package/dist/{runtime → services}/wasmtime-wasi-http-component.service.js +1 -1
  182. package/dist/services/wasmtime-wasi-http-component.service.js.map +1 -0
  183. package/dist/{bundle → types}/app-bundle.types.d.ts +1 -1
  184. package/dist/types/app-bundle.types.d.ts.map +1 -0
  185. package/dist/{install → types}/app-installation.types.d.ts +27 -7
  186. package/dist/types/app-installation.types.d.ts.map +1 -0
  187. package/dist/types/app-manifest.types.d.ts +119 -0
  188. package/dist/types/app-manifest.types.d.ts.map +1 -0
  189. package/dist/types/app-manifest.types.js +11 -0
  190. package/dist/types/app-manifest.types.js.map +1 -0
  191. package/dist/{permissions → types}/app-permissions.types.d.ts +2 -2
  192. package/dist/types/app-permissions.types.d.ts.map +1 -0
  193. package/dist/{publish → types}/app-publish.types.d.ts +4 -4
  194. package/dist/types/app-publish.types.d.ts.map +1 -0
  195. package/dist/{publish → types}/app-publish.types.js +1 -1
  196. package/dist/types/app-publish.types.js.map +1 -0
  197. package/dist/{registry → types}/app-registry.types.d.ts +8 -4
  198. package/dist/types/app-registry.types.d.ts.map +1 -0
  199. package/dist/{registry → types}/app-remote-registry.types.d.ts +3 -3
  200. package/dist/types/app-remote-registry.types.d.ts.map +1 -0
  201. package/dist/{registry → types}/app-remote-registry.types.js +1 -1
  202. package/dist/types/app-remote-registry.types.js.map +1 -0
  203. package/dist/{runtime → types}/main-runner.types.d.ts +3 -3
  204. package/dist/types/main-runner.types.d.ts.map +1 -0
  205. package/package.json +10 -3
  206. package/dist/bridge/host-bridge.service.d.ts.map +0 -1
  207. package/dist/bridge/host-bridge.service.js.map +0 -1
  208. package/dist/bundle/app-bundle.service.d.ts.map +0 -1
  209. package/dist/bundle/app-bundle.service.js +0 -196
  210. package/dist/bundle/app-bundle.service.js.map +0 -1
  211. package/dist/bundle/app-bundle.types.d.ts.map +0 -1
  212. package/dist/cli/app-runtime-cli.service.d.ts.map +0 -1
  213. package/dist/cli/app-runtime-cli.service.js.map +0 -1
  214. package/dist/cli/app-runtime-options.service.d.ts.map +0 -1
  215. package/dist/cli/app-runtime-options.service.js.map +0 -1
  216. package/dist/commands/create.controller.d.ts.map +0 -1
  217. package/dist/commands/create.controller.js.map +0 -1
  218. package/dist/commands/dev.controller.js.map +0 -1
  219. package/dist/commands/grant.controller.d.ts.map +0 -1
  220. package/dist/commands/grant.controller.js.map +0 -1
  221. package/dist/commands/info.controller.d.ts.map +0 -1
  222. package/dist/commands/info.controller.js.map +0 -1
  223. package/dist/commands/inspect.controller.js.map +0 -1
  224. package/dist/commands/install.controller.d.ts.map +0 -1
  225. package/dist/commands/install.controller.js.map +0 -1
  226. package/dist/commands/list.controller.d.ts.map +0 -1
  227. package/dist/commands/list.controller.js.map +0 -1
  228. package/dist/commands/pack.controller.d.ts +0 -17
  229. package/dist/commands/pack.controller.d.ts.map +0 -1
  230. package/dist/commands/pack.controller.js.map +0 -1
  231. package/dist/commands/permissions.controller.d.ts.map +0 -1
  232. package/dist/commands/permissions.controller.js.map +0 -1
  233. package/dist/commands/publish.controller.d.ts.map +0 -1
  234. package/dist/commands/publish.controller.js.map +0 -1
  235. package/dist/commands/registry.controller.d.ts.map +0 -1
  236. package/dist/commands/registry.controller.js.map +0 -1
  237. package/dist/commands/revoke.controller.d.ts.map +0 -1
  238. package/dist/commands/revoke.controller.js.map +0 -1
  239. package/dist/commands/run.controller.js.map +0 -1
  240. package/dist/commands/uninstall.controller.d.ts.map +0 -1
  241. package/dist/commands/uninstall.controller.js.map +0 -1
  242. package/dist/commands/update.controller.d.ts.map +0 -1
  243. package/dist/commands/update.controller.js.map +0 -1
  244. package/dist/commands/validate-publish.controller.d.ts.map +0 -1
  245. package/dist/commands/validate-publish.controller.js.map +0 -1
  246. package/dist/host/app-host.service.d.ts.map +0 -1
  247. package/dist/host/app-host.service.js.map +0 -1
  248. package/dist/host/app-instance.service.d.ts +0 -34
  249. package/dist/host/app-instance.service.d.ts.map +0 -1
  250. package/dist/host/app-instance.service.js.map +0 -1
  251. package/dist/install/app-installation.service.d.ts.map +0 -1
  252. package/dist/install/app-installation.service.js +0 -276
  253. package/dist/install/app-installation.service.js.map +0 -1
  254. package/dist/install/app-installation.types.d.ts.map +0 -1
  255. package/dist/main.js.map +0 -1
  256. package/dist/manifest/app-manifest.service.d.ts.map +0 -1
  257. package/dist/manifest/app-manifest.service.js +0 -147
  258. package/dist/manifest/app-manifest.service.js.map +0 -1
  259. package/dist/manifest/app-manifest.types.d.ts +0 -68
  260. package/dist/manifest/app-manifest.types.d.ts.map +0 -1
  261. package/dist/paths/app-home.service.d.ts.map +0 -1
  262. package/dist/paths/app-home.service.js.map +0 -1
  263. package/dist/permissions/app-grant.service.d.ts.map +0 -1
  264. package/dist/permissions/app-grant.service.js.map +0 -1
  265. package/dist/permissions/app-permissions.service.d.ts.map +0 -1
  266. package/dist/permissions/app-permissions.service.js.map +0 -1
  267. package/dist/permissions/app-permissions.types.d.ts.map +0 -1
  268. package/dist/publish/app-marketplace-client.service.d.ts.map +0 -1
  269. package/dist/publish/app-marketplace-client.service.js.map +0 -1
  270. package/dist/publish/app-marketplace-metadata.service.d.ts.map +0 -1
  271. package/dist/publish/app-marketplace-metadata.service.js.map +0 -1
  272. package/dist/publish/app-publish-validation.service.d.ts.map +0 -1
  273. package/dist/publish/app-publish-validation.service.js.map +0 -1
  274. package/dist/publish/app-publish.service.d.ts.map +0 -1
  275. package/dist/publish/app-publish.service.js.map +0 -1
  276. package/dist/publish/app-publish.types.d.ts.map +0 -1
  277. package/dist/publish/app-publish.types.js.map +0 -1
  278. package/dist/publish/platform-auth-state.service.d.ts.map +0 -1
  279. package/dist/publish/platform-auth-state.service.js.map +0 -1
  280. package/dist/registry/app-registry-config.service.js.map +0 -1
  281. package/dist/registry/app-registry.service.d.ts.map +0 -1
  282. package/dist/registry/app-registry.service.js +0 -118
  283. package/dist/registry/app-registry.service.js.map +0 -1
  284. package/dist/registry/app-registry.types.d.ts.map +0 -1
  285. package/dist/registry/app-remote-registry-client.service.d.ts.map +0 -1
  286. package/dist/registry/app-remote-registry-client.service.js.map +0 -1
  287. package/dist/registry/app-remote-registry.types.d.ts.map +0 -1
  288. package/dist/registry/app-remote-registry.types.js.map +0 -1
  289. package/dist/runtime/app-build.service.d.ts.map +0 -1
  290. package/dist/runtime/app-build.service.js.map +0 -1
  291. package/dist/runtime/app-runtime-toolchain.service.d.ts.map +0 -1
  292. package/dist/runtime/app-runtime-toolchain.service.js.map +0 -1
  293. package/dist/runtime/main-runner.service.d.ts +0 -9
  294. package/dist/runtime/main-runner.service.d.ts.map +0 -1
  295. package/dist/runtime/main-runner.service.js +0 -6
  296. package/dist/runtime/main-runner.service.js.map +0 -1
  297. package/dist/runtime/main-runner.types.d.ts.map +0 -1
  298. package/dist/runtime/wasm-main-runner.service.d.ts.map +0 -1
  299. package/dist/runtime/wasm-main-runner.service.js.map +0 -1
  300. package/dist/runtime/wasmtime-wasi-http-component.service.d.ts.map +0 -1
  301. package/dist/runtime/wasmtime-wasi-http-component.service.js.map +0 -1
  302. package/dist/sidecar/wasm-sidecar-client.service.d.ts.map +0 -1
  303. package/dist/sidecar/wasm-sidecar-client.service.js.map +0 -1
  304. package/dist/ui/ui-server.service.d.ts.map +0 -1
  305. package/dist/ui/ui-server.service.js.map +0 -1
  306. /package/dist/{main.d.ts → app/main.d.ts} +0 -0
@@ -1,14 +1,14 @@
1
- import { AppManifestService } from "../manifest/app-manifest.service.js";
2
- import { AppBundleService } from "../bundle/app-bundle.service.js";
3
- import { AppDocumentGrantMap } from "../permissions/app-permissions.types.js";
4
- import { AppHomeService } from "../paths/app-home.service.js";
5
- import { AppRegistryService } from "../registry/app-registry.service.js";
6
- import { AppBuildService } from "../runtime/app-build.service.js";
7
- import { AppRegistryConfigService } from "../registry/app-registry-config.service.js";
8
- import { AppRemoteRegistryClientService } from "../registry/app-remote-registry-client.service.js";
9
- import { AppInfoResult, AppInstallResult, AppLaunchResolution, AppUninstallResult, AppUpdateResult, InstalledAppListItem } from "./app-installation.types.js";
1
+ import { AppManifestService } from "./app-manifest.service.js";
2
+ import { AppBundleService } from "./app-bundle.service.js";
3
+ import { AppDocumentGrantMap } from "../types/app-permissions.types.js";
4
+ import { AppHomeService } from "./app-home.service.js";
5
+ import { AppRegistryService } from "./app-registry.service.js";
6
+ import { AppBuildService } from "./app-build.service.js";
7
+ import { AppRegistryConfigService } from "./app-registry-config.service.js";
8
+ import { AppRemoteRegistryClientService } from "./app-remote-registry-client.service.js";
9
+ import { AppActivationResult, AppInfoResult, AppInstallResult, AppLaunchResolution, AppRollbackResult, AppUninstallResult, AppUpdateResult, InstalledAppListItem } from "../types/app-installation.types.js";
10
10
 
11
- //#region src/install/app-installation.service.d.ts
11
+ //#region src/services/app-installation.service.d.ts
12
12
  declare class AppInstallationService {
13
13
  private readonly appHomeService;
14
14
  private readonly bundleService;
@@ -17,6 +17,7 @@ declare class AppInstallationService {
17
17
  private readonly registryService;
18
18
  private readonly registryConfigService;
19
19
  private readonly remoteRegistryClient;
20
+ private readonly installSourceService;
20
21
  constructor(appHomeService?: AppHomeService, bundleService?: AppBundleService, manifestService?: AppManifestService, buildService?: AppBuildService, registryService?: AppRegistryService, registryConfigService?: AppRegistryConfigService, remoteRegistryClient?: AppRemoteRegistryClientService);
21
22
  install: (appSource: string, options?: {
22
23
  registryUrl?: string;
@@ -28,13 +29,13 @@ declare class AppInstallationService {
28
29
  uninstall: (appId: string, purgeData: boolean) => Promise<AppUninstallResult>;
29
30
  list: () => Promise<InstalledAppListItem[]>;
30
31
  info: (appId: string) => Promise<AppInfoResult>;
32
+ setEnabled: (appId: string, enabled: boolean) => Promise<AppActivationResult>;
33
+ rollback: (appId: string, version: string) => Promise<AppRollbackResult>;
31
34
  resolveLaunch: (appReference: string, explicitDocumentGrantMap: AppDocumentGrantMap) => Promise<AppLaunchResolution>;
32
35
  persistGrants: (appId: string | undefined, documentGrantMap: AppDocumentGrantMap) => Promise<void>;
33
- private resolveInstallSource;
34
- private detectLocalSourceType;
35
- private parseRegistrySpec;
36
- private looksLikePath;
36
+ private copyToImmutableInstallDirectory;
37
37
  private materializeDistribution;
38
+ private pathExists;
38
39
  }
39
40
  //#endregion
40
41
  export { AppInstallationService };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-installation.service.d.ts","names":[],"sources":["../../src/services/app-installation.service.ts"],"mappings":";;;;;;;;;;;cA4Ba,sBAAA;EAAA,iBAIQ,cAAA;EAAA,iBACA,aAAA;EAAA,iBACA,eAAA;EAAA,iBACA,YAAA;EAAA,iBACA,eAAA;EAAA,iBACA,qBAAA;EAAA,iBAGA,oBAAA;EAAA,iBAXF,oBAAA;cAGE,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;EAUzC,OAAA,GACE,SAAA,UACA,OAAA;IACE,WAAA;EAAA,MAED,OAAA,CAAQ,gBAAA;EA4HX,MAAA,GACE,KAAA,UACA,OAAA;IACE,OAAA;IACA,WAAA;EAAA,MAED,OAAA,CAAQ,eAAA;EAkDX,SAAA,GACE,KAAA,UACA,SAAA,cACC,OAAA,CAAQ,kBAAA;EAwDX,IAAA,QAAiB,OAAA,CAAQ,oBAAA;EAkBzB,IAAA,GAAc,KAAA,aAAgB,OAAA,CAAQ,aAAA;EAmCtC,UAAA,GAAoB,KAAA,UAAe,OAAA,cAAmB,OAAA,CAAQ,mBAAA;EAS9D,QAAA,GAAkB,KAAA,UAAe,OAAA,aAAkB,OAAA,CAAQ,iBAAA;EAgC3D,aAAA,GACE,YAAA,UACA,wBAAA,EAA0B,mBAAA,KACzB,OAAA,CAAQ,mBAAA;EA2BX,aAAA,GACE,KAAA,sBACA,gBAAA,EAAkB,mBAAA,KACjB,OAAA;EAAA,QAOK,+BAAA;EAAA,QA4BA,uBAAA;EAAA,QAoBA,UAAA;AAAA"}
@@ -0,0 +1,332 @@
1
+ import { AppManifestService } from "./app-manifest.service.js";
2
+ import { isAppComponentManifestBundle, isAppStandaloneManifestBundle } from "../types/app-manifest.types.js";
3
+ import { AppBundleService } from "./app-bundle.service.js";
4
+ import { AppHomeService } from "./app-home.service.js";
5
+ import { AppBuildService } from "./app-build.service.js";
6
+ import { AppRegistryConfigService } from "./app-registry-config.service.js";
7
+ import { AppRemoteRegistryClientService } from "./app-remote-registry-client.service.js";
8
+ import { AppRegistryService } from "./app-registry.service.js";
9
+ import { AppInstallSourceService } from "./app-install-source.service.js";
10
+ import { randomUUID } from "node:crypto";
11
+ import { access, cp, mkdir, rename, rm } from "node:fs/promises";
12
+ import path from "node:path";
13
+ //#region src/services/app-installation.service.ts
14
+ var AppInstallationService = class {
15
+ installSourceService;
16
+ 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))) {
17
+ this.appHomeService = appHomeService;
18
+ this.bundleService = bundleService;
19
+ this.manifestService = manifestService;
20
+ this.buildService = buildService;
21
+ this.registryService = registryService;
22
+ this.registryConfigService = registryConfigService;
23
+ this.remoteRegistryClient = remoteRegistryClient;
24
+ this.installSourceService = new AppInstallSourceService(this.manifestService, this.remoteRegistryClient);
25
+ }
26
+ install = async (appSource, options) => {
27
+ const source = await this.installSourceService.resolve(appSource, options?.registryUrl);
28
+ const tempDirectory = await this.appHomeService.createTemporaryDirectory("napp-install-");
29
+ try {
30
+ const bundlePath = source.kind === "directory" ? (await this.bundleService.packAppDirectory({
31
+ appDirectory: source.appDirectory,
32
+ outputPath: path.join(tempDirectory, "app.napp")
33
+ })).bundlePath : source.kind === "bundle" ? source.bundlePath : (await this.remoteRegistryClient.downloadBundle({
34
+ resolution: source.registryResolution,
35
+ targetDirectory: tempDirectory
36
+ })).bundlePath;
37
+ const extractedDirectory = path.join(tempDirectory, "bundle");
38
+ const extractedMetadata = await this.bundleService.extractBundle({
39
+ bundlePath,
40
+ targetDirectory: extractedDirectory
41
+ });
42
+ await this.materializeDistribution({
43
+ appDirectory: extractedDirectory,
44
+ distributionMode: extractedMetadata.metadata.distributionMode
45
+ });
46
+ const manifestBundle = await this.manifestService.load(extractedDirectory);
47
+ const installDirectory = this.appHomeService.getInstallDirectory(manifestBundle.manifest.id, manifestBundle.manifest.version);
48
+ if (source.kind === "registry" && manifestBundle.manifest.id !== source.registryResolution.appId) throw new Error(`bundle manifest.appId 与 registry 请求不一致:期望 ${source.registryResolution.appId},实际 ${manifestBundle.manifest.id}`);
49
+ const dataDirectory = this.appHomeService.getAppDataDirectory(manifestBundle.manifest.id);
50
+ await this.copyToImmutableInstallDirectory({
51
+ appId: manifestBundle.manifest.id,
52
+ appVersion: manifestBundle.manifest.version,
53
+ extractedDirectory,
54
+ installDirectory
55
+ });
56
+ await mkdir(dataDirectory, { recursive: true });
57
+ let registryRecord;
58
+ try {
59
+ registryRecord = await this.registryService.upsertInstallation({
60
+ appId: manifestBundle.manifest.id,
61
+ name: manifestBundle.manifest.name,
62
+ description: manifestBundle.manifest.description,
63
+ version: manifestBundle.manifest.version,
64
+ installDirectory,
65
+ dataDirectory,
66
+ sourceKind: source.kind,
67
+ distributionMode: source.kind === "registry" ? source.registryResolution.distributionMode : extractedMetadata.metadata.distributionMode,
68
+ sourceRef: source.sourceRef,
69
+ installedAt: (/* @__PURE__ */ new Date()).toISOString(),
70
+ permissions: manifestBundle.manifest.schemaVersion === 1 ? manifestBundle.manifest.permissions ?? {} : {},
71
+ registryUrl: source.kind === "registry" ? source.registryResolution.registryUrl : void 0,
72
+ bundleUrl: source.kind === "registry" ? source.registryResolution.bundleUrl : void 0,
73
+ sha256: source.kind === "registry" ? source.registryResolution.sha256 : void 0,
74
+ publisher: source.kind === "registry" ? source.registryResolution.publisher : void 0,
75
+ manifestSchemaVersion: manifestBundle.manifest.schemaVersion,
76
+ components: isAppComponentManifestBundle(manifestBundle) ? manifestBundle.components.map((component) => ({
77
+ ...component,
78
+ componentDirectory: path.join(installDirectory, component.path),
79
+ manifestPath: path.join(installDirectory, component.path, component.kind === "panel" ? "panel-app.json" : "service-app.json")
80
+ })) : void 0,
81
+ primaryPanelId: isAppComponentManifestBundle(manifestBundle) ? manifestBundle.primaryPanelId : void 0
82
+ });
83
+ } catch (error) {
84
+ await rm(installDirectory, {
85
+ recursive: true,
86
+ force: true
87
+ });
88
+ throw error;
89
+ }
90
+ const activeVersionRecord = registryRecord.installedVersions[registryRecord.activeVersion];
91
+ return {
92
+ appId: registryRecord.appId,
93
+ name: registryRecord.name,
94
+ version: registryRecord.activeVersion,
95
+ installDirectory,
96
+ dataDirectory,
97
+ sourceKind: source.kind,
98
+ sourceRef: source.sourceRef,
99
+ distributionMode: registryRecord.installedVersions[registryRecord.activeVersion]?.distributionMode,
100
+ permissions: registryRecord.installedVersions[registryRecord.activeVersion]?.permissions ?? {},
101
+ registryUrl: registryRecord.installedVersions[registryRecord.activeVersion]?.registryUrl,
102
+ bundleUrl: registryRecord.installedVersions[registryRecord.activeVersion]?.bundleUrl,
103
+ sha256: registryRecord.installedVersions[registryRecord.activeVersion]?.sha256,
104
+ publisher: registryRecord.installedVersions[registryRecord.activeVersion]?.publisher,
105
+ enabled: registryRecord.enabled,
106
+ manifestSchemaVersion: activeVersionRecord?.manifestSchemaVersion ?? 1,
107
+ components: activeVersionRecord?.components,
108
+ primaryPanelId: activeVersionRecord?.primaryPanelId
109
+ };
110
+ } finally {
111
+ await rm(tempDirectory, {
112
+ recursive: true,
113
+ force: true
114
+ });
115
+ }
116
+ };
117
+ update = async (appId, options) => {
118
+ const appRecord = await this.registryService.getApp(appId);
119
+ if (!appRecord) throw new Error(`未找到已安装应用:${appId}`);
120
+ const activeVersionRecord = appRecord.installedVersions[appRecord.activeVersion];
121
+ const registryUrl = options?.registryUrl ?? activeVersionRecord?.registryUrl ?? (await this.registryConfigService.getSnapshot()).currentUrl;
122
+ const resolution = await this.remoteRegistryClient.resolve({
123
+ appId,
124
+ version: options?.version,
125
+ registryUrl
126
+ });
127
+ if (resolution.version === appRecord.activeVersion) {
128
+ if (!activeVersionRecord) throw new Error(`已安装应用缺少激活版本:${appId}`);
129
+ return {
130
+ appId: appRecord.appId,
131
+ name: appRecord.name,
132
+ version: appRecord.activeVersion,
133
+ previousVersion: appRecord.activeVersion,
134
+ installDirectory: activeVersionRecord.installDirectory,
135
+ dataDirectory: appRecord.dataDirectory,
136
+ sourceKind: activeVersionRecord.sourceKind,
137
+ sourceRef: activeVersionRecord.sourceRef,
138
+ permissions: activeVersionRecord.permissions,
139
+ registryUrl: activeVersionRecord.registryUrl,
140
+ bundleUrl: activeVersionRecord.bundleUrl,
141
+ sha256: activeVersionRecord.sha256,
142
+ publisher: activeVersionRecord.publisher,
143
+ enabled: appRecord.enabled,
144
+ manifestSchemaVersion: activeVersionRecord.manifestSchemaVersion,
145
+ components: activeVersionRecord.components,
146
+ primaryPanelId: activeVersionRecord.primaryPanelId,
147
+ updated: false
148
+ };
149
+ }
150
+ return {
151
+ ...await this.install(`${appId}@${resolution.version}`, { registryUrl }),
152
+ previousVersion: appRecord.activeVersion,
153
+ updated: true
154
+ };
155
+ };
156
+ uninstall = async (appId, purgeData) => {
157
+ const appRecord = await this.registryService.getApp(appId);
158
+ if (!appRecord) throw new Error(`未找到已安装应用:${appId}`);
159
+ const removedVersions = Object.keys(appRecord.installedVersions).sort((left, right) => left.localeCompare(right));
160
+ const stagedPaths = [];
161
+ const stagePath = async (originalPath) => {
162
+ if (!await this.pathExists(originalPath)) return;
163
+ const stagedPath = `${originalPath}.uninstalling-${randomUUID()}`;
164
+ await rename(originalPath, stagedPath);
165
+ stagedPaths.push({
166
+ originalPath,
167
+ stagedPath
168
+ });
169
+ };
170
+ const restoreStagedPaths = async () => {
171
+ for (const entry of [...stagedPaths].reverse()) if (await this.pathExists(entry.stagedPath)) await rename(entry.stagedPath, entry.originalPath);
172
+ };
173
+ try {
174
+ for (const versionRecord of Object.values(appRecord.installedVersions)) await stagePath(versionRecord.installDirectory);
175
+ if (purgeData) await stagePath(appRecord.dataDirectory);
176
+ if (!await this.registryService.removeApp(appId)) throw new Error(`卸载过程中应用记录已发生变化:${appId}`);
177
+ } catch (error) {
178
+ try {
179
+ await restoreStagedPaths();
180
+ } catch (restoreError) {
181
+ throw new AggregateError([error, restoreError], `卸载 ${appId} 失败,且无法完全恢复已暂存文件。`);
182
+ }
183
+ throw error;
184
+ }
185
+ await Promise.all(stagedPaths.map((entry) => rm(entry.stagedPath, {
186
+ recursive: true,
187
+ force: true
188
+ })));
189
+ return {
190
+ appId,
191
+ removedVersions,
192
+ dataRemoved: purgeData
193
+ };
194
+ };
195
+ list = async () => {
196
+ return (await this.registryService.listApps()).map((appRecord) => ({
197
+ appId: appRecord.appId,
198
+ name: appRecord.name,
199
+ activeVersion: appRecord.activeVersion,
200
+ sourceKind: appRecord.installedVersions[appRecord.activeVersion]?.sourceKind ?? "directory",
201
+ distributionMode: appRecord.installedVersions[appRecord.activeVersion]?.distributionMode,
202
+ enabled: appRecord.enabled,
203
+ manifestSchemaVersion: appRecord.installedVersions[appRecord.activeVersion]?.manifestSchemaVersion ?? 1,
204
+ primaryPanelId: appRecord.installedVersions[appRecord.activeVersion]?.primaryPanelId
205
+ }));
206
+ };
207
+ info = async (appId) => {
208
+ const appRecord = await this.registryService.getApp(appId);
209
+ if (!appRecord) throw new Error(`未找到已安装应用:${appId}`);
210
+ const installedVersions = Object.values(appRecord.installedVersions).sort((left, right) => left.version.localeCompare(right.version));
211
+ return {
212
+ appId: appRecord.appId,
213
+ name: appRecord.name,
214
+ description: appRecord.description,
215
+ activeVersion: appRecord.activeVersion,
216
+ enabled: appRecord.enabled,
217
+ dataDirectory: appRecord.dataDirectory,
218
+ installedVersions: installedVersions.map((versionRecord) => ({
219
+ version: versionRecord.version,
220
+ installDirectory: versionRecord.installDirectory,
221
+ sourceKind: versionRecord.sourceKind,
222
+ distributionMode: versionRecord.distributionMode,
223
+ sourceRef: versionRecord.sourceRef,
224
+ installedAt: versionRecord.installedAt,
225
+ permissions: versionRecord.permissions,
226
+ registryUrl: versionRecord.registryUrl,
227
+ bundleUrl: versionRecord.bundleUrl,
228
+ sha256: versionRecord.sha256,
229
+ publisher: versionRecord.publisher,
230
+ manifestSchemaVersion: versionRecord.manifestSchemaVersion,
231
+ components: versionRecord.components,
232
+ primaryPanelId: versionRecord.primaryPanelId
233
+ })),
234
+ grants: appRecord.grants
235
+ };
236
+ };
237
+ setEnabled = async (appId, enabled) => {
238
+ const appRecord = await this.registryService.setEnabled(appId, enabled);
239
+ return {
240
+ appId: appRecord.appId,
241
+ activeVersion: appRecord.activeVersion,
242
+ enabled: appRecord.enabled
243
+ };
244
+ };
245
+ rollback = async (appId, version) => {
246
+ const currentRecord = await this.registryService.getApp(appId);
247
+ if (!currentRecord) throw new Error(`未找到已安装应用:${appId}`);
248
+ if (currentRecord.activeVersion === version) return {
249
+ appId,
250
+ activeVersion: version,
251
+ previousVersion: version,
252
+ enabled: currentRecord.enabled,
253
+ rolledBack: false
254
+ };
255
+ const targetVersion = currentRecord.installedVersions[version];
256
+ if (!targetVersion) throw new Error(`应用 ${appId} 未安装版本 ${version}。`);
257
+ const targetManifest = await this.manifestService.load(targetVersion.installDirectory);
258
+ if (targetManifest.manifest.id !== appId || targetManifest.manifest.version !== version) throw new Error(`回滚目标 ${appId}@${version} 校验失败。`);
259
+ const appRecord = await this.registryService.activateVersion(appId, version);
260
+ return {
261
+ appId,
262
+ activeVersion: appRecord.activeVersion,
263
+ previousVersion: currentRecord.activeVersion,
264
+ enabled: appRecord.enabled,
265
+ rolledBack: true
266
+ };
267
+ };
268
+ resolveLaunch = async (appReference, explicitDocumentGrantMap) => {
269
+ const sourceType = await this.installSourceService.detectLocal(appReference, false);
270
+ if (sourceType.kind === "directory") return {
271
+ appDirectory: sourceType.appDirectory,
272
+ documentGrantMap: explicitDocumentGrantMap
273
+ };
274
+ const appRecord = await this.registryService.getApp(appReference);
275
+ if (!appRecord) throw new Error(`未找到应用目录,也未找到已安装应用:${appReference}`);
276
+ const activeVersion = appRecord.installedVersions[appRecord.activeVersion];
277
+ if (!activeVersion) throw new Error(`已安装应用缺少激活版本:${appReference}`);
278
+ return {
279
+ appDirectory: activeVersion.installDirectory,
280
+ appId: appRecord.appId,
281
+ dataDirectory: appRecord.dataDirectory,
282
+ documentGrantMap: {
283
+ ...appRecord.grants,
284
+ ...explicitDocumentGrantMap
285
+ }
286
+ };
287
+ };
288
+ persistGrants = async (appId, documentGrantMap) => {
289
+ if (!appId || Object.keys(documentGrantMap).length === 0) return;
290
+ await this.registryService.updateGrants(appId, documentGrantMap);
291
+ };
292
+ copyToImmutableInstallDirectory = async (params) => {
293
+ const { appId, appVersion, extractedDirectory, installDirectory } = params;
294
+ if (await this.pathExists(installDirectory)) throw new Error(`应用版本目录已存在,不能覆盖不可变版本:${appId}@${appVersion}`);
295
+ await mkdir(path.dirname(installDirectory), { recursive: true });
296
+ const stagedInstallDirectory = `${installDirectory}.staging-${randomUUID()}`;
297
+ try {
298
+ await cp(extractedDirectory, stagedInstallDirectory, { recursive: true });
299
+ const stagedManifest = await this.manifestService.load(stagedInstallDirectory);
300
+ if (stagedManifest.manifest.id !== appId || stagedManifest.manifest.version !== appVersion) throw new Error("staging manifest 与已验证 bundle 身份不一致。");
301
+ await rename(stagedInstallDirectory, installDirectory);
302
+ } catch (error) {
303
+ await rm(stagedInstallDirectory, {
304
+ recursive: true,
305
+ force: true
306
+ });
307
+ throw error;
308
+ }
309
+ };
310
+ materializeDistribution = async (params) => {
311
+ if (params.distributionMode !== "source") return;
312
+ const manifestBundle = await this.manifestService.load(params.appDirectory);
313
+ if (!isAppStandaloneManifestBundle(manifestBundle)) throw new Error("schema v2 组合包不允许运行安装期 build。");
314
+ if (manifestBundle.manifest.main.kind !== "wasi-http-component") return;
315
+ await this.buildService.build({
316
+ appDirectory: params.appDirectory,
317
+ install: true
318
+ });
319
+ };
320
+ pathExists = async (targetPath) => {
321
+ try {
322
+ await access(targetPath);
323
+ return true;
324
+ } catch {
325
+ return false;
326
+ }
327
+ };
328
+ };
329
+ //#endregion
330
+ export { AppInstallationService };
331
+
332
+ //# sourceMappingURL=app-installation.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-installation.service.js","names":[],"sources":["../../src/services/app-installation.service.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { access, cp, mkdir, rename, rm } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { AppBundleService } from \"#app-runtime/services/app-bundle.service.js\";\nimport { AppManifestService } from \"#app-runtime/services/app-manifest.service.js\";\nimport {\n isAppComponentManifestBundle,\n isAppStandaloneManifestBundle,\n} from \"#app-runtime/types/app-manifest.types.js\";\nimport { AppHomeService } from \"#app-runtime/services/app-home.service.js\";\nimport { AppBuildService } from \"#app-runtime/services/app-build.service.js\";\nimport type { AppDistributionMode } from \"#app-runtime/types/app-bundle.types.js\";\nimport type { AppDocumentGrantMap } from \"#app-runtime/types/app-permissions.types.js\";\nimport { AppRegistryConfigService } from \"#app-runtime/services/app-registry-config.service.js\";\nimport { AppRemoteRegistryClientService } from \"#app-runtime/services/app-remote-registry-client.service.js\";\nimport { AppRegistryService } from \"#app-runtime/services/app-registry.service.js\";\nimport { AppInstallSourceService } from \"#app-runtime/services/app-install-source.service.js\";\nimport type {\n AppInfoResult,\n AppActivationResult,\n AppInstallResult,\n AppLaunchResolution,\n AppUpdateResult,\n AppRollbackResult,\n AppUninstallResult,\n InstalledAppListItem,\n} from \"#app-runtime/types/app-installation.types.js\";\n\nexport class AppInstallationService {\n private readonly installSourceService: AppInstallSourceService;\n\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 this.installSourceService = new AppInstallSourceService(\n this.manifestService,\n this.remoteRegistryClient,\n );\n }\n\n install = async (\n appSource: string,\n options?: {\n registryUrl?: string;\n },\n ): Promise<AppInstallResult> => {\n const source = await this.installSourceService.resolve(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 this.copyToImmutableInstallDirectory({\n appId: manifestBundle.manifest.id,\n appVersion: manifestBundle.manifest.version,\n extractedDirectory,\n installDirectory,\n });\n await mkdir(dataDirectory, { recursive: true });\n let registryRecord;\n try {\n 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.schemaVersion === 1\n ? manifestBundle.manifest.permissions ?? {}\n : {},\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 manifestSchemaVersion: manifestBundle.manifest.schemaVersion,\n components: isAppComponentManifestBundle(manifestBundle)\n ? manifestBundle.components.map((component) => ({\n ...component,\n componentDirectory: path.join(installDirectory, component.path),\n manifestPath: path.join(\n installDirectory,\n component.path,\n component.kind === \"panel\" ? \"panel-app.json\" : \"service-app.json\",\n ),\n }))\n : undefined,\n primaryPanelId: isAppComponentManifestBundle(manifestBundle)\n ? manifestBundle.primaryPanelId\n : undefined,\n });\n } catch (error) {\n await rm(installDirectory, { recursive: true, force: true });\n throw error;\n }\n const activeVersionRecord = registryRecord.installedVersions[registryRecord.activeVersion];\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 enabled: registryRecord.enabled,\n manifestSchemaVersion: activeVersionRecord?.manifestSchemaVersion ?? 1,\n components: activeVersionRecord?.components,\n primaryPanelId: activeVersionRecord?.primaryPanelId,\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 enabled: appRecord.enabled,\n manifestSchemaVersion: activeVersionRecord.manifestSchemaVersion,\n components: activeVersionRecord.components,\n primaryPanelId: activeVersionRecord.primaryPanelId,\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.getApp(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 const stagedPaths: Array<{ originalPath: string; stagedPath: string }> = [];\n const stagePath = async (originalPath: string): Promise<void> => {\n if (!await this.pathExists(originalPath)) {\n return;\n }\n const stagedPath = `${originalPath}.uninstalling-${randomUUID()}`;\n await rename(originalPath, stagedPath);\n stagedPaths.push({ originalPath, stagedPath });\n };\n const restoreStagedPaths = async (): Promise<void> => {\n for (const entry of [...stagedPaths].reverse()) {\n if (await this.pathExists(entry.stagedPath)) {\n await rename(entry.stagedPath, entry.originalPath);\n }\n }\n };\n try {\n for (const versionRecord of Object.values(appRecord.installedVersions)) {\n await stagePath(versionRecord.installDirectory);\n }\n if (purgeData) {\n await stagePath(appRecord.dataDirectory);\n }\n const removedRecord = await this.registryService.removeApp(appId);\n if (!removedRecord) {\n throw new Error(`卸载过程中应用记录已发生变化:${appId}`);\n }\n } catch (error) {\n try {\n await restoreStagedPaths();\n } catch (restoreError) {\n throw new AggregateError(\n [error, restoreError],\n `卸载 ${appId} 失败,且无法完全恢复已暂存文件。`,\n );\n }\n throw error;\n }\n await Promise.all(stagedPaths.map((entry) =>\n rm(entry.stagedPath, { 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 enabled: appRecord.enabled,\n manifestSchemaVersion:\n appRecord.installedVersions[appRecord.activeVersion]?.manifestSchemaVersion ?? 1,\n primaryPanelId:\n appRecord.installedVersions[appRecord.activeVersion]?.primaryPanelId,\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 enabled: appRecord.enabled,\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 manifestSchemaVersion: versionRecord.manifestSchemaVersion,\n components: versionRecord.components,\n primaryPanelId: versionRecord.primaryPanelId,\n })),\n grants: appRecord.grants,\n };\n };\n\n setEnabled = async (appId: string, enabled: boolean): Promise<AppActivationResult> => {\n const appRecord = await this.registryService.setEnabled(appId, enabled);\n return {\n appId: appRecord.appId,\n activeVersion: appRecord.activeVersion,\n enabled: appRecord.enabled,\n };\n };\n\n rollback = async (appId: string, version: string): Promise<AppRollbackResult> => {\n const currentRecord = await this.registryService.getApp(appId);\n if (!currentRecord) {\n throw new Error(`未找到已安装应用:${appId}`);\n }\n if (currentRecord.activeVersion === version) {\n return {\n appId,\n activeVersion: version,\n previousVersion: version,\n enabled: currentRecord.enabled,\n rolledBack: false,\n };\n }\n const targetVersion = currentRecord.installedVersions[version];\n if (!targetVersion) {\n throw new Error(`应用 ${appId} 未安装版本 ${version}。`);\n }\n const targetManifest = await this.manifestService.load(targetVersion.installDirectory);\n if (targetManifest.manifest.id !== appId || targetManifest.manifest.version !== version) {\n throw new Error(`回滚目标 ${appId}@${version} 校验失败。`);\n }\n const appRecord = await this.registryService.activateVersion(appId, version);\n return {\n appId,\n activeVersion: appRecord.activeVersion,\n previousVersion: currentRecord.activeVersion,\n enabled: appRecord.enabled,\n rolledBack: true,\n };\n };\n\n resolveLaunch = async (\n appReference: string,\n explicitDocumentGrantMap: AppDocumentGrantMap,\n ): Promise<AppLaunchResolution> => {\n const sourceType = await this.installSourceService.detectLocal(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 copyToImmutableInstallDirectory = async (params: {\n appId: string;\n appVersion: string;\n extractedDirectory: string;\n installDirectory: string;\n }): Promise<void> => {\n const { appId, appVersion, extractedDirectory, installDirectory } = params;\n if (await this.pathExists(installDirectory)) {\n throw new Error(`应用版本目录已存在,不能覆盖不可变版本:${appId}@${appVersion}`);\n }\n await mkdir(path.dirname(installDirectory), { recursive: true });\n const stagedInstallDirectory = `${installDirectory}.staging-${randomUUID()}`;\n try {\n await cp(extractedDirectory, stagedInstallDirectory, { recursive: true });\n const stagedManifest = await this.manifestService.load(stagedInstallDirectory);\n if (\n stagedManifest.manifest.id !== appId ||\n stagedManifest.manifest.version !== appVersion\n ) {\n throw new Error(\"staging manifest 与已验证 bundle 身份不一致。\");\n }\n await rename(stagedInstallDirectory, installDirectory);\n } catch (error) {\n await rm(stagedInstallDirectory, { recursive: true, force: true });\n throw error;\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 (!isAppStandaloneManifestBundle(manifestBundle)) {\n throw new Error(\"schema v2 组合包不允许运行安装期 build。\");\n }\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 private pathExists = async (targetPath: string): Promise<boolean> => {\n try {\n await access(targetPath);\n return true;\n } catch {\n return false;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,IAAa,yBAAb,MAAoC;CAClC;CAEA,YACE,iBAAkD,IAAI,gBAAgB,EACtE,gBAAmD,IAAI,kBAAkB,EACzE,kBAAuD,IAA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AAO"}
@@ -0,0 +1,34 @@
1
+ import { AppManifestSummary, AppStandaloneManifestBundle } from "../types/app-manifest.types.js";
2
+ import { AppManifestService } from "./app-manifest.service.js";
3
+ import { AppDocumentGrantMap, AppPermissionSummary } from "../types/app-permissions.types.js";
4
+ import { AppPermissionsService } from "./app-permissions.service.js";
5
+ import { MainRunResult, WasmDocumentSummaryInput } from "../types/main-runner.types.js";
6
+ import { WasmMainRunnerService } from "./wasm-main-runner.service.js";
7
+
8
+ //#region src/services/app-instance.service.d.ts
9
+ type AppRunResult = {
10
+ action: string;
11
+ input: WasmDocumentSummaryInput;
12
+ output: MainRunResult;
13
+ observedAt: string;
14
+ };
15
+ declare class AppInstanceService {
16
+ readonly bundle: AppStandaloneManifestBundle;
17
+ private readonly permissionsService;
18
+ private readonly mainRunner;
19
+ private readonly manifestService;
20
+ private permissions?;
21
+ constructor(bundle: AppStandaloneManifestBundle, permissionsService?: AppPermissionsService, mainRunner?: WasmMainRunnerService, manifestService?: AppManifestService);
22
+ initialize: (documentGrantMap: AppDocumentGrantMap, context?: {
23
+ appId?: string;
24
+ }) => Promise<void>;
25
+ summarizeManifest: () => AppManifestSummary;
26
+ summarizePermissions: () => AppPermissionSummary;
27
+ runAction: (action?: string) => Promise<AppRunResult>;
28
+ private collectDocumentSummaryInput;
29
+ private collectDirectorySummary;
30
+ private getPermissions;
31
+ }
32
+ //#endregion
33
+ export { AppInstanceService, AppRunResult };
34
+ //# sourceMappingURL=app-instance.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-instance.service.d.ts","names":[],"sources":["../../src/services/app-instance.service.ts"],"mappings":";;;;;;;;KAaY,YAAA;EACV,MAAA;EACA,KAAA,EAAO,wBAAA;EACP,MAAA,EAAQ,aAAA;EACR,UAAA;AAAA;AAAA,cAGW,kBAAA;EAAA,SAIA,MAAA,EAAQ,2BAAA;EAAA,iBACA,kBAAA;EAAA,iBACA,UAAA;EAAA,iBACA,eAAA;EAAA,QANX,WAAA;cAGG,MAAA,EAAQ,2BAAA,EACA,kBAAA,GAAoB,qBAAA,EACpB,UAAA,GAAY,qBAAA,EACZ,eAAA,GAAiB,kBAAA;EAGpC,UAAA,GACE,gBAAA,EAAkB,mBAAA,EAClB,OAAA;IACE,KAAA;EAAA,MAED,OAAA;EAQH,iBAAA,QARU,kBAAA;EAYV,oBAAA,QAA2B,oBAAA;EAI3B,SAAA,GAAmB,MAAA,cAAkB,OAAA,CAAQ,YAAA;EAAA,QAuBrC,2BAAA;EAAA,QAiBA,uBAAA;EAAA,QA6BA,cAAA;AAAA"}
@@ -1,9 +1,9 @@
1
- import { AppManifestService } from "../manifest/app-manifest.service.js";
2
- import { AppPermissionsService } from "../permissions/app-permissions.service.js";
3
- import { WasmMainRunnerService } from "../runtime/wasm-main-runner.service.js";
1
+ import { AppManifestService } from "./app-manifest.service.js";
2
+ import { AppPermissionsService } from "./app-permissions.service.js";
3
+ import { WasmMainRunnerService } from "./wasm-main-runner.service.js";
4
4
  import { readFile, readdir } from "node:fs/promises";
5
5
  import path from "node:path";
6
- //#region src/host/app-instance.service.ts
6
+ //#region src/services/app-instance.service.ts
7
7
  var AppInstanceService = class {
8
8
  permissions;
9
9
  constructor(bundle, permissionsService = new AppPermissionsService(), mainRunner = new WasmMainRunnerService(), manifestService = new AppManifestService()) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-instance.service.js","names":[],"sources":["../../src/services/app-instance.service.ts"],"sourcesContent":["import { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { AppStandaloneManifestBundle } from \"#app-runtime/types/app-manifest.types.js\";\nimport { AppManifestService } from \"#app-runtime/services/app-manifest.service.js\";\nimport { AppPermissionsService } from \"#app-runtime/services/app-permissions.service.js\";\nimport type {\n AppDocumentGrantMap,\n AppPermissionSummary,\n ResolvedPermissions,\n} from \"#app-runtime/types/app-permissions.types.js\";\nimport { WasmMainRunnerService } from \"#app-runtime/services/wasm-main-runner.service.js\";\nimport type { MainRunResult, WasmDocumentSummaryInput } from \"#app-runtime/types/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: AppStandaloneManifestBundle,\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,18 +1,28 @@
1
- import { AppManifestBundle, AppManifestSummary } from "./app-manifest.types.js";
1
+ import { AppManifestBundle, AppManifestSummary } from "../types/app-manifest.types.js";
2
2
 
3
- //#region src/manifest/app-manifest.service.d.ts
3
+ //#region src/services/app-manifest.service.d.ts
4
4
  declare class AppManifestService {
5
5
  load: (appDirectory: string) => Promise<AppManifestBundle>;
6
6
  summarize: (bundle: AppManifestBundle) => AppManifestSummary;
7
+ private loadStandaloneBundle;
8
+ private loadComponentBundle;
7
9
  private parseManifest;
10
+ private parseCommonManifest;
8
11
  private parseMain;
9
12
  private parseUi;
13
+ private parseComponents;
14
+ private parseEngines;
15
+ private parsePresentation;
16
+ private readComponentId;
10
17
  private parsePermissions;
11
18
  private parseDocumentAccess;
12
19
  private parseStringArray;
13
20
  private parseStorage;
14
21
  private parseCapabilities;
15
22
  private assertResolvedFile;
23
+ private assertResolvedDirectory;
24
+ private resolveInside;
25
+ private normalizeRelativePath;
16
26
  private assertObject;
17
27
  private readRequiredString;
18
28
  private readOptionalString;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-manifest.service.d.ts","names":[],"sources":["../../src/services/app-manifest.service.ts"],"mappings":";;;cAmBa,kBAAA;EACX,IAAA,GAAc,YAAA,aAAuB,OAAA,CAAQ,iBAAA;EAU7C,SAAA,GAAa,MAAA,EAAQ,iBAAA,KAAoB,kBAAA;EAAA,QAoCjC,oBAAA;EAAA,QA8BA,mBAAA;EAAA,QA8DA,aAAA;EAAA,QAyBA,mBAAA;EAAA,QAcA,SAAA;EAAA,QAoBA,OAAA;EAAA,QAKA,eAAA;EAAA,QA+BA,YAAA;EAAA,QAUA,iBAAA;EAAA,QAeA,eAAA;EAAA,QA0BA,gBAAA;EAAA,QAaA,mBAAA;EAAA,QAwBA,gBAAA;EAAA,QAUA,YAAA;EAAA,QAQA,iBAAA;EAAA,QAYA,kBAAA;EAAA,QAaA,uBAAA;EAAA,QAcA,aAAA;EAAA,QAUA,qBAAA;EAAA,QAWA,YAAA;EAAA,QAOA,kBAAA;EAAA,QAOA,kBAAA;EAAA,QAIA,UAAA;EAAA,QAOA,WAAA;AAAA"}