chore(lib/plugins): update internal names with correct terminology
This commit is contained in:
parent
fc679a4d15
commit
67c3d9ec8d
9 changed files with 25 additions and 25 deletions
|
|
@ -6,7 +6,7 @@ export type PluginApiDecoratorStore<T extends 'PreInit' | 'Init' | 'Start'> =
|
|||
WeakMap<AnyPlugin, PluginApiDecorator<any, T>[]>
|
||||
|
||||
// Set of plugins that will always decorate the API of every other plugin.
|
||||
export const pImplicitDeps = new Set<AnyPlugin>()
|
||||
export const pApis = new Set<AnyPlugin>()
|
||||
|
||||
export const pDecoratorsPreInit: PluginApiDecoratorStore<'PreInit'> =
|
||||
new WeakMap()
|
||||
|
|
@ -32,17 +32,17 @@ export function decoratePluginApi(
|
|||
plugin: Plugin<any, any>,
|
||||
meta: InternalPluginMeta,
|
||||
) {
|
||||
// Don't decorate implicit dependencies
|
||||
if (pImplicitDeps.has(plugin)) return
|
||||
|
||||
// Decorate the plugin API with implicit dependencies
|
||||
// Implicit dependencies are internal plugin APIs, so we can run this without try-catch
|
||||
// If anything fails, everything else would fail anyway
|
||||
for (const dep of pImplicitDeps) {
|
||||
const decorators = store.get(dep)
|
||||
if (decorators)
|
||||
for (const decorator of decorators) decorator(plugin, meta.options)
|
||||
}
|
||||
// Don't decorate API plugins with API plugins...
|
||||
if (!pApis.has(plugin))
|
||||
// Decorate the plugin API with implicit dependencies
|
||||
// Implicit dependencies are internal plugin APIs, so we can run this without try-catch
|
||||
// If anything fails, everything else would fail anyway
|
||||
for (const dep of pApis) {
|
||||
const decorators = store.get(dep)
|
||||
if (decorators)
|
||||
for (const decorator of decorators)
|
||||
decorator(plugin, meta.options)
|
||||
}
|
||||
|
||||
const deps = getPluginDependencies(plugin)
|
||||
const { handleError: handleDependentError } = meta
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ import {
|
|||
import {
|
||||
addPluginApiDecorator,
|
||||
decoratePluginApi,
|
||||
pApis,
|
||||
pDecoratorsInit,
|
||||
pDecoratorsPreInit,
|
||||
pDecoratorsStart,
|
||||
pImplicitDeps,
|
||||
} from './decorators'
|
||||
import {
|
||||
computePendingNodes,
|
||||
|
|
@ -58,9 +58,10 @@ export const InternalPluginFlags = {
|
|||
*/
|
||||
Essential: 1 << 1,
|
||||
/**
|
||||
* Marks the plugin as a dependency of all other plugins.
|
||||
* Marks the plugin as an API plugin, which decorates all other plugins.
|
||||
* API plugins themselves won't be decorated by other API plugins unless explicitly declared in dependencies.
|
||||
*/
|
||||
ImplicitDependency: 1 << 2,
|
||||
API: 1 << 2,
|
||||
}
|
||||
|
||||
export interface InternalPluginMeta {
|
||||
|
|
@ -159,9 +160,9 @@ export function registerPlugin<O extends PluginApiExtensionsOptions>(
|
|||
pMetadata.set(plugin, meta)
|
||||
pList.set(manifest.id, plugin)
|
||||
|
||||
if (iflags & InternalPluginFlags.ImplicitDependency) {
|
||||
if (iflags & InternalPluginFlags.API) {
|
||||
pLeafOrSingleNodes.add(plugin)
|
||||
pImplicitDeps.add(plugin)
|
||||
pApis.add(plugin)
|
||||
}
|
||||
// Only add to pending if the plugin is enabled
|
||||
else if (isPluginEnabled(plugin)) pPending.add(plugin)
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@ registerPlugin(
|
|||
// biome-ignore format: Don't format this
|
||||
InternalPluginFlags.Internal |
|
||||
InternalPluginFlags.Essential |
|
||||
InternalPluginFlags.ImplicitDependency,
|
||||
InternalPluginFlags.API,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ registerPlugin(
|
|||
// biome-ignore format: Don't format this
|
||||
InternalPluginFlags.Internal |
|
||||
InternalPluginFlags.Essential |
|
||||
InternalPluginFlags.ImplicitDependency,
|
||||
InternalPluginFlags.API,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -71,5 +71,5 @@ registerPlugin(
|
|||
// biome-ignore format: Don't format this
|
||||
InternalPluginFlags.Internal |
|
||||
InternalPluginFlags.Essential |
|
||||
InternalPluginFlags.ImplicitDependency,
|
||||
InternalPluginFlags.API,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -40,5 +40,5 @@ registerPlugin(
|
|||
// biome-ignore format: Don't format this
|
||||
InternalPluginFlags.Internal |
|
||||
InternalPluginFlags.Essential |
|
||||
InternalPluginFlags.ImplicitDependency,
|
||||
InternalPluginFlags.API,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -54,5 +54,5 @@ registerPlugin(
|
|||
// biome-ignore format: Don't format this
|
||||
InternalPluginFlags.Internal |
|
||||
InternalPluginFlags.Essential |
|
||||
InternalPluginFlags.ImplicitDependency,
|
||||
InternalPluginFlags.API,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -37,5 +37,5 @@ registerPlugin(
|
|||
// biome-ignore format: Don't format this
|
||||
InternalPluginFlags.Internal |
|
||||
InternalPluginFlags.Essential |
|
||||
InternalPluginFlags.ImplicitDependency,
|
||||
InternalPluginFlags.API,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -76,8 +76,7 @@ const Filters: FilterAndSortActionSheetProps['filters'] = {
|
|||
'Non-APIs': {
|
||||
icon: getAssetIdByName('PaperIcon')!,
|
||||
desc: 'Exclude essential plugins that provide APIs for other plugins.',
|
||||
filter: (_, meta) =>
|
||||
!(meta.iflags & InternalPluginFlags.ImplicitDependency),
|
||||
filter: (_, meta) => !(meta.iflags & InternalPluginFlags.API),
|
||||
},
|
||||
} satisfies FilterAndSortActionSheetProps['filters']
|
||||
const DefaultFilters: FilterAndSortActionSheetProps['filter'] = ['Non-APIs']
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue