@delta-comic/plugin 3.0.0-next.14 → 3.0.0-next.15

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.
@@ -28,10 +28,12 @@ declare module '@delta-comic/utils' {
28
28
  }
29
29
  }
30
30
  declare namespace remote_d_exports {
31
- export { Definition, RemoteModel, TestFunction, TestGroup, TestGroupBase, TestRemoteGroup, TestResourceGroup };
31
+ export { Definition, RemoteListProvider, RemoteModel, RemoteSource, ResolvedTestGroup, ResolvedTestGroupBase, ResolvedTestRemoteGroup, ResolvedTestResourceGroup, TestFunction, TestGroup, TestGroupBase, TestRemoteGroup, TestResourceGroup };
32
32
  }
33
33
  type RemoteModel = TestGroup[];
34
34
  type TestFunction = (url: string, signal: AbortSignal) => Promise<void>;
35
+ type RemoteListProvider = (signal: AbortSignal) => Promise<Definition[]>;
36
+ type RemoteSource = Definition | RemoteListProvider;
35
37
  interface Definition {
36
38
  name: string;
37
39
  url: string;
@@ -42,7 +44,7 @@ interface Definition {
42
44
  }
43
45
  interface TestGroupBase {
44
46
  name: string;
45
- remotes: Definition[];
47
+ remotes: RemoteSource[] | RemoteListProvider;
46
48
  /**
47
49
  * group-level default test
48
50
  */
@@ -57,6 +59,17 @@ interface TestResourceGroup extends TestGroupBase {
57
59
  processors?: UniResourceProcessor[];
58
60
  }
59
61
  type TestGroup = TestRemoteGroup | TestResourceGroup;
62
+ interface ResolvedTestGroupBase extends Omit<TestGroupBase, 'remotes'> {
63
+ remotes: Definition[];
64
+ }
65
+ interface ResolvedTestRemoteGroup extends ResolvedTestGroupBase {
66
+ type: 'remote';
67
+ }
68
+ interface ResolvedTestResourceGroup extends ResolvedTestGroupBase {
69
+ type: 'resource';
70
+ processors?: UniResourceProcessor[];
71
+ }
72
+ type ResolvedTestGroup = ResolvedTestRemoteGroup | ResolvedTestResourceGroup;
60
73
  declare namespace user_d_exports {
61
74
  export { ActionPageItem, Auth, CallbackResult, Favourites, InjectCode, Method, Selection, UserAction, UserActionPage, UserModel };
62
75
  }
@@ -305,7 +318,7 @@ interface ContentHooks {
305
318
  //#endregion
306
319
  //#region lib/api/hook/remote.d.ts
307
320
  interface RemoteHooks {
308
- onRemoteTestDone(group: TestRemoteGroup, remote: Definition | false): void;
321
+ onRemoteTestDone(group: ResolvedTestRemoteGroup, remote: Definition | false): void;
309
322
  }
310
323
  //#endregion
311
324
  //#region lib/api/hook/social.d.ts
@@ -515,7 +528,7 @@ declare const createModelCapability: (services: PluginCapabilityServices) => Cap
515
528
  //#endregion
516
529
  //#region lib/capabilities/remote.d.ts
517
530
  interface RemoteSelection {
518
- readonly group: TestRemoteGroup;
531
+ readonly group: ResolvedTestRemoteGroup;
519
532
  readonly latencyMs?: number;
520
533
  readonly remote: Definition | false;
521
534
  }
@@ -1108,5 +1121,5 @@ declare const _default: PluginConfigFactory<{
1108
1121
  };
1109
1122
  }>;
1110
1123
  //#endregion
1111
- export { type ActionPageItem, ActivationContext, ActivationPipeline, ActivationStepUpdate, type Auth, type AutoCompleteProvider, type Barcode, type CallbackResult, CapabilityDefinition, CapabilityModule, type Category, CompositePluginCandidateProvider, ConfigDescription, ConfigEnv, ConfigPointer, content_d_exports as Content, type ContentHooks, type ContentModel, Contribution, ContributionChannel, ContributionHub, ContributionRegistry, ContributionValue, index_d_exports as Core, DCPluginConfig, DELTA_COMIC_PLUGIN_API_VERSION, DEV_CSS_PATH, DEV_ENTRY_PATH, DEV_MANIFEST_PATH, DEV_SERVER_LOADER_ID, DEV_SERVER_SOURCE_PREFIX, DatabasePluginArchiveRepository, DecodedPluginPackage, type Definition, DevServerPluginModuleReader, DevServerSourceResolver, expose_d_exports as Expose, type ExposeModel, type Favourites, GitHubSourceResolver, GitHubSourceResolverOptions, type HotCategory, type HotLevelboard, type HotPageContent, type HotSearchProvider, type HotTopButton, HttpSourceResolver, type InitiativeItem, type InjectCode, InstalledPluginCandidateProvider, InternalPluginCandidateProvider, InternalPluginDefinition, InternalPluginPreferences, type ItemProvider, type LifecycleHooks, LoadNormalOptions, LoadedPluginModule, LocalFileSourceResolver, LocalInternalPluginPreferences, MarketplaceSourceResolver, type Method, MissingPluginDependency, type Model, Platform, PluginArchiveRepository, PluginAuthGateway, PluginCandidate, PluginCandidateProvider, PluginCapabilityServices, PluginCatalog, PluginCatalogIndex, PluginCatalogListing, PluginCatalogPage, PluginCatalogPageReference, PluginCatalogPagination, PluginCatalogRelease, PluginCatalogRepository, PluginCatalogResult, PluginCatalogSource, PluginConfigFactory, type PluginConfigHooks, type PluginConfigModel, PluginConfigRegistry, PluginDependencyPlan, PluginDisposer, type PluginExposeRegistry, PluginFileReplacement, PluginFileStore, PluginHostServices, type PluginI18nAdapter, PluginInstallCatalog, PluginInstallInput, PluginInstallOptions, PluginInstallProgress, PluginInstallReporter, PluginInstallService, PluginInstallServiceOptions, type PluginLifecycleCleanup, PluginLoadingInfo, PluginLocaleMessage, PluginLocaleMessages, PluginManagementCapabilities, type PluginManifest, PluginManifestError, PluginMessageRegistry, PluginModuleReader, PluginOrigin, PluginPackageCodec, PluginPreloadRecovery, PluginRuntime, PluginRuntimeFailure, PluginRuntimeOperation, PluginRuntimeOptions, PluginRuntimeReport, PluginScope, PluginSourceResolver, PluginStore, type Promotes, RegisteredPluginConfig, remote_d_exports as Remote, type RemoteHooks, type RemoteModel, RemoteSelection, ResolvedPluginSource, type Search, type SearchAim, type SearchMethod, type Selection, type Share, type SharePopupConfig, type ShareToken, social_d_exports as Social, type SocialHooks, type SocialModel, special_d_exports as Special, type SpecialModel, type Step, StoredPluginModuleReader, type Subscribe, type SubscribeListProvider, type Tabbar, type TestFunction, type TestGroup, type TestGroupBase, type TestRemoteGroup, type TestResourceGroup, UnwrapConfigPointer, user_d_exports as User, type UserAction, type UserActionPage, type UserModel, ZipPackageCodec, configurePluginHost, createAuthCapability, createConfigCapability, createContentCapability, createDefaultCapabilities, createI18nCapability, createLifecycleCapability, createModelCapability, createRemoteCapability, createSpecialCapability, createUserCapability, defineCapability, defineContributionChannel, defineDeltaComicPlugin, defineInternalPlugin, devServerUrl, findPluginDependencyCycles, installPlugin, isPluginManifestCompatible, parseDevServerPort, parsePluginManifest, planPluginDependencies, pluginCatalog, pluginCatalogIdFromInstallInput, pluginCatalogInstallInput, pluginConfigStore, pluginContributions, pluginI18n, pluginInstaller, pluginModelChannels, pluginRemoteSelectionChannel, pluginRuntime, pluginStore, preparePluginHost, resolvePluginIconUrl, safePluginPath, setPluginEnabled, uninstallPlugin, updatePlugin, updatePluginByName, useConfig, usePluginStore };
1124
+ export { type ActionPageItem, ActivationContext, ActivationPipeline, ActivationStepUpdate, type Auth, type AutoCompleteProvider, type Barcode, type CallbackResult, CapabilityDefinition, CapabilityModule, type Category, CompositePluginCandidateProvider, ConfigDescription, ConfigEnv, ConfigPointer, content_d_exports as Content, type ContentHooks, type ContentModel, Contribution, ContributionChannel, ContributionHub, ContributionRegistry, ContributionValue, index_d_exports as Core, DCPluginConfig, DELTA_COMIC_PLUGIN_API_VERSION, DEV_CSS_PATH, DEV_ENTRY_PATH, DEV_MANIFEST_PATH, DEV_SERVER_LOADER_ID, DEV_SERVER_SOURCE_PREFIX, DatabasePluginArchiveRepository, DecodedPluginPackage, type Definition, DevServerPluginModuleReader, DevServerSourceResolver, expose_d_exports as Expose, type ExposeModel, type Favourites, GitHubSourceResolver, GitHubSourceResolverOptions, type HotCategory, type HotLevelboard, type HotPageContent, type HotSearchProvider, type HotTopButton, HttpSourceResolver, type InitiativeItem, type InjectCode, InstalledPluginCandidateProvider, InternalPluginCandidateProvider, InternalPluginDefinition, InternalPluginPreferences, type ItemProvider, type LifecycleHooks, LoadNormalOptions, LoadedPluginModule, LocalFileSourceResolver, LocalInternalPluginPreferences, MarketplaceSourceResolver, type Method, MissingPluginDependency, type Model, Platform, PluginArchiveRepository, PluginAuthGateway, PluginCandidate, PluginCandidateProvider, PluginCapabilityServices, PluginCatalog, PluginCatalogIndex, PluginCatalogListing, PluginCatalogPage, PluginCatalogPageReference, PluginCatalogPagination, PluginCatalogRelease, PluginCatalogRepository, PluginCatalogResult, PluginCatalogSource, PluginConfigFactory, type PluginConfigHooks, type PluginConfigModel, PluginConfigRegistry, PluginDependencyPlan, PluginDisposer, type PluginExposeRegistry, PluginFileReplacement, PluginFileStore, PluginHostServices, type PluginI18nAdapter, PluginInstallCatalog, PluginInstallInput, PluginInstallOptions, PluginInstallProgress, PluginInstallReporter, PluginInstallService, PluginInstallServiceOptions, type PluginLifecycleCleanup, PluginLoadingInfo, PluginLocaleMessage, PluginLocaleMessages, PluginManagementCapabilities, type PluginManifest, PluginManifestError, PluginMessageRegistry, PluginModuleReader, PluginOrigin, PluginPackageCodec, PluginPreloadRecovery, PluginRuntime, PluginRuntimeFailure, PluginRuntimeOperation, PluginRuntimeOptions, PluginRuntimeReport, PluginScope, PluginSourceResolver, PluginStore, type Promotes, RegisteredPluginConfig, remote_d_exports as Remote, type RemoteHooks, type RemoteListProvider, type RemoteModel, RemoteSelection, type RemoteSource, ResolvedPluginSource, type ResolvedTestGroup, type ResolvedTestGroupBase, type ResolvedTestRemoteGroup, type ResolvedTestResourceGroup, type Search, type SearchAim, type SearchMethod, type Selection, type Share, type SharePopupConfig, type ShareToken, social_d_exports as Social, type SocialHooks, type SocialModel, special_d_exports as Special, type SpecialModel, type Step, StoredPluginModuleReader, type Subscribe, type SubscribeListProvider, type Tabbar, type TestFunction, type TestGroup, type TestGroupBase, type TestRemoteGroup, type TestResourceGroup, UnwrapConfigPointer, user_d_exports as User, type UserAction, type UserActionPage, type UserModel, ZipPackageCodec, configurePluginHost, createAuthCapability, createConfigCapability, createContentCapability, createDefaultCapabilities, createI18nCapability, createLifecycleCapability, createModelCapability, createRemoteCapability, createSpecialCapability, createUserCapability, defineCapability, defineContributionChannel, defineDeltaComicPlugin, defineInternalPlugin, devServerUrl, findPluginDependencyCycles, installPlugin, isPluginManifestCompatible, parseDevServerPort, parsePluginManifest, planPluginDependencies, pluginCatalog, pluginCatalogIdFromInstallInput, pluginCatalogInstallInput, pluginConfigStore, pluginContributions, pluginI18n, pluginInstaller, pluginModelChannels, pluginRemoteSelectionChannel, pluginRuntime, pluginStore, preparePluginHost, resolvePluginIconUrl, safePluginPath, setPluginEnabled, uninstallPlugin, updatePlugin, updatePluginByName, useConfig, usePluginStore };
1112
1125
  //# sourceMappingURL=index.d.mts.map
@@ -417,6 +417,14 @@ const selectFastestEndpoint = async (candidates, signal, timeoutMs = 1e4) => {
417
417
  };
418
418
  //#endregion
419
419
  //#region lib/capabilities/remote.ts
420
+ const resolveGroup = async (group, signal) => {
421
+ const sources = typeof group.remotes === "function" ? [group.remotes] : group.remotes;
422
+ const remotes = (await Promise.all(sources.map((source) => typeof source === "function" ? source(signal) : source))).flat();
423
+ return {
424
+ ...group,
425
+ remotes
426
+ };
427
+ };
420
428
  const pluginRemoteSelectionChannel = defineContributionChannel("runtime:remote-selection");
421
429
  const createRemoteCapability = (services) => defineCapability({
422
430
  id: "remote",
@@ -426,14 +434,15 @@ const createRemoteCapability = (services) => defineCapability({
426
434
  } : void 0,
427
435
  async activate({ hooks, remotes }, context) {
428
436
  const groups = /* @__PURE__ */ new Set();
429
- for (const group of remotes) {
430
- if (!group.name) throw new Error("remote group name cannot be empty");
431
- if (groups.has(group.name)) throw new Error(`duplicate remote group "${group.name}"`);
432
- groups.add(group.name);
437
+ for (const sourceGroup of remotes) {
438
+ if (!sourceGroup.name) throw new Error("remote group name cannot be empty");
439
+ if (groups.has(sourceGroup.name)) throw new Error(`duplicate remote group "${sourceGroup.name}"`);
440
+ groups.add(sourceGroup.name);
433
441
  context.report({
434
442
  name: "remote",
435
- description: `probing ${group.name}`
443
+ description: `probing ${sourceGroup.name}`
436
444
  });
445
+ const group = await resolveGroup(sourceGroup, context.signal);
437
446
  const selected = await selectFastestEndpoint(group.remotes.map((remote) => ({
438
447
  test: remote.test ?? group.test,
439
448
  url: remote.url,
@@ -1838,7 +1847,7 @@ var PluginI18nRegistry = class {
1838
1847
  const pluginI18n = new PluginI18nRegistry();
1839
1848
  //#endregion
1840
1849
  //#region package.json
1841
- var version = "3.0.0-next.14";
1850
+ var version = "3.0.0-next.15";
1842
1851
  //#endregion
1843
1852
  //#region lib/core/env.ts
1844
1853
  const pluginName = "core";