@acoustic-content-sdk/component-utils 中文文档教程
框架独立的实用功能集合,用于接下来为网站实施服务和组件。
Table of Contents
@acoustic-content-sdk/component-utils
component-utils package
框架独立的实用功能集合,用于接下来为网站实施服务和组件。
Classes
Class | Description |
---|---|
AbstractComponentResolverService | Base class for component type resolvers |
AbstractComponentsService | |
AbstractDeliverySearchResolverService | |
AbstractLayoutMappingResolver | |
AbstractLayoutResolverService | |
AbstractProtectedContentService | Service to tell whether or not to serve protected content |
AbstractRenderingContextResolverService | Implementation of a service that resolves the outbound parts of a rendering context |
AbstractWchPageService |
Functions
Function | Description |
---|---|
assertSameOrigin(aLeft, aRight, aLogSvc) | Validates that the origin of both windows is the same, otherwise throws an exception |
createLayoutComponentDecorator(aComponentConsumer, aLayoutMappingConsumer) | Layout decorator and metadata. |
createLayoutMappingDecorator(aLayoutMappingConsumer) | Constructs the laout mapping decorator. Will callback the given function with the decorated object |
getEditHostWindow(aCurrentWindow) | Returns the window that controls the application. This is either the parent window or the opener window. |
Interfaces
Interface | Description |
---|---|
AbstractRegisteredComponent | |
AbstractRegisteredLayoutMapping |
Variables
Variable | Description |
---|---|
DEFAULT_LAYOUT_ID | name of the default layout |
PAGE_NOT_FOUND_LAYOUT_ID | |
selectId | |
selectIdFromRenderingContext | |
selectMetadata | |
VERSION | Version and build number of the package |
Type Aliases
Type Alias | Description |
---|---|
SendRequest |
Home > @acoustic-content-sdk/component-utils > AbstractComponentResolverService
AbstractComponentResolverService class
Base class for component type resolvers
Signature:
export declare class AbstractComponentResolverService<TYPE> implements AbstractComponentResolver<TYPE>
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aComponentsService, aLayoutResolverService, aLayoutMappingService, aComponentTypeRefResolvers, aLogSvc) | Constructs a new instance of the AbstractComponentResolverService class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
resolveComponent | (aRenderingContext: RenderingContextV2, aLayoutMode?: string) => Observable<TYPE> |
首页 > @acoustic-content-sdk/component-utils > AbstractComponentsService
AbstractComponentsService class
Signature:
export declare class AbstractComponentsService<TYPE> implements AbstractComponentsRegistry<TYPE>
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aDefaultComponent, aPredicate, aLogSvc) | Initializes our constructor. We make sure to keep all private instance variables as part of the closure and override the methods on the instance level. Since this is a singleton service, that approach does not cause a performance problem. |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
getTypeByLayout | (aLayout: Layout, aLayoutMode?: string) => Observable<TYPE> |
Returns the type object based on the layout configuration | |
getTypeBySelector | (aSelector: string, aLayoutMode?: string) => Observable<TYPE> |
Returns the type object based on the layout selector | |
registerType | (aController: string | string[], aType: TYPE, aLayoutModes?: string | string[]) => void |
define the methods |
Home > ; @acoustic-content-sdk/component-utils > AbstractDeliverySearchResolverService
AbstractDeliverySearchResolverService class
Signature:
export declare class AbstractDeliverySearchResolverService implements DeliverySearchResolver
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aFetchText, aProtected, aSeedResolver, aLogSvc) | Constructs a new instance of the AbstractDeliverySearchResolverService class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
getDeliverySearchResults | <T>(aQuery: QueryInput, aClassification: string) => Observable<SearchResults<T>> |
Home > ; @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver
AbstractLayoutMappingResolver class
Signature:
export declare class AbstractLayoutMappingResolver implements LayoutMappingResolver
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)() | Constructs a new instance of the AbstractLayoutMappingResolver class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
getSelector | (aLayoutMode: string, aRenderingContext: RenderingContextV2) => string | undefined |
Returns the layout selector based on the rendering context | |
registerMapping | (aId: string | string[], aSelector: string | string[], aLayoutMode?: string | string[]) => void |
Registers a layout mapping |
Home > ; @acoustic-content-sdk/component-utils > AbstractLayoutResolverService
AbstractLayoutResolverService class
Signature:
export declare class AbstractLayoutResolverService implements LayoutResolver
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aDeliveryTypeResolver, aDeliveryLayoutMappingResolver, aDeliveryLayoutResolver, aLogSvc) | Constructs a new instance of the AbstractLayoutResolverService class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
resolveLayout | (aLayoutMode: string, aRenderingContext: RenderingContextV2) => Observable<Layout> |
Home > ; @acoustic-content-sdk/component-utils > AbstractProtectedContentService
AbstractProtectedContentService class
Service to tell whether or not to serve protected content
Signature:
export declare class AbstractProtectedContentService implements ProtectedContent
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aUrlConfig$, aAuthStatus, aLogSvc) | Constructs a new instance of the AbstractProtectedContentService class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
protected$ | Observable<boolean> |
主页 > @acoustic-content-sdk/component-utils > AbstractRenderingContextResolverService
AbstractRenderingContextResolverService class
Implementation of a service that resolves the outbound parts of a rendering context
Signature:
export declare class AbstractRenderingContextResolverService implements RenderingContextResolver
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aDeliveryContentResolver, aLogSvc) | Constructs a new instance of the AbstractRenderingContextResolverService class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
resolveRenderingContext | (aItem: RenderingContextInput, aProvider: RenderingContextProviderV2) => Observable<RenderingContextV2> |
主页 > @acoustic-content-sdk/component-utils > AbstractWchPageService
AbstractWchPageService class
Signature:
export declare class AbstractWchPageService implements WchPageService
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(aDeliveryPageResolver, aUrlConfig$, aLogSvc) | Constructs a new instance of the AbstractWchPageService class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
getRenderingContextByPath | (aPath: string) => Observable<RenderingContextV2 | null | undefined> |
Resolves the rendering context given the path |
Home > ; @acoustic-content-sdk/component-utils > assertSameOrigin
assertSameOrigin() function
验证两个窗口的来源是否相同,否则抛出异常
签名:
export declare function assertSameOrigin(aLeft: WindowType, aRight: WindowType, aLogSvc?: LoggerService): void;
Parameters
Parameter | Type | Description |
---|---|---|
aLeft | WindowType |
left window to check |
aRight | WindowType |
right window to check |
aLogSvc | LoggerService |
optionally the logger service |
返回:
void
主页 @acoustic-content-sdk/component-utils > createLayoutComponentDecorator
createLayoutComponentDecorator() function
布局装饰器和元数据。
签名:
export declare function createLayoutComponentDecorator<TYPE, DIRECTIVE extends AbstractLayoutComponentDirective>(aComponentConsumer: BiConsumer<TYPE, AbstractRegisteredComponent<TYPE, DIRECTIVE>>, aLayoutMappingConsumer: BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>>): <T extends TYPE>(aDirective?: DIRECTIVE) => (cls: T) => void;
Parameters
Parameter | Type | Description |
---|---|---|
aComponentConsumer | BiConsumer<TYPE, AbstractRegisteredComponent<TYPE, DIRECTIVE>> |
|
aLayoutMappingConsumer | BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>> |
返回:
Home > @acoustic-content-sdk/component-utils > createLayoutMappingDecorator
createLayoutMappingDecorator() function
构造布局映射装饰器。 将使用装饰对象回调给定函数
Signature:
export declare function createLayoutMappingDecorator<TYPE>(aLayoutMappingConsumer: BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>>): <T extends TYPE>(aID: string | string[] | LayoutMappingDirective, aSelector?: string | string[] | TYPE, aLayoutMode?: string | string[]) => (cls: T) => void;
Parameters
Parameter | Type | Description |
---|---|---|
aLayoutMappingConsumer | BiConsumer<TYPE, AbstractRegisteredLayoutMapping<TYPE>> |
Returns:
@acoustic-content-sdk/component-utils > getEditHostWindow
getEditHostWindow() function
返回控制应用程序的窗口。 这是父窗口或开启者窗口。
Signature:
export declare function getEditHostWindow(aCurrentWindow: WindowType): WindowType;
Parameters
Parameter | Type | Description |
---|---|---|
aCurrentWindow | WindowType |
the current window |
Returns:
WindowType
the controlling window
首页 > @acoustic-content-sdk/component-utils > AbstractRegisteredComponent
AbstractRegisteredComponent interface
Signature:
export interface AbstractRegisteredComponent<TYPE, DIRECTIVE extends AbstractLayoutComponentDirective>
Properties
Property | Type | Description |
---|---|---|
directive | DIRECTIVE |
|
type | TYPE |
Home > ; @acoustic-content-sdk/component-utils > AbstractRegisteredLayoutMapping
AbstractRegisteredLayoutMapping interface
Signature:
export interface AbstractRegisteredLayoutMapping<TYPE>
Properties
Property | Type | Description |
---|---|---|
id | string | string[] |
Type IDs or content IDs to map this to |
kind | CONTENT_ITEM_KIND | CONTENT_ITEM_KIND[] |
Type IDs to map this to |
layoutMode | string | string[] |
An optional layout mode used with this layout mapping. |
selector | string | string[] | TYPE |
Defines the mapping between the layout controller to the layout implementation. If this property is missing, the selector of the component will be used instead. |
Home > ; @acoustic-content-sdk/component-utils > DEFAULT_LAYOUT_ID
DEFAULT_LAYOUT_ID variable
name of the default layout
Signature:
DEFAULT_LAYOUT_ID = "wch-default-layout"
Home > @acoustic-content-sdk/component-utils > PAGE_NOT_FOUND_LAYOUT_ID
PAGE_NOT_FOUND_LAYOUT_ID variable
Signature:
PAGE_NOT_FOUND_LAYOUT_ID = "wch-404"
Home > ; @acoustic-content-sdk/component-utils > selectId
selectId variable
Signature:
selectId: import("rxjs").UnaryFunction<any, any>
Home > ; @acoustic-content-sdk/component-utils > selectIdFromRenderingContext
selectIdFromRenderingContext variable
Signature:
selectIdFromRenderingContext: import("rxjs").UnaryFunction<any, string>
Home > ; @acoustic-content-sdk/component-utils > selectMetadata
selectMetadata variable
Signature:
selectMetadata: import("rxjs").UnaryFunction<DeliveryReferenceElement | DeliveryContentItem | DeliveryGroupElement | RenderingContextV2, import("@acoustic-content-sdk/api").DeliveryGroupElementMetadata | import("@acoustic-content-sdk/api").DeliveryReferenceElementMetadata | import("@acoustic-content-sdk/api").DeliveryContentMetadata>
Home > ; @acoustic-content-sdk/component-utils > VERSION
VERSION variable
Version and build number of the package
Signature:
VERSION: {
version: {
major: string;
minor: string;
patch: string;
branch: string;
};
build: Date;
}
首页 > @acoustic-content-sdk/component-utils > SendRequest
SendRequest type
Signature:
export declare type SendRequest = <T>(aUrl: string, aCredentials: boolean) => Observable<T>;
Home > ; @acoustic-content-sdk/component-utils > AbstractComponentResolverService > (constructor)
AbstractComponentResolverService.(constructor)
Constructs a new instance of the AbstractComponentResolverService
class
Signature:
protected constructor(aComponentsService: AbstractComponentsService<TYPE>, aLayoutResolverService: LayoutResolver, aLayoutMappingService: LayoutMappingResolver, aComponentTypeRefResolvers?: AbstractComponentTypeRefResolver<TYPE>[], aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aComponentsService | AbstractComponentsService<TYPE> |
|
aLayoutResolverService | LayoutResolver |
|
aLayoutMappingService | LayoutMappingResolver |
|
aComponentTypeRefResolvers | AbstractComponentTypeRefResolver<TYPE>[] |
|
aLogSvc | LoggerService |
主页 > @acoustic-content-sdk/component-utils > AbstractComponentResolverService > resolveComponent
AbstractComponentResolverService.resolveComponent property
Signature:
resolveComponent: (aRenderingContext: RenderingContextV2, aLayoutMode?: string) => Observable<TYPE>;
Home > ; @acoustic-content-sdk/component-utils > 抽象组件服务 > (构造函数)
AbstractComponentsService.(constructor)
初始化我们的构造函数。 我们确保将所有私有实例变量保留为闭包的一部分,并在实例级别覆盖方法。 由于这是一个单例服务,该方法不会导致性能问题。
Signature:
protected constructor(aDefaultComponent: TYPE, aPredicate: EqualsPredicate<TYPE>, aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aDefaultComponent | TYPE |
|
aPredicate | EqualsPredicate<TYPE> |
|
aLogSvc | LoggerService |
Home > @acoustic-content-sdk/component-utils > 抽象组件服务 > getTypeByLayout
AbstractComponentsService.getTypeByLayout property
Returns the type object based on the layout configuration
Signature:
getTypeByLayout: (aLayout: Layout, aLayoutMode?: string) => Observable<TYPE>;
主页 > @acoustic-content-sdk/component-utils > 抽象组件服务 > getTypeBySelector
AbstractComponentsService.getTypeBySelector property
Returns the type object based on the layout selector
Signature:
getTypeBySelector: (aSelector: string, aLayoutMode?: string) => Observable<TYPE>;
主页 > @acoustic-content-sdk/component-utils > 抽象组件服务 > registerType
AbstractComponentsService.registerType property
define the methods
Signature:
registerType: (aController: string | string[], aType: TYPE, aLayoutModes?: string | string[]) => void;
Home > @acoustic-content-sdk/component-utils > AbstractDeliverySearchResolverService > (constructor)
AbstractDeliverySearchResolverService.(constructor)
Constructs a new instance of the AbstractDeliverySearchResolverService
class
Signature:
protected constructor(aFetchText: FetchText, aProtected: ProtectedContent, aSeedResolver?: SeedResolver, aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aFetchText | FetchText |
|
aProtected | ProtectedContent |
|
aSeedResolver | SeedResolver |
|
aLogSvc | LoggerService |
主页 > @acoustic-content-sdk/component-utils > AbstractDeliverySearchResolverService > getDeliverySearchResults
AbstractDeliverySearchResolverService.getDeliverySearchResults property
Signature:
getDeliverySearchResults: <T>(aQuery: QueryInput, aClassification: string) => Observable<SearchResults<T>>;
Home > ; @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver > (constructor)
AbstractLayoutMappingResolver.(constructor)
Constructs a new instance of the AbstractLayoutMappingResolver
class
Signature:
protected constructor();
主页 > @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver > getSelector
AbstractLayoutMappingResolver.getSelector property
Returns the layout selector based on the rendering context
Signature:
getSelector: (aLayoutMode: string, aRenderingContext: RenderingContextV2) => string | undefined;
主页 > @acoustic-content-sdk/component-utils > AbstractLayoutMappingResolver > registerMapping
AbstractLayoutMappingResolver.registerMapping property
Registers a layout mapping
Signature:
registerMapping: (aId: string | string[], aSelector: string | string[], aLayoutMode?: string | string[]) => void;
Home< /a> > @acoustic-content-sdk/component-utils > AbstractProtectedContentService > (constructor)
AbstractProtectedContentService.(constructor)
Constructs a new instance of the AbstractProtectedContentService
class
Signature:
protected constructor(aUrlConfig$: Observable<UrlConfig>, aAuthStatus: AuthStatus, aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aUrlConfig$ | Observable<UrlConfig> |
|
aAuthStatus | AuthStatus |
|
aLogSvc | LoggerService |
主页 > @acoustic-content-sdk/component-utils > AbstractProtectedContentService > protected$
AbstractProtectedContentService.protected$ property
Signature:
protected$: Observable<boolean>;
Home > @acoustic-content-sdk/component-utils > AbstractLayoutResolverService > (constructor)
AbstractLayoutResolverService.(constructor)
Constructs a new instance of the AbstractLayoutResolverService
class
Signature:
protected constructor(aDeliveryTypeResolver: DeliveryTypeResolver, aDeliveryLayoutMappingResolver: DeliveryLayoutMappingResolver, aDeliveryLayoutResolver: DeliveryLayoutResolver, aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aDeliveryTypeResolver | DeliveryTypeResolver |
|
aDeliveryLayoutMappingResolver | DeliveryLayoutMappingResolver |
|
aDeliveryLayoutResolver | DeliveryLayoutResolver |
|
aLogSvc | LoggerService |
主页 > @acoustic-content-sdk/component-utils > AbstractLayoutResolverService > resolveLayout
AbstractLayoutResolverService.resolveLayout property
Signature:
resolveLayout: (aLayoutMode: string, aRenderingContext: RenderingContextV2) => Observable<Layout>;
Home > ; @acoustic-content-sdk/component-utils > AbstractWchPageService > (constructor)
AbstractWchPageService.(constructor)
Constructs a new instance of the AbstractWchPageService
class
Signature:
protected constructor(aDeliveryPageResolver: DeliveryPageResolver, aUrlConfig$: Observable<UrlConfig>, aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aDeliveryPageResolver | DeliveryPageResolver |
|
aUrlConfig$ | Observable<UrlConfig> |
|
aLogSvc | LoggerService |
主页 > @acoustic-content-sdk/component-utils > AbstractWchPageService > getRenderingContextByPath
AbstractWchPageService.getRenderingContextByPath property
Resolves the rendering context given the path
Signature:
getRenderingContextByPath: (aPath: string) => Observable<RenderingContextV2 | null | undefined>;
首页 > @acoustic-content-sdk/component-utils > AbstractRenderingContextResolverService > (constructor)
AbstractRenderingContextResolverService.(constructor)
Constructs a new instance of the AbstractRenderingContextResolverService
class
Signature:
protected constructor(aDeliveryContentResolver: DeliveryContentResolver, aLogSvc?: LoggerService);
Parameters
Parameter | Type | Description |
---|---|---|
aDeliveryContentResolver | DeliveryContentResolver |
|
aLogSvc | LoggerService |
主页 > @acoustic-content-sdk/component-utils > AbstractRenderingContextResolverService > resolveRenderingContext
AbstractRenderingContextResolverService.resolveRenderingContext property
Signature:
resolveRenderingContext: (aItem: RenderingContextInput, aProvider: RenderingContextProviderV2) => Observable<RenderingContextV2>;
Home > ; @acoustic-content-sdk/component-utils > 抽象注册布局映射 > id
AbstractRegisteredLayoutMapping.id property
Type IDs or content IDs to map this to
Signature:
id?: string | string[];
主页 > @acoustic-content-sdk/component-utils > 抽象注册布局映射 > kind
AbstractRegisteredLayoutMapping.kind property
Type IDs to map this to
Signature:
kind?: CONTENT_ITEM_KIND | CONTENT_ITEM_KIND[];
首页 > @acoustic-content-sdk/component-utils > 抽象注册布局映射 > layoutMode
AbstractRegisteredLayoutMapping.layoutMode property
用于此布局映射的可选布局模式。
Signature:
layoutMode?: string | string[];
Home > @acoustic-content-sdk/component-utils > 抽象注册布局映射 > 选择器
AbstractRegisteredLayoutMapping.selector property
定义布局控制器到布局实现之间的映射。 如果缺少此属性,将使用组件的选择器代替。
Signature:
selector: string | string[] | TYPE;
Home > @acoustic-content-sdk/component-utils > 抽象注册组件 > directive
AbstractRegisteredComponent.directive property
Signature:
directive: DIRECTIVE;
Home > ; @acoustic-content-sdk/component-utils > 抽象注册组件 > 键入
AbstractRegisteredComponent.type property
签名:
type: TYPE;