@idb-orm/react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +3 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.es.js +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright 2025 jtb
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.clientProviderFactory=function(t){const r=e.createContext(null);return{Context:r,useDbClient:()=>{const t=e.useContext(r);if(!t)throw new Error("Client Context not found. Please ensure this component is wrapped in a <DbClientProvider /> component.");return t},DbClientProvider:({fallback:n,children:o,version:i})=>{const[c,l]=e.useState(null);return e.useEffect(()=>{t.createClientAsync(i).then(e=>{l(e)}).catch(e=>{throw new Error(`@idb-orm Client Creation Failed: ${e}`)})},[i]),c?React.createElement(r.Provider,{value:c},o):n}}};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode, Context } from 'react';
|
|
2
|
+
import { core } from '@idb-orm/core';
|
|
3
|
+
export interface ClientProviderProps<Name extends string, ModelNames extends string, Models extends core.CollectionObject<ModelNames>> {
|
|
4
|
+
/**
|
|
5
|
+
* `CompiledDb` object
|
|
6
|
+
*/
|
|
7
|
+
db: core.CompiledDb<Name, ModelNames, Models>;
|
|
8
|
+
/**
|
|
9
|
+
* React node to render while the client is being built
|
|
10
|
+
* @default undefined
|
|
11
|
+
*/
|
|
12
|
+
fallback?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Version of the IDB Database
|
|
15
|
+
* @default 1
|
|
16
|
+
*/
|
|
17
|
+
version?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ClientProviderFactoryReturn<Name extends string, ModelNames extends string, Models extends core.CollectionObject<ModelNames>> {
|
|
20
|
+
Context: Context<core.DbClient<Name, ModelNames, Models> | null>;
|
|
21
|
+
useDbClient: () => core.DbClient<Name, ModelNames, Models>;
|
|
22
|
+
DbClientProvider: (props: PropsWithChildren<ClientProviderProps<Name, ModelNames, Models>>) => ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export declare function clientProviderFactory<Name extends string, ModelNames extends string, Models extends core.CollectionObject<ModelNames>>(db: core.CompiledDb<Name, ModelNames, Models>): ClientProviderFactoryReturn<Name, ModelNames, Models>;
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as e,useState as n,useEffect as t,useContext as r}from"react";function o(o){const i=e(null);return{Context:i,useDbClient:()=>{const e=r(i);if(!e)throw new Error("Client Context not found. Please ensure this component is wrapped in a <DbClientProvider /> component.");return e},DbClientProvider:({fallback:e,children:r,version:l})=>{const[c,a]=n(null);return t(()=>{o.createClientAsync(l).then(e=>{a(e)}).catch(e=>{throw new Error(`@idb-orm Client Creation Failed: ${e}`)})},[l]),c?/* @__PURE__ */React.createElement(i.Provider,{value:c},r):e}}}export{o as clientProviderFactory};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@idb-orm/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An adapter for the React framework for @idb-orm",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"build-test": "vite --config vite.config-test.ts build"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"typescript",
|
|
12
|
+
"react",
|
|
13
|
+
"adapter",
|
|
14
|
+
"idb-orm"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.es.js",
|
|
20
|
+
"require": "./dist/index.cjs.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"author": "jtb",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@idb-orm/core": "^1.0.7",
|
|
27
|
+
"react": "^19.2.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/js": "^9.38.0",
|
|
31
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
32
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
33
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
34
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
35
|
+
"@types/node": "^24.9.1",
|
|
36
|
+
"@types/react": "^19.2.7",
|
|
37
|
+
"eslint": "^9.38.0",
|
|
38
|
+
"rollup": "^4.52.4",
|
|
39
|
+
"serve": "^14.2.5",
|
|
40
|
+
"tslib": "^2.8.1",
|
|
41
|
+
"typescript": "^5.9.3",
|
|
42
|
+
"typescript-eslint": "^8.46.2",
|
|
43
|
+
"vite": "^7.2.4",
|
|
44
|
+
"vite-plugin-dts": "^4.5.4"
|
|
45
|
+
}
|
|
46
|
+
}
|