diff --git a/packages/neos-ts-interfaces/src/index.ts b/packages/neos-ts-interfaces/src/index.ts index efcaae26db..3f30fcff8f 100644 --- a/packages/neos-ts-interfaces/src/index.ts +++ b/packages/neos-ts-interfaces/src/index.ts @@ -1,5 +1,3 @@ -import type {I18nRegistry} from '@neos-project/neos-ui-i18n'; - export type NodeContextPath = string; export type FusionPath = string; export type NodeTypeName = string; @@ -252,27 +250,3 @@ export interface Change extends Readonly<{ value: any; }; }> {} - -// TODO: move to nodetypesregistry itself -export interface NodeTypesRegistry { - get: (nodeType: NodeTypeName) => NodeType | null; - getRole: (roleName: string) => NodeTypeName | null; - getSubTypesOf: (nodeType: NodeTypeName) => NodeTypeName[]; - getAllowedNodeTypesTakingAutoCreatedIntoAccount: (isSubjectNodeAutocreated: boolean, referenceParentName: string, referenceParentNodeType: NodeTypeName, referenceGrandParentNodeType: NodeTypeName | null, role: string) => NodeTypeName[]; -} - -// TODO: move to validatorsregistry itself -type Validator = ( - values: {}, - elementConfigurations: any -) => null | {} | string; -export interface ValidatorRegistry { - get: (validatorName: string) => Validator | null; - set: (validatorName: string, validator: Validator) => void; -} -export interface GlobalRegistry { - get: (key: K) => K extends 'i18n' ? I18nRegistry : - K extends 'validators' ? ValidatorRegistry : null; -} - -export type {I18nRegistry} from '@neos-project/neos-ui-i18n'; diff --git a/packages/neos-ui-ckeditor5-bindings/src/manifest.js b/packages/neos-ui-ckeditor5-bindings/src/manifest.js index 16b6489e19..89121c7bca 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/manifest.js +++ b/packages/neos-ui-ckeditor5-bindings/src/manifest.js @@ -2,7 +2,7 @@ import manifest from '@neos-project/neos-ui-extensibility'; import InlineEditorToolbar from './EditorToolbar'; import {bootstrap, createEditor} from './ckEditorApi'; -import {SynchronousMetaRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousMetaRegistry} from '@neos-project/neos-ui-registry'; import initializeRichtextToolbarRegistry from './manifest.richtextToolbar'; import initializeConfigRegistry from './manifest.config'; diff --git a/packages/neos-ui-ckeditor5-bindings/src/registry/CkEditorConfigRegistry.js b/packages/neos-ui-ckeditor5-bindings/src/registry/CkEditorConfigRegistry.js index a8064c5adb..2a7b97a648 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/registry/CkEditorConfigRegistry.js +++ b/packages/neos-ui-ckeditor5-bindings/src/registry/CkEditorConfigRegistry.js @@ -1,4 +1,4 @@ -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; export default class CkEditorConfigRegistry extends SynchronousRegistry { getCkeditorConfig(additionalInformation) { diff --git a/packages/neos-ui-ckeditor5-bindings/src/registry/RichTextToolbarRegistry.js b/packages/neos-ui-ckeditor5-bindings/src/registry/RichTextToolbarRegistry.js index 190efa84a9..80d5b621ae 100644 --- a/packages/neos-ui-ckeditor5-bindings/src/registry/RichTextToolbarRegistry.js +++ b/packages/neos-ui-ckeditor5-bindings/src/registry/RichTextToolbarRegistry.js @@ -1,4 +1,4 @@ -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; export default class RichTextToolbarRegistry extends SynchronousRegistry { } diff --git a/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js b/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js index 8b1d73e9b4..905563619b 100644 --- a/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js +++ b/packages/neos-ui-ckeditor5-bindings/tests/manual/index.js @@ -1,7 +1,7 @@ import initializeConfigRegistry from '../../src/manifest.config'; import {bootstrap, createEditor} from '../../src/ckEditorApi'; -import { SynchronousRegistry, SynchronousMetaRegistry } from '@neos-project/neos-ui-extensibility'; +import {SynchronousRegistry, SynchronousMetaRegistry} from '@neos-project/neos-ui-registry'; const fakeGlobalRegistry = new SynchronousMetaRegistry(); diff --git a/packages/neos-ui-contentrepository/package.json b/packages/neos-ui-contentrepository/package.json index 07d6a1dcc4..baea699581 100644 --- a/packages/neos-ui-contentrepository/package.json +++ b/packages/neos-ui-contentrepository/package.json @@ -3,7 +3,7 @@ "version": "", "description": "Bindings for the Neos ContentRepository", "private": true, - "main": "./src/manifest.js", + "main": "./src/index.ts", "devDependencies": { "@neos-project/jest-preset-neos-ui": "workspace:*", "typescript": "^4.6.4" diff --git a/packages/neos-ui-contentrepository/src/index.ts b/packages/neos-ui-contentrepository/src/index.ts new file mode 100644 index 0000000000..794a26a237 --- /dev/null +++ b/packages/neos-ui-contentrepository/src/index.ts @@ -0,0 +1,2 @@ + +export type {NodeTypesRegistry} from './registry'; diff --git a/packages/neos-ui-contentrepository/src/manifest.js b/packages/neos-ui-contentrepository/src/manifest.ts similarity index 68% rename from packages/neos-ui-contentrepository/src/manifest.js rename to packages/neos-ui-contentrepository/src/manifest.ts index 4eda6ecf6e..db053254b7 100644 --- a/packages/neos-ui-contentrepository/src/manifest.js +++ b/packages/neos-ui-contentrepository/src/manifest.ts @@ -10,3 +10,9 @@ manifest('@neos-project/neos-ui-contentrepository', {}, globalRegistry => { `) ); }); + +declare module '@neos-project/neos-ui-registry' { + interface GlobalRegistry { + get(key: '@neos-project/neos-ui-contentrepository'): NodeTypesRegistry; + } +} diff --git a/packages/neos-ui-contentrepository/src/registry/NodeTypesRegistry.ts b/packages/neos-ui-contentrepository/src/registry/NodeTypesRegistry.ts index 2880163634..f41d85bea9 100644 --- a/packages/neos-ui-contentrepository/src/registry/NodeTypesRegistry.ts +++ b/packages/neos-ui-contentrepository/src/registry/NodeTypesRegistry.ts @@ -1,7 +1,7 @@ import merge from 'lodash.merge'; import mapValues from 'lodash.mapvalues'; -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; import positionalArraySorter from '@neos-project/positional-array-sorter/src/positionalArraySorter'; import {NodeTypeName, NodeType} from '@neos-project/neos-ts-interfaces'; @@ -105,7 +105,7 @@ export default class NodeTypesRegistry extends SynchronousRegistry { return []; } - public getAllowedNodeTypesTakingAutoCreatedIntoAccount(isSubjectNodeAutocreated: boolean, referenceParentName: string, referenceParentNodeType: string, referenceGrandParentNodeType: string, role: string): NodeTypeName[] { + public getAllowedNodeTypesTakingAutoCreatedIntoAccount(isSubjectNodeAutocreated: boolean, referenceParentName: string, referenceParentNodeType: string, referenceGrandParentNodeType: string | null, role: string): NodeTypeName[] { let result; if (isSubjectNodeAutocreated) { if (!referenceGrandParentNodeType) { diff --git a/packages/neos-ui-contentrepository/src/registry/index.js b/packages/neos-ui-contentrepository/src/registry/index.ts similarity index 100% rename from packages/neos-ui-contentrepository/src/registry/index.js rename to packages/neos-ui-contentrepository/src/registry/index.ts diff --git a/packages/neos-ui-decorators/.yarnclean b/packages/neos-ui-decorators/.yarnclean deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/neos-ui-decorators/src/neos.tsx b/packages/neos-ui-decorators/src/neos.tsx index c09349c502..dc0d2f328d 100644 --- a/packages/neos-ui-decorators/src/neos.tsx +++ b/packages/neos-ui-decorators/src/neos.tsx @@ -1,6 +1,6 @@ import React from 'react'; import {defaultMemoize} from 'reselect'; -import {GlobalRegistry} from '@neos-project/neos-ts-interfaces'; +import {GlobalRegistry} from '@neos-project/neos-ui-registry'; // We need to memoize configuration and global registry; otherwise a new object is created at every render; leading to // LOADS of unnecessary re-draws. diff --git a/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.spec.ts b/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.spec.ts index aa32d0dc33..4aba4c9cef 100644 --- a/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.spec.ts +++ b/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.spec.ts @@ -1,5 +1,5 @@ import {processSelectBoxOptions} from './selectBoxHelpers'; -import {I18nRegistry} from '@neos-project/neos-ts-interfaces'; +import type {I18nRegistry} from '@neos-project/neos-ui-i18n'; const fakeI18NRegistry = { translate: (id) => id ?? '' diff --git a/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.ts b/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.ts index 1986dfbbf1..fc43ad4337 100644 --- a/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.ts +++ b/packages/neos-ui-editors/src/Editors/SelectBox/selectBoxHelpers.ts @@ -1,4 +1,4 @@ -import {I18nRegistry} from '@neos-project/neos-ts-interfaces'; +import type {I18nRegistry} from '@neos-project/neos-ui-i18n'; import {isNil} from '@neos-project/utils-helpers'; import { createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue diff --git a/packages/neos-ui-editors/src/_lib/testUtils.js b/packages/neos-ui-editors/src/_lib/testUtils.js index 219a3286d7..fe0f6a7d73 100644 --- a/packages/neos-ui-editors/src/_lib/testUtils.js +++ b/packages/neos-ui-editors/src/_lib/testUtils.js @@ -1,6 +1,6 @@ import React, {PureComponent, Children} from 'react'; import PropTypes from 'prop-types'; -import {SynchronousRegistry, SynchronousMetaRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry, SynchronousMetaRegistry} from '@neos-project/neos-ui-registry'; import {NeosContext} from '@neos-project/neos-ui-decorators'; const globalRegistry = new SynchronousMetaRegistry(); diff --git a/packages/neos-ui-extensibility/extensibilityMap.json b/packages/neos-ui-extensibility/extensibilityMap.json index 3bf12fa5fa..d5d1db01d9 100644 --- a/packages/neos-ui-extensibility/extensibilityMap.json +++ b/packages/neos-ui-extensibility/extensibilityMap.json @@ -22,5 +22,6 @@ "@neos-project/neos-ui-redux-store": "@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/neos-ui-redux-store", "@neos-project/neos-ui-views": "@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/neos-ui-views", "@neos-project/neos-ui-guest-frame": "@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/neos-ui-guest-frame", + "@neos-project/neos-ui-registry": "@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/neos-ui-registry", "@neos-project/utils-redux": "@neos-project/neos-ui-extensibility/dist/shims/neosProjectPackages/utils-redux" } diff --git a/packages/neos-ui-extensibility/package.json b/packages/neos-ui-extensibility/package.json index 11cde03196..c32f7f53b5 100644 --- a/packages/neos-ui-extensibility/package.json +++ b/packages/neos-ui-extensibility/package.json @@ -7,20 +7,14 @@ "homepage": "https://github.com/neos/neos-ui/blob/master/README.md", "main": "./src/index.ts", "publishConfig": { - "main": "./dist/index.js" + "main": "./plugin-api.js" }, "files": [ "dist", + "plugin-api.js", "extensibilityMap.json" ], "scripts": { "build": "yarn tsc --declaration" - }, - "devDependencies": { - "@neos-project/jest-preset-neos-ui": "workspace:*", - "typescript": "^4.6.4" - }, - "dependencies": { - "@neos-project/positional-array-sorter": "workspace:*" } } diff --git a/packages/neos-ui-extensibility/plugin-api.js b/packages/neos-ui-extensibility/plugin-api.js new file mode 100644 index 0000000000..b7a652f964 --- /dev/null +++ b/packages/neos-ui-extensibility/plugin-api.js @@ -0,0 +1,29 @@ +/** + * This file is the entry point for neos ui plugins. + * Require it via import '@neos-project/neos-ui-extensibility' + * + * **Internals** + * This file wired via the "publishConfig.main" but not used for building the Neos.Ui itself. + * The internal methods createConsumerApi() and readFromConsumerApi() are this way not exposed to plugins. + * Also, the readFromConsumerApi() call below to expose the "SynchronousRegistry" does not work in our host code. + */ + +import readFromConsumerApi from './dist/readFromConsumerApi'; + +/** + * Central function exposed to register a JavaScript package. + * + * import manifest from '@neos-project/neos-ui-extensibility' + * + * manifest('@my-vendor/my-plugin', {}, (globalRegistry, {store}) => { + * // ... + * }) + */ +const manifest = readFromConsumerApi('manifest'); +export default manifest; + +/** + * @deprecated legacy code to support `import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility'` please use `import {SynchronousRegistry} from '@neos-project/neos-ui-registry'` instead! + */ +const {SynchronousRegistry, SynchronousMetaRegistry} = readFromConsumerApi('NeosProjectPackages')().NeosUiRegistry; +export { SynchronousRegistry, SynchronousMetaRegistry }; diff --git a/packages/neos-ui-extensibility/src/index.ts b/packages/neos-ui-extensibility/src/index.ts index e258950aca..cdc888c16b 100644 --- a/packages/neos-ui-extensibility/src/index.ts +++ b/packages/neos-ui-extensibility/src/index.ts @@ -1,15 +1,9 @@ import createConsumerApi from './createConsumerApi'; import readFromConsumerApi from './readFromConsumerApi'; -import { - SynchronousRegistry, - SynchronousMetaRegistry -} from './registry/index'; export default readFromConsumerApi('manifest'); export { createConsumerApi, - readFromConsumerApi, - SynchronousRegistry, - SynchronousMetaRegistry + readFromConsumerApi }; diff --git a/packages/neos-ui-extensibility/src/shims/neosProjectPackages/neos-ui-registry/index.js b/packages/neos-ui-extensibility/src/shims/neosProjectPackages/neos-ui-registry/index.js new file mode 100644 index 0000000000..0132822e62 --- /dev/null +++ b/packages/neos-ui-extensibility/src/shims/neosProjectPackages/neos-ui-registry/index.js @@ -0,0 +1,3 @@ +import readFromConsumerApi from '../../../readFromConsumerApi'; + +module.exports = readFromConsumerApi('NeosProjectPackages')().NeosUiRegistry; diff --git a/packages/neos-ui-extensibility/src/types.d.ts b/packages/neos-ui-extensibility/src/types.d.ts new file mode 100644 index 0000000000..69e2eb14af --- /dev/null +++ b/packages/neos-ui-extensibility/src/types.d.ts @@ -0,0 +1,29 @@ + +/** + * Dedicated types declaration as we cannot bundle the types GlobalRegistry, Configuration correctly for distributing "neos-ui-extensibility" via NMP + * This file is not published. + */ +declare module '@neos-project/neos-ui-extensibility' { + import type {GlobalRegistry} from '@neos-project/neos-ui-registry'; + + type BootstrapDependencies = { + // correct store type depends on https://github.com/neos/neos-ui/pull/4010 + store: any; + /** @deprecated use `import {getFrontendConfigurationForPackage} from '@neos-project/neos-ui-configuration'` instead */ + frontendConfiguration: Record; + configuration: Record; + routes: Record; + }; + + type Bootstrap = ( + globalRegistry: GlobalRegistry, + bootstrapDependencies: BootstrapDependencies + ) => void; + + export default function manifest( + identifier: string, + // the age-old commit a2dae5b78a649ad75643f48b02b6df67f5915a58 introduced this parameter "options" though we not make use of it + options: {}, + bootstrap: Bootstrap + ): void; +} diff --git a/packages/neos-ui-guest-frame/src/manifest.js b/packages/neos-ui-guest-frame/src/manifest.js index b39abc9ea8..b15ffa4a36 100644 --- a/packages/neos-ui-guest-frame/src/manifest.js +++ b/packages/neos-ui-guest-frame/src/manifest.js @@ -1,5 +1,5 @@ import manifest from '@neos-project/neos-ui-extensibility'; -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; import makeInitializeGuestFrame from './initializeGuestFrame'; diff --git a/packages/neos-ui-i18n/src/manifest.js b/packages/neos-ui-i18n/src/manifest.ts similarity index 55% rename from packages/neos-ui-i18n/src/manifest.js rename to packages/neos-ui-i18n/src/manifest.ts index 920ed97519..fabf8683ee 100644 --- a/packages/neos-ui-i18n/src/manifest.js +++ b/packages/neos-ui-i18n/src/manifest.ts @@ -1,7 +1,13 @@ import manifest from '@neos-project/neos-ui-extensibility'; - +import type {I18nRegistry} from './registry'; import {i18nRegistry} from './registry'; manifest('@neos-project/neos-ui-i18n', {}, globalRegistry => { globalRegistry.set('i18n', i18nRegistry); }); + +declare module '@neos-project/neos-ui-registry' { + interface GlobalRegistry { + get(key: 'i18n'): I18nRegistry; + } +} diff --git a/packages/neos-ui-i18n/src/registry/I18nRegistry.ts b/packages/neos-ui-i18n/src/registry/I18nRegistry.ts index 57eae6e8c4..06c456ad7d 100644 --- a/packages/neos-ui-i18n/src/registry/I18nRegistry.ts +++ b/packages/neos-ui-i18n/src/registry/I18nRegistry.ts @@ -7,7 +7,7 @@ * information, please view the LICENSE file which was distributed with this * source code. */ -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; import logger from '@neos-project/utils-logger'; diff --git a/packages/neos-ui-redux-store/src/CR/Nodes/selectors.ts b/packages/neos-ui-redux-store/src/CR/Nodes/selectors.ts index 5ead4400d6..9f3aee3e71 100644 --- a/packages/neos-ui-redux-store/src/CR/Nodes/selectors.ts +++ b/packages/neos-ui-redux-store/src/CR/Nodes/selectors.ts @@ -1,6 +1,7 @@ import {createSelector, defaultMemoize} from 'reselect'; import {GlobalState} from '../../..'; -import {NodeContextPath, NodeMap, Node, NodeTypeName, ClipboardMode, NodeTypesRegistry} from '@neos-project/neos-ts-interfaces'; +import {NodeContextPath, NodeMap, Node, NodeTypeName, ClipboardMode} from '@neos-project/neos-ts-interfaces'; +import {NodeTypesRegistry} from '@neos-project/neos-ui-contentrepository'; export const inlineValidationErrorsSelector = (state: GlobalState) => state?.cr?.nodes?.inlineValidationErrors; export const nodesByContextPathSelector = (state: GlobalState) => state?.cr?.nodes?.byContextPath; diff --git a/packages/neos-ui-redux-store/src/UI/Inspector/selectors.ts b/packages/neos-ui-redux-store/src/UI/Inspector/selectors.ts index a2d03b2439..b6afd73e1e 100644 --- a/packages/neos-ui-redux-store/src/UI/Inspector/selectors.ts +++ b/packages/neos-ui-redux-store/src/UI/Inspector/selectors.ts @@ -1,9 +1,10 @@ import {createSelector, defaultMemoize} from 'reselect'; import validate from '@neos-project/neos-ui-validators'; +import type {ValidatorRegistry} from '@neos-project/neos-ui-validators'; import {selectors as nodes} from '../../CR/Nodes'; import {GlobalState} from '../../..'; -import {NodeTypesRegistry, ValidatorRegistry} from '@neos-project/neos-ts-interfaces'; +import {NodeTypesRegistry} from '@neos-project/neos-ui-contentrepository'; /** * Transient values and everything which depends on this diff --git a/packages/neos-ui-registry/package.json b/packages/neos-ui-registry/package.json new file mode 100644 index 0000000000..63da446c0d --- /dev/null +++ b/packages/neos-ui-registry/package.json @@ -0,0 +1,8 @@ +{ + "name": "@neos-project/neos-ui-registry", + "version": "", + "description": "Global registry for the Neos UI", + "private": true, + "main": "./src/index.ts", + "license": "GNU GPLv3" +} diff --git a/packages/neos-ui-registry/src/globalRegistry.ts b/packages/neos-ui-registry/src/globalRegistry.ts new file mode 100644 index 0000000000..05cf474e81 --- /dev/null +++ b/packages/neos-ui-registry/src/globalRegistry.ts @@ -0,0 +1,19 @@ +import {SynchronousMetaRegistry, SynchronousRegistry} from './registry'; + +export interface GlobalRegistry extends SynchronousMetaRegistry> { +} + +/** + * Access to the global registry. + * + * FIXME + * Note that we often pass the global registry around instead and inject it via the react context -> this should be simplified in favour of this global state. + */ +const globalRegistry = new SynchronousMetaRegistry(`The global registry`) as GlobalRegistry; + +export const getRegistryById: GlobalRegistry['get'] = (key) => { + // @ts-ignore + return globalRegistry.get(key); +} + +export const getGlobalRegistry = () => globalRegistry; diff --git a/packages/neos-ui-registry/src/index.ts b/packages/neos-ui-registry/src/index.ts new file mode 100644 index 0000000000..61b92f791d --- /dev/null +++ b/packages/neos-ui-registry/src/index.ts @@ -0,0 +1,4 @@ + +export {getRegistryById, getGlobalRegistry} from './globalRegistry'; +export {SynchronousRegistry, SynchronousMetaRegistry} from './registry'; +export type {GlobalRegistry} from './globalRegistry'; diff --git a/packages/neos-ui-extensibility/src/registry/AbstractRegistry.ts b/packages/neos-ui-registry/src/registry/AbstractRegistry.ts similarity index 100% rename from packages/neos-ui-extensibility/src/registry/AbstractRegistry.ts rename to packages/neos-ui-registry/src/registry/AbstractRegistry.ts diff --git a/packages/neos-ui-extensibility/src/registry/SynchronousMetaRegistry.ts b/packages/neos-ui-registry/src/registry/SynchronousMetaRegistry.ts similarity index 100% rename from packages/neos-ui-extensibility/src/registry/SynchronousMetaRegistry.ts rename to packages/neos-ui-registry/src/registry/SynchronousMetaRegistry.ts diff --git a/packages/neos-ui-extensibility/src/registry/SynchronousRegistry.spec.js b/packages/neos-ui-registry/src/registry/SynchronousRegistry.spec.js similarity index 100% rename from packages/neos-ui-extensibility/src/registry/SynchronousRegistry.spec.js rename to packages/neos-ui-registry/src/registry/SynchronousRegistry.spec.js diff --git a/packages/neos-ui-extensibility/src/registry/SynchronousRegistry.ts b/packages/neos-ui-registry/src/registry/SynchronousRegistry.ts similarity index 100% rename from packages/neos-ui-extensibility/src/registry/SynchronousRegistry.ts rename to packages/neos-ui-registry/src/registry/SynchronousRegistry.ts diff --git a/packages/neos-ui-extensibility/src/registry/index.ts b/packages/neos-ui-registry/src/registry/index.ts similarity index 100% rename from packages/neos-ui-extensibility/src/registry/index.ts rename to packages/neos-ui-registry/src/registry/index.ts diff --git a/packages/neos-ui-sagas/src/manifest.js b/packages/neos-ui-sagas/src/manifest.js index 4e226a187d..af4b8de23c 100644 --- a/packages/neos-ui-sagas/src/manifest.js +++ b/packages/neos-ui-sagas/src/manifest.js @@ -1,5 +1,5 @@ import manifest from '@neos-project/neos-ui-extensibility'; -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; import { browser, diff --git a/packages/neos-ui-validators/src/index.ts b/packages/neos-ui-validators/src/index.ts index d16e287a79..eb78c67f45 100644 --- a/packages/neos-ui-validators/src/index.ts +++ b/packages/neos-ui-validators/src/index.ts @@ -1,4 +1,5 @@ -import {ValidatorRegistry, PropertyConfiguration, ValidatorConfiguration} from '@neos-project/neos-ts-interfaces'; +import {PropertyConfiguration, ValidatorConfiguration} from '@neos-project/neos-ts-interfaces'; +import type {ValidatorRegistry} from './registry'; interface ValuesMap { [itemProp: string]: any; @@ -61,3 +62,6 @@ const validate = (values: ValuesMap, elementConfigurations: ElementConfiguarions }; export default validate; + +export type {ValidatorRegistry}; + diff --git a/packages/neos-ui-validators/src/manifest.ts b/packages/neos-ui-validators/src/manifest.ts index ffb77f5f29..e91d117b25 100644 --- a/packages/neos-ui-validators/src/manifest.ts +++ b/packages/neos-ui-validators/src/manifest.ts @@ -13,11 +13,11 @@ import StringLength from './StringLength'; import Text from './Text'; import Uuid from './Uuid'; -import manifest from '@neos-project/neos-ui-extensibility/src'; -import {GlobalRegistry} from '@neos-project/neos-ts-interfaces'; +import manifest from '@neos-project/neos-ui-extensibility'; +import {ValidatorRegistry, validatorRegistry} from './registry'; -manifest('validators', {}, (globalRegistry: GlobalRegistry) => { - const validatorRegistry = globalRegistry.get('validators'); +manifest('validators', {}, (globalRegistry) => { + globalRegistry.set('validators', validatorRegistry); validatorRegistry.set('Neos.Neos/Validation/AlphanumericValidator', Alphanumeric); validatorRegistry.set('Neos.Neos/Validation/CountValidator', Count); @@ -34,3 +34,9 @@ manifest('validators', {}, (globalRegistry: GlobalRegistry) => { validatorRegistry.set('Neos.Neos/Validation/TextValidator', Text); validatorRegistry.set('Neos.Neos/Validation/UuidValidator', Uuid); }); + +declare module '@neos-project/neos-ui-registry' { + interface GlobalRegistry { + get(key: 'validators'): ValidatorRegistry; + } +} diff --git a/packages/neos-ui-validators/src/registry.ts b/packages/neos-ui-validators/src/registry.ts new file mode 100644 index 0000000000..fe9d302724 --- /dev/null +++ b/packages/neos-ui-validators/src/registry.ts @@ -0,0 +1,15 @@ +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; + +type Validator = ( + values: {}, + elementConfigurations: any +) => null | {} | string; + +export const validatorRegistry = new SynchronousRegistry(` + Contains all validators. + + The key is a validator name (such as Neos.Neos/Validation/NotEmptyValidator) and the values + are validator options. +`); + +export type ValidatorRegistry = typeof validatorRegistry; diff --git a/packages/neos-ui/package.json b/packages/neos-ui/package.json index 3cf2a54b85..1c7ba56705 100644 --- a/packages/neos-ui/package.json +++ b/packages/neos-ui/package.json @@ -3,6 +3,11 @@ "version": "", "description": "Neos CMS UI written in ReactJS and a ton of other fun technology.", "private": true, + "exports": { + "./src/Containers/style.module.css": { + "default": "./src/Containers/style.module.css" + } + }, "devDependencies": { "@neos-project/debug-reason-for-rendering": "workspace:*", "@neos-project/jest-preset-neos-ui": "workspace:*", @@ -31,6 +36,7 @@ "@neos-project/neos-ui-i18n": "workspace:*", "@neos-project/neos-ui-inspector": "workspace:*", "@neos-project/neos-ui-redux-store": "workspace:*", + "@neos-project/neos-ui-registry": "workspace:*", "@neos-project/neos-ui-sagas": "workspace:*", "@neos-project/neos-ui-validators": "workspace:*", "@neos-project/neos-ui-views": "workspace:*", diff --git a/packages/neos-ui/src/Registry/HotkeyRegistry.js b/packages/neos-ui/src/Registry/HotkeyRegistry.js index bf87d9411d..3ff8dd9f94 100644 --- a/packages/neos-ui/src/Registry/HotkeyRegistry.js +++ b/packages/neos-ui/src/Registry/HotkeyRegistry.js @@ -1,4 +1,4 @@ -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; export default class HotkeyRegistry extends SynchronousRegistry { constructor(hotkeyConfiguration, ...args) { diff --git a/packages/neos-ui/src/Registry/RichTextToolbarRegistry.js b/packages/neos-ui/src/Registry/RichTextToolbarRegistry.js index b3221a7adf..7dfa90984a 100644 --- a/packages/neos-ui/src/Registry/RichTextToolbarRegistry.js +++ b/packages/neos-ui/src/Registry/RichTextToolbarRegistry.js @@ -1,5 +1,5 @@ import memoize from 'lodash.memoize'; -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; export default class RichTextToolbarRegistry extends SynchronousRegistry { constructor(...args) { diff --git a/packages/neos-ui/src/apiExposureMap.js b/packages/neos-ui/src/apiExposureMap.js index bcc1a15e70..d15b50568d 100644 --- a/packages/neos-ui/src/apiExposureMap.js +++ b/packages/neos-ui/src/apiExposureMap.js @@ -21,6 +21,7 @@ import * as CkEditorApi from '@neos-project/neos-ui-ckeditor5-bindings/src/ckEdi import NeosUiBackendConnectorDefault, * as NeosUiBackendConnector from '@neos-project/neos-ui-backend-connector'; import * as NeosUiViews from '@neos-project/neos-ui-views'; import * as NeosUiGuestFrameDom from '@neos-project/neos-ui-guest-frame/src/dom'; +import * as NeosUiRegistry from '@neos-project/neos-ui-registry'; // We export most needed components from CKE5 to be used when making custom plugins. // It's not safe to just install CKE5 packages from the extension because then then "instanceof" checks will no longer work, @@ -146,7 +147,8 @@ export default { NeosUiGuestFrameDom, // react-proptypes (optional) ReactUiComponents, - UtilsRedux + UtilsRedux, + NeosUiRegistry // TODO: how to write new reducers? // TODO: how to write new sagas? -> Registry --> CUSTOM PACKAGE diff --git a/packages/neos-ui/src/index.js b/packages/neos-ui/src/index.js index e1b7a97c10..b80e0ded70 100644 --- a/packages/neos-ui/src/index.js +++ b/packages/neos-ui/src/index.js @@ -7,7 +7,6 @@ import merge from 'lodash.merge'; import {actions} from '@neos-project/neos-ui-redux-store'; import {createConsumerApi} from '@neos-project/neos-ui-extensibility'; import fetchWithErrorHandling from '@neos-project/neos-ui-backend-connector/src/FetchWithErrorHandling'; -import {SynchronousMetaRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; import backend from '@neos-project/neos-ui-backend-connector'; import {handleActions} from '@neos-project/utils-redux'; import {initializeI18n} from '@neos-project/neos-ui-i18n'; @@ -27,6 +26,7 @@ import clipboardMiddleware from './clipboardMiddleware'; import Root from './Containers/Root'; import apiExposureMap from './apiExposureMap'; import DelegatingReducer from './DelegatingReducer'; +import {getGlobalRegistry} from '@neos-project/neos-ui-registry'; const devToolsArePresent = typeof window === 'object' && typeof window.__REDUX_DEVTOOLS_EXTENSION__ !== 'undefined'; const devToolsStoreEnhancer = () => devToolsArePresent ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f; @@ -39,14 +39,14 @@ const store = createStore(delegatingReducer.reducer(), {}, compose( )); const manifests = []; -const globalRegistry = new SynchronousMetaRegistry(`The global registry`); +const globalRegistry = getGlobalRegistry(); // // Create the host plugin api and load local manifests // createConsumerApi(manifests, apiExposureMap); require('./manifest'); -require('@neos-project/neos-ui-contentrepository'); +require('@neos-project/neos-ui-contentrepository/src/manifest'); require('@neos-project/neos-ui-editors'); require('@neos-project/neos-ui-views/src/manifest'); require('@neos-project/neos-ui-guest-frame'); diff --git a/packages/neos-ui/src/manifest.dataloaders.js b/packages/neos-ui/src/manifest.dataloaders.js index 3feb1b7569..59cc2ae0db 100644 --- a/packages/neos-ui/src/manifest.dataloaders.js +++ b/packages/neos-ui/src/manifest.dataloaders.js @@ -1,6 +1,6 @@ import HLRU from 'hashlru'; import manifest from '@neos-project/neos-ui-extensibility'; -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; import backend from '@neos-project/neos-ui-backend-connector'; function makeCacheKey(prefix, params) { diff --git a/packages/neos-ui/src/manifest.js b/packages/neos-ui/src/manifest.js index 216e16b420..aabe51b9ae 100644 --- a/packages/neos-ui/src/manifest.js +++ b/packages/neos-ui/src/manifest.js @@ -5,7 +5,7 @@ import {actions, selectors} from '@neos-project/neos-ui-redux-store'; import {parentNodeContextPath} from '@neos-project/neos-ui-redux-store/src/CR/Nodes/helpers'; import manifest from '@neos-project/neos-ui-extensibility'; -import {SynchronousRegistry, SynchronousMetaRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry, SynchronousMetaRegistry} from '@neos-project/neos-ui-registry'; import { getGuestFrameDocument, @@ -162,16 +162,6 @@ manifest('main', {}, (globalRegistry, {routes}) => { } `)); - // - // Create validators registry - // - globalRegistry.set('validators', new SynchronousRegistry(` - Contains all validators. - - The key is a validator name (such as Neos.Neos/Validation/NotEmptyValidator) and the values - are validator options. - `)); - // // Create server feedback handlers registry // diff --git a/packages/neos-ui/src/manifest.reducer.js b/packages/neos-ui/src/manifest.reducer.js index 1a639757f9..0dc423cad0 100644 --- a/packages/neos-ui/src/manifest.reducer.js +++ b/packages/neos-ui/src/manifest.reducer.js @@ -1,5 +1,5 @@ import manifest from '@neos-project/neos-ui-extensibility'; -import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry'; +import {SynchronousRegistry} from '@neos-project/neos-ui-registry'; import {reducer as coreReducer} from '@neos-project/neos-ui-redux-store'; manifest('main.reducer', {}, globalRegistry => { diff --git a/yarn.lock b/yarn.lock index b20e58f59d..c8f9999f57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3564,10 +3564,6 @@ __metadata: "@neos-project/neos-ui-extensibility@workspace:*, @neos-project/neos-ui-extensibility@workspace:packages/neos-ui-extensibility": version: 0.0.0-use.local resolution: "@neos-project/neos-ui-extensibility@workspace:packages/neos-ui-extensibility" - dependencies: - "@neos-project/jest-preset-neos-ui": "workspace:*" - "@neos-project/positional-array-sorter": "workspace:*" - typescript: ^4.6.4 languageName: unknown linkType: soft @@ -3647,6 +3643,12 @@ __metadata: languageName: unknown linkType: soft +"@neos-project/neos-ui-registry@workspace:*, @neos-project/neos-ui-registry@workspace:packages/neos-ui-registry": + version: 0.0.0-use.local + resolution: "@neos-project/neos-ui-registry@workspace:packages/neos-ui-registry" + languageName: unknown + linkType: soft + "@neos-project/neos-ui-sagas@workspace:*, @neos-project/neos-ui-sagas@workspace:packages/neos-ui-sagas": version: 0.0.0-use.local resolution: "@neos-project/neos-ui-sagas@workspace:packages/neos-ui-sagas" @@ -3732,6 +3734,7 @@ __metadata: "@neos-project/neos-ui-i18n": "workspace:*" "@neos-project/neos-ui-inspector": "workspace:*" "@neos-project/neos-ui-redux-store": "workspace:*" + "@neos-project/neos-ui-registry": "workspace:*" "@neos-project/neos-ui-sagas": "workspace:*" "@neos-project/neos-ui-validators": "workspace:*" "@neos-project/neos-ui-views": "workspace:*"