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

replicache

Package Overview
Dependencies
Maintainers
3
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replicache - npm Package Compare versions

Comparing version 0.5.0 to 0.5.2

1

out.cjs/mod.d.ts
export { default } from './replicache.js';
export { TransactionClosedError } from './transaction-closed-error.js';
/** @deprecated Use the wasmModule parameter to Replicache constructor instead */
export { REPMWasmInvoker } from './repm-invoker.js';

@@ -4,0 +5,0 @@ export type { Mutator } from './replicache.js';

@@ -7,3 +7,4 @@ "use strict";

Object.defineProperty(exports, "TransactionClosedError", { enumerable: true, get: function () { return transaction_closed_error_js_1.TransactionClosedError; } });
/** @deprecated Use the wasmModule parameter to Replicache constructor instead */
var repm_invoker_js_1 = require("./repm-invoker.js");
Object.defineProperty(exports, "REPMWasmInvoker", { enumerable: true, get: function () { return repm_invoker_js_1.REPMWasmInvoker; } });

27

out.cjs/replicache.d.ts

@@ -6,2 +6,3 @@ import type { JSONValue } from './json.js';

import type { ReadTransaction, WriteTransaction } from './transactions.js';
import type { InitInput } from './wasm/release/replicache_client.js';
export declare type Mutator<Return extends JSONValue | void, Args extends JSONValue> = (args: Args) => Promise<Return | void>;

@@ -15,2 +16,14 @@ declare type MutatorImpl<Return extends JSONValue | void, Args extends JSONValue> = (tx: WriteTransaction, args: Args) => Promise<Return>;

declare type MaybePromise<T> = T | Promise<T>;
interface ReplicacheOptions {
batchURL?: string;
dataLayerAuth?: string;
diffServerAuth?: string;
diffServerURL: string;
name?: string;
/** @deprecated Use wasmModule instead */
repmInvoker?: Invoker;
syncInterval?: number | null;
pushDelay?: number;
wasmModule?: InitInput | undefined;
}
export default class Replicache implements ReadTransaction {

@@ -44,12 +57,3 @@ private readonly _batchURL;

getDataLayerAuth: (() => MaybePromise<string | null | undefined>) | null | undefined;
constructor({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, repmInvoker, syncInterval, pushDelay, }: {
batchURL?: string;
dataLayerAuth?: string;
diffServerAuth?: string;
diffServerURL: string;
name?: string;
repmInvoker?: Invoker;
syncInterval?: number | null;
pushDelay?: number;
});
constructor({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, repmInvoker, syncInterval, pushDelay, wasmModule, }: ReplicacheOptions);
private _open;

@@ -159,3 +163,3 @@ get online(): boolean;

export declare class ReplicacheTest extends Replicache {
static new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, repmInvoker, }: {
static new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, }: {
diffServerURL: string;

@@ -166,3 +170,2 @@ batchURL?: string;

name?: string;
repmInvoker: Invoker;
}): Promise<ReplicacheTest>;

@@ -169,0 +172,0 @@ beginSync(): Promise<BeginSyncResult>;

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

class Replicache {
constructor({ batchURL = '', dataLayerAuth = '', diffServerAuth = '', diffServerURL, name = 'default', repmInvoker = new repm_invoker_js_1.REPMWasmInvoker(), syncInterval = 60000, pushDelay = 300, }) {
constructor({ batchURL = '', dataLayerAuth = '', diffServerAuth = '', diffServerURL, name = 'default', repmInvoker, syncInterval = 60000, pushDelay = 300, wasmModule, }) {
this._closed = false;

@@ -45,3 +45,3 @@ this._online = true;

this._name = name;
this._repmInvoker = repmInvoker;
this._repmInvoker = repmInvoker !== null && repmInvoker !== void 0 ? repmInvoker : new repm_invoker_js_1.REPMWasmInvoker(wasmModule);
this._syncInterval = syncInterval;

@@ -250,3 +250,2 @@ this.pushDelay = pushDelay;

const { original } = mutation;
console.log('parsing', mutation.args);
syncHead = await this._replay(syncHead, original, mutation.name, JSON.parse(mutation.args));

@@ -449,3 +448,3 @@ }

class ReplicacheTest extends Replicache {
static async new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name = '', repmInvoker, }) {
static async new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name = '', }) {
const rep = new ReplicacheTest({

@@ -457,3 +456,2 @@ batchURL,

name,
repmInvoker,
syncInterval: null,

@@ -460,0 +458,0 @@ });

@@ -37,3 +37,2 @@ "use strict";

let rep2 = null;
const wasmInvoker = new mod_js_1.REPMWasmInvoker();
async function replicacheForTesting(name, { diffServerURL = '', dataLayerAuth = '', diffServerAuth = '', batchURL = '', } = {}) {

@@ -47,3 +46,2 @@ dbsToDrop.add(name);

name,
repmInvoker: wasmInvoker,
});

