@fencyai/react 0.1.7 → 0.1.8
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/dist/index.cjs +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +7 -0
- package/package.json +4 -3
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var v=(e,n)=>{for(var r in n)y(e,r,{get:n[r],enumerable:!0})},I=(e,n,r,c)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of C(n))!P.call(e,o)&&o!==r&&y(e,o,{get:()=>n[o],enumerable:!(c=m(n,o))||c.enumerable});return e};var E=e=>I(y({},"__esModule",{value:!0}),e);var h={};v(h,{FencyProvider:()=>F,useFency:()=>a});module.exports=E(h);var t=require("react"),p=require("react/jsx-runtime"),u=(0,t.createContext)(void 0);function F({fency:e,children:n}){let[r,c]=(0,t.useState)(null),[o,i]=(0,t.useState)(!0),[l,d]=(0,t.useState)(null);if((0,t.useEffect)(()=>{e.then(s=>{c(s),i(!1)}).catch(s=>{d(s),i(!1)})},[e]),!r)return null;let x={fency:r,loading:o,error:l};return(0,p.jsx)(u.Provider,{value:x,children:n})}var f=require("react");function a(){let e=(0,f.useContext)(u);if(e===void 0)throw new Error("useFency must be used within a FencyProvider");return e}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
import{createContext as f,useEffect as a,useState as t}from"react";import{jsx as d}from"react/jsx-runtime";var r=f(void 0);function l({fency:e,children:s}){let[o,y]=t(null),[u,c]=t(!0),[i,F]=t(null);if(a(()=>{e.then(n=>{y(n),c(!1)}).catch(n=>{F(n),c(!1)})},[e]),!o)return null;let p={fency:o,loading:u,error:i};return d(r.Provider,{value:p,children:s})}import{useContext as x}from"react";function m(){let e=x(r);if(e===void 0)throw new Error("useFency must be used within a FencyProvider");return e}export{l as FencyProvider,m as useFency};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/FencyProvider.tsx", "../src/useFency.ts"],
|
|
4
|
+
"sourcesContent": ["import { createContext, useEffect, useState } from 'react';\nimport type { FencyContext, FencyInstance, FencyProviderProps } from './types';\n\n// Create the context\nexport const FencyContextValue = createContext<FencyContext | undefined>(undefined);\n\n/**\n * Provider component that provides Fency instance to child components\n * Expects a promise that resolves to a Fency instance\n */\nexport function FencyProvider({ fency, children }: FencyProviderProps) {\n const [fencyInstance, setFencyInstance] = useState<FencyInstance | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n fency\n .then((instance: FencyInstance) => {\n setFencyInstance(instance);\n setLoading(false);\n })\n .catch((err: Error) => {\n setError(err);\n setLoading(false);\n });\n }, [fency]);\n\n // Only render children and provide context when fency is loaded\n if (!fencyInstance) {\n return null;\n }\n\n const value: FencyContext = {\n fency: fencyInstance,\n loading,\n error,\n };\n\n return (\n <FencyContextValue.Provider value={value}>\n {children}\n </FencyContextValue.Provider>\n );\n} ", "import { useContext } from 'react';\nimport type { FencyContext } from './types';\nimport { FencyContextValue } from './FencyProvider';\n\n/**\n * Hook to access Fency instance and loading state\n */\nexport function useFency(): FencyContext {\n const context = useContext(FencyContextValue);\n if (context === undefined) {\n throw new Error('useFency must be used within a FencyProvider');\n }\n return context;\n} "],
|
|
5
|
+
"mappings": "AAAA,OAAS,iBAAAA,EAAe,aAAAC,EAAW,YAAAC,MAAgB,QAuC/C,cAAAC,MAAA,oBAnCG,IAAMC,EAAoBJ,EAAwC,MAAS,EAM3E,SAASK,EAAc,CAAE,MAAAC,EAAO,SAAAC,CAAS,EAAuB,CACrE,GAAM,CAACC,EAAeC,CAAgB,EAAIP,EAA+B,IAAI,EACvE,CAACQ,EAASC,CAAU,EAAIT,EAAS,EAAI,EACrC,CAACU,EAAOC,CAAQ,EAAIX,EAAuB,IAAI,EAerD,GAbAD,EAAU,IAAM,CACdK,EACG,KAAMQ,GAA4B,CACjCL,EAAiBK,CAAQ,EACzBH,EAAW,EAAK,CAClB,CAAC,EACA,MAAOI,GAAe,CACrBF,EAASE,CAAG,EACZJ,EAAW,EAAK,CAClB,CAAC,CACL,EAAG,CAACL,CAAK,CAAC,EAGN,CAACE,EACH,OAAO,KAGT,IAAMQ,EAAsB,CAC1B,MAAOR,EACP,QAAAE,EACA,MAAAE,CACF,EAEA,OACET,EAACC,EAAkB,SAAlB,CAA2B,MAAOY,EAChC,SAAAT,EACH,CAEJ,CC3CA,OAAS,cAAAU,MAAkB,QAOpB,SAASC,GAAyB,CACvC,IAAMC,EAAUC,EAAWC,CAAiB,EAC5C,GAAIF,IAAY,OACd,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT",
|
|
6
|
+
"names": ["createContext", "useEffect", "useState", "jsx", "FencyContextValue", "FencyProvider", "fency", "children", "fencyInstance", "setFencyInstance", "loading", "setLoading", "error", "setError", "instance", "err", "value", "useContext", "useFency", "context", "useContext", "FencyContextValue"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "React components for Fency integration",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
12
13
|
"types": "./dist/index.d.ts"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"dist"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
|
-
"build": "tsc && esbuild
|
|
20
|
+
"build": "tsc && node esbuild.config.js",
|
|
20
21
|
"dev": "tsc --watch",
|
|
21
22
|
"clean": "rm -rf dist",
|
|
22
23
|
"prepublishOnly": "npm run clean && npm run build",
|