@dfinity/candid
Advanced tools
Comparing version 0.20.2 to 0.21.1
import * as IDL from './idl'; | ||
import * as UI from './candid-core'; | ||
declare type InputBox = UI.InputBox; | ||
type InputBox = UI.InputBox; | ||
declare const FormConfig: UI.FormConfig; | ||
@@ -5,0 +5,0 @@ export declare const inputBox: (t: IDL.Type, config: Partial<UI.UIConfig>) => UI.InputBox; |
@@ -27,4 +27,2 @@ "use strict"; | ||
exports.renderValue = exports.renderInput = exports.Render = exports.vecForm = exports.optForm = exports.variantForm = exports.tupleForm = exports.recordForm = exports.inputBox = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
const IDL = __importStar(require("./idl")); | ||
@@ -31,0 +29,0 @@ const principal_1 = require("@dfinity/principal"); |
@@ -226,2 +226,3 @@ import { Principal as PrincipalId } from '@dfinity/principal'; | ||
* Arrays of float or other non-primitive types are encoded/decoded as untyped array in Javascript. | ||
* | ||
* @param {Type} t | ||
@@ -260,3 +261,3 @@ */ | ||
* Represents an IDL Record | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -292,3 +293,3 @@ export declare class RecordClass extends ConstructType<Record<string, any>> { | ||
* Represents an IDL Variant | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -390,3 +391,3 @@ export declare class VariantClass extends ConstructType<Record<string, any>> { | ||
*/ | ||
export declare type InterfaceFactory = (idl: { | ||
export type InterfaceFactory = (idl: { | ||
IDL: { | ||
@@ -393,0 +394,0 @@ Empty: EmptyClass; |
@@ -5,4 +5,3 @@ "use strict"; | ||
exports.Service = exports.Func = exports.Rec = void 0; | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
// tslint:disable:max-classes-per-file | ||
const principal_1 = require("@dfinity/principal"); | ||
@@ -160,3 +159,2 @@ const buffer_1 = require("./utils/buffer"); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_buildTypeTableImpl(typeTable) { | ||
@@ -626,2 +624,3 @@ // No type table encoding for Primitive types. | ||
* Arrays of float or other non-primitive types are encoded/decoded as untyped array in Javascript. | ||
* | ||
* @param {Type} t | ||
@@ -809,3 +808,3 @@ */ | ||
* Represents an IDL Record | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -993,3 +992,3 @@ class RecordClass extends ConstructType { | ||
* Represents an IDL Variant | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -1195,2 +1194,8 @@ class VariantClass extends ConstructType { | ||
class FuncClass extends ConstructType { | ||
static argsToString(types, v) { | ||
if (types.length !== v.length) { | ||
throw new Error('arity mismatch'); | ||
} | ||
return '(' + types.map((t, i) => t.valueToString(v[i])).join(', ') + ')'; | ||
} | ||
constructor(argTypes, retTypes, annotations = []) { | ||
@@ -1202,8 +1207,2 @@ super(); | ||
} | ||
static argsToString(types, v) { | ||
if (types.length !== v.length) { | ||
throw new Error('arity mismatch'); | ||
} | ||
return '(' + types.map((t, i) => t.valueToString(v[i])).join(', ') + ')'; | ||
} | ||
accept(v, d) { | ||
@@ -1271,5 +1270,2 @@ return v.visitFunc(this, d); | ||
} | ||
else if (ann === 'composite_query') { | ||
return new Uint8Array([3]); | ||
} | ||
else { | ||
@@ -1284,11 +1280,3 @@ throw new Error('Illegal function annotation'); | ||
super(); | ||
this._fields = Object.entries(fields).sort((a, b) => { | ||
if (a[0] < b[0]) { | ||
return -1; | ||
} | ||
if (a[0] > b[0]) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
this._fields = Object.entries(fields).sort((a, b) => (0, hash_1.idlLabelToId)(a[0]) - (0, hash_1.idlLabelToId)(b[0])); | ||
} | ||
@@ -1443,6 +1431,2 @@ accept(v, d) { | ||
} | ||
case 3: { | ||
annotations.push('composite_query'); | ||
break; | ||
} | ||
default: | ||
@@ -1449,0 +1433,0 @@ throw new Error('unknown annotation'); |
@@ -5,2 +5,2 @@ export interface JsonArray extends Array<JsonValue> { | ||
} | ||
export declare type JsonValue = boolean | string | number | JsonArray | JsonObject; | ||
export type JsonValue = boolean | string | number | JsonArray | JsonObject; |
/** | ||
* Equivalent to `Math.log2(n)` with support for `BigInt` values | ||
* | ||
* @param n bigint or integer | ||
@@ -10,2 +11,3 @@ * @returns integer | ||
* (necessary for browser preprocessors which replace the `**` operator with `Math.pow`) | ||
* | ||
* @param n bigint or integer | ||
@@ -12,0 +14,0 @@ * @returns bigint |
@@ -6,2 +6,3 @@ "use strict"; | ||
* Equivalent to `Math.log2(n)` with support for `BigInt` values | ||
* | ||
* @param n bigint or integer | ||
@@ -21,2 +22,3 @@ * @returns integer | ||
* (necessary for browser preprocessors which replace the `**` operator with `Math.pow`) | ||
* | ||
* @param n bigint or integer | ||
@@ -23,0 +25,0 @@ * @returns bigint |
@@ -98,2 +98,3 @@ "use strict"; | ||
// Add a little bit of exponential growth. | ||
// tslint:disable-next-line:no-bitwise | ||
const b = new ArrayBuffer(((this._buffer.byteLength + amount) * 1.2) | 0); | ||
@@ -100,0 +101,0 @@ const v = new Uint8Array(b, 0, this._view.byteLength + amount); |
@@ -5,2 +5,3 @@ "use strict"; | ||
/* eslint-disable no-constant-condition */ | ||
// tslint:disable:no-bitwise | ||
// Note: this file uses buffer-pipe, which on Node only, uses the Node Buffer | ||
@@ -7,0 +8,0 @@ // implementation, which isn't compatible with the NPM buffer package |
import * as IDL from './idl'; | ||
import * as UI from './candid-core'; | ||
declare type InputBox = UI.InputBox; | ||
type InputBox = UI.InputBox; | ||
declare const FormConfig: UI.FormConfig; | ||
@@ -5,0 +5,0 @@ export declare const inputBox: (t: IDL.Type, config: Partial<UI.UIConfig>) => UI.InputBox; |
@@ -1,3 +0,1 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import * as IDL from './idl'; | ||
@@ -4,0 +2,0 @@ import { Principal } from '@dfinity/principal'; |
@@ -226,2 +226,3 @@ import { Principal as PrincipalId } from '@dfinity/principal'; | ||
* Arrays of float or other non-primitive types are encoded/decoded as untyped array in Javascript. | ||
* | ||
* @param {Type} t | ||
@@ -260,3 +261,3 @@ */ | ||
* Represents an IDL Record | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -292,3 +293,3 @@ export declare class RecordClass extends ConstructType<Record<string, any>> { | ||
* Represents an IDL Variant | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -390,3 +391,3 @@ export declare class VariantClass extends ConstructType<Record<string, any>> { | ||
*/ | ||
export declare type InterfaceFactory = (idl: { | ||
export type InterfaceFactory = (idl: { | ||
IDL: { | ||
@@ -393,0 +394,0 @@ Empty: EmptyClass; |
@@ -1,3 +0,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
// tslint:disable:max-classes-per-file | ||
import { Principal as PrincipalId } from '@dfinity/principal'; | ||
@@ -153,3 +152,2 @@ import { concat, PipeArrayBuffer as Pipe } from './utils/buffer'; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_buildTypeTableImpl(typeTable) { | ||
@@ -606,2 +604,3 @@ // No type table encoding for Primitive types. | ||
* Arrays of float or other non-primitive types are encoded/decoded as untyped array in Javascript. | ||
* | ||
* @param {Type} t | ||
@@ -787,3 +786,3 @@ */ | ||
* Represents an IDL Record | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -969,3 +968,3 @@ export class RecordClass extends ConstructType { | ||
* Represents an IDL Variant | ||
* @param {object} [fields] - mapping of function name to Type | ||
* @param {Object} [fields] - mapping of function name to Type | ||
*/ | ||
@@ -1168,2 +1167,8 @@ export class VariantClass extends ConstructType { | ||
export class FuncClass extends ConstructType { | ||
static argsToString(types, v) { | ||
if (types.length !== v.length) { | ||
throw new Error('arity mismatch'); | ||
} | ||
return '(' + types.map((t, i) => t.valueToString(v[i])).join(', ') + ')'; | ||
} | ||
constructor(argTypes, retTypes, annotations = []) { | ||
@@ -1175,8 +1180,2 @@ super(); | ||
} | ||
static argsToString(types, v) { | ||
if (types.length !== v.length) { | ||
throw new Error('arity mismatch'); | ||
} | ||
return '(' + types.map((t, i) => t.valueToString(v[i])).join(', ') + ')'; | ||
} | ||
accept(v, d) { | ||
@@ -1244,5 +1243,2 @@ return v.visitFunc(this, d); | ||
} | ||
else if (ann === 'composite_query') { | ||
return new Uint8Array([3]); | ||
} | ||
else { | ||
@@ -1256,11 +1252,3 @@ throw new Error('Illegal function annotation'); | ||
super(); | ||
this._fields = Object.entries(fields).sort((a, b) => { | ||
if (a[0] < b[0]) { | ||
return -1; | ||
} | ||
if (a[0] > b[0]) { | ||
return 1; | ||
} | ||
return 0; | ||
}); | ||
this._fields = Object.entries(fields).sort((a, b) => idlLabelToId(a[0]) - idlLabelToId(b[0])); | ||
} | ||
@@ -1413,6 +1401,2 @@ accept(v, d) { | ||
} | ||
case 3: { | ||
annotations.push('composite_query'); | ||
break; | ||
} | ||
default: | ||
@@ -1419,0 +1403,0 @@ throw new Error('unknown annotation'); |
@@ -5,2 +5,2 @@ export interface JsonArray extends Array<JsonValue> { | ||
} | ||
export declare type JsonValue = boolean | string | number | JsonArray | JsonObject; | ||
export type JsonValue = boolean | string | number | JsonArray | JsonObject; |
/** | ||
* Equivalent to `Math.log2(n)` with support for `BigInt` values | ||
* | ||
* @param n bigint or integer | ||
@@ -10,2 +11,3 @@ * @returns integer | ||
* (necessary for browser preprocessors which replace the `**` operator with `Math.pow`) | ||
* | ||
* @param n bigint or integer | ||
@@ -12,0 +14,0 @@ * @returns bigint |
/** | ||
* Equivalent to `Math.log2(n)` with support for `BigInt` values | ||
* | ||
* @param n bigint or integer | ||
@@ -16,2 +17,3 @@ * @returns integer | ||
* (necessary for browser preprocessors which replace the `**` operator with `Math.pow`) | ||
* | ||
* @param n bigint or integer | ||
@@ -18,0 +20,0 @@ * @returns bigint |
@@ -92,2 +92,3 @@ /** | ||
// Add a little bit of exponential growth. | ||
// tslint:disable-next-line:no-bitwise | ||
const b = new ArrayBuffer(((this._buffer.byteLength + amount) * 1.2) | 0); | ||
@@ -94,0 +95,0 @@ const v = new Uint8Array(b, 0, this._view.byteLength + amount); |
/* eslint-disable no-constant-condition */ | ||
// tslint:disable:no-bitwise | ||
// Note: this file uses buffer-pipe, which on Node only, uses the Node Buffer | ||
@@ -3,0 +4,0 @@ // implementation, which isn't compatible with the NPM buffer package |
{ | ||
"name": "@dfinity/candid", | ||
"version": "0.20.2", | ||
"version": "0.21.1", | ||
"author": "DFINITY Stiftung <sdk@dfinity.org>", | ||
@@ -51,3 +51,3 @@ "license": "Apache-2.0", | ||
"peerDependencies": { | ||
"@dfinity/principal": "^0.20.2" | ||
"@dfinity/principal": "^0.21.1" | ||
}, | ||
@@ -54,0 +54,0 @@ "devDependencies": { |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
636602
6720
3