@@ -65,2 +63,7 @@ }

}
function spyInvoke(rep) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return sinon.spy(rep, '_invoke');
}
teardown(async () => {

@@ -491,8 +494,4 @@ client_js_1.default.restore();

test('sync2', async () => {
sinon.spy(wasmInvoker, 'invoke');
rep = await replicacheForTesting('sync2', {
batchURL: 'https://replicache-sample-todo.now.sh/serve/replicache-batch',
dataLayerAuth: '1',
diffServerAuth: '1',
});
rep = await replicacheForTesting('sync2');
const spy = spyInvoke(rep);
const s1 = rep.sync();

@@ -502,4 +501,4 @@ const s2 = rep.sync();

await s2;
const calls = wasmInvoker.invoke.args;
const syncCalls = calls.filter(([, rpc]) => rpc === 'beginSync').length;
const calls = spy.args;
const syncCalls = calls.filter(([rpc]) => rpc === 'beginSync').length;
chai_1.expect(syncCalls).to.equal(2);

@@ -548,3 +547,2 @@ });

syncInterval: 12.34,
repmInvoker: wasmInvoker,
diffServerURL: 'xxx',

@@ -556,3 +554,2 @@ });

test('closeTransaction after rep.scan', async () => {
sinon.spy(wasmInvoker, 'invoke');
rep = await replicacheForTesting('test5');

@@ -564,7 +561,7 @@ const add = rep.register('add-data', addData);

});
const invokeSpy = wasmInvoker.invoke;
invokeSpy.resetHistory();
const spy = spyInvoke(rep);
spy.resetHistory();
function expectCalls(log) {
chai_1.expect(log).to.eql(log);
const rpcs = invokeSpy.args.map(([, rpc]) => rpc);
const rpcs = spy.args.map(([rpc]) => rpc);
chai_1.expect(rpcs).to.eql(['openTransaction', 'scan', 'closeTransaction']);

@@ -580,3 +577,3 @@ }

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
await (async () => {

@@ -595,3 +592,3 @@ if (!rep) {

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
{

@@ -607,3 +604,3 @@ const it = rep.scan();

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
(await expectPromiseToReject((async () => {

@@ -622,3 +619,3 @@ if (!rep) {

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
(await expectPromiseToReject((async () => {

@@ -625,0 +622,0 @@ if (!rep) {

export { default } from './replicache.js';
export { TransactionClosedError } from './transaction-closed-error.js';
/** @deprecated Use the wasmModule parameter to Replicache constructor instead */
export { REPMWasmInvoker } from './repm-invoker.js';

@@ -4,0 +5,0 @@ export type { Mutator } from './replicache.js';

export { default } from './replicache.js';
export { TransactionClosedError } from './transaction-closed-error.js';
/** @deprecated Use the wasmModule parameter to Replicache constructor instead */
export { REPMWasmInvoker } from './repm-invoker.js';

@@ -6,2 +6,3 @@ import type { JSONValue } from './json.js';

import type { ReadTransaction, WriteTransaction } from './transactions.js';
import type { InitInput } from './wasm/release/replicache_client.js';
export declare type Mutator<Return extends JSONValue | void, Args extends JSONValue> = (args: Args) => Promise<Return | void>;

@@ -15,2 +16,14 @@ declare type MutatorImpl<Return extends JSONValue | void, Args extends JSONValue> = (tx: WriteTransaction, args: Args) => Promise<Return>;

declare type MaybePromise<T> = T | Promise<T>;
interface ReplicacheOptions {
batchURL?: string;
dataLayerAuth?: string;
diffServerAuth?: string;
diffServerURL: string;
name?: string;
/** @deprecated Use wasmModule instead */
repmInvoker?: Invoker;
syncInterval?: number | null;
pushDelay?: number;
wasmModule?: InitInput | undefined;
}
export default class Replicache implements ReadTransaction {

@@ -44,12 +57,3 @@ private readonly _batchURL;

getDataLayerAuth: (() => MaybePromise<string | null | undefined>) | null | undefined;
constructor({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, repmInvoker, syncInterval, pushDelay, }: {
batchURL?: string;
dataLayerAuth?: string;
diffServerAuth?: string;
diffServerURL: string;
name?: string;
repmInvoker?: Invoker;
syncInterval?: number | null;
pushDelay?: number;
});
constructor({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, repmInvoker, syncInterval, pushDelay, wasmModule, }: ReplicacheOptions);
private _open;

@@ -159,3 +163,3 @@ get online(): boolean;

export declare class ReplicacheTest extends Replicache {
static new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, repmInvoker, }: {
static new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name, }: {
diffServerURL: string;

@@ -166,3 +170,2 @@ batchURL?: string;

name?: string;
repmInvoker: Invoker;
}): Promise<ReplicacheTest>;

@@ -169,0 +172,0 @@ beginSync(): Promise<BeginSyncResult>;

@@ -8,3 +8,3 @@ import { REPMWasmInvoker, } from './repm-invoker.js';

export default class Replicache {
constructor({ batchURL = '', dataLayerAuth = '', diffServerAuth = '', diffServerURL, name = 'default', repmInvoker = new REPMWasmInvoker(), syncInterval = 60000, pushDelay = 300, }) {
constructor({ batchURL = '', dataLayerAuth = '', diffServerAuth = '', diffServerURL, name = 'default', repmInvoker, syncInterval = 60000, pushDelay = 300, wasmModule, }) {
this._closed = false;

@@ -42,3 +42,3 @@ this._online = true;

this._name = name;
this._repmInvoker = repmInvoker;
this._repmInvoker = repmInvoker !== null && repmInvoker !== void 0 ? repmInvoker : new REPMWasmInvoker(wasmModule);
this._syncInterval = syncInterval;

@@ -247,3 +247,2 @@ this.pushDelay = pushDelay;

const { original } = mutation;
console.log('parsing', mutation.args);
syncHead = await this._replay(syncHead, original, mutation.name, JSON.parse(mutation.args));

@@ -445,3 +444,3 @@ }

export class ReplicacheTest extends Replicache {
static async new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name = '', repmInvoker, }) {
static async new({ batchURL, dataLayerAuth, diffServerAuth, diffServerURL, name = '', }) {
const rep = new ReplicacheTest({

@@ -453,3 +452,2 @@ batchURL,

name,
repmInvoker,
syncInterval: null,

@@ -456,0 +454,0 @@ });

import { ReplicacheTest, httpStatusUnauthorized } from './replicache.js';
import Replicache, { REPMWasmInvoker, TransactionClosedError, } from './mod.js';
import Replicache, { TransactionClosedError } from './mod.js';
import { restoreScanPageSizeForTesting, setScanPageSizeForTesting, } from './scan-iterator.js';

@@ -13,3 +13,2 @@ import { assert, expect } from '@esm-bundle/chai';

let rep2 = null;
const wasmInvoker = new REPMWasmInvoker();
async function replicacheForTesting(name, { diffServerURL = '', dataLayerAuth = '', diffServerAuth = '', batchURL = '', } = {}) {

@@ -23,3 +22,2 @@ dbsToDrop.add(name);

name,
repmInvoker: wasmInvoker,
});

@@ -41,2 +39,7 @@ }

}
function spyInvoke(rep) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return sinon.spy(rep, '_invoke');
}
teardown(async () => {

@@ -467,8 +470,4 @@ fetchMock.restore();

test('sync2', async () => {
sinon.spy(wasmInvoker, 'invoke');
rep = await replicacheForTesting('sync2', {
batchURL: 'https://replicache-sample-todo.now.sh/serve/replicache-batch',
dataLayerAuth: '1',
diffServerAuth: '1',
});
rep = await replicacheForTesting('sync2');
const spy = spyInvoke(rep);
const s1 = rep.sync();

@@ -478,4 +477,4 @@ const s2 = rep.sync();

await s2;
const calls = wasmInvoker.invoke.args;
const syncCalls = calls.filter(([, rpc]) => rpc === 'beginSync').length;
const calls = spy.args;
const syncCalls = calls.filter(([rpc]) => rpc === 'beginSync').length;
expect(syncCalls).to.equal(2);

@@ -524,3 +523,2 @@ });

syncInterval: 12.34,
repmInvoker: wasmInvoker,
diffServerURL: 'xxx',

@@ -532,3 +530,2 @@ });

test('closeTransaction after rep.scan', async () => {
sinon.spy(wasmInvoker, 'invoke');
rep = await replicacheForTesting('test5');

@@ -540,7 +537,7 @@ const add = rep.register('add-data', addData);

});
const invokeSpy = wasmInvoker.invoke;
invokeSpy.resetHistory();
const spy = spyInvoke(rep);
spy.resetHistory();
function expectCalls(log) {
expect(log).to.eql(log);
const rpcs = invokeSpy.args.map(([, rpc]) => rpc);
const rpcs = spy.args.map(([rpc]) => rpc);
expect(rpcs).to.eql(['openTransaction', 'scan', 'closeTransaction']);

@@ -556,3 +553,3 @@ }

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
await (async () => {

@@ -571,3 +568,3 @@ if (!rep) {

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
{

@@ -583,3 +580,3 @@ const it = rep.scan();

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
(await expectPromiseToReject((async () => {

@@ -598,3 +595,3 @@ if (!rep) {

log.length = 0;
invokeSpy.resetHistory();
spy.resetHistory();
(await expectPromiseToReject((async () => {

@@ -601,0 +598,0 @@ if (!rep) {

{
"name": "replicache",
"description": "Offline-First for Every Application",
"version": "0.5.0",
"version": "0.5.2",
"repository": "github:rocicorp/replicache-sdk-js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -9,4 +9,8 @@ # Replicache JS SDK

This tutorial walks through creating a basic offline-first todo app with [Replicache](https://replicache.dev/). If you have any problems or questions, please [join us on Slack](https://join.slack.com/t/rocicorp/shared_invite/zt-h8ygwu8j-RVniv5XsBps0Q9oJXdMyoA). We'd be happy to help.
This tutorial walks through creating the UI for a basic [Replicache](https://replicache.dev/)-powered todo list.
It relies on the [replicache-sample-todo](https://github.com/rocicorp/replicache-sample-todo) backend. To learn how to setup you own Replicache backend, see [Server Side Setup](https://github.com/rocicorp/replicache#server-side).
If you have any problems or questions, please [join us on Slack](https://join.slack.com/t/rocicorp/shared_invite/zt-h8ygwu8j-RVniv5XsBps0Q9oJXdMyoA). We'd be happy to help.
You can also skip to the end and [check out the full working version of this sample](https://github.com/rocicorp/replicache-sdk-js/tree/master/sample/cal).

@@ -115,4 +119,4 @@

- [Check out the full version of this sample](https://github.com/rocicorp/replicache-sdk-js/tree/master/sample/lit-todo)
- [Learn how to build your own backend integration](https://github.com/rocicorp/replicache#server-side)
- [Learn how to add Replicache support to your own backend service](https://github.com/rocicorp/replicache#server-side)
- [Check out the richer React/Babel/GCal sample](https://github.com/rocicorp/replicache-sdk-js/tree/master/sample/cal)
- [Browse the full JS documentation](https://replicache-sdk-js.now.sh/)

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