@umbraco-cms/backoffice 14.0.0--preview005-c6c57135 → 14.0.0--preview005-44025f0f

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.
Files changed (65) hide show
  1. package/dist-cms/apps/app/app.element.js +19 -15
  2. package/dist-cms/custom-elements.json +40 -6
  3. package/dist-cms/libs/extension-api/controller/base-extension-initializer.controller.js +2 -2
  4. package/dist-cms/libs/extension-api/controller/base-extensions-initializer.controller.js +2 -2
  5. package/dist-cms/libs/extension-api/initializers/bundle-extension-initializer.js +1 -1
  6. package/dist-cms/libs/extension-api/initializers/entry-point-extension-initializer.js +1 -1
  7. package/dist-cms/libs/extension-api/registry/extension.registry.d.ts +41 -14
  8. package/dist-cms/libs/extension-api/registry/extension.registry.js +115 -145
  9. package/dist-cms/mocks/data/data-type/data-type.data.js +7 -0
  10. package/dist-cms/mocks/data/document-type/document-type.data.js +26 -0
  11. package/dist-cms/packages/block/block/workspace/block-workspace.context.js +0 -1
  12. package/dist-cms/packages/block/block-grid/property-editors/block-grid-group-configuration/manifests.d.ts +2 -0
  13. package/dist-cms/packages/block/block-grid/property-editors/block-grid-group-configuration/manifests.js +11 -0
  14. package/dist-cms/packages/block/block-grid/property-editors/block-grid-group-configuration/property-editor-ui-block-grid-group-configuration.element.d.ts +19 -0
  15. package/dist-cms/packages/block/block-grid/property-editors/block-grid-group-configuration/property-editor-ui-block-grid-group-configuration.element.js +61 -0
  16. package/dist-cms/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.d.ts +10 -3
  17. package/dist-cms/packages/block/block-grid/property-editors/block-grid-type-configuration/property-editor-ui-block-grid-type-configuration.element.js +130 -11
  18. package/dist-cms/packages/block/block-grid/property-editors/manifests.js +8 -1
  19. package/dist-cms/packages/block/block-grid/types.d.ts +9 -2
  20. package/dist-cms/packages/block/block-grid/types.js +1 -1
  21. package/dist-cms/packages/block/block-list/property-editors/block-list-type-configuration/property-editor-ui-block-list-type-configuration.element.d.ts +3 -0
  22. package/dist-cms/packages/block/block-list/property-editors/block-list-type-configuration/property-editor-ui-block-list-type-configuration.element.js +41 -3
  23. package/dist-cms/packages/block/block-list/types.d.ts +1 -0
  24. package/dist-cms/packages/block/block-list/types.js +1 -1
  25. package/dist-cms/packages/block/block-type/components/index.d.ts +1 -1
  26. package/dist-cms/packages/block/block-type/components/index.js +1 -1
  27. package/dist-cms/packages/block/block-type/components/input-block-type/input-block-type.element.d.ts +1 -3
  28. package/dist-cms/packages/block/block-type/components/input-block-type/input-block-type.element.js +42 -46
  29. package/dist-cms/packages/block/block-type/workspace/block-type-workspace.context.d.ts +4 -4
  30. package/dist-cms/packages/block/block-type/workspace/block-type-workspace.context.js +3 -1
  31. package/dist-cms/packages/block/block-type/workspace/block-type-workspace.element.js +4 -2
  32. package/dist-cms/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.js +1 -1
  33. package/dist-cms/packages/core/components/input-section/input-section.element.js +1 -1
  34. package/dist-cms/packages/core/components/input-tiny-mce/input-tiny-mce.element.js +1 -1
  35. package/dist-cms/packages/core/data-type/modals/data-type-picker-flow/data-type-picker-flow-modal.element.js +1 -1
  36. package/dist-cms/packages/core/data-type/modals/property-editor-ui-picker/property-editor-ui-picker-modal.element.js +2 -2
  37. package/dist-cms/packages/core/localization/components/ui-culture-input/ui-culture-input.element.js +1 -1
  38. package/dist-cms/packages/core/localization/registry/localization.registry.js +1 -1
  39. package/dist-cms/packages/core/modal/common/section-picker/section-picker-modal.element.js +2 -2
  40. package/dist-cms/packages/core/property-editor/uis/tiny-mce/config/toolbar/property-editor-ui-tiny-mce-toolbar-configuration.element.js +1 -1
  41. package/dist-cms/packages/core/themes/theme.context.js +1 -1
  42. package/dist-cms/packages/core/tree/tree-item-base/tree-item-base.context.js +1 -1
  43. package/dist-cms/packages/documents/document-types/workspace/views/design/document-type-workspace-view-edit.element.js +1 -1
  44. package/dist-cms/packages/health-check/dashboard-health-check.element.js +1 -1
  45. package/dist-cms/packages/media/media-types/workspace/views/design/media-type-workspace-view-edit.element.js +1 -1
  46. package/dist-cms/packages/packages/package-section/views/created/created-packages-section-view.element.js +2 -2
  47. package/dist-cms/packages/packages/package-section/views/installed/installed-packages-section-view-item.element.js +1 -1
  48. package/dist-cms/packages/user/current-user/user-profile-apps/user-profile-app-themes.element.js +1 -1
  49. package/dist-cms/packages/user/user-group/collection/components/user-group-table-sections-column-layout.element.js +1 -1
  50. package/dist-cms/packages/user/user-group/components/user-group-ref/user-group-ref.element.js +1 -1
  51. package/dist-cms/packages/user/user-group/workspace/components/user-group-default-permission-list.element.js +1 -1
  52. package/dist-cms/packages/user/user-permission/components/entity-user-permission-settings-list/entity-user-permission-settings-list.element.js +1 -1
  53. package/dist-cms/shared/auth/auth-flow.d.ts +0 -2
  54. package/dist-cms/shared/auth/auth-flow.js +28 -9
  55. package/dist-cms/shared/auth/auth.context.d.ts +14 -5
  56. package/dist-cms/shared/auth/auth.context.js +15 -3
  57. package/dist-cms/shared/auth/auth.context.token.d.ts +4 -2
  58. package/dist-cms/shared/auth/auth.context.token.js +2 -0
  59. package/dist-cms/shared/auth/index.d.ts +0 -1
  60. package/dist-cms/shared/auth/index.js +0 -1
  61. package/dist-cms/tsconfig.build.tsbuildinfo +1 -1
  62. package/dist-cms/vscode-html-custom-data.json +23 -5
  63. package/package.json +1 -1
  64. package/dist-cms/shared/auth/auth.context.interface.d.ts +0 -39
  65. package/dist-cms/shared/auth/auth.context.interface.js +0 -1
@@ -18,7 +18,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
18
18
  var _UmbAppElement_instances, _UmbAppElement_authContext, _UmbAppElement_umbIconRegistry, _UmbAppElement_uuiIconRegistry, _UmbAppElement_serverConnection, _UmbAppElement_setup, _UmbAppElement_setAuthStatus, _UmbAppElement_redirect, _UmbAppElement_isAuthorizedGuard, _UmbAppElement_errorPage;
19
19
  import { UmbAppContext } from './app.context.js';
20
20
  import { UmbServerConnection } from './server-connection.js';
21
- import { UmbAuthContext } from '../../shared/auth/index.js';
21
+ import { UMB_STORAGE_REDIRECT_URL, UmbAuthContext } from '../../shared/auth/index.js';
22
22
  import { css, html, customElement, property } from '../../external/lit/index.js';
23
23
  import { UUIIconRegistryEssential } from '../../external/uui/index.js';
24
24
  import { UmbIconRegistry } from '../../shared/icon-registry/index.js';
@@ -46,7 +46,6 @@ let UmbAppElement = class UmbAppElement extends UmbLitElement {
46
46
  /**
47
47
  * Bypass authentication.
48
48
  */
49
- // TODO: this might not be the right solution
50
49
  this.bypassAuth = false;
51
50
  this._routes = [
52
51
  {
@@ -141,6 +140,14 @@ async function _UmbAppElement_setAuthStatus() {
141
140
  OpenAPI.WITH_CREDENTIALS = true;
142
141
  };
143
142
  _UmbAppElement_redirect = function _UmbAppElement_redirect() {
143
+ // If there is a ?code parameter in the url, then we are in the middle of the oauth flow
144
+ // and we need to complete the login (the authorization notifier will redirect after this is done
145
+ // essentially hitting this method again)
146
+ const queryParams = new URLSearchParams(window.location.search);
147
+ if (queryParams.has('code')) {
148
+ __classPrivateFieldGet(this, _UmbAppElement_authContext, "f")?.completeAuthorizationRequest();
149
+ return;
150
+ }
144
151
  switch (__classPrivateFieldGet(this, _UmbAppElement_serverConnection, "f")?.getStatus()) {
145
152
  case RuntimeLevelModel.INSTALL:
146
153
  history.replaceState(null, '', 'install');
@@ -153,16 +160,14 @@ _UmbAppElement_redirect = function _UmbAppElement_redirect() {
153
160
  break;
154
161
  case RuntimeLevelModel.RUN: {
155
162
  const pathname = pathWithoutBasePath({ start: true, end: false });
156
- // If we are on the installer or upgrade page, redirect to the root
157
- // but if not, keep the current path but replace state anyway to initialize the router
158
- let currentRoute = location.href;
159
- const savedRoute = sessionStorage.getItem('umb:auth:redirect');
160
- if (savedRoute) {
161
- sessionStorage.removeItem('umb:auth:redirect');
162
- currentRoute = savedRoute;
163
+ // If we are on installer or upgrade page, redirect to the root since we are in the RUN state
164
+ if (pathname === '/install' || pathname === '/upgrade') {
165
+ history.replaceState(null, '', '/');
166
+ break;
163
167
  }
164
- const finalPath = pathname === '/install' || pathname === '/upgrade' ? '/' : currentRoute;
165
- history.replaceState(null, '', finalPath);
168
+ // Keep the current path but replace state anyway to initialize the router
169
+ // because the router will not initialize a wildcard route by itself
170
+ history.replaceState(null, '', location.href);
166
171
  break;
167
172
  }
168
173
  default:
@@ -179,10 +184,9 @@ _UmbAppElement_isAuthorizedGuard = function _UmbAppElement_isAuthorizedGuard() {
179
184
  return true;
180
185
  }
181
186
  // Save location.href so we can redirect to it after login
182
- window.sessionStorage.setItem('umb:auth:redirect', location.href);
187
+ window.sessionStorage.setItem(UMB_STORAGE_REDIRECT_URL, location.href);
183
188
  // Make a request to the auth server to start the auth flow
184
- // TODO: find better name for this method
185
- __classPrivateFieldGet(this, _UmbAppElement_authContext, "f").login();
189
+ __classPrivateFieldGet(this, _UmbAppElement_authContext, "f").makeAuthorizationRequest();
186
190
  // Return false to prevent the route from being rendered
187
191
  return false;
188
192
  };
@@ -219,7 +223,7 @@ __decorate([
219
223
  ], UmbAppElement.prototype, "serverUrl", void 0);
220
224
  __decorate([
221
225
  property({ type: String })
222
- // TODO: get from server config
226
+ // TODO: get from base element or maybe move to UmbAuthContext.#getRedirectUrl since it is only used there
223
227
  ], UmbAppElement.prototype, "backofficePath", void 0);
224
228
  __decorate([
225
229
  property({ type: Boolean })
@@ -504,6 +504,36 @@
504
504
  }
505
505
  ]
506
506
  },
507
+ {
508
+ "name": "umb-property-editor-ui-block-grid-group-configuration",
509
+ "path": "./../src/packages/block/block-grid/property-editors/block-grid-group-configuration/property-editor-ui-block-grid-group-configuration.element.ts",
510
+ "attributes": [
511
+ {
512
+ "name": "value",
513
+ "type": "UmbBlockGridGroupType[]"
514
+ }
515
+ ],
516
+ "properties": [
517
+ {
518
+ "name": "value",
519
+ "attribute": "value",
520
+ "type": "UmbBlockGridGroupType[]"
521
+ },
522
+ {
523
+ "name": "config"
524
+ },
525
+ {
526
+ "name": "styles",
527
+ "type": "array",
528
+ "default": "[\"UmbTextStyles\",null]"
529
+ }
530
+ ],
531
+ "events": [
532
+ {
533
+ "name": "property-value-change"
534
+ }
535
+ ]
536
+ },
507
537
  {
508
538
  "name": "umb-property-editor-ui-block-grid-layout-stylesheet",
509
539
  "path": "./../src/packages/block/block-grid/property-editors/block-grid-layout-stylesheet/property-editor-ui-block-grid-layout-stylesheet.element.ts",
@@ -540,8 +570,7 @@
540
570
  "properties": [
541
571
  {
542
572
  "name": "value",
543
- "type": "UmbBlockTypeBaseModel[]",
544
- "default": "[]"
573
+ "type": "UmbBlockTypeWithGroupKey[]"
545
574
  },
546
575
  {
547
576
  "name": "config"
@@ -549,7 +578,7 @@
549
578
  {
550
579
  "name": "styles",
551
580
  "type": "array",
552
- "default": "[\"UmbTextStyles\"]"
581
+ "default": "[\"UmbTextStyles\",null]"
553
582
  }
554
583
  ]
555
584
  },
@@ -722,7 +751,7 @@
722
751
  "path": "./../src/packages/block/block-type/components/input-block-type/input-block-type.element.ts",
723
752
  "attributes": [
724
753
  {
725
- "name": "entity-type",
754
+ "name": "workspacePath",
726
755
  "type": "string | undefined"
727
756
  }
728
757
  ],
@@ -732,8 +761,8 @@
732
761
  "type": "BlockType[]"
733
762
  },
734
763
  {
735
- "name": "entityType",
736
- "attribute": "entity-type",
764
+ "name": "workspacePath",
765
+ "attribute": "workspacePath",
737
766
  "type": "string | undefined"
738
767
  },
739
768
  {
@@ -741,6 +770,11 @@
741
770
  "type": "array",
742
771
  "default": "[null]"
743
772
  }
773
+ ],
774
+ "events": [
775
+ {
776
+ "name": "create"
777
+ }
744
778
  ]
745
779
  },
746
780
  {
@@ -120,7 +120,7 @@ export class UmbBaseExtensionInitializer extends UmbBaseController {
120
120
  __classPrivateFieldSet(this, _UmbBaseExtensionInitializer_onPermissionChanged, onPermissionChanged, "f");
121
121
  }
122
122
  _init() {
123
- __classPrivateFieldSet(this, _UmbBaseExtensionInitializer_manifestObserver, this.observe(__classPrivateFieldGet(this, _UmbBaseExtensionInitializer_extensionRegistry, "f").getByAlias(__classPrivateFieldGet(this, _UmbBaseExtensionInitializer_alias, "f")), async (extensionManifest) => {
123
+ __classPrivateFieldSet(this, _UmbBaseExtensionInitializer_manifestObserver, this.observe(__classPrivateFieldGet(this, _UmbBaseExtensionInitializer_extensionRegistry, "f").byAlias(__classPrivateFieldGet(this, _UmbBaseExtensionInitializer_alias, "f")), async (extensionManifest) => {
124
124
  __classPrivateFieldGet(this, _UmbBaseExtensionInitializer_instances, "m", _UmbBaseExtensionInitializer_clearPermittedState).call(this);
125
125
  __classPrivateFieldSet(this, _UmbBaseExtensionInitializer_manifest, extensionManifest, "f");
126
126
  if (extensionManifest) {
@@ -197,7 +197,7 @@ _UmbBaseExtensionInitializer_promiseResolvers = new WeakMap(), _UmbBaseExtension
197
197
  oldAmountOfControllers === conditionConfigs.length;
198
198
  if (conditionConfigs.length > 0) {
199
199
  // Observes the conditions and initialize as they come in.
200
- this.observe(__classPrivateFieldGet(this, _UmbBaseExtensionInitializer_extensionRegistry, "f").getByTypeAndAliases('condition', conditionAliases), __classPrivateFieldGet(this, _UmbBaseExtensionInitializer_gotConditions, "f"), '_observeConditions');
200
+ this.observe(__classPrivateFieldGet(this, _UmbBaseExtensionInitializer_extensionRegistry, "f").byTypeAndAliases('condition', conditionAliases), __classPrivateFieldGet(this, _UmbBaseExtensionInitializer_gotConditions, "f"), '_observeConditions');
201
201
  }
202
202
  else {
203
203
  this.removeControllerByAlias('_observeConditions');
@@ -111,8 +111,8 @@ export class UmbBaseExtensionsInitializer extends UmbBaseController {
111
111
  }
112
112
  _init() {
113
113
  let source = Array.isArray(__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_type, "f"))
114
- ? __classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_extensionRegistry, "f").extensionsOfTypes(__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_type, "f"))
115
- : __classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_extensionRegistry, "f").extensionsOfType(__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_type, "f"));
114
+ ? __classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_extensionRegistry, "f").byTypes(__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_type, "f"))
115
+ : __classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_extensionRegistry, "f").byType(__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_type, "f"));
116
116
  if (__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_filter, "f")) {
117
117
  source = source.pipe(map((extensions) => extensions.filter(__classPrivateFieldGet(this, _UmbBaseExtensionsInitializer_filter, "f"))));
118
118
  }
@@ -18,7 +18,7 @@ export class UmbBundleExtensionInitializer extends UmbBaseController {
18
18
  _UmbBundleExtensionInitializer_extensionRegistry.set(this, void 0);
19
19
  _UmbBundleExtensionInitializer_bundleMap.set(this, new Map());
20
20
  __classPrivateFieldSet(this, _UmbBundleExtensionInitializer_extensionRegistry, extensionRegistry, "f");
21
- this.observe(extensionRegistry.extensionsOfType('bundle'), (bundles) => {
21
+ this.observe(extensionRegistry.byType('bundle'), (bundles) => {
22
22
  // Unregister removed bundles:
23
23
  __classPrivateFieldGet(this, _UmbBundleExtensionInitializer_bundleMap, "f").forEach((existingBundle) => {
24
24
  if (!bundles.find((b) => b.alias === existingBundle.alias)) {
@@ -20,7 +20,7 @@ export class UmbEntryPointExtensionInitializer extends UmbBaseController {
20
20
  _UmbEntryPointExtensionInitializer_entryPointMap.set(this, new Map());
21
21
  __classPrivateFieldSet(this, _UmbEntryPointExtensionInitializer_host, host, "f");
22
22
  __classPrivateFieldSet(this, _UmbEntryPointExtensionInitializer_extensionRegistry, extensionRegistry, "f");
23
- this.observe(extensionRegistry.extensionsOfType('entryPoint'), (entryPoints) => {
23
+ this.observe(extensionRegistry.byType('entryPoint'), (entryPoints) => {
24
24
  entryPoints.forEach((entryPoint) => {
25
25
  if (__classPrivateFieldGet(this, _UmbEntryPointExtensionInitializer_entryPointMap, "f").has(entryPoint.alias))
26
26
  return;
@@ -2,6 +2,7 @@ import type { ManifestBase, ManifestKind } from '../types/index.js';
2
2
  import type { ManifestTypeMap, SpecificManifestTypeOrManifestBase } from '../types/map.types.js';
3
3
  import type { Observable } from '../../../external/rxjs/index.js';
4
4
  export declare class UmbExtensionRegistry<IncomingManifestTypes extends ManifestBase, ManifestTypes extends ManifestBase = IncomingManifestTypes | ManifestBase> {
5
+ #private;
5
6
  readonly MANIFEST_TYPES: ManifestTypes;
6
7
  private _extensions;
7
8
  readonly extensions: Observable<ManifestTypes[]>;
@@ -13,33 +14,59 @@ export declare class UmbExtensionRegistry<IncomingManifestTypes extends Manifest
13
14
  unregisterMany(aliases: Array<string>): void;
14
15
  unregister(alias: string): void;
15
16
  isRegistered(alias: string): boolean;
16
- private checkExtension;
17
- private _kindsOfType;
18
- private _extensionsOfType;
19
- private _kindsOfTypes;
20
- private _extensionsOfTypes;
21
- getByAlias<T extends ManifestBase = ManifestBase>(alias: string): Observable<T | undefined>;
22
- getByTypeAndAlias<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, alias: string): Observable<T | undefined>;
23
- getByTypeAndAliases<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, aliases: Array<string>): Observable<T[]>;
24
- /**
25
- * Get an observable of an extension by type and a given filter method.
17
+ /**
18
+ * Get an observable that provides extensions matching the given alias.
19
+ * @param alias {string} - The alias of the extensions to get.
20
+ * @returns {Observable<T | undefined>} - An observable of the extension that matches the alias.
21
+ */
22
+ byAlias<T extends ManifestBase = ManifestBase>(alias: string): Observable<T | undefined>;
23
+ /**
24
+ * @deprecated Use `byAlias` instead.
25
+ */
26
+ getByAlias: <T extends ManifestBase = ManifestBase>(alias: string) => Observable<T | undefined>;
27
+ /**
28
+ * Get an observable that provides extensions matching the given type and alias.
29
+ * @param type {string} - The type of the extensions to get.
30
+ * @param alias {string} - The alias of the extensions to get.
31
+ * @returns {Observable<T | undefined>} - An observable of the extensions that matches the type and alias.
32
+ */
33
+ byTypeAndAlias<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, alias: string): Observable<T | undefined>;
34
+ /**
35
+ * @deprecated Use `byTypeAndAlias` instead.
36
+ */
37
+ getByTypeAndAlias: <Key extends string | number | ManifestTypes["type"], T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, alias: string) => Observable<T | undefined>;
38
+ byTypeAndAliases<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, aliases: Array<string>): Observable<T[]>;
39
+ /**
40
+ * @deprecated Use `byTypeAndAliases` instead.
41
+ */
42
+ getByTypeAndAliases: <Key extends string | number | ManifestTypes["type"], T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, aliases: Array<string>) => Observable<T[]>;
43
+ /**
44
+ * Get an observable of extensions by type and a given filter method.
26
45
  * This will return the all extensions that matches the type and which filter method returns true.
27
46
  * The filter method will be called for each extension manifest of the given type, and the first argument to it is the extension manifest.
28
47
  * @param type {string} - The type of the extension to get
29
48
  * @param filter {(ext: T): void} - The filter method to use to filter the extensions
30
- * @returns {Observable<T | undefined>} - An observable of the extensions that matches the type and filter method
49
+ * @returns {Observable<Array<T>>} - An observable of the extensions that matches the type and filter method
31
50
  */
32
- byTypeAndFilter<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, filter: (ext: T) => boolean): Observable<T | undefined>;
51
+ byTypeAndFilter<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key, filter: (ext: T) => boolean): Observable<T[]>;
33
52
  /**
34
53
  * Get an observable that provides extensions matching the given type.
35
54
  * @param type {string} - The type of the extensions to get.
36
55
  * @returns {Observable<T | undefined>} - An observable of the extensions that matches the type.
37
56
  */
38
- extensionsOfType<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key): Observable<T[]>;
57
+ byType<Key extends keyof ManifestTypeMap<ManifestTypes> | string, T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key): Observable<T[]>;
58
+ /**
59
+ * @deprecated Use `byType` instead.
60
+ */
61
+ extensionsOfType: <Key extends string | number | ManifestTypes["type"], T extends ManifestBase = SpecificManifestTypeOrManifestBase<ManifestTypes, Key>>(type: Key) => Observable<T[]>;
39
62
  /**
40
63
  * Get an observable that provides extensions matching given types.
41
64
  * @param type {Array<string>} - The types of the extensions to get.
42
65
  * @returns {Observable<T | undefined>} - An observable of the extensions that matches the types.
43
66
  */
44
- extensionsOfTypes<ExtensionTypes extends ManifestBase = ManifestBase>(types: string[]): Observable<Array<ExtensionTypes>>;
67
+ byTypes<ExtensionTypes extends ManifestBase = ManifestBase>(types: string[]): Observable<Array<ExtensionTypes>>;
68
+ /**
69
+ * @deprecated Use `byTypes` instead.
70
+ */
71
+ extensionsOfTypes: <ExtensionTypes extends ManifestBase = ManifestBase>(types: string[]) => Observable<ExtensionTypes[]>;
45
72
  }
@@ -1,3 +1,9 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _UmbExtensionRegistry_instances, _UmbExtensionRegistry_checkExtension, _UmbExtensionRegistry_kindsOfType, _UmbExtensionRegistry_extensionsOfType, _UmbExtensionRegistry_kindsOfTypes, _UmbExtensionRegistry_extensionsOfTypes, _UmbExtensionRegistry_mergeExtensionWithKinds, _UmbExtensionRegistry_mergeExtensionsWithKinds;
1
7
  import { UmbBasicState } from '../../observable-api/index.js';
2
8
  import { map, distinctUntilChanged, combineLatest, of, switchMap } from '../../../external/rxjs/index.js';
3
9
  function extensionArrayMemoization(previousValue, currentValue) {
@@ -48,11 +54,32 @@ function extensionAndKindMatchSingleMemoization(previousValue, currentValue) {
48
54
  const sortExtensions = (a, b) => (b.weight || 0) - (a.weight || 0);
49
55
  export class UmbExtensionRegistry {
50
56
  constructor() {
57
+ _UmbExtensionRegistry_instances.add(this);
51
58
  this.MANIFEST_TYPES = undefined;
52
59
  this._extensions = new UmbBasicState([]);
53
60
  this.extensions = this._extensions.asObservable();
54
61
  this._kinds = new UmbBasicState([]);
55
62
  this.kinds = this._kinds.asObservable();
63
+ /**
64
+ * @deprecated Use `byAlias` instead.
65
+ */
66
+ this.getByAlias = this.byAlias.bind(this);
67
+ /**
68
+ * @deprecated Use `byTypeAndAlias` instead.
69
+ */
70
+ this.getByTypeAndAlias = this.byTypeAndAlias.bind(this);
71
+ /**
72
+ * @deprecated Use `byTypeAndAliases` instead.
73
+ */
74
+ this.getByTypeAndAliases = this.byTypeAndAliases.bind(this);
75
+ /**
76
+ * @deprecated Use `byType` instead.
77
+ */
78
+ this.extensionsOfType = this.byType.bind(this);
79
+ /**
80
+ * @deprecated Use `byTypes` instead.
81
+ */
82
+ this.extensionsOfTypes = this.byTypes.bind(this);
56
83
  }
57
84
  defineKind(kind) {
58
85
  const extensionsValues = this._extensions.getValue();
@@ -69,7 +96,7 @@ export class UmbExtensionRegistry {
69
96
  this._kinds.setValue(nextData);
70
97
  }
71
98
  register(manifest) {
72
- const isValid = this.checkExtension(manifest);
99
+ const isValid = __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_checkExtension).call(this, manifest);
73
100
  if (!isValid) {
74
101
  return;
75
102
  }
@@ -97,181 +124,124 @@ export class UmbExtensionRegistry {
97
124
  }
98
125
  return false;
99
126
  }
100
- /*
101
- getByAlias(alias: string) {
102
- // TODO: make pipes prettier/simpler/reuseable
103
- return this.extensions.pipe(map((extensions) => extensions.find((extension) => extension.alias === alias) || null));
104
- }
105
- */
106
- checkExtension(manifest) {
107
- if (!manifest.type) {
108
- console.error(`Extension is missing type`, manifest);
109
- return false;
110
- }
111
- if (!manifest.alias) {
112
- console.error(`Extension is missing alias`, manifest);
113
- return false;
114
- }
115
- if (manifest.type === 'kind') {
116
- this.defineKind(manifest);
117
- return false;
118
- }
119
- const extensionsValues = this._extensions.getValue();
120
- const extension = extensionsValues.find((extension) => extension.alias === manifest.alias);
121
- if (extension) {
122
- console.error(`Extension with alias ${manifest.alias} is already registered`);
123
- return false;
124
- }
125
- return true;
126
- }
127
- _kindsOfType(type) {
128
- return this.kinds.pipe(map((kinds) => kinds.filter((kind) => kind.matchType === type)), distinctUntilChanged(extensionArrayMemoization));
129
- }
130
- _extensionsOfType(type) {
131
- return this.extensions.pipe(map((exts) => exts.filter((ext) => ext.type === type)), distinctUntilChanged(extensionArrayMemoization));
132
- }
133
- _kindsOfTypes(types) {
134
- return this.kinds.pipe(map((kinds) => kinds.filter((kind) => types.indexOf(kind.matchType) !== -1)), distinctUntilChanged(extensionArrayMemoization));
135
- }
136
- // TODO: can we get rid of as unknown here
137
- _extensionsOfTypes(types) {
138
- return this.extensions.pipe(map((exts) => exts.filter((ext) => types.indexOf(ext.type) !== -1)), distinctUntilChanged(extensionArrayMemoization));
139
- }
140
- // TODO: get rid of the name get
141
- getByAlias(alias) {
127
+ /**
128
+ * Get an observable that provides extensions matching the given alias.
129
+ * @param alias {string} - The alias of the extensions to get.
130
+ * @returns {Observable<T | undefined>} - An observable of the extension that matches the alias.
131
+ */
132
+ byAlias(alias) {
142
133
  return this.extensions.pipe(map((exts) => exts.find((ext) => ext.alias === alias)), distinctUntilChanged(extensionSingleMemoization), switchMap((ext) => {
143
134
  if (ext?.kind) {
144
- return this._kindsOfType(ext.type).pipe(map((kinds) => {
145
- // Specific Extension Meta merge (does not merge conditions)
146
- if (ext) {
147
- // Since we dont have the type up front in this request, we will just get all kinds here and find the matching one:
148
- const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
149
- // TODO: This check can go away when making a find kind based on type and kind.
150
- if (baseManifest) {
151
- const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
152
- if (baseManifest.meta) {
153
- merged.meta = { ...baseManifest.meta, ...ext.meta };
154
- }
155
- return merged;
156
- }
157
- }
158
- return ext;
159
- }));
135
+ return __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_kindsOfType).call(this, ext.type).pipe(map((kinds) => __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_mergeExtensionWithKinds).call(this, [ext, kinds])));
160
136
  }
161
137
  return of(ext);
162
138
  }), distinctUntilChanged(extensionAndKindMatchSingleMemoization));
163
139
  }
164
- // TODO: get rid of the name get
165
- getByTypeAndAlias(type, alias) {
140
+ /**
141
+ * Get an observable that provides extensions matching the given type and alias.
142
+ * @param type {string} - The type of the extensions to get.
143
+ * @param alias {string} - The alias of the extensions to get.
144
+ * @returns {Observable<T | undefined>} - An observable of the extensions that matches the type and alias.
145
+ */
146
+ byTypeAndAlias(type, alias) {
166
147
  return combineLatest([
167
148
  this.extensions.pipe(map((exts) => exts.find((ext) => ext.type === type && ext.alias === alias)), distinctUntilChanged(extensionSingleMemoization)),
168
- this._kindsOfType(type),
169
- ]).pipe(map(([ext, kinds]) => {
170
- // TODO: share one merge function between the different methods of this class:
171
- // Specific Extension Meta merge (does not merge conditions)
172
- if (ext) {
173
- const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
174
- if (baseManifest) {
175
- const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
176
- if (baseManifest.meta) {
177
- merged.meta = { ...baseManifest.meta, ...ext.meta };
178
- }
179
- return merged;
180
- }
181
- }
182
- return ext;
183
- }), distinctUntilChanged(extensionAndKindMatchSingleMemoization));
149
+ __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_kindsOfType).call(this, type),
150
+ ]).pipe(map(__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_mergeExtensionWithKinds)), distinctUntilChanged(extensionAndKindMatchSingleMemoization));
184
151
  }
185
- // TODO: get rid of the name get
186
- getByTypeAndAliases(type, aliases) {
152
+ byTypeAndAliases(type, aliases) {
187
153
  return combineLatest([
188
154
  this.extensions.pipe(map((exts) => exts.filter((ext) => ext.type === type && aliases.indexOf(ext.alias) !== -1)), distinctUntilChanged(extensionArrayMemoization)),
189
- this._kindsOfType(type),
190
- ]).pipe(map(([exts, kinds]) => exts
191
- .map((ext) => {
192
- // Specific Extension Meta merge (does not merge conditions)
193
- const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
194
- if (baseManifest) {
195
- const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
196
- if (baseManifest.meta) {
197
- merged.meta = { ...baseManifest.meta, ...ext.meta };
198
- }
199
- return merged;
200
- }
201
- return ext;
202
- })
203
- .sort(sortExtensions)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
155
+ __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_kindsOfType).call(this, type),
156
+ ]).pipe(map(__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_mergeExtensionsWithKinds)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
204
157
  }
205
158
  /**
206
- * Get an observable of an extension by type and a given filter method.
159
+ * Get an observable of extensions by type and a given filter method.
207
160
  * This will return the all extensions that matches the type and which filter method returns true.
208
161
  * The filter method will be called for each extension manifest of the given type, and the first argument to it is the extension manifest.
209
162
  * @param type {string} - The type of the extension to get
210
163
  * @param filter {(ext: T): void} - The filter method to use to filter the extensions
211
- * @returns {Observable<T | undefined>} - An observable of the extensions that matches the type and filter method
164
+ * @returns {Observable<Array<T>>} - An observable of the extensions that matches the type and filter method
212
165
  */
213
166
  byTypeAndFilter(type, filter) {
214
167
  return combineLatest([
215
- this.extensions.pipe(map((exts) => exts.find((ext) => ext.type === type && filter(ext))), distinctUntilChanged(extensionSingleMemoization)),
216
- this._kindsOfType(type),
217
- ]).pipe(map(([ext, kinds]) => {
218
- // TODO: share one merge function between the different methods of this class:
219
- // Specific Extension Meta merge (does not merge conditions)
220
- if (ext) {
221
- const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
222
- if (baseManifest) {
223
- const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
224
- if (baseManifest.meta) {
225
- merged.meta = { ...baseManifest.meta, ...ext.meta };
226
- }
227
- return merged;
228
- }
229
- }
230
- return ext;
231
- }), distinctUntilChanged(extensionAndKindMatchSingleMemoization));
168
+ this.extensions.pipe(map((exts) => exts.filter((ext) => ext.type === type && filter(ext))), distinctUntilChanged(extensionArrayMemoization)),
169
+ __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_kindsOfType).call(this, type),
170
+ ]).pipe(map(__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_mergeExtensionsWithKinds)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
232
171
  }
233
172
  /**
234
173
  * Get an observable that provides extensions matching the given type.
235
174
  * @param type {string} - The type of the extensions to get.
236
175
  * @returns {Observable<T | undefined>} - An observable of the extensions that matches the type.
237
176
  */
238
- extensionsOfType(type) {
239
- return combineLatest([this._extensionsOfType(type), this._kindsOfType(type)]).pipe(map(([exts, kinds]) => exts
240
- .map((ext) => {
241
- // Specific Extension Meta merge (does not merge conditions)
242
- const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
243
- if (baseManifest) {
244
- const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
245
- if (baseManifest.meta) {
246
- merged.meta = { ...baseManifest.meta, ...ext.meta };
247
- }
248
- return merged;
249
- }
250
- return ext;
251
- })
252
- .sort(sortExtensions)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
177
+ byType(type) {
178
+ return combineLatest([__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_extensionsOfType).call(this, type), __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_kindsOfType).call(this, type)]).pipe(map(__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_mergeExtensionsWithKinds)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
253
179
  }
254
180
  /**
255
181
  * Get an observable that provides extensions matching given types.
256
182
  * @param type {Array<string>} - The types of the extensions to get.
257
183
  * @returns {Observable<T | undefined>} - An observable of the extensions that matches the types.
258
184
  */
259
- extensionsOfTypes(types) {
260
- return combineLatest([this._extensionsOfTypes(types), this._kindsOfTypes(types)]).pipe(map(([exts, kinds]) => exts
261
- .map((ext) => {
262
- // Specific Extension Meta merge (does not merge conditions)
263
- if (ext) {
264
- const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
265
- if (baseManifest) {
266
- const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
267
- if (baseManifest.meta) {
268
- merged.meta = { ...baseManifest.meta, ...ext.meta };
269
- }
270
- return merged;
271
- }
272
- }
273
- return ext;
274
- })
275
- .sort(sortExtensions)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
185
+ byTypes(types) {
186
+ return combineLatest([__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_extensionsOfTypes).call(this, types), __classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_kindsOfTypes).call(this, types)]).pipe(map(__classPrivateFieldGet(this, _UmbExtensionRegistry_instances, "m", _UmbExtensionRegistry_mergeExtensionsWithKinds)), distinctUntilChanged(extensionAndKindMatchArrayMemoization));
276
187
  }
277
188
  }
189
+ _UmbExtensionRegistry_instances = new WeakSet(), _UmbExtensionRegistry_checkExtension = function _UmbExtensionRegistry_checkExtension(manifest) {
190
+ if (!manifest.type) {
191
+ console.error(`Extension is missing type`, manifest);
192
+ return false;
193
+ }
194
+ if (!manifest.alias) {
195
+ console.error(`Extension is missing alias`, manifest);
196
+ return false;
197
+ }
198
+ if (manifest.type === 'kind') {
199
+ this.defineKind(manifest);
200
+ return false;
201
+ }
202
+ const extensionsValues = this._extensions.getValue();
203
+ const extension = extensionsValues.find((extension) => extension.alias === manifest.alias);
204
+ if (extension) {
205
+ console.error(`Extension with alias ${manifest.alias} is already registered`);
206
+ return false;
207
+ }
208
+ return true;
209
+ }, _UmbExtensionRegistry_kindsOfType = function _UmbExtensionRegistry_kindsOfType(type) {
210
+ return this.kinds.pipe(map((kinds) => kinds.filter((kind) => kind.matchType === type)), distinctUntilChanged(extensionArrayMemoization));
211
+ }, _UmbExtensionRegistry_extensionsOfType = function _UmbExtensionRegistry_extensionsOfType(type) {
212
+ return this.extensions.pipe(map((exts) => exts.filter((ext) => ext.type === type)), distinctUntilChanged(extensionArrayMemoization));
213
+ }, _UmbExtensionRegistry_kindsOfTypes = function _UmbExtensionRegistry_kindsOfTypes(types) {
214
+ return this.kinds.pipe(map((kinds) => kinds.filter((kind) => types.indexOf(kind.matchType) !== -1)), distinctUntilChanged(extensionArrayMemoization));
215
+ }, _UmbExtensionRegistry_extensionsOfTypes = function _UmbExtensionRegistry_extensionsOfTypes(types) {
216
+ return this.extensions.pipe(map((exts) => exts.filter((ext) => types.indexOf(ext.type) !== -1)), distinctUntilChanged(extensionArrayMemoization));
217
+ }, _UmbExtensionRegistry_mergeExtensionWithKinds = function _UmbExtensionRegistry_mergeExtensionWithKinds([ext, kinds,]) {
218
+ // Specific Extension Meta merge (does not merge conditions)
219
+ if (ext) {
220
+ // Since we don't have the type up front in this request, we will just get all kinds here and find the matching one:
221
+ const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
222
+ // TODO: This check can go away when making a find kind based on type and kind.
223
+ if (baseManifest) {
224
+ const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
225
+ if (baseManifest.meta) {
226
+ merged.meta = { ...baseManifest.meta, ...ext.meta };
227
+ }
228
+ return merged;
229
+ }
230
+ }
231
+ return ext;
232
+ }, _UmbExtensionRegistry_mergeExtensionsWithKinds = function _UmbExtensionRegistry_mergeExtensionsWithKinds([exts, kinds,]) {
233
+ return exts
234
+ .map((ext) => {
235
+ // Specific Extension Meta merge (does not merge conditions)
236
+ const baseManifest = kinds.find((kind) => kind.matchKind === ext.kind)?.manifest;
237
+ if (baseManifest) {
238
+ const merged = { __isMatchedWithKind: true, ...baseManifest, ...ext };
239
+ if (baseManifest.meta) {
240
+ merged.meta = { ...baseManifest.meta, ...ext.meta };
241
+ }
242
+ return merged;
243
+ }
244
+ return ext;
245
+ })
246
+ .sort(sortExtensions);
247
+ };
@@ -692,6 +692,13 @@ export const data = [
692
692
  icon: 'icon-book-alt',
693
693
  groupKey: 'demo-block-group-id',
694
694
  },
695
+ {
696
+ label: 'Test broken group key',
697
+ contentElementTypeKey: 'test-block-id',
698
+ editorSize: 'medium',
699
+ icon: 'icon-war',
700
+ groupKey: 'group-id-that-does-not-exist',
701
+ },
695
702
  ],
696
703
  },
697
704
  ],