Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@instantdb/react

Package Overview
Dependencies
Maintainers
2
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@instantdb/react - npm Package Compare versions

Comparing version 0.3.38 to 0.3.39

dist/datalog.d.ts

10

dist/index.d.ts

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

import { instatx, Config, transact as transactCore } from "@instantdb/core";
import * as instatx from "./instatx";
export declare function getDB(): any;
type Config = {
appId: string;
websocketURI: string;
};
export declare function init(config: Config): any;

@@ -6,3 +11,4 @@ export declare function useQuery(query: any): any;

export declare const tx: instatx.EmptyChunk;
export declare const transact: typeof transactCore;
export declare function transact(chunks: instatx.TransactionChunk | instatx.TransactionChunk[]): any;
export {};
//# sourceMappingURL=index.d.ts.map

71

dist/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.transact = exports.tx = exports.id = exports.useQuery = exports.init = void 0;
const core_1 = require("@instantdb/core");
exports.transact = exports.tx = exports.id = exports.useQuery = exports.init = exports.getDB = void 0;
const error_1 = require("./utils/error");
const ReactiveDB_1 = __importDefault(require("./ReactiveDB"));
const react_1 = require("react");
const weakHash_1 = __importDefault(require("./utils/weakHash"));
const instatx = __importStar(require("./instatx"));
const uuid_1 = __importDefault(require("./utils/uuid"));
let _GLOBAL_DB;
function getDB() {
(0, error_1.assert)(_GLOBAL_DB, "Uh oh! Looks like `init` hasn't run yet. Make sure `init` runs " +
"before your first `useQuery` or `transact`.");
return _GLOBAL_DB;
}
exports.getDB = getDB;
function init(config) {
return (0, core_1.init)(config);
// (XXX): This is some hackery, to make
// sure that during HMR, we don't
// create multiple instances of the DB
let _prev;
if (typeof window !== "undefined") {
_prev = window._GLOBAL_DB;
}
if (!_GLOBAL_DB) {
_GLOBAL_DB = _prev || new ReactiveDB_1.default(config);
if (typeof window !== "undefined") {
window._GLOBAL_DB = _GLOBAL_DB;
}
}
return _GLOBAL_DB;
}
exports.init = init;
function useQuery(query) {
const db = (0, core_1.getDB)();
// (XXX): Don't set `isLoading` true if we already have data, would
// be better to immediately show loaded data
const db = getDB();
const [state, setState] = (0, react_1.useState)({ isLoading: true });

@@ -21,9 +69,12 @@ (0, react_1.useEffect)(() => {

return unsub;
}, [(0, core_1.weakHash)(query)]);
}, [(0, weakHash_1.default)(query)]);
return state;
}
exports.useQuery = useQuery;
exports.id = core_1.uuid;
exports.tx = core_1.instatx.tx;
exports.transact = core_1.transact;
exports.id = uuid_1.default;
exports.tx = instatx.tx;
function transact(chunks) {
return getDB().pushTx(chunks);
}
exports.transact = transact;
//# sourceMappingURL=index.js.map

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

import { instatx, Config, transact as transactCore } from "@instantdb/core";
import * as instatx from "./instatx";
export declare function getDB(): any;
type Config = {
appId: string;
websocketURI: string;
};
export declare function init(config: Config): any;

@@ -6,3 +11,4 @@ export declare function useQuery(query: any): any;

export declare const tx: instatx.EmptyChunk;
export declare const transact: typeof transactCore;
export declare function transact(chunks: instatx.TransactionChunk | instatx.TransactionChunk[]): any;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,10 +0,31 @@

import { getDB, weakHash, instatx, uuid, init as initCore, transact as transactCore, } from "@instantdb/core";
import { assert } from "./utils/error";
import ReactiveDB from "./ReactiveDB";
import { useEffect, useState } from "react";
import weakHash from "./utils/weakHash";
import * as instatx from "./instatx";
import uuid from "./utils/uuid";
let _GLOBAL_DB;
export function getDB() {
assert(_GLOBAL_DB, "Uh oh! Looks like `init` hasn't run yet. Make sure `init` runs " +
"before your first `useQuery` or `transact`.");
return _GLOBAL_DB;
}
export function init(config) {
return initCore(config);
// (XXX): This is some hackery, to make
// sure that during HMR, we don't
// create multiple instances of the DB
let _prev;
if (typeof window !== "undefined") {
_prev = window._GLOBAL_DB;
}
if (!_GLOBAL_DB) {
_GLOBAL_DB = _prev || new ReactiveDB(config);
if (typeof window !== "undefined") {
window._GLOBAL_DB = _GLOBAL_DB;
}
}
return _GLOBAL_DB;
}
export function useQuery(query) {
const db = getDB();
// (XXX): Don't set `isLoading` true if we already have data, would
// be better to immediately show loaded data
const [state, setState] = useState({ isLoading: true });

@@ -22,3 +43,5 @@ useEffect(() => {

export const tx = instatx.tx;
export const transact = transactCore;
export function transact(chunks) {
return getDB().pushTx(chunks);
}
//# sourceMappingURL=index.js.map
{
"name": "@instantdb/react",
"version": "0.3.38",
"version": "0.3.39",
"description": "Instant DB for React",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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