proxyIdentifier.ts ×5

Frontier kind: Code frontier

unlabeled · c_304532c5595e

117 tests · 7594 LOC · 35 files · introduces 0 tests · 74 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges74 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1115 ranges7594 lines · 35 files · Browse complete extent
All tests (intent)
117 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 74 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/services/extensions/common/proxyIdentifier.ts 74 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- proxyIdentifier.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import type { VSBuffer } from '../../../../base/common/buffer.js';
7 > import type { CancellationToken } from '../../../../base/common/cancellation.js';
8 >
9 > export interface IRPCProtocol {
10 > /**
11 > * Returns a proxy to an object addressable/named in the extension host process or in the renderer process.
12 > */
13 > getProxy<T>(identifier: ProxyIdentifier<T>): Proxied<T>;
14 >
15 > /**
16 > * Register manually created instance.
17 > */
18 > set<T, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R;
19 >
20 > /**
21 > * Assert these identifiers are already registered via `.set`.
22 > */
23 > assertRegistered(identifiers: ProxyIdentifier<unknown>[]): void;
24 >
25 > /**
26 > * Wait for the write buffer (if applicable) to become empty.
27 > */
28 > drain(): Promise<void>;
29 >
30 > dispose(): void;
31 > }
32 >
33 > export class ProxyIdentifier<T> {
34 > public static count = 0;
35 > _proxyIdentifierBrand: void = undefined;
36 >
37 > public readonly sid: string;
38 > public readonly nid: number;
39 >
40 > constructor(sid: string) {
41 this.sid = sid;
42 this.nid = (++ProxyIdentifier.count);
43 }
45 >
46 > const identifiers: ProxyIdentifier<unknown>[] = [];
47 >
48 > export function createProxyIdentifier<T>(identifier: string): ProxyIdentifier<T> {
49 const result = new ProxyIdentifier<T>(identifier);
50 identifiers[result.nid] = result;
51 return result;
52 }
54 > /**
55 > * Mapped-type that replaces all JSONable-types with their toJSON-result type
56 > */
57 > export type Dto<T> = T extends { toJSON(): infer U }
58 > ? U
59 > : T extends VSBuffer // VSBuffer is understood by rpc-logic
60 > ? T
61 > : T extends CancellationToken // CancellationToken is understood by rpc-logic
62 > ? T
63 > : T extends Function // functions are dropped during JSON-stringify
64 > ? never
65 > : T extends object // recurse
66 > ? { [k in keyof T]: Dto<T[k]>; }
67 > : T;
68 >
69 > export type Proxied<T> = { [K in keyof T]: T[K] extends (...args: infer A) => infer R
70 > ? (...args: { [K in keyof A]: Dto<A[K]> }) => Promise<Dto<Awaited<R>>>
71 > : never
72 > };
73 >
74 > export function getStringIdentifierForProxy(nid: number): string {
75 return identifiers[nid].sid;
76 }
78 > /**
79 > * Marks the object as containing buffers that should be serialized more efficiently.
80 > */
81 > export class SerializableObjectWithBuffers<T> {
82 > constructor(
83 public readonly value: T
84 ) { }