@lvble/react 2.0.71
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 +21 -0
- package/README.md +82 -0
- package/dist/_bundles/react.js +3 -0
- package/dist/_bundles/react.js.LICENSE.txt +9 -0
- package/dist/_bundles/react.js.map +1 -0
- package/dist/_bundles/react.min.js +3 -0
- package/dist/_bundles/react.min.js.LICENSE.txt +9 -0
- package/dist/_bundles/react.min.js.map +1 -0
- package/dist/lib/components/index.d.ts +2 -0
- package/dist/lib/components/index.d.ts.map +1 -0
- package/dist/lib/components/index.js +18 -0
- package/dist/lib/components/index.js.map +1 -0
- package/dist/lib/components/lvble/index.d.ts +6 -0
- package/dist/lib/components/lvble/index.d.ts.map +1 -0
- package/dist/lib/components/lvble/index.js +31 -0
- package/dist/lib/components/lvble/index.js.map +1 -0
- package/dist/lib/context.d.ts +15 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/context.js +31 -0
- package/dist/lib/context.js.map +1 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +22 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/storybook-utils.d.ts +5 -0
- package/dist/lib/storybook-utils.d.ts.map +1 -0
- package/dist/lib/storybook-utils.js +9 -0
- package/dist/lib/storybook-utils.js.map +1 -0
- package/dist/lib/utils/openExperience.d.ts +9 -0
- package/dist/lib/utils/openExperience.d.ts.map +1 -0
- package/dist/lib/utils/openExperience.js +17 -0
- package/dist/lib/utils/openExperience.js.map +1 -0
- package/dist/lib/utils/openExperienceAndSetToken.d.ts +4 -0
- package/dist/lib/utils/openExperienceAndSetToken.d.ts.map +1 -0
- package/dist/lib/utils/openExperienceAndSetToken.js +10 -0
- package/dist/lib/utils/openExperienceAndSetToken.js.map +1 -0
- package/dist/lib-esm/components/index.d.ts +2 -0
- package/dist/lib-esm/components/index.d.ts.map +1 -0
- package/dist/lib-esm/components/index.js +2 -0
- package/dist/lib-esm/components/index.js.map +1 -0
- package/dist/lib-esm/components/lvble/index.d.ts +6 -0
- package/dist/lib-esm/components/lvble/index.d.ts.map +1 -0
- package/dist/lib-esm/components/lvble/index.js +28 -0
- package/dist/lib-esm/components/lvble/index.js.map +1 -0
- package/dist/lib-esm/context.d.ts +15 -0
- package/dist/lib-esm/context.d.ts.map +1 -0
- package/dist/lib-esm/context.js +26 -0
- package/dist/lib-esm/context.js.map +1 -0
- package/dist/lib-esm/index.d.ts +5 -0
- package/dist/lib-esm/index.d.ts.map +1 -0
- package/dist/lib-esm/index.js +5 -0
- package/dist/lib-esm/index.js.map +1 -0
- package/dist/lib-esm/storybook-utils.d.ts +5 -0
- package/dist/lib-esm/storybook-utils.d.ts.map +1 -0
- package/dist/lib-esm/storybook-utils.js +5 -0
- package/dist/lib-esm/storybook-utils.js.map +1 -0
- package/dist/lib-esm/utils/openExperience.d.ts +9 -0
- package/dist/lib-esm/utils/openExperience.d.ts.map +1 -0
- package/dist/lib-esm/utils/openExperience.js +13 -0
- package/dist/lib-esm/utils/openExperience.js.map +1 -0
- package/dist/lib-esm/utils/openExperienceAndSetToken.d.ts +4 -0
- package/dist/lib-esm/utils/openExperienceAndSetToken.d.ts.map +1 -0
- package/dist/lib-esm/utils/openExperienceAndSetToken.js +6 -0
- package/dist/lib-esm/utils/openExperienceAndSetToken.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2023] [Ignacio Andrés Miranda Figueroa]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# ⚛️⚡ Lvble react component
|
|
2
|
+
|
|
3
|
+
**@lvble/react** is a React package that provides a set of core functionalities for building interactive web applications with the lvble platform. It includes widgets.
|
|
4
|
+
|
|
5
|
+
## ⚡️ Quick start
|
|
6
|
+
|
|
7
|
+
### NPM
|
|
8
|
+
|
|
9
|
+
You can install **@lvble/react** using npm (Node Package Manager). Make sure you have Node.js and npm installed on your machine. Open your terminal or command prompt and run the following command:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @lvble/react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
You can then import the react package and start using our great widgets. In your `App.js` file you create a `LvbleProvider`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
19
|
+
import { ThemeProvider } from "@mui/material/styles";
|
|
20
|
+
import theme from "~/theme";
|
|
21
|
+
import { UserProvider } from "./hooks/user";
|
|
22
|
+
import rainbow from "~/lib/rainbow";
|
|
23
|
+
import MainContent from "./components/MainContent";
|
|
24
|
+
import Snackbar from "@mui/material/Snackbar";
|
|
25
|
+
import { LvbleProvider, Environment } from "@lvble/react";
|
|
26
|
+
import { useState, useCallback } from "react";
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
const onEvent = useCallback((eventType: string, data: any) => {
|
|
30
|
+
console.debug(`Lvble event: ${eventType} with ${data}`);
|
|
31
|
+
switch (eventType) {
|
|
32
|
+
case "EXPERIENCE_OPENED":
|
|
33
|
+
...
|
|
34
|
+
break;
|
|
35
|
+
case "EXPERIENCE_CLOSED":
|
|
36
|
+
...
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
console.log("Got unknown event", eventType, data);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<LvbleProvider environment={Environment.Local} onEvent={onEvent}>
|
|
46
|
+
<MainContent />
|
|
47
|
+
</LvbleProvider>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default App;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
And then you can use the `LvbleWidget` component:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { LvbleWidget } from "@lvble/react";
|
|
58
|
+
|
|
59
|
+
export default function Home() {
|
|
60
|
+
return (
|
|
61
|
+
<div className="flex flex-col gap-12">
|
|
62
|
+
<h1>Home</h1>
|
|
63
|
+
<div className="flex flex-wrap">
|
|
64
|
+
<LvbleWidget token="token" />
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Kudos
|
|
72
|
+
|
|
73
|
+
[This template](https://github.com/IgnacioNMiranda/vite-component-library-template)
|
|
74
|
+
[Ignacio Miranda Figueroa](https://www.linkedin.com/in/ignacio-miranda-figueroa/)
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
[MIT](LICENSE)
|
|
79
|
+
|
|
80
|
+
## Creator
|
|
81
|
+
|
|
82
|
+
[Lior Pollak](https://blog.liorp.dev/)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! For license information please see react.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@lvble/core"),require("react")):"function"==typeof define&&define.amd?define("MyLib",["@lvble/core","React"],t):"object"==typeof exports?exports.MyLib=t(require("@lvble/core"),require("react")):e.MyLib=t(e["@lvble/core"],e.React)}(self,((e,t)=>(()=>{"use strict";var r={354:(e,t,r)=>{var o=r(639),n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,u=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var o,i={},s=null,a=null;for(o in void 0!==r&&(s=""+r),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(a=t.ref),t)l.call(t,o)&&!c.hasOwnProperty(o)&&(i[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===i[o]&&(i[o]=t[o]);return{$$typeof:n,type:e,key:s,ref:a,props:i,_owner:u.current}}t.Fragment=i,t.jsx=s,t.jsxs=s},527:(e,t,r)=>{e.exports=r(354)},862:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(93),t)},93:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.LvbleWidget=void 0;const n=r(527),i=r(639),l=r(291);t.LvbleWidget=(0,i.memo)((e=>{var{token:t}=e,r=o(e,["token"]);const{lvble:u}=(0,l.useLvbleContext)(),c=(0,i.useMemo)((()=>null==u?void 0:u.createWidget({token:t})),[u,t]);return(0,n.jsx)("div",Object.assign({style:{minHeight:"220px",width:"100%",height:"100%"},ref:e=>{if(c){for(;null==e?void 0:e.firstChild;)null==e||e.removeChild(null==e?void 0:e.firstChild);null==e||e.appendChild(c)}}},r))}))},291:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useLvbleContext=t.LvbleProvider=void 0;const o=r(527),n=r(639),i=r(54),l=(0,n.createContext)(null);t.LvbleProvider=({environment:e,onEvent:t,modal:r,customApiUrl:u,children:c})=>{const s=(0,n.useMemo)((()=>{if(e)return(0,i.Lvble)({environment:e,onEvent:t,modal:r,customApiUrl:u})}),[e,t,r,u]);return(0,o.jsx)(l.Provider,{value:{lvble:s},children:c})},t.useLvbleContext=()=>{const e=(0,n.useContext)(l);if(null==e)throw new Error("useLvbleContext must be used within a LvbleProvider");return e}},887:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.Environment=void 0;const i=r(54);n(r(862),t),n(r(291),t),t.Environment=i.Environment},54:t=>{t.exports=e},639:e=>{e.exports=t}},o={};return function e(t){var n=o[t];if(void 0!==n)return n.exports;var i=o[t]={exports:{}};return r[t].call(i.exports,i,i.exports,e),i.exports}(887)})()));
|
|
3
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","mappings":"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","sources":["webpack://MyLib/webpack/universalModuleDefinition","webpack://MyLib/./node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react-jsx-runtime.production.min.js","webpack://MyLib/./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js","webpack://MyLib/./src/lib/components/index.ts","webpack://MyLib/./src/lib/components/lvble/index.tsx","webpack://MyLib/./src/lib/context.tsx","webpack://MyLib/./src/lib/index.ts","webpack://MyLib/external umd {\"commonjs\":\"@lvble/core\",\"commonjs2\":\"@lvble/core\",\"amd\":\"@lvble/core\",\"root\":\"@lvble/core\"}","webpack://MyLib/external umd {\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"React\",\"root\":\"React\"}","webpack://MyLib/webpack/bootstrap","webpack://MyLib/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@lvble/core\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MyLib\", [\"@lvble/core\", \"React\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLib\"] = factory(require(\"@lvble/core\"), require(\"react\"));\n\telse\n\t\troot[\"MyLib\"] = factory(root[\"@lvble/core\"], root[\"React\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__54__, __WEBPACK_EXTERNAL_MODULE__639__) => {\nreturn ","/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","export * from \"./lvble\";\n","import React, { memo, useMemo } from \"react\";\nimport { useLvbleContext } from \"../../context\";\n\nexport type LvbleWidgetProps = {\n token: string;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nexport const LvbleWidget = memo(({ token, ...props }: LvbleWidgetProps) => {\n const { lvble } = useLvbleContext();\n const widget = useMemo(() => lvble?.createWidget({ token }), [lvble, token]);\n return (\n <div style={{ minHeight: \"220px\", width: \"100%\", height: \"100%\" }}\n ref={(ref) => {\n if (!widget) return;\n while (ref?.firstChild) {\n ref?.removeChild(ref?.firstChild);\n }\n ref?.appendChild(widget);\n }}\n {...props}\n ></div>\n );\n});","import {\n ReactNode,\n useEffect,\n createContext,\n useContext,\n useState,\n useMemo,\n} from \"react\";\nimport {\n type Environment,\n type LvbleType,\n type ModalOptions,\n Lvble,\n} from \"@lvble/core\";\n\ntype LvbleContextType = {\n lvble?: LvbleType;\n};\n\nconst LvbleContext = createContext<LvbleContextType | null | undefined>(null);\n\nexport const LvbleProvider = ({\n environment,\n onEvent,\n modal,\n customApiUrl,\n children,\n}: {\n environment: Environment;\n onEvent: (eventType: string, data: any) => void;\n modal?: ModalOptions;\n customApiUrl?: string | null,\n children: ReactNode;\n}) => {\n const lvble = useMemo(() => {\n if (!environment) return;\n const l = Lvble({\n environment,\n onEvent,\n modal,\n customApiUrl,\n });\n return l;\n }, [environment, onEvent, modal, customApiUrl]);\n\n return (\n <LvbleContext.Provider value={{ lvble }}>{children}</LvbleContext.Provider>\n );\n};\n\nexport const useLvbleContext = () => {\n const context = useContext(LvbleContext);\n if (context === undefined || context === null) {\n throw new Error(\"useLvbleContext must be used within a LvbleProvider\");\n }\n return context;\n};\n","import { Environment as _Environment } from \"@lvble/core\";\n\nexport * from \"./components\";\nexport * from \"./context\";\nexport const Environment = _Environment;\n","module.exports = __WEBPACK_EXTERNAL_MODULE__54__;","module.exports = __WEBPACK_EXTERNAL_MODULE__639__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(887);\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__54__","__WEBPACK_EXTERNAL_MODULE__639__","f","k","Symbol","for","l","m","Object","prototype","hasOwnProperty","n","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","ReactCurrentOwner","p","key","ref","__self","__source","q","c","a","g","b","d","e","h","call","defaultProps","$$typeof","type","props","_owner","current","Fragment","jsx","jsxs","LvbleWidget","memo","token","lvble","useLvbleContext","widget","useMemo","createWidget","style","minHeight","width","height","firstChild","removeChild","appendChild","LvbleContext","createContext","LvbleProvider","environment","onEvent","modal","customApiUrl","children","Lvble","Provider","value","context","useContext","Error","Environment","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! For license information please see react.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@lvble/core"),require("react")):"function"==typeof define&&define.amd?define("MyLib",["@lvble/core","React"],t):"object"==typeof exports?exports.MyLib=t(require("@lvble/core"),require("react")):e.MyLib=t(e["@lvble/core"],e.React)}(self,((e,t)=>(()=>{"use strict";var r={354:(e,t,r)=>{var o=r(639),n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,u=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var o,i={},s=null,a=null;for(o in void 0!==r&&(s=""+r),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(a=t.ref),t)l.call(t,o)&&!c.hasOwnProperty(o)&&(i[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===i[o]&&(i[o]=t[o]);return{$$typeof:n,type:e,key:s,ref:a,props:i,_owner:u.current}}t.Fragment=i,t.jsx=s,t.jsxs=s},527:(e,t,r)=>{e.exports=r(354)},862:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(93),t)},93:function(e,t,r){var o=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.LvbleWidget=void 0;const n=r(527),i=r(639),l=r(291);t.LvbleWidget=(0,i.memo)((e=>{var{token:t}=e,r=o(e,["token"]);const{lvble:u}=(0,l.useLvbleContext)(),c=(0,i.useMemo)((()=>null==u?void 0:u.createWidget({token:t})),[u,t]);return(0,n.jsx)("div",Object.assign({style:{minHeight:"220px",width:"100%",height:"100%"},ref:e=>{if(c){for(;null==e?void 0:e.firstChild;)null==e||e.removeChild(null==e?void 0:e.firstChild);null==e||e.appendChild(c)}}},r))}))},291:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useLvbleContext=t.LvbleProvider=void 0;const o=r(527),n=r(639),i=r(54),l=(0,n.createContext)(null);t.LvbleProvider=({environment:e,onEvent:t,modal:r,customApiUrl:u,children:c})=>{const s=(0,n.useMemo)((()=>{if(e)return(0,i.Lvble)({environment:e,onEvent:t,modal:r,customApiUrl:u})}),[e,t,r,u]);return(0,o.jsx)(l.Provider,{value:{lvble:s},children:c})},t.useLvbleContext=()=>{const e=(0,n.useContext)(l);if(null==e)throw new Error("useLvbleContext must be used within a LvbleProvider");return e}},887:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.Environment=void 0;const i=r(54);n(r(862),t),n(r(291),t),t.Environment=i.Environment},54:t=>{t.exports=e},639:e=>{e.exports=t}},o={};return function e(t){var n=o[t];if(void 0!==n)return n.exports;var i=o[t]={exports:{}};return r[t].call(i.exports,i,i.exports,e),i.exports}(887)})()));
|
|
3
|
+
//# sourceMappingURL=react.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.min.js","mappings":"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","sources":["webpack://MyLib/webpack/universalModuleDefinition","webpack://MyLib/./node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react-jsx-runtime.production.min.js","webpack://MyLib/./node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js","webpack://MyLib/./src/lib/components/index.ts","webpack://MyLib/./src/lib/components/lvble/index.tsx","webpack://MyLib/./src/lib/context.tsx","webpack://MyLib/./src/lib/index.ts","webpack://MyLib/external umd {\"commonjs\":\"@lvble/core\",\"commonjs2\":\"@lvble/core\",\"amd\":\"@lvble/core\",\"root\":\"@lvble/core\"}","webpack://MyLib/external umd {\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"React\",\"root\":\"React\"}","webpack://MyLib/webpack/bootstrap","webpack://MyLib/webpack/startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@lvble/core\"), require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MyLib\", [\"@lvble/core\", \"React\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MyLib\"] = factory(require(\"@lvble/core\"), require(\"react\"));\n\telse\n\t\troot[\"MyLib\"] = factory(root[\"@lvble/core\"], root[\"React\"]);\n})(self, (__WEBPACK_EXTERNAL_MODULE__54__, __WEBPACK_EXTERNAL_MODULE__639__) => {\nreturn ","/**\n * @license React\n * react-jsx-runtime.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var f=require(\"react\"),k=Symbol.for(\"react.element\"),l=Symbol.for(\"react.fragment\"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};\nfunction q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=\"\"+g);void 0!==a.key&&(e=\"\"+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","export * from \"./lvble\";\n","import React, { memo, useMemo } from \"react\";\nimport { useLvbleContext } from \"../../context\";\n\nexport type LvbleWidgetProps = {\n token: string;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nexport const LvbleWidget = memo(({ token, ...props }: LvbleWidgetProps) => {\n const { lvble } = useLvbleContext();\n const widget = useMemo(() => lvble?.createWidget({ token }), [lvble, token]);\n return (\n <div style={{ minHeight: \"220px\", width: \"100%\", height: \"100%\" }}\n ref={(ref) => {\n if (!widget) return;\n while (ref?.firstChild) {\n ref?.removeChild(ref?.firstChild);\n }\n ref?.appendChild(widget);\n }}\n {...props}\n ></div>\n );\n});","import {\n ReactNode,\n useEffect,\n createContext,\n useContext,\n useState,\n useMemo,\n} from \"react\";\nimport {\n type Environment,\n type LvbleType,\n type ModalOptions,\n Lvble,\n} from \"@lvble/core\";\n\ntype LvbleContextType = {\n lvble?: LvbleType;\n};\n\nconst LvbleContext = createContext<LvbleContextType | null | undefined>(null);\n\nexport const LvbleProvider = ({\n environment,\n onEvent,\n modal,\n customApiUrl,\n children,\n}: {\n environment: Environment;\n onEvent: (eventType: string, data: any) => void;\n modal?: ModalOptions;\n customApiUrl?: string | null,\n children: ReactNode;\n}) => {\n const lvble = useMemo(() => {\n if (!environment) return;\n const l = Lvble({\n environment,\n onEvent,\n modal,\n customApiUrl,\n });\n return l;\n }, [environment, onEvent, modal, customApiUrl]);\n\n return (\n <LvbleContext.Provider value={{ lvble }}>{children}</LvbleContext.Provider>\n );\n};\n\nexport const useLvbleContext = () => {\n const context = useContext(LvbleContext);\n if (context === undefined || context === null) {\n throw new Error(\"useLvbleContext must be used within a LvbleProvider\");\n }\n return context;\n};\n","import { Environment as _Environment } from \"@lvble/core\";\n\nexport * from \"./components\";\nexport * from \"./context\";\nexport const Environment = _Environment;\n","module.exports = __WEBPACK_EXTERNAL_MODULE__54__;","module.exports = __WEBPACK_EXTERNAL_MODULE__639__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(887);\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__54__","__WEBPACK_EXTERNAL_MODULE__639__","f","k","Symbol","for","l","m","Object","prototype","hasOwnProperty","n","__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","ReactCurrentOwner","p","key","ref","__self","__source","q","c","a","g","b","d","e","h","call","defaultProps","$$typeof","type","props","_owner","current","Fragment","jsx","jsxs","LvbleWidget","memo","token","lvble","useLvbleContext","widget","useMemo","createWidget","style","minHeight","width","height","firstChild","removeChild","appendChild","LvbleContext","createContext","LvbleProvider","environment","onEvent","modal","customApiUrl","children","Lvble","Provider","value","context","useContext","Error","Environment","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lvble"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type LvbleWidgetProps = {
|
|
3
|
+
token: string;
|
|
4
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
export declare const LvbleWidget: React.MemoExoticComponent<({ token, ...props }: LvbleWidgetProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/lvble/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAG7C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;AAEzC,eAAO,MAAM,WAAW,kDAA8B,gBAAgB,6CAepE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.LvbleWidget = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const context_1 = require("../../context");
|
|
18
|
+
exports.LvbleWidget = (0, react_1.memo)((_a) => {
|
|
19
|
+
var { token } = _a, props = __rest(_a, ["token"]);
|
|
20
|
+
const { lvble } = (0, context_1.useLvbleContext)();
|
|
21
|
+
const widget = (0, react_1.useMemo)(() => lvble === null || lvble === void 0 ? void 0 : lvble.createWidget({ token }), [lvble, token]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ style: { minHeight: "220px", width: "100%", height: "100%" }, ref: (ref) => {
|
|
23
|
+
if (!widget)
|
|
24
|
+
return;
|
|
25
|
+
while (ref === null || ref === void 0 ? void 0 : ref.firstChild) {
|
|
26
|
+
ref === null || ref === void 0 ? void 0 : ref.removeChild(ref === null || ref === void 0 ? void 0 : ref.firstChild);
|
|
27
|
+
}
|
|
28
|
+
ref === null || ref === void 0 ? void 0 : ref.appendChild(widget);
|
|
29
|
+
} }, props)));
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/components/lvble/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAA6C;AAC7C,2CAAgD;AAMnC,QAAA,WAAW,GAAG,IAAA,YAAI,EAAC,CAAC,EAAqC,EAAE,EAAE;QAAzC,EAAE,KAAK,OAA8B,EAAzB,KAAK,cAAjB,SAAmB,CAAF;IAChD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,yBAAe,GAAE,CAAC;IACpC,MAAM,MAAM,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7E,OAAO,CACL,8CAAK,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAC/D,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,OAAO,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAE;gBACtB,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAC,CAAC;aACnC;YACD,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,IACG,KAAK,EACJ,CACR,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { type Environment, type LvbleType, type ModalOptions } from "@lvble/core";
|
|
3
|
+
type LvbleContextType = {
|
|
4
|
+
lvble?: LvbleType;
|
|
5
|
+
};
|
|
6
|
+
export declare const LvbleProvider: ({ environment, onEvent, modal, customApiUrl, children, }: {
|
|
7
|
+
environment: Environment;
|
|
8
|
+
onEvent: (eventType: string, data: any) => void;
|
|
9
|
+
modal?: ModalOptions | undefined;
|
|
10
|
+
customApiUrl?: string | null | undefined;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const useLvbleContext: () => LvbleContextType;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/lib/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,aAAa;iBAOX,WAAW;yBACH,MAAM,QAAQ,GAAG,KAAK,IAAI;;;cAGrC,SAAS;6CAgBpB,CAAC;AAEF,eAAO,MAAM,eAAe,wBAM3B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLvbleContext = exports.LvbleProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const core_1 = require("@lvble/core");
|
|
7
|
+
const LvbleContext = (0, react_1.createContext)(null);
|
|
8
|
+
const LvbleProvider = ({ environment, onEvent, modal, customApiUrl, children, }) => {
|
|
9
|
+
const lvble = (0, react_1.useMemo)(() => {
|
|
10
|
+
if (!environment)
|
|
11
|
+
return;
|
|
12
|
+
const l = (0, core_1.Lvble)({
|
|
13
|
+
environment,
|
|
14
|
+
onEvent,
|
|
15
|
+
modal,
|
|
16
|
+
customApiUrl,
|
|
17
|
+
});
|
|
18
|
+
return l;
|
|
19
|
+
}, [environment, onEvent, modal, customApiUrl]);
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(LvbleContext.Provider, { value: { lvble }, children: children }));
|
|
21
|
+
};
|
|
22
|
+
exports.LvbleProvider = LvbleProvider;
|
|
23
|
+
const useLvbleContext = () => {
|
|
24
|
+
const context = (0, react_1.useContext)(LvbleContext);
|
|
25
|
+
if (context === undefined || context === null) {
|
|
26
|
+
throw new Error("useLvbleContext must be used within a LvbleProvider");
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
};
|
|
30
|
+
exports.useLvbleContext = useLvbleContext;
|
|
31
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/lib/context.tsx"],"names":[],"mappings":";;;;AAAA,iCAOe;AACf,sCAKqB;AAMrB,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAsC,IAAI,CAAC,CAAC;AAEvE,MAAM,aAAa,GAAG,CAAC,EAC5B,WAAW,EACX,OAAO,EACP,KAAK,EACL,YAAY,EACZ,QAAQ,GAOT,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACzB,IAAI,CAAC,WAAW;YAAE,OAAO;QACzB,MAAM,CAAC,GAAG,IAAA,YAAK,EAAC;YACd,WAAW;YACX,OAAO;YACP,KAAK;YACL,YAAY;SACb,CAAC,CAAC;QACH,OAAO,CAAC,CAAC;IACX,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IAEhD,OAAO,CACL,uBAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,YAAG,QAAQ,GAAyB,CAC5E,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,aAAa,iBA2BxB;AAEK,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,YAAY,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,eAAO,MAAM,WAAW,qBAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Environment = void 0;
|
|
18
|
+
const core_1 = require("@lvble/core");
|
|
19
|
+
__exportStar(require("./components"), exports);
|
|
20
|
+
__exportStar(require("./context"), exports);
|
|
21
|
+
exports.Environment = core_1.Environment;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,sCAA0D;AAE1D,+CAA6B;AAC7B,4CAA0B;AACb,QAAA,WAAW,GAAG,kBAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-utils.d.ts","sourceRoot":"","sources":["../../src/lib/storybook-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,QAAS,OAAO,MAAM,EAAE,MAAM,CAAC;;;CAGhE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectValuesToControls = void 0;
|
|
4
|
+
const objectValuesToControls = (obj, control = 'select') => ({
|
|
5
|
+
control,
|
|
6
|
+
options: Object.keys(obj),
|
|
7
|
+
});
|
|
8
|
+
exports.objectValuesToControls = objectValuesToControls;
|
|
9
|
+
//# sourceMappingURL=storybook-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-utils.js","sourceRoot":"","sources":["../../src/lib/storybook-utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,sBAAsB,GAAG,CAAC,GAA2B,EAAE,OAAO,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1F,OAAO;IACP,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;CAC1B,CAAC,CAAA;AAHW,QAAA,sBAAsB,0BAGjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Environment, type ModalOptions } from "@lvble/core";
|
|
2
|
+
export declare const openExperience: ({ token, environment, onEvent, modal, customApiUrl, }: {
|
|
3
|
+
token: string;
|
|
4
|
+
environment: Environment;
|
|
5
|
+
onEvent: (eventType: string, data: any) => void;
|
|
6
|
+
modal?: ModalOptions | undefined;
|
|
7
|
+
customApiUrl?: string | null | undefined;
|
|
8
|
+
}) => null | undefined;
|
|
9
|
+
//# sourceMappingURL=openExperience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperience.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/openExperience.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAc,MAAM,aAAa,CAAC;AAE9E,eAAO,MAAM,cAAc;WAOlB,MAAM;iBACA,WAAW;yBACH,MAAM,QAAQ,GAAG,KAAK,IAAI;;;sBAahD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openExperience = void 0;
|
|
4
|
+
const core_1 = require("@lvble/core");
|
|
5
|
+
const openExperience = ({ token, environment, onEvent, modal, customApiUrl, }) => {
|
|
6
|
+
if (!environment || !onEvent)
|
|
7
|
+
return null;
|
|
8
|
+
const livbleInstance = (0, core_1.Lvble)({
|
|
9
|
+
environment,
|
|
10
|
+
onEvent,
|
|
11
|
+
modal,
|
|
12
|
+
customApiUrl,
|
|
13
|
+
});
|
|
14
|
+
livbleInstance.open(token);
|
|
15
|
+
};
|
|
16
|
+
exports.openExperience = openExperience;
|
|
17
|
+
//# sourceMappingURL=openExperience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperience.js","sourceRoot":"","sources":["../../../src/lib/utils/openExperience.ts"],"names":[],"mappings":";;;AAEA,sCAAoC;AAG7B,MAAM,cAAc,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,OAAO,EACP,KAAK,EACL,YAAY,GAOb,EAAE,EAAE;IACH,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAA,YAAK,EAAC;QAC3B,WAAW;QACX,OAAO;QACP,KAAK;QACL,YAAY;KACb,CAAC,CAAC;IAEH,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC;AAtBW,QAAA,cAAc,kBAsBzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperienceAndSetToken.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/openExperienceAndSetToken.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB;WAAwB,MAAM;UAInE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openExperienceAndSetToken = void 0;
|
|
4
|
+
const core_1 = require("@lvble/core");
|
|
5
|
+
const openExperienceAndSetToken = ({ token }) => {
|
|
6
|
+
const livbleInstance = (0, core_1.Lvble)();
|
|
7
|
+
livbleInstance.openExperienceAndSetToken(token);
|
|
8
|
+
};
|
|
9
|
+
exports.openExperienceAndSetToken = openExperienceAndSetToken;
|
|
10
|
+
//# sourceMappingURL=openExperienceAndSetToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperienceAndSetToken.js","sourceRoot":"","sources":["../../../src/lib/utils/openExperienceAndSetToken.ts"],"names":[],"mappings":";;;AAEA,sCAAoC;AAE7B,MAAM,yBAAyB,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IACxE,MAAM,cAAc,GAAG,IAAA,YAAK,GAAE,CAAC;IAE/B,cAAc,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type LvbleWidgetProps = {
|
|
3
|
+
token: string;
|
|
4
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
export declare const LvbleWidget: React.MemoExoticComponent<({ token, ...props }: LvbleWidgetProps) => import("react/jsx-runtime").JSX.Element>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/lvble/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAG7C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;AAEzC,eAAO,MAAM,WAAW,kDAA8B,gBAAgB,6CAepE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { memo, useMemo } from "react";
|
|
14
|
+
import { useLvbleContext } from "../../context";
|
|
15
|
+
export const LvbleWidget = memo((_a) => {
|
|
16
|
+
var { token } = _a, props = __rest(_a, ["token"]);
|
|
17
|
+
const { lvble } = useLvbleContext();
|
|
18
|
+
const widget = useMemo(() => lvble === null || lvble === void 0 ? void 0 : lvble.createWidget({ token }), [lvble, token]);
|
|
19
|
+
return (_jsx("div", Object.assign({ style: { minHeight: "220px", width: "100%", height: "100%" }, ref: (ref) => {
|
|
20
|
+
if (!widget)
|
|
21
|
+
return;
|
|
22
|
+
while (ref === null || ref === void 0 ? void 0 : ref.firstChild) {
|
|
23
|
+
ref === null || ref === void 0 ? void 0 : ref.removeChild(ref === null || ref === void 0 ? void 0 : ref.firstChild);
|
|
24
|
+
}
|
|
25
|
+
ref === null || ref === void 0 ? void 0 : ref.appendChild(widget);
|
|
26
|
+
} }, props)));
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/components/lvble/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMhD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,EAAqC,EAAE,EAAE;QAAzC,EAAE,KAAK,OAA8B,EAAzB,KAAK,cAAjB,SAAmB,CAAF;IAChD,MAAM,EAAE,KAAK,EAAE,GAAG,eAAe,EAAE,CAAC;IACpC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7E,OAAO,CACL,4BAAK,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAC/D,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;YACX,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,OAAO,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAE;gBACtB,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,CAAC,CAAC;aACnC;YACD,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,IACG,KAAK,EACJ,CACR,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { type Environment, type LvbleType, type ModalOptions } from "@lvble/core";
|
|
3
|
+
type LvbleContextType = {
|
|
4
|
+
lvble?: LvbleType;
|
|
5
|
+
};
|
|
6
|
+
export declare const LvbleProvider: ({ environment, onEvent, modal, customApiUrl, children, }: {
|
|
7
|
+
environment: Environment;
|
|
8
|
+
onEvent: (eventType: string, data: any) => void;
|
|
9
|
+
modal?: ModalOptions | undefined;
|
|
10
|
+
customApiUrl?: string | null | undefined;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const useLvbleContext: () => LvbleContextType;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/lib/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AACf,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAIF,eAAO,MAAM,aAAa;iBAOX,WAAW;yBACH,MAAM,QAAQ,GAAG,KAAK,IAAI;;;cAGrC,SAAS;6CAgBpB,CAAC;AAEF,eAAO,MAAM,eAAe,wBAM3B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, } from "react";
|
|
3
|
+
import { Lvble, } from "@lvble/core";
|
|
4
|
+
const LvbleContext = createContext(null);
|
|
5
|
+
export const LvbleProvider = ({ environment, onEvent, modal, customApiUrl, children, }) => {
|
|
6
|
+
const lvble = useMemo(() => {
|
|
7
|
+
if (!environment)
|
|
8
|
+
return;
|
|
9
|
+
const l = Lvble({
|
|
10
|
+
environment,
|
|
11
|
+
onEvent,
|
|
12
|
+
modal,
|
|
13
|
+
customApiUrl,
|
|
14
|
+
});
|
|
15
|
+
return l;
|
|
16
|
+
}, [environment, onEvent, modal, customApiUrl]);
|
|
17
|
+
return (_jsx(LvbleContext.Provider, { value: { lvble }, children: children }));
|
|
18
|
+
};
|
|
19
|
+
export const useLvbleContext = () => {
|
|
20
|
+
const context = useContext(LvbleContext);
|
|
21
|
+
if (context === undefined || context === null) {
|
|
22
|
+
throw new Error("useLvbleContext must be used within a LvbleProvider");
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/lib/context.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,aAAa,EACb,UAAU,EAEV,OAAO,GACR,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,GACN,MAAM,aAAa,CAAC;AAMrB,MAAM,YAAY,GAAG,aAAa,CAAsC,IAAI,CAAC,CAAC;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,WAAW,EACX,OAAO,EACP,KAAK,EACL,YAAY,EACZ,QAAQ,GAOT,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,IAAI,CAAC,WAAW;YAAE,OAAO;QACzB,MAAM,CAAC,GAAG,KAAK,CAAC;YACd,WAAW;YACX,OAAO;YACP,KAAK;YACL,YAAY;SACb,CAAC,CAAC;QACH,OAAO,CAAC,CAAC;IACX,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IAEhD,OAAO,CACL,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,YAAG,QAAQ,GAAyB,CAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,eAAO,MAAM,WAAW,qBAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1D,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-utils.d.ts","sourceRoot":"","sources":["../../src/lib/storybook-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,QAAS,OAAO,MAAM,EAAE,MAAM,CAAC;;;CAGhE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-utils.js","sourceRoot":"","sources":["../../src/lib/storybook-utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAA2B,EAAE,OAAO,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1F,OAAO;IACP,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;CAC1B,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Environment, type ModalOptions } from "@lvble/core";
|
|
2
|
+
export declare const openExperience: ({ token, environment, onEvent, modal, customApiUrl, }: {
|
|
3
|
+
token: string;
|
|
4
|
+
environment: Environment;
|
|
5
|
+
onEvent: (eventType: string, data: any) => void;
|
|
6
|
+
modal?: ModalOptions | undefined;
|
|
7
|
+
customApiUrl?: string | null | undefined;
|
|
8
|
+
}) => null | undefined;
|
|
9
|
+
//# sourceMappingURL=openExperience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperience.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/openExperience.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAc,MAAM,aAAa,CAAC;AAE9E,eAAO,MAAM,cAAc;WAOlB,MAAM;iBACA,WAAW;yBACH,MAAM,QAAQ,GAAG,KAAK,IAAI;;;sBAahD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Lvble } from "@lvble/core";
|
|
2
|
+
export const openExperience = ({ token, environment, onEvent, modal, customApiUrl, }) => {
|
|
3
|
+
if (!environment || !onEvent)
|
|
4
|
+
return null;
|
|
5
|
+
const livbleInstance = Lvble({
|
|
6
|
+
environment,
|
|
7
|
+
onEvent,
|
|
8
|
+
modal,
|
|
9
|
+
customApiUrl,
|
|
10
|
+
});
|
|
11
|
+
livbleInstance.open(token);
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=openExperience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperience.js","sourceRoot":"","sources":["../../../src/lib/utils/openExperience.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,OAAO,EACP,KAAK,EACL,YAAY,GAOb,EAAE,EAAE;IACH,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1C,MAAM,cAAc,GAAG,KAAK,CAAC;QAC3B,WAAW;QACX,OAAO;QACP,KAAK;QACL,YAAY;KACb,CAAC,CAAC;IAEH,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperienceAndSetToken.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/openExperienceAndSetToken.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB;WAAwB,MAAM;UAInE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openExperienceAndSetToken.js","sourceRoot":"","sources":["../../../src/lib/utils/openExperienceAndSetToken.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IACxE,MAAM,cAAc,GAAG,KAAK,EAAE,CAAC;IAE/B,cAAc,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lvble/react",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "2.0.71",
|
|
5
|
+
"main": "./dist/_bundles/index.js",
|
|
6
|
+
"module": "./dist/lib-esm/index.js",
|
|
7
|
+
"types": "./dist/lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/lib-esm/index.js",
|
|
11
|
+
"require": "./dist/lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./dist/style.css": "./dist/style.css"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=14.0.0"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"start": "tsc && tsc -m es6 --outDir dist/lib-esm --watch",
|
|
20
|
+
"build:webpack": "webpack --config webpack.config.js --watch",
|
|
21
|
+
"link:lvble-core": "pnpm link ../core",
|
|
22
|
+
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx --fix",
|
|
23
|
+
"format:prettier": "prettier --write \"src/**/*.{ts,tsx,js,mdx}\"",
|
|
24
|
+
"test": "vitest",
|
|
25
|
+
"test:cov": "vitest run --coverage",
|
|
26
|
+
"prepack": ""
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"lint-staged": {
|
|
32
|
+
"*.{ts,tsx,js,jsx,json,css,md}": [
|
|
33
|
+
"prettier -w"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@babel/preset-env": "^7.22.15",
|
|
38
|
+
"@babel/preset-react": "^7.22.15",
|
|
39
|
+
"@types/react": "^18.2.16",
|
|
40
|
+
"autoprefixer": "^10.4.14",
|
|
41
|
+
"babel-loader": "^9.1.3",
|
|
42
|
+
"css-loader": "^6.8.1",
|
|
43
|
+
"html-webpack-plugin": "^5.5.3",
|
|
44
|
+
"postcss-loader": "^7.3.3",
|
|
45
|
+
"react": "^18.2.0",
|
|
46
|
+
"react-dom": "^18.2.0",
|
|
47
|
+
"style-loader": "^3.3.3",
|
|
48
|
+
"tailwindcss": "^3.3.3",
|
|
49
|
+
"ts-loader": "^9.4.4",
|
|
50
|
+
"webpack": "^5.88.2",
|
|
51
|
+
"webpack-cli": "^5.1.4",
|
|
52
|
+
"webpack-dev-server": "^4.15.1"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"pkg-dir": "^7.0.0",
|
|
56
|
+
"@lvble/core": "^2.0.71"
|
|
57
|
+
}
|
|
58
|
+
}
|