@delta-comic/plugin 3.0.0-next.16 → 3.0.0-next.18

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["#modules","#entries","#controller","#disposers","#disposePromise","#dispose","isRecord","record","DELTA_COMIC_PLUGIN_API_VERSION","defaultStorage","useDbConfig","#versions","#install","#decode","#database","#store","#open","#key","#root","#moduleVersions","#urls","CorePlugin","pkg.version","__import_glob__0_0_","#activeNormal","#options","#prepared","#preloadReport","#preloadOperation","#app","#prepareEnabledPlugins","#writeRecovery","#normalOperation","#loadNormal","#track","#unloadNormal","#assertReadyForToggle","#booted","#activateNormal","#activationFailure","#prepareAndActivate","#deactivateNormal","#loadPlugin","#flattenErrors","#runUninstallHook","#selectWithDependencies","#assertValidPlan"],"sources":["../../lib/api/config.ts","../../lib/api/model/content.ts","../../lib/api/model/expose.ts","../../lib/api/model/remote.ts","../../lib/api/model/social.ts","../../lib/api/model/special.ts","../../lib/api/model/user.ts","../../lib/api/plugin.ts","../../lib/kernel/candidate.ts","../../lib/kernel/capability.ts","../../lib/kernel/contribution.ts","../../lib/kernel/dependency.ts","../../lib/kernel/scope.ts","../../lib/capabilities/auth.ts","../../lib/capabilities/config.ts","../../lib/capabilities/registryBinding.ts","../../lib/capabilities/content.ts","../../lib/capabilities/i18n.ts","../../lib/capabilities/lifecycle.ts","../../lib/capabilities/channels.ts","../../lib/capabilities/model.ts","../../lib/capabilities/endpointProbe.ts","../../lib/capabilities/remote.ts","../../lib/capabilities/special.ts","../../lib/capabilities/user.ts","../../lib/capabilities/index.ts","../../lib/install/manifest.ts","../../lib/adapters/awesomeRegistry/types.ts","../../lib/adapters/awesomeRegistry/schema.ts","../../lib/adapters/awesomeRegistry/cache.ts","../../lib/adapters/awesomeRegistry/client.ts","../../lib/adapters/configStore.ts","../../lib/install/candidateProvider.ts","../../lib/install/catalog.ts","../../lib/install/codec.ts","../../lib/install/moduleReader.ts","../../lib/install/repository.ts","../../lib/install/service.ts","../../lib/install/source.ts","../../lib/adapters/fileStore.ts","../../lib/adapters/i18n.ts","../../package.json","../../lib/core/env.ts","../../lib/core/config.ts","../../lib/core/i18n.ts","../../lib/core/share.ts","../../lib/core/index.ts","../../lib/builtins/core.builtin.ts","../../lib/builtins/index.ts","../../lib/runtime/store.ts","../../lib/runtime/engine.ts","../../lib/runtime/providers.ts","../../lib/composition.ts"],"sourcesContent":["import type { FormSingleConfigure } from '@delta-comic/model'\n\nexport type ConfigDescription = Record<\n string,\n Required<Pick<FormSingleConfigure, 'defaultValue'>> & FormSingleConfigure\n>\n\nexport type UnwrapConfigPointer<T extends ConfigPointer> = T['_type']\n\nexport class ConfigPointer<T extends ConfigDescription = ConfigDescription> {\n public readonly key: symbol\n declare public readonly _type: T\n\n public constructor(\n public readonly pluginName: string,\n public readonly config: T,\n public readonly configName: string,\n ) {\n this.key = Symbol.for(`config:${pluginName}`)\n }\n}","import type {\n StreamQuery,\n UniCommentRow,\n UniContentDownloadProvider,\n UniContentLayoutComponent,\n UniContentPageLike,\n UniItem,\n UniItemCardComponent,\n UniItemTranslator,\n} from '@delta-comic/model'\nimport type { Component } from 'vue'\n\nexport interface ContentModel {\n models?: Model[]\n search?: Search\n promotes?: Promotes\n}\n\n// model\nexport interface Model {\n name: string\n ItemCard?: UniItemCardComponent\n CommentRow?: UniCommentRow\n Layout?: UniContentLayoutComponent\n ContentPage?: UniContentPageLike\n DownloadProvider?: UniContentDownloadProvider\n ItemTranslator?: UniItemTranslator\n}\n\n// search\nexport interface Search {\n methods: SearchMethod[]\n barcode?: Barcode[]\n getHotSearch: HotSearchProvider\n}\n\nexport type HotSearchProvider = (signal: AbortSignal) => Promise<SearchAim[]>\n\nexport interface SearchMethod {\n name: string\n id: string\n sorts: { options: { label: string; id: string }[]; default: string }\n\n fetchSearchResult: StreamQuery<UniItem, { aim: SearchAim }>\n getAutoComplete: AutoCompleteProvider\n}\n\nexport type AutoCompleteProvider = (\n input: string,\n signal: AbortSignal,\n) => Promise<SearchAim[] | Component>\n\nexport interface SearchAim {\n input: string\n search: { method: string; sort?: string }\n}\n\nexport interface Barcode {\n name: string\n id: string\n getTipText: (aim: SearchAim) => string\n isMatch: (aim: SearchAim) => boolean\n}\n\n// promotes\nexport interface Promotes {\n tabbar?: Tabbar[]\n categories?: Category[]\n hotPageContent?: HotPageContent\n\n fetchRandomItems?: ItemProvider\n}\n\nexport type ItemProvider = (signal: AbortSignal) => Promise<UniItem[]>\n\nexport interface Category {\n title: string\n namespace: string\n search: SearchAim\n}\n\nexport interface Tabbar {\n title: string\n id: string\n comp: Component<{ isActive: boolean; tabbar: Tabbar }>\n}\n\n// promotes - hotPageContent\n\nexport interface HotPageContent {\n levelboard?: HotLevelboard[]\n topButton?: HotTopButton[]\n categories?: HotCategory[]\n}\n\nexport interface HotLevelboard {\n name: string\n id: string\n content: ItemProvider\n}\nexport interface HotCategory {\n name: string\n content: ItemProvider\n}\nexport interface HotTopButton {\n name: string\n icon: Component\n bgColor: string\n}","export type ExposeModel = Record<string, unknown>\n\n/** Plugin id to public expose contract. Plugin consumers extend this through module augmentation. */\nexport interface PluginExposeRegistry {}","import type { UniResourceProcessor } from '@delta-comic/model'\n\nexport type RemoteModel = TestGroup[]\n\nexport type TestFunction = (url: string, signal: AbortSignal) => Promise<void>\n\nexport type RemoteListProvider = (signal: AbortSignal) => Promise<Definition[]>\n\nexport type RemoteSource = Definition | RemoteListProvider\n\nexport interface Definition {\n name: string\n url: string\n /**\n * cover root `test` method\n */\n test?: TestFunction\n}\n\nexport interface TestGroupBase {\n name: string\n remotes: RemoteSource[] | RemoteListProvider\n /**\n * group-level default test\n */\n test: TestFunction\n allowNoConnected?: boolean\n}\n\nexport interface TestRemoteGroup extends TestGroupBase {\n type: 'remote'\n}\n\nexport interface TestResourceGroup extends TestGroupBase {\n type: 'resource'\n processors?: UniResourceProcessor[]\n}\n\nexport type TestGroup = TestRemoteGroup | TestResourceGroup\n\nexport interface ResolvedTestGroupBase extends Omit<TestGroupBase, 'remotes'> {\n remotes: Definition[]\n}\n\nexport interface ResolvedTestRemoteGroup extends ResolvedTestGroupBase {\n type: 'remote'\n}\n\nexport interface ResolvedTestResourceGroup extends ResolvedTestGroupBase {\n type: 'resource'\n processors?: UniResourceProcessor[]\n}\n\nexport type ResolvedTestGroup = ResolvedTestRemoteGroup | ResolvedTestResourceGroup","import type {\n UniContentPage,\n UniImage,\n StreamQuery,\n UniItem,\n UniItemAuthor,\n} from '@delta-comic/model'\nimport type { Component } from 'vue'\n\nexport interface SocialModel {\n share?: Share\n subscribe?: Subscribe\n}\n\n// share\nexport interface Share {\n initiative?: InitiativeItem[]\n tokenListen?: ShareToken[]\n}\n\nexport interface ShareToken {\n key: string\n name: string\n isMatched(chipboard: string): boolean\n show(chipboard: string): Promise<SharePopupConfig>\n}\n\nexport interface SharePopupConfig {\n title: string\n detail: string\n onPositive(): void\n onNegative(): void\n}\n\nexport interface InitiativeItem {\n key: string\n name: string\n icon: Component | UniImage\n bgColor?: string\n call(page: UniContentPage): Promise<{ token?: string } | void>\n filter(page: UniContentPage): boolean\n}\n\n// subscribe\nexport interface Subscribe {\n getUpdateList: SubscribeListProvider\n fetchAuthorContent: StreamQuery<UniItem, { author: UniItemAuthor }>\n}\n\nexport type SubscribeListProvider = (\n olds: { author: UniItemAuthor; list: UniItem[] }[],\n signal: AbortSignal,\n) => Promise<{ isUpdated: boolean; whichUpdated: UniItemAuthor[] }>","export type SpecialModel = Step[]\n\nexport interface Step {\n name: string\n call: (setDescription: (description: string) => void) => Promise<void>\n}","import type { FormConfigure, FormSingleResult } from '@delta-comic/model'\nimport type { UniItem, UniItemAuthor, UniItemRaw, UniUserCardComponent } from '@delta-comic/model'\nimport type { Component, MaybeRefOrGetter } from 'vue'\n\nexport interface UserModel {\n auth: Auth\n edit?: Component\n card?: UniUserCardComponent\n /**\n * 你希望展示的(`userActions`)自己的板块的页面\n */\n userActionPages?: UserActionPage[]\n /**\n * 在用户界面,在历史记录那个板块的下方,你希望展示的自己的板块\n */\n userActions?: UserAction[]\n\n favourites: Favourites\n}\n\n// auth\nexport interface Auth {\n selections: Selection[]\n /**\n * @returns `string` -> id; `false` -> by user; `true` -> no auth\n */\n default: () => Promise<string | boolean>\n}\n\nexport interface Selection {\n name: string\n id: string\n call: (by: Method) => Promise<void>\n}\n\nexport type Method = {\n form<T extends FormConfigure>(\n form: T,\n ): Promise<{\n [x in keyof T]: FormSingleResult<T[x]>\n }>\n /**\n * @param injectCode 你可以在js调用`callback(...)`来完成鉴权,传值为你给的回调\n */\n website<T>(url: string, injectCode: InjectCode): Promise<CallbackResult<T>>\n}\n\nexport interface InjectCode {\n js: string\n css: string\n}\n\nexport interface CallbackResult<T> {\n callbackValue: T\n cookie: string\n localStorage: Record<string, string>\n sessionStorage: Record<string, string>\n href: string\n title: string\n}\n\n// user\n\nexport interface UserAction {\n call(author: UniItemAuthor): unknown\n name: string\n id: string\n icon?: Component\n}\n\nexport interface UserActionPage {\n title?: string\n items: ActionPageItem[]\n\n clickPage?: Component\n clickText?: string\n}\nexport type ActionPageItem =\n | {\n name: string\n key: string\n type: 'button'\n icon: Component\n\n page: Component\n }\n | {\n name: string\n key: string\n type: 'statistic'\n icon?: Component\n\n value: MaybeRefOrGetter<string | number>\n }\n\nexport interface Favourites {\n download: (signal: AbortSignal) => Promise<UniItem[]>\n upload: (items: UniItemRaw[], signal: AbortSignal) => Promise<void>\n}","import { isFunction } from 'es-toolkit'\n\nimport type { ConfigPointer } from './config'\nimport type { ConfigEnv } from './env'\nimport type { PluginConfigHooks } from './hook'\nimport type { PluginLocaleMessages } from './i18n'\nimport type { PluginConfigModel } from './model'\n\nexport interface DCPluginConfig {\n /** Stable plugin id. It must equal the candidate manifest id. */\n name: string\n /** At most one declarative configuration form can be contributed by a plugin. */\n config?: ConfigPointer\n i18n?: PluginLocaleMessages\n model?: PluginConfigModel\n hooks?: PluginConfigHooks\n}\n\nexport type PluginConfigFactory<T extends DCPluginConfig = DCPluginConfig> = (env: ConfigEnv) => T\n\nexport const defineDeltaComicPlugin = <T extends DCPluginConfig>(\n config: T | PluginConfigFactory<T>,\n): PluginConfigFactory<T> => {\n if (isFunction(config)) return config\n return () => config\n}","import type { PluginManifest } from '@delta-comic/model'\n\nimport type { PluginConfigFactory } from '../api'\n\nimport type { PluginScope } from './scope'\n\nexport type PluginOrigin = 'builtin' | 'installed'\n\nexport interface PluginManagementCapabilities {\n readonly canDisable: boolean\n readonly canUninstall: boolean\n readonly canUpdate: boolean\n}\n\nexport interface LoadedPluginModule {\n readonly factory: PluginConfigFactory\n activate?(scope: PluginScope): Promise<void> | void\n dispose?(): Promise<void> | void\n}\n\nexport interface PluginCandidate {\n readonly manifest: PluginManifest\n readonly origin: PluginOrigin\n readonly enabled: boolean\n readonly management: PluginManagementCapabilities\n load(signal: AbortSignal): Promise<LoadedPluginModule>\n}\n\nexport interface PluginCandidateProvider {\n readonly id: string\n list(signal: AbortSignal): Promise<readonly PluginCandidate[]>\n}\n\nexport interface InternalPluginDefinition {\n readonly manifest: PluginManifest\n readonly factory: PluginConfigFactory\n readonly canDisable?: boolean\n readonly enabledByDefault?: boolean\n}\n\nexport const defineInternalPlugin = <T extends InternalPluginDefinition>(definition: T) =>\n definition","import type { DCPluginConfig } from '../api'\n\nimport type { PluginScope } from './scope'\n\nexport interface ActivationStepUpdate {\n readonly description?: string\n readonly name?: string\n}\n\nexport interface ActivationContext {\n readonly owner: string\n readonly scope: PluginScope\n readonly signal: AbortSignal\n report(update: ActivationStepUpdate | string): void\n}\n\nexport interface CapabilityModule {\n readonly id: string\n activate(plugin: DCPluginConfig, context: ActivationContext): Promise<boolean>\n}\n\nexport interface CapabilityDefinition<T> {\n readonly id: string\n select(plugin: DCPluginConfig): T | undefined\n activate(model: T, context: ActivationContext): Promise<void> | void\n}\n\nexport const defineCapability = <T>(definition: CapabilityDefinition<T>): CapabilityModule => ({\n id: definition.id,\n async activate(plugin, context) {\n const model = definition.select(plugin)\n if (model === undefined) return false\n await definition.activate(model, context)\n return true\n },\n})\n\nexport class ActivationPipeline {\n readonly #modules: readonly CapabilityModule[]\n\n public constructor(modules: readonly CapabilityModule[]) {\n const ids = new Set<string>()\n for (const module of modules) {\n if (!module.id) throw new Error('capability id cannot be empty')\n if (ids.has(module.id)) throw new Error(`duplicate capability \"${module.id}\"`)\n ids.add(module.id)\n }\n this.#modules = [...modules]\n }\n\n public async activate(plugin: DCPluginConfig, context: ActivationContext) {\n const activated: string[] = []\n for (const module of this.#modules) {\n if (context.signal.aborted) throw context.signal.reason\n context.report({ description: '', name: module.id })\n if (await module.activate(plugin, context)) activated.push(module.id)\n }\n return activated\n }\n}","import { shallowReactive } from 'vue'\n\nimport type { PluginScope } from './scope'\n\nexport interface Contribution<T> {\n readonly owner: string\n readonly id: string\n readonly value: T\n}\n\nexport interface ContributionChannel<T, Owners extends Record<keyof Owners, T> = Record<never, T>> {\n readonly key: string\n readonly __type?: T\n readonly __owners?: Owners\n}\n\nexport const defineContributionChannel = <\n T,\n Owners extends Record<keyof Owners, T> = Record<never, T>,\n>(\n key: string,\n): ContributionChannel<T, Owners> => ({ key })\n\nexport type ContributionValue<\n T,\n Owners extends Record<keyof Owners, T>,\n Owner extends string,\n> = Owner extends keyof Owners ? Owners[Owner] : T\n\nconst contributionKey = (owner: string, id: string) => JSON.stringify([owner, id])\n\nexport class ContributionRegistry<T, Owners extends Record<keyof Owners, T> = Record<never, T>> {\n readonly #entries = shallowReactive(new Map<string, Contribution<T>>())\n\n public get size() {\n return this.#entries.size\n }\n\n public get entries(): ReadonlyMap<string, Contribution<T>> {\n return this.#entries\n }\n\n public register<Owner extends string>(\n owner: Owner,\n id: string,\n value: ContributionValue<T, Owners, Owner>,\n ) {\n if (!owner) throw new Error('contribution owner cannot be empty')\n if (!id) throw new Error('contribution id cannot be empty')\n\n const key = contributionKey(owner, id)\n if (this.#entries.has(key)) {\n throw new Error(`duplicate contribution \"${owner}:${id}\"`)\n }\n\n const contribution: Contribution<T> = { id, owner, value: value as T }\n this.#entries.set(key, contribution)\n\n let active = true\n return () => {\n if (!active) return false\n active = false\n return this.#entries.delete(key)\n }\n }\n\n public get<Owner extends string>(owner: Owner, id: string) {\n type Value = ContributionValue<T, Owners, Owner>\n return this.#entries.get(contributionKey(owner, id)) as Contribution<Value> | undefined\n }\n\n public byOwner<Owner extends string>(owner: Owner) {\n type Value = ContributionValue<T, Owners, Owner>\n return [...this.#entries.values()].filter(\n entry => entry.owner === owner,\n ) as Contribution<Value>[]\n }\n\n public removeOwner(owner: string) {\n for (const [key, entry] of this.#entries) {\n if (entry.owner === owner) this.#entries.delete(key)\n }\n }\n\n public values() {\n return this.#entries.values()\n }\n}\n\nexport class ContributionHub {\n private readonly registries = new Map<string, ContributionRegistry<any, any>>()\n\n public channel<T, Owners extends Record<keyof Owners, T> = Record<never, T>>(\n channel: ContributionChannel<T, Owners>,\n ): ContributionRegistry<T, Owners> {\n let registry = this.registries.get(channel.key)\n if (!registry) {\n registry = new ContributionRegistry<T, Owners>()\n this.registries.set(channel.key, registry)\n }\n return registry //as ContributionRegistry<T, Owners>\n }\n\n public register<T, Owners extends Record<keyof Owners, T> = Record<never, T>>(\n scope: PluginScope,\n channel: ContributionChannel<T, Owners>,\n id: string,\n value: T,\n ) {\n const unregister = this.channel(channel).register<string>(\n scope.owner,\n id,\n value as ContributionValue<T, Owners, string>,\n )\n scope.defer(() => void unregister())\n return unregister\n }\n\n public removeOwner(owner: string) {\n for (const registry of this.registries.values()) registry.removeOwner(owner)\n }\n}","import type { PluginCandidate } from './candidate'\n\nexport interface MissingPluginDependency {\n readonly plugin: string\n readonly dependency: string\n}\n\nexport interface PluginDependencyPlan {\n readonly levels: PluginCandidate[][]\n readonly missing: MissingPluginDependency[]\n readonly cycles: string[][]\n}\n\nconst dependenciesOf = (candidate: PluginCandidate) =>\n candidate.manifest.require.map(dependency => dependency.id)\n\nconst canonicalCycleKey = (cycle: readonly string[]) => {\n const nodes = cycle.slice(0, -1)\n const rotations = nodes.map((_, index) => nodes.slice(index).concat(nodes.slice(0, index)))\n rotations.sort((left, right) => left.join('\\0').localeCompare(right.join('\\0')))\n return rotations[0]?.join('\\0') ?? ''\n}\n\nexport const findPluginDependencyCycles = (candidates: readonly PluginCandidate[]) => {\n const candidateIds = new Set(candidates.map(candidate => candidate.manifest.name.id))\n const dependencies = new Map(\n candidates.map(candidate => [\n candidate.manifest.name.id,\n dependenciesOf(candidate).filter(dependency => candidateIds.has(dependency)),\n ]),\n )\n const state = new Map<string, 'visiting' | 'visited'>()\n const path: string[] = []\n const keys = new Set<string>()\n const cycles: string[][] = []\n\n const visit = (plugin: string) => {\n state.set(plugin, 'visiting')\n path.push(plugin)\n for (const dependency of dependencies.get(plugin) ?? []) {\n if (state.get(dependency) === 'visiting') {\n const start = path.lastIndexOf(dependency)\n if (start < 0) continue\n const cycle = path.slice(start).concat(dependency)\n const key = canonicalCycleKey(cycle)\n if (!keys.has(key)) {\n keys.add(key)\n cycles.push(cycle)\n }\n } else if (state.get(dependency) !== 'visited') {\n visit(dependency)\n }\n }\n path.pop()\n state.set(plugin, 'visited')\n }\n\n for (const candidate of candidates) {\n const id = candidate.manifest.name.id\n if (!state.has(id)) visit(id)\n }\n return cycles\n}\n\nexport const planPluginDependencies = (\n candidates: readonly PluginCandidate[],\n): PluginDependencyPlan => {\n const byId = new Map(candidates.map(candidate => [candidate.manifest.name.id, candidate]))\n const degree = new Map<string, number>()\n const dependents = new Map<string, string[]>()\n const missing: MissingPluginDependency[] = []\n\n for (const candidate of candidates) {\n const id = candidate.manifest.name.id\n const installed = dependenciesOf(candidate).filter(dependency => {\n if (byId.has(dependency)) return true\n missing.push({ dependency, plugin: id })\n return false\n })\n degree.set(id, installed.length)\n for (const dependency of installed) {\n const entries = dependents.get(dependency) ?? []\n entries.push(id)\n dependents.set(dependency, entries)\n }\n }\n\n const queue = [...degree].filter(([, value]) => value === 0).map(([id]) => id)\n const levels: PluginCandidate[][] = []\n while (queue.length > 0) {\n const current = queue.splice(0)\n const level = current.flatMap(id => {\n const candidate = byId.get(id)\n return candidate ? [candidate] : []\n })\n if (level.length > 0) levels.push(level)\n for (const id of current) {\n for (const dependent of dependents.get(id) ?? []) {\n const next = (degree.get(dependent) ?? 0) - 1\n degree.set(dependent, next)\n if (next === 0) queue.push(dependent)\n }\n }\n }\n\n const unresolved = candidates.filter(\n candidate => (degree.get(candidate.manifest.name.id) ?? 0) > 0,\n )\n return { cycles: findPluginDependencyCycles(unresolved), levels, missing }\n}","export type PluginDisposer = () => Promise<void> | void\n\nexport class PluginScope {\n readonly #controller = new AbortController()\n readonly #disposers: PluginDisposer[] = []\n #disposePromise?: Promise<void>\n\n public constructor(public readonly owner: string) {}\n\n public get signal() {\n return this.#controller.signal\n }\n\n public get disposed() {\n return this.#disposePromise !== undefined\n }\n\n public defer(disposer: PluginDisposer) {\n if (this.disposed) throw new Error(`plugin scope \"${this.owner}\" is already disposed`)\n this.#disposers.push(disposer)\n return disposer\n }\n\n public dispose(reason?: unknown) {\n return (this.#disposePromise ??= this.#dispose(reason))\n }\n\n async #dispose(reason?: unknown) {\n this.#controller.abort(reason)\n const errors: unknown[] = []\n\n for (const disposer of this.#disposers.reverse()) {\n try {\n await disposer()\n } catch (error) {\n errors.push(error)\n }\n }\n this.#disposers.length = 0\n\n if (errors.length > 0) {\n throw new AggregateError(errors, `failed to dispose plugin scope \"${this.owner}\"`)\n }\n }\n}","import { defineCapability, type CapabilityModule } from '../kernel'\n\nimport type { PluginCapabilityServices } from './services'\n\nexport const createAuthCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'auth',\n select: config => config.model?.user?.auth,\n async activate(auth, context) {\n if (!services.auth) throw new Error('plugin authentication requires a host auth gateway')\n context.report({ name: 'auth', description: 'checking authentication' })\n await services.auth.authenticate(context.owner, auth, context.signal)\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nimport type { PluginCapabilityServices } from './services'\n\nexport const createConfigCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'config',\n select: config => config.config,\n async activate(pointer, context) {\n if (pointer.pluginName !== context.scope.owner) {\n throw new Error(\n `plugin config owner mismatch: ${context.scope.owner} / ${pointer.pluginName}`,\n )\n }\n context.report({ description: pointer.configName })\n const registered = services.config.register(pointer)\n context.scope.defer(() => services.config.unregister(pointer))\n await registered.ready\n },\n })","import type { PluginScope } from '../kernel'\n\ninterface MutableRegistry<TKey, TValue> {\n delete(key: TKey): boolean\n get(key: TKey): TValue | undefined\n has(key: TKey): boolean\n set(key: TKey, value: TValue): unknown\n}\n\n/** Bind a host registry entry and restore exactly the value that existed before activation. */\nexport const bindRegistryValue = <TKey, TValue>(\n scope: PluginScope,\n registry: MutableRegistry<TKey, TValue>,\n key: TKey,\n value: TValue | undefined,\n) => {\n if (value === undefined) return\n const hadPrevious = registry.has(key)\n const previous = registry.get(key)\n registry.set(key, value)\n scope.defer(() => {\n if (hadPrevious) registry.set(key, previous as TValue)\n else registry.delete(key)\n })\n}","import { UniComment, UniContentPage, UniItem } from '@delta-comic/model'\n\nimport { defineCapability, type CapabilityModule } from '../kernel'\n\nimport { bindRegistryValue } from './registryBinding'\n\nexport const createContentCapability = (): CapabilityModule =>\n defineCapability({\n id: 'content-bindings',\n select: config => config.model?.content?.models,\n activate(models, context) {\n const names = new Set<string>()\n for (const model of models) {\n if (!model.name) throw new Error('content model name cannot be empty')\n if (names.has(model.name)) throw new Error(`duplicate content model \"${model.name}\"`)\n names.add(model.name)\n const key: [plugin: string, name: string] = [context.owner, model.name]\n bindRegistryValue(context.scope, UniContentPage.layouts, key, model.Layout)\n bindRegistryValue(context.scope, UniItem.itemCards, key, model.ItemCard)\n bindRegistryValue(context.scope, UniContentPage.contentPages, key, model.ContentPage)\n bindRegistryValue(\n context.scope,\n UniContentPage.downloadProviders,\n key,\n model.DownloadProvider,\n )\n bindRegistryValue(context.scope, UniComment.commentRow, key, model.CommentRow)\n bindRegistryValue(context.scope, UniItem.itemTranslator, key, model.ItemTranslator)\n }\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nimport type { PluginCapabilityServices } from './services'\n\nexport const createI18nCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'i18n',\n select: config => config.i18n,\n activate(messages, context) {\n services.i18n.register(context.scope.owner, messages)\n context.scope.defer(() => services.i18n.remove(context.scope.owner))\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nexport const createLifecycleCapability = (): CapabilityModule =>\n defineCapability({\n id: 'lifecycle',\n select: config => {\n const hooks = config.hooks\n return hooks?.onBooted || hooks?.onUnload ? hooks : undefined\n },\n async activate(hooks, context) {\n if (hooks.onUnload) context.scope.defer(() => hooks.onUnload?.())\n await hooks.onBooted?.()\n },\n })","import type {\n ContentModel,\n ExposeModel,\n PluginExposeRegistry,\n RemoteModel,\n SocialModel,\n SpecialModel,\n UserModel,\n} from '../api/model'\nimport { defineContributionChannel } from '../kernel'\n\nexport const pluginModelChannels = {\n content: defineContributionChannel<ContentModel>('model:content'),\n expose: defineContributionChannel<ExposeModel, PluginExposeRegistry>('model:expose'),\n remote: defineContributionChannel<RemoteModel>('model:remote'),\n social: defineContributionChannel<SocialModel>('model:social'),\n special: defineContributionChannel<SpecialModel>('model:special'),\n user: defineContributionChannel<UserModel>('model:user'),\n} as const","import type { PluginConfigModel } from '../api/model'\nimport { defineCapability, type CapabilityModule, type ContributionChannel } from '../kernel'\n\nimport { pluginModelChannels } from './channels'\nimport type { PluginCapabilityServices } from './services'\n\nexport const createModelCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'model',\n select: config => config.model,\n activate(model: PluginConfigModel, context) {\n const register = <T>(channel: ContributionChannel<T>, value: T | undefined) => {\n if (value !== undefined) {\n services.contributions.register(context.scope, channel, 'default', value)\n }\n }\n\n register(pluginModelChannels.content, model.content)\n register(pluginModelChannels.expose, model.expose)\n register(pluginModelChannels.remote, model.remotes)\n register(pluginModelChannels.social, model.social)\n register(pluginModelChannels.special, model.special)\n register(pluginModelChannels.user, model.user)\n },\n })","export interface EndpointProbeCandidate<T> {\n readonly test: (url: string, signal: AbortSignal) => PromiseLike<void>\n readonly url: string\n readonly value: T\n}\n\nexport interface EndpointProbeResult<T> {\n readonly latencyMs: number\n readonly url: string\n readonly value: T\n}\n\nconst probeOne = async <T>(\n candidate: EndpointProbeCandidate<T>,\n parentSignal: AbortSignal,\n timeoutMs: number,\n controllers: Set<AbortController>,\n) => {\n const controller = new AbortController()\n controllers.add(controller)\n const relayAbort = () => controller.abort(parentSignal.reason)\n parentSignal.addEventListener('abort', relayAbort, { once: true })\n const timeout = setTimeout(\n () => controller.abort(new Error('endpoint probe timed out')),\n timeoutMs,\n )\n const startedAt = performance.now()\n try {\n await candidate.test(candidate.url, controller.signal)\n return { latencyMs: performance.now() - startedAt, url: candidate.url, value: candidate.value }\n } finally {\n clearTimeout(timeout)\n parentSignal.removeEventListener('abort', relayAbort)\n controllers.delete(controller)\n }\n}\n\n/** Probe independently in parallel and stop remaining attempts after the first reachable endpoint. */\nexport const selectFastestEndpoint = async <T>(\n candidates: readonly EndpointProbeCandidate<T>[],\n signal: AbortSignal,\n timeoutMs = 10_000,\n): Promise<EndpointProbeResult<T> | undefined> => {\n signal.throwIfAborted()\n const controllers = new Set<AbortController>()\n try {\n return await Promise.any(\n candidates.map(candidate => probeOne(candidate, signal, timeoutMs, controllers)),\n )\n } catch (error) {\n signal.throwIfAborted()\n if (error instanceof AggregateError) return undefined\n throw error\n } finally {\n for (const controller of controllers)\n controller.abort(new Error('another endpoint was selected'))\n }\n}","import { UniResource } from '@delta-comic/model'\n\nimport type { Remote } from '../api'\nimport { defineCapability, defineContributionChannel, type CapabilityModule } from '../kernel'\n\nimport { selectFastestEndpoint } from './endpointProbe'\nimport { bindRegistryValue } from './registryBinding'\nimport type { PluginCapabilityServices } from './services'\n\nconst resolveGroup = async (\n group: Remote.TestGroup,\n signal: AbortSignal,\n): Promise<Remote.ResolvedTestGroup> => {\n const sources = typeof group.remotes === 'function' ? [group.remotes] : group.remotes\n const remotes = (\n await Promise.all(\n sources.map(source => (typeof source === 'function' ? source(signal) : source)),\n )\n ).flat()\n\n return { ...group, remotes }\n}\n\nexport interface RemoteSelection {\n readonly group: Remote.ResolvedTestRemoteGroup\n readonly latencyMs?: number\n readonly remote: Remote.Definition | false\n}\n\nexport const pluginRemoteSelectionChannel = defineContributionChannel<RemoteSelection>(\n 'runtime:remote-selection',\n)\n\nexport const createRemoteCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'remote',\n select: config =>\n config.model?.remotes ? { hooks: config.hooks, remotes: config.model.remotes } : undefined,\n async activate({ hooks, remotes }, context) {\n const groups = new Set<string>()\n for (const sourceGroup of remotes) {\n if (!sourceGroup.name) throw new Error('remote group name cannot be empty')\n if (groups.has(sourceGroup.name)) {\n throw new Error(`duplicate remote group \"${sourceGroup.name}\"`)\n }\n groups.add(sourceGroup.name)\n context.report({ name: 'remote', description: `probing ${sourceGroup.name}` })\n const group = await resolveGroup(sourceGroup, context.signal)\n const selected = await selectFastestEndpoint(\n group.remotes.map(remote => ({\n test: remote.test ?? group.test,\n url: remote.url,\n value: remote,\n })),\n context.signal,\n )\n if (!selected && !group.allowNoConnected) {\n if (group.type === 'remote') {\n throw new Error(`no reachable endpoint for remote group \"${group.name}\"`)\n }\n throw new Error(`no reachable endpoint for resource \"${group.name}\"`)\n }\n if (group.type === 'resource') {\n bindRegistryValue(\n context.scope,\n UniResource.fork,\n [context.owner, group.name],\n group.remotes.map(remote => remote.url),\n )\n if (selected) {\n bindRegistryValue(\n context.scope,\n UniResource.precedenceFork,\n [context.owner, group.name],\n selected.url,\n )\n }\n const processors = new Set<string>()\n for (const processor of group.processors ?? []) {\n if (!processor.name) throw new Error('resource process name cannot be empty')\n if (processors.has(processor.name)) {\n throw new Error(`duplicate resource process \"${processor.name}\"`)\n }\n processors.add(processor.name)\n bindRegistryValue(\n context.scope,\n UniResource.processInstances,\n [context.owner, processor.name],\n processor,\n )\n }\n continue\n }\n const selection: RemoteSelection = {\n group,\n latencyMs: selected?.latencyMs,\n remote: selected?.value ?? false,\n }\n services.contributions.register(\n context.scope,\n pluginRemoteSelectionChannel,\n group.name,\n selection,\n )\n hooks?.onRemoteTestDone?.(group, selection.remote)\n }\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nexport const createSpecialCapability = (): CapabilityModule =>\n defineCapability({\n id: 'special',\n select: config => config.model?.special,\n async activate(steps, context) {\n for (const step of steps) {\n context.signal.throwIfAborted()\n if (!step.name) throw new Error('special step name cannot be empty')\n context.report({ name: step.name, description: '' })\n await step.call(description => context.report({ name: step.name, description }))\n }\n },\n })","import { UniUser } from '@delta-comic/model'\n\nimport { defineCapability, type CapabilityModule } from '../kernel'\n\nimport { bindRegistryValue } from './registryBinding'\n\nexport const createUserCapability = (): CapabilityModule =>\n defineCapability({\n id: 'user-bindings',\n select: config => config.model?.user,\n activate(user, context) {\n bindRegistryValue(context.scope, UniUser.userCards, context.owner, user.card)\n bindRegistryValue(context.scope, UniUser.userEditorBase, context.owner, user.edit)\n },\n })","import type { CapabilityModule } from '../kernel'\n\nimport { createAuthCapability } from './auth'\nimport { createConfigCapability } from './config'\nimport { createContentCapability } from './content'\nimport { createI18nCapability } from './i18n'\nimport { createLifecycleCapability } from './lifecycle'\nimport { createModelCapability } from './model'\nimport { createRemoteCapability } from './remote'\nimport type { PluginCapabilityServices } from './services'\nimport { createSpecialCapability } from './special'\nimport { createUserCapability } from './user'\n\nexport * from './auth'\nexport * from './channels'\nexport * from './config'\nexport * from './content'\nexport * from './i18n'\nexport * from './lifecycle'\nexport * from './model'\nexport * from './remote'\nexport * from './services'\nexport * from './special'\nexport * from './user'\n\n/** Fixed host-owned activation topology. Third-party plugins only provide data to it. */\nexport const createDefaultCapabilities = (\n services: PluginCapabilityServices,\n): readonly CapabilityModule[] => [\n createConfigCapability(services),\n createI18nCapability(services),\n createModelCapability(services),\n createContentCapability(),\n createUserCapability(),\n createRemoteCapability(services),\n createAuthCapability(services),\n createSpecialCapability(),\n createLifecycleCapability(),\n]","import { DELTA_COMIC_PLUGIN_API_VERSION, type PluginManifest } from '@delta-comic/model'\nimport semver from 'semver'\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst record = (value: unknown, path: string) => {\n if (!isRecord(value)) throw new PluginManifestError(`${path} must be an object`)\n return value\n}\n\nconst text = (value: unknown, path: string) => {\n if (typeof value !== 'string' || value.length === 0) {\n throw new PluginManifestError(`${path} must be a non-empty string`)\n }\n return value\n}\n\nconst pluginId = (value: unknown, path: string) => {\n const id = text(value, path)\n if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(id)) {\n throw new PluginManifestError(`${path} must be a portable 1-64 character plugin identifier`)\n }\n return id\n}\n\nexport const safePluginPath = (value: unknown, path: string) => {\n const normalized = text(value, path).replaceAll('\\\\', '/')\n if (\n normalized.startsWith('/') ||\n /^[a-z]:($|\\/)/i.test(normalized) ||\n normalized.includes('\\0') ||\n normalized.split('/').some(segment => segment === '..')\n ) {\n throw new PluginManifestError(`${path} must be a safe relative path`)\n }\n return normalized\n .split('/')\n .filter(segment => segment && segment !== '.')\n .join('/')\n}\n\nexport class PluginManifestError extends Error {\n public constructor(message: string) {\n super(`Invalid Delta Comic manifest: ${message}`)\n this.name = 'PluginManifestError'\n }\n}\n\nconst pluginIcon = (value: unknown) => {\n const icon = text(value, 'manifest.icon').trim()\n if (!/^[a-z][a-z\\d+.-]*:/i.test(icon)) return safePluginPath(icon, 'manifest.icon')\n let url: URL\n try {\n url = new URL(icon)\n } catch {\n throw new PluginManifestError('manifest.icon must be an HTTP(S) URL or a safe relative path')\n }\n if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) {\n throw new PluginManifestError(\n 'manifest.icon must be a credential-free HTTP(S) URL or a safe relative path',\n )\n }\n return icon\n}\n\nexport const parsePluginManifest = (value: unknown): PluginManifest => {\n const manifest = record(value, 'manifest')\n if (manifest.apiVersion !== DELTA_COMIC_PLUGIN_API_VERSION) {\n throw new PluginManifestError(`manifest.apiVersion must be ${DELTA_COMIC_PLUGIN_API_VERSION}`)\n }\n const name = record(manifest.name, 'manifest.name')\n const version = record(manifest.version, 'manifest.version')\n const id = pluginId(name.id, 'manifest.name.id')\n if (!Array.isArray(manifest.require)) {\n throw new PluginManifestError('manifest.require must be an array')\n }\n\n const result: PluginManifest = {\n apiVersion: DELTA_COMIC_PLUGIN_API_VERSION,\n author: text(manifest.author, 'manifest.author'),\n description: text(manifest.description, 'manifest.description'),\n name: { display: text(name.display, 'manifest.name.display'), id },\n require: manifest.require.map((value, index) => {\n const dependency = record(value, `manifest.require[${index}]`)\n return {\n id: pluginId(dependency.id, `manifest.require[${index}].id`),\n ...(dependency.download === undefined\n ? {}\n : { download: text(dependency.download, `manifest.require[${index}].download`) }),\n }\n }),\n version: {\n plugin: text(version.plugin, 'manifest.version.plugin'),\n supportCore: text(version.supportCore, 'manifest.version.supportCore'),\n },\n }\n\n if (manifest.icon !== undefined) result.icon = pluginIcon(manifest.icon)\n if (manifest.entry !== undefined) {\n const entry = record(manifest.entry, 'manifest.entry')\n result.entry = {\n jsPath: safePluginPath(entry.jsPath, 'manifest.entry.jsPath'),\n ...(entry.cssPath === undefined\n ? {}\n : { cssPath: safePluginPath(entry.cssPath, 'manifest.entry.cssPath') }),\n }\n }\n if (manifest.integrity !== undefined) {\n const integrity = record(manifest.integrity, 'manifest.integrity')\n if (integrity.algorithm !== 'blake3' && integrity.algorithm !== 'sha256') {\n throw new PluginManifestError('manifest.integrity.algorithm is unsupported')\n }\n result.integrity = {\n algorithm: integrity.algorithm,\n digest: text(integrity.digest, 'manifest.integrity.digest'),\n }\n }\n return result\n}\n\nexport const isPluginManifestCompatible = (manifest: PluginManifest, coreVersion: string) =>\n semver.satisfies(coreVersion, manifest.version.supportCore)","export const AWESOME_REGISTRY_BASE_URL =\n 'https://raw.githubusercontent.com/delta-comic/awesome-plugins/main/'\nexport const AWESOME_REGISTRY_INDEX_PATH = 'registry/index.json'\nexport const AWESOME_REGISTRY_SCHEMA_VERSION = 1 as const\n\nexport interface AwesomeRegistryPageReference {\n page: number\n items: number\n path: string\n}\n\nexport interface AwesomeRegistryIndex {\n schemaVersion: typeof AWESOME_REGISTRY_SCHEMA_VERSION\n pageSize: number\n totalItems: number\n totalPages: number\n pages: AwesomeRegistryPageReference[]\n}\n\nexport interface AwesomeRegistryPagination {\n page: number\n pageSize: number\n totalItems: number\n totalPages: number\n previous: string | null\n next: string | null\n}\n\nexport type AwesomePluginDownload =\n | { type: 'github'; repository: string }\n | { type: 'url'; url: string }\n\nexport interface AwesomePluginRepository {\n owner: string\n name: string\n url: string\n defaultBranch: string\n lastCommitAt: string\n readmeUrl?: string\n}\n\nexport interface AwesomePluginRelease {\n version: string\n url: string\n publishedAt: string\n manifestUrl: string | null\n}\n\nexport interface AwesomePluginListing {\n schemaVersion: typeof AWESOME_REGISTRY_SCHEMA_VERSION\n id: string\n authors: string[]\n download: AwesomePluginDownload\n repository?: AwesomePluginRepository\n release?: AwesomePluginRelease\n}\n\nexport interface AwesomeRegistryPage {\n schemaVersion: typeof AWESOME_REGISTRY_SCHEMA_VERSION\n pagination: AwesomeRegistryPagination\n items: AwesomePluginListing[]\n}\n\nexport interface AwesomeRegistryResult<T> {\n data: T\n cachedAt: string\n stale: boolean\n}\n\nexport interface AwesomeRegistryStorage {\n getItem(key: string): string | null\n removeItem(key: string): void\n setItem(key: string, value: string): void\n}","import {\n AWESOME_REGISTRY_SCHEMA_VERSION,\n type AwesomePluginDownload,\n type AwesomePluginListing,\n type AwesomePluginRelease,\n type AwesomePluginRepository,\n type AwesomeRegistryIndex,\n type AwesomeRegistryPage,\n type AwesomeRegistryPagination,\n type AwesomeRegistryPageReference,\n} from './types'\n\n/** Paths are validated before they are resolved against the configured registry origin. */\nconst PAGE_PATH_PATTERN = /^registry\\/pages\\/[1-9][0-9]*\\.json$/\nconst PLUGIN_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/\nconst GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/\nconst GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst record = (value: unknown, path: string) => {\n if (!isRecord(value)) throw new AwesomeRegistryValidationError(`${path} must be an object`)\n return value\n}\n\nconst exactKeys = (value: Record<string, unknown>, allowed: readonly string[], path: string) => {\n const extras = Object.keys(value).filter(key => !allowed.includes(key))\n if (extras.length > 0) {\n throw new AwesomeRegistryValidationError(`${path} has unknown fields: ${extras.join(', ')}`)\n }\n}\n\nconst string = (value: unknown, path: string) => {\n if (typeof value !== 'string' || value.length === 0) {\n throw new AwesomeRegistryValidationError(`${path} must be a non-empty string`)\n }\n return value\n}\n\nconst integer = (value: unknown, path: string, minimum: number, maximum = Infinity) => {\n if (!Number.isInteger(value) || (value as number) < minimum || (value as number) > maximum) {\n throw new AwesomeRegistryValidationError(\n `${path} must be an integer between ${minimum} and ${maximum}`,\n )\n }\n return value as number\n}\n\nconst schemaVersion = (value: unknown, path: string) => {\n if (value !== AWESOME_REGISTRY_SCHEMA_VERSION) {\n throw new AwesomeRegistryVersionError(value, path)\n }\n return AWESOME_REGISTRY_SCHEMA_VERSION\n}\n\nconst path = (value: unknown, field: string) => {\n const result = string(value, field)\n if (!PAGE_PATH_PATTERN.test(result)) {\n throw new AwesomeRegistryValidationError(`${field} must be a registry page path`)\n }\n return result\n}\n\nconst httpUrl = (value: unknown, field: string) => {\n const result = string(value, field)\n let parsed: URL\n try {\n parsed = new URL(result)\n } catch {\n throw new AwesomeRegistryValidationError(`${field} must be an absolute URL`)\n }\n if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) {\n throw new AwesomeRegistryValidationError(`${field} must be a credential-free HTTP(S) URL`)\n }\n return result\n}\n\nconst dateTime = (value: unknown, field: string) => {\n const result = string(value, field)\n if (!/^\\d{4}-\\d{2}-\\d{2}T/.test(result) || Number.isNaN(Date.parse(result))) {\n throw new AwesomeRegistryValidationError(`${field} must be an ISO date-time`)\n }\n return result\n}\n\nconst parsePageReference = (value: unknown, field: string): AwesomeRegistryPageReference => {\n const item = record(value, field)\n exactKeys(item, ['page', 'items', 'path'], field)\n return {\n page: integer(item.page, `${field}.page`, 1),\n items: integer(item.items, `${field}.items`, 1),\n path: path(item.path, `${field}.path`),\n }\n}\n\nconst parseDownload = (value: unknown, field: string): AwesomePluginDownload => {\n const download = record(value, field)\n if (download.type === 'github') {\n exactKeys(download, ['type', 'repository'], field)\n const repository = string(download.repository, `${field}.repository`)\n if (!GITHUB_REPOSITORY_PATTERN.test(repository)) {\n throw new AwesomeRegistryValidationError(`${field}.repository is invalid`)\n }\n return { type: 'github', repository }\n }\n if (download.type === 'url') {\n exactKeys(download, ['type', 'url'], field)\n return { type: 'url', url: httpUrl(download.url, `${field}.url`) }\n }\n throw new AwesomeRegistryValidationError(`${field}.type is unsupported`)\n}\n\nconst parseRepository = (value: unknown, field: string): AwesomePluginRepository => {\n const repository = record(value, field)\n exactKeys(\n repository,\n ['owner', 'name', 'url', 'defaultBranch', 'lastCommitAt', 'readmeUrl'],\n field,\n )\n return {\n owner: string(repository.owner, `${field}.owner`),\n name: string(repository.name, `${field}.name`),\n url: httpUrl(repository.url, `${field}.url`),\n defaultBranch: string(repository.defaultBranch, `${field}.defaultBranch`),\n lastCommitAt: dateTime(repository.lastCommitAt, `${field}.lastCommitAt`),\n ...(repository.readmeUrl === undefined\n ? {}\n : { readmeUrl: httpUrl(repository.readmeUrl, `${field}.readmeUrl`) }),\n }\n}\n\nconst parseRelease = (value: unknown, field: string): AwesomePluginRelease => {\n const release = record(value, field)\n exactKeys(release, ['version', 'url', 'publishedAt', 'manifestUrl'], field)\n return {\n version: string(release.version, `${field}.version`),\n url: httpUrl(release.url, `${field}.url`),\n publishedAt: dateTime(release.publishedAt, `${field}.publishedAt`),\n manifestUrl:\n release.manifestUrl === null ? null : httpUrl(release.manifestUrl, `${field}.manifestUrl`),\n }\n}\n\nexport class AwesomeRegistryValidationError extends Error {\n public constructor(message: string) {\n super(`Invalid awesome-plugins registry: ${message}`)\n this.name = 'AwesomeRegistryValidationError'\n }\n}\n\nexport class AwesomeRegistryVersionError extends AwesomeRegistryValidationError {\n public constructor(\n public readonly received: unknown,\n path: string,\n ) {\n super(`${path} has unsupported schemaVersion ${String(received)}`)\n this.name = 'AwesomeRegistryVersionError'\n }\n}\n\nexport const parseAwesomeRegistryIndex = (value: unknown): AwesomeRegistryIndex => {\n const index = record(value, 'index')\n exactKeys(index, ['schemaVersion', 'pageSize', 'totalItems', 'totalPages', 'pages'], 'index')\n if (!Array.isArray(index.pages)) {\n throw new AwesomeRegistryValidationError('index.pages must be an array')\n }\n const result: AwesomeRegistryIndex = {\n schemaVersion: schemaVersion(index.schemaVersion, 'index'),\n pageSize: integer(index.pageSize, 'index.pageSize', 1, 100),\n totalItems: integer(index.totalItems, 'index.totalItems', 0),\n totalPages: integer(index.totalPages, 'index.totalPages', 0),\n pages: index.pages.map((item, itemIndex) =>\n parsePageReference(item, `index.pages[${itemIndex}]`),\n ),\n }\n if (result.pages.length !== result.totalPages) {\n throw new AwesomeRegistryValidationError('index.pages length must equal index.totalPages')\n }\n if (result.pages.reduce((total, page) => total + page.items, 0) !== result.totalItems) {\n throw new AwesomeRegistryValidationError('index page item counts must equal index.totalItems')\n }\n result.pages.forEach((page, itemIndex) => {\n if (page.page !== itemIndex + 1 || page.items > result.pageSize) {\n throw new AwesomeRegistryValidationError('index pages must be ordered and respect pageSize')\n }\n })\n return result\n}\n\nexport const parseAwesomePluginListing = (\n value: unknown,\n field = 'listing',\n): AwesomePluginListing => {\n const listing = record(value, field)\n exactKeys(listing, ['schemaVersion', 'id', 'authors', 'download', 'repository', 'release'], field)\n const id = string(listing.id, `${field}.id`)\n if (!PLUGIN_ID_PATTERN.test(id)) {\n throw new AwesomeRegistryValidationError(`${field}.id is invalid`)\n }\n if (!Array.isArray(listing.authors) || listing.authors.length === 0) {\n throw new AwesomeRegistryValidationError(`${field}.authors must be a non-empty array`)\n }\n const authors = listing.authors.map((author, index) => {\n const login = string(author, `${field}.authors[${index}]`)\n if (!GITHUB_LOGIN_PATTERN.test(login)) {\n throw new AwesomeRegistryValidationError(`${field}.authors[${index}] is invalid`)\n }\n return login\n })\n if (new Set(authors).size !== authors.length) {\n throw new AwesomeRegistryValidationError(`${field}.authors must be unique`)\n }\n return {\n schemaVersion: schemaVersion(listing.schemaVersion, field),\n id,\n authors,\n download: parseDownload(listing.download, `${field}.download`),\n ...(listing.repository === undefined\n ? {}\n : { repository: parseRepository(listing.repository, `${field}.repository`) }),\n ...(listing.release === undefined\n ? {}\n : { release: parseRelease(listing.release, `${field}.release`) }),\n }\n}\n\nconst parsePagination = (value: unknown, field: string): AwesomeRegistryPagination => {\n const pagination = record(value, field)\n exactKeys(pagination, ['page', 'pageSize', 'totalItems', 'totalPages', 'previous', 'next'], field)\n return {\n page: integer(pagination.page, `${field}.page`, 1),\n pageSize: integer(pagination.pageSize, `${field}.pageSize`, 1, 100),\n totalItems: integer(pagination.totalItems, `${field}.totalItems`, 0),\n totalPages: integer(pagination.totalPages, `${field}.totalPages`, 1),\n previous: pagination.previous === null ? null : path(pagination.previous, `${field}.previous`),\n next: pagination.next === null ? null : path(pagination.next, `${field}.next`),\n }\n}\n\nexport const parseAwesomeRegistryPage = (value: unknown): AwesomeRegistryPage => {\n const page = record(value, 'page')\n exactKeys(page, ['schemaVersion', 'pagination', 'items'], 'page')\n if (!Array.isArray(page.items)) {\n throw new AwesomeRegistryValidationError('page.items must be an array')\n }\n const result: AwesomeRegistryPage = {\n schemaVersion: schemaVersion(page.schemaVersion, 'page'),\n pagination: parsePagination(page.pagination, 'page.pagination'),\n items: page.items.map((item, index) => parseAwesomePluginListing(item, `page.items[${index}]`)),\n }\n if (result.items.length > result.pagination.pageSize) {\n throw new AwesomeRegistryValidationError('page.items exceeds pageSize')\n }\n const expectedPrevious = result.pagination.page === 1 ? null : result.pagination.page - 1\n const expectedNext =\n result.pagination.page === result.pagination.totalPages ? null : result.pagination.page + 1\n if (\n (expectedPrevious === null) !== (result.pagination.previous === null) ||\n (expectedNext === null) !== (result.pagination.next === null)\n ) {\n throw new AwesomeRegistryValidationError('page pagination links are inconsistent')\n }\n return result\n}\n\nexport const assertAwesomeRegistryPagePath = (value: string) => path(value, 'page path')","import { parseAwesomeRegistryIndex, parseAwesomeRegistryPage } from './schema'\nimport type { AwesomeRegistryIndex, AwesomeRegistryPage, AwesomeRegistryStorage } from './types'\n\ninterface CacheEnvelope {\n cachedAt: string\n data: unknown\n}\n\nconst parseEnvelope = (value: string): CacheEnvelope | undefined => {\n try {\n const envelope = JSON.parse(value) as Partial<CacheEnvelope>\n if (typeof envelope.cachedAt !== 'string' || !('data' in envelope)) return undefined\n return { cachedAt: envelope.cachedAt, data: envelope.data }\n } catch {\n return undefined\n }\n}\n\nexport class AwesomeRegistryCache {\n public constructor(\n private readonly storage?: AwesomeRegistryStorage,\n private readonly prefix = 'delta-comic:awesome-registry:v1',\n ) {}\n\n public readIndex() {\n return this.read(`${this.prefix}:index`, parseAwesomeRegistryIndex)\n }\n\n public writeIndex(data: AwesomeRegistryIndex) {\n return this.write(`${this.prefix}:index`, data)\n }\n\n public readPage(path: string) {\n return this.read(`${this.prefix}:page:${path}`, parseAwesomeRegistryPage)\n }\n\n public writePage(path: string, data: AwesomeRegistryPage) {\n return this.write(`${this.prefix}:page:${path}`, data)\n }\n\n private read<T>(key: string, parse: (value: unknown) => T) {\n if (!this.storage) return undefined\n let stored: string | null\n try {\n stored = this.storage.getItem(key)\n } catch {\n return undefined\n }\n if (!stored) return undefined\n const envelope = parseEnvelope(stored)\n if (!envelope) {\n this.remove(key)\n return undefined\n }\n try {\n return { cachedAt: envelope.cachedAt, data: parse(envelope.data) }\n } catch {\n this.remove(key)\n return undefined\n }\n }\n\n private remove(key: string) {\n try {\n this.storage?.removeItem(key)\n } catch {}\n }\n\n private write(key: string, data: AwesomeRegistryIndex | AwesomeRegistryPage) {\n const cachedAt = new Date().toISOString()\n try {\n this.storage?.setItem(key, JSON.stringify({ cachedAt, data } satisfies CacheEnvelope))\n } catch {}\n return cachedAt\n }\n}","import { logger } from '@delta-comic/logger'\nimport type { PluginManifest } from '@delta-comic/model'\nimport ky from 'ky'\n\nimport type {\n PluginCatalog,\n PluginCatalogIndex,\n PluginCatalogListing,\n PluginCatalogPage,\n PluginCatalogResult,\n} from '../../install/catalog'\nimport { parsePluginManifest } from '../../install/manifest'\n\nimport { AwesomeRegistryCache } from './cache'\nimport {\n assertAwesomeRegistryPagePath,\n parseAwesomeRegistryIndex,\n parseAwesomeRegistryPage,\n AwesomeRegistryValidationError,\n} from './schema'\nimport {\n AWESOME_REGISTRY_BASE_URL,\n AWESOME_REGISTRY_INDEX_PATH,\n type AwesomePluginListing,\n type AwesomeRegistryIndex,\n type AwesomeRegistryPage,\n type AwesomeRegistryResult,\n type AwesomeRegistryStorage,\n} from './types'\n\nconst marketplaceLogger = logger.scoped('plugin:marketplace')\n\nexport interface AwesomeRegistryClientOptions {\n baseUrl?: string\n cache?: AwesomeRegistryCache\n requestJson?: (url: string, signal?: AbortSignal) => Promise<unknown>\n storage?: AwesomeRegistryStorage\n}\n\nconst defaultRequestJson = async (url: string, signal?: AbortSignal) =>\n await ky.get(url, { retry: 2, signal, timeout: 30_000 }).json<unknown>()\n\nconst defaultStorage = () => {\n try {\n return globalThis.localStorage\n } catch {\n return undefined\n }\n}\n\nexport class AwesomeRegistryNetworkError extends Error {\n public constructor(\n message: string,\n public override readonly cause?: unknown,\n ) {\n super(message)\n this.name = 'AwesomeRegistryNetworkError'\n }\n}\n\nconst catalogIndex = (index: AwesomeRegistryIndex): PluginCatalogIndex => ({\n pageSize: index.pageSize,\n pages: index.pages,\n totalItems: index.totalItems,\n totalPages: index.totalPages,\n})\n\nconst catalogListing = (listing: AwesomePluginListing): PluginCatalogListing => ({\n authors: listing.authors,\n id: listing.id,\n ...(listing.release ? { release: listing.release } : {}),\n ...(listing.repository ? { repository: listing.repository } : {}),\n source: listing.download,\n})\n\nconst catalogPage = (page: AwesomeRegistryPage): PluginCatalogPage => ({\n items: page.items.map(catalogListing),\n pagination: page.pagination,\n})\n\nexport class AwesomeRegistryClient implements PluginCatalog {\n private readonly baseUrl: string\n private readonly cache: AwesomeRegistryCache\n private readonly requestJson: (url: string, signal?: AbortSignal) => Promise<unknown>\n\n public constructor(options: AwesomeRegistryClientOptions = {}) {\n this.baseUrl = new URL(options.baseUrl ?? AWESOME_REGISTRY_BASE_URL).href\n this.cache = options.cache ?? new AwesomeRegistryCache(options.storage ?? defaultStorage())\n this.requestJson = options.requestJson ?? defaultRequestJson\n }\n\n public async loadIndex(signal?: AbortSignal): Promise<PluginCatalogResult<PluginCatalogIndex>> {\n const result = await this.load(\n AWESOME_REGISTRY_INDEX_PATH,\n parseAwesomeRegistryIndex,\n () => this.cache.readIndex(),\n data => this.cache.writeIndex(data),\n signal,\n )\n return { ...result, data: catalogIndex(result.data) }\n }\n\n public async loadPage(\n path: string,\n signal?: AbortSignal,\n ): Promise<PluginCatalogResult<PluginCatalogPage>> {\n const safePath = assertAwesomeRegistryPagePath(path)\n const result = await this.load(\n safePath,\n parseAwesomeRegistryPage,\n () => this.cache.readPage(safePath),\n data => this.cache.writePage(safePath, data),\n signal,\n )\n return { ...result, data: catalogPage(result.data) }\n }\n\n public async resolveInstallInput(id: string, signal: AbortSignal) {\n const listing = await this.findListing(id, signal)\n return listing.source.type === 'github' ? `gh:${listing.source.repository}` : listing.source.url\n }\n\n public async findListing(id: string, signal?: AbortSignal): Promise<PluginCatalogListing> {\n marketplaceLogger.debug('searching marketplace listing', { plugin: id })\n const { data: index } = await this.loadIndex(signal)\n for (const pageReference of index.pages) {\n const { data: page } = await this.loadPage(pageReference.path, signal)\n const listing = page.items.find(item => item.id === id)\n if (listing) {\n marketplaceLogger.debug('marketplace listing found', { plugin: id })\n return listing\n }\n }\n throw new Error(`Plugin \"${id}\" is not registered in awesome-plugins`)\n }\n\n public async loadManifest(\n listing: PluginCatalogListing,\n signal?: AbortSignal,\n ): Promise<PluginManifest | undefined> {\n const manifestUrl = listing.release?.manifestUrl\n if (!manifestUrl) return undefined\n const manifest = parsePluginManifest(await this.requestJson(manifestUrl, signal))\n if (manifest.name.id !== listing.id) {\n throw new AwesomeRegistryValidationError(\n `listing ${listing.id} points to manifest for ${manifest.name.id}`,\n )\n }\n return manifest\n }\n\n private async load<T>(\n path: string,\n parse: (value: unknown) => T,\n readCache: () => { data: T; cachedAt: string } | undefined,\n writeCache: (data: T) => string,\n signal?: AbortSignal,\n ): Promise<AwesomeRegistryResult<T>> {\n let payload: unknown\n try {\n payload = await this.requestJson(new URL(path, this.baseUrl).href, signal)\n } catch (error) {\n if (signal?.aborted) throw signal.reason\n if (error instanceof AwesomeRegistryValidationError || error instanceof SyntaxError)\n throw error\n const cached = readCache()\n if (cached) {\n marketplaceLogger.warn('marketplace request failed; using stale cache', { path }, error)\n return { ...cached, stale: true }\n }\n marketplaceLogger.error('marketplace request failed without cache', { path }, error)\n throw new AwesomeRegistryNetworkError(`Failed to request awesome-plugins ${path}`, error)\n }\n const data = parse(payload)\n marketplaceLogger.debug('marketplace response cached', { path })\n return { cachedAt: writeCache(data), data, stale: false }\n }\n}","import { useConfig as useDbConfig } from '@delta-comic/db'\nimport type { FormDefaultValue, FormResult } from '@delta-comic/model'\nimport { shallowReactive, type Ref } from 'vue'\n\nimport type { ConfigPointer, UnwrapConfigPointer } from '../api'\n\nexport type ConfigSave<T extends ConfigPointer = ConfigPointer> = {\n form: UnwrapConfigPointer<T>\n data: Ref<FormResult<T['config']>>\n name: string\n ready: Promise<void>\n}\n\ntype StoredConfigSave = {\n data: Ref<Record<string, FormDefaultValue[keyof FormDefaultValue]>>\n form: ConfigPointer['config']\n name: string\n ready: Promise<void>\n}\n\nexport type PluginConfigLoader = <T extends ConfigPointer>(pointer: T) => ConfigSave<T>\n\nconst loadDatabaseConfig: PluginConfigLoader = pointer => {\n const store = useDbConfig(pointer.pluginName, pointer.config)\n return { data: store, form: pointer.config, name: pointer.configName, ready: store.ready }\n}\n\nexport class ConfigStore {\n private readonly entries = shallowReactive(new Map<symbol, StoredConfigSave>())\n private readonly pointers = new Map<string, ConfigPointer>()\n private readonly isSystemDark =\n globalThis.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false\n\n public constructor(private readonly loadConfig: PluginConfigLoader = loadDatabaseConfig) {}\n\n public get form(): ReadonlyMap<symbol, StoredConfigSave> {\n return this.entries\n }\n\n public get isDark() {\n const pointer = this.pointers.get('core')\n if (!pointer) return this.isSystemDark\n const mode = (this.load(pointer).data.value as { darkMode?: string }).darkMode\n if (mode === 'light') return false\n if (mode === 'dark') return true\n return this.isSystemDark\n }\n\n public load<T extends ConfigPointer>(pointer: T): ConfigSave<T> {\n const value = this.entries.get(pointer.key)\n if (!value) throw new Error(`not found config by plugin \"${pointer.pluginName}\"`)\n return value as ConfigSave<T>\n }\n\n public has(pointer: ConfigPointer) {\n return this.entries.has(pointer.key)\n }\n\n public register<T extends ConfigPointer>(pointer: T) {\n const registered = this.entries.get(pointer.key)\n const ownerPointer = this.pointers.get(pointer.pluginName)\n if (registered && ownerPointer === pointer) return registered as ConfigSave<T>\n if (ownerPointer) {\n throw new Error(`plugin \"${pointer.pluginName}\" can only register one config`)\n }\n\n const saved = this.loadConfig(pointer)\n this.entries.set(pointer.key, saved as StoredConfigSave)\n this.pointers.set(pointer.pluginName, pointer)\n return saved\n }\n\n public unregister(pointer: ConfigPointer) {\n if (this.pointers.get(pointer.pluginName) !== pointer) return\n this.pointers.delete(pointer.pluginName)\n this.entries.delete(pointer.key)\n }\n}","import type { PluginCandidate, PluginCandidateProvider } from '../kernel'\n\nimport type { PluginArchiveRepository, PluginModuleReader } from './contracts'\n\n/**\n * The persisted `enable` flag is stored in a `TEXT` column. `kysely-plugin-serialize` normally\n * restores booleans, but the value that reaches this boundary is only typed as `boolean` — not\n * guaranteed at runtime. Normalize it so a legacy string/number (`'false'`, `'0'`, `1`, ...) can\n * never be mistaken for `true` by the runtime's truthiness check.\n */\nconst toBoolean = (value: unknown): boolean =>\n value === true || value === 'true' || value === 1 || value === '1'\n\n/** Normalize persisted archives into the same candidate protocol used by internal plugins. */\nexport class InstalledPluginCandidateProvider implements PluginCandidateProvider {\n public readonly id = 'installed'\n\n public constructor(\n private readonly repository: PluginArchiveRepository,\n private readonly readers: readonly PluginModuleReader[],\n ) {}\n\n public async list(signal: AbortSignal): Promise<PluginCandidate[]> {\n const archives = await this.repository.list()\n signal.throwIfAborted()\n return archives.map(archive => ({\n enabled: toBoolean(archive.enable),\n load: async loadSignal => {\n const reader =\n this.readers.find(candidate => candidate.matches?.(archive)) ??\n this.readers.find(candidate => !candidate.matches) ??\n this.readers[0]\n if (!reader) throw new Error('no plugin module reader is configured')\n return await reader.read(archive, loadSignal)\n },\n management: {\n canDisable: true,\n canUninstall: true,\n canUpdate: archive.installInput.length > 0,\n },\n manifest: archive.meta,\n origin: 'installed',\n }))\n }\n}","import type { PluginManifest } from '@delta-comic/model'\n\nexport type PluginCatalogSource =\n | { readonly type: 'github'; readonly repository: string }\n | { readonly type: 'url'; readonly url: string }\n\nexport interface PluginCatalogRepository {\n readonly defaultBranch: string\n readonly lastCommitAt: string\n readonly name: string\n readonly owner: string\n readonly readmeUrl?: string\n readonly url: string\n}\n\nexport interface PluginCatalogRelease {\n readonly manifestUrl: string | null\n readonly publishedAt: string\n readonly url: string\n readonly version: string\n}\n\nexport interface PluginCatalogListing {\n readonly authors: readonly string[]\n readonly id: string\n readonly release?: PluginCatalogRelease\n readonly repository?: PluginCatalogRepository\n readonly source: PluginCatalogSource\n}\n\nexport interface PluginCatalogPageReference {\n readonly items: number\n readonly page: number\n readonly path: string\n}\n\nexport interface PluginCatalogIndex {\n readonly pageSize: number\n readonly pages: readonly PluginCatalogPageReference[]\n readonly totalItems: number\n readonly totalPages: number\n}\n\nexport interface PluginCatalogPagination {\n readonly next: string | null\n readonly page: number\n readonly pageSize: number\n readonly previous: string | null\n readonly totalItems: number\n readonly totalPages: number\n}\n\nexport interface PluginCatalogPage {\n readonly items: readonly PluginCatalogListing[]\n readonly pagination: PluginCatalogPagination\n}\n\nexport interface PluginCatalogResult<T> {\n readonly cachedAt: string\n readonly data: T\n readonly stale: boolean\n}\n\n/** The narrow catalog port required by an install source resolver. */\nexport interface PluginInstallCatalog {\n resolveInstallInput(plugin: string, signal: AbortSignal): Promise<string>\n}\n\n/** Host-facing catalog operations used by the marketplace feature. */\nexport interface PluginCatalog extends PluginInstallCatalog {\n loadIndex(signal?: AbortSignal): Promise<PluginCatalogResult<PluginCatalogIndex>>\n loadManifest(\n listing: PluginCatalogListing,\n signal?: AbortSignal,\n ): Promise<PluginManifest | undefined>\n loadPage(path: string, signal?: AbortSignal): Promise<PluginCatalogResult<PluginCatalogPage>>\n}\n\nconst catalogInstallInputPattern = /^ap:([A-Za-z0-9][A-Za-z0-9_-]{0,63})$/\n\nexport const pluginCatalogInstallInput = (plugin: string) => {\n const input = `ap:${plugin}`\n if (!catalogInstallInputPattern.test(input)) {\n throw new TypeError(`invalid plugin catalog id: ${plugin}`)\n }\n return input\n}\n\nexport const pluginCatalogIdFromInstallInput = (input: unknown) =>\n typeof input === 'string' ? catalogInstallInputPattern.exec(input)?.[1] : undefined","import type { PluginManifest } from '@delta-comic/model'\nimport JSZip from 'jszip'\n\nimport type { DecodedPluginPackage, PluginPackageCodec } from './contracts'\nimport { parsePluginManifest, safePluginPath } from './manifest'\n\nconst sha256 = async (bytes: Uint8Array) => {\n const digest = await globalThis.crypto.subtle.digest('SHA-256', Uint8Array.from(bytes).buffer)\n return [...new Uint8Array(digest)].map(value => value.toString(16).padStart(2, '0')).join('')\n}\n\nconst withIntegrity = async (manifest: PluginManifest, bytes: Uint8Array) => ({\n ...manifest,\n integrity: { algorithm: 'sha256' as const, digest: await sha256(bytes) },\n})\n\nexport class ZipPackageCodec implements PluginPackageCodec {\n public readonly id = 'zip'\n\n public matches(file: File) {\n return file.name.toLowerCase().endsWith('.zip') || file.type === 'application/zip'\n }\n\n public async decode(file: File, signal: AbortSignal): Promise<DecodedPluginPackage> {\n const bytes = new Uint8Array(await file.arrayBuffer())\n if (signal.aborted) throw signal.reason\n const archive = await JSZip.loadAsync(bytes)\n const manifestFile = archive.file('manifest.json')\n if (!manifestFile) throw new Error('plugin archive does not contain manifest.json')\n const manifest = await withIntegrity(\n parsePluginManifest(JSON.parse(await manifestFile.async('text'))),\n bytes,\n )\n const files = new Map<string, Uint8Array>()\n for (const entry of Object.values(archive.files)) {\n if (signal.aborted) throw signal.reason\n if (entry.dir) continue\n const path = safePluginPath(entry.name, `archive entry ${entry.name}`)\n files.set(path, await entry.async('uint8array'))\n }\n return { codecId: this.id, files, manifest }\n }\n}","import type { PluginArchiveDB } from '@delta-comic/db'\n\nimport type { PluginConfigFactory } from '../api'\nimport type { LoadedPluginModule } from '../kernel'\n\nimport type { PluginFileStore, PluginModuleReader } from './contracts'\nimport {\n DEV_CSS_PATH,\n DEV_ENTRY_PATH,\n DEV_SERVER_LOADER_ID,\n devServerUrl,\n parseDevServerPort,\n} from './dev'\n\nconst asFactory = (value: unknown, plugin: string): PluginConfigFactory => {\n if (typeof value !== 'function') {\n throw new TypeError(`plugin entry has no default factory: ${plugin}`)\n }\n return value as PluginConfigFactory\n}\n\nconst styleActivator = (plugin: string, styleText: string | undefined) =>\n styleText === undefined\n ? undefined\n : (scope: import('../kernel').PluginScope) => {\n if (typeof document === 'undefined') return\n const style = document.createElement('style')\n style.dataset.plugin = plugin\n style.textContent = styleText\n document.head.append(style)\n scope.defer(() => style.remove())\n }\n\nexport class StoredPluginModuleReader implements PluginModuleReader {\n public readonly id = 'stored'\n\n public constructor(private readonly files: PluginFileStore) {}\n\n public async read(\n archive: PluginArchiveDB.Archive,\n signal: AbortSignal,\n ): Promise<LoadedPluginModule> {\n const plugin = archive.pluginName\n const url = await this.files.createModuleUrl(plugin, 'index.mjs')\n if (signal.aborted) {\n this.files.release(plugin)\n throw signal.reason\n }\n try {\n const module = (await import(/* @vite-ignore */ url)) as { default?: unknown }\n signal.throwIfAborted()\n let styleText: string | undefined\n try {\n styleText = new TextDecoder().decode(await this.files.read(plugin, 'index.css'))\n } catch {\n styleText = undefined\n }\n signal.throwIfAborted()\n return {\n activate: styleActivator(plugin, styleText),\n factory: asFactory(module.default, plugin),\n dispose: () => this.files.release(plugin),\n }\n } catch (error) {\n this.files.release(plugin)\n throw error\n }\n }\n}\n\nexport class DevServerPluginModuleReader implements PluginModuleReader {\n public readonly id = DEV_SERVER_LOADER_ID\n readonly #versions = new Map<string, number>()\n\n public matches(archive: PluginArchiveDB.Archive) {\n return archive.loaderName === this.id\n }\n\n public async read(\n archive: PluginArchiveDB.Archive,\n signal: AbortSignal,\n ): Promise<LoadedPluginModule> {\n const port = parseDevServerPort(archive.installInput)\n if (port === undefined) {\n throw new Error(`development plugin has an invalid install source: ${archive.installInput}`)\n }\n const previousVersion = this.#versions.get(archive.pluginName)\n const version = (previousVersion ?? 0) + 1\n this.#versions.set(archive.pluginName, version)\n signal.throwIfAborted()\n\n // Keep the first entry URL stable so its source modules share one native Vite HMR graph.\n // Explicit plugin updates still get a fresh bootstrap URL after the first load.\n const entryUrl = devServerUrl(port, DEV_ENTRY_PATH)\n const module = (await import(\n /* @vite-ignore */ previousVersion === undefined ? entryUrl : `${entryUrl}?v=${version}`\n )) as { default?: unknown }\n signal.throwIfAborted()\n\n let styleText: string | undefined\n const response = await fetch(devServerUrl(port, DEV_CSS_PATH), { cache: 'no-store', signal })\n if (response.status !== 404) {\n if (!response.ok) throw new Error(`development plugin CSS request failed: ${response.status}`)\n styleText = await response.text()\n }\n signal.throwIfAborted()\n return {\n activate: styleActivator(archive.pluginName, styleText),\n factory: asFactory(module.default, archive.pluginName),\n }\n }\n}","import { assertWriteRow, db, validateReadRow, type PluginArchiveDB } from '@delta-comic/db'\n\nimport type { PluginArchiveRepository } from './contracts'\n\nexport class DatabasePluginArchiveRepository implements PluginArchiveRepository {\n public async find(plugin: string) {\n const row = await db\n .selectFrom('plugin')\n .selectAll()\n .where('pluginName', '=', plugin)\n .executeTakeFirst()\n return row ? validateReadRow('plugin', row) : undefined\n }\n\n public async list() {\n const rows = await db.selectFrom('plugin').selectAll().execute()\n return rows.map(row => validateReadRow('plugin', row))\n }\n\n public async remove(plugin: string) {\n await db.deleteFrom('plugin').where('pluginName', '=', plugin).execute()\n }\n\n public async upsert(archive: PluginArchiveDB.Archive) {\n const row = assertWriteRow('plugin', { ...archive, meta: JSON.stringify(archive.meta) })\n await db.replaceInto('plugin').values(row).execute()\n }\n}","import type { PluginArchiveDB } from '@delta-comic/db'\n\nimport type {\n DecodedPluginPackage,\n PluginArchiveRepository,\n PluginFileStore,\n PluginInstallInput,\n PluginInstallReporter,\n PluginPackageCodec,\n PluginSourceResolver,\n ResolvedPluginSource,\n} from './contracts'\n\nexport interface PluginInstallServiceOptions {\n readonly codecs: readonly PluginPackageCodec[]\n readonly files: PluginFileStore\n readonly repository: PluginArchiveRepository\n readonly reservedIds?: ReadonlySet<string>\n readonly resolvers: readonly PluginSourceResolver[]\n}\n\ninterface PluginInstallContext {\n readonly installing: Set<string>\n readonly installed: Set<string>\n readonly added: string[]\n}\n\nexport class PluginInstallService {\n public constructor(private readonly options: PluginInstallServiceOptions) {}\n\n public async install(\n input: PluginInstallInput,\n signal = new AbortController().signal,\n report: PluginInstallReporter = () => {},\n ) {\n const context: PluginInstallContext = { added: [], installed: new Set(), installing: new Set() }\n try {\n return await this.#install(input, signal, report, context)\n } catch (error) {\n const rollbackErrors: unknown[] = [error]\n for (const plugin of [...context.added].reverse()) {\n try {\n await this.uninstall(plugin)\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n }\n if (rollbackErrors.length === 1) throw error\n throw new AggregateError(rollbackErrors, 'failed to install plugin dependencies')\n }\n }\n\n async #install(\n input: PluginInstallInput,\n signal: AbortSignal,\n report: PluginInstallReporter,\n context: PluginInstallContext,\n expectedPlugin?: string,\n ) {\n report({ phase: 'resolve', progress: 0 })\n const resolver = this.options.resolvers.find(candidate => candidate.matches(input))\n if (!resolver) throw new Error('no plugin source resolver accepts this input')\n const source = await resolver.resolve(input, signal, report)\n report({\n description: source.file?.name ?? source.installInput,\n phase: 'resolve',\n progress: 100,\n })\n\n const decoded = source.package ?? (await this.#decode(source, signal, report))\n const plugin = decoded.manifest.name.id\n if (this.options.reservedIds?.has(plugin)) {\n throw new Error(`plugin id \"${plugin}\" is reserved by an internal plugin`)\n }\n if (expectedPlugin && plugin !== expectedPlugin) {\n throw new Error(`plugin dependency \"${expectedPlugin}\" downloaded as \"${plugin}\"`)\n }\n if (context.installing.has(plugin)) {\n throw new Error(`plugin dependency cycle includes \"${plugin}\"`)\n }\n report({ description: plugin, phase: 'decode', progress: 100 })\n\n context.installing.add(plugin)\n try {\n for (const dependency of decoded.manifest.require) {\n if (\n this.options.reservedIds?.has(dependency.id) ||\n context.installed.has(dependency.id) ||\n (await this.options.repository.find(dependency.id))\n ) {\n context.installed.add(dependency.id)\n continue\n }\n if (!dependency.download) continue\n await this.#install(dependency.download, signal, report, context, dependency.id)\n }\n\n const previous = await this.options.repository.find(plugin)\n const replacement = await this.options.files.replace(\n plugin,\n source.storage === 'remote' ? new Map() : decoded.files,\n )\n const archive: PluginArchiveDB.Archive = {\n displayName: decoded.manifest.name.display,\n enable: previous?.enable ?? true,\n installerName: source.resolverId,\n installInput: source.installInput,\n loaderName: source.package?.codecId ?? decoded.codecId,\n meta: decoded.manifest,\n pluginName: plugin,\n }\n\n try {\n report({ description: plugin, phase: 'persist', progress: 50 })\n await this.options.repository.upsert(archive)\n await replacement.commit()\n report({ description: plugin, phase: 'persist', progress: 100 })\n context.installed.add(plugin)\n if (!previous) context.added.push(plugin)\n return archive\n } catch (error) {\n const rollbackErrors: unknown[] = []\n try {\n await replacement.rollback()\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n try {\n if (previous) await this.options.repository.upsert(previous)\n else await this.options.repository.remove(plugin)\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n if (rollbackErrors.length > 0) {\n throw new AggregateError(\n [error, ...rollbackErrors],\n `failed to install plugin \"${plugin}\"`,\n )\n }\n throw error\n }\n } finally {\n context.installing.delete(plugin)\n }\n }\n\n async #decode(\n source: ResolvedPluginSource,\n signal: AbortSignal,\n report: PluginInstallReporter,\n ): Promise<DecodedPluginPackage> {\n const file = source.file\n if (!file) throw new Error('resolved plugin source contains neither a file nor a package')\n const codec = this.options.codecs.find(candidate => candidate.matches(file))\n if (!codec) throw new Error('no plugin package codec accepts this file')\n report({ description: codec.id, phase: 'decode', progress: 0 })\n const decoded = await codec.decode(file, signal)\n return decoded\n }\n\n /** Remove archive metadata and files as one compensating transaction. */\n public async uninstall(plugin: string) {\n const previous = await this.options.repository.find(plugin)\n const replacement = await this.options.files.replace(plugin, new Map())\n try {\n await this.options.repository.remove(plugin)\n await replacement.commit()\n } catch (error) {\n const rollbackErrors: unknown[] = []\n try {\n await replacement.rollback()\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n try {\n if (previous) await this.options.repository.upsert(previous)\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n if (rollbackErrors.length > 0) {\n throw new AggregateError(\n [error, ...rollbackErrors],\n `failed to uninstall plugin \"${plugin}\"`,\n )\n }\n throw error\n }\n }\n}","import { logger } from '@delta-comic/logger'\nimport { Octokit } from '@octokit/rest'\n\nimport { pluginCatalogIdFromInstallInput, type PluginInstallCatalog } from './catalog'\nimport type {\n PluginInstallInput,\n PluginInstallReporter,\n PluginSourceResolver,\n ResolvedPluginSource,\n} from './contracts'\nimport {\n DEV_CSS_PATH,\n DEV_ENTRY_PATH,\n DEV_MANIFEST_PATH,\n DEV_SERVER_LOADER_ID,\n devServerUrl,\n parseDevServerPort,\n} from './dev'\nimport { isPluginManifestCompatible, parsePluginManifest } from './manifest'\n\nconst REPORT_INTERVAL = 250\n\nasync function responseFile(\n response: Response,\n name: string,\n report: PluginInstallReporter = () => {},\n): Promise<File> {\n const totalHeader = response.headers.get('content-length')\n const totalBytes = totalHeader ? Number(totalHeader) : undefined\n const reader = response.body?.getReader()\n if (!reader) return new File([await response.blob()], name)\n\n const chunks: Uint8Array<ArrayBuffer>[] = []\n let downloadedBytes = 0\n let lastReport = 0\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n const chunk = new Uint8Array(value.byteLength)\n chunk.set(value)\n chunks.push(chunk)\n downloadedBytes += value.byteLength\n const now = performance.now()\n if (now - lastReport < REPORT_INTERVAL) continue\n lastReport = now\n report({\n downloadedBytes,\n phase: 'resolve',\n progress: totalBytes ? (downloadedBytes / totalBytes) * 100 : undefined,\n totalBytes,\n })\n }\n report({ downloadedBytes, phase: 'resolve', progress: 100, totalBytes })\n return new File(chunks, name)\n}\n\nexport class LocalFileSourceResolver implements PluginSourceResolver {\n public readonly id = 'local-file'\n\n public matches(input: PluginInstallInput): input is File {\n return typeof input !== 'string'\n }\n\n public async resolve(input: PluginInstallInput): Promise<ResolvedPluginSource> {\n if (typeof input === 'string') throw new TypeError('local file resolver requires a File')\n return { file: input, installInput: '', resolverId: this.id }\n }\n}\n\nexport class HttpSourceResolver implements PluginSourceResolver {\n public readonly id = 'http'\n\n public matches(input: PluginInstallInput): input is string {\n return typeof input === 'string' && /^https?:\\/\\//i.test(input)\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n report?: PluginInstallReporter,\n ): Promise<ResolvedPluginSource> {\n if (typeof input !== 'string') throw new TypeError('HTTP resolver requires a URL')\n const response = await fetch(input, { signal })\n if (!response.ok) throw new Error(`plugin download failed: ${response.status}`)\n const name = new URL(input).pathname.split('/').at(-1) || 'plugin.zip'\n return {\n file: await responseFile(response, name, report),\n installInput: input,\n resolverId: this.id,\n }\n }\n}\n\nconst fetchDevText = async (\n url: string,\n signal: AbortSignal,\n optional = false,\n): Promise<string | undefined> => {\n const response = await fetch(url, { cache: 'no-store', signal })\n if (!response.ok) {\n if (optional && response.status === 404) return undefined\n throw new Error(`development plugin request failed: ${response.status}`)\n }\n return await response.text()\n}\n\nexport class DevServerSourceResolver implements PluginSourceResolver {\n public readonly id = DEV_SERVER_LOADER_ID\n\n public matches(input: PluginInstallInput): input is string {\n return typeof input === 'string' && parseDevServerPort(input) !== undefined\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n ): Promise<ResolvedPluginSource> {\n if (typeof input !== 'string') throw new TypeError('development resolver requires dev:<port>')\n const port = parseDevServerPort(input)\n if (port === undefined) throw new TypeError('development resolver requires dev:<port>')\n\n const manifestText = await fetchDevText(devServerUrl(port, DEV_MANIFEST_PATH), signal)\n const manifest = parsePluginManifest(JSON.parse(manifestText ?? ''))\n await fetchDevText(devServerUrl(port, DEV_ENTRY_PATH), signal)\n if (manifest.entry?.cssPath !== undefined) {\n await fetchDevText(devServerUrl(port, DEV_CSS_PATH), signal, true)\n }\n\n return {\n installInput: input,\n package: { codecId: this.id, files: new Map(), manifest },\n resolverId: this.id,\n storage: 'remote',\n }\n }\n}\n\nexport interface GitHubSourceResolverOptions {\n readonly coreVersion: string\n readonly includePrereleases?: () => boolean\n readonly token?: string\n}\n\nexport class GitHubSourceResolver implements PluginSourceResolver {\n public readonly id = 'github'\n\n public constructor(private readonly options: GitHubSourceResolverOptions) {}\n\n public matches(input: PluginInstallInput): input is string {\n return typeof input === 'string' && /^gh:[^/]+\\/[^/]+$/.test(input)\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n report?: PluginInstallReporter,\n ) {\n if (typeof input !== 'string') throw new TypeError('GitHub resolver requires a repository')\n const [owner, repo] = input.slice(3).split('/') as [string, string]\n logger.info('github use token : ', this.options.token)\n const octokit = new Octokit({ auth: this.options.token })\n const includePrereleases = this.options.includePrereleases?.() ?? false\n const pages = octokit.paginate.iterator(octokit.rest.repos.listReleases, {\n owner,\n per_page: 100,\n repo,\n request: { signal },\n })\n for await (const page of pages) {\n for (const release of page.data) {\n if (release.draft || (release.prerelease && !includePrereleases)) continue\n const manifestAsset = release.assets.find(asset => asset.name === 'manifest.json')\n const packageAsset = release.assets.find(asset => asset.name === 'plugin.zip')\n if (!manifestAsset || !packageAsset) continue\n const manifestResponse = await fetch(manifestAsset.browser_download_url, { signal })\n if (!manifestResponse.ok) continue\n const manifest = parsePluginManifest(await manifestResponse.json())\n if (!isPluginManifestCompatible(manifest, this.options.coreVersion)) continue\n logger.info('download plugin from github with response: ', packageAsset)\n const packageResponse = await fetch(packageAsset.browser_download_url, { signal })\n if (!packageResponse.ok)\n throw new Error(`plugin download failed: ${packageResponse.status}`)\n return {\n file: await responseFile(packageResponse, packageAsset.name, report),\n installInput: input,\n resolverId: this.id,\n }\n }\n }\n throw new Error(`no compatible plugin release found for ${owner}/${repo}`)\n }\n}\n\nexport class MarketplaceSourceResolver implements PluginSourceResolver {\n public readonly id = 'marketplace'\n\n public constructor(\n private readonly catalog: PluginInstallCatalog,\n private readonly sources: readonly PluginSourceResolver[],\n ) {}\n\n public matches(input: PluginInstallInput): input is string {\n return pluginCatalogIdFromInstallInput(input) !== undefined\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n report?: PluginInstallReporter,\n ) {\n if (typeof input !== 'string') {\n throw new TypeError('marketplace resolver requires a plugin catalog id')\n }\n const plugin = pluginCatalogIdFromInstallInput(input)\n if (!plugin) throw new TypeError('marketplace resolver requires a plugin catalog id')\n const redirected = await this.catalog.resolveInstallInput(plugin, signal)\n const resolver = this.sources.find(source => source.matches(redirected))\n if (!resolver)\n throw new Error(`plugin catalog returned an unsupported install source: ${redirected}`)\n const source = await resolver.resolve(redirected, signal, report)\n return { ...source, installInput: input, resolverId: this.id }\n }\n}","import { convertFileSrc, isTauri } from '@tauri-apps/api/core'\n\nimport type { PluginFileReplacement, PluginFileStore } from '../install'\nimport { safePluginPath } from '../install'\n\ntype PluginFiles = ReadonlyMap<string, Uint8Array>\n\ninterface PluginFileBackend {\n read(plugin: string, path: string): Promise<Uint8Array>\n snapshot(plugin: string): Promise<Map<string, Uint8Array>>\n replace(plugin: string, files: PluginFiles): Promise<void>\n moduleUrl?(plugin: string, path: string): Promise<string>\n}\n\nconst cloneFiles = (files: PluginFiles) =>\n new Map([...files].map(([path, bytes]) => [path, Uint8Array.from(bytes)]))\n\nconst mimeType = (path: string) =>\n ({\n avif: 'image/avif',\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n jpg: 'image/jpeg',\n png: 'image/png',\n svg: 'image/svg+xml',\n webp: 'image/webp',\n })[path.split('.').at(-1)?.toLowerCase() ?? ''] ?? 'application/octet-stream'\n\nexport const createPluginProtocolUrl = (plugin: string, path: string) => {\n const base = convertFileSrc('', 'plugin')\n const encodedPath = safePluginPath(path, 'plugin protocol path')\n .split('/')\n .map(encodeURIComponent)\n .join('/')\n return `${base}${encodeURIComponent(plugin)}/${encodedPath}`\n}\n\nexport class MemoryPluginFileStore implements PluginFileStore {\n readonly #files = new Map<string, Map<string, Uint8Array>>()\n readonly #urls = new Map<string, Set<string>>()\n\n public async replace(plugin: string, files: PluginFiles): Promise<PluginFileReplacement> {\n const previous = cloneFiles(this.#files.get(plugin) ?? new Map())\n this.#files.set(plugin, cloneFiles(files))\n let settled = false\n return {\n commit: async () => {\n settled = true\n },\n rollback: async () => {\n if (settled) return\n settled = true\n this.#files.set(plugin, previous)\n },\n }\n }\n\n public async remove(plugin: string) {\n this.release(plugin)\n this.#files.delete(plugin)\n }\n\n public async read(plugin: string, path: string) {\n const bytes = this.#files.get(plugin)?.get(safePluginPath(path, 'plugin file path'))\n if (!bytes) throw new Error(`plugin file not found: ${plugin}/${path}`)\n return Uint8Array.from(bytes)\n }\n\n public async createModuleUrl(plugin: string, path: string) {\n return await this.#createUrl(plugin, path, 'text/javascript')\n }\n\n public async createAssetUrl(plugin: string, path: string) {\n return await this.#createUrl(plugin, path, mimeType(path))\n }\n\n async #createUrl(plugin: string, path: string, type: string) {\n const bytes = await this.read(plugin, path)\n const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes)], { type }))\n const urls = this.#urls.get(plugin) ?? new Set<string>()\n urls.add(url)\n this.#urls.set(plugin, urls)\n return url\n }\n\n public release(plugin: string) {\n for (const url of this.#urls.get(plugin) ?? []) URL.revokeObjectURL(url)\n this.#urls.delete(plugin)\n }\n}\n\nclass IndexedDbPluginFileBackend implements PluginFileBackend {\n readonly #database = 'delta-comic-plugin-files-v2'\n readonly #store = 'files'\n\n async #open() {\n return await new Promise<IDBDatabase>((resolve, reject) => {\n const request = indexedDB.open(this.#database, 1)\n request.onupgradeneeded = () => {\n if (!request.result.objectStoreNames.contains(this.#store)) {\n request.result.createObjectStore(this.#store)\n }\n }\n request.onsuccess = () => resolve(request.result)\n request.onerror = () => reject(request.error)\n })\n }\n\n #key(plugin: string, path: string) {\n return `${plugin}/${path}`\n }\n\n public async read(plugin: string, path: string) {\n const database = await this.#open()\n try {\n return await new Promise<Uint8Array>((resolve, reject) => {\n const transaction = database.transaction(this.#store, 'readonly')\n const request = transaction.objectStore(this.#store).get(this.#key(plugin, path))\n request.onsuccess = () => {\n if (!request.result) reject(new Error(`plugin file not found: ${plugin}/${path}`))\n else resolve(Uint8Array.from(request.result as Uint8Array))\n }\n request.onerror = () => reject(request.error)\n })\n } finally {\n database.close()\n }\n }\n\n public async snapshot(plugin: string) {\n const database = await this.#open()\n try {\n return await new Promise<Map<string, Uint8Array>>((resolve, reject) => {\n const files = new Map<string, Uint8Array>()\n const transaction = database.transaction(this.#store, 'readonly')\n const request = transaction.objectStore(this.#store).openCursor()\n const prefix = `${plugin}/`\n request.onsuccess = () => {\n const cursor = request.result\n if (!cursor) return\n const key = String(cursor.key)\n if (key.startsWith(prefix))\n files.set(key.slice(prefix.length), Uint8Array.from(cursor.value))\n cursor.continue()\n }\n request.onerror = () => reject(request.error)\n transaction.oncomplete = () => resolve(files)\n transaction.onerror = () => reject(transaction.error)\n })\n } finally {\n database.close()\n }\n }\n\n public async replace(plugin: string, files: PluginFiles) {\n const database = await this.#open()\n try {\n await new Promise<void>((resolve, reject) => {\n const transaction = database.transaction(this.#store, 'readwrite')\n const store = transaction.objectStore(this.#store)\n const prefix = `${plugin}/`\n const cursor = store.openKeyCursor()\n cursor.onsuccess = () => {\n if (cursor.result) {\n if (String(cursor.result.key).startsWith(prefix)) cursor.result.delete()\n cursor.result.continue()\n return\n }\n for (const [path, bytes] of files) store.put(bytes, this.#key(plugin, path))\n }\n cursor.onerror = () => reject(cursor.error)\n transaction.oncomplete = () => resolve()\n transaction.onerror = () => reject(transaction.error)\n transaction.onabort = () => reject(transaction.error)\n })\n } finally {\n database.close()\n }\n }\n}\n\nclass TauriPluginFileBackend implements PluginFileBackend {\n async #root(plugin: string) {\n const { appLocalDataDir, join } = await import('@tauri-apps/api/path')\n return await join(await appLocalDataDir(), 'plugin', plugin)\n }\n\n public async read(plugin: string, path: string) {\n const [{ join }, fs] = await Promise.all([\n import('@tauri-apps/api/path'),\n import('@tauri-apps/plugin-fs'),\n ])\n return await fs.readFile(await join(await this.#root(plugin), path))\n }\n\n public async snapshot(plugin: string) {\n const [{ join }, fs] = await Promise.all([\n import('@tauri-apps/api/path'),\n import('@tauri-apps/plugin-fs'),\n ])\n const root = await this.#root(plugin)\n const files = new Map<string, Uint8Array>()\n if (!(await fs.exists(root))) return files\n const visit = async (directory: string, prefix = '') => {\n for (const entry of await fs.readDir(directory)) {\n const path = prefix ? `${prefix}/${entry.name}` : entry.name\n const absolute = await join(directory, entry.name)\n if (entry.isDirectory) await visit(absolute, path)\n else if (entry.isFile) files.set(path, await fs.readFile(absolute))\n }\n }\n await visit(root)\n return files\n }\n\n public async replace(plugin: string, files: PluginFiles) {\n const [{ appLocalDataDir, join }, fs] = await Promise.all([\n import('@tauri-apps/api/path'),\n import('@tauri-apps/plugin-fs'),\n ])\n const appData = await appLocalDataDir()\n const base = await join(appData, 'plugin')\n const token = crypto.randomUUID()\n const live = await join(base, plugin)\n const stagingRoot = await join(appData, 'plugin-staging')\n const backupRoot = await join(appData, 'plugin-backup')\n const staging = await join(stagingRoot, `${plugin}-${token}`)\n const backup = await join(backupRoot, `${plugin}-${token}`)\n await fs.mkdir(staging, { recursive: true })\n try {\n for (const [path, bytes] of files) {\n const segments = safePluginPath(path, 'plugin file path').split('/')\n const target = await join(staging, ...segments)\n const parent = await join(staging, ...segments.slice(0, -1))\n await fs.mkdir(parent, { recursive: true })\n await fs.writeFile(target, bytes)\n }\n const existed = await fs.exists(live)\n if (existed) {\n await fs.mkdir(backupRoot, { recursive: true })\n await fs.rename(live, backup)\n }\n try {\n await fs.rename(staging, live)\n } catch (error) {\n if (existed && (await fs.exists(backup))) await fs.rename(backup, live)\n throw error\n }\n if (await fs.exists(backup)) {\n await fs.remove(backup, { recursive: true }).catch(() => undefined)\n }\n } catch (error) {\n if (await fs.exists(staging)) await fs.remove(staging, { recursive: true })\n throw error\n }\n }\n\n public async moduleUrl(plugin: string, path: string) {\n return createPluginProtocolUrl(plugin, path)\n }\n}\n\nexport class AtomicPluginFileStore implements PluginFileStore {\n readonly #moduleVersions = new Map<string, number>()\n readonly #urls = new Map<string, Set<string>>()\n\n public constructor(private readonly backend: PluginFileBackend) {}\n\n public async replace(plugin: string, files: PluginFiles) {\n this.#moduleVersions.set(plugin, (this.#moduleVersions.get(plugin) ?? 0) + 1)\n const previous = await this.backend.snapshot(plugin)\n await this.backend.replace(plugin, files)\n let settled = false\n return {\n commit: async () => {\n settled = true\n },\n rollback: async () => {\n if (settled) return\n settled = true\n await this.backend.replace(plugin, previous)\n },\n }\n }\n\n public async remove(plugin: string) {\n this.#moduleVersions.set(plugin, (this.#moduleVersions.get(plugin) ?? 0) + 1)\n this.release(plugin)\n await this.backend.replace(plugin, new Map())\n }\n\n public read(plugin: string, path: string) {\n return this.backend.read(plugin, safePluginPath(path, 'plugin file path'))\n }\n\n public async createModuleUrl(plugin: string, path: string) {\n const safePath = safePluginPath(path, 'plugin module path')\n if (this.backend.moduleUrl) {\n // The protocol URL is stable, so bust the module cache on every file replacement so a\n // hot reload always evaluates the current files instead of the previously imported module.\n const version = this.#moduleVersions.get(plugin) ?? 0\n return `${await this.backend.moduleUrl(plugin, safePath)}?v=${version}`\n }\n const bytes = await this.backend.read(plugin, safePath)\n const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes)], { type: 'text/javascript' }))\n const urls = this.#urls.get(plugin) ?? new Set<string>()\n urls.add(url)\n this.#urls.set(plugin, urls)\n return url\n }\n\n public async createAssetUrl(plugin: string, path: string) {\n const safePath = safePluginPath(path, 'plugin asset path')\n if (this.backend.moduleUrl) return await this.backend.moduleUrl(plugin, safePath)\n const bytes = await this.backend.read(plugin, safePath)\n const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes)], { type: mimeType(path) }))\n const urls = this.#urls.get(plugin) ?? new Set<string>()\n urls.add(url)\n this.#urls.set(plugin, urls)\n return url\n }\n\n public release(plugin: string) {\n for (const url of this.#urls.get(plugin) ?? []) URL.revokeObjectURL(url)\n this.#urls.delete(plugin)\n }\n}\n\nexport const createDefaultPluginFileStore = () =>\n new AtomicPluginFileStore(\n isTauri() ? new TauriPluginFileBackend() : new IndexedDbPluginFileBackend(),\n )","import { defaultsDeep } from 'es-toolkit/compat'\n\nimport type { PluginLocaleMessage, PluginLocaleMessages } from '../api/i18n'\n\nexport type { PluginLocaleMessage, PluginLocaleMessages } from '../api/i18n'\n\nexport interface PluginI18nAdapter {\n setLocaleMessage(locale: string, message: PluginLocaleMessage): void\n translate?(key: string, params?: Record<string, number | string>): string\n /** 判断消息是否已注册(建议覆盖回退语言链),用于解析宿主渲染的展示文本。 */\n has?(key: string): boolean\n}\n\nexport class PluginI18nRegistry {\n private adapter?: PluginI18nAdapter\n private baseMessages: PluginLocaleMessages = {}\n private readonly pluginMessages = new Map<string, PluginLocaleMessages>()\n\n public install(adapter: PluginI18nAdapter, baseMessages: PluginLocaleMessages) {\n this.adapter = adapter\n this.baseMessages = baseMessages\n this.refresh(this.locales())\n }\n\n public register(plugin: string, messages: PluginLocaleMessages) {\n const previous = this.pluginMessages.get(plugin) ?? {}\n const merged: PluginLocaleMessages = defaultsDeep({}, messages, previous)\n this.pluginMessages.set(plugin, merged)\n this.refresh(new Set([...Object.keys(previous), ...Object.keys(messages)]))\n }\n\n public remove(plugin: string) {\n const messages = this.pluginMessages.get(plugin)\n if (!messages) return\n this.pluginMessages.delete(plugin)\n this.refresh(new Set(Object.keys(messages)))\n }\n\n /**\n * 立即翻译一个 i18n key,供插件在自己的运行时回调中使用;\n * 未注册或没有适配器时返回 key 本身。\n */\n public translate(key: string, params?: Record<string, number | string>) {\n return this.adapter?.translate?.(key, params) ?? key\n }\n\n /**\n * 解析插件提供的展示文本:命中已注册的普通 i18n key 时翻译,\n * 否则按字面文本原样返回。宿主渲染的插件字符串字段\n * (如 `Selection.name`、清单展示名)都应经过本方法。\n */\n public translateText(value: string) {\n if (this.adapter?.has?.(value)) return this.translate(value)\n return value\n }\n\n private compose(locale: string) {\n const message: PluginLocaleMessage = {}\n defaultsDeep(message, this.baseMessages[locale])\n for (const messages of this.pluginMessages.values()) defaultsDeep(message, messages[locale])\n return message\n }\n\n private locales() {\n const locales = new Set(Object.keys(this.baseMessages))\n for (const messages of this.pluginMessages.values()) {\n for (const locale of Object.keys(messages)) locales.add(locale)\n }\n return locales\n }\n\n private refresh(locales: Iterable<string>) {\n if (!this.adapter) return\n for (const locale of locales) this.adapter.setLocaleMessage(locale, this.compose(locale))\n }\n}\n\nexport const pluginI18n = new PluginI18nRegistry()","","export const pluginName = 'core'","import { ConfigPointer } from '../api/config'\n\nimport { pluginName } from './env'\n\nexport const cfg = new ConfigPointer(\n pluginName,\n {\n recordHistory: { type: 'switch', defaultValue: true, info: 'plugin.core.config.recordHistory' },\n showAIProject: { type: 'switch', defaultValue: true, info: 'plugin.core.config.showAiWorks' },\n darkMode: {\n type: 'radio',\n defaultValue: 'system',\n info: 'plugin.core.config.theme.title',\n comp: 'select',\n selects: [\n { label: 'plugin.core.config.theme.light', value: 'light' },\n { label: 'plugin.core.config.theme.dark', value: 'dark' },\n { label: 'plugin.core.config.systemDefault', value: 'system' },\n ],\n },\n easilyTitle: {\n type: 'switch',\n defaultValue: false,\n info: 'plugin.core.config.simplifiedTitle',\n },\n githubToken: {\n type: 'string',\n defaultValue: '',\n info: 'plugin.core.config.githubToken.title',\n placeholder: 'plugin.core.config.githubToken.placeholder',\n },\n receivePerReleaseUpdate: {\n type: 'switch',\n defaultValue: false,\n info: 'plugin.core.config.prereleaseUpdates',\n },\n cloudEnabled: { type: 'switch', defaultValue: false, info: 'plugin.core.config.cloud.enabled' },\n cloudServerUrl: {\n type: 'string',\n defaultValue: '',\n info: 'plugin.core.config.cloud.serverUrl',\n placeholder: 'plugin.core.config.cloud.serverUrlPlaceholder',\n },\n installOverride: {\n type: 'pairs',\n defaultValue: [],\n info: 'plugin.core.config.installOverride',\n required: true,\n },\n },\n 'plugin.core.config.name',\n)","import type { PluginLocaleMessages } from '../api/i18n'\n\nexport const coreI18n: PluginLocaleMessages = {\n 'zh-CN': {\n plugin: {\n core: {\n config: {\n name: '核心',\n recordHistory: '记录历史记录',\n showAiWorks: '展示 AI 作品',\n theme: { title: '外观模式', light: '浅色', dark: '深色' },\n systemDefault: '跟随系统',\n simplifiedTitle: '简化标题(实验性功能)',\n githubToken: { title: 'GitHub Token', placeholder: '仅用于提高 API 访问限额' },\n prereleaseUpdates: '接收预发布版本更新(可能不稳定)',\n cloud: {\n enabled: '启用云服务',\n serverUrl: '云服务地址',\n serverUrlPlaceholder: '启用云服务后填写服务地址',\n },\n installOverride: '安装源覆盖配置',\n },\n },\n },\n },\n}","import { UniContentPage } from '@delta-comic/model'\nimport { SharedFunction } from '@delta-comic/utils'\nimport { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string'\n\nimport { pluginI18n } from '../adapters'\nimport type { Social } from '../api'\n\ninterface CorePluginTokenShareMeta {\n item: { name: string; contentType: string; ep: string }\n plugin: string\n id: string\n}\n\nexport const tokenInit: Social.InitiativeItem = {\n filter: page => !!page.preload,\n icon: {},\n key: 'token',\n name: 'plugin.share.copyToken',\n async call(page) {\n const item = page.preload?.toJSON()\n if (!item) throw new Error('Not found preload in content. Maybe not fetch detail?')\n\n const compressed = compressToEncodedURIComponent(\n JSON.stringify(<CorePluginTokenShareMeta>{\n item: {\n contentType: UniContentPage.contentPages.key.toString(item.contentType),\n ep: item.thisEp.id,\n name: item.title,\n },\n plugin: page.plugin,\n id: page.id,\n }),\n )\n return { token: `[${item.title}](复制这条口令,打开Delta Comic)${compressed}` }\n },\n}\n\nexport const nativeInit: Social.InitiativeItem = {\n filter: page => !!page.preload,\n icon: {},\n key: 'native',\n name: 'plugin.share.native',\n async call(page) {\n const item = page.preload?.toJSON()\n if (!item) throw new Error('Not found preload in content. Maybe not fetch detail?')\n\n const compressed = compressToEncodedURIComponent(\n JSON.stringify(<CorePluginTokenShareMeta>{\n item: {\n contentType: UniContentPage.contentPages.key.toString(item.contentType),\n ep: item.thisEp.id,\n name: item.title,\n },\n plugin: page.plugin,\n id: page.id,\n }),\n )\n const token = `[${item.title}](复制这条口令,打开Delta Comic)${compressed}`\n await navigator.share({ title: pluginI18n.translate('plugin.share.nativeTitle'), text: token })\n\n return { token }\n },\n}\n\nexport const tokenShare: Social.ShareToken = {\n key: 'token',\n name: 'plugin.share.defaultToken',\n isMatched(chipboard) {\n return /^\\[.+\\]\\(复制这条口令,打开Delta Comic\\).+/.test(chipboard)\n },\n async show(chipboard) {\n // const pluginStore = usePluginStore()\n const meta: CorePluginTokenShareMeta = JSON.parse(\n decompressFromEncodedURIComponent(\n chipboard.replace(/^\\[.+\\]/, '').replaceAll('(复制这条口令,打开Delta Comic)', ''),\n ),\n )\n return {\n title: pluginI18n.translate('plugin.share.tokenTitle'),\n detail: pluginI18n.translate('plugin.share.tokenDetail', { item: meta.item.name }),\n onNegative() {},\n onPositive() {\n return SharedFunction.call(\n 'routeToContent',\n UniContentPage.contentPages.key.toJSON(meta.item.contentType),\n meta.id,\n meta.item.ep,\n )\n },\n }\n },\n}","import { defineDeltaComicPlugin } from '../api'\n\nexport { cfg } from './config'\n\nimport { pluginName } from './env'\nimport { coreI18n } from './i18n'\nimport { tokenInit, nativeInit, tokenShare } from './share'\n\nexport default defineDeltaComicPlugin(() => ({\n name: pluginName,\n i18n: coreI18n,\n model: { social: { share: { initiative: [tokenInit, nativeInit], tokenListen: [tokenShare] } } },\n}))","import pkg from '../../package.json'\nimport { DELTA_COMIC_PLUGIN_API_VERSION } from '../api'\nimport CorePlugin from '../core'\nimport { defineInternalPlugin } from '../kernel'\n\nexport const corePluginDefinition = defineInternalPlugin({\n canDisable: false,\n factory: CorePlugin,\n manifest: {\n apiVersion: DELTA_COMIC_PLUGIN_API_VERSION,\n author: 'Delta Comic',\n description: 'Delta Comic host capabilities',\n name: { display: 'core', id: 'core' },\n require: [],\n version: { plugin: pkg.version, supportCore: '*' },\n },\n})\n\nexport default corePluginDefinition","import type { InternalPluginDefinition } from '../kernel'\n\nexport * from './core.builtin'\n\nconst builtinModules = import.meta.glob<{ default: InternalPluginDefinition }>('./*.builtin.ts', {\n eager: true,\n})\n\n/** Files are the registration boundary: adding a built-in does not change the composition root. */\nexport const internalPluginDefinitions = Object.entries(builtinModules)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, module]) => {\n if (!module.default)\n throw new Error(`built-in plugin module has no default definition: ${path}`)\n return module.default\n })","import { shallowReactive, type Raw } from 'vue'\n\nimport type { DCPluginConfig } from '../api'\nimport type { PluginCandidate } from '../kernel'\n\nexport class PluginStore {\n private readonly candidateEntries = shallowReactive(new Map<string, PluginCandidate>())\n private readonly loadingEntries = shallowReactive(new Map<string, Raw<DCPluginConfig>>())\n private readonly pluginEntries = shallowReactive(new Map<string, Raw<DCPluginConfig>>())\n private readonly readyEntries = shallowReactive(new Set<string>())\n\n public constructor(private readonly translateText: (value: string) => string = value => value) {}\n\n public get candidates(): ReadonlyMap<string, PluginCandidate> {\n return this.candidateEntries\n }\n\n public get loading(): ReadonlyMap<string, Raw<DCPluginConfig>> {\n return this.loadingEntries\n }\n\n public get plugins(): ReadonlyMap<string, Raw<DCPluginConfig>> {\n return this.pluginEntries\n }\n\n public get ready(): ReadonlySet<string> {\n return this.readyEntries\n }\n\n public replaceCandidates(candidates: readonly PluginCandidate[]) {\n this.candidateEntries.clear()\n for (const candidate of candidates) {\n this.candidateEntries.set(candidate.manifest.name.id, candidate)\n }\n }\n\n public markLoading(plugin: string, config: Raw<DCPluginConfig>) {\n this.readyEntries.delete(plugin)\n this.loadingEntries.set(plugin, config)\n this.pluginEntries.delete(plugin)\n }\n\n public markReady(plugin: string) {\n const config = this.loadingEntries.get(plugin)\n if (!config) throw new Error(`plugin \"${plugin}\" was not marked as loading`)\n this.loadingEntries.delete(plugin)\n this.pluginEntries.set(plugin, config)\n this.readyEntries.add(plugin)\n }\n\n public markUnloaded(plugin: string) {\n this.readyEntries.delete(plugin)\n this.loadingEntries.delete(plugin)\n this.pluginEntries.delete(plugin)\n }\n\n public isLoaded(plugin: string) {\n return this.readyEntries.has(plugin)\n }\n\n public displayName(plugin: string) {\n return this.translateText(this.candidateEntries.get(plugin)?.manifest.name.display ?? plugin)\n }\n\n public modelEntries<K extends keyof NonNullable<DCPluginConfig['model']>>(key: K) {\n type Model = NonNullable<NonNullable<DCPluginConfig['model']>[K]>\n return [...this.pluginEntries].flatMap(([plugin, config]) => {\n const model = config.model?.[key]\n return model === undefined ? [] : ([[plugin, model]] as [string, Model][])\n })\n }\n}","import { logger } from '@delta-comic/logger'\nimport { markRaw, ref, shallowReactive, type App, type Raw, type Ref } from 'vue'\n\nimport type { ConfigEnv, DCPluginConfig, PluginLocaleMessages } from '../api'\nimport {\n ActivationPipeline,\n planPluginDependencies,\n PluginScope,\n type CapabilityModule,\n type LoadedPluginModule,\n type PluginCandidate,\n type PluginCandidateProvider,\n} from '../kernel'\n\nimport { PluginStore } from './store'\n\nexport interface PluginLoadingInfo {\n progress: {\n errorReason?: string\n status: 'done' | 'error' | 'process' | 'wait'\n stepsIndex: number\n }\n steps: { description: string; name: string }[]\n}\n\nexport interface PluginRuntimeFailure {\n readonly error: unknown\n readonly phase: 'normal' | 'preload'\n readonly plugin: string\n}\n\nexport interface PluginRuntimeReport {\n readonly activated: string[]\n readonly failures: PluginRuntimeFailure[]\n}\n\nexport interface PluginRuntimeOperation {\n readonly operation: Promise<PluginRuntimeReport>\n readonly progress: Ref<Record<string, PluginLoadingInfo>>\n}\n\nexport interface LoadNormalOptions {\n readonly pluginNames?: readonly string[]\n}\n\nexport interface PluginPreloadRecovery {\n failedAt: number\n plugins: string[]\n reason: string\n}\n\nexport interface PluginRuntimeOptions {\n readonly capabilities: () => readonly CapabilityModule[]\n readonly environment: () => ConfigEnv\n readonly provider: PluginCandidateProvider\n readonly remove: (plugin: string) => Promise<void>\n readonly store?: PluginStore\n readonly services?: {\n readonly i18n?: {\n register(plugin: string, messages: PluginLocaleMessages): void\n remove(plugin: string): void\n }\n }\n}\n\ninterface PreparedPlugin {\n readonly candidate: PluginCandidate\n readonly config: Raw<DCPluginConfig>\n readonly module: LoadedPluginModule\n readonly scope: PluginScope\n}\n\nconst recoveryKey = 'delta-comic:plugin-preload-recovery:v1'\nconst runtimeLogger = logger.scoped('plugin:runtime')\n\nconst errorText = (error: unknown) => (error instanceof Error ? error.message : String(error))\n\nconst joinErrorMessages = (errors: readonly unknown[]) =>\n errors\n .map(error => errorText(error))\n .filter(Boolean)\n .join('; ')\n\nconst loadingInfo = (): PluginLoadingInfo => ({\n progress: { status: 'wait', stepsIndex: 0 },\n steps: [{ description: '', name: 'waiting' }],\n})\n\nexport class PluginRuntime {\n readonly #activeNormal = new Map<string, PluginScope>()\n readonly #options: PluginRuntimeOptions\n readonly #prepared = new Map<string, PreparedPlugin>()\n #app?: App\n #booted = false\n #normalOperation?: Promise<PluginRuntimeReport>\n #preloadOperation?: Promise<PluginRuntimeReport>\n #preloadReport?: PluginRuntimeReport\n\n public readonly restartRequired = shallowReactive(new Set<string>())\n public readonly store: PluginStore\n\n public constructor(options: PluginRuntimeOptions) {\n this.#options = options\n this.store = options.store ?? new PluginStore()\n }\n\n public get activeNormalPluginNames() {\n return [...this.#activeNormal.keys()]\n }\n\n public async preload(app: App) {\n if (this.#preloadReport) return this.#preloadReport\n if (this.#preloadOperation) return await this.#preloadOperation\n this.#app = app\n const operation = this.#prepareEnabledPlugins(app)\n this.#preloadOperation = operation\n try {\n const report = await operation\n this.#preloadReport = report\n if (report.failures.length > 0) this.#writeRecovery(report.failures)\n else this.clearRecovery()\n return report\n } finally {\n this.#preloadOperation = undefined\n }\n }\n\n public loadNormal(options: LoadNormalOptions = {}): PluginRuntimeOperation {\n if (!this.#preloadReport) throw new Error('plugins must be preloaded before normal activation')\n if (this.#normalOperation) throw new Error('plugin normal parts are already loading')\n if (this.activeNormalPluginNames.length > 0) {\n throw new Error('plugin normal parts are already active; use reloadNormal()')\n }\n const progress = ref<Record<string, PluginLoadingInfo>>({})\n const operation = this.#loadNormal(progress, options.pluginNames)\n this.#track(operation)\n return { operation, progress }\n }\n\n public reloadNormal(options: LoadNormalOptions = {}): PluginRuntimeOperation {\n if (!this.#preloadReport) throw new Error('plugins must be preloaded before normal activation')\n if (this.#normalOperation) throw new Error('plugin normal parts are already loading')\n const progress = ref<Record<string, PluginLoadingInfo>>({})\n const operation = (async () => {\n await this.#unloadNormal()\n return await this.#loadNormal(progress, options.pluginNames)\n })()\n this.#track(operation)\n return { operation, progress }\n }\n\n public markRestartRequired(plugin: string) {\n this.restartRequired.add(plugin)\n }\n\n /** Prepare a plugin that was enabled after startup and activate it once normal parts are booted. */\n public async enablePlugin(plugin: string) {\n await this.enablePlugins([plugin])\n }\n\n /**\n * Prepare every given plugin, plus any enabled requirement that is not prepared yet, in\n * dependency order, and activate their normal parts once the application is booted.\n */\n public async enablePlugins(plugins: readonly string[]) {\n this.#assertReadyForToggle()\n const targets = new Map<string, PluginCandidate>()\n const visit = (plugin: string) => {\n if (targets.has(plugin)) return\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n if (!candidate.enabled) throw new Error(`plugin \"${plugin}\" is not enabled`)\n targets.set(plugin, candidate)\n for (const dependency of candidate.manifest.require) visit(dependency.id)\n }\n for (const plugin of plugins) visit(plugin)\n\n const plan = planPluginDependencies([...targets.values()])\n if (plan.cycles.length > 0) {\n const cycles = plan.cycles.map(cycle => cycle.join(' -> ')).join('; ')\n throw new Error(`cannot enable plugins: dependency cycles: ${cycles}`)\n }\n\n for (const level of plan.levels) {\n for (const candidate of level) {\n const plugin = candidate.manifest.name.id\n const prepared = this.#prepared.get(plugin)\n if (prepared) {\n if (this.#booted && !this.#activeNormal.has(plugin)) {\n const result = await this.#activateNormal(prepared)\n if (result.error !== undefined) throw this.#activationFailure(plugin, result)\n }\n continue\n }\n await this.#prepareAndActivate(candidate)\n }\n }\n }\n\n /**\n * Unload a plugin together with its prepared dependents, then reload it from its current files\n * so an install or update takes effect without an application restart.\n */\n public async reloadPlugin(plugin: string) {\n this.#assertReadyForToggle()\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n\n const affected: string[] = []\n const visited = new Set<string>()\n const collectDependents = (id: string) => {\n if (visited.has(id)) return\n visited.add(id)\n for (const [name, prepared] of this.#prepared) {\n if (prepared.candidate.manifest.require.some(dependency => dependency.id === id)) {\n collectDependents(name)\n }\n }\n if (id !== plugin) affected.push(id)\n }\n collectDependents(plugin)\n\n const errors: unknown[] = []\n for (const id of [...affected, plugin]) {\n const active = this.#activeNormal.get(id)\n if (active) {\n try {\n await this.#deactivateNormal(id, active)\n } catch (error) {\n errors.push(error)\n }\n }\n const prepared = this.#prepared.get(id)\n if (prepared) {\n this.#prepared.delete(id)\n try {\n await prepared.scope.dispose()\n } catch (error) {\n errors.push(error)\n }\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(\n errors,\n `failed to unload plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n if (candidate.enabled) await this.enablePlugins([plugin, ...affected])\n }\n\n /** Deactivate and unload a plugin so disabling it takes effect without a restart. */\n public async disablePlugin(plugin: string) {\n this.#assertReadyForToggle()\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n if (!candidate.management.canDisable) throw new Error(`plugin \"${plugin}\" cannot be disabled`)\n const dependents = [...this.#prepared.entries()]\n .filter(([, prepared]) =>\n prepared.candidate.manifest.require.some(dependency => dependency.id === plugin),\n )\n .map(([id]) => id)\n if (dependents.length > 0) {\n throw new Error(`cannot disable plugin \"${plugin}\": required by ${dependents.join(', ')}`)\n }\n\n const errors: unknown[] = []\n const active = this.#activeNormal.get(plugin)\n if (active) {\n try {\n await this.#deactivateNormal(plugin, active)\n } catch (error) {\n errors.push(error)\n }\n }\n const prepared = this.#prepared.get(plugin)\n if (prepared) {\n this.#prepared.delete(plugin)\n try {\n await prepared.scope.dispose()\n } catch (error) {\n errors.push(error)\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(\n errors,\n `failed to disable plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n }\n\n async #prepareAndActivate(candidate: PluginCandidate) {\n const plugin = candidate.manifest.name.id\n const app = this.#app\n if (!app) throw new Error('plugins must be preloaded before enabling a plugin')\n const scope = new PluginScope(plugin)\n try {\n const { config, module } = await this.#loadPlugin(candidate, scope)\n const cleanup = await config.hooks?.onPreboot?.({ app })\n if (cleanup) scope.defer(cleanup)\n const prepared: PreparedPlugin = { candidate, config, module, scope }\n this.#prepared.set(plugin, prepared)\n if (this.#booted) {\n const result = await this.#activateNormal(prepared)\n if (result.error !== undefined) throw this.#activationFailure(plugin, result)\n }\n } catch (error) {\n this.#prepared.delete(plugin)\n const errors: unknown[] = this.#flattenErrors(error)\n const disposeError = await scope.dispose(error).catch(caught => caught)\n if (disposeError !== undefined) errors.push(...this.#flattenErrors(disposeError))\n throw new AggregateError(\n errors,\n `failed to enable plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n }\n\n #assertReadyForToggle() {\n if (!this.#preloadReport) {\n throw new Error('plugins must be preloaded before enabling or disabling a plugin')\n }\n if (this.#normalOperation) throw new Error('plugin normal parts are currently loading')\n }\n\n #flattenErrors(error: unknown): unknown[] {\n return error instanceof AggregateError ? [...error.errors] : [error]\n }\n\n #activationFailure(\n plugin: string,\n result: { error?: unknown; disposeError?: unknown },\n ): AggregateError {\n const errors = result.error === undefined ? [] : this.#flattenErrors(result.error)\n if (result.disposeError !== undefined) errors.push(...this.#flattenErrors(result.disposeError))\n return new AggregateError(\n errors,\n `failed to activate plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n\n public async uninstall(plugin: string) {\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n if (!candidate.management.canUninstall) {\n throw new Error(`plugin \"${plugin}\" cannot be uninstalled`)\n }\n\n const active = this.#activeNormal.get(plugin)\n if (active) await this.#deactivateNormal(plugin, active)\n const prepared = this.#prepared.get(plugin)\n if (prepared) {\n this.#prepared.delete(plugin)\n await prepared.scope.dispose()\n } else {\n try {\n await this.#runUninstallHook(candidate)\n } catch (error) {\n runtimeLogger.warn(`failed to run uninstall hook for plugin \"${plugin}\"`, error)\n }\n }\n this.restartRequired.delete(plugin)\n await this.#options.remove(plugin)\n await this.refreshCandidates()\n }\n\n public async refreshCandidates() {\n const candidates = await this.#options.provider.list(new AbortController().signal)\n this.store.replaceCandidates(candidates)\n return candidates\n }\n\n public readRecovery(): PluginPreloadRecovery | null {\n try {\n const value = globalThis.localStorage?.getItem(recoveryKey)\n return value ? (JSON.parse(value) as PluginPreloadRecovery) : null\n } catch {\n return null\n }\n }\n\n public clearRecovery() {\n try {\n globalThis.localStorage?.removeItem(recoveryKey)\n } catch {}\n }\n\n async #prepareEnabledPlugins(app: App): Promise<PluginRuntimeReport> {\n const candidates = (await this.refreshCandidates()).filter(candidate => candidate.enabled)\n const plan = planPluginDependencies(candidates)\n\n const activated: string[] = []\n const failures: PluginRuntimeFailure[] = plan.missing.map(({ dependency, plugin }) => ({\n error: new Error(`missing dependency: ${dependency}`),\n phase: 'preload',\n plugin,\n }))\n for (const cycle of plan.cycles) {\n const error = new Error(`dependency cycle: ${cycle.join(' -> ')}`)\n for (const plugin of cycle.slice(0, -1)) failures.push({ error, phase: 'preload', plugin })\n }\n const failed = new Set(failures.map(value => value.plugin))\n for (const level of plan.levels) {\n for (const candidate of level) {\n const plugin = candidate.manifest.name.id\n if (failed.has(plugin)) continue\n const blockedBy = candidate.manifest.require\n .map(value => value.id)\n .filter(dependency => failed.has(dependency))\n if (blockedBy.length > 0) {\n failures.push({\n error: new Error(`dependency preload failed: ${blockedBy.join(', ')}`),\n phase: 'preload',\n plugin,\n })\n failed.add(plugin)\n continue\n }\n\n const scope = new PluginScope(plugin)\n try {\n const { config, module } = await this.#loadPlugin(candidate, scope)\n const cleanup = await config.hooks?.onPreboot?.({ app })\n if (cleanup) scope.defer(cleanup)\n\n // Register i18n during preload so config forms and host UI can translate immediately.\n if (this.#options.services?.i18n && config.i18n) {\n this.#options.services.i18n.register(plugin, config.i18n)\n scope.defer(() => this.#options.services!.i18n!.remove(plugin))\n }\n\n this.#prepared.set(plugin, { candidate, config, module, scope })\n activated.push(plugin)\n } catch (error) {\n failures.push({ error, phase: 'preload', plugin })\n failed.add(plugin)\n await scope.dispose(error).catch(disposeError => {\n failures.push({ error: disposeError, phase: 'preload', plugin })\n })\n }\n }\n }\n return { activated, failures }\n }\n\n async #loadNormal(\n progress: Ref<Record<string, PluginLoadingInfo>>,\n selected?: readonly string[],\n ): Promise<PluginRuntimeReport> {\n const candidates = [...this.#prepared.values()].map(value => value.candidate)\n const mandatory = candidates\n .filter(candidate => !candidate.management.canDisable)\n .map(candidate => candidate.manifest.name.id)\n const chosen = selected\n ? this.#selectWithDependencies(candidates, [...mandatory, ...selected])\n : candidates\n const plan = planPluginDependencies(chosen)\n this.#assertValidPlan(plan)\n\n const activated: string[] = []\n const failures: PluginRuntimeFailure[] = []\n const failed = new Set<string>()\n for (const level of plan.levels) {\n for (const candidate of level) {\n const plugin = candidate.manifest.name.id\n const info = (progress.value[plugin] = loadingInfo())\n const blockedBy = candidate.manifest.require\n .map(value => value.id)\n .filter(dependency => failed.has(dependency))\n if (blockedBy.length > 0) {\n const error = new Error(`dependency activation failed: ${blockedBy.join(', ')}`)\n info.progress = { errorReason: error.message, status: 'error', stepsIndex: 0 }\n failures.push({ error, phase: 'normal', plugin })\n failed.add(plugin)\n continue\n }\n\n const prepared = this.#prepared.get(plugin)\n if (!prepared) continue\n const result = await this.#activateNormal(prepared, info)\n if (result.error === undefined) {\n activated.push(plugin)\n continue\n }\n failures.push({ error: result.error, phase: 'normal', plugin })\n failed.add(plugin)\n if (result.disposeError !== undefined) {\n failures.push({ error: result.disposeError, phase: 'normal', plugin })\n }\n }\n }\n this.#booted = true\n return { activated, failures }\n }\n\n /** Run the normal activation pipeline for a prepared plugin on a fresh normal scope. */\n async #activateNormal(\n prepared: PreparedPlugin,\n info?: PluginLoadingInfo,\n ): Promise<{ error?: unknown; disposeError?: unknown }> {\n const plugin = prepared.candidate.manifest.name.id\n const scope = new PluginScope(plugin)\n try {\n if (info) info.progress.status = 'process'\n await prepared.module.activate?.(scope)\n this.store.markLoading(plugin, prepared.config)\n scope.defer(() => this.store.markUnloaded(plugin))\n await new ActivationPipeline(this.#options.capabilities()).activate(prepared.config, {\n owner: plugin,\n report: update => {\n if (!info) return\n const value = typeof update === 'string' ? { description: update } : update\n info.steps[0] = { ...info.steps[0], ...value }\n },\n scope,\n signal: scope.signal,\n })\n this.#activeNormal.set(plugin, scope)\n this.store.markReady(plugin)\n if (info) info.progress.status = 'done'\n return {}\n } catch (error) {\n if (info) info.progress = { errorReason: errorText(error), status: 'error', stepsIndex: 0 }\n const disposeError = await scope.dispose(error).catch(caught => caught)\n return { error, disposeError }\n }\n }\n\n async #loadPlugin(candidate: PluginCandidate, scope: PluginScope) {\n const plugin = candidate.manifest.name.id\n const loaded: LoadedPluginModule = await candidate.load(scope.signal)\n if (loaded.dispose) scope.defer(loaded.dispose)\n const config = markRaw(loaded.factory(this.#options.environment()))\n if (config.name !== plugin) throw new Error(`plugin name mismatch: ${plugin} / ${config.name}`)\n return { config, module: loaded }\n }\n\n async #runUninstallHook(candidate: PluginCandidate) {\n const plugin = candidate.manifest.name.id\n const scope = new PluginScope(plugin)\n try {\n const { config } = await this.#loadPlugin(candidate, scope)\n await config.hooks?.onUninstall?.()\n } finally {\n await scope.dispose()\n }\n }\n\n #assertValidPlan(plan: ReturnType<typeof planPluginDependencies>) {\n if (plan.missing.length === 0 && plan.cycles.length === 0) return\n const missing = plan.missing.map(value => `${value.plugin} -> ${value.dependency}`).join(', ')\n const cycles = plan.cycles.map(value => value.join(' -> ')).join(', ')\n throw new Error(\n [missing && `missing: ${missing}`, cycles && `cycles: ${cycles}`].filter(Boolean).join('; '),\n )\n }\n\n #selectWithDependencies(candidates: readonly PluginCandidate[], selected: readonly string[]) {\n const byId = new Map(candidates.map(candidate => [candidate.manifest.name.id, candidate]))\n const result = new Map<string, PluginCandidate>()\n const visit = (plugin: string) => {\n const candidate = byId.get(plugin)\n if (!candidate || result.has(plugin)) return\n for (const dependency of candidate.manifest.require) visit(dependency.id)\n result.set(plugin, candidate)\n }\n for (const plugin of selected) visit(plugin)\n return [...result.values()]\n }\n\n #track(operation: Promise<PluginRuntimeReport>) {\n this.#normalOperation = operation\n void operation.then(\n () => (this.#normalOperation = undefined),\n () => (this.#normalOperation = undefined),\n )\n }\n\n async #unloadNormal() {\n const targets = [...this.#activeNormal].reverse()\n const errors: unknown[] = []\n for (const [plugin, scope] of targets) {\n try {\n await this.#deactivateNormal(plugin, scope)\n } catch (error) {\n errors.push(error)\n }\n }\n if (errors.length > 0) throw new AggregateError(errors, 'some plugins failed to unload')\n }\n\n async #deactivateNormal(plugin: string, scope: PluginScope) {\n this.#activeNormal.delete(plugin)\n await scope.dispose()\n }\n\n #writeRecovery(failures: readonly PluginRuntimeFailure[]) {\n try {\n globalThis.localStorage?.setItem(\n recoveryKey,\n JSON.stringify({\n failedAt: Date.now(),\n plugins: failures.map(value => value.plugin),\n reason: failures.map(value => errorText(value.error)).join('\\n'),\n } satisfies PluginPreloadRecovery),\n )\n } catch {}\n }\n}","import type { InternalPluginDefinition, PluginCandidate, PluginCandidateProvider } from '../kernel'\n\nconst defaultStorage = () => {\n try {\n return globalThis.localStorage\n } catch {\n return undefined\n }\n}\n\nexport interface InternalPluginPreferences {\n enabled(plugin: string, fallback: boolean): Promise<boolean>\n setEnabled(plugin: string, enabled: boolean): Promise<void>\n}\n\nexport class LocalInternalPluginPreferences implements InternalPluginPreferences {\n public constructor(\n private readonly storage: Storage | undefined = defaultStorage(),\n private readonly prefix = 'delta-comic:internal-plugin:',\n ) {}\n\n public async enabled(plugin: string, fallback: boolean) {\n try {\n const value = this.storage?.getItem(`${this.prefix}${plugin}`)\n return value === null || value === undefined ? fallback : value === 'true'\n } catch {\n return fallback\n }\n }\n\n public async setEnabled(plugin: string, enabled: boolean) {\n try {\n this.storage?.setItem(`${this.prefix}${plugin}`, String(enabled))\n } catch {}\n }\n}\n\nexport class InternalPluginCandidateProvider implements PluginCandidateProvider {\n public readonly id = 'internal'\n\n public constructor(\n private readonly definitions: readonly InternalPluginDefinition[],\n private readonly preferences: InternalPluginPreferences = new LocalInternalPluginPreferences(),\n ) {}\n\n public async list(signal: AbortSignal) {\n const candidates: PluginCandidate[] = []\n for (const definition of this.definitions) {\n if (signal.aborted) throw signal.reason\n candidates.push({\n enabled:\n definition.canDisable === false\n ? true\n : await this.preferences.enabled(\n definition.manifest.name.id,\n definition.enabledByDefault ?? true,\n ),\n load: async () => ({ factory: definition.factory }),\n management: {\n canDisable: definition.canDisable ?? true,\n canUninstall: false,\n canUpdate: false,\n },\n manifest: definition.manifest,\n origin: 'builtin',\n })\n }\n return candidates\n }\n}\n\nexport class CompositePluginCandidateProvider implements PluginCandidateProvider {\n public readonly id = 'composite'\n\n public constructor(private readonly providers: readonly PluginCandidateProvider[]) {}\n\n public async list(signal: AbortSignal) {\n const candidates = (\n await Promise.all(this.providers.map(provider => provider.list(signal)))\n ).flat()\n const owners = new Map<string, PluginCandidate>()\n for (const candidate of candidates) {\n const id = candidate.manifest.name.id\n const previous = owners.get(id)\n if (previous) {\n if (previous.origin === 'builtin' && candidate.origin === 'installed') continue\n if (previous.origin === 'installed' && candidate.origin === 'builtin') {\n owners.set(id, candidate)\n continue\n }\n throw new Error(\n `duplicate plugin candidate \"${id}\" from ${previous.origin} and ${candidate.origin}`,\n )\n }\n owners.set(id, candidate)\n }\n return [...owners.values()]\n }\n}","import { isTauri } from '@tauri-apps/api/core'\n\nimport {\n AwesomeRegistryClient,\n ConfigStore,\n createDefaultPluginFileStore,\n pluginI18n,\n} from './adapters'\nimport { corePluginDefinition, internalPluginDefinitions } from './builtins'\nimport { createDefaultCapabilities, type PluginAuthGateway } from './capabilities'\nimport { cfg } from './core/config'\nimport {\n DatabasePluginArchiveRepository,\n DevServerPluginModuleReader,\n DevServerSourceResolver,\n DEV_SERVER_LOADER_ID,\n GitHubSourceResolver,\n HttpSourceResolver,\n InstalledPluginCandidateProvider,\n LocalFileSourceResolver,\n MarketplaceSourceResolver,\n type PluginCatalog,\n type PluginInstallReporter,\n PluginInstallService,\n safePluginPath,\n StoredPluginModuleReader,\n ZipPackageCodec,\n devServerUrl,\n parseDevServerPort,\n} from './install'\nimport { ContributionHub } from './kernel'\nimport {\n CompositePluginCandidateProvider,\n InternalPluginCandidateProvider,\n LocalInternalPluginPreferences,\n PluginRuntime,\n PluginStore,\n} from './runtime'\n\nexport const pluginContributions = new ContributionHub()\nexport const pluginStore = new PluginStore(value => pluginI18n.translateText(value))\nexport const pluginConfigStore = new ConfigStore()\nexport const useConfig = () => pluginConfigStore\n\nexport const preparePluginHost = async () => {\n await pluginConfigStore.register(cfg).ready\n}\n\nexport interface PluginHostServices {\n readonly auth?: PluginAuthGateway\n}\n\nconst pluginHostServices: PluginHostServices = {}\n\n/** Install host-only integrations without exposing UI or platform details to the runtime kernel. */\nexport const configurePluginHost = (services: PluginHostServices) => {\n Object.assign(pluginHostServices, services)\n}\n\nconst pluginFiles = createDefaultPluginFileStore()\nconst pluginRepository = new DatabasePluginArchiveRepository()\nconst pluginReaders = [new StoredPluginModuleReader(pluginFiles), new DevServerPluginModuleReader()]\nconst internalPreferences = new LocalInternalPluginPreferences()\nconst internalPluginIds = new Set(\n internalPluginDefinitions.map(definition => definition.manifest.name.id),\n)\nconst internalProvider = new InternalPluginCandidateProvider(\n internalPluginDefinitions,\n internalPreferences,\n)\nconst candidateProvider = new CompositePluginCandidateProvider([\n internalProvider,\n new InstalledPluginCandidateProvider(pluginRepository, pluginReaders),\n])\n\nconst devSource = new DevServerSourceResolver()\nconst httpSource = new HttpSourceResolver()\nconst githubSource = new GitHubSourceResolver({\n coreVersion: corePluginDefinition.manifest.version.plugin,\n includePrereleases: () =>\n pluginConfigStore.has(cfg) &&\n pluginConfigStore.load(cfg).data.value.receivePerReleaseUpdate === true,\n})\nconst awesomeRegistry = new AwesomeRegistryClient()\nconst marketplaceSource = new MarketplaceSourceResolver(awesomeRegistry, [githubSource, httpSource])\n\nexport const pluginCatalog: PluginCatalog = awesomeRegistry\n\nexport const pluginInstaller = new PluginInstallService({\n codecs: [new ZipPackageCodec()],\n files: pluginFiles,\n repository: pluginRepository,\n reservedIds: internalPluginIds,\n resolvers: [\n new LocalFileSourceResolver(),\n devSource,\n marketplaceSource,\n githubSource,\n httpSource,\n ],\n})\n\nexport const pluginRuntime = new PluginRuntime({\n capabilities: () =>\n createDefaultCapabilities({\n auth: pluginHostServices.auth,\n config: pluginConfigStore,\n contributions: pluginContributions,\n i18n: pluginI18n,\n }),\n environment: () => ({ platform: isTauri() ? 'tauri' : 'web' }),\n provider: candidateProvider,\n remove: plugin => pluginInstaller.uninstall(plugin),\n store: pluginStore,\n services: { i18n: pluginI18n },\n})\n\nexport interface PluginInstallOptions {\n readonly report?: PluginInstallReporter\n readonly signal?: AbortSignal\n}\n\nexport const installPlugin = async (input: File | string, options: PluginInstallOptions = {}) => {\n const installed = new Set([\n ...internalPluginIds,\n ...(await pluginRepository.list()).map(archive => archive.pluginName),\n ])\n const archive = await pluginInstaller.install(input, options.signal, options.report)\n await pluginRuntime.refreshCandidates()\n try {\n // Files and metadata are already persisted; load the result immediately so installs and\n // updates work without an application restart. reloadPlugin also reloads prepared dependents.\n await pluginRuntime.reloadPlugin(archive.pluginName)\n } catch (error) {\n // Loading failed: keep a restart hint so a restart retries with the persisted state.\n for (const candidate of pluginRuntime.store.candidates.values()) {\n const plugin = candidate.manifest.name.id\n if (plugin === archive.pluginName || !installed.has(plugin)) {\n pluginRuntime.markRestartRequired(plugin)\n }\n }\n throw new Error(\n `plugin installed but failed to start: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n return archive\n}\n\nexport const updatePlugin = async (\n archive: { installInput: string },\n options?: PluginInstallOptions,\n) => {\n if (!archive.installInput) throw new Error('plugin has no reusable install source')\n return await installPlugin(archive.installInput, options)\n}\n\nexport const updatePluginByName = async (plugin: string, options?: PluginInstallOptions) => {\n const archive = await pluginRepository.find(plugin)\n if (!archive) throw new Error(`installed plugin not found: ${plugin}`)\n return await updatePlugin(archive, options)\n}\n\nexport const setPluginEnabled = async (plugin: string, enabled: boolean) => {\n const candidate = pluginStore.candidates.get(plugin)\n if (!candidate?.management.canDisable) throw new Error(`plugin \"${plugin}\" cannot be disabled`)\n const persist = async () => {\n if (candidate.origin === 'builtin') await internalPreferences.setEnabled(plugin, enabled)\n else {\n const archive = await pluginRepository.find(plugin)\n if (!archive) throw new Error(`installed plugin not found: ${plugin}`)\n await pluginRepository.upsert({ ...archive, enable: enabled })\n }\n }\n const restore = async () => {\n if (candidate.origin === 'builtin')\n await internalPreferences.setEnabled(plugin, candidate.enabled)\n else {\n const archive = await pluginRepository.find(plugin)\n if (archive) await pluginRepository.upsert({ ...archive, enable: candidate.enabled })\n }\n await pluginRuntime.refreshCandidates()\n }\n\n if (enabled) {\n await persist()\n await pluginRuntime.refreshCandidates()\n try {\n await pluginRuntime.enablePlugin(plugin)\n } catch (error) {\n // Enabling failed; restore the persisted flag so the list matches the runtime state.\n await restore()\n throw error\n }\n pluginRuntime.restartRequired.delete(plugin)\n return\n }\n\n // Disable validates (dependencies, management) and unloads first, then the flag is persisted.\n await pluginRuntime.disablePlugin(plugin)\n await persist()\n await pluginRuntime.refreshCandidates()\n pluginRuntime.restartRequired.delete(plugin)\n}\n\nexport const uninstallPlugin = async (plugin: string) => await pluginRuntime.uninstall(plugin)\n\nexport const resolvePluginIconUrl = async (\n plugin: string | undefined,\n icon: string | undefined,\n) => {\n if (!icon) return undefined\n if (/^https?:\\/\\//i.test(icon)) return icon\n if (!plugin) throw new Error('a plugin id is required to resolve a local plugin icon')\n const archive = await pluginRepository.find(plugin)\n if (archive?.loaderName === DEV_SERVER_LOADER_ID) {\n const port = parseDevServerPort(archive.installInput)\n if (port === undefined) {\n throw new Error(`development plugin has an invalid install source: ${archive.installInput}`)\n }\n return devServerUrl(port, `/${safePluginPath(icon, 'plugin icon path')}`)\n }\n return await pluginFiles.createAssetUrl(plugin, icon)\n}\n\nexport { pluginI18n, type PluginI18nAdapter, type PluginLocaleMessages } from './adapters'\n\nexport const usePluginStore = () => pluginStore"],"mappings":";;;;;;;;;;;;;;;;AASA,IAAa,gBAAb,MAA4E;CAKxD;CACA;CACA;CANlB;CAGA,YACE,YACA,QACA,YACA;EAHgB,KAAA,aAAA;EACA,KAAA,SAAA;EACA,KAAA,aAAA;EAEhB,KAAK,MAAM,OAAO,IAAI,UAAU,YAAY;CAC9C;AACF;;;;;;;;;;;;;;;;;;;;;AOAA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IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO;CACvC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,wDAAwD;CACrF,MAAM,UAAU,MAAM,iBAAiB,KAAK,MAAM;CAClD,IAAI,SAAS,eAAA,cAAqC;EAChD,MAAM,OAAO,mBAAmB,QAAQ,YAAY;EACpD,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MAAM,qDAAqD,QAAQ,cAAc;EAE7F,OAAO,aAAa,MAAM,IAAI,eAAe,MAAM,kBAAkB,GAAG;CAC1E;CACA,OAAO,MAAM,YAAY,eAAe,QAAQ,IAAI;AACtD;AAIA,MAAa,uBAAuB"}
1
+ {"version":3,"file":"index.mjs","names":["#modules","#entries","#controller","#disposers","#disposePromise","#dispose","isRecord","record","DELTA_COMIC_PLUGIN_API_VERSION","defaultStorage","useDbConfig","#versions","#install","#decode","#database","#store","#open","#key","#root","#moduleVersions","#urls","CorePlugin","pkg.version","__import_glob__0_0_","#activeNormal","#options","#prepared","#preloadReport","#preloadOperation","#app","#prepareEnabledPlugins","#writeRecovery","#normalOperation","#loadNormal","#track","#unloadNormal","#assertReadyForToggle","#booted","#activateNormal","#activationFailure","#prepareAndActivate","#deactivateNormal","#loadPlugin","#flattenErrors","#runUninstallHook","#selectWithDependencies","#assertValidPlan"],"sources":["../../lib/api/config.ts","../../lib/api/model/content.ts","../../lib/api/model/expose.ts","../../lib/api/model/remote.ts","../../lib/api/model/social.ts","../../lib/api/model/special.ts","../../lib/api/model/user.ts","../../lib/api/plugin.ts","../../lib/kernel/candidate.ts","../../lib/kernel/capability.ts","../../lib/kernel/contribution.ts","../../lib/kernel/dependency.ts","../../lib/kernel/scope.ts","../../lib/capabilities/auth.ts","../../lib/capabilities/config.ts","../../lib/capabilities/registryBinding.ts","../../lib/capabilities/content.ts","../../lib/capabilities/i18n.ts","../../lib/capabilities/lifecycle.ts","../../lib/capabilities/channels.ts","../../lib/capabilities/model.ts","../../lib/capabilities/endpointProbe.ts","../../lib/capabilities/remote.ts","../../lib/capabilities/special.ts","../../lib/capabilities/user.ts","../../lib/capabilities/index.ts","../../lib/install/manifest.ts","../../lib/adapters/awesomeRegistry/types.ts","../../lib/adapters/awesomeRegistry/schema.ts","../../lib/adapters/awesomeRegistry/cache.ts","../../lib/adapters/awesomeRegistry/client.ts","../../lib/adapters/configStore.ts","../../lib/install/candidateProvider.ts","../../lib/install/catalog.ts","../../lib/install/codec.ts","../../lib/install/moduleReader.ts","../../lib/install/repository.ts","../../lib/install/service.ts","../../lib/install/source.ts","../../lib/adapters/fileStore.ts","../../lib/adapters/i18n.ts","../../package.json","../../lib/core/env.ts","../../lib/core/config.ts","../../lib/core/i18n.ts","../../lib/core/share.ts","../../lib/core/index.ts","../../lib/builtins/core.builtin.ts","../../lib/builtins/index.ts","../../lib/runtime/store.ts","../../lib/runtime/engine.ts","../../lib/runtime/providers.ts","../../lib/composition.ts"],"sourcesContent":["import type { FormSingleConfigure } from '@delta-comic/model'\n\nexport type ConfigDescription = Record<\n string,\n Required<Pick<FormSingleConfigure, 'defaultValue'>> & FormSingleConfigure\n>\n\nexport type UnwrapConfigPointer<T extends ConfigPointer> = T['_type']\n\nexport class ConfigPointer<T extends ConfigDescription = ConfigDescription> {\n public readonly key: symbol\n declare public readonly _type: T\n\n public constructor(\n public readonly pluginName: string,\n public readonly config: T,\n public readonly configName: string,\n ) {\n this.key = Symbol.for(`config:${pluginName}`)\n }\n}","import type {\n StreamQuery,\n UniCommentRow,\n UniContentDownloadProvider,\n UniContentLayoutComponent,\n UniContentPageLike,\n UniItem,\n UniItemCardComponent,\n UniItemTranslator,\n} from '@delta-comic/model'\nimport type { Component } from 'vue'\n\nexport interface ContentModel {\n models?: Model[]\n search?: Search\n promotes?: Promotes\n}\n\n// model\nexport interface Model {\n name: string\n ItemCard?: UniItemCardComponent\n CommentRow?: UniCommentRow\n Layout?: UniContentLayoutComponent\n ContentPage?: UniContentPageLike\n DownloadProvider?: UniContentDownloadProvider\n ItemTranslator?: UniItemTranslator\n}\n\n// search\nexport interface Search {\n methods: SearchMethod[]\n barcode?: Barcode[]\n getHotSearch: HotSearchProvider\n}\n\nexport type HotSearchProvider = (signal: AbortSignal) => Promise<SearchAim[]>\n\nexport interface SearchMethod {\n name: string\n id: string\n sorts: { options: { label: string; id: string }[]; default: string }\n\n fetchSearchResult: StreamQuery<UniItem, { aim: SearchAim }>\n getAutoComplete: AutoCompleteProvider\n}\n\nexport type AutoCompleteProvider = (\n input: string,\n signal: AbortSignal,\n) => Promise<SearchAim[] | Component>\n\nexport interface SearchAim {\n input: string\n search: { method: string; sort?: string }\n}\n\nexport interface Barcode {\n name: string\n id: string\n getTipText: (aim: SearchAim) => string\n isMatch: (aim: SearchAim) => boolean\n}\n\n// promotes\nexport interface Promotes {\n tabbar?: Tabbar[]\n categories?: Category[]\n hotPageContent?: HotPageContent\n\n fetchRandomItems?: ItemProvider\n}\n\nexport type ItemProvider = (signal: AbortSignal) => Promise<UniItem[]>\n\nexport interface Category {\n title: string\n namespace: string\n search: SearchAim\n}\n\nexport interface Tabbar {\n title: string\n id: string\n comp: Component<{ isActive: boolean; tabbar: Tabbar }>\n}\n\n// promotes - hotPageContent\n\nexport interface HotPageContent {\n levelboard?: HotLevelboard[]\n topButton?: HotTopButton[]\n categories?: HotCategory[]\n}\n\nexport interface HotLevelboard {\n name: string\n id: string\n content: ItemProvider\n}\nexport interface HotCategory {\n name: string\n content: ItemProvider\n}\nexport interface HotTopButton {\n name: string\n icon: Component\n bgColor: string\n}","export type ExposeModel = object\n\n/** Plugin id to public expose contract. Plugin consumers extend this through module augmentation. */\nexport interface PluginExposeRegistry {}","import type { UniResourceProcessor } from '@delta-comic/model'\n\nexport type RemoteModel = TestGroup[]\n\nexport type TestFunction = (url: string, signal: AbortSignal) => Promise<void>\n\nexport type RemoteListProvider = (signal: AbortSignal) => Promise<Definition[]>\n\nexport type RemoteSource = Definition | RemoteListProvider\n\nexport interface Definition {\n name: string\n url: string\n /**\n * cover root `test` method\n */\n test?: TestFunction\n}\n\nexport interface TestGroupBase {\n name: string\n remotes: RemoteSource[] | RemoteListProvider\n /**\n * group-level default test\n */\n test: TestFunction\n allowNoConnected?: boolean\n}\n\nexport interface TestRemoteGroup extends TestGroupBase {\n type: 'remote'\n}\n\nexport interface TestResourceGroup extends TestGroupBase {\n type: 'resource'\n processors?: UniResourceProcessor[]\n}\n\nexport type TestGroup = TestRemoteGroup | TestResourceGroup\n\nexport interface ResolvedTestGroupBase extends Omit<TestGroupBase, 'remotes'> {\n remotes: Definition[]\n}\n\nexport interface ResolvedTestRemoteGroup extends ResolvedTestGroupBase {\n type: 'remote'\n}\n\nexport interface ResolvedTestResourceGroup extends ResolvedTestGroupBase {\n type: 'resource'\n processors?: UniResourceProcessor[]\n}\n\nexport type ResolvedTestGroup = ResolvedTestRemoteGroup | ResolvedTestResourceGroup","import type {\n UniContentPage,\n UniImage,\n StreamQuery,\n UniItem,\n UniItemAuthor,\n} from '@delta-comic/model'\nimport type { Component } from 'vue'\n\nexport interface SocialModel {\n share?: Share\n subscribe?: Subscribe\n}\n\n// share\nexport interface Share {\n initiative?: InitiativeItem[]\n tokenListen?: ShareToken[]\n}\n\nexport interface ShareToken {\n key: string\n name: string\n isMatched(chipboard: string): boolean\n show(chipboard: string): Promise<SharePopupConfig>\n}\n\nexport interface SharePopupConfig {\n title: string\n detail: string\n onPositive(): void\n onNegative(): void\n}\n\nexport interface InitiativeItem {\n key: string\n name: string\n icon: Component | UniImage\n bgColor?: string\n call(page: UniContentPage): Promise<{ token?: string } | void>\n filter(page: UniContentPage): boolean\n}\n\n// subscribe\nexport interface Subscribe {\n getUpdateList: SubscribeListProvider\n fetchAuthorContent: StreamQuery<UniItem, { author: UniItemAuthor }>\n}\n\nexport type SubscribeListProvider = (\n olds: { author: UniItemAuthor; list: UniItem[] }[],\n signal: AbortSignal,\n) => Promise<{ isUpdated: boolean; whichUpdated: UniItemAuthor[] }>","export type SpecialModel = Step[]\n\nexport interface Step {\n name: string\n call: (setDescription: (description: string) => void) => Promise<void>\n}","import type { FormConfigure, FormSingleResult } from '@delta-comic/model'\nimport type { UniItem, UniItemAuthor, UniItemRaw, UniUserCardComponent } from '@delta-comic/model'\nimport type { Component, MaybeRefOrGetter } from 'vue'\n\nexport interface UserModel {\n auth: Auth\n edit?: Component\n card?: UniUserCardComponent\n /**\n * 你希望展示的(`userActions`)自己的板块的页面\n */\n userActionPages?: UserActionPage[]\n /**\n * 在用户界面,在历史记录那个板块的下方,你希望展示的自己的板块\n */\n userActions?: UserAction[]\n\n favourites: Favourites\n}\n\n// auth\nexport interface Auth {\n selections: Selection[]\n /**\n * @returns `string` -> id; `false` -> by user; `true` -> no auth\n */\n default: () => Promise<string | boolean>\n}\n\nexport interface Selection {\n name: string\n id: string\n call: (by: Method) => Promise<void>\n}\n\nexport type Method = {\n form<T extends FormConfigure>(\n form: T,\n ): Promise<{\n [x in keyof T]: FormSingleResult<T[x]>\n }>\n /**\n * @param injectCode 你可以在js调用`callback(...)`来完成鉴权,传值为你给的回调\n */\n website<T>(url: string, injectCode: InjectCode): Promise<CallbackResult<T>>\n}\n\nexport interface InjectCode {\n js: string\n css: string\n}\n\nexport interface CallbackResult<T> {\n callbackValue: T\n cookie: string\n localStorage: Record<string, string>\n sessionStorage: Record<string, string>\n href: string\n title: string\n}\n\n// user\n\nexport interface UserAction {\n call(author: UniItemAuthor): unknown\n name: string\n id: string\n icon?: Component\n}\n\nexport interface UserActionPage {\n title?: string\n items: ActionPageItem[]\n\n clickPage?: Component\n clickText?: string\n}\nexport type ActionPageItem =\n | {\n name: string\n key: string\n type: 'button'\n icon: Component\n\n page: Component\n }\n | {\n name: string\n key: string\n type: 'statistic'\n icon?: Component\n\n value: MaybeRefOrGetter<string | number>\n }\n\nexport interface Favourites {\n download: (signal: AbortSignal) => Promise<UniItem[]>\n upload: (items: UniItemRaw[], signal: AbortSignal) => Promise<void>\n}","import { isFunction } from 'es-toolkit'\n\nimport type { ConfigPointer } from './config'\nimport type { ConfigEnv } from './env'\nimport type { PluginConfigHooks } from './hook'\nimport type { PluginLocaleMessages } from './i18n'\nimport type { PluginConfigModel } from './model'\n\nexport interface DCPluginConfig {\n /** Stable plugin id. It must equal the candidate manifest id. */\n name: string\n /** At most one declarative configuration form can be contributed by a plugin. */\n config?: ConfigPointer\n i18n?: PluginLocaleMessages\n model?: PluginConfigModel\n hooks?: PluginConfigHooks\n}\n\nexport type PluginConfigFactory<T extends DCPluginConfig = DCPluginConfig> = (env: ConfigEnv) => T\n\nexport const defineDeltaComicPlugin = <T extends DCPluginConfig>(\n config: T | PluginConfigFactory<T>,\n): PluginConfigFactory<T> => {\n if (isFunction(config)) return config\n return () => config\n}","import type { PluginManifest } from '@delta-comic/model'\n\nimport type { PluginConfigFactory } from '../api'\n\nimport type { PluginScope } from './scope'\n\nexport type PluginOrigin = 'builtin' | 'installed'\n\nexport interface PluginManagementCapabilities {\n readonly canDisable: boolean\n readonly canUninstall: boolean\n readonly canUpdate: boolean\n}\n\nexport interface LoadedPluginModule {\n readonly factory: PluginConfigFactory\n activate?(scope: PluginScope): Promise<void> | void\n dispose?(): Promise<void> | void\n}\n\nexport interface PluginCandidate {\n readonly manifest: PluginManifest\n readonly origin: PluginOrigin\n readonly enabled: boolean\n readonly management: PluginManagementCapabilities\n load(signal: AbortSignal): Promise<LoadedPluginModule>\n}\n\nexport interface PluginCandidateProvider {\n readonly id: string\n list(signal: AbortSignal): Promise<readonly PluginCandidate[]>\n}\n\nexport interface InternalPluginDefinition {\n readonly manifest: PluginManifest\n readonly factory: PluginConfigFactory\n readonly canDisable?: boolean\n readonly enabledByDefault?: boolean\n}\n\nexport const defineInternalPlugin = <T extends InternalPluginDefinition>(definition: T) =>\n definition","import type { DCPluginConfig } from '../api'\n\nimport type { PluginScope } from './scope'\n\nexport interface ActivationStepUpdate {\n readonly description?: string\n readonly name?: string\n}\n\nexport interface ActivationContext {\n readonly owner: string\n readonly scope: PluginScope\n readonly signal: AbortSignal\n report(update: ActivationStepUpdate | string): void\n}\n\nexport interface CapabilityModule {\n readonly id: string\n activate(plugin: DCPluginConfig, context: ActivationContext): Promise<boolean>\n}\n\nexport interface CapabilityDefinition<T> {\n readonly id: string\n select(plugin: DCPluginConfig): T | undefined\n activate(model: T, context: ActivationContext): Promise<void> | void\n}\n\nexport const defineCapability = <T>(definition: CapabilityDefinition<T>): CapabilityModule => ({\n id: definition.id,\n async activate(plugin, context) {\n const model = definition.select(plugin)\n if (model === undefined) return false\n await definition.activate(model, context)\n return true\n },\n})\n\nexport class ActivationPipeline {\n readonly #modules: readonly CapabilityModule[]\n\n public constructor(modules: readonly CapabilityModule[]) {\n const ids = new Set<string>()\n for (const module of modules) {\n if (!module.id) throw new Error('capability id cannot be empty')\n if (ids.has(module.id)) throw new Error(`duplicate capability \"${module.id}\"`)\n ids.add(module.id)\n }\n this.#modules = [...modules]\n }\n\n public async activate(plugin: DCPluginConfig, context: ActivationContext) {\n const activated: string[] = []\n for (const module of this.#modules) {\n if (context.signal.aborted) throw context.signal.reason\n context.report({ description: '', name: module.id })\n if (await module.activate(plugin, context)) activated.push(module.id)\n }\n return activated\n }\n}","import { shallowReactive } from 'vue'\n\nimport type { PluginScope } from './scope'\n\nexport interface Contribution<T> {\n readonly owner: string\n readonly id: string\n readonly value: T\n}\n\nexport interface ContributionChannel<T, Owners extends Record<keyof Owners, T> = Record<never, T>> {\n readonly key: string\n readonly __type?: T\n readonly __owners?: Owners\n}\n\nexport const defineContributionChannel = <\n T,\n Owners extends Record<keyof Owners, T> = Record<never, T>,\n>(\n key: string,\n): ContributionChannel<T, Owners> => ({ key })\n\nexport type ContributionValue<\n T,\n Owners extends Record<keyof Owners, T>,\n Owner extends string,\n> = Owner extends keyof Owners ? Owners[Owner] : T\n\nconst contributionKey = (owner: string, id: string) => JSON.stringify([owner, id])\n\nexport class ContributionRegistry<T, Owners extends Record<keyof Owners, T> = Record<never, T>> {\n readonly #entries = shallowReactive(new Map<string, Contribution<T>>())\n\n public get size() {\n return this.#entries.size\n }\n\n public get entries(): ReadonlyMap<string, Contribution<T>> {\n return this.#entries\n }\n\n public register<Owner extends string>(\n owner: Owner,\n id: string,\n value: ContributionValue<T, Owners, Owner>,\n ) {\n if (!owner) throw new Error('contribution owner cannot be empty')\n if (!id) throw new Error('contribution id cannot be empty')\n\n const key = contributionKey(owner, id)\n if (this.#entries.has(key)) {\n throw new Error(`duplicate contribution \"${owner}:${id}\"`)\n }\n\n const contribution: Contribution<T> = { id, owner, value: value as T }\n this.#entries.set(key, contribution)\n\n let active = true\n return () => {\n if (!active) return false\n active = false\n return this.#entries.delete(key)\n }\n }\n\n public get<Owner extends string>(owner: Owner, id: string) {\n type Value = ContributionValue<T, Owners, Owner>\n return this.#entries.get(contributionKey(owner, id)) as Contribution<Value> | undefined\n }\n\n public byOwner<Owner extends string>(owner: Owner) {\n type Value = ContributionValue<T, Owners, Owner>\n return [...this.#entries.values()].filter(\n entry => entry.owner === owner,\n ) as Contribution<Value>[]\n }\n\n public removeOwner(owner: string) {\n for (const [key, entry] of this.#entries) {\n if (entry.owner === owner) this.#entries.delete(key)\n }\n }\n\n public values() {\n return this.#entries.values()\n }\n}\n\nexport class ContributionHub {\n private readonly registries = new Map<string, ContributionRegistry<any, any>>()\n\n public channel<T, Owners extends Record<keyof Owners, T> = Record<never, T>>(\n channel: ContributionChannel<T, Owners>,\n ): ContributionRegistry<T, Owners> {\n let registry = this.registries.get(channel.key)\n if (!registry) {\n registry = new ContributionRegistry<T, Owners>()\n this.registries.set(channel.key, registry)\n }\n return registry //as ContributionRegistry<T, Owners>\n }\n\n public register<T, Owners extends Record<keyof Owners, T> = Record<never, T>>(\n scope: PluginScope,\n channel: ContributionChannel<T, Owners>,\n id: string,\n value: T,\n ) {\n const unregister = this.channel(channel).register<string>(\n scope.owner,\n id,\n value as ContributionValue<T, Owners, string>,\n )\n scope.defer(() => void unregister())\n return unregister\n }\n\n public removeOwner(owner: string) {\n for (const registry of this.registries.values()) registry.removeOwner(owner)\n }\n}","import type { PluginCandidate } from './candidate'\n\nexport interface MissingPluginDependency {\n readonly plugin: string\n readonly dependency: string\n}\n\nexport interface PluginDependencyPlan {\n readonly levels: PluginCandidate[][]\n readonly missing: MissingPluginDependency[]\n readonly cycles: string[][]\n}\n\nconst dependenciesOf = (candidate: PluginCandidate) =>\n candidate.manifest.require.map(dependency => dependency.id)\n\nconst canonicalCycleKey = (cycle: readonly string[]) => {\n const nodes = cycle.slice(0, -1)\n const rotations = nodes.map((_, index) => nodes.slice(index).concat(nodes.slice(0, index)))\n rotations.sort((left, right) => left.join('\\0').localeCompare(right.join('\\0')))\n return rotations[0]?.join('\\0') ?? ''\n}\n\nexport const findPluginDependencyCycles = (candidates: readonly PluginCandidate[]) => {\n const candidateIds = new Set(candidates.map(candidate => candidate.manifest.name.id))\n const dependencies = new Map(\n candidates.map(candidate => [\n candidate.manifest.name.id,\n dependenciesOf(candidate).filter(dependency => candidateIds.has(dependency)),\n ]),\n )\n const state = new Map<string, 'visiting' | 'visited'>()\n const path: string[] = []\n const keys = new Set<string>()\n const cycles: string[][] = []\n\n const visit = (plugin: string) => {\n state.set(plugin, 'visiting')\n path.push(plugin)\n for (const dependency of dependencies.get(plugin) ?? []) {\n if (state.get(dependency) === 'visiting') {\n const start = path.lastIndexOf(dependency)\n if (start < 0) continue\n const cycle = path.slice(start).concat(dependency)\n const key = canonicalCycleKey(cycle)\n if (!keys.has(key)) {\n keys.add(key)\n cycles.push(cycle)\n }\n } else if (state.get(dependency) !== 'visited') {\n visit(dependency)\n }\n }\n path.pop()\n state.set(plugin, 'visited')\n }\n\n for (const candidate of candidates) {\n const id = candidate.manifest.name.id\n if (!state.has(id)) visit(id)\n }\n return cycles\n}\n\nexport const planPluginDependencies = (\n candidates: readonly PluginCandidate[],\n): PluginDependencyPlan => {\n const byId = new Map(candidates.map(candidate => [candidate.manifest.name.id, candidate]))\n const degree = new Map<string, number>()\n const dependents = new Map<string, string[]>()\n const missing: MissingPluginDependency[] = []\n\n for (const candidate of candidates) {\n const id = candidate.manifest.name.id\n const installed = dependenciesOf(candidate).filter(dependency => {\n if (byId.has(dependency)) return true\n missing.push({ dependency, plugin: id })\n return false\n })\n degree.set(id, installed.length)\n for (const dependency of installed) {\n const entries = dependents.get(dependency) ?? []\n entries.push(id)\n dependents.set(dependency, entries)\n }\n }\n\n const queue = [...degree].filter(([, value]) => value === 0).map(([id]) => id)\n const levels: PluginCandidate[][] = []\n while (queue.length > 0) {\n const current = queue.splice(0)\n const level = current.flatMap(id => {\n const candidate = byId.get(id)\n return candidate ? [candidate] : []\n })\n if (level.length > 0) levels.push(level)\n for (const id of current) {\n for (const dependent of dependents.get(id) ?? []) {\n const next = (degree.get(dependent) ?? 0) - 1\n degree.set(dependent, next)\n if (next === 0) queue.push(dependent)\n }\n }\n }\n\n const unresolved = candidates.filter(\n candidate => (degree.get(candidate.manifest.name.id) ?? 0) > 0,\n )\n return { cycles: findPluginDependencyCycles(unresolved), levels, missing }\n}","export type PluginDisposer = () => Promise<void> | void\n\nexport class PluginScope {\n readonly #controller = new AbortController()\n readonly #disposers: PluginDisposer[] = []\n #disposePromise?: Promise<void>\n\n public constructor(public readonly owner: string) {}\n\n public get signal() {\n return this.#controller.signal\n }\n\n public get disposed() {\n return this.#disposePromise !== undefined\n }\n\n public defer(disposer: PluginDisposer) {\n if (this.disposed) throw new Error(`plugin scope \"${this.owner}\" is already disposed`)\n this.#disposers.push(disposer)\n return disposer\n }\n\n public dispose(reason?: unknown) {\n return (this.#disposePromise ??= this.#dispose(reason))\n }\n\n async #dispose(reason?: unknown) {\n this.#controller.abort(reason)\n const errors: unknown[] = []\n\n for (const disposer of this.#disposers.reverse()) {\n try {\n await disposer()\n } catch (error) {\n errors.push(error)\n }\n }\n this.#disposers.length = 0\n\n if (errors.length > 0) {\n throw new AggregateError(errors, `failed to dispose plugin scope \"${this.owner}\"`)\n }\n }\n}","import { defineCapability, type CapabilityModule } from '../kernel'\n\nimport type { PluginCapabilityServices } from './services'\n\nexport const createAuthCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'auth',\n select: config => config.model?.user?.auth,\n async activate(auth, context) {\n if (!services.auth) throw new Error('plugin authentication requires a host auth gateway')\n context.report({ name: 'auth', description: 'checking authentication' })\n await services.auth.authenticate(context.owner, auth, context.signal)\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nimport type { PluginCapabilityServices } from './services'\n\nexport const createConfigCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'config',\n select: config => config.config,\n async activate(pointer, context) {\n if (pointer.pluginName !== context.scope.owner) {\n throw new Error(\n `plugin config owner mismatch: ${context.scope.owner} / ${pointer.pluginName}`,\n )\n }\n context.report({ description: pointer.configName })\n const registered = services.config.register(pointer)\n context.scope.defer(() => services.config.unregister(pointer))\n await registered.ready\n },\n })","import type { PluginScope } from '../kernel'\n\ninterface MutableRegistry<TKey, TValue> {\n delete(key: TKey): boolean\n get(key: TKey): TValue | undefined\n has(key: TKey): boolean\n set(key: TKey, value: TValue): unknown\n}\n\n/** Bind a host registry entry and restore exactly the value that existed before activation. */\nexport const bindRegistryValue = <TKey, TValue>(\n scope: PluginScope,\n registry: MutableRegistry<TKey, TValue>,\n key: TKey,\n value: TValue | undefined,\n) => {\n if (value === undefined) return\n const hadPrevious = registry.has(key)\n const previous = registry.get(key)\n registry.set(key, value)\n scope.defer(() => {\n if (hadPrevious) registry.set(key, previous as TValue)\n else registry.delete(key)\n })\n}","import { UniComment, UniContentPage, UniItem } from '@delta-comic/model'\n\nimport { defineCapability, type CapabilityModule } from '../kernel'\n\nimport { bindRegistryValue } from './registryBinding'\n\nexport const createContentCapability = (): CapabilityModule =>\n defineCapability({\n id: 'content-bindings',\n select: config => config.model?.content?.models,\n activate(models, context) {\n const names = new Set<string>()\n for (const model of models) {\n if (!model.name) throw new Error('content model name cannot be empty')\n if (names.has(model.name)) throw new Error(`duplicate content model \"${model.name}\"`)\n names.add(model.name)\n const key: [plugin: string, name: string] = [context.owner, model.name]\n bindRegistryValue(context.scope, UniContentPage.layouts, key, model.Layout)\n bindRegistryValue(context.scope, UniItem.itemCards, key, model.ItemCard)\n bindRegistryValue(context.scope, UniContentPage.contentPages, key, model.ContentPage)\n bindRegistryValue(\n context.scope,\n UniContentPage.downloadProviders,\n key,\n model.DownloadProvider,\n )\n bindRegistryValue(context.scope, UniComment.commentRow, key, model.CommentRow)\n bindRegistryValue(context.scope, UniItem.itemTranslator, key, model.ItemTranslator)\n }\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nimport type { PluginCapabilityServices } from './services'\n\nexport const createI18nCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'i18n',\n select: config => config.i18n,\n activate(messages, context) {\n services.i18n.register(context.scope.owner, messages)\n context.scope.defer(() => services.i18n.remove(context.scope.owner))\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nexport const createLifecycleCapability = (): CapabilityModule =>\n defineCapability({\n id: 'lifecycle',\n select: config => {\n const hooks = config.hooks\n return hooks?.onBooted || hooks?.onUnload ? hooks : undefined\n },\n async activate(hooks, context) {\n if (hooks.onUnload) context.scope.defer(() => hooks.onUnload?.())\n await hooks.onBooted?.()\n },\n })","import type {\n ContentModel,\n ExposeModel,\n PluginExposeRegistry,\n RemoteModel,\n SocialModel,\n SpecialModel,\n UserModel,\n} from '../api/model'\nimport { defineContributionChannel } from '../kernel'\n\nexport const pluginModelChannels = {\n content: defineContributionChannel<ContentModel>('model:content'),\n expose: defineContributionChannel<ExposeModel, PluginExposeRegistry>('model:expose'),\n remote: defineContributionChannel<RemoteModel>('model:remote'),\n social: defineContributionChannel<SocialModel>('model:social'),\n special: defineContributionChannel<SpecialModel>('model:special'),\n user: defineContributionChannel<UserModel>('model:user'),\n} as const","import type { PluginConfigModel } from '../api/model'\nimport { defineCapability, type CapabilityModule, type ContributionChannel } from '../kernel'\n\nimport { pluginModelChannels } from './channels'\nimport type { PluginCapabilityServices } from './services'\n\nexport const createModelCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'model',\n select: config => config.model,\n activate(model: PluginConfigModel, context) {\n const register = <T>(channel: ContributionChannel<T>, value: T | undefined) => {\n if (value !== undefined) {\n services.contributions.register(context.scope, channel, 'default', value)\n }\n }\n\n register(pluginModelChannels.content, model.content)\n register(pluginModelChannels.expose, model.expose)\n register(pluginModelChannels.remote, model.remotes)\n register(pluginModelChannels.social, model.social)\n register(pluginModelChannels.special, model.special)\n register(pluginModelChannels.user, model.user)\n },\n })","export interface EndpointProbeCandidate<T> {\n readonly test: (url: string, signal: AbortSignal) => PromiseLike<void>\n readonly url: string\n readonly value: T\n}\n\nexport interface EndpointProbeResult<T> {\n readonly latencyMs: number\n readonly url: string\n readonly value: T\n}\n\nconst probeOne = async <T>(\n candidate: EndpointProbeCandidate<T>,\n parentSignal: AbortSignal,\n timeoutMs: number,\n controllers: Set<AbortController>,\n) => {\n const controller = new AbortController()\n controllers.add(controller)\n const relayAbort = () => controller.abort(parentSignal.reason)\n parentSignal.addEventListener('abort', relayAbort, { once: true })\n const timeout = setTimeout(\n () => controller.abort(new Error('endpoint probe timed out')),\n timeoutMs,\n )\n const startedAt = performance.now()\n try {\n await candidate.test(candidate.url, controller.signal)\n return { latencyMs: performance.now() - startedAt, url: candidate.url, value: candidate.value }\n } finally {\n clearTimeout(timeout)\n parentSignal.removeEventListener('abort', relayAbort)\n controllers.delete(controller)\n }\n}\n\n/** Probe independently in parallel and stop remaining attempts after the first reachable endpoint. */\nexport const selectFastestEndpoint = async <T>(\n candidates: readonly EndpointProbeCandidate<T>[],\n signal: AbortSignal,\n timeoutMs = 10_000,\n): Promise<EndpointProbeResult<T> | undefined> => {\n signal.throwIfAborted()\n const controllers = new Set<AbortController>()\n try {\n return await Promise.any(\n candidates.map(candidate => probeOne(candidate, signal, timeoutMs, controllers)),\n )\n } catch (error) {\n signal.throwIfAborted()\n if (error instanceof AggregateError) return undefined\n throw error\n } finally {\n for (const controller of controllers)\n controller.abort(new Error('another endpoint was selected'))\n }\n}","import { UniResource } from '@delta-comic/model'\n\nimport type { Remote } from '../api'\nimport { defineCapability, defineContributionChannel, type CapabilityModule } from '../kernel'\n\nimport { selectFastestEndpoint } from './endpointProbe'\nimport { bindRegistryValue } from './registryBinding'\nimport type { PluginCapabilityServices } from './services'\n\nconst resolveGroup = async (\n group: Remote.TestGroup,\n signal: AbortSignal,\n): Promise<Remote.ResolvedTestGroup> => {\n const sources = typeof group.remotes === 'function' ? [group.remotes] : group.remotes\n const remotes = (\n await Promise.all(\n sources.map(source => (typeof source === 'function' ? source(signal) : source)),\n )\n ).flat()\n\n return { ...group, remotes }\n}\n\nexport interface RemoteSelection {\n readonly group: Remote.ResolvedTestRemoteGroup\n readonly latencyMs?: number\n readonly remote: Remote.Definition | false\n}\n\nexport const pluginRemoteSelectionChannel = defineContributionChannel<RemoteSelection>(\n 'runtime:remote-selection',\n)\n\nexport const createRemoteCapability = (services: PluginCapabilityServices): CapabilityModule =>\n defineCapability({\n id: 'remote',\n select: config =>\n config.model?.remotes ? { hooks: config.hooks, remotes: config.model.remotes } : undefined,\n async activate({ hooks, remotes }, context) {\n const groups = new Set<string>()\n for (const sourceGroup of remotes) {\n if (!sourceGroup.name) throw new Error('remote group name cannot be empty')\n if (groups.has(sourceGroup.name)) {\n throw new Error(`duplicate remote group \"${sourceGroup.name}\"`)\n }\n groups.add(sourceGroup.name)\n context.report({ name: 'remote', description: `probing ${sourceGroup.name}` })\n const group = await resolveGroup(sourceGroup, context.signal)\n const selected = await selectFastestEndpoint(\n group.remotes.map(remote => ({\n test: remote.test ?? group.test,\n url: remote.url,\n value: remote,\n })),\n context.signal,\n )\n if (!selected && !group.allowNoConnected) {\n if (group.type === 'remote') {\n throw new Error(`no reachable endpoint for remote group \"${group.name}\"`)\n }\n throw new Error(`no reachable endpoint for resource \"${group.name}\"`)\n }\n if (group.type === 'resource') {\n bindRegistryValue(\n context.scope,\n UniResource.fork,\n [context.owner, group.name],\n group.remotes.map(remote => remote.url),\n )\n if (selected) {\n bindRegistryValue(\n context.scope,\n UniResource.precedenceFork,\n [context.owner, group.name],\n selected.url,\n )\n }\n const processors = new Set<string>()\n for (const processor of group.processors ?? []) {\n if (!processor.name) throw new Error('resource process name cannot be empty')\n if (processors.has(processor.name)) {\n throw new Error(`duplicate resource process \"${processor.name}\"`)\n }\n processors.add(processor.name)\n bindRegistryValue(\n context.scope,\n UniResource.processInstances,\n [context.owner, processor.name],\n processor,\n )\n }\n continue\n }\n const selection: RemoteSelection = {\n group,\n latencyMs: selected?.latencyMs,\n remote: selected?.value ?? false,\n }\n services.contributions.register(\n context.scope,\n pluginRemoteSelectionChannel,\n group.name,\n selection,\n )\n hooks?.onRemoteTestDone?.(group, selection.remote)\n }\n },\n })","import { defineCapability, type CapabilityModule } from '../kernel'\n\nexport const createSpecialCapability = (): CapabilityModule =>\n defineCapability({\n id: 'special',\n select: config => config.model?.special,\n async activate(steps, context) {\n for (const step of steps) {\n context.signal.throwIfAborted()\n if (!step.name) throw new Error('special step name cannot be empty')\n context.report({ name: step.name, description: '' })\n await step.call(description => context.report({ name: step.name, description }))\n }\n },\n })","import { UniUser } from '@delta-comic/model'\n\nimport { defineCapability, type CapabilityModule } from '../kernel'\n\nimport { bindRegistryValue } from './registryBinding'\n\nexport const createUserCapability = (): CapabilityModule =>\n defineCapability({\n id: 'user-bindings',\n select: config => config.model?.user,\n activate(user, context) {\n bindRegistryValue(context.scope, UniUser.userCards, context.owner, user.card)\n bindRegistryValue(context.scope, UniUser.userEditorBase, context.owner, user.edit)\n },\n })","import type { CapabilityModule } from '../kernel'\n\nimport { createAuthCapability } from './auth'\nimport { createConfigCapability } from './config'\nimport { createContentCapability } from './content'\nimport { createI18nCapability } from './i18n'\nimport { createLifecycleCapability } from './lifecycle'\nimport { createModelCapability } from './model'\nimport { createRemoteCapability } from './remote'\nimport type { PluginCapabilityServices } from './services'\nimport { createSpecialCapability } from './special'\nimport { createUserCapability } from './user'\n\nexport * from './auth'\nexport * from './channels'\nexport * from './config'\nexport * from './content'\nexport * from './i18n'\nexport * from './lifecycle'\nexport * from './model'\nexport * from './remote'\nexport * from './services'\nexport * from './special'\nexport * from './user'\n\n/** Fixed host-owned activation topology. Third-party plugins only provide data to it. */\nexport const createDefaultCapabilities = (\n services: PluginCapabilityServices,\n): readonly CapabilityModule[] => [\n createConfigCapability(services),\n createI18nCapability(services),\n createModelCapability(services),\n createContentCapability(),\n createUserCapability(),\n createRemoteCapability(services),\n createAuthCapability(services),\n createSpecialCapability(),\n createLifecycleCapability(),\n]","import { DELTA_COMIC_PLUGIN_API_VERSION, type PluginManifest } from '@delta-comic/model'\nimport semver from 'semver'\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst record = (value: unknown, path: string) => {\n if (!isRecord(value)) throw new PluginManifestError(`${path} must be an object`)\n return value\n}\n\nconst text = (value: unknown, path: string) => {\n if (typeof value !== 'string' || value.length === 0) {\n throw new PluginManifestError(`${path} must be a non-empty string`)\n }\n return value\n}\n\nconst pluginId = (value: unknown, path: string) => {\n const id = text(value, path)\n if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(id)) {\n throw new PluginManifestError(`${path} must be a portable 1-64 character plugin identifier`)\n }\n return id\n}\n\nexport const safePluginPath = (value: unknown, path: string) => {\n const normalized = text(value, path).replaceAll('\\\\', '/')\n if (\n normalized.startsWith('/') ||\n /^[a-z]:($|\\/)/i.test(normalized) ||\n normalized.includes('\\0') ||\n normalized.split('/').some(segment => segment === '..')\n ) {\n throw new PluginManifestError(`${path} must be a safe relative path`)\n }\n return normalized\n .split('/')\n .filter(segment => segment && segment !== '.')\n .join('/')\n}\n\nexport class PluginManifestError extends Error {\n public constructor(message: string) {\n super(`Invalid Delta Comic manifest: ${message}`)\n this.name = 'PluginManifestError'\n }\n}\n\nconst pluginIcon = (value: unknown) => {\n const icon = text(value, 'manifest.icon').trim()\n if (!/^[a-z][a-z\\d+.-]*:/i.test(icon)) return safePluginPath(icon, 'manifest.icon')\n let url: URL\n try {\n url = new URL(icon)\n } catch {\n throw new PluginManifestError('manifest.icon must be an HTTP(S) URL or a safe relative path')\n }\n if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) {\n throw new PluginManifestError(\n 'manifest.icon must be a credential-free HTTP(S) URL or a safe relative path',\n )\n }\n return icon\n}\n\nexport const parsePluginManifest = (value: unknown): PluginManifest => {\n const manifest = record(value, 'manifest')\n if (manifest.apiVersion !== DELTA_COMIC_PLUGIN_API_VERSION) {\n throw new PluginManifestError(`manifest.apiVersion must be ${DELTA_COMIC_PLUGIN_API_VERSION}`)\n }\n const name = record(manifest.name, 'manifest.name')\n const version = record(manifest.version, 'manifest.version')\n const id = pluginId(name.id, 'manifest.name.id')\n if (!Array.isArray(manifest.require)) {\n throw new PluginManifestError('manifest.require must be an array')\n }\n\n const result: PluginManifest = {\n apiVersion: DELTA_COMIC_PLUGIN_API_VERSION,\n author: text(manifest.author, 'manifest.author'),\n description: text(manifest.description, 'manifest.description'),\n name: { display: text(name.display, 'manifest.name.display'), id },\n require: manifest.require.map((value, index) => {\n const dependency = record(value, `manifest.require[${index}]`)\n return {\n id: pluginId(dependency.id, `manifest.require[${index}].id`),\n ...(dependency.download === undefined\n ? {}\n : { download: text(dependency.download, `manifest.require[${index}].download`) }),\n }\n }),\n version: {\n plugin: text(version.plugin, 'manifest.version.plugin'),\n supportCore: text(version.supportCore, 'manifest.version.supportCore'),\n },\n }\n\n if (manifest.icon !== undefined) result.icon = pluginIcon(manifest.icon)\n if (manifest.integrity !== undefined) {\n const integrity = record(manifest.integrity, 'manifest.integrity')\n if (integrity.algorithm !== 'blake3' && integrity.algorithm !== 'sha256') {\n throw new PluginManifestError('manifest.integrity.algorithm is unsupported')\n }\n result.integrity = {\n algorithm: integrity.algorithm,\n digest: text(integrity.digest, 'manifest.integrity.digest'),\n }\n }\n return result\n}\n\nexport const isPluginManifestCompatible = (manifest: PluginManifest, coreVersion: string) =>\n semver.satisfies(coreVersion, manifest.version.supportCore)","export const AWESOME_REGISTRY_BASE_URL =\n 'https://raw.githubusercontent.com/delta-comic/awesome-plugins/main/'\nexport const AWESOME_REGISTRY_INDEX_PATH = 'registry/index.json'\nexport const AWESOME_REGISTRY_SCHEMA_VERSION = 1 as const\n\nexport interface AwesomeRegistryPageReference {\n page: number\n items: number\n path: string\n}\n\nexport interface AwesomeRegistryIndex {\n schemaVersion: typeof AWESOME_REGISTRY_SCHEMA_VERSION\n pageSize: number\n totalItems: number\n totalPages: number\n pages: AwesomeRegistryPageReference[]\n}\n\nexport interface AwesomeRegistryPagination {\n page: number\n pageSize: number\n totalItems: number\n totalPages: number\n previous: string | null\n next: string | null\n}\n\nexport type AwesomePluginDownload =\n | { type: 'github'; repository: string }\n | { type: 'url'; url: string }\n\nexport interface AwesomePluginRepository {\n owner: string\n name: string\n url: string\n defaultBranch: string\n lastCommitAt: string\n readmeUrl?: string\n}\n\nexport interface AwesomePluginRelease {\n version: string\n url: string\n publishedAt: string\n manifestUrl: string | null\n}\n\nexport interface AwesomePluginListing {\n schemaVersion: typeof AWESOME_REGISTRY_SCHEMA_VERSION\n id: string\n authors: string[]\n download: AwesomePluginDownload\n repository?: AwesomePluginRepository\n release?: AwesomePluginRelease\n}\n\nexport interface AwesomeRegistryPage {\n schemaVersion: typeof AWESOME_REGISTRY_SCHEMA_VERSION\n pagination: AwesomeRegistryPagination\n items: AwesomePluginListing[]\n}\n\nexport interface AwesomeRegistryResult<T> {\n data: T\n cachedAt: string\n stale: boolean\n}\n\nexport interface AwesomeRegistryStorage {\n getItem(key: string): string | null\n removeItem(key: string): void\n setItem(key: string, value: string): void\n}","import {\n AWESOME_REGISTRY_SCHEMA_VERSION,\n type AwesomePluginDownload,\n type AwesomePluginListing,\n type AwesomePluginRelease,\n type AwesomePluginRepository,\n type AwesomeRegistryIndex,\n type AwesomeRegistryPage,\n type AwesomeRegistryPagination,\n type AwesomeRegistryPageReference,\n} from './types'\n\n/** Paths are validated before they are resolved against the configured registry origin. */\nconst PAGE_PATH_PATTERN = /^registry\\/pages\\/[1-9][0-9]*\\.json$/\nconst PLUGIN_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/\nconst GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/\nconst GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst record = (value: unknown, path: string) => {\n if (!isRecord(value)) throw new AwesomeRegistryValidationError(`${path} must be an object`)\n return value\n}\n\nconst exactKeys = (value: Record<string, unknown>, allowed: readonly string[], path: string) => {\n const extras = Object.keys(value).filter(key => !allowed.includes(key))\n if (extras.length > 0) {\n throw new AwesomeRegistryValidationError(`${path} has unknown fields: ${extras.join(', ')}`)\n }\n}\n\nconst string = (value: unknown, path: string) => {\n if (typeof value !== 'string' || value.length === 0) {\n throw new AwesomeRegistryValidationError(`${path} must be a non-empty string`)\n }\n return value\n}\n\nconst integer = (value: unknown, path: string, minimum: number, maximum = Infinity) => {\n if (!Number.isInteger(value) || (value as number) < minimum || (value as number) > maximum) {\n throw new AwesomeRegistryValidationError(\n `${path} must be an integer between ${minimum} and ${maximum}`,\n )\n }\n return value as number\n}\n\nconst schemaVersion = (value: unknown, path: string) => {\n if (value !== AWESOME_REGISTRY_SCHEMA_VERSION) {\n throw new AwesomeRegistryVersionError(value, path)\n }\n return AWESOME_REGISTRY_SCHEMA_VERSION\n}\n\nconst path = (value: unknown, field: string) => {\n const result = string(value, field)\n if (!PAGE_PATH_PATTERN.test(result)) {\n throw new AwesomeRegistryValidationError(`${field} must be a registry page path`)\n }\n return result\n}\n\nconst httpUrl = (value: unknown, field: string) => {\n const result = string(value, field)\n let parsed: URL\n try {\n parsed = new URL(result)\n } catch {\n throw new AwesomeRegistryValidationError(`${field} must be an absolute URL`)\n }\n if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) {\n throw new AwesomeRegistryValidationError(`${field} must be a credential-free HTTP(S) URL`)\n }\n return result\n}\n\nconst dateTime = (value: unknown, field: string) => {\n const result = string(value, field)\n if (!/^\\d{4}-\\d{2}-\\d{2}T/.test(result) || Number.isNaN(Date.parse(result))) {\n throw new AwesomeRegistryValidationError(`${field} must be an ISO date-time`)\n }\n return result\n}\n\nconst parsePageReference = (value: unknown, field: string): AwesomeRegistryPageReference => {\n const item = record(value, field)\n exactKeys(item, ['page', 'items', 'path'], field)\n return {\n page: integer(item.page, `${field}.page`, 1),\n items: integer(item.items, `${field}.items`, 1),\n path: path(item.path, `${field}.path`),\n }\n}\n\nconst parseDownload = (value: unknown, field: string): AwesomePluginDownload => {\n const download = record(value, field)\n if (download.type === 'github') {\n exactKeys(download, ['type', 'repository'], field)\n const repository = string(download.repository, `${field}.repository`)\n if (!GITHUB_REPOSITORY_PATTERN.test(repository)) {\n throw new AwesomeRegistryValidationError(`${field}.repository is invalid`)\n }\n return { type: 'github', repository }\n }\n if (download.type === 'url') {\n exactKeys(download, ['type', 'url'], field)\n return { type: 'url', url: httpUrl(download.url, `${field}.url`) }\n }\n throw new AwesomeRegistryValidationError(`${field}.type is unsupported`)\n}\n\nconst parseRepository = (value: unknown, field: string): AwesomePluginRepository => {\n const repository = record(value, field)\n exactKeys(\n repository,\n ['owner', 'name', 'url', 'defaultBranch', 'lastCommitAt', 'readmeUrl'],\n field,\n )\n return {\n owner: string(repository.owner, `${field}.owner`),\n name: string(repository.name, `${field}.name`),\n url: httpUrl(repository.url, `${field}.url`),\n defaultBranch: string(repository.defaultBranch, `${field}.defaultBranch`),\n lastCommitAt: dateTime(repository.lastCommitAt, `${field}.lastCommitAt`),\n ...(repository.readmeUrl === undefined\n ? {}\n : { readmeUrl: httpUrl(repository.readmeUrl, `${field}.readmeUrl`) }),\n }\n}\n\nconst parseRelease = (value: unknown, field: string): AwesomePluginRelease => {\n const release = record(value, field)\n exactKeys(release, ['version', 'url', 'publishedAt', 'manifestUrl'], field)\n return {\n version: string(release.version, `${field}.version`),\n url: httpUrl(release.url, `${field}.url`),\n publishedAt: dateTime(release.publishedAt, `${field}.publishedAt`),\n manifestUrl:\n release.manifestUrl === null ? null : httpUrl(release.manifestUrl, `${field}.manifestUrl`),\n }\n}\n\nexport class AwesomeRegistryValidationError extends Error {\n public constructor(message: string) {\n super(`Invalid awesome-plugins registry: ${message}`)\n this.name = 'AwesomeRegistryValidationError'\n }\n}\n\nexport class AwesomeRegistryVersionError extends AwesomeRegistryValidationError {\n public constructor(\n public readonly received: unknown,\n path: string,\n ) {\n super(`${path} has unsupported schemaVersion ${String(received)}`)\n this.name = 'AwesomeRegistryVersionError'\n }\n}\n\nexport const parseAwesomeRegistryIndex = (value: unknown): AwesomeRegistryIndex => {\n const index = record(value, 'index')\n exactKeys(index, ['schemaVersion', 'pageSize', 'totalItems', 'totalPages', 'pages'], 'index')\n if (!Array.isArray(index.pages)) {\n throw new AwesomeRegistryValidationError('index.pages must be an array')\n }\n const result: AwesomeRegistryIndex = {\n schemaVersion: schemaVersion(index.schemaVersion, 'index'),\n pageSize: integer(index.pageSize, 'index.pageSize', 1, 100),\n totalItems: integer(index.totalItems, 'index.totalItems', 0),\n totalPages: integer(index.totalPages, 'index.totalPages', 0),\n pages: index.pages.map((item, itemIndex) =>\n parsePageReference(item, `index.pages[${itemIndex}]`),\n ),\n }\n if (result.pages.length !== result.totalPages) {\n throw new AwesomeRegistryValidationError('index.pages length must equal index.totalPages')\n }\n if (result.pages.reduce((total, page) => total + page.items, 0) !== result.totalItems) {\n throw new AwesomeRegistryValidationError('index page item counts must equal index.totalItems')\n }\n result.pages.forEach((page, itemIndex) => {\n if (page.page !== itemIndex + 1 || page.items > result.pageSize) {\n throw new AwesomeRegistryValidationError('index pages must be ordered and respect pageSize')\n }\n })\n return result\n}\n\nexport const parseAwesomePluginListing = (\n value: unknown,\n field = 'listing',\n): AwesomePluginListing => {\n const listing = record(value, field)\n exactKeys(listing, ['schemaVersion', 'id', 'authors', 'download', 'repository', 'release'], field)\n const id = string(listing.id, `${field}.id`)\n if (!PLUGIN_ID_PATTERN.test(id)) {\n throw new AwesomeRegistryValidationError(`${field}.id is invalid`)\n }\n if (!Array.isArray(listing.authors) || listing.authors.length === 0) {\n throw new AwesomeRegistryValidationError(`${field}.authors must be a non-empty array`)\n }\n const authors = listing.authors.map((author, index) => {\n const login = string(author, `${field}.authors[${index}]`)\n if (!GITHUB_LOGIN_PATTERN.test(login)) {\n throw new AwesomeRegistryValidationError(`${field}.authors[${index}] is invalid`)\n }\n return login\n })\n if (new Set(authors).size !== authors.length) {\n throw new AwesomeRegistryValidationError(`${field}.authors must be unique`)\n }\n return {\n schemaVersion: schemaVersion(listing.schemaVersion, field),\n id,\n authors,\n download: parseDownload(listing.download, `${field}.download`),\n ...(listing.repository === undefined\n ? {}\n : { repository: parseRepository(listing.repository, `${field}.repository`) }),\n ...(listing.release === undefined\n ? {}\n : { release: parseRelease(listing.release, `${field}.release`) }),\n }\n}\n\nconst parsePagination = (value: unknown, field: string): AwesomeRegistryPagination => {\n const pagination = record(value, field)\n exactKeys(pagination, ['page', 'pageSize', 'totalItems', 'totalPages', 'previous', 'next'], field)\n return {\n page: integer(pagination.page, `${field}.page`, 1),\n pageSize: integer(pagination.pageSize, `${field}.pageSize`, 1, 100),\n totalItems: integer(pagination.totalItems, `${field}.totalItems`, 0),\n totalPages: integer(pagination.totalPages, `${field}.totalPages`, 1),\n previous: pagination.previous === null ? null : path(pagination.previous, `${field}.previous`),\n next: pagination.next === null ? null : path(pagination.next, `${field}.next`),\n }\n}\n\nexport const parseAwesomeRegistryPage = (value: unknown): AwesomeRegistryPage => {\n const page = record(value, 'page')\n exactKeys(page, ['schemaVersion', 'pagination', 'items'], 'page')\n if (!Array.isArray(page.items)) {\n throw new AwesomeRegistryValidationError('page.items must be an array')\n }\n const result: AwesomeRegistryPage = {\n schemaVersion: schemaVersion(page.schemaVersion, 'page'),\n pagination: parsePagination(page.pagination, 'page.pagination'),\n items: page.items.map((item, index) => parseAwesomePluginListing(item, `page.items[${index}]`)),\n }\n if (result.items.length > result.pagination.pageSize) {\n throw new AwesomeRegistryValidationError('page.items exceeds pageSize')\n }\n const expectedPrevious = result.pagination.page === 1 ? null : result.pagination.page - 1\n const expectedNext =\n result.pagination.page === result.pagination.totalPages ? null : result.pagination.page + 1\n if (\n (expectedPrevious === null) !== (result.pagination.previous === null) ||\n (expectedNext === null) !== (result.pagination.next === null)\n ) {\n throw new AwesomeRegistryValidationError('page pagination links are inconsistent')\n }\n return result\n}\n\nexport const assertAwesomeRegistryPagePath = (value: string) => path(value, 'page path')","import { parseAwesomeRegistryIndex, parseAwesomeRegistryPage } from './schema'\nimport type { AwesomeRegistryIndex, AwesomeRegistryPage, AwesomeRegistryStorage } from './types'\n\ninterface CacheEnvelope {\n cachedAt: string\n data: unknown\n}\n\nconst parseEnvelope = (value: string): CacheEnvelope | undefined => {\n try {\n const envelope = JSON.parse(value) as Partial<CacheEnvelope>\n if (typeof envelope.cachedAt !== 'string' || !('data' in envelope)) return undefined\n return { cachedAt: envelope.cachedAt, data: envelope.data }\n } catch {\n return undefined\n }\n}\n\nexport class AwesomeRegistryCache {\n public constructor(\n private readonly storage?: AwesomeRegistryStorage,\n private readonly prefix = 'delta-comic:awesome-registry:v1',\n ) {}\n\n public readIndex() {\n return this.read(`${this.prefix}:index`, parseAwesomeRegistryIndex)\n }\n\n public writeIndex(data: AwesomeRegistryIndex) {\n return this.write(`${this.prefix}:index`, data)\n }\n\n public readPage(path: string) {\n return this.read(`${this.prefix}:page:${path}`, parseAwesomeRegistryPage)\n }\n\n public writePage(path: string, data: AwesomeRegistryPage) {\n return this.write(`${this.prefix}:page:${path}`, data)\n }\n\n private read<T>(key: string, parse: (value: unknown) => T) {\n if (!this.storage) return undefined\n let stored: string | null\n try {\n stored = this.storage.getItem(key)\n } catch {\n return undefined\n }\n if (!stored) return undefined\n const envelope = parseEnvelope(stored)\n if (!envelope) {\n this.remove(key)\n return undefined\n }\n try {\n return { cachedAt: envelope.cachedAt, data: parse(envelope.data) }\n } catch {\n this.remove(key)\n return undefined\n }\n }\n\n private remove(key: string) {\n try {\n this.storage?.removeItem(key)\n } catch {}\n }\n\n private write(key: string, data: AwesomeRegistryIndex | AwesomeRegistryPage) {\n const cachedAt = new Date().toISOString()\n try {\n this.storage?.setItem(key, JSON.stringify({ cachedAt, data } satisfies CacheEnvelope))\n } catch {}\n return cachedAt\n }\n}","import { logger } from '@delta-comic/logger'\nimport type { PluginManifest } from '@delta-comic/model'\nimport ky from 'ky'\n\nimport type {\n PluginCatalog,\n PluginCatalogIndex,\n PluginCatalogListing,\n PluginCatalogPage,\n PluginCatalogResult,\n} from '../../install/catalog'\nimport { parsePluginManifest } from '../../install/manifest'\n\nimport { AwesomeRegistryCache } from './cache'\nimport {\n assertAwesomeRegistryPagePath,\n parseAwesomeRegistryIndex,\n parseAwesomeRegistryPage,\n AwesomeRegistryValidationError,\n} from './schema'\nimport {\n AWESOME_REGISTRY_BASE_URL,\n AWESOME_REGISTRY_INDEX_PATH,\n type AwesomePluginListing,\n type AwesomeRegistryIndex,\n type AwesomeRegistryPage,\n type AwesomeRegistryResult,\n type AwesomeRegistryStorage,\n} from './types'\n\nconst marketplaceLogger = logger.scoped('plugin:marketplace')\n\nexport interface AwesomeRegistryClientOptions {\n baseUrl?: string\n cache?: AwesomeRegistryCache\n requestJson?: (url: string, signal?: AbortSignal) => Promise<unknown>\n storage?: AwesomeRegistryStorage\n}\n\nconst defaultRequestJson = async (url: string, signal?: AbortSignal) =>\n await ky.get(url, { retry: 2, signal, timeout: 30_000 }).json<unknown>()\n\nconst defaultStorage = () => {\n try {\n return globalThis.localStorage\n } catch {\n return undefined\n }\n}\n\nexport class AwesomeRegistryNetworkError extends Error {\n public constructor(\n message: string,\n public override readonly cause?: unknown,\n ) {\n super(message)\n this.name = 'AwesomeRegistryNetworkError'\n }\n}\n\nconst catalogIndex = (index: AwesomeRegistryIndex): PluginCatalogIndex => ({\n pageSize: index.pageSize,\n pages: index.pages,\n totalItems: index.totalItems,\n totalPages: index.totalPages,\n})\n\nconst catalogListing = (listing: AwesomePluginListing): PluginCatalogListing => ({\n authors: listing.authors,\n id: listing.id,\n ...(listing.release ? { release: listing.release } : {}),\n ...(listing.repository ? { repository: listing.repository } : {}),\n source: listing.download,\n})\n\nconst catalogPage = (page: AwesomeRegistryPage): PluginCatalogPage => ({\n items: page.items.map(catalogListing),\n pagination: page.pagination,\n})\n\nexport class AwesomeRegistryClient implements PluginCatalog {\n private readonly baseUrl: string\n private readonly cache: AwesomeRegistryCache\n private readonly requestJson: (url: string, signal?: AbortSignal) => Promise<unknown>\n\n public constructor(options: AwesomeRegistryClientOptions = {}) {\n this.baseUrl = new URL(options.baseUrl ?? AWESOME_REGISTRY_BASE_URL).href\n this.cache = options.cache ?? new AwesomeRegistryCache(options.storage ?? defaultStorage())\n this.requestJson = options.requestJson ?? defaultRequestJson\n }\n\n public async loadIndex(signal?: AbortSignal): Promise<PluginCatalogResult<PluginCatalogIndex>> {\n const result = await this.load(\n AWESOME_REGISTRY_INDEX_PATH,\n parseAwesomeRegistryIndex,\n () => this.cache.readIndex(),\n data => this.cache.writeIndex(data),\n signal,\n )\n return { ...result, data: catalogIndex(result.data) }\n }\n\n public async loadPage(\n path: string,\n signal?: AbortSignal,\n ): Promise<PluginCatalogResult<PluginCatalogPage>> {\n const safePath = assertAwesomeRegistryPagePath(path)\n const result = await this.load(\n safePath,\n parseAwesomeRegistryPage,\n () => this.cache.readPage(safePath),\n data => this.cache.writePage(safePath, data),\n signal,\n )\n return { ...result, data: catalogPage(result.data) }\n }\n\n public async resolveInstallInput(id: string, signal: AbortSignal) {\n const listing = await this.findListing(id, signal)\n return listing.source.type === 'github' ? `gh:${listing.source.repository}` : listing.source.url\n }\n\n public async findListing(id: string, signal?: AbortSignal): Promise<PluginCatalogListing> {\n marketplaceLogger.debug('searching marketplace listing', { plugin: id })\n const { data: index } = await this.loadIndex(signal)\n for (const pageReference of index.pages) {\n const { data: page } = await this.loadPage(pageReference.path, signal)\n const listing = page.items.find(item => item.id === id)\n if (listing) {\n marketplaceLogger.debug('marketplace listing found', { plugin: id })\n return listing\n }\n }\n throw new Error(`Plugin \"${id}\" is not registered in awesome-plugins`)\n }\n\n public async loadManifest(\n listing: PluginCatalogListing,\n signal?: AbortSignal,\n ): Promise<PluginManifest | undefined> {\n const manifestUrl = listing.release?.manifestUrl\n if (!manifestUrl) return undefined\n const manifest = parsePluginManifest(await this.requestJson(manifestUrl, signal))\n if (manifest.name.id !== listing.id) {\n throw new AwesomeRegistryValidationError(\n `listing ${listing.id} points to manifest for ${manifest.name.id}`,\n )\n }\n return manifest\n }\n\n private async load<T>(\n path: string,\n parse: (value: unknown) => T,\n readCache: () => { data: T; cachedAt: string } | undefined,\n writeCache: (data: T) => string,\n signal?: AbortSignal,\n ): Promise<AwesomeRegistryResult<T>> {\n let payload: unknown\n try {\n payload = await this.requestJson(new URL(path, this.baseUrl).href, signal)\n } catch (error) {\n if (signal?.aborted) throw signal.reason\n if (error instanceof AwesomeRegistryValidationError || error instanceof SyntaxError)\n throw error\n const cached = readCache()\n if (cached) {\n marketplaceLogger.warn('marketplace request failed; using stale cache', { path }, error)\n return { ...cached, stale: true }\n }\n marketplaceLogger.error('marketplace request failed without cache', { path }, error)\n throw new AwesomeRegistryNetworkError(`Failed to request awesome-plugins ${path}`, error)\n }\n const data = parse(payload)\n marketplaceLogger.debug('marketplace response cached', { path })\n return { cachedAt: writeCache(data), data, stale: false }\n }\n}","import { useConfig as useDbConfig } from '@delta-comic/db'\nimport type { FormDefaultValue, FormResult } from '@delta-comic/model'\nimport { shallowReactive, type Ref } from 'vue'\n\nimport type { ConfigPointer, UnwrapConfigPointer } from '../api'\n\nexport type ConfigSave<T extends ConfigPointer = ConfigPointer> = {\n form: UnwrapConfigPointer<T>\n data: Ref<FormResult<T['config']>>\n name: string\n ready: Promise<void>\n}\n\ntype StoredConfigSave = {\n data: Ref<Record<string, FormDefaultValue[keyof FormDefaultValue]>>\n form: ConfigPointer['config']\n name: string\n ready: Promise<void>\n}\n\nexport type PluginConfigLoader = <T extends ConfigPointer>(pointer: T) => ConfigSave<T>\n\nconst loadDatabaseConfig: PluginConfigLoader = pointer => {\n const store = useDbConfig(pointer.pluginName, pointer.config)\n return { data: store, form: pointer.config, name: pointer.configName, ready: store.ready }\n}\n\nexport class ConfigStore {\n private readonly entries = shallowReactive(new Map<symbol, StoredConfigSave>())\n private readonly pointers = new Map<string, ConfigPointer>()\n private readonly isSystemDark =\n globalThis.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false\n\n public constructor(private readonly loadConfig: PluginConfigLoader = loadDatabaseConfig) {}\n\n public get form(): ReadonlyMap<symbol, StoredConfigSave> {\n return this.entries\n }\n\n public get isDark() {\n const pointer = this.pointers.get('core')\n if (!pointer) return this.isSystemDark\n const mode = (this.load(pointer).data.value as { darkMode?: string }).darkMode\n if (mode === 'light') return false\n if (mode === 'dark') return true\n return this.isSystemDark\n }\n\n public load<T extends ConfigPointer>(pointer: T): ConfigSave<T> {\n const value = this.entries.get(pointer.key)\n if (!value) throw new Error(`not found config by plugin \"${pointer.pluginName}\"`)\n return value as ConfigSave<T>\n }\n\n public has(pointer: ConfigPointer) {\n return this.entries.has(pointer.key)\n }\n\n public register<T extends ConfigPointer>(pointer: T) {\n const registered = this.entries.get(pointer.key)\n const ownerPointer = this.pointers.get(pointer.pluginName)\n if (registered && ownerPointer === pointer) return registered as ConfigSave<T>\n if (ownerPointer) {\n throw new Error(`plugin \"${pointer.pluginName}\" can only register one config`)\n }\n\n const saved = this.loadConfig(pointer)\n this.entries.set(pointer.key, saved as StoredConfigSave)\n this.pointers.set(pointer.pluginName, pointer)\n return saved\n }\n\n public unregister(pointer: ConfigPointer) {\n if (this.pointers.get(pointer.pluginName) !== pointer) return\n this.pointers.delete(pointer.pluginName)\n this.entries.delete(pointer.key)\n }\n}","import type { PluginCandidate, PluginCandidateProvider } from '../kernel'\n\nimport type { PluginArchiveRepository, PluginModuleReader } from './contracts'\n\n/**\n * The persisted `enable` flag is stored in a `TEXT` column. `kysely-plugin-serialize` normally\n * restores booleans, but the value that reaches this boundary is only typed as `boolean` — not\n * guaranteed at runtime. Normalize it so a legacy string/number (`'false'`, `'0'`, `1`, ...) can\n * never be mistaken for `true` by the runtime's truthiness check.\n */\nconst toBoolean = (value: unknown): boolean =>\n value === true || value === 'true' || value === 1 || value === '1'\n\n/** Normalize persisted archives into the same candidate protocol used by internal plugins. */\nexport class InstalledPluginCandidateProvider implements PluginCandidateProvider {\n public readonly id = 'installed'\n\n public constructor(\n private readonly repository: PluginArchiveRepository,\n private readonly readers: readonly PluginModuleReader[],\n ) {}\n\n public async list(signal: AbortSignal): Promise<PluginCandidate[]> {\n const archives = await this.repository.list()\n signal.throwIfAborted()\n return archives.map(archive => ({\n enabled: toBoolean(archive.enable),\n load: async loadSignal => {\n const reader =\n this.readers.find(candidate => candidate.matches?.(archive)) ??\n this.readers.find(candidate => !candidate.matches) ??\n this.readers[0]\n if (!reader) throw new Error('no plugin module reader is configured')\n return await reader.read(archive, loadSignal)\n },\n management: {\n canDisable: true,\n canUninstall: true,\n canUpdate: archive.installInput.length > 0,\n },\n manifest: archive.meta,\n origin: 'installed',\n }))\n }\n}","import type { PluginManifest } from '@delta-comic/model'\n\nexport type PluginCatalogSource =\n | { readonly type: 'github'; readonly repository: string }\n | { readonly type: 'url'; readonly url: string }\n\nexport interface PluginCatalogRepository {\n readonly defaultBranch: string\n readonly lastCommitAt: string\n readonly name: string\n readonly owner: string\n readonly readmeUrl?: string\n readonly url: string\n}\n\nexport interface PluginCatalogRelease {\n readonly manifestUrl: string | null\n readonly publishedAt: string\n readonly url: string\n readonly version: string\n}\n\nexport interface PluginCatalogListing {\n readonly authors: readonly string[]\n readonly id: string\n readonly release?: PluginCatalogRelease\n readonly repository?: PluginCatalogRepository\n readonly source: PluginCatalogSource\n}\n\nexport interface PluginCatalogPageReference {\n readonly items: number\n readonly page: number\n readonly path: string\n}\n\nexport interface PluginCatalogIndex {\n readonly pageSize: number\n readonly pages: readonly PluginCatalogPageReference[]\n readonly totalItems: number\n readonly totalPages: number\n}\n\nexport interface PluginCatalogPagination {\n readonly next: string | null\n readonly page: number\n readonly pageSize: number\n readonly previous: string | null\n readonly totalItems: number\n readonly totalPages: number\n}\n\nexport interface PluginCatalogPage {\n readonly items: readonly PluginCatalogListing[]\n readonly pagination: PluginCatalogPagination\n}\n\nexport interface PluginCatalogResult<T> {\n readonly cachedAt: string\n readonly data: T\n readonly stale: boolean\n}\n\n/** The narrow catalog port required by an install source resolver. */\nexport interface PluginInstallCatalog {\n resolveInstallInput(plugin: string, signal: AbortSignal): Promise<string>\n}\n\n/** Host-facing catalog operations used by the marketplace feature. */\nexport interface PluginCatalog extends PluginInstallCatalog {\n loadIndex(signal?: AbortSignal): Promise<PluginCatalogResult<PluginCatalogIndex>>\n loadManifest(\n listing: PluginCatalogListing,\n signal?: AbortSignal,\n ): Promise<PluginManifest | undefined>\n loadPage(path: string, signal?: AbortSignal): Promise<PluginCatalogResult<PluginCatalogPage>>\n}\n\nconst catalogInstallInputPattern = /^ap:([A-Za-z0-9][A-Za-z0-9_-]{0,63})$/\n\nexport const pluginCatalogInstallInput = (plugin: string) => {\n const input = `ap:${plugin}`\n if (!catalogInstallInputPattern.test(input)) {\n throw new TypeError(`invalid plugin catalog id: ${plugin}`)\n }\n return input\n}\n\nexport const pluginCatalogIdFromInstallInput = (input: unknown) =>\n typeof input === 'string' ? catalogInstallInputPattern.exec(input)?.[1] : undefined","import type { PluginManifest } from '@delta-comic/model'\nimport JSZip from 'jszip'\n\nimport type { DecodedPluginPackage, PluginPackageCodec } from './contracts'\nimport { parsePluginManifest, safePluginPath } from './manifest'\n\nconst sha256 = async (bytes: Uint8Array) => {\n const digest = await globalThis.crypto.subtle.digest('SHA-256', Uint8Array.from(bytes).buffer)\n return [...new Uint8Array(digest)].map(value => value.toString(16).padStart(2, '0')).join('')\n}\n\nconst withIntegrity = async (manifest: PluginManifest, bytes: Uint8Array) => ({\n ...manifest,\n integrity: { algorithm: 'sha256' as const, digest: await sha256(bytes) },\n})\n\nexport class ZipPackageCodec implements PluginPackageCodec {\n public readonly id = 'zip'\n\n public matches(file: File) {\n return file.name.toLowerCase().endsWith('.zip') || file.type === 'application/zip'\n }\n\n public async decode(file: File, signal: AbortSignal): Promise<DecodedPluginPackage> {\n const bytes = new Uint8Array(await file.arrayBuffer())\n if (signal.aborted) throw signal.reason\n const archive = await JSZip.loadAsync(bytes)\n const manifestFile = archive.file('manifest.json')\n if (!manifestFile) throw new Error('plugin archive does not contain manifest.json')\n const manifest = await withIntegrity(\n parsePluginManifest(JSON.parse(await manifestFile.async('text'))),\n bytes,\n )\n const files = new Map<string, Uint8Array>()\n for (const entry of Object.values(archive.files)) {\n if (signal.aborted) throw signal.reason\n if (entry.dir) continue\n const path = safePluginPath(entry.name, `archive entry ${entry.name}`)\n files.set(path, await entry.async('uint8array'))\n }\n return { codecId: this.id, files, manifest }\n }\n}","import type { PluginArchiveDB } from '@delta-comic/db'\n\nimport type { PluginConfigFactory } from '../api'\nimport type { LoadedPluginModule } from '../kernel'\n\nimport type { PluginFileStore, PluginModuleReader } from './contracts'\nimport {\n DEV_CSS_PATH,\n DEV_ENTRY_PATH,\n DEV_SERVER_LOADER_ID,\n devServerUrl,\n parseDevServerPort,\n} from './dev'\n\nconst asFactory = (value: unknown, plugin: string): PluginConfigFactory => {\n if (typeof value !== 'function') {\n throw new TypeError(`plugin entry has no default factory: ${plugin}`)\n }\n return value as PluginConfigFactory\n}\n\nconst styleActivator = (plugin: string, styleText: string | undefined) =>\n styleText === undefined\n ? undefined\n : (scope: import('../kernel').PluginScope) => {\n if (typeof document === 'undefined') return\n const style = document.createElement('style')\n style.dataset.plugin = plugin\n style.textContent = styleText\n document.head.append(style)\n scope.defer(() => style.remove())\n }\n\nexport class StoredPluginModuleReader implements PluginModuleReader {\n public readonly id = 'stored'\n\n public constructor(private readonly files: PluginFileStore) {}\n\n public async read(\n archive: PluginArchiveDB.Archive,\n signal: AbortSignal,\n ): Promise<LoadedPluginModule> {\n const plugin = archive.pluginName\n const url = await this.files.createModuleUrl(plugin, 'index.mjs')\n if (signal.aborted) {\n this.files.release(plugin)\n throw signal.reason\n }\n try {\n const module = (await import(/* @vite-ignore */ url)) as { default?: unknown }\n signal.throwIfAborted()\n let styleText: string | undefined\n try {\n styleText = new TextDecoder().decode(await this.files.read(plugin, 'index.css'))\n } catch {\n styleText = undefined\n }\n signal.throwIfAborted()\n return {\n activate: styleActivator(plugin, styleText),\n factory: asFactory(module.default, plugin),\n dispose: () => this.files.release(plugin),\n }\n } catch (error) {\n this.files.release(plugin)\n throw error\n }\n }\n}\n\nexport class DevServerPluginModuleReader implements PluginModuleReader {\n public readonly id = DEV_SERVER_LOADER_ID\n readonly #versions = new Map<string, number>()\n\n public matches(archive: PluginArchiveDB.Archive) {\n return archive.loaderName === this.id\n }\n\n public async read(\n archive: PluginArchiveDB.Archive,\n signal: AbortSignal,\n ): Promise<LoadedPluginModule> {\n const port = parseDevServerPort(archive.installInput)\n if (port === undefined) {\n throw new Error(`development plugin has an invalid install source: ${archive.installInput}`)\n }\n const previousVersion = this.#versions.get(archive.pluginName)\n const version = (previousVersion ?? 0) + 1\n this.#versions.set(archive.pluginName, version)\n signal.throwIfAborted()\n\n // Keep the first entry URL stable so its source modules share one native Vite HMR graph.\n // Explicit plugin updates still get a fresh bootstrap URL after the first load.\n const entryUrl = devServerUrl(port, DEV_ENTRY_PATH)\n const moduleUrl = previousVersion === undefined ? entryUrl : `${entryUrl}?v=${version}`\n const module = (await import(/* @vite-ignore */ moduleUrl)) as { default?: unknown }\n signal.throwIfAborted()\n\n let styleText: string | undefined\n const response = await fetch(devServerUrl(port, DEV_CSS_PATH), { cache: 'no-store', signal })\n if (response.status !== 404) {\n if (!response.ok) throw new Error(`development plugin CSS request failed: ${response.status}`)\n styleText = await response.text()\n }\n signal.throwIfAborted()\n return {\n activate: styleActivator(archive.pluginName, styleText),\n factory: asFactory(module.default, archive.pluginName),\n }\n }\n}","import { assertWriteRow, db, validateReadRow, type PluginArchiveDB } from '@delta-comic/db'\n\nimport type { PluginArchiveRepository } from './contracts'\n\nexport class DatabasePluginArchiveRepository implements PluginArchiveRepository {\n public async find(plugin: string) {\n const row = await db\n .selectFrom('plugin')\n .selectAll()\n .where('pluginName', '=', plugin)\n .executeTakeFirst()\n return row ? validateReadRow('plugin', row) : undefined\n }\n\n public async list() {\n const rows = await db.selectFrom('plugin').selectAll().execute()\n return rows.map(row => validateReadRow('plugin', row))\n }\n\n public async remove(plugin: string) {\n await db.deleteFrom('plugin').where('pluginName', '=', plugin).execute()\n }\n\n public async upsert(archive: PluginArchiveDB.Archive) {\n const row = assertWriteRow('plugin', { ...archive, meta: JSON.stringify(archive.meta) })\n await db.replaceInto('plugin').values(row).execute()\n }\n}","import type { PluginArchiveDB } from '@delta-comic/db'\n\nimport type {\n DecodedPluginPackage,\n PluginArchiveRepository,\n PluginFileStore,\n PluginInstallInput,\n PluginInstallReporter,\n PluginPackageCodec,\n PluginSourceResolver,\n ResolvedPluginSource,\n} from './contracts'\n\nexport interface PluginInstallServiceOptions {\n readonly codecs: readonly PluginPackageCodec[]\n readonly files: PluginFileStore\n readonly repository: PluginArchiveRepository\n readonly reservedIds?: ReadonlySet<string>\n readonly resolvers: readonly PluginSourceResolver[]\n}\n\ninterface PluginInstallContext {\n readonly installing: Set<string>\n readonly installed: Set<string>\n readonly added: string[]\n}\n\nexport class PluginInstallService {\n public constructor(private readonly options: PluginInstallServiceOptions) {}\n\n public async install(\n input: PluginInstallInput,\n signal = new AbortController().signal,\n report: PluginInstallReporter = () => {},\n ) {\n const context: PluginInstallContext = { added: [], installed: new Set(), installing: new Set() }\n try {\n return await this.#install(input, signal, report, context)\n } catch (error) {\n const rollbackErrors: unknown[] = [error]\n for (const plugin of [...context.added].reverse()) {\n try {\n await this.uninstall(plugin)\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n }\n if (rollbackErrors.length === 1) throw error\n throw new AggregateError(rollbackErrors, 'failed to install plugin dependencies')\n }\n }\n\n async #install(\n input: PluginInstallInput,\n signal: AbortSignal,\n report: PluginInstallReporter,\n context: PluginInstallContext,\n expectedPlugin?: string,\n ) {\n report({ phase: 'resolve', progress: 0 })\n const resolver = this.options.resolvers.find(candidate => candidate.matches(input))\n if (!resolver) throw new Error('no plugin source resolver accepts this input')\n const source = await resolver.resolve(input, signal, report)\n report({\n description: source.file?.name ?? source.installInput,\n phase: 'resolve',\n progress: 100,\n })\n\n const decoded = source.package ?? (await this.#decode(source, signal, report))\n const plugin = decoded.manifest.name.id\n if (this.options.reservedIds?.has(plugin)) {\n throw new Error(`plugin id \"${plugin}\" is reserved by an internal plugin`)\n }\n if (expectedPlugin && plugin !== expectedPlugin) {\n throw new Error(`plugin dependency \"${expectedPlugin}\" downloaded as \"${plugin}\"`)\n }\n if (context.installing.has(plugin)) {\n throw new Error(`plugin dependency cycle includes \"${plugin}\"`)\n }\n report({ description: plugin, phase: 'decode', progress: 100 })\n\n context.installing.add(plugin)\n try {\n for (const dependency of decoded.manifest.require) {\n if (\n this.options.reservedIds?.has(dependency.id) ||\n context.installed.has(dependency.id) ||\n (await this.options.repository.find(dependency.id))\n ) {\n context.installed.add(dependency.id)\n continue\n }\n if (!dependency.download) continue\n await this.#install(dependency.download, signal, report, context, dependency.id)\n }\n\n const previous = await this.options.repository.find(plugin)\n const replacement = await this.options.files.replace(\n plugin,\n source.storage === 'remote' ? new Map() : decoded.files,\n )\n const archive: PluginArchiveDB.Archive = {\n displayName: decoded.manifest.name.display,\n enable: previous?.enable ?? true,\n installerName: source.resolverId,\n installInput: source.installInput,\n loaderName: source.package?.codecId ?? decoded.codecId,\n meta: decoded.manifest,\n pluginName: plugin,\n }\n\n try {\n report({ description: plugin, phase: 'persist', progress: 50 })\n await this.options.repository.upsert(archive)\n await replacement.commit()\n report({ description: plugin, phase: 'persist', progress: 100 })\n context.installed.add(plugin)\n if (!previous) context.added.push(plugin)\n return archive\n } catch (error) {\n const rollbackErrors: unknown[] = []\n try {\n await replacement.rollback()\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n try {\n if (previous) await this.options.repository.upsert(previous)\n else await this.options.repository.remove(plugin)\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n if (rollbackErrors.length > 0) {\n throw new AggregateError(\n [error, ...rollbackErrors],\n `failed to install plugin \"${plugin}\"`,\n )\n }\n throw error\n }\n } finally {\n context.installing.delete(plugin)\n }\n }\n\n async #decode(\n source: ResolvedPluginSource,\n signal: AbortSignal,\n report: PluginInstallReporter,\n ): Promise<DecodedPluginPackage> {\n const file = source.file\n if (!file) throw new Error('resolved plugin source contains neither a file nor a package')\n const codec = this.options.codecs.find(candidate => candidate.matches(file))\n if (!codec) throw new Error('no plugin package codec accepts this file')\n report({ description: codec.id, phase: 'decode', progress: 0 })\n const decoded = await codec.decode(file, signal)\n return decoded\n }\n\n /** Remove archive metadata and files as one compensating transaction. */\n public async uninstall(plugin: string) {\n const previous = await this.options.repository.find(plugin)\n const replacement = await this.options.files.replace(plugin, new Map())\n try {\n await this.options.repository.remove(plugin)\n await replacement.commit()\n } catch (error) {\n const rollbackErrors: unknown[] = []\n try {\n await replacement.rollback()\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n try {\n if (previous) await this.options.repository.upsert(previous)\n } catch (rollbackError) {\n rollbackErrors.push(rollbackError)\n }\n if (rollbackErrors.length > 0) {\n throw new AggregateError(\n [error, ...rollbackErrors],\n `failed to uninstall plugin \"${plugin}\"`,\n )\n }\n throw error\n }\n }\n}","import { logger } from '@delta-comic/logger'\nimport { Octokit } from '@octokit/rest'\n\nimport { pluginCatalogIdFromInstallInput, type PluginInstallCatalog } from './catalog'\nimport type {\n PluginInstallInput,\n PluginInstallReporter,\n PluginSourceResolver,\n ResolvedPluginSource,\n} from './contracts'\nimport {\n DEV_CSS_PATH,\n DEV_ENTRY_PATH,\n DEV_MANIFEST_PATH,\n DEV_SERVER_LOADER_ID,\n devServerUrl,\n parseDevServerPort,\n} from './dev'\nimport { isPluginManifestCompatible, parsePluginManifest } from './manifest'\n\nconst REPORT_INTERVAL = 250\n\nasync function responseFile(\n response: Response,\n name: string,\n report: PluginInstallReporter = () => {},\n): Promise<File> {\n const totalHeader = response.headers.get('content-length')\n const totalBytes = totalHeader ? Number(totalHeader) : undefined\n const reader = response.body?.getReader()\n if (!reader) return new File([await response.blob()], name)\n\n const chunks: Uint8Array<ArrayBuffer>[] = []\n let downloadedBytes = 0\n let lastReport = 0\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n const chunk = new Uint8Array(value.byteLength)\n chunk.set(value)\n chunks.push(chunk)\n downloadedBytes += value.byteLength\n const now = performance.now()\n if (now - lastReport < REPORT_INTERVAL) continue\n lastReport = now\n report({\n downloadedBytes,\n phase: 'resolve',\n progress: totalBytes ? (downloadedBytes / totalBytes) * 100 : undefined,\n totalBytes,\n })\n }\n report({ downloadedBytes, phase: 'resolve', progress: 100, totalBytes })\n return new File(chunks, name)\n}\n\nexport class LocalFileSourceResolver implements PluginSourceResolver {\n public readonly id = 'local-file'\n\n public matches(input: PluginInstallInput): input is File {\n return typeof input !== 'string'\n }\n\n public async resolve(input: PluginInstallInput): Promise<ResolvedPluginSource> {\n if (typeof input === 'string') throw new TypeError('local file resolver requires a File')\n return { file: input, installInput: '', resolverId: this.id }\n }\n}\n\nexport class HttpSourceResolver implements PluginSourceResolver {\n public readonly id = 'http'\n\n public matches(input: PluginInstallInput): input is string {\n return typeof input === 'string' && /^https?:\\/\\//i.test(input)\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n report?: PluginInstallReporter,\n ): Promise<ResolvedPluginSource> {\n if (typeof input !== 'string') throw new TypeError('HTTP resolver requires a URL')\n const response = await fetch(input, { signal })\n if (!response.ok) throw new Error(`plugin download failed: ${response.status}`)\n const name = new URL(input).pathname.split('/').at(-1) || 'plugin.zip'\n return {\n file: await responseFile(response, name, report),\n installInput: input,\n resolverId: this.id,\n }\n }\n}\n\nconst fetchDevText = async (\n url: string,\n signal: AbortSignal,\n optional = false,\n): Promise<string | undefined> => {\n const response = await fetch(url, { cache: 'no-store', signal })\n if (!response.ok) {\n if (optional && response.status === 404) return undefined\n throw new Error(`development plugin request failed: ${response.status}`)\n }\n return await response.text()\n}\n\nexport class DevServerSourceResolver implements PluginSourceResolver {\n public readonly id = DEV_SERVER_LOADER_ID\n\n public matches(input: PluginInstallInput): input is string {\n return typeof input === 'string' && parseDevServerPort(input) !== undefined\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n ): Promise<ResolvedPluginSource> {\n if (typeof input !== 'string') throw new TypeError('development resolver requires dev:<port>')\n const port = parseDevServerPort(input)\n if (port === undefined) throw new TypeError('development resolver requires dev:<port>')\n\n const manifestText = await fetchDevText(devServerUrl(port, DEV_MANIFEST_PATH), signal)\n const manifest = parsePluginManifest(JSON.parse(manifestText ?? ''))\n await fetchDevText(devServerUrl(port, DEV_ENTRY_PATH), signal)\n await fetchDevText(devServerUrl(port, DEV_CSS_PATH), signal, true)\n\n return {\n installInput: input,\n package: { codecId: this.id, files: new Map(), manifest },\n resolverId: this.id,\n storage: 'remote',\n }\n }\n}\n\nexport interface GitHubSourceResolverOptions {\n readonly coreVersion: string\n readonly includePrereleases?: () => boolean\n readonly token?: string\n}\n\nexport class GitHubSourceResolver implements PluginSourceResolver {\n public readonly id = 'github'\n\n public constructor(private readonly options: GitHubSourceResolverOptions) {}\n\n public matches(input: PluginInstallInput): input is string {\n return typeof input === 'string' && /^gh:[^/]+\\/[^/]+$/.test(input)\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n report?: PluginInstallReporter,\n ) {\n if (typeof input !== 'string') throw new TypeError('GitHub resolver requires a repository')\n const [owner, repo] = input.slice(3).split('/') as [string, string]\n logger.info('github use token : ', this.options.token)\n const octokit = new Octokit({ auth: this.options.token })\n const includePrereleases = this.options.includePrereleases?.() ?? false\n const pages = octokit.paginate.iterator(octokit.rest.repos.listReleases, {\n owner,\n per_page: 100,\n repo,\n request: { signal },\n })\n for await (const page of pages) {\n for (const release of page.data) {\n if (release.draft || (release.prerelease && !includePrereleases)) continue\n const manifestAsset = release.assets.find(asset => asset.name === 'manifest.json')\n const packageAsset = release.assets.find(asset => asset.name === 'plugin.zip')\n if (!manifestAsset || !packageAsset) continue\n const manifestResponse = await fetch(manifestAsset.browser_download_url, { signal })\n if (!manifestResponse.ok) continue\n const manifest = parsePluginManifest(await manifestResponse.json())\n if (!isPluginManifestCompatible(manifest, this.options.coreVersion)) continue\n logger.info('download plugin from github with response: ', packageAsset)\n const packageResponse = await fetch(packageAsset.browser_download_url, { signal })\n if (!packageResponse.ok)\n throw new Error(`plugin download failed: ${packageResponse.status}`)\n return {\n file: await responseFile(packageResponse, packageAsset.name, report),\n installInput: input,\n resolverId: this.id,\n }\n }\n }\n throw new Error(`no compatible plugin release found for ${owner}/${repo}`)\n }\n}\n\nexport class MarketplaceSourceResolver implements PluginSourceResolver {\n public readonly id = 'marketplace'\n\n public constructor(\n private readonly catalog: PluginInstallCatalog,\n private readonly sources: readonly PluginSourceResolver[],\n ) {}\n\n public matches(input: PluginInstallInput): input is string {\n return pluginCatalogIdFromInstallInput(input) !== undefined\n }\n\n public async resolve(\n input: PluginInstallInput,\n signal: AbortSignal,\n report?: PluginInstallReporter,\n ) {\n if (typeof input !== 'string') {\n throw new TypeError('marketplace resolver requires a plugin catalog id')\n }\n const plugin = pluginCatalogIdFromInstallInput(input)\n if (!plugin) throw new TypeError('marketplace resolver requires a plugin catalog id')\n const redirected = await this.catalog.resolveInstallInput(plugin, signal)\n const resolver = this.sources.find(source => source.matches(redirected))\n if (!resolver)\n throw new Error(`plugin catalog returned an unsupported install source: ${redirected}`)\n const source = await resolver.resolve(redirected, signal, report)\n return { ...source, installInput: input, resolverId: this.id }\n }\n}","import { convertFileSrc, isTauri } from '@tauri-apps/api/core'\n\nimport type { PluginFileReplacement, PluginFileStore } from '../install'\nimport { safePluginPath } from '../install'\n\ntype PluginFiles = ReadonlyMap<string, Uint8Array>\n\nexport const getTauriPluginRoot = async (plugin: string) => {\n const { appLocalDataDir, join } = await import('@tauri-apps/api/path')\n return await join(await appLocalDataDir(), 'plugin', plugin)\n}\n\ninterface PluginFileBackend {\n read(plugin: string, path: string): Promise<Uint8Array>\n snapshot(plugin: string): Promise<Map<string, Uint8Array>>\n replace(plugin: string, files: PluginFiles): Promise<void>\n moduleUrl?(plugin: string, path: string): Promise<string>\n}\n\nconst cloneFiles = (files: PluginFiles) =>\n new Map([...files].map(([path, bytes]) => [path, Uint8Array.from(bytes)]))\n\nconst mimeType = (path: string) =>\n ({\n avif: 'image/avif',\n gif: 'image/gif',\n jpeg: 'image/jpeg',\n jpg: 'image/jpeg',\n png: 'image/png',\n svg: 'image/svg+xml',\n webp: 'image/webp',\n })[path.split('.').at(-1)?.toLowerCase() ?? ''] ?? 'application/octet-stream'\n\nexport const createPluginProtocolUrl = (plugin: string, path: string) => {\n const base = convertFileSrc('', 'plugin')\n const encodedPath = safePluginPath(path, 'plugin protocol path')\n .split('/')\n .map(encodeURIComponent)\n .join('/')\n return `${base}${encodeURIComponent(plugin)}/${encodedPath}`\n}\n\nexport class MemoryPluginFileStore implements PluginFileStore {\n readonly #files = new Map<string, Map<string, Uint8Array>>()\n readonly #urls = new Map<string, Set<string>>()\n\n public async replace(plugin: string, files: PluginFiles): Promise<PluginFileReplacement> {\n const previous = cloneFiles(this.#files.get(plugin) ?? new Map())\n this.#files.set(plugin, cloneFiles(files))\n let settled = false\n return {\n commit: async () => {\n settled = true\n },\n rollback: async () => {\n if (settled) return\n settled = true\n this.#files.set(plugin, previous)\n },\n }\n }\n\n public async remove(plugin: string) {\n this.release(plugin)\n this.#files.delete(plugin)\n }\n\n public async read(plugin: string, path: string) {\n const bytes = this.#files.get(plugin)?.get(safePluginPath(path, 'plugin file path'))\n if (!bytes) throw new Error(`plugin file not found: ${plugin}/${path}`)\n return Uint8Array.from(bytes)\n }\n\n public async createModuleUrl(plugin: string, path: string) {\n return await this.#createUrl(plugin, path, 'text/javascript')\n }\n\n public async createAssetUrl(plugin: string, path: string) {\n return await this.#createUrl(plugin, path, mimeType(path))\n }\n\n async #createUrl(plugin: string, path: string, type: string) {\n const bytes = await this.read(plugin, path)\n const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes)], { type }))\n const urls = this.#urls.get(plugin) ?? new Set<string>()\n urls.add(url)\n this.#urls.set(plugin, urls)\n return url\n }\n\n public release(plugin: string) {\n for (const url of this.#urls.get(plugin) ?? []) URL.revokeObjectURL(url)\n this.#urls.delete(plugin)\n }\n}\n\nclass IndexedDbPluginFileBackend implements PluginFileBackend {\n readonly #database = 'delta-comic-plugin-files-v2'\n readonly #store = 'files'\n\n async #open() {\n return await new Promise<IDBDatabase>((resolve, reject) => {\n const request = indexedDB.open(this.#database, 1)\n request.onupgradeneeded = () => {\n if (!request.result.objectStoreNames.contains(this.#store)) {\n request.result.createObjectStore(this.#store)\n }\n }\n request.onsuccess = () => resolve(request.result)\n request.onerror = () => reject(request.error)\n })\n }\n\n #key(plugin: string, path: string) {\n return `${plugin}/${path}`\n }\n\n public async read(plugin: string, path: string) {\n const database = await this.#open()\n try {\n return await new Promise<Uint8Array>((resolve, reject) => {\n const transaction = database.transaction(this.#store, 'readonly')\n const request = transaction.objectStore(this.#store).get(this.#key(plugin, path))\n request.onsuccess = () => {\n if (!request.result) reject(new Error(`plugin file not found: ${plugin}/${path}`))\n else resolve(Uint8Array.from(request.result as Uint8Array))\n }\n request.onerror = () => reject(request.error)\n })\n } finally {\n database.close()\n }\n }\n\n public async snapshot(plugin: string) {\n const database = await this.#open()\n try {\n return await new Promise<Map<string, Uint8Array>>((resolve, reject) => {\n const files = new Map<string, Uint8Array>()\n const transaction = database.transaction(this.#store, 'readonly')\n const request = transaction.objectStore(this.#store).openCursor()\n const prefix = `${plugin}/`\n request.onsuccess = () => {\n const cursor = request.result\n if (!cursor) return\n const key = String(cursor.key)\n if (key.startsWith(prefix))\n files.set(key.slice(prefix.length), Uint8Array.from(cursor.value))\n cursor.continue()\n }\n request.onerror = () => reject(request.error)\n transaction.oncomplete = () => resolve(files)\n transaction.onerror = () => reject(transaction.error)\n })\n } finally {\n database.close()\n }\n }\n\n public async replace(plugin: string, files: PluginFiles) {\n const database = await this.#open()\n try {\n await new Promise<void>((resolve, reject) => {\n const transaction = database.transaction(this.#store, 'readwrite')\n const store = transaction.objectStore(this.#store)\n const prefix = `${plugin}/`\n const cursor = store.openKeyCursor()\n cursor.onsuccess = () => {\n if (cursor.result) {\n if (String(cursor.result.key).startsWith(prefix)) cursor.result.delete()\n cursor.result.continue()\n return\n }\n for (const [path, bytes] of files) store.put(bytes, this.#key(plugin, path))\n }\n cursor.onerror = () => reject(cursor.error)\n transaction.oncomplete = () => resolve()\n transaction.onerror = () => reject(transaction.error)\n transaction.onabort = () => reject(transaction.error)\n })\n } finally {\n database.close()\n }\n }\n}\n\nclass TauriPluginFileBackend implements PluginFileBackend {\n async #root(plugin: string) {\n return await getTauriPluginRoot(plugin)\n }\n\n public async read(plugin: string, path: string) {\n const [{ join }, fs] = await Promise.all([\n import('@tauri-apps/api/path'),\n import('@tauri-apps/plugin-fs'),\n ])\n return await fs.readFile(await join(await this.#root(plugin), path))\n }\n\n public async snapshot(plugin: string) {\n const [{ join }, fs] = await Promise.all([\n import('@tauri-apps/api/path'),\n import('@tauri-apps/plugin-fs'),\n ])\n const root = await this.#root(plugin)\n const files = new Map<string, Uint8Array>()\n if (!(await fs.exists(root))) return files\n const visit = async (directory: string, prefix = '') => {\n for (const entry of await fs.readDir(directory)) {\n const path = prefix ? `${prefix}/${entry.name}` : entry.name\n const absolute = await join(directory, entry.name)\n if (entry.isDirectory) await visit(absolute, path)\n else if (entry.isFile) files.set(path, await fs.readFile(absolute))\n }\n }\n await visit(root)\n return files\n }\n\n public async replace(plugin: string, files: PluginFiles) {\n const [{ appLocalDataDir, join }, fs] = await Promise.all([\n import('@tauri-apps/api/path'),\n import('@tauri-apps/plugin-fs'),\n ])\n const appData = await appLocalDataDir()\n const base = await join(appData, 'plugin')\n const token = crypto.randomUUID()\n const live = await join(base, plugin)\n const stagingRoot = await join(appData, 'plugin-staging')\n const backupRoot = await join(appData, 'plugin-backup')\n const staging = await join(stagingRoot, `${plugin}-${token}`)\n const backup = await join(backupRoot, `${plugin}-${token}`)\n await fs.mkdir(staging, { recursive: true })\n try {\n for (const [path, bytes] of files) {\n const segments = safePluginPath(path, 'plugin file path').split('/')\n const target = await join(staging, ...segments)\n const parent = await join(staging, ...segments.slice(0, -1))\n await fs.mkdir(parent, { recursive: true })\n await fs.writeFile(target, bytes)\n }\n const existed = await fs.exists(live)\n if (existed) {\n await fs.mkdir(backupRoot, { recursive: true })\n await fs.rename(live, backup)\n }\n try {\n await fs.rename(staging, live)\n } catch (error) {\n if (existed && (await fs.exists(backup))) await fs.rename(backup, live)\n throw error\n }\n if (await fs.exists(backup)) {\n await fs.remove(backup, { recursive: true }).catch(() => undefined)\n }\n } catch (error) {\n if (await fs.exists(staging)) await fs.remove(staging, { recursive: true })\n throw error\n }\n }\n\n public async moduleUrl(plugin: string, path: string) {\n return createPluginProtocolUrl(plugin, path)\n }\n}\n\nexport class AtomicPluginFileStore implements PluginFileStore {\n readonly #moduleVersions = new Map<string, number>()\n readonly #urls = new Map<string, Set<string>>()\n\n public constructor(private readonly backend: PluginFileBackend) {}\n\n public async replace(plugin: string, files: PluginFiles) {\n this.#moduleVersions.set(plugin, (this.#moduleVersions.get(plugin) ?? 0) + 1)\n const previous = await this.backend.snapshot(plugin)\n await this.backend.replace(plugin, files)\n let settled = false\n return {\n commit: async () => {\n settled = true\n },\n rollback: async () => {\n if (settled) return\n settled = true\n await this.backend.replace(plugin, previous)\n },\n }\n }\n\n public async remove(plugin: string) {\n this.#moduleVersions.set(plugin, (this.#moduleVersions.get(plugin) ?? 0) + 1)\n this.release(plugin)\n await this.backend.replace(plugin, new Map())\n }\n\n public read(plugin: string, path: string) {\n return this.backend.read(plugin, safePluginPath(path, 'plugin file path'))\n }\n\n public async createModuleUrl(plugin: string, path: string) {\n const safePath = safePluginPath(path, 'plugin module path')\n if (this.backend.moduleUrl) {\n // The protocol URL is stable, so bust the module cache on every file replacement so a\n // hot reload always evaluates the current files instead of the previously imported module.\n const version = this.#moduleVersions.get(plugin) ?? 0\n return `${await this.backend.moduleUrl(plugin, safePath)}?v=${version}`\n }\n const bytes = await this.backend.read(plugin, safePath)\n const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes)], { type: 'text/javascript' }))\n const urls = this.#urls.get(plugin) ?? new Set<string>()\n urls.add(url)\n this.#urls.set(plugin, urls)\n return url\n }\n\n public async createAssetUrl(plugin: string, path: string) {\n const safePath = safePluginPath(path, 'plugin asset path')\n if (this.backend.moduleUrl) return await this.backend.moduleUrl(plugin, safePath)\n const bytes = await this.backend.read(plugin, safePath)\n const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes)], { type: mimeType(path) }))\n const urls = this.#urls.get(plugin) ?? new Set<string>()\n urls.add(url)\n this.#urls.set(plugin, urls)\n return url\n }\n\n public release(plugin: string) {\n for (const url of this.#urls.get(plugin) ?? []) URL.revokeObjectURL(url)\n this.#urls.delete(plugin)\n }\n}\n\nexport const createDefaultPluginFileStore = () =>\n new AtomicPluginFileStore(\n isTauri() ? new TauriPluginFileBackend() : new IndexedDbPluginFileBackend(),\n )","import { defaultsDeep } from 'es-toolkit/compat'\n\nimport type { PluginLocaleMessage, PluginLocaleMessages } from '../api/i18n'\n\nexport type { PluginLocaleMessage, PluginLocaleMessages } from '../api/i18n'\n\nexport interface PluginI18nAdapter {\n setLocaleMessage(locale: string, message: PluginLocaleMessage): void\n translate?(key: string, params?: Record<string, number | string>): string\n /** 判断消息是否已注册(建议覆盖回退语言链),用于解析宿主渲染的展示文本。 */\n has?(key: string): boolean\n}\n\nexport class PluginI18nRegistry {\n private adapter?: PluginI18nAdapter\n private baseMessages: PluginLocaleMessages = {}\n private readonly pluginMessages = new Map<string, PluginLocaleMessages>()\n\n public install(adapter: PluginI18nAdapter, baseMessages: PluginLocaleMessages) {\n this.adapter = adapter\n this.baseMessages = baseMessages\n this.refresh(this.locales())\n }\n\n public register(plugin: string, messages: PluginLocaleMessages) {\n const previous = this.pluginMessages.get(plugin) ?? {}\n const merged: PluginLocaleMessages = defaultsDeep({}, messages, previous)\n this.pluginMessages.set(plugin, merged)\n this.refresh(new Set([...Object.keys(previous), ...Object.keys(messages)]))\n }\n\n public remove(plugin: string) {\n const messages = this.pluginMessages.get(plugin)\n if (!messages) return\n this.pluginMessages.delete(plugin)\n this.refresh(new Set(Object.keys(messages)))\n }\n\n /**\n * 立即翻译一个 i18n key,供插件在自己的运行时回调中使用;\n * 未注册或没有适配器时返回 key 本身。\n */\n public translate(key: string, params?: Record<string, number | string>) {\n return this.adapter?.translate?.(key, params) ?? key\n }\n\n /**\n * 解析插件提供的展示文本:命中已注册的普通 i18n key 时翻译,\n * 否则按字面文本原样返回。宿主渲染的插件字符串字段\n * (如 `Selection.name`、清单展示名)都应经过本方法。\n */\n public translateText(value: string) {\n if (this.adapter?.has?.(value)) return this.translate(value)\n return value\n }\n\n private compose(locale: string) {\n const message: PluginLocaleMessage = {}\n defaultsDeep(message, this.baseMessages[locale])\n for (const messages of this.pluginMessages.values()) defaultsDeep(message, messages[locale])\n return message\n }\n\n private locales() {\n const locales = new Set(Object.keys(this.baseMessages))\n for (const messages of this.pluginMessages.values()) {\n for (const locale of Object.keys(messages)) locales.add(locale)\n }\n return locales\n }\n\n private refresh(locales: Iterable<string>) {\n if (!this.adapter) return\n for (const locale of locales) this.adapter.setLocaleMessage(locale, this.compose(locale))\n }\n}\n\nexport const pluginI18n = new PluginI18nRegistry()","","export const pluginName = 'core'","import { ConfigPointer } from '../api/config'\n\nimport { pluginName } from './env'\n\nexport const cfg = new ConfigPointer(\n pluginName,\n {\n recordHistory: { type: 'switch', defaultValue: true, info: 'plugin.core.config.recordHistory' },\n showAIProject: { type: 'switch', defaultValue: true, info: 'plugin.core.config.showAiWorks' },\n darkMode: {\n type: 'radio',\n defaultValue: 'system',\n info: 'plugin.core.config.theme.title',\n comp: 'select',\n selects: [\n { label: 'plugin.core.config.theme.light', value: 'light' },\n { label: 'plugin.core.config.theme.dark', value: 'dark' },\n { label: 'plugin.core.config.systemDefault', value: 'system' },\n ],\n },\n easilyTitle: {\n type: 'switch',\n defaultValue: false,\n info: 'plugin.core.config.simplifiedTitle',\n },\n githubToken: {\n type: 'string',\n defaultValue: '',\n info: 'plugin.core.config.githubToken.title',\n placeholder: 'plugin.core.config.githubToken.placeholder',\n },\n receivePerReleaseUpdate: {\n type: 'switch',\n defaultValue: false,\n info: 'plugin.core.config.prereleaseUpdates',\n },\n cloudEnabled: { type: 'switch', defaultValue: false, info: 'plugin.core.config.cloud.enabled' },\n cloudServerUrl: {\n type: 'string',\n defaultValue: '',\n info: 'plugin.core.config.cloud.serverUrl',\n placeholder: 'plugin.core.config.cloud.serverUrlPlaceholder',\n },\n installOverride: {\n type: 'pairs',\n defaultValue: [],\n info: 'plugin.core.config.installOverride',\n required: true,\n },\n },\n 'plugin.core.config.name',\n)","import type { PluginLocaleMessages } from '../api/i18n'\n\nexport const coreI18n: PluginLocaleMessages = {\n 'zh-CN': {\n plugin: {\n core: {\n config: {\n name: '核心',\n recordHistory: '记录历史记录',\n showAiWorks: '展示 AI 作品',\n theme: { title: '外观模式', light: '浅色', dark: '深色' },\n systemDefault: '跟随系统',\n simplifiedTitle: '简化标题(实验性功能)',\n githubToken: { title: 'GitHub Token', placeholder: '仅用于提高 API 访问限额' },\n prereleaseUpdates: '接收预发布版本更新(可能不稳定)',\n cloud: {\n enabled: '启用云服务',\n serverUrl: '云服务地址',\n serverUrlPlaceholder: '启用云服务后填写服务地址',\n },\n installOverride: '安装源覆盖配置',\n },\n },\n },\n },\n}","import { UniContentPage } from '@delta-comic/model'\nimport { SharedFunction } from '@delta-comic/utils'\nimport { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string'\n\nimport { pluginI18n } from '../adapters'\nimport type { Social } from '../api'\n\ninterface CorePluginTokenShareMeta {\n item: { name: string; contentType: string; ep: string }\n plugin: string\n id: string\n}\n\nexport const tokenInit: Social.InitiativeItem = {\n filter: page => !!page.preload,\n icon: {},\n key: 'token',\n name: 'plugin.share.copyToken',\n async call(page) {\n const item = page.preload?.toJSON()\n if (!item) throw new Error('Not found preload in content. Maybe not fetch detail?')\n\n const compressed = compressToEncodedURIComponent(\n JSON.stringify(<CorePluginTokenShareMeta>{\n item: {\n contentType: UniContentPage.contentPages.key.toString(item.contentType),\n ep: item.thisEp.id,\n name: item.title,\n },\n plugin: page.plugin,\n id: page.id,\n }),\n )\n return { token: `[${item.title}](复制这条口令,打开Delta Comic)${compressed}` }\n },\n}\n\nexport const nativeInit: Social.InitiativeItem = {\n filter: page => !!page.preload,\n icon: {},\n key: 'native',\n name: 'plugin.share.native',\n async call(page) {\n const item = page.preload?.toJSON()\n if (!item) throw new Error('Not found preload in content. Maybe not fetch detail?')\n\n const compressed = compressToEncodedURIComponent(\n JSON.stringify(<CorePluginTokenShareMeta>{\n item: {\n contentType: UniContentPage.contentPages.key.toString(item.contentType),\n ep: item.thisEp.id,\n name: item.title,\n },\n plugin: page.plugin,\n id: page.id,\n }),\n )\n const token = `[${item.title}](复制这条口令,打开Delta Comic)${compressed}`\n await navigator.share({ title: pluginI18n.translate('plugin.share.nativeTitle'), text: token })\n\n return { token }\n },\n}\n\nexport const tokenShare: Social.ShareToken = {\n key: 'token',\n name: 'plugin.share.defaultToken',\n isMatched(chipboard) {\n return /^\\[.+\\]\\(复制这条口令,打开Delta Comic\\).+/.test(chipboard)\n },\n async show(chipboard) {\n // const pluginStore = usePluginStore()\n const meta: CorePluginTokenShareMeta = JSON.parse(\n decompressFromEncodedURIComponent(\n chipboard.replace(/^\\[.+\\]/, '').replaceAll('(复制这条口令,打开Delta Comic)', ''),\n ),\n )\n return {\n title: pluginI18n.translate('plugin.share.tokenTitle'),\n detail: pluginI18n.translate('plugin.share.tokenDetail', { item: meta.item.name }),\n onNegative() {},\n onPositive() {\n return SharedFunction.call(\n 'routeToContent',\n UniContentPage.contentPages.key.toJSON(meta.item.contentType),\n meta.id,\n meta.item.ep,\n )\n },\n }\n },\n}","import { defineDeltaComicPlugin } from '../api'\n\nexport { cfg } from './config'\n\nimport { pluginName } from './env'\nimport { coreI18n } from './i18n'\nimport { tokenInit, nativeInit, tokenShare } from './share'\n\nexport default defineDeltaComicPlugin(() => ({\n name: pluginName,\n i18n: coreI18n,\n model: { social: { share: { initiative: [tokenInit, nativeInit], tokenListen: [tokenShare] } } },\n}))","import pkg from '../../package.json'\nimport { DELTA_COMIC_PLUGIN_API_VERSION } from '../api'\nimport CorePlugin from '../core'\nimport { defineInternalPlugin } from '../kernel'\n\nexport const corePluginDefinition = defineInternalPlugin({\n canDisable: false,\n factory: CorePlugin,\n manifest: {\n apiVersion: DELTA_COMIC_PLUGIN_API_VERSION,\n author: 'Delta Comic',\n description: 'Delta Comic host capabilities',\n name: { display: 'core', id: 'core' },\n require: [],\n version: { plugin: pkg.version, supportCore: '*' },\n },\n})\n\nexport default corePluginDefinition","import type { InternalPluginDefinition } from '../kernel'\n\nexport * from './core.builtin'\n\nconst builtinModules = import.meta.glob<{ default: InternalPluginDefinition }>('./*.builtin.ts', {\n eager: true,\n})\n\n/** Files are the registration boundary: adding a built-in does not change the composition root. */\nexport const internalPluginDefinitions = Object.entries(builtinModules)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, module]) => {\n if (!module.default)\n throw new Error(`built-in plugin module has no default definition: ${path}`)\n return module.default\n })","import { shallowReactive, type Raw } from 'vue'\n\nimport type { DCPluginConfig } from '../api'\nimport type { PluginCandidate } from '../kernel'\n\nexport class PluginStore {\n private readonly candidateEntries = shallowReactive(new Map<string, PluginCandidate>())\n private readonly loadingEntries = shallowReactive(new Map<string, Raw<DCPluginConfig>>())\n private readonly pluginEntries = shallowReactive(new Map<string, Raw<DCPluginConfig>>())\n private readonly readyEntries = shallowReactive(new Set<string>())\n\n public constructor(private readonly translateText: (value: string) => string = value => value) {}\n\n public get candidates(): ReadonlyMap<string, PluginCandidate> {\n return this.candidateEntries\n }\n\n public get loading(): ReadonlyMap<string, Raw<DCPluginConfig>> {\n return this.loadingEntries\n }\n\n public get plugins(): ReadonlyMap<string, Raw<DCPluginConfig>> {\n return this.pluginEntries\n }\n\n public get ready(): ReadonlySet<string> {\n return this.readyEntries\n }\n\n public replaceCandidates(candidates: readonly PluginCandidate[]) {\n this.candidateEntries.clear()\n for (const candidate of candidates) {\n this.candidateEntries.set(candidate.manifest.name.id, candidate)\n }\n }\n\n public markLoading(plugin: string, config: Raw<DCPluginConfig>) {\n this.readyEntries.delete(plugin)\n this.loadingEntries.set(plugin, config)\n this.pluginEntries.delete(plugin)\n }\n\n public markReady(plugin: string) {\n const config = this.loadingEntries.get(plugin)\n if (!config) throw new Error(`plugin \"${plugin}\" was not marked as loading`)\n this.loadingEntries.delete(plugin)\n this.pluginEntries.set(plugin, config)\n this.readyEntries.add(plugin)\n }\n\n public markUnloaded(plugin: string) {\n this.readyEntries.delete(plugin)\n this.loadingEntries.delete(plugin)\n this.pluginEntries.delete(plugin)\n }\n\n public isLoaded(plugin: string) {\n return this.readyEntries.has(plugin)\n }\n\n public displayName(plugin: string) {\n return this.translateText(this.candidateEntries.get(plugin)?.manifest.name.display ?? plugin)\n }\n\n public modelEntries<K extends keyof NonNullable<DCPluginConfig['model']>>(key: K) {\n type Model = NonNullable<NonNullable<DCPluginConfig['model']>[K]>\n return [...this.pluginEntries].flatMap(([plugin, config]) => {\n const model = config.model?.[key]\n return model === undefined ? [] : ([[plugin, model]] as [string, Model][])\n })\n }\n}","import { logger } from '@delta-comic/logger'\nimport { markRaw, ref, shallowReactive, type App, type Raw, type Ref } from 'vue'\n\nimport type { ConfigEnv, DCPluginConfig, PluginLocaleMessages } from '../api'\nimport {\n ActivationPipeline,\n planPluginDependencies,\n PluginScope,\n type CapabilityModule,\n type LoadedPluginModule,\n type PluginCandidate,\n type PluginCandidateProvider,\n} from '../kernel'\n\nimport { PluginStore } from './store'\n\nexport interface PluginLoadingInfo {\n progress: {\n errorReason?: string\n status: 'done' | 'error' | 'process' | 'wait'\n stepsIndex: number\n }\n steps: { description: string; name: string }[]\n}\n\nexport interface PluginRuntimeFailure {\n readonly error: unknown\n readonly phase: 'normal' | 'preload'\n readonly plugin: string\n}\n\nexport interface PluginRuntimeReport {\n readonly activated: string[]\n readonly failures: PluginRuntimeFailure[]\n}\n\nexport interface PluginRuntimeOperation {\n readonly operation: Promise<PluginRuntimeReport>\n readonly progress: Ref<Record<string, PluginLoadingInfo>>\n}\n\nexport interface LoadNormalOptions {\n readonly pluginNames?: readonly string[]\n}\n\nexport interface PluginPreloadRecovery {\n failedAt: number\n plugins: string[]\n reason: string\n}\n\nexport interface PluginRuntimeOptions {\n readonly capabilities: () => readonly CapabilityModule[]\n readonly environment: () => ConfigEnv\n readonly provider: PluginCandidateProvider\n readonly remove: (plugin: string) => Promise<void>\n readonly store?: PluginStore\n readonly services?: {\n readonly i18n?: {\n register(plugin: string, messages: PluginLocaleMessages): void\n remove(plugin: string): void\n }\n }\n}\n\ninterface PreparedPlugin {\n readonly candidate: PluginCandidate\n readonly config: Raw<DCPluginConfig>\n readonly module: LoadedPluginModule\n readonly scope: PluginScope\n}\n\nconst recoveryKey = 'delta-comic:plugin-preload-recovery:v1'\nconst runtimeLogger = logger.scoped('plugin:runtime')\n\nconst errorText = (error: unknown) => (error instanceof Error ? error.message : String(error))\n\nconst joinErrorMessages = (errors: readonly unknown[]) =>\n errors\n .map(error => errorText(error))\n .filter(Boolean)\n .join('; ')\n\nconst loadingInfo = (): PluginLoadingInfo => ({\n progress: { status: 'wait', stepsIndex: 0 },\n steps: [{ description: '', name: 'waiting' }],\n})\n\nexport class PluginRuntime {\n readonly #activeNormal = new Map<string, PluginScope>()\n readonly #options: PluginRuntimeOptions\n readonly #prepared = new Map<string, PreparedPlugin>()\n #app?: App\n #booted = false\n #normalOperation?: Promise<PluginRuntimeReport>\n #preloadOperation?: Promise<PluginRuntimeReport>\n #preloadReport?: PluginRuntimeReport\n\n public readonly restartRequired = shallowReactive(new Set<string>())\n public readonly store: PluginStore\n\n public constructor(options: PluginRuntimeOptions) {\n this.#options = options\n this.store = options.store ?? new PluginStore()\n }\n\n public get activeNormalPluginNames() {\n return [...this.#activeNormal.keys()]\n }\n\n public async preload(app: App) {\n if (this.#preloadReport) return this.#preloadReport\n if (this.#preloadOperation) return await this.#preloadOperation\n this.#app = app\n const operation = this.#prepareEnabledPlugins(app)\n this.#preloadOperation = operation\n try {\n const report = await operation\n this.#preloadReport = report\n if (report.failures.length > 0) this.#writeRecovery(report.failures)\n else this.clearRecovery()\n return report\n } finally {\n this.#preloadOperation = undefined\n }\n }\n\n public loadNormal(options: LoadNormalOptions = {}): PluginRuntimeOperation {\n if (!this.#preloadReport) throw new Error('plugins must be preloaded before normal activation')\n if (this.#normalOperation) throw new Error('plugin normal parts are already loading')\n if (this.activeNormalPluginNames.length > 0) {\n throw new Error('plugin normal parts are already active; use reloadNormal()')\n }\n const progress = ref<Record<string, PluginLoadingInfo>>({})\n const operation = this.#loadNormal(progress, options.pluginNames)\n this.#track(operation)\n return { operation, progress }\n }\n\n public reloadNormal(options: LoadNormalOptions = {}): PluginRuntimeOperation {\n if (!this.#preloadReport) throw new Error('plugins must be preloaded before normal activation')\n if (this.#normalOperation) throw new Error('plugin normal parts are already loading')\n const progress = ref<Record<string, PluginLoadingInfo>>({})\n const operation = (async () => {\n await this.#unloadNormal()\n return await this.#loadNormal(progress, options.pluginNames)\n })()\n this.#track(operation)\n return { operation, progress }\n }\n\n public markRestartRequired(plugin: string) {\n this.restartRequired.add(plugin)\n }\n\n /** Prepare a plugin that was enabled after startup and activate it once normal parts are booted. */\n public async enablePlugin(plugin: string) {\n await this.enablePlugins([plugin])\n }\n\n /**\n * Prepare every given plugin, plus any enabled requirement that is not prepared yet, in\n * dependency order, and activate their normal parts once the application is booted.\n */\n public async enablePlugins(plugins: readonly string[]) {\n this.#assertReadyForToggle()\n const targets = new Map<string, PluginCandidate>()\n const visit = (plugin: string) => {\n if (targets.has(plugin)) return\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n if (!candidate.enabled) throw new Error(`plugin \"${plugin}\" is not enabled`)\n targets.set(plugin, candidate)\n for (const dependency of candidate.manifest.require) visit(dependency.id)\n }\n for (const plugin of plugins) visit(plugin)\n\n const plan = planPluginDependencies([...targets.values()])\n if (plan.cycles.length > 0) {\n const cycles = plan.cycles.map(cycle => cycle.join(' -> ')).join('; ')\n throw new Error(`cannot enable plugins: dependency cycles: ${cycles}`)\n }\n\n for (const level of plan.levels) {\n for (const candidate of level) {\n const plugin = candidate.manifest.name.id\n const prepared = this.#prepared.get(plugin)\n if (prepared) {\n if (this.#booted && !this.#activeNormal.has(plugin)) {\n const result = await this.#activateNormal(prepared)\n if (result.error !== undefined) throw this.#activationFailure(plugin, result)\n }\n continue\n }\n await this.#prepareAndActivate(candidate)\n }\n }\n }\n\n /**\n * Unload a plugin together with its prepared dependents, then reload it from its current files\n * so an install or update takes effect without an application restart.\n */\n public async reloadPlugin(plugin: string) {\n this.#assertReadyForToggle()\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n\n const affected: string[] = []\n const visited = new Set<string>()\n const collectDependents = (id: string) => {\n if (visited.has(id)) return\n visited.add(id)\n for (const [name, prepared] of this.#prepared) {\n if (prepared.candidate.manifest.require.some(dependency => dependency.id === id)) {\n collectDependents(name)\n }\n }\n if (id !== plugin) affected.push(id)\n }\n collectDependents(plugin)\n\n const errors: unknown[] = []\n for (const id of [...affected, plugin]) {\n const active = this.#activeNormal.get(id)\n if (active) {\n try {\n await this.#deactivateNormal(id, active)\n } catch (error) {\n errors.push(error)\n }\n }\n const prepared = this.#prepared.get(id)\n if (prepared) {\n this.#prepared.delete(id)\n try {\n await prepared.scope.dispose()\n } catch (error) {\n errors.push(error)\n }\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(\n errors,\n `failed to unload plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n if (candidate.enabled) await this.enablePlugins([plugin, ...affected])\n }\n\n /** Deactivate and unload a plugin so disabling it takes effect without a restart. */\n public async disablePlugin(plugin: string) {\n this.#assertReadyForToggle()\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n if (!candidate.management.canDisable) throw new Error(`plugin \"${plugin}\" cannot be disabled`)\n const dependents = [...this.#prepared.entries()]\n .filter(([, prepared]) =>\n prepared.candidate.manifest.require.some(dependency => dependency.id === plugin),\n )\n .map(([id]) => id)\n if (dependents.length > 0) {\n throw new Error(`cannot disable plugin \"${plugin}\": required by ${dependents.join(', ')}`)\n }\n\n const errors: unknown[] = []\n const active = this.#activeNormal.get(plugin)\n if (active) {\n try {\n await this.#deactivateNormal(plugin, active)\n } catch (error) {\n errors.push(error)\n }\n }\n const prepared = this.#prepared.get(plugin)\n if (prepared) {\n this.#prepared.delete(plugin)\n try {\n await prepared.scope.dispose()\n } catch (error) {\n errors.push(error)\n }\n }\n if (errors.length > 0) {\n throw new AggregateError(\n errors,\n `failed to disable plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n }\n\n async #prepareAndActivate(candidate: PluginCandidate) {\n const plugin = candidate.manifest.name.id\n const app = this.#app\n if (!app) throw new Error('plugins must be preloaded before enabling a plugin')\n const scope = new PluginScope(plugin)\n try {\n const { config, module } = await this.#loadPlugin(candidate, scope)\n const cleanup = await config.hooks?.onPreboot?.({ app })\n if (cleanup) scope.defer(cleanup)\n const prepared: PreparedPlugin = { candidate, config, module, scope }\n this.#prepared.set(plugin, prepared)\n if (this.#booted) {\n const result = await this.#activateNormal(prepared)\n if (result.error !== undefined) throw this.#activationFailure(plugin, result)\n }\n } catch (error) {\n this.#prepared.delete(plugin)\n const errors: unknown[] = this.#flattenErrors(error)\n const disposeError = await scope.dispose(error).catch(caught => caught)\n if (disposeError !== undefined) errors.push(...this.#flattenErrors(disposeError))\n throw new AggregateError(\n errors,\n `failed to enable plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n }\n\n #assertReadyForToggle() {\n if (!this.#preloadReport) {\n throw new Error('plugins must be preloaded before enabling or disabling a plugin')\n }\n if (this.#normalOperation) throw new Error('plugin normal parts are currently loading')\n }\n\n #flattenErrors(error: unknown): unknown[] {\n return error instanceof AggregateError ? [...error.errors] : [error]\n }\n\n #activationFailure(\n plugin: string,\n result: { error?: unknown; disposeError?: unknown },\n ): AggregateError {\n const errors = result.error === undefined ? [] : this.#flattenErrors(result.error)\n if (result.disposeError !== undefined) errors.push(...this.#flattenErrors(result.disposeError))\n return new AggregateError(\n errors,\n `failed to activate plugin \"${plugin}\": ${joinErrorMessages(errors)}`,\n )\n }\n\n public async uninstall(plugin: string) {\n const candidate = this.store.candidates.get(plugin)\n if (!candidate) throw new Error(`plugin \"${plugin}\" is not a known candidate`)\n if (!candidate.management.canUninstall) {\n throw new Error(`plugin \"${plugin}\" cannot be uninstalled`)\n }\n\n const active = this.#activeNormal.get(plugin)\n if (active) await this.#deactivateNormal(plugin, active)\n const prepared = this.#prepared.get(plugin)\n if (prepared) {\n this.#prepared.delete(plugin)\n await prepared.scope.dispose()\n } else {\n try {\n await this.#runUninstallHook(candidate)\n } catch (error) {\n runtimeLogger.warn(`failed to run uninstall hook for plugin \"${plugin}\"`, error)\n }\n }\n this.restartRequired.delete(plugin)\n await this.#options.remove(plugin)\n await this.refreshCandidates()\n }\n\n public async refreshCandidates() {\n const candidates = await this.#options.provider.list(new AbortController().signal)\n this.store.replaceCandidates(candidates)\n return candidates\n }\n\n public readRecovery(): PluginPreloadRecovery | null {\n try {\n const value = globalThis.localStorage?.getItem(recoveryKey)\n return value ? (JSON.parse(value) as PluginPreloadRecovery) : null\n } catch {\n return null\n }\n }\n\n public clearRecovery() {\n try {\n globalThis.localStorage?.removeItem(recoveryKey)\n } catch {}\n }\n\n async #prepareEnabledPlugins(app: App): Promise<PluginRuntimeReport> {\n const candidates = (await this.refreshCandidates()).filter(candidate => candidate.enabled)\n const plan = planPluginDependencies(candidates)\n\n const activated: string[] = []\n const failures: PluginRuntimeFailure[] = plan.missing.map(({ dependency, plugin }) => ({\n error: new Error(`missing dependency: ${dependency}`),\n phase: 'preload',\n plugin,\n }))\n for (const cycle of plan.cycles) {\n const error = new Error(`dependency cycle: ${cycle.join(' -> ')}`)\n for (const plugin of cycle.slice(0, -1)) failures.push({ error, phase: 'preload', plugin })\n }\n const failed = new Set(failures.map(value => value.plugin))\n for (const level of plan.levels) {\n for (const candidate of level) {\n const plugin = candidate.manifest.name.id\n if (failed.has(plugin)) continue\n const blockedBy = candidate.manifest.require\n .map(value => value.id)\n .filter(dependency => failed.has(dependency))\n if (blockedBy.length > 0) {\n failures.push({\n error: new Error(`dependency preload failed: ${blockedBy.join(', ')}`),\n phase: 'preload',\n plugin,\n })\n failed.add(plugin)\n continue\n }\n\n const scope = new PluginScope(plugin)\n try {\n const { config, module } = await this.#loadPlugin(candidate, scope)\n const cleanup = await config.hooks?.onPreboot?.({ app })\n if (cleanup) scope.defer(cleanup)\n\n // Register i18n during preload so config forms and host UI can translate immediately.\n if (this.#options.services?.i18n && config.i18n) {\n this.#options.services.i18n.register(plugin, config.i18n)\n scope.defer(() => this.#options.services!.i18n!.remove(plugin))\n }\n\n this.#prepared.set(plugin, { candidate, config, module, scope })\n activated.push(plugin)\n } catch (error) {\n failures.push({ error, phase: 'preload', plugin })\n failed.add(plugin)\n await scope.dispose(error).catch(disposeError => {\n failures.push({ error: disposeError, phase: 'preload', plugin })\n })\n }\n }\n }\n return { activated, failures }\n }\n\n async #loadNormal(\n progress: Ref<Record<string, PluginLoadingInfo>>,\n selected?: readonly string[],\n ): Promise<PluginRuntimeReport> {\n const candidates = [...this.#prepared.values()].map(value => value.candidate)\n const mandatory = candidates\n .filter(candidate => !candidate.management.canDisable)\n .map(candidate => candidate.manifest.name.id)\n const chosen = selected\n ? this.#selectWithDependencies(candidates, [...mandatory, ...selected])\n : candidates\n const plan = planPluginDependencies(chosen)\n this.#assertValidPlan(plan)\n\n const activated: string[] = []\n const failures: PluginRuntimeFailure[] = []\n const failed = new Set<string>()\n for (const level of plan.levels) {\n for (const candidate of level) {\n const plugin = candidate.manifest.name.id\n const info = (progress.value[plugin] = loadingInfo())\n const blockedBy = candidate.manifest.require\n .map(value => value.id)\n .filter(dependency => failed.has(dependency))\n if (blockedBy.length > 0) {\n const error = new Error(`dependency activation failed: ${blockedBy.join(', ')}`)\n info.progress = { errorReason: error.message, status: 'error', stepsIndex: 0 }\n failures.push({ error, phase: 'normal', plugin })\n failed.add(plugin)\n continue\n }\n\n const prepared = this.#prepared.get(plugin)\n if (!prepared) continue\n const result = await this.#activateNormal(prepared, info)\n if (result.error === undefined) {\n activated.push(plugin)\n continue\n }\n failures.push({ error: result.error, phase: 'normal', plugin })\n failed.add(plugin)\n if (result.disposeError !== undefined) {\n failures.push({ error: result.disposeError, phase: 'normal', plugin })\n }\n }\n }\n this.#booted = true\n return { activated, failures }\n }\n\n /** Run the normal activation pipeline for a prepared plugin on a fresh normal scope. */\n async #activateNormal(\n prepared: PreparedPlugin,\n info?: PluginLoadingInfo,\n ): Promise<{ error?: unknown; disposeError?: unknown }> {\n const plugin = prepared.candidate.manifest.name.id\n const scope = new PluginScope(plugin)\n try {\n if (info) info.progress.status = 'process'\n await prepared.module.activate?.(scope)\n this.store.markLoading(plugin, prepared.config)\n scope.defer(() => this.store.markUnloaded(plugin))\n await new ActivationPipeline(this.#options.capabilities()).activate(prepared.config, {\n owner: plugin,\n report: update => {\n if (!info) return\n const value = typeof update === 'string' ? { description: update } : update\n info.steps[0] = { ...info.steps[0], ...value }\n },\n scope,\n signal: scope.signal,\n })\n this.#activeNormal.set(plugin, scope)\n this.store.markReady(plugin)\n if (info) info.progress.status = 'done'\n return {}\n } catch (error) {\n if (info) info.progress = { errorReason: errorText(error), status: 'error', stepsIndex: 0 }\n const disposeError = await scope.dispose(error).catch(caught => caught)\n return { error, disposeError }\n }\n }\n\n async #loadPlugin(candidate: PluginCandidate, scope: PluginScope) {\n const plugin = candidate.manifest.name.id\n const loaded: LoadedPluginModule = await candidate.load(scope.signal)\n if (loaded.dispose) scope.defer(loaded.dispose)\n const config = markRaw(loaded.factory(this.#options.environment()))\n if (config.name !== plugin) throw new Error(`plugin name mismatch: ${plugin} / ${config.name}`)\n return { config, module: loaded }\n }\n\n async #runUninstallHook(candidate: PluginCandidate) {\n const plugin = candidate.manifest.name.id\n const scope = new PluginScope(plugin)\n try {\n const { config } = await this.#loadPlugin(candidate, scope)\n await config.hooks?.onUninstall?.()\n } finally {\n await scope.dispose()\n }\n }\n\n #assertValidPlan(plan: ReturnType<typeof planPluginDependencies>) {\n if (plan.missing.length === 0 && plan.cycles.length === 0) return\n const missing = plan.missing.map(value => `${value.plugin} -> ${value.dependency}`).join(', ')\n const cycles = plan.cycles.map(value => value.join(' -> ')).join(', ')\n throw new Error(\n [missing && `missing: ${missing}`, cycles && `cycles: ${cycles}`].filter(Boolean).join('; '),\n )\n }\n\n #selectWithDependencies(candidates: readonly PluginCandidate[], selected: readonly string[]) {\n const byId = new Map(candidates.map(candidate => [candidate.manifest.name.id, candidate]))\n const result = new Map<string, PluginCandidate>()\n const visit = (plugin: string) => {\n const candidate = byId.get(plugin)\n if (!candidate || result.has(plugin)) return\n for (const dependency of candidate.manifest.require) visit(dependency.id)\n result.set(plugin, candidate)\n }\n for (const plugin of selected) visit(plugin)\n return [...result.values()]\n }\n\n #track(operation: Promise<PluginRuntimeReport>) {\n this.#normalOperation = operation\n void operation.then(\n () => (this.#normalOperation = undefined),\n () => (this.#normalOperation = undefined),\n )\n }\n\n async #unloadNormal() {\n const targets = [...this.#activeNormal].reverse()\n const errors: unknown[] = []\n for (const [plugin, scope] of targets) {\n try {\n await this.#deactivateNormal(plugin, scope)\n } catch (error) {\n errors.push(error)\n }\n }\n if (errors.length > 0) throw new AggregateError(errors, 'some plugins failed to unload')\n }\n\n async #deactivateNormal(plugin: string, scope: PluginScope) {\n this.#activeNormal.delete(plugin)\n await scope.dispose()\n }\n\n #writeRecovery(failures: readonly PluginRuntimeFailure[]) {\n try {\n globalThis.localStorage?.setItem(\n recoveryKey,\n JSON.stringify({\n failedAt: Date.now(),\n plugins: failures.map(value => value.plugin),\n reason: failures.map(value => errorText(value.error)).join('\\n'),\n } satisfies PluginPreloadRecovery),\n )\n } catch {}\n }\n}","import type { InternalPluginDefinition, PluginCandidate, PluginCandidateProvider } from '../kernel'\n\nconst defaultStorage = () => {\n try {\n return globalThis.localStorage\n } catch {\n return undefined\n }\n}\n\nexport interface InternalPluginPreferences {\n enabled(plugin: string, fallback: boolean): Promise<boolean>\n setEnabled(plugin: string, enabled: boolean): Promise<void>\n}\n\nexport class LocalInternalPluginPreferences implements InternalPluginPreferences {\n public constructor(\n private readonly storage: Storage | undefined = defaultStorage(),\n private readonly prefix = 'delta-comic:internal-plugin:',\n ) {}\n\n public async enabled(plugin: string, fallback: boolean) {\n try {\n const value = this.storage?.getItem(`${this.prefix}${plugin}`)\n return value === null || value === undefined ? fallback : value === 'true'\n } catch {\n return fallback\n }\n }\n\n public async setEnabled(plugin: string, enabled: boolean) {\n try {\n this.storage?.setItem(`${this.prefix}${plugin}`, String(enabled))\n } catch {}\n }\n}\n\nexport class InternalPluginCandidateProvider implements PluginCandidateProvider {\n public readonly id = 'internal'\n\n public constructor(\n private readonly definitions: readonly InternalPluginDefinition[],\n private readonly preferences: InternalPluginPreferences = new LocalInternalPluginPreferences(),\n ) {}\n\n public async list(signal: AbortSignal) {\n const candidates: PluginCandidate[] = []\n for (const definition of this.definitions) {\n if (signal.aborted) throw signal.reason\n candidates.push({\n enabled:\n definition.canDisable === false\n ? true\n : await this.preferences.enabled(\n definition.manifest.name.id,\n definition.enabledByDefault ?? true,\n ),\n load: async () => ({ factory: definition.factory }),\n management: {\n canDisable: definition.canDisable ?? true,\n canUninstall: false,\n canUpdate: false,\n },\n manifest: definition.manifest,\n origin: 'builtin',\n })\n }\n return candidates\n }\n}\n\nexport class CompositePluginCandidateProvider implements PluginCandidateProvider {\n public readonly id = 'composite'\n\n public constructor(private readonly providers: readonly PluginCandidateProvider[]) {}\n\n public async list(signal: AbortSignal) {\n const candidates = (\n await Promise.all(this.providers.map(provider => provider.list(signal)))\n ).flat()\n const owners = new Map<string, PluginCandidate>()\n for (const candidate of candidates) {\n const id = candidate.manifest.name.id\n const previous = owners.get(id)\n if (previous) {\n if (previous.origin === 'builtin' && candidate.origin === 'installed') continue\n if (previous.origin === 'installed' && candidate.origin === 'builtin') {\n owners.set(id, candidate)\n continue\n }\n throw new Error(\n `duplicate plugin candidate \"${id}\" from ${previous.origin} and ${candidate.origin}`,\n )\n }\n owners.set(id, candidate)\n }\n return [...owners.values()]\n }\n}","import { isTauri } from '@tauri-apps/api/core'\n\nimport {\n AwesomeRegistryClient,\n ConfigStore,\n createDefaultPluginFileStore,\n pluginI18n,\n} from './adapters'\nimport { corePluginDefinition, internalPluginDefinitions } from './builtins'\nimport { createDefaultCapabilities, type PluginAuthGateway } from './capabilities'\nimport { cfg } from './core/config'\nimport {\n DatabasePluginArchiveRepository,\n DevServerPluginModuleReader,\n DevServerSourceResolver,\n DEV_SERVER_LOADER_ID,\n GitHubSourceResolver,\n HttpSourceResolver,\n InstalledPluginCandidateProvider,\n LocalFileSourceResolver,\n MarketplaceSourceResolver,\n type PluginCatalog,\n type PluginInstallReporter,\n PluginInstallService,\n safePluginPath,\n StoredPluginModuleReader,\n ZipPackageCodec,\n devServerUrl,\n parseDevServerPort,\n} from './install'\nimport { ContributionHub } from './kernel'\nimport {\n CompositePluginCandidateProvider,\n InternalPluginCandidateProvider,\n LocalInternalPluginPreferences,\n PluginRuntime,\n PluginStore,\n} from './runtime'\n\nexport const pluginContributions = new ContributionHub()\nexport const pluginStore = new PluginStore(value => pluginI18n.translateText(value))\nexport const pluginConfigStore = new ConfigStore()\nexport const useConfig = () => pluginConfigStore\n\nexport const preparePluginHost = async () => {\n await pluginConfigStore.register(cfg).ready\n}\n\nexport interface PluginHostServices {\n readonly auth?: PluginAuthGateway\n}\n\nconst pluginHostServices: PluginHostServices = {}\n\n/** Install host-only integrations without exposing UI or platform details to the runtime kernel. */\nexport const configurePluginHost = (services: PluginHostServices) => {\n Object.assign(pluginHostServices, services)\n}\n\nconst pluginFiles = createDefaultPluginFileStore()\nconst pluginRepository = new DatabasePluginArchiveRepository()\nconst pluginReaders = [new StoredPluginModuleReader(pluginFiles), new DevServerPluginModuleReader()]\nconst internalPreferences = new LocalInternalPluginPreferences()\nconst internalPluginIds = new Set(\n internalPluginDefinitions.map(definition => definition.manifest.name.id),\n)\nconst internalProvider = new InternalPluginCandidateProvider(\n internalPluginDefinitions,\n internalPreferences,\n)\nconst candidateProvider = new CompositePluginCandidateProvider([\n internalProvider,\n new InstalledPluginCandidateProvider(pluginRepository, pluginReaders),\n])\n\nconst devSource = new DevServerSourceResolver()\nconst httpSource = new HttpSourceResolver()\nconst githubSource = new GitHubSourceResolver({\n coreVersion: corePluginDefinition.manifest.version.plugin,\n includePrereleases: () =>\n pluginConfigStore.has(cfg) &&\n pluginConfigStore.load(cfg).data.value.receivePerReleaseUpdate === true,\n})\nconst awesomeRegistry = new AwesomeRegistryClient()\nconst marketplaceSource = new MarketplaceSourceResolver(awesomeRegistry, [githubSource, httpSource])\n\nexport const pluginCatalog: PluginCatalog = awesomeRegistry\n\nexport const pluginInstaller = new PluginInstallService({\n codecs: [new ZipPackageCodec()],\n files: pluginFiles,\n repository: pluginRepository,\n reservedIds: internalPluginIds,\n resolvers: [\n new LocalFileSourceResolver(),\n devSource,\n marketplaceSource,\n githubSource,\n httpSource,\n ],\n})\n\nexport const pluginRuntime = new PluginRuntime({\n capabilities: () =>\n createDefaultCapabilities({\n auth: pluginHostServices.auth,\n config: pluginConfigStore,\n contributions: pluginContributions,\n i18n: pluginI18n,\n }),\n environment: () => ({ platform: isTauri() ? 'tauri' : 'web' }),\n provider: candidateProvider,\n remove: plugin => pluginInstaller.uninstall(plugin),\n store: pluginStore,\n services: { i18n: pluginI18n },\n})\n\nexport interface PluginInstallOptions {\n readonly report?: PluginInstallReporter\n readonly signal?: AbortSignal\n}\n\nexport const installPlugin = async (input: File | string, options: PluginInstallOptions = {}) => {\n const installed = new Set([\n ...internalPluginIds,\n ...(await pluginRepository.list()).map(archive => archive.pluginName),\n ])\n const archive = await pluginInstaller.install(input, options.signal, options.report)\n await pluginRuntime.refreshCandidates()\n try {\n // Files and metadata are already persisted; load the result immediately so installs and\n // updates work without an application restart. reloadPlugin also reloads prepared dependents.\n await pluginRuntime.reloadPlugin(archive.pluginName)\n } catch (error) {\n // Loading failed: keep a restart hint so a restart retries with the persisted state.\n for (const candidate of pluginRuntime.store.candidates.values()) {\n const plugin = candidate.manifest.name.id\n if (plugin === archive.pluginName || !installed.has(plugin)) {\n pluginRuntime.markRestartRequired(plugin)\n }\n }\n throw new Error(\n `plugin installed but failed to start: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n return archive\n}\n\nexport const updatePlugin = async (\n archive: { installInput: string },\n options?: PluginInstallOptions,\n) => {\n if (!archive.installInput) throw new Error('plugin has no reusable install source')\n return await installPlugin(archive.installInput, options)\n}\n\nexport const updatePluginByName = async (plugin: string, options?: PluginInstallOptions) => {\n const archive = await pluginRepository.find(plugin)\n if (!archive) throw new Error(`installed plugin not found: ${plugin}`)\n return await updatePlugin(archive, options)\n}\n\nexport const setPluginEnabled = async (plugin: string, enabled: boolean) => {\n const candidate = pluginStore.candidates.get(plugin)\n if (!candidate?.management.canDisable) throw new Error(`plugin \"${plugin}\" cannot be disabled`)\n const persist = async () => {\n if (candidate.origin === 'builtin') await internalPreferences.setEnabled(plugin, enabled)\n else {\n const archive = await pluginRepository.find(plugin)\n if (!archive) throw new Error(`installed plugin not found: ${plugin}`)\n await pluginRepository.upsert({ ...archive, enable: enabled })\n }\n }\n const restore = async () => {\n if (candidate.origin === 'builtin')\n await internalPreferences.setEnabled(plugin, candidate.enabled)\n else {\n const archive = await pluginRepository.find(plugin)\n if (archive) await pluginRepository.upsert({ ...archive, enable: candidate.enabled })\n }\n await pluginRuntime.refreshCandidates()\n }\n\n if (enabled) {\n await persist()\n await pluginRuntime.refreshCandidates()\n try {\n await pluginRuntime.enablePlugin(plugin)\n } catch (error) {\n // Enabling failed; restore the persisted flag so the list matches the runtime state.\n await restore()\n throw error\n }\n pluginRuntime.restartRequired.delete(plugin)\n return\n }\n\n // Disable validates (dependencies, management) and unloads first, then the flag is persisted.\n await pluginRuntime.disablePlugin(plugin)\n await persist()\n await pluginRuntime.refreshCandidates()\n pluginRuntime.restartRequired.delete(plugin)\n}\n\nexport const uninstallPlugin = async (plugin: string) => await pluginRuntime.uninstall(plugin)\n\nexport const resolvePluginIconUrl = async (\n plugin: string | undefined,\n icon: string | undefined,\n) => {\n if (!icon) return undefined\n if (/^https?:\\/\\//i.test(icon)) return icon\n if (!plugin) throw new Error('a plugin id is required to resolve a local plugin icon')\n const archive = await pluginRepository.find(plugin)\n if (archive?.loaderName === DEV_SERVER_LOADER_ID) {\n const port = parseDevServerPort(archive.installInput)\n if (port === undefined) {\n throw new Error(`development plugin has an invalid install source: ${archive.installInput}`)\n }\n return devServerUrl(port, `/${safePluginPath(icon, 'plugin icon path')}`)\n }\n return await pluginFiles.createAssetUrl(plugin, icon)\n}\n\nexport {\n getTauriPluginRoot,\n pluginI18n,\n type PluginI18nAdapter,\n type PluginLocaleMessages,\n} from './adapters'\n\nexport const usePluginStore = () => pluginStore"],"mappings":";;;;;;;;;;;;;;;;AASA,IAAa,gBAAb,MAA4E;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