@telia-ace/widget-core 0.0.1
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.
- package/action-resolver.d.ts +9 -0
- package/bootstrap.d.ts +16 -0
- package/component-platform/actions-controller.d.ts +41 -0
- package/component-platform/component-configuration-api.d.ts +2 -0
- package/component-platform/component-controller.d.ts +39 -0
- package/component-platform/component-node-collection.d.ts +19 -0
- package/component-platform/component-node.d.ts +64 -0
- package/component-platform/component-platform.d.ts +55 -0
- package/component-platform/component-query.d.ts +17 -0
- package/component-platform/create-component-model.d.ts +37 -0
- package/component-platform/custom-component-handler.d.ts +22 -0
- package/component-platform/descriptor.d.ts +9 -0
- package/component-platform/extend-component.d.ts +9 -0
- package/component-platform/index.d.ts +18 -0
- package/component-platform/queries.d.ts +7 -0
- package/component-platform/state-processor.d.ts +13 -0
- package/component-resolver.d.ts +15 -0
- package/environment.d.ts +49 -0
- package/event-subscriber.d.ts +8 -0
- package/implementation.d.ts +8 -0
- package/index.d.ts +14 -0
- package/index.js +3 -0
- package/index.mjs +910 -0
- package/package.json +12 -0
- package/plugin.d.ts +8 -0
- package/types/configuration.d.ts +87 -0
- package/types/index.d.ts +2 -0
- package/types/ui.d.ts +48 -0
- package/version.d.ts +2 -0
- package/widget-type.d.ts +8 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
2
|
+
|
|
3
|
+
export type Action = (origin: string, action: string, value?: any) => void;
|
|
4
|
+
export default class ActionResolver {
|
|
5
|
+
private events;
|
|
6
|
+
constructor(container: Container);
|
|
7
|
+
action(target: string, action: string, value: any): void;
|
|
8
|
+
subscribe(origin: string, fn: Action): EventSubscriptionCancellation;
|
|
9
|
+
}
|
package/bootstrap.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BootstrappedImplementation } from '@webprovisions/bootstrapping';
|
|
2
|
+
import { ConfigureCallback } from '@webprovisions/platform';
|
|
3
|
+
import { default as Implementation } from './implementation';
|
|
4
|
+
|
|
5
|
+
export type BootstrapOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Resolver function for the root element to base the bootstrapping on.
|
|
8
|
+
*/
|
|
9
|
+
rootElementResolver?: () => HTMLElement;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Bootstraps an `Implementation` by scanning trigger elements and attaches them to
|
|
13
|
+
* their corresponding widgets.
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: (implementation: Implementation, configure: ConfigureCallback, options?: BootstrapOptions) => Promise<BootstrappedImplementation>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
2
|
+
import { ComponentNodeController } from './component-controller';
|
|
3
|
+
import { ComponentNode } from './component-node';
|
|
4
|
+
import { ComponentPlatform } from './component-platform';
|
|
5
|
+
import { ComponentQuery } from './component-query';
|
|
6
|
+
|
|
7
|
+
export type ActionData = any;
|
|
8
|
+
export type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;
|
|
9
|
+
export type NextActionDelegate = (data: any, options?: any) => Promise<any>;
|
|
10
|
+
export type WatchActionDelegate = (input: ActionData, next: NextActionDelegate, instance: ComponentNodeController) => Promise<any> | any;
|
|
11
|
+
export type ActionWatcherContext = {
|
|
12
|
+
source: ComponentNode;
|
|
13
|
+
action: string;
|
|
14
|
+
};
|
|
15
|
+
export type ActionsState = {
|
|
16
|
+
handlers: {
|
|
17
|
+
fn: ActionHandler;
|
|
18
|
+
key: string;
|
|
19
|
+
target: ComponentQuery;
|
|
20
|
+
ns?: string;
|
|
21
|
+
}[];
|
|
22
|
+
watchers: {
|
|
23
|
+
target: ComponentQuery;
|
|
24
|
+
fn: WatchActionDelegate;
|
|
25
|
+
key: string;
|
|
26
|
+
ns?: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
export declare class ActionsController {
|
|
30
|
+
private platform;
|
|
31
|
+
private target;
|
|
32
|
+
private ns?;
|
|
33
|
+
private subscriptions;
|
|
34
|
+
constructor(platform: ComponentPlatform, target: ComponentQuery, ns?: string | undefined);
|
|
35
|
+
create(key: string, fn?: ActionHandler): EventSubscriptionCancellation;
|
|
36
|
+
dispatch(key: string, data: any): Promise<{
|
|
37
|
+
[instanceId: string]: any;
|
|
38
|
+
}>;
|
|
39
|
+
watch(key: string, fn: WatchActionDelegate): EventSubscriptionCancellation;
|
|
40
|
+
dispose(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ActionsController } from './actions-controller';
|
|
2
|
+
import { ChangesetOptions, ComponentNode, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties } from './component-node';
|
|
3
|
+
import { ComponentPlatform } from './component-platform';
|
|
4
|
+
import { ComponentQuery } from './component-query';
|
|
5
|
+
|
|
6
|
+
export interface ComponentController {
|
|
7
|
+
actions: ActionsController;
|
|
8
|
+
writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;
|
|
9
|
+
writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;
|
|
10
|
+
writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare class ComponentNodeController implements ComponentController {
|
|
14
|
+
private platform;
|
|
15
|
+
node: ComponentNode;
|
|
16
|
+
actions: ActionsController;
|
|
17
|
+
private subscribe;
|
|
18
|
+
private unsubscribe;
|
|
19
|
+
constructor(platform: ComponentPlatform, node: ComponentNode, ns?: string);
|
|
20
|
+
properties<T extends ComponentNodeProperties>(updated?: (properties: T) => void | Partial<ComponentNodeProperties>): T;
|
|
21
|
+
context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext;
|
|
22
|
+
layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout;
|
|
23
|
+
writeProperties(properties: Partial<ComponentNodeProperties> | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>), options?: ChangesetOptions): void;
|
|
24
|
+
writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void;
|
|
25
|
+
writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class AbstractComponentController implements ComponentController {
|
|
29
|
+
private platform;
|
|
30
|
+
private target;
|
|
31
|
+
private clearOnDispose;
|
|
32
|
+
actions: ActionsController;
|
|
33
|
+
private removes;
|
|
34
|
+
constructor(platform: ComponentPlatform, target: ComponentQuery, clearOnDispose?: boolean);
|
|
35
|
+
writeProperties(properties: Partial<ComponentNodeProperties>, options?: ChangesetOptions): void;
|
|
36
|
+
writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void;
|
|
37
|
+
writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void;
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EventManager } from '@webprovisions/platform';
|
|
2
|
+
import { ComponentNode } from './component-node';
|
|
3
|
+
import { SwitchMap } from './component-platform';
|
|
4
|
+
|
|
5
|
+
export type QueryDescriptor = {
|
|
6
|
+
id?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class ComponentNodeCollection {
|
|
11
|
+
root: ComponentNode;
|
|
12
|
+
private switches;
|
|
13
|
+
all: ComponentNode[];
|
|
14
|
+
visible: ComponentNode[];
|
|
15
|
+
detached: ComponentNode[];
|
|
16
|
+
constructor(root: ComponentNode, switches: SwitchMap, events: EventManager);
|
|
17
|
+
query(query?: QueryDescriptor): ComponentNode[];
|
|
18
|
+
get(id: string): ComponentNode | undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Container, EventManager } from '@webprovisions/platform';
|
|
2
|
+
import { Breakpoints } from '../types';
|
|
3
|
+
|
|
4
|
+
export type ComponentNodeEventData = {
|
|
5
|
+
node: ComponentNode;
|
|
6
|
+
};
|
|
7
|
+
export type RemoveChangeset = () => void;
|
|
8
|
+
export type ComponentNodeAttributes = {
|
|
9
|
+
tags: string[];
|
|
10
|
+
properties: ComponentNodeProperties;
|
|
11
|
+
context: ComponentNodeContext;
|
|
12
|
+
layout: ComponentNodeLayout;
|
|
13
|
+
};
|
|
14
|
+
export type ResolveComponentNodeProperties = (properties: ComponentNodeProperties) => Partial<ComponentNodeProperties> | void;
|
|
15
|
+
export type ResolveComponentNodeContext = (context: ComponentNodeContext) => Partial<ComponentNodeContext>;
|
|
16
|
+
export type ResolveComponentNodeLayout = (layout: ComponentNodeLayout) => Partial<ComponentNodeLayout>;
|
|
17
|
+
export type ComponentNodeSettings = {
|
|
18
|
+
tags?: string[];
|
|
19
|
+
properties?: ComponentNodeProperties | ResolveComponentNodeProperties;
|
|
20
|
+
context?: ComponentNodeContext | ResolveComponentNodeContext;
|
|
21
|
+
layout?: ComponentNodeLayout | ResolveComponentNodeLayout;
|
|
22
|
+
};
|
|
23
|
+
export type ComponentNodeProperties = {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
export type ComponentNodeContext = {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
export type ComponentNodeLayout = {
|
|
30
|
+
size?: Size;
|
|
31
|
+
indent?: number;
|
|
32
|
+
order?: number;
|
|
33
|
+
};
|
|
34
|
+
export type Size = number | 'full' | 'none';
|
|
35
|
+
export type UnmountComponentNode = () => void;
|
|
36
|
+
export type ChangesetOptions = {
|
|
37
|
+
breakpoints?: Breakpoints;
|
|
38
|
+
};
|
|
39
|
+
export type Changeset = [Partial<ComponentNodeSettings>, ChangesetOptions];
|
|
40
|
+
export declare class ComponentNode {
|
|
41
|
+
private events;
|
|
42
|
+
id: string;
|
|
43
|
+
type: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
parent?: ComponentNode;
|
|
46
|
+
tags: string[];
|
|
47
|
+
children: {
|
|
48
|
+
[key: string]: ComponentNode[];
|
|
49
|
+
};
|
|
50
|
+
changesets: Changeset[];
|
|
51
|
+
attributes: ComponentNodeAttributes;
|
|
52
|
+
private mountCount;
|
|
53
|
+
constructor(events: EventManager, type: string);
|
|
54
|
+
mount(viewOutletContainer: Container, element?: HTMLElement): UnmountComponentNode;
|
|
55
|
+
appendChild(node: ComponentNode, branch?: string): void;
|
|
56
|
+
prependChild(node: ComponentNode, branch?: string): void;
|
|
57
|
+
touchProperties(properties: ResolveComponentNodeProperties, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
58
|
+
writeProperties(properties: Partial<ComponentNodeProperties> | ResolveComponentNodeProperties, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
59
|
+
writeLayout(layout: Partial<ComponentNodeLayout> | ResolveComponentNodeLayout, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
60
|
+
writeContext(context: Partial<ComponentNodeContext> | ResolveComponentNodeContext, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
61
|
+
getChildren(branch?: string): ComponentNode[];
|
|
62
|
+
remove(): void;
|
|
63
|
+
removeChild(node: ComponentNode): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Container, EventManager, Widget } from '@webprovisions/platform';
|
|
2
|
+
import { ActionsController, ActionsState } from './actions-controller';
|
|
3
|
+
import { ChangesetProvider } from './changeset-provider';
|
|
4
|
+
import { ChangesetOptions, ComponentNode, ComponentNodeSettings, RemoveChangeset } from './component-node';
|
|
5
|
+
import { ComponentNodeCollection } from './component-node-collection';
|
|
6
|
+
import { ComponentQuery } from './component-query';
|
|
7
|
+
import { CustomHandlerCallback } from './custom-component-handler';
|
|
8
|
+
|
|
9
|
+
export type MergeOptions = {
|
|
10
|
+
breakpoints?: string[];
|
|
11
|
+
};
|
|
12
|
+
export type SwitchMap = {
|
|
13
|
+
[id: string]: string;
|
|
14
|
+
};
|
|
15
|
+
export type ChangesetData = {
|
|
16
|
+
key?: string;
|
|
17
|
+
target: ComponentQuery;
|
|
18
|
+
attributes: Partial<ComponentNodeSettings>;
|
|
19
|
+
options?: ChangesetOptions;
|
|
20
|
+
removable?: boolean;
|
|
21
|
+
provider?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare class ComponentPlatform {
|
|
24
|
+
private providers;
|
|
25
|
+
events: EventManager;
|
|
26
|
+
breakpoints: string[];
|
|
27
|
+
nodes: ComponentNodeCollection;
|
|
28
|
+
actionsState: ActionsState;
|
|
29
|
+
private switches;
|
|
30
|
+
private changesets;
|
|
31
|
+
private subscriptions;
|
|
32
|
+
private processNode;
|
|
33
|
+
private customComponentHandler;
|
|
34
|
+
constructor(widget: Widget, providers?: {
|
|
35
|
+
[key: string]: ChangesetProvider;
|
|
36
|
+
});
|
|
37
|
+
static getInstance(container: Container): Promise<ComponentPlatform>;
|
|
38
|
+
addBreakpoint(name: string): void;
|
|
39
|
+
removeBreakpoint(name: string): void;
|
|
40
|
+
setSwitch(node: ComponentNode, branch: string): void;
|
|
41
|
+
getBranch(node: ComponentNode): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a `ComponentNode` of the specified type.
|
|
44
|
+
* @param type Type of node.
|
|
45
|
+
*/
|
|
46
|
+
createNode(type: string, options?: {
|
|
47
|
+
detached?: boolean;
|
|
48
|
+
}): ComponentNode;
|
|
49
|
+
components(): ComponentQuery;
|
|
50
|
+
actions(target: ComponentQuery, ns: string): ActionsController;
|
|
51
|
+
write(data: ChangesetData): RemoveChangeset;
|
|
52
|
+
addComponentHandler(definitionType: string, fn: CustomHandlerCallback): void;
|
|
53
|
+
getComponentHandler(definitionType: string): CustomHandlerCallback | undefined;
|
|
54
|
+
dispose(): void;
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AbstractComponentController } from './component-controller';
|
|
2
|
+
import { ComponentNode } from './component-node';
|
|
3
|
+
import { ComponentPlatform } from './component-platform';
|
|
4
|
+
|
|
5
|
+
export type ComponentQueryRule = {
|
|
6
|
+
id?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class ComponentQuery {
|
|
10
|
+
private platform;
|
|
11
|
+
rules: ComponentQueryRule[];
|
|
12
|
+
constructor(platform: ComponentPlatform, rules?: ComponentQueryRule[]);
|
|
13
|
+
match(node: ComponentNode): boolean;
|
|
14
|
+
ofType(type: string): ComponentQuery;
|
|
15
|
+
withId(id: string): ComponentQuery;
|
|
16
|
+
select(): AbstractComponentController;
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
2
|
+
import { Breakpoints, ComponentSettings, ViewDefinition, WidgetSettings } from '../types';
|
|
3
|
+
import { ComponentNode, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties } from './component-node';
|
|
4
|
+
import { ComponentPlatform } from './component-platform';
|
|
5
|
+
|
|
6
|
+
type ComponentReference = string | [string, ...ComponentReferenceOverride[]];
|
|
7
|
+
type ComponentReferenceOverride = {
|
|
8
|
+
breakpoints?: Breakpoints;
|
|
9
|
+
tags?: string[];
|
|
10
|
+
context?: ComponentNodeContext;
|
|
11
|
+
properties?: ComponentNodeProperties;
|
|
12
|
+
layout?: ComponentNodeLayout;
|
|
13
|
+
};
|
|
14
|
+
export type NormalizedComponentReference = {
|
|
15
|
+
definitionId: string;
|
|
16
|
+
overrides: ComponentReferenceOverride[];
|
|
17
|
+
};
|
|
18
|
+
export declare const normalizeReference: (reference: ComponentReference) => NormalizedComponentReference;
|
|
19
|
+
export type ComponentHandlerOptions = {
|
|
20
|
+
platform: ComponentPlatform;
|
|
21
|
+
node: ComponentNode;
|
|
22
|
+
references: ComponentReference[];
|
|
23
|
+
definitions: {
|
|
24
|
+
[name: string]: ComponentSettings;
|
|
25
|
+
};
|
|
26
|
+
views: {
|
|
27
|
+
[key: string]: ViewDefinition;
|
|
28
|
+
};
|
|
29
|
+
branch?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const createChildren: (platform: ComponentPlatform, node: ComponentNode, references: ComponentReference[], definitions: {
|
|
32
|
+
[name: string]: ComponentSettings;
|
|
33
|
+
}, views: {
|
|
34
|
+
[key: string]: ViewDefinition;
|
|
35
|
+
}, branch?: string) => void;
|
|
36
|
+
export declare const createComponentModel: (platform: ComponentPlatform, settings: WidgetSettings) => EventSubscriptionCancellation;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentReference, ComponentSettings, ViewDefinition } from '../types';
|
|
2
|
+
import { ComponentNode } from './component-node';
|
|
3
|
+
import { ComponentPlatform } from './component-platform';
|
|
4
|
+
import { NormalizedComponentReference } from './create-component-model';
|
|
5
|
+
|
|
6
|
+
export type CustomHandlerCallback = (ref: NormalizedComponentReference, options: {
|
|
7
|
+
platform: ComponentPlatform;
|
|
8
|
+
node: ComponentNode;
|
|
9
|
+
references: ComponentReference[];
|
|
10
|
+
definitions: {
|
|
11
|
+
[name: string]: ComponentSettings;
|
|
12
|
+
};
|
|
13
|
+
views: {
|
|
14
|
+
[key: string]: ViewDefinition;
|
|
15
|
+
};
|
|
16
|
+
branch?: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
export declare class CustomComponentHandler {
|
|
19
|
+
private handlers;
|
|
20
|
+
add(name: string, fn: CustomHandlerCallback): void;
|
|
21
|
+
get(name: string): CustomHandlerCallback | undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
import { ComponentNodeController } from './component-controller';
|
|
3
|
+
import { ComponentQuery } from './component-query';
|
|
4
|
+
|
|
5
|
+
export type ExtendComponentHandler = (controller: ComponentNodeController) => any;
|
|
6
|
+
export type ExtendComponentOptions = {
|
|
7
|
+
reuseController?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const extendComponent: (container: Container, typeOrQuery: string | ComponentQuery, handler: ExtendComponentHandler, ns?: string, options?: ExtendComponentOptions) => Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { ActionsController } from './actions-controller';
|
|
2
|
+
export type { WatchActionDelegate } from './actions-controller';
|
|
3
|
+
export type { ChangesetProvider } from './changeset-provider';
|
|
4
|
+
export { default as componentConfigurationApi } from './component-configuration-api';
|
|
5
|
+
export { AbstractComponentController, ComponentNodeController, } from './component-controller';
|
|
6
|
+
export { ComponentNode } from './component-node';
|
|
7
|
+
export type { ChangesetOptions, ComponentNodeAttributes, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties, ComponentNodeSettings, Size, } from './component-node';
|
|
8
|
+
export { ComponentPlatform } from './component-platform';
|
|
9
|
+
export type { SwitchMap } from './component-platform';
|
|
10
|
+
export { ComponentQuery } from './component-query';
|
|
11
|
+
export type { ComponentQueryRule } from './component-query';
|
|
12
|
+
export { createChildren, createComponentModel } from './create-component-model';
|
|
13
|
+
export type { ComponentHandlerOptions, NormalizedComponentReference, } from './create-component-model';
|
|
14
|
+
export { asDescriptor } from './descriptor';
|
|
15
|
+
export type { ComponentDescriptor } from './descriptor';
|
|
16
|
+
export { extendComponent } from './extend-component';
|
|
17
|
+
export type { ExtendComponentHandler, ExtendComponentOptions, } from './extend-component';
|
|
18
|
+
export { findComponent, findVisibleComponents, traverseComponents, } from './queries';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ComponentNode } from './component-node';
|
|
2
|
+
import { SwitchMap } from './component-platform';
|
|
3
|
+
|
|
4
|
+
export declare const traverseComponents: (root: ComponentNode, switches: SwitchMap, fn: (node: ComponentNode) => boolean | void) => void;
|
|
5
|
+
export declare const findVisibleComponents: (root: ComponentNode, switches: SwitchMap) => ComponentNode[];
|
|
6
|
+
export declare const findComponent: (root: ComponentNode, switches: SwitchMap, fn: (node: ComponentNode) => boolean) => ComponentNode | undefined;
|
|
7
|
+
export declare const getAncestors: (node: ComponentNode) => ComponentNode[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentPlatform } from '.';
|
|
2
|
+
import { ComponentNode } from './component-node';
|
|
3
|
+
|
|
4
|
+
export type ProcessOptions = {
|
|
5
|
+
context?: boolean;
|
|
6
|
+
properties?: boolean;
|
|
7
|
+
layout?: boolean;
|
|
8
|
+
recursive?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type StateProcessor = (node: ComponentNode, options: ProcessOptions) => void;
|
|
11
|
+
export type ProcessResult = Map<ComponentNode, ProcessOptions>;
|
|
12
|
+
export type ProcessReportCallback = (report: ProcessResult) => void;
|
|
13
|
+
export declare const createStateProcessor: (platform: ComponentPlatform, callback: ProcessReportCallback) => StateProcessor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Logger } from '../../utilities/src/index.ts';
|
|
2
|
+
import { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
3
|
+
|
|
4
|
+
export type ReactComponent = any | null;
|
|
5
|
+
export default class ComponentResolver {
|
|
6
|
+
aliases: Map<string, string>;
|
|
7
|
+
components: Map<string, any>;
|
|
8
|
+
events: EventManager;
|
|
9
|
+
logger: Logger;
|
|
10
|
+
constructor(container: Container);
|
|
11
|
+
getComponent(key: string): ReactComponent;
|
|
12
|
+
registerComponent(key: string, component: ReactComponent): EventSubscriptionCancellation;
|
|
13
|
+
registerResolver(key: string, fn: (component: ReactComponent) => void): EventSubscriptionCancellation;
|
|
14
|
+
registerAlias(alias: string, key: string): EventSubscriptionCancellation;
|
|
15
|
+
}
|
package/environment.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BootstrappedImplementationConfiguration } from '@webprovisions/bootstrapping';
|
|
2
|
+
import { ConfigurationApiDefinition, Environment as EnvironmentBase, WidgetSelector } from '@webprovisions/platform';
|
|
3
|
+
import { default as Implementation } from './implementation';
|
|
4
|
+
|
|
5
|
+
export interface RuntimeConfiguration {
|
|
6
|
+
/**
|
|
7
|
+
* Extensions for the configuration API (optional).
|
|
8
|
+
*/
|
|
9
|
+
configurationApiExtensions?: ConfigurationApiDefinition[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The widget runtime.
|
|
13
|
+
*/
|
|
14
|
+
export default class Environment extends EnvironmentBase {
|
|
15
|
+
/**
|
|
16
|
+
* Version of the widget runtime.
|
|
17
|
+
*/
|
|
18
|
+
static version: string;
|
|
19
|
+
constructor(name: string, configurationApiExtensions?: ConfigurationApiDefinition[]);
|
|
20
|
+
createImplementation(configuration: BootstrappedImplementationConfiguration): Implementation;
|
|
21
|
+
/**
|
|
22
|
+
* Performs navigation for widgets matching the specified selector by invoking a
|
|
23
|
+
* 'navigate' command.
|
|
24
|
+
* @param selector Widget selector matching the widget(s) to perform navigation on.
|
|
25
|
+
* @param route Route name.
|
|
26
|
+
* @param params Route params.
|
|
27
|
+
*/
|
|
28
|
+
navigate(selector: WidgetSelector, route: string, params: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
}): void;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a runtime based on provided configuration.
|
|
33
|
+
* @param configuration Runtime configuration.
|
|
34
|
+
*/
|
|
35
|
+
static create(configuration?: RuntimeConfiguration): Environment;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a widget runtime based on provided configuration and retains configuration handlers
|
|
38
|
+
* registered on global context. Use this factory to fully support the default embed script.
|
|
39
|
+
* Will return any existing widget runtime if available.
|
|
40
|
+
* @param configuration Runtime configuration.
|
|
41
|
+
* @param global Object to read configuration handlers from (default: window).
|
|
42
|
+
*/
|
|
43
|
+
static createFromGlobal(globalInstance: any, configuration?: RuntimeConfiguration): Environment;
|
|
44
|
+
/**
|
|
45
|
+
* Determines whether the specified object is a valid widget runtime.
|
|
46
|
+
* @param obj Object to compare.
|
|
47
|
+
*/
|
|
48
|
+
static isRuntime(obj: any): boolean;
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventListener, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
2
|
+
|
|
3
|
+
export type SubscribeDelegate = (type: string, listener: EventListener) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Creates s subscriber for the specified `EventManager` and provides a single cancellation
|
|
6
|
+
* function for all registered subscriptions.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createEventSubscriber: (events: EventManager) => [SubscribeDelegate, EventSubscriptionCancellation];
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as ActionResolver } from './action-resolver';
|
|
2
|
+
export { default as bootstrap } from './bootstrap';
|
|
3
|
+
export { ActionsController, asDescriptor, componentConfigurationApi, ComponentNode, ComponentNodeController, ComponentPlatform, ComponentQuery, createChildren, createComponentModel, extendComponent, findComponent, findVisibleComponents, traverseComponents, } from './component-platform';
|
|
4
|
+
export type { ChangesetOptions, ChangesetProvider, ComponentDescriptor, ComponentHandlerOptions, ComponentNodeAttributes, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties, ComponentNodeSettings, ComponentQueryRule, ExtendComponentHandler, ExtendComponentOptions, NormalizedComponentReference, Size, SwitchMap, WatchActionDelegate, } from './component-platform';
|
|
5
|
+
export { default as ComponentResolver } from './component-resolver';
|
|
6
|
+
export type { ReactComponent } from './component-resolver';
|
|
7
|
+
export { default as Environment } from './environment';
|
|
8
|
+
export { createEventSubscriber } from './event-subscriber';
|
|
9
|
+
export type { SubscribeDelegate } from './event-subscriber';
|
|
10
|
+
export { default as Implementation } from './implementation';
|
|
11
|
+
export { default as Plugin } from './plugin';
|
|
12
|
+
export * from './types';
|
|
13
|
+
export { default as version } from './version';
|
|
14
|
+
export { default as WidgetType } from './widget-type';
|
package/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@webprovisions/bootstrapping"),b=require("@webprovisions/platform"),g=require("@telia-ace/widget-utilities");class Q{constructor(t){const{events:e}=t.get("$widget");this.events=e.createChild(this)}action(t,e,s){this.events.dispatch("data:action",{action:e,value:s,target:t},{bubbles:!0})}subscribe(t,e){return this.events.subscribe("data:action",(s,{action:i,value:c,target:o})=>t===o&&e(t,i,c))}}const z=(n,t,e={})=>$.bootstrapImplementation(n,n.bindings,()=>{const s=n.container.get("$runtimecfg").map(i=>{const c=i[0];if(typeof c=="function")return c;if(b.selectImplementations(c)(n))return i[1]}).filter(i=>!!i);return(t?[t]:[]).concat(s)},e.rootElementResolver||(()=>document.body)),L=n=>{const t=[];return[(s,i)=>{t.push(n.subscribe(s,i))},()=>{t.forEach(s=>{s()})}]};class E{constructor(t,e=[]){this.platform=t,this.rules=e}match(t){return this.rules.every(e=>!(e.id&&e.id!==t.id||e.type&&e.type!==t.type))}ofType(t){return this.rules.push({type:t}),this}withId(t){return this.rules.push({id:t}),this}select(){return new U(this.platform,this)}}class A{constructor(t,e,s){this.platform=t,this.node=e,this.actions=new O(t,new E(t).withId(e.id),s);const[i,c]=L(this.platform.events);this.subscribe=i,this.unsubscribe=c}properties(t){return t&&this.node.touchProperties(e=>t(e)),this.node.attributes.properties}context(t){return t&&this.subscribe("components:context-changed",(e,{node:s})=>{s===this.node&&t(this.node.attributes.context)}),this.node.attributes.context}layout(t){return t&&this.subscribe("components:layout-changed",(e,{node:s})=>{s===this.node&&t(this.node.attributes.layout)}),this.node.attributes.layout}writeProperties(t,e){this.node.writeProperties(t,e)}writeContext(t,e){this.node.writeProperties(t,e)}writeLayout(t,e){this.node.writeLayout(t,e)}dispose(){this.unsubscribe(),this.actions.dispose()}}class U{constructor(t,e,s=!0){this.platform=t,this.target=e,this.clearOnDispose=s,this.removes=[],this.actions=new O(this.platform,this.target)}writeProperties(t,e){this.removes.push(this.platform.write({options:e,attributes:{properties:t},target:this.target,removable:this.clearOnDispose}))}writeContext(t,e){this.removes.push(this.platform.write({options:e,attributes:{context:t},target:this.target,removable:this.clearOnDispose}))}writeLayout(t,e){this.removes.push(this.platform.write({options:e,attributes:{layout:t},target:this.target,removable:this.clearOnDispose}))}dispose(){this.removes.forEach(t=>{t()}),this.actions.dispose()}}const W=(n,t,e)=>{const s=n.concat(),i=(c,o,a)=>{let u=!0;if(s.length){const h=s.shift(),r=(p,l)=>(u=!1,i(p,Object.assign({},o,l),a));return Promise.resolve(h(c,r,a)).then(p=>({...p,cancelled:u}))}return Promise.resolve({data:c,cancelled:!1,options:o})};return i(t,{},e)};class O{constructor(t,e,s){this.platform=t,this.target=e,this.ns=s,this.subscriptions=[],this.create=this.create.bind(this)}create(t,e=()=>{}){const s={key:t,fn:e,target:this.target,ns:this.ns};this.platform.actionsState.handlers.push(s);const i=()=>{const c=this.platform.actionsState.handlers.indexOf(s);c>-1&&this.platform.actionsState.handlers.splice(c,1)};return this.subscriptions.push(i),i}dispatch(t,e){const s=this.platform.nodes.all.concat(this.platform.nodes.detached),i={},c=this.platform.actionsState.handlers.filter(o=>o.key===t&&(!o.ns||!this.ns||o.ns===this.ns));return Promise.all(c.map(o=>{const a=s.filter(h=>o.target.match(h)&&this.target.match(h)),u=this.platform.actionsState.watchers.filter(h=>h.key===t&&(!h.ns||!this.ns||h.ns===this.ns)&&a.some(r=>h.target.match(r))).map(h=>h.fn);return Promise.all(a.map(h=>{const r=new A(this.platform,h,this.ns);return W(u,e,r).then(p=>{const{data:l={},options:d,cancelled:y}=p;return Promise.resolve(y?{}:o.fn(l,d,r)).then(x=>{i[h.id]=x})})}))})).then(()=>i)}watch(t,e){let s=t,i=this.ns;const c=t.split(".");c.length>1&&(i=c[0],s=c.splice(1).join("."));const o={fn:e,target:this.target,key:s,ns:i};this.platform.actionsState.watchers.push(o);const a=()=>{const u=this.platform.actionsState.watchers.indexOf(o);u>-1&&this.platform.actionsState.watchers.splice(u,1)};return this.subscriptions.push(a),a}dispose(){this.subscriptions.forEach(t=>t())}}const F=b.createConfigurationApi(n=>{n.createCommand("components",t=>e=>{t.events.subscribeOnce("components:platform-created",(s,{platform:i})=>{e.handlers&&e.handlers.forEach(([c,o])=>{i.addComponentHandler(c,o)})})})});class R{constructor(t,e){this.events=t,this.tags=[],this.children={},this.changesets=[],this.mountCount=0,this.id=g.uuid(),this.type=e,this.attributes={context:{},properties:{},layout:{},tags:[]},this.writeLayout({size:"full",indent:0})}mount(t,e){let s=t.get("mounted-nodes");return s||(s=new Map,t.register("mounted-nodes",s)),s.has(this)?(process.env.NODE_ENV!=="production"&&g.Logger.error("Trying to mount an already mounted component node.",this),()=>{}):(this.events.dispatch("components:node-mounted",{node:this}),this.mountCount===0&&(this.mountCount=this.mountCount+1,this.events.dispatch("components:node-enter",{node:this})),()=>{s.delete(this),this.events.dispatch("components:node-unmounted",{node:this}),this.mountCount=this.mountCount-1,this.mountCount===0&&this.events.dispatch("components:node-exit",{node:this})})}appendChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].push(t),this.events.dispatch("components:node-appended",{node:t})}prependChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].unshift(t),this.events.dispatch("components:node-appended",{node:t})}touchProperties(t,e={},s){const c=[{properties:t},e];return this.changesets.push(c),this.events.dispatch("components:set-properties",{node:this}),()=>{if(s){const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeProperties(t,e={},s){const c=[{properties:t},e];return this.changesets.push(c),this.events.dispatch("components:set-properties",{node:this}),()=>{if(s){const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeLayout(t,e={},s){const c=[{layout:t},e];return this.changesets.push(c),this.events.dispatch("components:set-layout",{node:this}),()=>{if(!s)return;const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-layout",{node:this}))}}writeContext(t,e={},s){const c=[{context:t},e];return this.changesets.push(c),this.events.dispatch("components:set-context",{node:this}),()=>{if(!s)return;const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-context",{node:this}))}}getChildren(t="default"){const e=this.children[t]||[];return e.reduce((s,i,c)=>{const{order:o=c}=i.attributes.layout;return s[o]?s.splice(o,0,i):s[o]=i,s},Array(e.length))}remove(){this.parent&&this.parent.removeChild(this)}removeChild(t){Object.keys(this.children).forEach(e=>{const s=this.children[e],i=s.indexOf(t);i>-1&&(s.splice(i,1),this.events.dispatch("components:node-removed",{node:t,parentNode:this}))}),delete t.parent}}const _=(n,t,e)=>{for(let s=0,i=n.length;s<i&&e(n[s])!==!0;s++){const c=t[n[s].id]||"default",o=n[s].getChildren(c);_(o,t,e)}},N=(n,t,e)=>{if(e(n)!==!0){const s=t[n.id]||"default",i=n.children[s];_(i,t,e)}},C=(n,t)=>{const e=[];return N(n,t,s=>{e.push(s)}),e},H=(n,t,e)=>{let s;return N(n,t,i=>{if(e(i))return s=i,!0}),s};class G{constructor(t,e,s){this.root=t,this.switches=e,this.all=[],this.visible=[],this.detached=[],s.subscribe("components:node-appended",(i,c)=>{this.all.push(c.node),this.visible=C(t,e)}),s.subscribe("components:node-removed",(i,c)=>{let o=this.all.indexOf(c.node);o>-1&&this.all.splice(o,1),o=this.visible.indexOf(c.node),o>-1&&this.visible.splice(o,1),this.visible=C(t,e)}),s.subscribe("components:node-switched",(i,c)=>{this.visible=C(t,e)})}query(t={}){const e=[];return N(this.root,this.switches,s=>{Object.keys(t).every(c=>t[c]===s[c])&&e.push(s)}),e}get(t){return H(this.root,this.switches,e=>e.id===t)||this.detached.find(e=>e.id===t)}}class K{constructor(){this.handlers=new Map}add(t,e){this.handlers.set(t,e)}get(t){return this.handlers.get(t)}}const Y=n=>{let t=n,e=0;for(;t.parent;)e=e+1,t=t.parent;return e},J=n=>n.map(([e,s])=>[Y(e),e,s]).sort(([e],[s])=>e-s).map(([,e,s])=>[e,s]),k=n=>n instanceof Date?!1:n&&typeof n=="object"&&!Array.isArray(n),v=(n,...t)=>{if(!t.length)return n;const e=t.shift();if(k(n)&&k(e))for(const s in e)k(e[s])?(n[s]||Object.assign(n,{[s]:{}}),v(n[s],e[s])):Object.assign(n,{[s]:e[s]});return v(n,...t)},X=(n,t)=>!n||n==="all"?!0:n.some(e=>t.indexOf(e)>-1),Z=(n,t)=>{let e=[],s=[],i;const c=()=>{process.env.NODE_ENV!=="production"&&console.time("state-processor.flush");const a=new Map,u=J(e.map((r,p)=>[r,s[p]])),h=(r,p)=>{var I;const l=a.get(r)||{},d=p.context&&!l.context,y=p.properties&&!l.properties,x=p.layout&&!l.layout;a.set(r,{context:l.context||d,properties:l.properties||y,layout:l.layout||x}),y&&(r.attributes.properties={}),x&&(r.attributes.layout={}),d&&(r.attributes.context=v({},(I=r.parent)==null?void 0:I.attributes.context));const S=[],T=[],D=[];if(r.changesets.forEach(f=>{const[m,P]=f;X(P.breakpoints,n.breakpoints)&&(y&&(typeof m.properties=="function"?S.push(m.properties):v(r.attributes.properties,m.properties)),x&&(typeof m.layout=="function"?T.push(m.layout):v(r.attributes.layout,m.layout)),d&&(typeof m.context=="function"?D.push(m.context):v(r.attributes.context,m.context)))}),S.forEach(f=>{v(r.attributes.properties,f(r.attributes.properties))}),T.forEach(f=>{v(r.attributes.layout,f(r.attributes.layout))}),D.forEach(f=>{v(r.attributes.context,f(r.attributes.context))}),d||p.recursive){const f=n.getBranch(r),m=p.recursive?p:{context:!!d};r.getChildren(f).forEach(P=>{h(P,m)})}};process.env.NODE_ENV!=="production"&&console.timeEnd("state-processor.flush"),u.forEach(([r,p])=>{h(r,p)}),e=[],s=[],t(a)},o=()=>{clearTimeout(i),i=setTimeout(c,0)};return(a,u)=>{const h=e.indexOf(a);if(h>-1){const r=s[h];return u.context&&(r.context=!0),u.properties&&(r.properties=!0),u.layout&&(r.layout=!0),u.recursive&&(r.recursive=!0),o()}return e.push(a),s.push(u),o()}};class M{constructor(t,e={}){this.providers=e,this.breakpoints=[],this.actionsState={handlers:[],watchers:[]},this.switches={},this.changesets=[],this.subscriptions=[],this.customComponentHandler=new K,this.events=t.events.createChild(this);const s=new R(this.events,"root");s.name=`root-${t.name}`,this.nodes=new G(s,this.switches,this.events);const i=this.processNode=Z(this,c=>{const o=Array.from(c.keys());process.env.NODE_ENV!=="production"&&console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
|
|
2
|
+
${o.map(a=>`${a.name||"<no name>"} (${a.id})
|
|
3
|
+
`)}`),o.forEach(a=>{const u=c.get(a);a.parent&&a.parent.type==="root"&&this.events.dispatch("components:root-children-changed",{node:a}),u!=null&&u.context&&this.events.dispatch("components:context-changed",{node:a}),u!=null&&u.properties&&this.events.dispatch("components:properties-changed",{node:a}),u!=null&&u.layout&&this.events.dispatch("components:layout-changed",{node:a})}),this.events.dispatch("components:component-model-initialized",{},{bubbles:!0})});Promise.all(Object.keys(e).map(c=>e[c].load(this))),this.subscriptions.push(this.events.subscribe("components:node-appended",(c,o)=>{const{node:a}=o;this.changesets.forEach(u=>{const{changeset:h,target:r,removes:p}=u,[l,d]=h;r.match(o.node)&&(l.properties&&p.push(a.writeProperties(l.properties,d)),l.context&&p.push(a.writeContext(l.context,d)),l.layout&&p.push(a.writeLayout(l.layout,d)))})})),this.subscriptions.push(this.events.subscribe("components:node-appended",(c,o)=>{i(o.node,{properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:set-properties",(c,o)=>{i(o.node,{properties:!0})})),this.subscriptions.push(this.events.subscribe("components:set-context",(c,o)=>{i(o.node,{properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:set-indent",(c,o)=>{i(o.node,{layout:!0})})),this.subscriptions.push(this.events.subscribe("components:set-layout",(c,o)=>{i(o.node,{layout:!0})})),this.subscriptions.push(this.events.subscribe("components:node-switched",(c,{node:o,branch:a})=>{i(o,{layout:!0,recursive:!0,properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:node-removed",(c,{parentNode:o})=>{i(o,{properties:!0})})),this.events.parent&&this.events.parent.dispatch("components:platform-created",{platform:this})}static getInstance(t){return t.getAsync("components")}addBreakpoint(t){this.breakpoints.indexOf(t)===-1&&(this.breakpoints.push(t),this.processNode(this.nodes.root,{context:!0,properties:!0,layout:!0,recursive:!0}))}removeBreakpoint(t){const e=this.breakpoints.indexOf(t);e>-1&&(this.breakpoints.splice(e,1),this.processNode(this.nodes.root,{context:!0,properties:!0,layout:!0,recursive:!0}))}setSwitch(t,e){this.switches[t.id]=e,this.events.dispatch("components:node-switched",{node:t,branch:e})}getBranch(t){return this.switches[t.id]}createNode(t,e={}){const s=new R(this.events,t);return e.detached&&this.nodes.detached.push(s),s}components(){return new E(this)}actions(t,e){return new O(this,t,e)}write(t){const{provider:e,target:s,attributes:i,options:c={},removable:o}=t,a=t.key||g.uuid(),h={changeset:[i,c],target:s,removes:[]};if(e){const r=this.providers[e];r.write(a,s,i,c),h.removes.push(()=>{r.remove(a)})}return this.changesets.push(h),this.nodes.all.forEach(r=>{if(s.match(r)){let p=()=>{};i.properties&&(p=r.writeProperties(i.properties,c,o)),i.context&&(p=r.writeContext(i.context,c,o)),i.layout&&(p=r.writeContext(i.layout,c,o)),h.removes.push(p)}}),()=>{if(o){h.removes.forEach(p=>p());const r=this.changesets.indexOf(h);r>-1&&this.changesets.splice(r,1)}}}addComponentHandler(t,e){this.customComponentHandler.add(t,e)}getComponentHandler(t){return this.customComponentHandler.get(t)}dispose(){this.subscriptions.forEach(t=>t())}}const tt=n=>{if(Array.isArray(n)){const[t,...e]=n;return{definitionId:t,overrides:e}}return{definitionId:n,overrides:[]}},w=(n,t,e,s,i,c)=>{e.forEach(o=>{const a=tt(o),u=s[a.definitionId];if(a.definitionId==="view"){const h=n.createNode("view");h.name="view",Object.keys(i).forEach(r=>{const p=i[r];w(n,h,[p.entry],s,i,r)}),t.appendChild(h),a.overrides.forEach(r=>{r.properties&&h.writeProperties(r.properties,{breakpoints:r.breakpoints}),r.context&&h.writeContext(r.context,{breakpoints:r.breakpoints}),r.layout&&h.writeLayout(r.layout,{breakpoints:r.breakpoints})})}else if(n.getComponentHandler(u.type)){const h=n.getComponentHandler(u.type);h&&h(a,{platform:n,node:t,references:e,definitions:s,views:i,branch:c})}else{const h=s[a.definitionId];if(process.env.NODE_ENV!=="production"&&!h){g.Logger.error(`No definition found for component type '${a.definitionId}'.`);return}const r=n.createNode(h.type);r.name=a.definitionId,r.tags=h.tags||[],h.properties&&r.writeProperties(h.properties),h.context&&r.writeContext(h.context),h.layout&&r.writeLayout(h.layout),t.appendChild(r,c),a.overrides.forEach(p=>{const l={breakpoints:p.breakpoints};p.properties&&r.writeProperties(p.properties,l),p.context&&r.writeContext(p.context,l),p.layout&&r.writeLayout(p.layout,l)}),h.children&&w(n,r,h.children,s,i)}})},et=(n,t)=>{const{entry:e,components:s,breakpoints:i,views:c}=t,o=[];return Object.keys(i).forEach(a=>{const u=i[a],h=window.matchMedia(u);h.matches&&n.breakpoints.push(a);const r=p=>{p.matches?n.addBreakpoint(a):n.removeBreakpoint(a)};h.addListener(r),o.push(()=>h.removeListener(r))}),w(n,n.nodes.root,[e],s,c),()=>o.forEach(a=>{a()})},st=(n,t)=>({id:n.id,type:n.type,name:n.name,branch:t||"default"}),nt=(n,t,e,s=g.uuid(),i={})=>n.getAsync("components").then(c=>{let o;if(typeof t=="string"){const h=new E(c);h.ofType(t),o=h}else o=t;const a={},u=h=>{const r=a[h.id];return r?Promise.resolve(r.controller):M.getInstance(n).then(p=>new A(p,h,s))};c.events.subscribe("components:node-enter",(h,{node:r})=>{o.match(r)&&u(r).then(p=>{Promise.resolve(e(p)).then(l=>{a[r.id]={dispose:l,controller:p}})})}),c.events.subscribe("components:node-exit",(h,{node:r})=>{const p=a[r.id];p&&(p.dispose&&p.dispose(),i.reuseController||(p.controller.dispose(),delete a[r.id]))})});class it{constructor(t){this.aliases=new Map,this.components=new Map,this.logger=new g.Logger;const{events:e}=t.get("$widget");this.events=e}getComponent(t){const e=this.aliases.get(t),s=this.components.get(e||t)||null;return process.env.NODE_ENV!=="production"&&(s||this.logger.warn(e||t,`Unable to resolve component: "${e||t}". You most likely forgot to register the required plugin for: ${e||t}.`)),s}registerComponent(t,e){return this.components.set(t,e),this.events.dispatch("component-resolver:resolve",t),()=>{this.components.delete(t)}}registerResolver(t,e){return this.events.subscribe("component-resolver:resolve",(s,i)=>{if(i===t){const c=this.getComponent(t);e(c)}})}registerAlias(t,e){return this.aliases.set(t,e),this.events.dispatch("component-resolver:resolve",t),()=>{this.aliases.delete(t)}}}const V="#____version____#",B=class j extends b.Environment{constructor(t,e=[]){super(t,e,{transformPluginSettings:(s,i,c)=>{const o=c.get("$settings");return{...o.plugins&&i?o.plugins[i]||{}:{},...s}}})}createImplementation(t){const e=super.createImplementation(t);return e.bindings=t.bindings,e}navigate(t,e,s){this.widgets.query(t).forEach(i=>i.invoke("navigate",{route:e,params:s}))}static create(t={}){const e=[$.ConfigurationApi].concat(t.configurationApiExtensions||[]);return new j("humany",e)}static createFromGlobal(t,e={}){if(this.isRuntime(t))return t.patch(e),t;const s=[],i=t&&t._c;i&&i.forEach(o=>s.push(o));const c=this.create(e);return c.container.register("$runtimecfg",s),c}static isRuntime(t){return!!(t&&typeof t=="object"&&t.container&&typeof t.container.get=="function"&&t.container.get("$environment")===t&&t.container.owner===t)}};B.version=`${V} (${b.version})`;let ot=B;class rt extends b.Implementation{constructor(){super(...arguments),this.bindings=[]}}class ct extends b.Plugin{constructor(t,e){super(t,e)}}var q=(n=>(n.open="open",n.closed="closed",n.hidden="hidden",n))(q||{});class ht extends b.WidgetType{constructor(t){super(t)}}exports.ActionResolver=Q;exports.ActionsController=O;exports.ComponentNode=R;exports.ComponentNodeController=A;exports.ComponentPlatform=M;exports.ComponentQuery=E;exports.ComponentResolver=it;exports.Environment=ot;exports.Implementation=rt;exports.Plugin=ct;exports.WidgetRenderState=q;exports.WidgetType=ht;exports.asDescriptor=st;exports.bootstrap=z;exports.componentConfigurationApi=F;exports.createChildren=w;exports.createComponentModel=et;exports.createEventSubscriber=L;exports.extendComponent=nt;exports.findComponent=H;exports.findVisibleComponents=C;exports.traverseComponents=N;exports.version=V;
|