ipfs-message-port-protocol
Advanced tools
Comparing version
export interface JSONObject { | ||
[key: string]: JSONValue; | ||
} | ||
export declare type JSONArray = JSONValue[]; | ||
export declare type JSONValue = null | boolean | number | string | JSONArray | JSONObject; | ||
export declare type Encoded<_Data, Representation> = Representation; | ||
export declare type StringEncoded<T> = Encoded<T, string>; | ||
export declare type Result<X, T> = { | ||
export type JSONArray = JSONValue[]; | ||
export type JSONValue = null | boolean | number | string | JSONArray | JSONObject; | ||
export type Encoded<_Data, Representation> = Representation; | ||
export type StringEncoded<T> = Encoded<T, string>; | ||
export type Result<X, T> = { | ||
ok: true; | ||
@@ -10,0 +10,0 @@ value: T; |
import type { Mtime } from 'ipfs-unixfs'; | ||
import type { RemoteIterable } from './core'; | ||
import type { EncodedCID } from './cid'; | ||
export declare type FileType = 'dir' | 'file'; | ||
export declare type EncodedFileContent = ArrayBufferView | ArrayBuffer | Blob | string | RemoteIterable<ArrayBufferView> | RemoteIterable<ArrayBuffer>; | ||
export type FileType = 'dir' | 'file'; | ||
export type EncodedFileContent = ArrayBufferView | ArrayBuffer | Blob | string | RemoteIterable<ArrayBufferView> | RemoteIterable<ArrayBuffer>; | ||
export interface EncodedFileInput { | ||
@@ -17,4 +17,4 @@ path?: string; | ||
} | ||
export declare type EncodedAddInput = EncodedFileContent | EncodedFileInput | EncodedDirectoryInput; | ||
export declare type EncodedAddAllInput = RemoteIterable<EncodedAddInput>; | ||
export type EncodedAddInput = EncodedFileContent | EncodedFileInput | EncodedDirectoryInput; | ||
export type EncodedAddAllInput = RemoteIterable<EncodedAddInput>; | ||
export interface EncodedAddResult { | ||
@@ -21,0 +21,0 @@ path: string; |
@@ -1,6 +0,6 @@ | ||
export declare type Procedure<T> = T extends (arg: infer I) => infer O ? (query: I & QueryOptions) => Return<O> : undefined; | ||
export declare type Remote<T extends Record<string, unknown>> = { | ||
export type Procedure<T> = T extends (arg: infer I) => infer O ? (query: I & QueryOptions) => Return<O> : undefined; | ||
export type Remote<T extends Record<string, unknown>> = { | ||
[K in keyof T]: Procedure<T[K]>; | ||
}; | ||
export declare type Return<T> = T extends Promise<infer U> ? Promise<U & TransferOptions> : Promise<T & TransferOptions>; | ||
export type Return<T> = T extends Promise<infer U> ? Promise<U & TransferOptions> : Promise<T & TransferOptions>; | ||
export interface QueryOptions { | ||
@@ -14,4 +14,4 @@ signal?: AbortSignal; | ||
} | ||
export declare type NonUndefined<A> = A extends undefined ? never : A; | ||
export declare type ProcedureNames<T extends Record<string, unknown>> = Array<{ | ||
export type NonUndefined<A> = A extends undefined ? never : A; | ||
export type ProcedureNames<T extends Record<string, unknown>> = Array<{ | ||
[K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never; | ||
@@ -22,16 +22,16 @@ }[keyof T]>; | ||
*/ | ||
export declare type Method<T extends Record<string, unknown>> = ServiceQuery<T>['method']; | ||
export type Method<T extends Record<string, unknown>> = ServiceQuery<T>['method']; | ||
/** | ||
* Namespace of the RCP service | ||
*/ | ||
export declare type Namespace<T extends Record<string, unknown>> = ServiceQuery<T>['namespace']; | ||
export declare type Values<T extends Record<string, unknown>> = T[keyof T]; | ||
export declare type Keys<T extends Record<string, unknown>> = keyof T; | ||
export declare type Inn<T extends Record<string, unknown>> = ServiceQuery<T>['input']; | ||
export declare type Out<T extends Record<string, unknown>> = ServiceQuery<T>['result']; | ||
export declare type RPCQuery<T extends Record<string, unknown>> = Pick<ServiceQuery<T>, 'method' | 'namespace' | 'input' | 'timeout' | 'signal'>; | ||
export declare type ServiceQuery<T> = Values<{ | ||
export type Namespace<T extends Record<string, unknown>> = ServiceQuery<T>['namespace']; | ||
export type Values<T extends Record<string, unknown>> = T[keyof T]; | ||
export type Keys<T extends Record<string, unknown>> = keyof T; | ||
export type Inn<T extends Record<string, unknown>> = ServiceQuery<T>['input']; | ||
export type Out<T extends Record<string, unknown>> = ServiceQuery<T>['result']; | ||
export type RPCQuery<T extends Record<string, unknown>> = Pick<ServiceQuery<T>, 'method' | 'namespace' | 'input' | 'timeout' | 'signal'>; | ||
export type ServiceQuery<T> = Values<{ | ||
[NS in keyof T]: NamespacedQuery<T[NS], NS>; | ||
}>; | ||
export declare type NamespacedQuery<S, NS> = Values<{ | ||
export type NamespacedQuery<S, NS> = Values<{ | ||
[M in keyof S]-?: S[M] extends (input: infer I) => infer O ? { | ||
@@ -44,12 +44,12 @@ namespace: NS; | ||
}>; | ||
declare type R<O> = O extends Promise<infer T> ? Promise<WithTransferOptions<T>> : Promise<WithTransferOptions<O>>; | ||
declare type WithTransferOptions<O> = O extends Record<string, unknown> ? O & TransferOptions : O; | ||
export declare type MultiService<T> = { | ||
type R<O> = O extends Promise<infer T> ? Promise<WithTransferOptions<T>> : Promise<WithTransferOptions<O>>; | ||
type WithTransferOptions<O> = O extends Record<string, unknown> ? O & TransferOptions : O; | ||
export type MultiService<T> = { | ||
[NS in keyof T]: NamespacedService<T[NS]>; | ||
}; | ||
declare type NamespacedService<S> = { | ||
type NamespacedService<S> = { | ||
[M in keyof S]: NamespacedMethod<S[M]>; | ||
}; | ||
export declare type NamespacedMethod<T> = T extends (arg: infer I) => infer O ? (query: I & QueryOptions) => Return<O> : never; | ||
export type NamespacedMethod<T> = T extends (arg: infer I) => infer O ? (query: I & QueryOptions) => Return<O> : never; | ||
export {}; | ||
//# sourceMappingURL=rpc.d.ts.map |
{ | ||
"name": "ipfs-message-port-protocol", | ||
"version": "0.14.1-a77e40cc.0", | ||
"version": "0.15.0", | ||
"description": "IPFS client/server protocol over message port", | ||
@@ -90,10 +90,9 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"ipfs-core-types": "^0.13.1-a77e40cc.0", | ||
"multiformats": "^10.0.0" | ||
"ipfs-core-types": "^0.14.0", | ||
"multiformats": "^11.0.0" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^37.0.11", | ||
"aegir": "^37.11.0", | ||
"uint8arrays": "^4.0.2" | ||
}, | ||
"gitHead": "a614528c55b8b22866bbdd2ffcde2e38eb5f578f" | ||
} | ||
} |
@@ -39,9 +39,2 @@ import { CID } from 'multiformats/cid' | ||
// @ts-expect-error non-enumerable field that doesn't always get transferred | ||
if (!cid._baseCache) { | ||
Object.defineProperty(cid, '_baseCache', { | ||
value: new Map() | ||
}) | ||
} | ||
if (!cid.asCID) { | ||
@@ -53,2 +46,8 @@ Object.defineProperty(cid, 'asCID', { | ||
if (!cid['/']) { | ||
Object.defineProperty(cid, '/', { | ||
get: () => cid.bytes | ||
}) | ||
} | ||
Object.setPrototypeOf(cid.multihash.digest, Uint8Array.prototype) | ||
@@ -58,8 +57,4 @@ Object.setPrototypeOf(cid.multihash.bytes, Uint8Array.prototype) | ||
Object.setPrototypeOf(cid, CID.prototype) | ||
// TODO: Figure out a way to avoid `Symbol.for` here as it can get out of | ||
// sync with cids implementation. | ||
// See: https://github.com/moxystudio/js-class-is/issues/25 | ||
Object.defineProperty(cid, Symbol.for('@ipld/js-cid/CID'), { value: true }) | ||
return cid | ||
} |
@@ -69,3 +69,4 @@ import { CID } from 'multiformats/cid' | ||
if (cid) { | ||
cids.push(cid) | ||
// @ts-expect-error - this has to be the same instance | ||
cids.push(value) | ||
encodeCID(cid, transfer) | ||
@@ -72,0 +73,0 @@ } else if (value instanceof ArrayBuffer) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
38424
-1.24%747
-0.53%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated