Skip to content

Commit

Permalink
work on docs
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Peveler <[email protected]>
  • Loading branch information
MasterOdin committed Dec 14, 2021
1 parent e766ba5 commit cfa164e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 59 deletions.
116 changes: 58 additions & 58 deletions packages/io-display/src/display-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,69 @@ export class DisplayContext {
});
}

public async displayUrl(
windowName: string,
url: string,
options: DisplayUrlOptions,
): Promise<ViewObject> {
const uniformGridCellSize = await this.displayWindows
.get(windowName)
.getUniformGridCellSize();

if (
(options.width === undefined || options.height === undefined) &&
uniformGridCellSize === undefined
) {
throw new Error('Uniform grid cell size must be initialized');
}

if (options.width === undefined && options.widthFactor === undefined) {
throw new Error('width or widthFactor is required');
}
if (options.height === undefined && options.heightFactor === undefined) {
throw new Error('height or heightFactor is required');
}

return await this.createViewObject(
{
nodeIntegration: false,
uiDraggable: true,
uiClosable: true,
...(options.top === undefined && options.left === undefined
? {
position: {
gridLeft: 1,
gridTop: 1,
},
}
: {}),
...options,
width:
options.width !== undefined
? typeof options.width === 'string'
? options.width
: `${options.width}px`
: `${options.widthFactor * uniformGridCellSize.width}px`,
height:
options.height !== undefined
? typeof options.height === 'string'
? options.height
: `${options.height}px`
: `${options.heightFactor * uniformGridCellSize.height}px`,
url,
},
windowName,
);
}

private validQueue(queueName: string): boolean {
return (
queueName.indexOf('rpc-display-') > -1 &&
this.displayNames.has(queueName.replace('rpc-display-', ''))
);
}

_clean(closedDisplay: string): void {
private _clean(closedDisplay: string): void {
const closedWindows: string[] = [];
for (const [k, v] of this.displayWindows) {
if (v.displayName === closedDisplay) {
Expand All @@ -195,7 +250,7 @@ export class DisplayContext {
}
}

async _postRequest<T = any>(displayName: string, data): Promise<T> {
private async _postRequest<T = any>(displayName: string, data): Promise<T> {
const response = await this.io.rabbit.publishRpc(
`rpc-display-${displayName}`,
data,
Expand Down Expand Up @@ -279,7 +334,7 @@ export class DisplayContext {
return this.show();
}

async _executeInAvailableDisplays<T = any>(cmd: {
private async _executeInAvailableDisplays<T = any>(cmd: {
command: string;
options: { context: string };
}): Promise<T[]> {
Expand Down Expand Up @@ -580,61 +635,6 @@ export class DisplayContext {
return viewObject;
}

public async displayUrl(
windowName: string,
url: string,
options: DisplayUrlOptions,
): Promise<ViewObject> {
const uniformGridCellSize = await this.displayWindows
.get(windowName)
.getUniformGridCellSize();

if (
(options.width === undefined || options.height === undefined) &&
uniformGridCellSize === undefined
) {
throw new Error('Uniform grid cell size must be initialized');
}

if (options.width === undefined && options.widthFactor === undefined) {
throw new Error('width or widthFactor is required');
}
if (options.height === undefined && options.heightFactor === undefined) {
throw new Error('height or heightFactor is required');
}

return await this.createViewObject(
{
nodeIntegration: false,
uiDraggable: true,
uiClosable: true,
...(options.top === undefined && options.left === undefined
? {
position: {
gridLeft: 1,
gridTop: 1,
},
}
: {}),
...options,
width:
options.width !== undefined
? typeof options.width === 'string'
? options.width
: `${options.width}px`
: `${options.widthFactor * uniformGridCellSize.width}px`,
height:
options.height !== undefined
? typeof options.height === 'string'
? options.height
: `${options.height}px`
: `${options.heightFactor * uniformGridCellSize.height}px`,
url,
},
windowName,
);
}

/**
* DisplayContext closed event
* @param {displayContextClosedEventCallback} handler - event handler
Expand Down
12 changes: 12 additions & 0 deletions packages/io-display/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ interface FocusWindowResponse extends BaseResponse {

/**
* Class representing the DisplayContextFactory object.
*
* The main function to use is {@link openDisplayContext}
*/
export class DisplayWorker {
private io: Io;
Expand All @@ -135,6 +137,12 @@ export class DisplayWorker {
this.io.rabbit.setTimeout(10000);
}

/**
* Open a new or existing display context.
*
* @param displayContextName - Name of the display context
* @param displayOptions - Options for the display context
*/
public async openDisplayContext(
displayContextName: string,
displayOptions: DisplayOptions,
Expand Down Expand Up @@ -168,6 +176,7 @@ export class DisplayWorker {
}

/**
* @deprecated This will be removed in 2.0
*
* @param name The name of the display worker to communicate with
* @param display The name of the context within display worker to communicate with
Expand Down Expand Up @@ -603,6 +612,9 @@ export class DisplayWorker {
}
}

/**
* It is not suggested to call this function directly, and it will be removed in the future.
*/
export function registerDisplay(io: Io): void {
if (!io.rabbit || !io.redis) {
throw new Error('Requires both redis and rabbitmq');
Expand Down
4 changes: 3 additions & 1 deletion typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"plugin": [
"typedoc-plugin-missing-exports"
],
"readme": "README.md"
"readme": "README.md",
"excludeInternal": true,
"sort": ["source-order"]
}

0 comments on commit cfa164e

Please sign in to comment.