@nemme/js-sdk 1.0.0 → 1.1.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/CHANGELOG.md +34 -0
- package/README.md +25 -3
- package/dist/chunks/{chunk-CZZ4p3Yf.js → chunk-DWNI8pZO.js} +1 -1
- package/dist/chunks/{client-D6k2IoC6.js → client-CKvtSbpa.js} +13 -7
- package/dist/chunks/{client-D6k2IoC6.js.map → client-CKvtSbpa.js.map} +1 -1
- package/dist/chunks/{client-BYPXJmEU.js → client-Db2ZE5y9.js} +2 -2
- package/dist/chunks/{client-BYPXJmEU.js.map → client-Db2ZE5y9.js.map} +1 -1
- package/dist/chunks/{config-C6VpkZGH.js → config-DCrsd6gZ.js} +1 -1
- package/dist/chunks/{config-C6VpkZGH.js.map → config-DCrsd6gZ.js.map} +1 -1
- package/dist/chunks/{config-BnABfG_n.js → config-hiNBGctX.js} +2 -2
- package/dist/chunks/{config-BnABfG_n.js.map → config-hiNBGctX.js.map} +1 -1
- package/dist/chunks/form-manager-BG1qr31N.js +12 -0
- package/dist/chunks/form-manager-BG1qr31N.js.map +1 -0
- package/dist/chunks/{form-manager-BqtPAs-A.js → form-manager-Dit5tdsl.js} +112 -104
- package/dist/chunks/form-manager-Dit5tdsl.js.map +1 -0
- package/dist/client.d.ts +6 -1
- package/dist/forms.cjs +1 -1
- package/dist/forms.esm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/js-sdk.css +2 -1
- package/dist/nemme-sdk.umd.js +7 -7
- package/dist/nemme-sdk.umd.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.esm.js +1 -1
- package/dist/react.esm.js.map +1 -1
- package/dist/utils/safe-url.d.ts +1 -0
- package/package.json +16 -15
- package/dist/chunks/form-manager-3PwpV6gK.js +0 -12
- package/dist/chunks/form-manager-3PwpV6gK.js.map +0 -1
- package/dist/chunks/form-manager-BqtPAs-A.js.map +0 -1
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunks/chunk-DWNI8pZO.js"),t=require("./chunks/client-Db2ZE5y9.js");let n=require("react");n=e.n(n,1);let r=require("react/jsx-runtime");var i=(0,n.createContext)(void 0);function a(e,t){switch(t.type){case`reset`:return{client:null,isInitialized:!1,error:null};case`success`:return{client:t.client,isInitialized:t.initialized,error:t.error};case`error`:return{client:null,isInitialized:!1,error:t.error}}}var o=({clientKey:e,config:o,children:s})=>{let[c,l]=(0,n.useReducer)(a,{client:null,isInitialized:!1,error:null}),u=(0,n.useMemo)(()=>o,[JSON.stringify(o)]);(0,n.useEffect)(()=>{let n=!1,r=null;return l({type:`reset`}),(async()=>{try{let i=new t.t(e);if(await i.init(u),n){i.destroy();return}r=i,l({type:`success`,client:i,initialized:i.initialized,error:i.lastInitError?i.lastInitError.message:null})}catch(e){n||l({type:`error`,error:e instanceof Error?e.message:`Failed to initialize Nemme client`})}})(),()=>{n=!0,r&&r.destroy()}},[e,u]);let d={client:c.client,isInitialized:c.isInitialized,error:c.error};return(0,r.jsx)(i.Provider,{value:d,children:s})},s=()=>{let e=(0,n.useContext)(i);if(e===void 0)throw Error(`useNemmeContext must be used within a NemmeProvider`);return e},c=()=>{let{client:e,isInitialized:t,error:r}=s();return{track:(0,n.useCallback)(async n=>{if(!e||!t){console.warn(`Nemme client not initialized`);return}return e.track(n)},[e,t]),flush:(0,n.useCallback)(async()=>{if(!e||!t){console.warn(`Nemme client not initialized`);return}return e.flush()},[e,t]),isInitialized:t,error:r,client:e}};exports.NemmeProvider=o,exports.useNemme=c,exports.useNemmeContext=s;
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.cjs","names":[],"sources":["../src/react/context.ts","../src/react/NemmeProvider.tsx","../src/react/useNemmeContext.ts","../src/react/useNemme.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { NemmeClient } from '../client';\n\nexport interface NemmeContextType {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n}\n\nexport const NemmeContext = createContext<NemmeContextType | undefined>(undefined);\n","import * as React from 'react';\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { ClientConfigType, NemmeClient } from '../client';\nimport { NemmeContext, NemmeContextType } from './context';\n\ninterface NemmeProviderProps {\n clientKey: string;\n config: ClientConfigType;\n children: React.ReactNode;\n}\n\ntype State = {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n};\n\ntype Action =\n | { type: 'reset' }\n | { type: 'success'; client: NemmeClient; initialized: boolean; error: string | null }\n | { type: 'error'; error: string };\n\nfunction reducer(_state: State, action: Action): State {\n switch (action.type) {\n case 'reset':\n return { client: null, isInitialized: false, error: null };\n case 'success':\n return { client: action.client, isInitialized: action.initialized, error: action.error };\n case 'error':\n return { client: null, isInitialized: false, error: action.error };\n }\n}\n\nexport const NemmeProvider: React.FC<NemmeProviderProps> = ({ clientKey, config, children }) => {\n const [state, dispatch] = useReducer(reducer, { client: null, isInitialized: false, error: null });\n\n // Stabilize config: only changes when the serialized value differs\n const serializedConfig = JSON.stringify(config);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableConfig = useMemo<ClientConfigType>(() => config, [serializedConfig]);\n\n useEffect(() => {\n let isCancelled = false;\n let currentClient: NemmeClient | null = null;\n\n dispatch({ type: 'reset' });\n\n const initializeClient = async () => {\n try {\n const nemmeClient = new NemmeClient(clientKey);\n await nemmeClient.init(stableConfig);\n\n if (isCancelled) {\n nemmeClient.destroy();\n return;\n }\n\n currentClient = nemmeClient;\n dispatch({\n type: 'success',\n client: nemmeClient,\n initialized: nemmeClient.initialized,\n error: nemmeClient.lastInitError ? nemmeClient.lastInitError.message : null\n });\n } catch (err) {\n if (!isCancelled) {\n dispatch({\n type: 'error',\n error: err instanceof Error ? err.message : 'Failed to initialize Nemme client'\n });\n }\n }\n };\n\n initializeClient();\n\n return () => {\n isCancelled = true;\n if (currentClient) {\n currentClient.destroy();\n }\n };\n }, [clientKey, stableConfig]);\n\n const value: NemmeContextType = {\n client: state.client,\n isInitialized: state.isInitialized,\n error: state.error\n };\n\n return <NemmeContext.Provider value={value}>{children}</NemmeContext.Provider>;\n};\n","import { useContext } from 'react';\nimport { NemmeContext } from './context';\n\nexport const useNemmeContext = () => {\n const context = useContext(NemmeContext);\n if (context === undefined) {\n throw new Error('useNemmeContext must be used within a NemmeProvider');\n }\n return context;\n};\n","import { useCallback } from 'react';\nimport { useNemmeContext } from './useNemmeContext';\nimport { TrackEventOptions } from '../client';\n\nexport const useNemme = () => {\n const { client, isInitialized, error } = useNemmeContext();\n\n const track = useCallback(\n async <T extends TrackEventOptions>(options: T) => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.track(options);\n },\n [client, isInitialized]\n );\n\n const flush = useCallback(async () => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.flush();\n }, [client, isInitialized]);\n\n return {\n track,\n flush,\n isInitialized,\n error,\n client\n };\n};\n"],"mappings":"+NASA,IAAa,GAAA,EAAA,EAAA,eAA2D,IAAA,
|
|
1
|
+
{"version":3,"file":"react.cjs","names":[],"sources":["../src/react/context.ts","../src/react/NemmeProvider.tsx","../src/react/useNemmeContext.ts","../src/react/useNemme.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { NemmeClient } from '../client';\n\nexport interface NemmeContextType {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n}\n\nexport const NemmeContext = createContext<NemmeContextType | undefined>(undefined);\n","import * as React from 'react';\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { ClientConfigType, NemmeClient } from '../client';\nimport { NemmeContext, NemmeContextType } from './context';\n\ninterface NemmeProviderProps {\n clientKey: string;\n config: ClientConfigType;\n children: React.ReactNode;\n}\n\ntype State = {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n};\n\ntype Action =\n | { type: 'reset' }\n | { type: 'success'; client: NemmeClient; initialized: boolean; error: string | null }\n | { type: 'error'; error: string };\n\nfunction reducer(_state: State, action: Action): State {\n switch (action.type) {\n case 'reset':\n return { client: null, isInitialized: false, error: null };\n case 'success':\n return { client: action.client, isInitialized: action.initialized, error: action.error };\n case 'error':\n return { client: null, isInitialized: false, error: action.error };\n }\n}\n\nexport const NemmeProvider: React.FC<NemmeProviderProps> = ({ clientKey, config, children }) => {\n const [state, dispatch] = useReducer(reducer, { client: null, isInitialized: false, error: null });\n\n // Stabilize config: only changes when the serialized value differs\n const serializedConfig = JSON.stringify(config);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableConfig = useMemo<ClientConfigType>(() => config, [serializedConfig]);\n\n useEffect(() => {\n let isCancelled = false;\n let currentClient: NemmeClient | null = null;\n\n dispatch({ type: 'reset' });\n\n const initializeClient = async () => {\n try {\n const nemmeClient = new NemmeClient(clientKey);\n await nemmeClient.init(stableConfig);\n\n if (isCancelled) {\n nemmeClient.destroy();\n return;\n }\n\n currentClient = nemmeClient;\n dispatch({\n type: 'success',\n client: nemmeClient,\n initialized: nemmeClient.initialized,\n error: nemmeClient.lastInitError ? nemmeClient.lastInitError.message : null\n });\n } catch (err) {\n if (!isCancelled) {\n dispatch({\n type: 'error',\n error: err instanceof Error ? err.message : 'Failed to initialize Nemme client'\n });\n }\n }\n };\n\n initializeClient();\n\n return () => {\n isCancelled = true;\n if (currentClient) {\n currentClient.destroy();\n }\n };\n }, [clientKey, stableConfig]);\n\n const value: NemmeContextType = {\n client: state.client,\n isInitialized: state.isInitialized,\n error: state.error\n };\n\n return <NemmeContext.Provider value={value}>{children}</NemmeContext.Provider>;\n};\n","import { useContext } from 'react';\nimport { NemmeContext } from './context';\n\nexport const useNemmeContext = () => {\n const context = useContext(NemmeContext);\n if (context === undefined) {\n throw new Error('useNemmeContext must be used within a NemmeProvider');\n }\n return context;\n};\n","import { useCallback } from 'react';\nimport { useNemmeContext } from './useNemmeContext';\nimport { TrackEventOptions } from '../client';\n\nexport const useNemme = () => {\n const { client, isInitialized, error } = useNemmeContext();\n\n const track = useCallback(\n async <T extends TrackEventOptions>(options: T) => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.track(options);\n },\n [client, isInitialized]\n );\n\n const flush = useCallback(async () => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.flush();\n }, [client, isInitialized]);\n\n return {\n track,\n flush,\n isInitialized,\n error,\n client\n };\n};\n"],"mappings":"+NASA,IAAa,GAAA,EAAA,EAAA,eAA2D,IAAA,EAAS,ECajF,SAAS,EAAQ,EAAe,EAAuB,CACrD,OAAQ,EAAO,KAAf,CACE,IAAK,QACH,MAAO,CAAE,OAAQ,KAAM,cAAe,GAAO,MAAO,IAAK,EAC3D,IAAK,UACH,MAAO,CAAE,OAAQ,EAAO,OAAQ,cAAe,EAAO,YAAa,MAAO,EAAO,KAAM,EACzF,IAAK,QACH,MAAO,CAAE,OAAQ,KAAM,cAAe,GAAO,MAAO,EAAO,KAAM,CACrE,CACF,CAEA,IAAa,GAA+C,CAAE,YAAW,SAAQ,cAAe,CAC9F,GAAM,CAAC,EAAO,IAAA,EAAA,EAAA,YAAuB,EAAS,CAAE,OAAQ,KAAM,cAAe,GAAO,MAAO,IAAK,CAAC,EAK3F,GAAA,EAAA,EAAA,aAA+C,EAAQ,CAFpC,KAAK,UAAU,CAEsB,CAAgB,CAAC,GAE/E,EAAA,EAAA,eAAgB,CACd,IAAI,EAAc,GACd,EAAoC,KAiCxC,OA/BA,EAAS,CAAE,KAAM,OAAQ,CAAC,GA6B1B,SA3BqC,CACnC,GAAI,CACF,IAAM,EAAc,IAAI,E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ks/client-
|
|
1
|
+
import { t as e } from "./chunks/client-CKvtSbpa.js";
|
|
2
2
|
import { createContext as t, useCallback as n, useContext as r, useEffect as i, useMemo as a, useReducer as o } from "react";
|
|
3
3
|
import { jsx as s } from "react/jsx-runtime";
|
|
4
4
|
//#region src/react/context.ts
|
package/dist/react.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.esm.js","names":[],"sources":["../src/react/context.ts","../src/react/NemmeProvider.tsx","../src/react/useNemmeContext.ts","../src/react/useNemme.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { NemmeClient } from '../client';\n\nexport interface NemmeContextType {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n}\n\nexport const NemmeContext = createContext<NemmeContextType | undefined>(undefined);\n","import * as React from 'react';\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { ClientConfigType, NemmeClient } from '../client';\nimport { NemmeContext, NemmeContextType } from './context';\n\ninterface NemmeProviderProps {\n clientKey: string;\n config: ClientConfigType;\n children: React.ReactNode;\n}\n\ntype State = {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n};\n\ntype Action =\n | { type: 'reset' }\n | { type: 'success'; client: NemmeClient; initialized: boolean; error: string | null }\n | { type: 'error'; error: string };\n\nfunction reducer(_state: State, action: Action): State {\n switch (action.type) {\n case 'reset':\n return { client: null, isInitialized: false, error: null };\n case 'success':\n return { client: action.client, isInitialized: action.initialized, error: action.error };\n case 'error':\n return { client: null, isInitialized: false, error: action.error };\n }\n}\n\nexport const NemmeProvider: React.FC<NemmeProviderProps> = ({ clientKey, config, children }) => {\n const [state, dispatch] = useReducer(reducer, { client: null, isInitialized: false, error: null });\n\n // Stabilize config: only changes when the serialized value differs\n const serializedConfig = JSON.stringify(config);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableConfig = useMemo<ClientConfigType>(() => config, [serializedConfig]);\n\n useEffect(() => {\n let isCancelled = false;\n let currentClient: NemmeClient | null = null;\n\n dispatch({ type: 'reset' });\n\n const initializeClient = async () => {\n try {\n const nemmeClient = new NemmeClient(clientKey);\n await nemmeClient.init(stableConfig);\n\n if (isCancelled) {\n nemmeClient.destroy();\n return;\n }\n\n currentClient = nemmeClient;\n dispatch({\n type: 'success',\n client: nemmeClient,\n initialized: nemmeClient.initialized,\n error: nemmeClient.lastInitError ? nemmeClient.lastInitError.message : null\n });\n } catch (err) {\n if (!isCancelled) {\n dispatch({\n type: 'error',\n error: err instanceof Error ? err.message : 'Failed to initialize Nemme client'\n });\n }\n }\n };\n\n initializeClient();\n\n return () => {\n isCancelled = true;\n if (currentClient) {\n currentClient.destroy();\n }\n };\n }, [clientKey, stableConfig]);\n\n const value: NemmeContextType = {\n client: state.client,\n isInitialized: state.isInitialized,\n error: state.error\n };\n\n return <NemmeContext.Provider value={value}>{children}</NemmeContext.Provider>;\n};\n","import { useContext } from 'react';\nimport { NemmeContext } from './context';\n\nexport const useNemmeContext = () => {\n const context = useContext(NemmeContext);\n if (context === undefined) {\n throw new Error('useNemmeContext must be used within a NemmeProvider');\n }\n return context;\n};\n","import { useCallback } from 'react';\nimport { useNemmeContext } from './useNemmeContext';\nimport { TrackEventOptions } from '../client';\n\nexport const useNemme = () => {\n const { client, isInitialized, error } = useNemmeContext();\n\n const track = useCallback(\n async <T extends TrackEventOptions>(options: T) => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.track(options);\n },\n [client, isInitialized]\n );\n\n const flush = useCallback(async () => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.flush();\n }, [client, isInitialized]);\n\n return {\n track,\n flush,\n isInitialized,\n error,\n client\n };\n};\n"],"mappings":";;;;AASA,IAAa,IAAe,EAA4C,KAAA,
|
|
1
|
+
{"version":3,"file":"react.esm.js","names":[],"sources":["../src/react/context.ts","../src/react/NemmeProvider.tsx","../src/react/useNemmeContext.ts","../src/react/useNemme.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { NemmeClient } from '../client';\n\nexport interface NemmeContextType {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n}\n\nexport const NemmeContext = createContext<NemmeContextType | undefined>(undefined);\n","import * as React from 'react';\nimport { useEffect, useMemo, useReducer } from 'react';\nimport { ClientConfigType, NemmeClient } from '../client';\nimport { NemmeContext, NemmeContextType } from './context';\n\ninterface NemmeProviderProps {\n clientKey: string;\n config: ClientConfigType;\n children: React.ReactNode;\n}\n\ntype State = {\n client: NemmeClient | null;\n isInitialized: boolean;\n error: string | null;\n};\n\ntype Action =\n | { type: 'reset' }\n | { type: 'success'; client: NemmeClient; initialized: boolean; error: string | null }\n | { type: 'error'; error: string };\n\nfunction reducer(_state: State, action: Action): State {\n switch (action.type) {\n case 'reset':\n return { client: null, isInitialized: false, error: null };\n case 'success':\n return { client: action.client, isInitialized: action.initialized, error: action.error };\n case 'error':\n return { client: null, isInitialized: false, error: action.error };\n }\n}\n\nexport const NemmeProvider: React.FC<NemmeProviderProps> = ({ clientKey, config, children }) => {\n const [state, dispatch] = useReducer(reducer, { client: null, isInitialized: false, error: null });\n\n // Stabilize config: only changes when the serialized value differs\n const serializedConfig = JSON.stringify(config);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableConfig = useMemo<ClientConfigType>(() => config, [serializedConfig]);\n\n useEffect(() => {\n let isCancelled = false;\n let currentClient: NemmeClient | null = null;\n\n dispatch({ type: 'reset' });\n\n const initializeClient = async () => {\n try {\n const nemmeClient = new NemmeClient(clientKey);\n await nemmeClient.init(stableConfig);\n\n if (isCancelled) {\n nemmeClient.destroy();\n return;\n }\n\n currentClient = nemmeClient;\n dispatch({\n type: 'success',\n client: nemmeClient,\n initialized: nemmeClient.initialized,\n error: nemmeClient.lastInitError ? nemmeClient.lastInitError.message : null\n });\n } catch (err) {\n if (!isCancelled) {\n dispatch({\n type: 'error',\n error: err instanceof Error ? err.message : 'Failed to initialize Nemme client'\n });\n }\n }\n };\n\n initializeClient();\n\n return () => {\n isCancelled = true;\n if (currentClient) {\n currentClient.destroy();\n }\n };\n }, [clientKey, stableConfig]);\n\n const value: NemmeContextType = {\n client: state.client,\n isInitialized: state.isInitialized,\n error: state.error\n };\n\n return <NemmeContext.Provider value={value}>{children}</NemmeContext.Provider>;\n};\n","import { useContext } from 'react';\nimport { NemmeContext } from './context';\n\nexport const useNemmeContext = () => {\n const context = useContext(NemmeContext);\n if (context === undefined) {\n throw new Error('useNemmeContext must be used within a NemmeProvider');\n }\n return context;\n};\n","import { useCallback } from 'react';\nimport { useNemmeContext } from './useNemmeContext';\nimport { TrackEventOptions } from '../client';\n\nexport const useNemme = () => {\n const { client, isInitialized, error } = useNemmeContext();\n\n const track = useCallback(\n async <T extends TrackEventOptions>(options: T) => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.track(options);\n },\n [client, isInitialized]\n );\n\n const flush = useCallback(async () => {\n if (!client || !isInitialized) {\n console.warn('Nemme client not initialized');\n return;\n }\n return client.flush();\n }, [client, isInitialized]);\n\n return {\n track,\n flush,\n isInitialized,\n error,\n client\n };\n};\n"],"mappings":";;;;AASA,IAAa,IAAe,EAA4C,KAAA,CAAS;;;ACajF,SAAS,EAAQ,GAAe,GAAuB;CACrD,QAAQ,EAAO,MAAf;EACE,KAAK,SACH,OAAO;GAAE,QAAQ;GAAM,eAAe;GAAO,OAAO;EAAK;EAC3D,KAAK,WACH,OAAO;GAAE,QAAQ,EAAO;GAAQ,eAAe,EAAO;GAAa,OAAO,EAAO;EAAM;EACzF,KAAK,SACH,OAAO;GAAE,QAAQ;GAAM,eAAe;GAAO,OAAO,EAAO;EAAM;CACrE;AACF;AAEA,IAAa,KAA+C,EAAE,cAAW,WAAQ,kBAAe;CAC9F,IAAM,CAAC,GAAO,KAAY,EAAW,GAAS;EAAE,QAAQ;EAAM,eAAe;EAAO,OAAO;CAAK,CAAC,GAK3F,IAAe,QAAgC,GAAQ,CAFpC,KAAK,UAAU,CAEsB,CAAgB,C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,CAIvB;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isSafeExternalLink: (value: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nemme/js-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"unpkg": "./dist/nemme-sdk.umd.js",
|
|
9
9
|
"jsdelivr": "./dist/nemme-sdk.umd.js",
|
|
10
10
|
"files": [
|
|
11
|
-
"/dist"
|
|
11
|
+
"/dist",
|
|
12
|
+
"CHANGELOG.md"
|
|
12
13
|
],
|
|
13
14
|
"sideEffects": [
|
|
14
15
|
"**/*.css"
|
|
@@ -75,9 +76,9 @@
|
|
|
75
76
|
},
|
|
76
77
|
"dependencies": {
|
|
77
78
|
"@phosphor-icons/react": "^2.1.10",
|
|
78
|
-
"date-fns": "^4.
|
|
79
|
+
"date-fns": "^4.4.0",
|
|
79
80
|
"i18next-browser-languagedetector": "^8.2.1",
|
|
80
|
-
"react-i18next": "^17.0.
|
|
81
|
+
"react-i18next": "^17.0.8"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@bcoe/v8-coverage": "^1.0.2",
|
|
@@ -88,20 +89,20 @@
|
|
|
88
89
|
"@nemme/ui-kit": "^0.2.1",
|
|
89
90
|
"@storybook/addon-a11y": "^10.3.6",
|
|
90
91
|
"@storybook/addon-docs": "^10.3.6",
|
|
91
|
-
"@storybook/addon-vitest": "^10.
|
|
92
|
+
"@storybook/addon-vitest": "^10.4.2",
|
|
92
93
|
"@storybook/react-vite": "^10.3.6",
|
|
93
94
|
"@tailwindcss/postcss": "^4.1.13",
|
|
94
95
|
"@tailwindcss/vite": "^4.1.13",
|
|
95
96
|
"@testing-library/jest-dom": "^6.6.3",
|
|
96
97
|
"@testing-library/react": "^16.3.2",
|
|
97
|
-
"@types/react": "^19.2.
|
|
98
|
+
"@types/react": "^19.2.17",
|
|
98
99
|
"@types/react-dom": "^19.2.3",
|
|
99
100
|
"@typescript-eslint/eslint-plugin": "^8.59.2",
|
|
100
101
|
"@typescript-eslint/parser": "^8.59.2",
|
|
101
|
-
"@vitejs/plugin-react": "^6.0.
|
|
102
|
-
"@vitest/browser": "^4.
|
|
103
|
-
"@vitest/coverage-v8": "^4.
|
|
104
|
-
"ast-v8-to-istanbul": "^1.0.
|
|
102
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
103
|
+
"@vitest/browser": "^4.1.8",
|
|
104
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
105
|
+
"ast-v8-to-istanbul": "^1.0.3",
|
|
105
106
|
"eslint": "^10.3.0",
|
|
106
107
|
"eslint-config-prettier": "^10.1.5",
|
|
107
108
|
"eslint-plugin-prettier": "^5.4.1",
|
|
@@ -109,21 +110,21 @@
|
|
|
109
110
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
110
111
|
"eslint-plugin-storybook": "^10.3.6",
|
|
111
112
|
"globals": "^17.3.0",
|
|
112
|
-
"happy-dom": "^20.
|
|
113
|
+
"happy-dom": "^20.10.2",
|
|
113
114
|
"husky": "^9.1.7",
|
|
114
115
|
"lint-staged": "^17.0.4",
|
|
115
|
-
"playwright": "^1.
|
|
116
|
+
"playwright": "^1.60.0",
|
|
116
117
|
"postcss": "^8.5.6",
|
|
117
118
|
"postcss-import": "^16.1.1",
|
|
118
119
|
"postcss-prefixwrap": "^1.58.0",
|
|
119
120
|
"prettier": "^3.5.1",
|
|
120
|
-
"react": "^19.2.
|
|
121
|
-
"react-dom": "^19.2.
|
|
121
|
+
"react": "^19.2.7",
|
|
122
|
+
"react-dom": "^19.2.7",
|
|
122
123
|
"storybook": "^10.3.6",
|
|
123
124
|
"tailwindcss": "^4.1.13",
|
|
124
125
|
"typescript": "^6.0.3",
|
|
125
126
|
"vite": "^8.0.11",
|
|
126
127
|
"vite-plugin-dts": "^5.0.0",
|
|
127
|
-
"vitest": "^4.
|
|
128
|
+
"vitest": "^4.1.8"
|
|
128
129
|
}
|
|
129
130
|
}
|