@jitsu/jitsu-react 0.0.0-alpha.98 → 0.0.1-alpha.120

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.
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { AnalyticsInterface } from "@jitsu/types/analytics";
2
+ import { AnalyticsInterface } from "@jitsu/analytics-types/analytics";
3
3
  declare const JitsuContext: import("react").Context<AnalyticsInterface | null>;
4
4
  export default JitsuContext;
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JitsuOptions } from "@jitsu/js";
2
- import { AnalyticsInterface } from "@jitsu/types/analytics";
3
- declare function createClient(params: JitsuOptions): AnalyticsInterface;
4
- export default createClient;
1
+ import { JitsuOptions } from "@jitsu/js";
2
+ import { AnalyticsInterface } from "@jitsu/analytics-types/analytics";
3
+ declare function createClient(params: JitsuOptions): AnalyticsInterface;
4
+ export default createClient;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/types/analytics\";\n\nconst JitsuContext = createContext<AnalyticsInterface | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: JitsuOptions }>> = function (props) {\n const client = jitsuAnalytics(props.options);\n return <JitsuContext.Provider value={client}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext, useEffect } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { AnalyticsInterface } from \"@jitsu/types/analytics\";\nimport type { useLocation } from \"react-router-dom\";\nimport type { useRouter } from \"next/router\";\n\nimport { Union } from \"ts-toolbelt\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\ninterface ReactRouterOptions {\n reactRouter: typeof useLocation;\n}\n\ninterface NextJsRouterOptions {\n nextjsRouter: typeof useRouter;\n}\n\ninterface AutoPageTrackingBefore {\n before: (analytics: AnalyticsInterface) => any;\n beforeDeps: any[];\n}\ntype RouterOptions = Union.Strict<ReactRouterOptions | NextJsRouterOptions>;\n\ntype ExtendedJitsuOptions = JitsuOptions & {\n autoPageTracking?: Union.Strict<(RouterOptions & AutoPageTrackingBefore) | RouterOptions>;\n};\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let cl = useContext(JitsuContext);\n if (!cl) {\n if (opts?.host) {\n cl = jitsuAnalytics(opts);\n } else {\n throw new Error(\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n } else if (opts?.host) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n const client = cl;\n\n const reactLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.reactRouter ? opts.autoPageTracking.reactRouter() : null;\n const before = opts?.autoPageTracking && opts.autoPageTracking.before ? opts.autoPageTracking.before : null;\n const nextjsLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.nextjsRouter ? opts.autoPageTracking.nextjsRouter() : null;\n useEffect(() => {\n if (before) {\n before(client);\n }\n }, opts?.autoPageTracking?.beforeDeps || []);\n\n useEffect(() => {\n if (reactLocationHook) {\n client.page();\n } else if (nextjsLocationHook) {\n client.page();\n }\n }, [reactLocationHook, nextjsLocationHook]);\n\n return { analytics: client };\n}\n\nexport default useJitsu;\n"],"names":["JitsuContext","createContext","JitsuProvider","props","client","jitsuAnalytics","options","React","Provider","value","children","useJitsu","opts","cl","useContext","host","Error","reactLocationHook","autoPageTracking","reactRouter","before","nextjsLocationHook","nextjsRouter","useEffect","beforeDeps","page","analytics"],"mappings":";;;AAGA,IAAMA,YAAY,GAAGC,mBAAa,CAA4B,IAAI,CAAC;;ACEnE,IAAMC,aAAa,GAA2D,SAAxEA,aAAa,CAAqEC,KAAK;EAC3F,IAAMC,MAAM,GAAGC,iBAAc,CAACF,KAAK,CAACG,OAAO,CAAC;EAC5C,OAAOC,oBAACP,YAAY,CAACQ,QAAQ;IAACC,KAAK,EAAEL;KAASD,KAAK,CAACO,QAAQ,CAAyB;AACvF,CAAC;;ACsBD,SAASC,QAAQ,CAACC,IAA2B;;EAC3C,IAAIC,EAAE,GAAGC,gBAAU,CAACd,YAAY,CAAC;EACjC,IAAI,CAACa,EAAE,EAAE;IACP,IAAID,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEG,IAAI,EAAE;MACdF,EAAE,GAAGR,iBAAc,CAACO,IAAI,CAAC;KAC1B,MAAM;MACL,MAAM,IAAII,KAAK,CACb,iJAAiJ,CAClJ;;GAEJ,MAAM,IAAIJ,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEG,IAAI,EAAE;IACrB,MAAM,IAAIC,KAAK,CACb,2IAA2I,CAC5I;;EAEH,IAAMZ,MAAM,GAAGS,EAAE;EAEjB,IAAMI,iBAAiB,GACrBL,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEM,gBAAgB,IAAIN,IAAI,CAACM,gBAAgB,CAACC,WAAW,GAAGP,IAAI,CAACM,gBAAgB,CAACC,WAAW,EAAE,GAAG,IAAI;EAC1G,IAAMC,MAAM,GAAGR,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEM,gBAAgB,IAAIN,IAAI,CAACM,gBAAgB,CAACE,MAAM,GAAGR,IAAI,CAACM,gBAAgB,CAACE,MAAM,GAAG,IAAI;EAC3G,IAAMC,kBAAkB,GACtBT,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEM,gBAAgB,IAAIN,IAAI,CAACM,gBAAgB,CAACI,YAAY,GAAGV,IAAI,CAACM,gBAAgB,CAACI,YAAY,EAAE,GAAG,IAAI;EAC5GC,eAAS,CAAC;IACR,IAAIH,MAAM,EAAE;MACVA,MAAM,CAAChB,MAAM,CAAC;;GAEjB,EAAE,CAAAQ,IAAI,aAAJA,IAAI,gDAAJA,IAAI,CAAEM,gBAAgB,0DAAtB,sBAAwBM,UAAU,KAAI,EAAE,CAAC;EAE5CD,eAAS,CAAC;IACR,IAAIN,iBAAiB,EAAE;MACrBb,MAAM,CAACqB,IAAI,EAAE;KACd,MAAM,IAAIJ,kBAAkB,EAAE;MAC7BjB,MAAM,CAACqB,IAAI,EAAE;;GAEhB,EAAE,CAACR,iBAAiB,EAAEI,kBAAkB,CAAC,CAAC;EAE3C,OAAO;IAAEK,SAAS,EAAEtB;GAAQ;AAC9B;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/analytics-types/analytics\";\n\nconst JitsuContext = createContext<AnalyticsInterface | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: JitsuOptions }>> = function (props) {\n const client = jitsuAnalytics(props.options);\n return <JitsuContext.Provider value={client}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext, useEffect } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { AnalyticsInterface } from \"@jitsu/analytics-types/analytics\";\nimport type { useLocation } from \"react-router-dom\";\nimport type { useRouter } from \"next/router\";\n\nimport { Union } from \"ts-toolbelt\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\ninterface ReactRouterOptions {\n reactRouter: typeof useLocation;\n}\n\ninterface NextJsRouterOptions {\n nextjsRouter: typeof useRouter;\n}\n\ninterface AutoPageTrackingBefore {\n before: (analytics: AnalyticsInterface) => any;\n beforeDeps: any[];\n}\ntype RouterOptions = Union.Strict<ReactRouterOptions | NextJsRouterOptions>;\n\ntype ExtendedJitsuOptions = JitsuOptions & {\n autoPageTracking?: Union.Strict<(RouterOptions & AutoPageTrackingBefore) | RouterOptions>;\n};\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let cl = useContext(JitsuContext);\n if (!cl) {\n if (opts?.host) {\n cl = jitsuAnalytics(opts);\n } else {\n throw new Error(\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n } else if (opts?.host) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n const client = cl;\n\n const reactLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.reactRouter ? opts.autoPageTracking.reactRouter() : null;\n const before = opts?.autoPageTracking && opts.autoPageTracking.before ? opts.autoPageTracking.before : null;\n const nextjsLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.nextjsRouter ? opts.autoPageTracking.nextjsRouter() : null;\n useEffect(() => {\n if (before) {\n before(client);\n }\n }, opts?.autoPageTracking?.beforeDeps || []);\n\n useEffect(() => {\n if (reactLocationHook) {\n client.page();\n } else if (nextjsLocationHook) {\n client.page();\n }\n }, [reactLocationHook, nextjsLocationHook]);\n\n return { analytics: client };\n}\n\nexport default useJitsu;\n"],"names":["JitsuContext","createContext","JitsuProvider","props","client","jitsuAnalytics","options","React","Provider","value","children","useJitsu","opts","cl","useContext","host","Error","reactLocationHook","autoPageTracking","reactRouter","before","nextjsLocationHook","nextjsRouter","useEffect","beforeDeps","page","analytics"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EAAE,GAAG,IAAI;EAC5GC,eAAS,CAAC;IACR,IAAIH,MAAM,EAAE;MACVA,MAAM,CAAChB,MAAM,CAAC;;GAEjB,EAAE,CAAAQ,IAAI,aAAJA,IAAI,gDAAJA,IAAI,CAAEM,gBAAgB,0DAAtB,sBAAwBM,UAAU,KAAI,EAAE,CAAC;EAE5CD,eAAS,CAAC;IACR,IAAIN,iBAAiB,EAAE;MACrBb,MAAM,CAACqB,IAAI,EAAE;KACd,MAAM,IAAIJ,kBAAkB,EAAE;MAC7BjB,MAAM,CAACqB,IAAI,EAAE;;GAEhB,EAAE,CAACR,iBAAiB,EAAEI,kBAAkB,CAAC,CAAC;EAE3C,OAAO;IAAEK,SAAS,EAAEtB;GAAQ;AAC9B;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/types/analytics\";\n\nconst JitsuContext = createContext<AnalyticsInterface | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: JitsuOptions }>> = function (props) {\n const client = jitsuAnalytics(props.options);\n return <JitsuContext.Provider value={client}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext, useEffect } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { AnalyticsInterface } from \"@jitsu/types/analytics\";\nimport type { useLocation } from \"react-router-dom\";\nimport type { useRouter } from \"next/router\";\n\nimport { Union } from \"ts-toolbelt\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\ninterface ReactRouterOptions {\n reactRouter: typeof useLocation;\n}\n\ninterface NextJsRouterOptions {\n nextjsRouter: typeof useRouter;\n}\n\ninterface AutoPageTrackingBefore {\n before: (analytics: AnalyticsInterface) => any;\n beforeDeps: any[];\n}\ntype RouterOptions = Union.Strict<ReactRouterOptions | NextJsRouterOptions>;\n\ntype ExtendedJitsuOptions = JitsuOptions & {\n autoPageTracking?: Union.Strict<(RouterOptions & AutoPageTrackingBefore) | RouterOptions>;\n};\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let cl = useContext(JitsuContext);\n if (!cl) {\n if (opts?.host) {\n cl = jitsuAnalytics(opts);\n } else {\n throw new Error(\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n } else if (opts?.host) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n const client = cl;\n\n const reactLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.reactRouter ? opts.autoPageTracking.reactRouter() : null;\n const before = opts?.autoPageTracking && opts.autoPageTracking.before ? opts.autoPageTracking.before : null;\n const nextjsLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.nextjsRouter ? opts.autoPageTracking.nextjsRouter() : null;\n useEffect(() => {\n if (before) {\n before(client);\n }\n }, opts?.autoPageTracking?.beforeDeps || []);\n\n useEffect(() => {\n if (reactLocationHook) {\n client.page();\n } else if (nextjsLocationHook) {\n client.page();\n }\n }, [reactLocationHook, nextjsLocationHook]);\n\n return { analytics: client };\n}\n\nexport default useJitsu;\n"],"names":["JitsuContext","createContext","JitsuProvider","props","client","jitsuAnalytics","options","React","Provider","value","children","useJitsu","opts","cl","useContext","host","Error","reactLocationHook","autoPageTracking","reactRouter","before","nextjsLocationHook","nextjsRouter","useEffect","beforeDeps","page","analytics"],"mappings":";;;AAGA,IAAMA,YAAY,GAAGC,aAAa,CAA4B,IAAI,CAAC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,MAAM,CAAChB,MAAM,CAAC;;GAEjB,EAAE,CAAAQ,IAAI,aAAJA,IAAI,gDAAJA,IAAI,CAAEM,gBAAgB,0DAAtB,sBAAwBM,UAAU,KAAI,EAAE,CAAC;EAE5CD,SAAS,CAAC;IACR,IAAIN,iBAAiB,EAAE;MACrBb,MAAM,CAACqB,IAAI,EAAE;KACd,MAAM,IAAIJ,kBAAkB,EAAE;MAC7BjB,MAAM,CAACqB,IAAI,EAAE;;GAEhB,EAAE,CAACR,iBAAiB,EAAEI,kBAAkB,CAAC,CAAC;EAE3C,OAAO;IAAEK,SAAS,EAAEtB;GAAQ;AAC9B;;;;"}
1
+ {"version":3,"file":"index.modern.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/analytics-types/analytics\";\n\nconst JitsuContext = createContext<AnalyticsInterface | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: JitsuOptions }>> = function (props) {\n const client = jitsuAnalytics(props.options);\n return <JitsuContext.Provider value={client}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext, useEffect } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\nimport { AnalyticsInterface } from \"@jitsu/analytics-types/analytics\";\nimport type { useLocation } from \"react-router-dom\";\nimport type { useRouter } from \"next/router\";\n\nimport { Union } from \"ts-toolbelt\";\nimport { jitsuAnalytics, JitsuOptions } from \"@jitsu/js\";\n\ninterface ReactRouterOptions {\n reactRouter: typeof useLocation;\n}\n\ninterface NextJsRouterOptions {\n nextjsRouter: typeof useRouter;\n}\n\ninterface AutoPageTrackingBefore {\n before: (analytics: AnalyticsInterface) => any;\n beforeDeps: any[];\n}\ntype RouterOptions = Union.Strict<ReactRouterOptions | NextJsRouterOptions>;\n\ntype ExtendedJitsuOptions = JitsuOptions & {\n autoPageTracking?: Union.Strict<(RouterOptions & AutoPageTrackingBefore) | RouterOptions>;\n};\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let cl = useContext(JitsuContext);\n if (!cl) {\n if (opts?.host) {\n cl = jitsuAnalytics(opts);\n } else {\n throw new Error(\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n } else if (opts?.host) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n }\n const client = cl;\n\n const reactLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.reactRouter ? opts.autoPageTracking.reactRouter() : null;\n const before = opts?.autoPageTracking && opts.autoPageTracking.before ? opts.autoPageTracking.before : null;\n const nextjsLocationHook =\n opts?.autoPageTracking && opts.autoPageTracking.nextjsRouter ? opts.autoPageTracking.nextjsRouter() : null;\n useEffect(() => {\n if (before) {\n before(client);\n }\n }, opts?.autoPageTracking?.beforeDeps || []);\n\n useEffect(() => {\n if (reactLocationHook) {\n client.page();\n } else if (nextjsLocationHook) {\n client.page();\n }\n }, [reactLocationHook, nextjsLocationHook]);\n\n return { analytics: client };\n}\n\nexport default useJitsu;\n"],"names":["JitsuContext","createContext","JitsuProvider","props","client","jitsuAnalytics","options","React","Provider","value","children","useJitsu","opts","cl","useContext","host","Error","reactLocationHook","autoPageTracking","reactRouter","before","nextjsLocationHook","nextjsRouter","useEffect","beforeDeps","page","analytics"],"mappings":";;;AAGA,IAAMA,YAAY,GAAGC,aAAa,CAA4B,IAAI,CAAC;;ACEnE,IAAMC,aAAa,GAA2D,SAAxEA,aAAa,CAAqEC,KAAK;EAC3F,IAAMC,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JA,IAAI,CAAEM,gBAAgB,0DAAtB,sBAAwBM,UAAU,KAAI,EAAE,CAAC;EAE5CD,SAAS,CAAC;IACR,IAAIN,iBAAiB,EAAE;MACrBb,MAAM,CAACqB,IAAI,EAAE;KACd,MAAM,IAAIJ,kBAAkB,EAAE;MAC7BjB,MAAM,CAACqB,IAAI,EAAE;;GAEhB,EAAE,CAACR,iBAAiB,EAAEI,kBAAkB,CAAC,CAAC;EAE3C,OAAO;IAAEK,SAAS,EAAEtB;GAAQ;AAC9B;;;;"}
@@ -1,4 +1,4 @@
1
- import { AnalyticsInterface } from "@jitsu/types/analytics";
1
+ import { AnalyticsInterface } from "@jitsu/analytics-types/analytics";
2
2
  import type { useLocation } from "react-router-dom";
3
3
  import type { useRouter } from "next/router";
4
4
  import { Union } from "ts-toolbelt";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jitsu/jitsu-react",
3
- "version": "0.0.0-alpha.98",
3
+ "version": "0.0.1-alpha.120",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,7 @@
11
11
  "node": ">=10"
12
12
  },
13
13
  "dependencies": {
14
- "@jitsu/js": "0.0.0-alpha.98"
14
+ "@jitsu/js": "0.0.1-alpha.120"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "react": "15.x || 16.x || 17.x || 18.x",
@@ -39,8 +39,8 @@
39
39
  "microbundle-crl": "^0.13.11",
40
40
  "react": "^18.2.0",
41
41
  "typescript": "^4.9.3",
42
- "@jitsu/js": "0.0.0-alpha.98",
43
- "@jitsu/types": "0.0.0-alpha.98"
42
+ "@jitsu/js": "0.0.1-alpha.120",
43
+ "@jitsu/analytics-types": "0.0.1-alpha.120"
44
44
  },
45
45
  "files": [
46
46
  "dist"