core-3nweb-client-lib 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,8 @@ import { ObjectReference } from './protobuf-msg';
2
2
  import { ExposedServices, Caller } from './connector';
3
3
  declare type FileByteSink = web3n.files.FileByteSink;
4
4
  declare type FileByteSource = web3n.files.FileByteSource;
5
- export declare function makeSinkCaller(caller: Caller, ref: ObjectReference): FileByteSink;
6
- export declare function exposeSinkService(sink: FileByteSink, expServices: ExposedServices): ObjectReference;
7
- export declare function makeSrcCaller(caller: Caller, ref: ObjectReference): FileByteSource;
8
- export declare function exposeSrcService(src: FileByteSource, expServices: ExposedServices): ObjectReference;
5
+ export declare function makeSinkCaller(caller: Caller, ref: ObjectReference<'FileByteSink'>): FileByteSink;
6
+ export declare function exposeSinkService(sink: FileByteSink, expServices: ExposedServices): ObjectReference<'FileByteSink'>;
7
+ export declare function makeSrcCaller(caller: Caller, ref: ObjectReference<'FileByteSource'>): FileByteSource;
8
+ export declare function exposeSrcService(src: FileByteSource, expServices: ExposedServices): ObjectReference<'FileByteSource'>;
9
9
  export {};
@@ -20,9 +20,9 @@ export declare class ClientsSideImpl implements ClientsSide {
20
20
  private startCall;
21
21
  startPromiseCall(path: string[], req: EnvelopeBody): Promise<EnvelopeBody>;
22
22
  startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
23
- registerClientDrop(o: any, srvRef: ObjectReference): void;
23
+ registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
24
24
  private makeClientDropCB;
25
25
  private sendObjDropMsg;
26
- srvRefOf(clientObj: any): ObjectReference;
26
+ srvRefOf(clientObj: any): ObjectReference<any>;
27
27
  listObj(path: string[]): string[];
28
28
  }
@@ -1,4 +1,4 @@
1
- import { ObjectReference, ExposedObjType } from "./protobuf-msg";
1
+ import { ObjectReference } from "./protobuf-msg";
2
2
  import { ServicesSide, Envelope, EnvelopeBody, ExposedFn, ExposedObj, ExposedServices } from "./connector";
