🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@based/client

Package Overview
Dependencies
Maintainers
7
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@based/client - npm Package Compare versions

Comparing version

to
6.1.0

3

dist/src/channel/index.d.ts
import { BasedClient } from '../index.js';
import { ChannelMessageFunction } from '../types/index.js';
import { BasedError } from '@based/errors';
export declare class BasedChannel<P = any, K = any> {

@@ -10,4 +9,4 @@ id: number;

constructor(client: BasedClient, name: string, payload: P);
subscribe(onMessage: ChannelMessageFunction, onError?: (err: BasedError) => void): () => void;
subscribe(onMessage: ChannelMessageFunction, onError?: (err: Error) => void): () => void;
publish(message: K): void;
}

@@ -11,5 +11,7 @@ import { inflateSync } from 'fflate';

import { freeCacheMemory } from '../cache.js';
import { convertDataToBasedError } from '@based/errors';
import { convertDataToBasedError } from '@based/errors/client';
const decodeAndDeflate = (start, end, isDeflate, buffer) => {
return new TextDecoder().decode(isDeflate ? inflateSync(buffer.slice(start, end)) : buffer.slice(start, end));
return new TextDecoder().decode(isDeflate
? inflateSync(buffer.slice(start, end))
: buffer.slice(start, end));
};

@@ -16,0 +18,0 @@ export const incoming = async (client, data) => {

@@ -6,2 +6,15 @@ import { BasedClient } from './index.js';

};
export declare const createCacheScriptTag: (client: BasedClient) => string;
export declare const createCacheObjectFiltered: (client: BasedClient, queries?: {
endpoint: string;
payload?: any;
}[]) => {
[key: string]: CacheValue;
};
export declare const createInlineFromCurrentCache: (client: BasedClient, queries?: {
endpoint: string;
payload?: any;
}[]) => string;
export declare const createInlineCache: (client: BasedClient, queries: {
endpoint: string;
payload?: any;
}[]) => Promise<string>;

@@ -0,1 +1,2 @@

import { genObserveId } from './genObserveId.js';
export const createCacheObject = (client) => {

@@ -8,5 +9,27 @@ const m = {};

};
export const createCacheScriptTag = (client) => {
export const createCacheObjectFiltered = (client, queries) => {
const m = {};
for (const q of queries) {
const key = genObserveId(q.endpoint, q.payload);
if (client.cache.has(key)) {
m[key] = client.cache.get(key);
}
}
return m;
};
export const createInlineFromCurrentCache = (client, queries) => {
if (queries) {
return `<script>window.__basedcache__=${JSON.stringify(createCacheObjectFiltered(client, queries))}</script>`;
}
return `<script>window.__basedcache__=${JSON.stringify(createCacheObject(client))}</script>`;
};
export const createInlineCache = async (client, queries) => {
const m = {};
await Promise.all(queries.map(async ({ endpoint, payload }) => {
const query = client.query(endpoint, payload);
await query.get();
m[query.id] = client.cache.get(query.id);
}));
return `<script>window.__basedcache__=${JSON.stringify(m)}</script>`;
};
//# sourceMappingURL=ssr.js.map

@@ -72,3 +72,3 @@ import { addStreamChunk, addStreamRegister } from '../outgoing/index.js';

const dcHandler = () => {
console.error('CLIENT DC -> ABORT STREAM', Date.now(), id);
// console.error('CLIENT DC -> ABORT STREAM', Date.now(), id)
};

@@ -75,0 +75,0 @@ client.once('disconnect', dcHandler);

@@ -136,3 +136,3 @@ import { Readable, Writable } from "stream";

// HANDLE THIS
console.error("CLIENT DC -> ABORT STREAM", Date.now(), id);
// console.error("CLIENT DC -> ABORT STREAM", Date.now(), id);
};

@@ -139,0 +139,0 @@ client.once("disconnect", dcHandler);

@@ -1,2 +0,2 @@

import { BasedError } from '@based/errors';
import { BasedError } from '@based/errors/client';
export type ChannelMessageFunction<K = any> = (message: K) => void;

@@ -3,0 +3,0 @@ export type ChannelType = 5 | 7;

@@ -1,2 +0,2 @@

import { BasedError } from '@based/errors';
import { BasedError } from '@based/errors/client';
export type ObserveOpts = {

@@ -3,0 +3,0 @@ localStorage?: boolean;

{
"name": "@based/client",
"version": "6.0.1",
"version": "6.1.0",
"license": "MIT",
"scripts": {
"build": "npx tsc && cp ./dist/src/index.d.ts ./dist/src/index_original.d.ts",
"test-stream": "npx ts-node ./test/browser/upload-file.ts",
"watch": "npx tsc --watch",
"clean": "rimraf {.turbo,dist,node_modules}",
"test": "npx ava",
"microBuild": "microbundle -i dist/src/index.js -o test/browser/bundle.js --no-pkg-main -f modern --visualize",
"browserBuildConsole": "esbuild ./test/browser/index.ts --bundle --outfile=./test/browser/out.js --minify --metafile=./test/browser/meta.json --define:global=window",
"browserBuild": "esbuild ./test/browser/index.ts --bundle --outfile=./test/browser/out.js --minify --metafile=./test/browser/meta.json --define:global=window",
"browser": "node ./test/browser/server.js"
"test": "npx ava"
},

@@ -27,3 +22,3 @@ "type": "module",

"ava": {
"timeout": "4m",
"timeout": "10m",
"workerThreads": false,

@@ -40,7 +35,7 @@ "files": [

"dependencies": {
"@saulx/diff": "^2.0.1",
"@saulx/diff": "^2.0.2",
"@saulx/hash": "^3.0.0",
"@saulx/utils": "^4.3.2",
"@saulx/utils": "^5.0.0",
"@based/fetch": "^2.0.3",
"@based/errors": "^1.2.0",
"@based/errors": "^1.3.0",
"@based/opts": "^1.0.0",

@@ -53,7 +48,5 @@ "fflate": "0.8.1",

"get-port": "7.0.0",
"microbundle": "^0.15.1",
"esbuild": "^0.19.5",
"@aws-sdk/lib-storage": "^3.304.0",
"@aws-sdk/client-s3": "^3.304.0",
"@based/functions": "^3.0.1",
"@based/functions": "^3.0.2",
"cross-fetch": "4.0.0",

@@ -64,2 +57,2 @@ "ava": "5.3.1",

}
}
}

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