New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →
Socket
Sign inDemoInstall
Socket

libzap

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libzap - npm Package Compare versions

Comparing version 0.0.11 to 0.0.13

lib/remote/handler.d.ts

2

lib/ot/client.d.ts

@@ -8,3 +8,3 @@ import { WorkspaceOp } from "./workspace";

apply?: (op: WorkspaceOp) => Promise<void>;
reset(): void;
reset(newHistory?: WorkspaceOp[]): void;
record(op: WorkspaceOp): void;

@@ -11,0 +11,0 @@ ack(): void;

@@ -9,4 +9,4 @@ "use strict";

}
reset() {
this.rev = 0;
reset(newHistory) {
this.rev = newHistory ? newHistory.length : 0;
this.wait = null;

@@ -13,0 +13,0 @@ this.buf = null;

@@ -5,3 +5,3 @@ "use strict";

const connection_1 = require("./connection");
const ot_1 = require("./ot");
const handler_1 = require("./handler");
const protocol_1 = require("./protocol");

@@ -342,3 +342,3 @@ const alert = (message) => { console.log("ALERT:", message); };

if (this.capabilities.workspaceOperationalTransformation) {
this._registeredHandlers.get(ot_1.OperationalTransformationHandler.id).register(connection);
this._registeredHandlers.get(handler_1.Handler.id).register(connection);
}

@@ -345,0 +345,0 @@ else {

"use strict";
const assert = require("assert");
const client_1 = require("../ot/client");
const client_2 = require("./client");
const ot_1 = require("./ot");
const client_1 = require("./client");
const handler_1 = require("./handler");
const protocol_1 = require("./protocol");
const util_1 = require("./util");
describe("OperationalTransformationHandler", () => {
function mockWorkspace() {
let onOpListener;
return {
apply(_op) { throw new Error("not implemented"); },
reset(_history) { return Promise.resolve(void 0); },
onOp(listener) { onOpListener = listener; },
onReset(_listener) { },
onWillSaveFile(_listener) { },
dispose() { },
mockRecordOp(op) { onOpListener(op); },
};
}
describe("Handler", () => {
it("ref/update", () => {
const { server, serverOptions } = util_1.createTestServer();
let ok = new Promise((resolve) => {
server.onRequest("ref/update", () => {
resolve();
server.onRequest("repo/watch", () => {
return server.sendRequest("ref/update", {
repo: "repo",
ref: "ref",
state: { gitBase: "c", gitBranch: "d" },
});
});
let ok = new Promise((resolve, reject) => {
server.onRequest("ref/update", (params) => {
try {
assert.deepEqual(params, {
repo: "repo",
ref: "ref",
current: { gitBase: "c", gitBranch: "d", rev: 0 },
op: { head: "a" },
});
resolve();
}
catch (err) {
reject(err);
}
return {};
});
});
const client = new client_2.Client(serverOptions, {});
const otClient = new client_1.Client();
const otHandler = new ot_1.OperationalTransformationHandler(client, otClient);
otHandler.refIdentifier = { repo: "repo", ref: "ref" };
otHandler.refState = { gitBase: "c", gitBranch: "d" };
client.registerHandler(ot_1.OperationalTransformationHandler.id, otHandler);
const client = new client_1.Client(serverOptions, {});
const handler = new handler_1.Handler(client);
client.registerHandler(handler_1.Handler.id, handler);
const workspace = mockWorkspace();
handler.attachWorkspace({ repo: "repo", ref: "ref" }, workspace);
return client.start().initialStart.then(() => {
otClient.record({ head: "a" });
return util_1.assertResolved(ok, "server did not receive 'recv' from client");
return handler.repoWatch({ repo: "repo", refspec: "*" }).then(() => {
workspace.mockRecordOp({ head: "a" });
return util_1.assertResolved(ok, "server did not receive 'ref/update' from client");
});
}, (err) => assert.ifError(err));

@@ -29,12 +60,11 @@ });

const { server, serverOptions } = util_1.createTestServer();
const client = new client_2.Client(serverOptions, {});
const otClient = new client_1.Client();
const otHandler = new ot_1.OperationalTransformationHandler(client, otClient);
otHandler.refIdentifier = { repo: "repo", ref: "ref" };
otHandler.refState = { gitBase: "c", gitBranch: "d" };
client.registerHandler(ot_1.OperationalTransformationHandler.id, otHandler);
const client = new client_1.Client(serverOptions, {});
const handler = new handler_1.Handler(client);
client.registerHandler(handler_1.Handler.id, handler);
const workspace = mockWorkspace();
handler.attachWorkspace({ repo: "repo", ref: "ref" }, workspace);
let ok = false;
otClient.ack = () => { ok = true; };
handler.getRepo("repo").getRef("ref").ot.ack = () => { ok = true; };
return client.start().initialStart.then(() => {
return server.sendRequest(ot_1.RefUpdateDownstreamRequest.type, {
return server.sendRequest(protocol_1.RefUpdateDownstreamRequest.type, {
repo: "repo",

@@ -41,0 +71,0 @@ ref: "ref",

import { NotificationType, NotificationType0, RequestType, RequestType0 } from "vscode-jsonrpc";
import { WorkspaceOp } from "../ot/workspace";
export declare enum StatusType {

@@ -87,1 +88,99 @@ StatusTypeError = 1,

}
export interface RefIdentifier {
repo: string;
ref: string;
}
export interface RefBaseInfo {
gitBase: string;
gitBranch: string;
}
export interface RefPointer extends RefBaseInfo {
rev: number;
}
export interface RefState extends RefBaseInfo {
history?: WorkspaceOp[];
}
export interface RefInfo extends RefIdentifier, RefBaseInfo {
rev: number;
target?: string;
watchers: string[];
}
export declare namespace RefListRequest {
const type: RequestType<void, RefInfo[], void, void>;
}
export interface RepoWatchParams {
repo: string;
refspec: string;
}
export declare namespace RepoWatchRequest {
const type: RequestType<RepoWatchParams, void, void, void>;
}
export interface RefInfoResult {
state?: RefState;
target?: string;
}
export declare namespace RefInfoRequest {
const type: RequestType<RefIdentifier, RefInfoResult, void, void>;
}
export interface RefUpdateDownstreamParams extends RefIdentifier {
current?: RefBaseInfo;
state?: RefState;
op?: WorkspaceOp;
ack?: boolean;
delete?: boolean;
}
export interface RefUpdateDownstreamResult {
}
export declare namespace RefUpdateDownstreamRequest {
const type: RequestType<RefUpdateDownstreamParams, RefUpdateDownstreamResult, void, void>;
}
export interface RefUpdateUpstreamParams extends RefIdentifier {
current?: RefPointer;
state?: RefState;
force?: boolean;
op?: WorkspaceOp;
delete?: boolean;
}
export interface RefUpdateUpstreamResult {
}
export declare namespace RefUpdateUpstreamRequest {
const type: RequestType<RefUpdateUpstreamParams, RefUpdateUpstreamResult, void, void>;
}
export interface WorkspaceIdentifier {
dir: string;
}
export interface WorkspaceAddParams extends WorkspaceIdentifier {
}
export interface WorkspaceAddResult {
}
export declare namespace WorkspaceAddRequest {
const type: RequestType<WorkspaceAddParams, WorkspaceAddResult, any, void>;
}
export interface WorkspaceRemoveParams extends WorkspaceIdentifier {
}
export interface WorkspaceRemoveResult {
}
export declare namespace WorkspaceRemoveRequest {
const type: RequestType<WorkspaceRemoveParams, WorkspaceRemoveResult, any, void>;
}
export interface WorkspaceConfiguration {
syncTree?: boolean;
}
export interface WorkspaceConfigureParams extends WorkspaceIdentifier, WorkspaceConfiguration {
}
export interface WorkspaceConfigureResult {
}
export declare namespace WorkspaceConfigureRequest {
const type: RequestType<WorkspaceConfigureParams, WorkspaceConfigureResult, any, void>;
}
export interface WorkspaceStatusParams extends WorkspaceIdentifier, WorkspaceConfiguration {
}
export declare namespace WorkspaceStatusRequest {
const type: RequestType<WorkspaceStatusParams, ShowStatusParams, any, void>;
}
export interface WorkspaceWillSaveFileParams {
uri: string;
}
export declare namespace WorkspaceWillSaveFileRequest {
const type: RequestType<WorkspaceWillSaveFileParams, void, any, void>;
}

@@ -56,2 +56,43 @@ "use strict";

})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
var RefListRequest;
(function (RefListRequest) {
RefListRequest.type = new vscode_jsonrpc_1.RequestType("ref/list");
})(RefListRequest = exports.RefListRequest || (exports.RefListRequest = {}));
var RepoWatchRequest;
(function (RepoWatchRequest) {
RepoWatchRequest.type = new vscode_jsonrpc_1.RequestType("repo/watch");
})(RepoWatchRequest = exports.RepoWatchRequest || (exports.RepoWatchRequest = {}));
var RefInfoRequest;
(function (RefInfoRequest) {
RefInfoRequest.type = new vscode_jsonrpc_1.RequestType("ref/info");
})(RefInfoRequest = exports.RefInfoRequest || (exports.RefInfoRequest = {}));
var RefUpdateDownstreamRequest;
(function (RefUpdateDownstreamRequest) {
RefUpdateDownstreamRequest.type = new vscode_jsonrpc_1.RequestType("ref/update");
})(RefUpdateDownstreamRequest = exports.RefUpdateDownstreamRequest || (exports.RefUpdateDownstreamRequest = {}));
var RefUpdateUpstreamRequest;
(function (RefUpdateUpstreamRequest) {
RefUpdateUpstreamRequest.type = new vscode_jsonrpc_1.RequestType("ref/update");
})(RefUpdateUpstreamRequest = exports.RefUpdateUpstreamRequest || (exports.RefUpdateUpstreamRequest = {}));
;
var WorkspaceAddRequest;
(function (WorkspaceAddRequest) {
WorkspaceAddRequest.type = new vscode_jsonrpc_1.RequestType("workspace/add");
})(WorkspaceAddRequest = exports.WorkspaceAddRequest || (exports.WorkspaceAddRequest = {}));
var WorkspaceRemoveRequest;
(function (WorkspaceRemoveRequest) {
WorkspaceRemoveRequest.type = new vscode_jsonrpc_1.RequestType("workspace/remove");
})(WorkspaceRemoveRequest = exports.WorkspaceRemoveRequest || (exports.WorkspaceRemoveRequest = {}));
var WorkspaceConfigureRequest;
(function (WorkspaceConfigureRequest) {
WorkspaceConfigureRequest.type = new vscode_jsonrpc_1.RequestType("workspace/configure");
})(WorkspaceConfigureRequest = exports.WorkspaceConfigureRequest || (exports.WorkspaceConfigureRequest = {}));
var WorkspaceStatusRequest;
(function (WorkspaceStatusRequest) {
WorkspaceStatusRequest.type = new vscode_jsonrpc_1.RequestType("workspace/status");
})(WorkspaceStatusRequest = exports.WorkspaceStatusRequest || (exports.WorkspaceStatusRequest = {}));
var WorkspaceWillSaveFileRequest;
(function (WorkspaceWillSaveFileRequest) {
WorkspaceWillSaveFileRequest.type = new vscode_jsonrpc_1.RequestType("workspace/willSaveFile");
})(WorkspaceWillSaveFileRequest = exports.WorkspaceWillSaveFileRequest || (exports.WorkspaceWillSaveFileRequest = {}));
//# sourceMappingURL=protocol.js.map
{
"name": "libzap",
"version": "0.0.11",
"version": "0.0.13",
"description": "JavaScript library for Zap",

@@ -5,0 +5,0 @@ "license": "none",

@@ -19,5 +19,5 @@ import { WorkspaceOp, compose, noop, transform } from "./workspace";

// reset clears rev, wait, and buf.
public reset(): void {
this.rev = 0;
// reset resets rev, wait, and buf.
public reset(newHistory?: WorkspaceOp[]): void {
this.rev = newHistory ? newHistory.length : 0;
this.wait = null;

@@ -24,0 +24,0 @@ this.buf = null;

@@ -6,3 +6,3 @@ import * as is from "../util/is";

import { ConsoleLogger, IConnection, createConnection } from "./connection";
import { OperationalTransformationHandler } from "./ot";
import { Handler } from "./handler";
import { InitializeError, InitializeParams, InitializeResult, InitializedNotification, MessageType, ServerCapabilities, ShowMessageRequest } from "./protocol";

@@ -452,3 +452,3 @@

if (this.capabilities.workspaceOperationalTransformation) {
this._registeredHandlers.get(OperationalTransformationHandler.id) !.register(connection);
this._registeredHandlers.get(Handler.id) !.register(connection);
} else {

@@ -455,0 +455,0 @@ this.logger.log("WARNING: server did not send workspaceOperationalTransformation capability");

import * as assert from "assert";
import { Client as OTClient } from "../ot/client";
import { Client } from "./client";
import { OperationalTransformationHandler, RefUpdateDownstreamRequest, RefUpdateDownstreamParams } from "./ot";
import { Handler, Workspace } from "./handler";
import { RefUpdateDownstreamRequest, RefUpdateDownstreamParams, WorkspaceWillSaveFileParams } from "./protocol";
import { assertResolved, createTestServer } from "./util";
import { WorkspaceOp } from "../ot/workspace";
describe("OperationalTransformationHandler", () => {
function mockWorkspace(): Workspace & { mockRecordOp: (op: WorkspaceOp) => void } {
let onOpListener: ((op: WorkspaceOp) => void) | undefined;
return {
apply(_op: WorkspaceOp): Promise<void> { throw new Error("not implemented"); },
reset(_history: WorkspaceOp[]): Promise<void> { return Promise.resolve(void 0); },
onOp(listener?: (op: WorkspaceOp) => void): void { onOpListener = listener; },
onReset(_listener?: (newOp?: WorkspaceOp) => void): void { /* noop */ },
onWillSaveFile(_listener?: (params: WorkspaceWillSaveFileParams) => Thenable<void>): void { /* noop */ },
dispose(): void { /* noop */ },
mockRecordOp(op: WorkspaceOp): void { onOpListener!(op); },
};
}
describe("Handler", () => {
it("ref/update", () => {
const { server, serverOptions } = createTestServer();
let ok = new Promise((resolve) => {
server.onRequest("ref/update", () => {
resolve();
server.onRequest("repo/watch", () => {
return server.sendRequest("ref/update", {
repo: "repo",
ref: "ref",
state: { gitBase: "c", gitBranch: "d" },
} as RefUpdateDownstreamParams);
});
let ok = new Promise((resolve, reject) => {
server.onRequest("ref/update", (params) => {
try {
assert.deepEqual(params, {
repo: "repo",
ref: "ref",
current: { gitBase: "c", gitBranch: "d", rev: 0 },
op: { head: "a" },
});
resolve();
} catch (err) {
reject(err);
}
return {};

@@ -20,12 +52,13 @@ });

const client = new Client(serverOptions, {});
const handler = new Handler(client);
client.registerHandler(Handler.id, handler);
const otClient = new OTClient();
const otHandler = new OperationalTransformationHandler(client, otClient);
otHandler.refIdentifier = { repo: "repo", ref: "ref" };
otHandler.refState = { gitBase: "c", gitBranch: "d" };
client.registerHandler(OperationalTransformationHandler.id, otHandler);
const workspace = mockWorkspace();
handler.attachWorkspace({ repo: "repo", ref: "ref" }, workspace);
return client.start().initialStart.then(() => {
otClient.record({ head: "a" });
return assertResolved(ok, "server did not receive 'recv' from client");
return handler.repoWatch({ repo: "repo", refspec: "*" }).then(() => {
workspace.mockRecordOp({ head: "a" });
return assertResolved(ok, "server did not receive 'ref/update' from client");
});
}, (err) => assert.ifError(err));

@@ -38,11 +71,10 @@ });

const client = new Client(serverOptions, {});
const handler = new Handler(client);
client.registerHandler(Handler.id, handler);
const otClient = new OTClient();
const otHandler = new OperationalTransformationHandler(client, otClient);
otHandler.refIdentifier = { repo: "repo", ref: "ref" };
otHandler.refState = { gitBase: "c", gitBranch: "d" };
client.registerHandler(OperationalTransformationHandler.id, otHandler);
const workspace = mockWorkspace();
handler.attachWorkspace({ repo: "repo", ref: "ref" }, workspace);
let ok = false;
otClient.ack = () => { ok = true; };
(handler as any).getRepo("repo").getRef("ref").ot.ack = () => { ok = true; };

@@ -49,0 +81,0 @@ return client.start().initialStart.then(() => {

import { NotificationType, NotificationType0, RequestType, RequestType0 } from "vscode-jsonrpc";
import { WorkspaceOp } from "../ot/workspace";
export enum StatusType {

@@ -251,1 +253,123 @@ StatusTypeError = 1,

}
export interface RefIdentifier {
repo: string;
ref: string;
}
export interface RefBaseInfo {
gitBase: string;
gitBranch: string;
}
export interface RefPointer extends RefBaseInfo {
rev: number;
}
export interface RefState extends RefBaseInfo {
history?: WorkspaceOp[]; // undefined is equivalent to empty array
}
export interface RefInfo extends RefIdentifier, RefBaseInfo {
rev: number;
target?: string;
watchers: string[];
}
export namespace RefListRequest {
export const type = new RequestType<void, RefInfo[], void, void>("ref/list");
}
export interface RepoWatchParams {
repo: string;
refspec: string;
}
export namespace RepoWatchRequest {
export const type = new RequestType<RepoWatchParams, void, void, void>("repo/watch");
}
export interface RefInfoResult {
state?: RefState;
target?: string;
}
export namespace RefInfoRequest {
export const type = new RequestType<RefIdentifier, RefInfoResult, void, void>("ref/info");
}
export interface RefUpdateDownstreamParams extends RefIdentifier {
current?: RefBaseInfo;
state?: RefState;
op?: WorkspaceOp;
ack?: boolean;
delete?: boolean;
}
export interface RefUpdateDownstreamResult { }
export namespace RefUpdateDownstreamRequest {
export const type = new RequestType<RefUpdateDownstreamParams, RefUpdateDownstreamResult, void, void>("ref/update");
}
export interface RefUpdateUpstreamParams extends RefIdentifier {
current?: RefPointer;
state?: RefState;
force?: boolean;
op?: WorkspaceOp;
delete?: boolean;
}
export interface RefUpdateUpstreamResult { }
export namespace RefUpdateUpstreamRequest {
export const type = new RequestType<RefUpdateUpstreamParams, RefUpdateUpstreamResult, void, void>("ref/update");
}
// Workspace
export interface WorkspaceIdentifier {
dir: string;
};
export interface WorkspaceAddParams extends WorkspaceIdentifier { }
export interface WorkspaceAddResult { }
export namespace WorkspaceAddRequest {
export const type = new RequestType<WorkspaceAddParams, WorkspaceAddResult, any, void>("workspace/add");
}
export interface WorkspaceRemoveParams extends WorkspaceIdentifier { }
export interface WorkspaceRemoveResult { }
export namespace WorkspaceRemoveRequest {
export const type = new RequestType<WorkspaceRemoveParams, WorkspaceRemoveResult, any, void>("workspace/remove");
}
export interface WorkspaceConfiguration {
syncTree?: boolean;
}
export interface WorkspaceConfigureParams extends WorkspaceIdentifier, WorkspaceConfiguration { }
export interface WorkspaceConfigureResult { }
export namespace WorkspaceConfigureRequest {
export const type = new RequestType<WorkspaceConfigureParams, WorkspaceConfigureResult, any, void>("workspace/configure");
}
export interface WorkspaceStatusParams extends WorkspaceIdentifier, WorkspaceConfiguration { }
export namespace WorkspaceStatusRequest {
export const type = new RequestType<WorkspaceStatusParams, ShowStatusParams, any, void>("workspace/status");
}
export interface WorkspaceWillSaveFileParams {
uri: string;
}
export namespace WorkspaceWillSaveFileRequest {
export const type = new RequestType<WorkspaceWillSaveFileParams, void, any, void>("workspace/willSaveFile");
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc