1220
1221
export function toService<T extends object>(channel: IChannel, options?: ICreateProxyServiceOptions): T {
1222
>
const disableMarshalling = options?.disableMarshalling;
ipc.ts
1223
>
1224
>
return new Proxy({}, {
1225
>
get(_target: T, propKey: PropertyKey) {
1226
>
if (typeof propKey === 'string') {
1227
>
1228
>
// Check for predefined values
1229
>
if (options?.properties?.has(propKey)) {
1230
return options.properties.get(propKey);
1231
}
1233
>
// Dynamic Event
1234
>
if (propertyIsDynamicEvent(propKey)) {
1235
return function (arg: unknown) {
1236
return channel.listen(propKey, arg);
1237
};
1238
}
1240
>
// Event
1241
>
if (propertyIsEvent(propKey)) {
1242
return channel.listen(propKey);
1243
}