Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function labeledDecoder(
typeDecoder: Decoder,
msgDecoder: Decoder
): Decoder> {
return object({
// TODO: in 4.0.0 make protocol and verison fields mandatory
protocol: either(
constant<'iframe-coordinator'>(API_PROTOCOL),
hardcoded<'iframe-coordinator'>(API_PROTOCOL)
),
version: either(string, hardcoded('unknown')),
msgType: typeDecoder,
msg: msgDecoder
});
}
proposeGeometry: () => {rows: number, cols: number};
fit: () => void;
webLinksInit: (handler?: (event: Event, link: string) => void) => void;
// TODO: Update xterm types?
linkifier: any;
buffer: any;
selectionManager: any;
dispose: () => void;
}
const assertTerminalOptionsInFeatureConfig = guard(
object({
cursorBlink: boolean,
cursorStyle: either3(
constant('block'),
constant('underline'),
constant('bar'),
),
scrollback: number,
fontFamily: string,
fontSize: number,
lineHeight: number,
macOptionIsMeta: boolean,
allowTransparency: boolean,
experimentalCharAtlas: either3(
constant('none'),
constant('static'),
constant('dynamic'),
),
rendererType: either(constant('canvas'), constant('dom')),
}),
/**
* Initial setup message where environmental data
* is sent to the client.
* @external
*/
export interface LabeledEnvInit extends LabeledMsg {
/** Message identifier */
msgType: 'env_init';
/** Environment data */
msg: SetupData;
}
/* @external */
const envDecoder: Decoder = object({
msgType: constant<'env_init'>('env_init'),
msg: object({
locale: string,
hostRootUrl: string,
assignedRoute: string,
registeredKeys: optional(
array(
object({
key: string,
altKey: optional(boolean),
ctrlKey: optional(boolean),
metaKey: optional(boolean),
shiftKey: optional(boolean)
})
)
),
custom: mixed
webLinksInit: (handler?: (event: Event, link: string) => void) => void;
// TODO: Update xterm types?
linkifier: any;
buffer: any;
selectionManager: any;
dispose: () => void;
}
const assertTerminalOptionsInFeatureConfig = guard(
object({
cursorBlink: boolean,
cursorStyle: either3(
constant('block'),
constant('underline'),
constant('bar'),
),
scrollback: number,
fontFamily: string,
fontSize: number,
lineHeight: number,
macOptionIsMeta: boolean,
allowTransparency: boolean,
experimentalCharAtlas: either3(
constant('none'),
constant('static'),
constant('dynamic'),
),
rendererType: either(constant('canvas'), constant('dom')),
}),
);
pojo,
positiveInteger,
positiveNumber,
predicate,
regex,
string,
truthy,
tuple4,
tuple6,
undefined_,
field,
unknown,
url,
} from 'decoders';
const rect = object({ type: constant('rect') });
const circle = object({ type: constant('circle') });
const shape = dispatch(field('type', string), type => {
switch (type) {
case 'rect':
return rect;
case 'circle':
return circle;
}
return fail('Must be a valid shape');
});
guard(
object({
a0: string,
a1: number,
a2: optional(nullable(either4(string, email, regex(/x/, 'Must be x'), url()))),
positiveInteger,
positiveNumber,
predicate,
regex,
string,
truthy,
tuple4,
tuple6,
undefined_,
field,
unknown,
url,
} from 'decoders';
const rect = object({ type: constant('rect') });
const circle = object({ type: constant('circle') });
const shape = dispatch(field('type', string), type => {
switch (type) {
case 'rect':
return rect;
case 'circle':
return circle;
}
return fail('Must be a valid shape');
});
guard(
object({
a0: string,
a1: number,
a2: optional(nullable(either4(string, email, regex(/x/, 'Must be x'), url()))),
a3: fail('foo'),
/**
* A message used to publish a generic messages
* between the clients and the host application.
* @external
*/
export interface LabeledPublication extends LabeledMsg {
/** Message identifier */
msgType: 'publish';
/** Details of the data to publish */
msg: Publication;
}
/** @external */
const decoder: Decoder = object({
msgType: constant<'publish'>('publish'),
msg: object({
topic: string,
payload: mixed,
clientId: optional(string)
})
});
export { decoder };
/**
* A message used to request toasts to display
* in the host application.
* @external
*/
export interface LabeledToast extends LabeledMsg {
/** Message identifier */
msgType: 'toastRequest';
/** Toast details */
msg: Toast;
}
/** @external */
const decoder: Decoder = object({
msgType: constant<'toastRequest'>('toastRequest'),
msg: object({
title: optional(string),
message: string,
custom: mixed
})
});
export { decoder };
/**
* A message used to request the host navigate to another
* URI.
* @external
*/
export interface LabeledNavRequest extends LabeledMsg {
/** Message identifier */
msgType: 'navRequest';
/** Navigation request details */
msg: NavRequest;
}
/** @external */
const decoder: Decoder = object({
msgType: constant<'navRequest'>('navRequest'),
msg: object({
url: string
})
});
export { decoder };