{"version":3,"file":"registry.mjs","sources":["../../lib/ui/registry.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { IFileAction, IFileListAction } from './actions/index.ts'\nimport type { IFileListFilter } from './filters/index.ts'\nimport type { IFileListHeader } from './headers/index.ts'\n\nimport { TypedEventTarget } from 'typescript-event-target'\nimport { scopedGlobals } from '../globalScope.ts'\n\ninterface FilesRegistryEvents {\n\t'register:action': RegistrationEvent<IFileAction>\n\t'register:listAction': RegistrationEvent<IFileListAction>\n\t'register:listFilter': RegistrationEvent<IFileListFilter>\n\t'register:listHeader': RegistrationEvent<IFileListHeader>\n\t'unregister:listFilter': UnregisterEvent\n}\n\n/**\n * Custom event for registry events.\n * The detail is the registered item.\n */\nclass RegistrationEvent<T> extends CustomEvent<T> {}\n\n/**\n * Custom event for unregistering items from the registry.\n * The detail is the id of the unregistered item.\n */\nclass UnregisterEvent extends RegistrationEvent<string> {}\n\n/**\n * The registry for files app.\n * This is used to keep track of registered actions, filters, headers, etc. and to emit events when new items are registered.\n * Allowing to keep a reactive state of the registered items in the UI without being coupled to one specific reactivity framework.\n *\n * This is an internal implementation detail and should not be used directly.\n *\n * @internal\n * @see PublicFilesRegistry - for the public API to listen to registry events.\n */\nexport class FilesRegistry extends TypedEventTarget<FilesRegistryEvents> {}\n\n/**\n * The registry for files app.\n * This is used to keep track of registered actions, filters, headers, etc. and to emit events when new items are registered.\n * Allowing to keep a reactive state of the registered items in the UI without being coupled to one specific reactivity framework.\n */\nexport type PublicFilesRegistry = Pick<FilesRegistry, 'addEventListener' | 'removeEventListener'>\n\n/**\n * Get the global files registry.\n *\n * @internal\n */\nexport function getRegistry() {\n\tscopedGlobals.registry ??= new FilesRegistry()\n\treturn scopedGlobals.registry\n}\n\n/**\n * Get the global files registry.\n *\n * This allows to listen for new registrations of actions, filters, headers, etc.\n * Events are dispatched by the respective registration functions.\n */\nexport function getFilesRegistry(): PublicFilesRegistry {\n\treturn getRegistry()\n}\n"],"names":[],"mappings":";;AA0CO,MAAM,sBAAsB,iBAAsC;AAAC;AAcnE,SAAS,cAAc;AAC7B,gBAAc,aAAa,IAAI,cAAA;AAC/B,SAAO,cAAc;AACtB;AAQO,SAAS,mBAAwC;AACvD,SAAO,YAAA;AACR;"}