3
3
  export declare class ServicesSideImpl implements ServicesSide {
4
4
  private readonly sendMsg;
@@ -16,8 +16,8 @@ export declare class ServicesSideImpl implements ServicesSide {
16
16
  }
17
17
  export declare class ExposedObjs {
18
18
  private readonly objs;
19
- exposeDroppableService(objType: ExposedObjType, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference;
20
- getOriginalObj<T>(ref: ObjectReference): T;
19
+ exposeDroppableService<T>(objType: T, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference<T>;
20
+ getOriginalObj<T>(ref: ObjectReference<any>): T;
21
21
  exposeW3NService(exp: ExposedFn | ExposedObj<any>): void;
22
22
  drop(name: string): void;
23
23
  find(path: string[] | undefined): ExposedFn | ExposedObj<any> | undefined;
@@ -149,7 +149,6 @@ class ExposedObjs {
149
149
  this.objs = new Map();
150
150
  }
151
151
  exposeDroppableService(objType, exp, original) {
152
- connector_1.ensureCorrectRefObjType(objType);
153
152
  let id;
154
153
  do {
155
154
  id = random_node_1.stringOfB64CharsSync(20);
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { Observable, Observer, Subject } from "rxjs";
3
- import { ObjectReference, ExposedObjType, Value } from "./protobuf-msg";
3
+ import { ObjectReference, Value } from "./protobuf-msg";
4
4
  export interface ExposedServices {
5
- exposeDroppableService(objType: ExposedObjType, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference;
6
- getOriginalObj<T>(ref: ObjectReference): T;
5
+ exposeDroppableService<T>(objType: T, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference<T>;
6
+ getOriginalObj<T>(ref: ObjectReference<any>): T;
7
7
  exposeW3NService(exp: ExposedFn | ExposedObj<any>): void;
8
8
  listObj(path: string[]): string[] | null;
9
9
  }
@@ -18,8 +18,8 @@ export interface ServicesSide {
18
18
  export interface Caller {
19
19
  startPromiseCall(path: string[], req: EnvelopeBody): Promise<EnvelopeBody>;
20
20
  startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
21
- registerClientDrop(o: any, srvRef: ObjectReference): void;
22
- srvRefOf(clientObj: any): ObjectReference;
21
+ registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
22
+ srvRefOf(clientObj: any): ObjectReference<any>;
23
23
  listObj(path: string[]): string[];
24
24
  }
25
25
  export interface ClientsSide {
@@ -43,7 +43,6 @@ export declare class ObjectsConnector {
43
43
  private sendCallError;
44
44
  }
45
45
  export declare const W3N_NAME = "w3n";
46
- export declare function ensureCorrectRefObjType(objType: ExposedObjType): void;
47
46
  /**
48
47
  * Envelope is a message form that is sent in IPC channel.
49
48
  */
@@ -86,4 +85,4 @@ export interface IPCException extends web3n.RuntimeException {
86
85
  path?: string[];
87
86
  }
88
87
  export declare function makeIPCException(fields: Partial<IPCException>): IPCException;
89
- export declare function checkRefObjTypeIs(expected: ExposedObjType, ref: ObjectReference): void;
88
+ export declare function checkRefObjTypeIs<T>(expected: T, ref: ObjectReference<T>): void;
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.checkRefObjTypeIs = exports.makeIPCException = exports.msgProtoType = exports.ensureCorrectRefObjType = exports.W3N_NAME = exports.ObjectsConnector = void 0;
19
+ exports.checkRefObjTypeIs = exports.makeIPCException = exports.msgProtoType = exports.W3N_NAME = exports.ObjectsConnector = void 0;
20
20
  const protobuf_msg_1 = require("./protobuf-msg");
21
21
  // Note that make_?_Side functions could've been imported normally, but client
22
22
  // side uses weakrefs, while services side doesn't, and services side is used
@@ -156,21 +156,6 @@ exports.ObjectsConnector = ObjectsConnector;
156
156
  Object.freeze(ObjectsConnector.prototype);
157
157
  Object.freeze(ObjectsConnector);
158
158
  exports.W3N_NAME = 'w3n';
159
- function ensureCorrectRefObjType(objType) {
160
- switch (objType) {
161
- case 'FileByteSink':
162
- case 'FileByteSource':
163
- case 'FileImpl':
164
- case 'FSImpl':
165
- case 'SymLinkImpl':
166
- case 'FSCollection':
167
- case 'FSItemsIter':
168
- return;
169
- default:
170
- throw new Error(`Object type ${objType} is not known`);
171
- }
172
- }
173
- exports.ensureCorrectRefObjType = ensureCorrectRefObjType;
174
159
  exports.msgProtoType = protobuf_msg_1.makeProtobufTypeFrom('ipc.proto', 'ipc.Envelope');
175
160
  function makeIPCException(fields) {
176
161
  const exc = {
@@ -20,7 +20,7 @@ export interface FileMsg {
20
20
  isVersioned: boolean;
21
21
  name: string;
22
22
  isNew: boolean;
23
- impl: ObjectReference;
23
+ impl: ObjectReference<'FileImpl'>;
24
24
  }
25
25
  export declare function packXAttrValue(val: any): EnvelopeBody;
26
26
  export declare function unpackXAttrValue(buf: EnvelopeBody): any;
@@ -91,7 +91,7 @@ export declare namespace vReadJSON {
91
91
  export declare namespace vGetByteSource {
92
92
  interface Reply {
93
93
  version: number;
94
- src: ObjectReference;
94
+ src: ObjectReference<'FileByteSource'>;
95
95
  }
96
96
  const replyType: ProtoType<Reply>;
97
97
  function wrapService(fn: ReadonlyFileVersionedAPI['getByteSource'], expServices: ExposedServices): ExposedFn;
@@ -120,7 +120,7 @@ export declare namespace updateXAttrs {
120
120
  export declare namespace vGetByteSink {
121
121
  interface Reply {
122
122
  version: number;
123
- sink: ObjectReference;
123
+ sink: ObjectReference<'FileByteSink'>;
124
124
  }
125
125
  const replyType: ProtoType<Reply>;
126
126
  function wrapService(fn: WritableFileVersionedAPI['getByteSink'], expServices: ExposedServices): ExposedFn;
@@ -11,7 +11,7 @@ export interface FSMsg {
11
11
  isVersioned: boolean;
12
12
  writable: boolean;
13
13
  name: string;
14
- impl: ObjectReference;
14
+ impl: ObjectReference<'FSImpl'>;
15
15
  }
16
16
  export declare const fsMsgType: ProtoType<FSMsg>;
17
17
  export declare namespace fsItem {
@@ -23,7 +23,7 @@ export declare namespace fsItem {
23
23
  item?: {
24
24
  fs?: FSMsg;
25
25
  file?: FileMsg;
26
- collection?: ObjectReference;
26
+ collection?: ObjectReference<'FSCollection'>;
27
27
  };
28
28
  location?: {
29
29
  fs: FSMsg;
@@ -3,12 +3,11 @@ import { EnvelopeBody } from './connector';
3
3
  import { ProtoType } from '../lib-client/protobuf-loader';
4
4
  declare type RuntimeException = web3n.RuntimeException;
5
5
  export declare function makeProtobufTypeFrom<T extends object>(protoFile: string, typeName: string): ProtoType<T>;
6
- export declare type ExposedObjType = 'FileByteSink' | 'FileByteSource' | 'FileImpl' | 'FSImpl' | 'SymLinkImpl' | 'FSCollection' | 'FSItemsIter';
7
- export interface ObjectReference {
8
- objType: ExposedObjType;
6
+ export interface ObjectReference<T> {
7
+ objType: T;
9
8
  path: string[];
10
9
  }
11
- export declare const objRefType: ProtoType<ObjectReference>;
10
+ export declare const objRefType: ProtoType<ObjectReference<any>>;
12
11
  export interface BooleanValue {
13
12
  value: boolean;
14
13
  }