crosstalk-comments-livechat-sdk 0.0.3 → 0.0.5-beta.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.
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["crosstalk-comments-livechat-sdk"]=t():e["crosstalk-comments-livechat-sdk"]=t()}(this,()=>(()=>{"use strict";var e={};class t{constructor(e,t){this.container=e,this.config=t,this.iframe=null,this.messageHandler=null,this.render()}setupMessageListener(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.messageHandler=e=>{if((!this.iframe||e.source===this.iframe.contentWindow)&&e.origin.includes(".crosstalk.cc"))try{const t=JSON.parse(e.data);t.asize&&(this.iframe.style.height=`${t.asize}px`)}catch(e){}},window.addEventListener("message",this.messageHandler)}render(){this.container.innerHTML="",this.iframe=document.createElement("iframe"),this.iframe.src=function(e){const t=new URLSearchParams;return e.wp&&t.append("wp",e.wp),e.url&&t.append("url",e.url),e.theme&&t.append("theme",e.theme),`https://widgets.crosstalk.cc/ai_summary?${t.toString()}`}(this.config),this.iframe.setAttribute("style","width: 100%; scrollbar-width:thin !important"),this.iframe.setAttribute("frameborder","0"),this.iframe.sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups",this.iframe.scrolling="no",this.container.appendChild(this.iframe),this.setupMessageListener()}update(e){this.config={...this.config,...e},this.render()}destroy(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.iframe.parentNode&&(this.iframe.parentNode.removeChild(this.iframe),this.iframe=null)}getIframe(){return this.iframe}}function s(e,s){return new t(e,s)}class i{constructor(e,t){this.container=e,this.config=t,this.iframe=null,this.messageHandler=null,this.render()}setupMessageListener(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.messageHandler=e=>{if((!this.iframe||e.source===this.iframe.contentWindow)&&e.origin.includes(".crosstalk.cc"))try{const t=JSON.parse(e.data);t.csize&&(this.iframe.style.height=`${t.csize}px`)}catch(e){}},window.addEventListener("message",this.messageHandler)}render(){this.container.innerHTML="",this.iframe=document.createElement("iframe"),this.iframe.src=function(e){const t=new URLSearchParams;return t.append("wp",e.wp),e.url?t.append("url",e.url):e.pageID&&t.append("pageID",e.pageID),e.theme&&t.append("theme",e.theme),void 0!==e.reactions&&t.append("reactions",String(e.reactions)),`https://widgets.crosstalk.cc/comments?${t.toString()}`}(this.config),this.iframe.setAttribute("style","width: 100%; scrollbar-width:thin !important"),this.iframe.setAttribute("frameborder","0"),this.iframe.sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups",this.iframe.scrolling="no",this.container.appendChild(this.iframe),this.setupMessageListener()}update(e){this.config={...this.config,...e},this.render()}destroy(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.iframe.parentNode&&(this.iframe.parentNode.removeChild(this.iframe),this.iframe=null)}getIframe(){return this.iframe}}function a(e,t){return new i(e,t)}class r{constructor(e,t){this.container=e,this.config=t,this.iframe=null,this.messageHandler=null,this.render()}setupMessageListener(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.messageHandler=e=>{if((!this.iframe||e.source===this.iframe.contentWindow)&&e.origin.includes(".crosstalk.cc"))try{const t=JSON.parse(e.data);t.psize&&(this.iframe.style.height=`${t.psize}px`)}catch(e){}},window.addEventListener("message",this.messageHandler)}render(){this.container.innerHTML="",this.iframe=document.createElement("iframe"),this.iframe.src=function(e){const t=new URLSearchParams;return t.append("wp",e.wp),e.url?t.append("url",e.url):e.pageID&&t.append("pageID",e.pageID),e.theme&&t.append("theme",e.theme),e.pollID&&t.append("pollID",e.pollID),`https://widgets.crosstalk.cc/poll?${t.toString()}`}(this.config),this.iframe.setAttribute("style","width: 100%; scrollbar-width:thin !important"),this.iframe.setAttribute("frameborder","0"),this.iframe.sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups",this.iframe.scrolling="no",this.container.appendChild(this.iframe),this.setupMessageListener()}update(e){this.config={...this.config,...e},this.render()}destroy(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.iframe.parentNode&&(this.iframe.parentNode.removeChild(this.iframe),this.iframe=null)}getIframe(){return this.iframe}}function n(e,t){return new r(e,t)}class o{constructor(e,t){this.container=e,this.config=t,this.iframe=null,this.messageHandler=null,this.render()}setupMessageListener(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.messageHandler=e=>{if((!this.iframe||e.source===this.iframe.contentWindow)&&e.origin.includes(".crosstalk.cc"))try{const t=JSON.parse(e.data);t.vsize&&(this.iframe.style.height=`${t.vsize}px`)}catch(e){}},window.addEventListener("message",this.messageHandler)}render(){this.container.innerHTML="",this.iframe=document.createElement("iframe"),this.iframe.src=function(e){const t=new URLSearchParams;return t.append("wp",e.wp),e.url?t.append("url",e.url):e.pageID&&t.append("pageID",e.pageID),e.theme&&t.append("theme",e.theme),e.src&&e.srcType&&(t.append("src",e.src),t.append("srcType",e.srcType)),e.ytvid&&t.append("ytvid",e.ytvid),e.rtvid&&t.append("rtvid",e.rtvid),e.vkvid&&t.append("vkvid",e.vkvid),e.vklive&&t.append("vklive",e.vklive),e.vimeoid&&t.append("vimeoid",e.vimeoid),`https://widgets.crosstalk.cc/video?${t.toString()}`}(this.config),this.iframe.setAttribute("style","width: 100%; scrollbar-width:thin !important"),this.iframe.setAttribute("frameborder","0"),this.iframe.sandbox="allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups",this.iframe.scrolling="auto",this.container.appendChild(this.iframe),this.setupMessageListener()}update(e){this.config={...this.config,...e},this.render()}destroy(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.iframe&&this.iframe.parentNode&&(this.iframe.parentNode.removeChild(this.iframe),this.iframe=null)}getIframe(){return this.iframe}}function d(e,t){return new o(e,t)}const l={initComments:a,initPlayer:d,initPoll:n,initAISummary:s,initAll(){return console.log("crosstalk initialised"),function(){const e=document.querySelectorAll("div[data-crosstalk-comments]"),t=[];e.forEach(e=>{const s=a(e,{wp:e.dataset.wp,url:e.dataset.url||"",pageID:e.dataset.pageId||"",theme:e.dataset.theme||"light",reactions:"true"===e.dataset.reactions});s&&t.push(s)})}(),function(){const e=document.querySelectorAll("div[data-crosstalk-video-player]"),t=[];e.forEach(e=>{const s=d(e,{wp:e.dataset.wp,url:e.dataset.url||"",pageID:e.dataset.pageId||"",theme:e.dataset.theme||"light",src:e.dataset.src||"",srcType:e.dataset.srcType||"",ytvid:e.dataset.ytId||"",rtvid:e.dataset.rtId||"",vkvid:e.dataset.vkId||"",vklive:e.dataset.vkLive||"",vimeoid:e.dataset.vimeoId||""});s&&t.push(s)})}(),function(){const e=document.querySelectorAll("div[data-crosstalk-poll]"),t=[];e.forEach(e=>{const s=n(e,{wp:e.dataset.wp,url:e.dataset.url||"",pageID:e.dataset.pageId||"",theme:e.dataset.theme||"light",pollID:e.dataset.pollId||""});s&&t.push(s)})}(),function(){const e=document.querySelectorAll("div[data-crosstalk-ai-summary]"),t=[];e.forEach(e=>{const i=s(e,{wp:e.dataset.wp||"",url:e.dataset.url||"",theme:e.dataset.theme||"light"});i&&t.push(i)})}(),this}};return"undefined"!=typeof window&&(console.log("in browser"),window.CTCore=l,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>l.initAll()):l.initAll()),e.default})());
2
+ //# sourceMappingURL=crosstalk_sdk.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crosstalk_sdk.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,mCAAqCD,IAE7CD,EAAK,mCAAqCC,GAC3C,CATD,CASGK,KAAM,I,4BCEF,MAAMC,EACT,WAAAC,CAAYC,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,MAAOoB,EAAUN,QAAQS,MAAQ,GACjCtB,OAAQmB,EAAUN,QAAQU,QAAU,GACpCtB,QAASkB,EAAUN,QAAQW,SAAW,KAGtCZ,GACAM,EAAaH,KAAKH,IAG9B,CChGQa,GF8DD,WACH,MAAMC,EAAWhE,SAAS8C,iBAAiB,4BACrCmB,EAAa,GACnBD,EAAShB,QAAQkB,IACb,MAOMhB,EAAWnB,EAASmC,EAPX,CACX7D,GAAI6D,EAAQf,QAAQ9C,GACpBE,IAAK2D,EAAQf,QAAQ5C,KAAO,GAC5BgB,OAAQ2C,EAAQf,QAAQC,QAAU,GAClC5C,MAAO0D,EAAQf,QAAQ3C,OAAS,QAChCsB,OAAQoC,EAAQf,QAAQgB,QAAU,KAGlCjB,GACAe,EAAWZ,KAAKH,IAG5B,CE7EQkB,GJwDD,WACH,MAAMC,EAASrE,SAAS8C,iBAAiB,kCACnCwB,EAAW,GACjBD,EAAOrB,QAAQuB,IACX,MAKMrB,EAAW9B,EAAcmD,EALhB,CACXlE,GAAIkE,EAAMpB,QAAQ9C,IAAM,GACxBE,IAAKgE,EAAMpB,QAAQ5C,KAAO,GAC1BC,MAAO+D,EAAMpB,QAAQ3C,OAAS,UAG9B0C,GACAoB,EAASjB,KAAKH,IAG1B,CIrEQsB,GACOlG,IACX,G,MAMkB,oBAAXS,SACP4D,QAAQC,IAAI,cACZ7D,OAAO0D,OAASA,EACY,YAAxBzC,SAASyE,WACTzE,SAASF,iBAAiB,mBAAoB,IAAM2C,EAAOC,WAE3DD,EAAOC,W","sources":["webpack://crosstalk-comments-livechat-sdk/webpack/universalModuleDefinition","webpack://crosstalk-comments-livechat-sdk/./src/CrossTalkAISummaryEmbed.ts","webpack://crosstalk-comments-livechat-sdk/./src/CrossTalkCommentsEmbed.ts","webpack://crosstalk-comments-livechat-sdk/./src/CrossTalkPollEmbed.ts","webpack://crosstalk-comments-livechat-sdk/./src/CrossTalkVideoPlayerEmbed.ts","webpack://crosstalk-comments-livechat-sdk/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"crosstalk-comments-livechat-sdk\"] = factory();\n\telse\n\t\troot[\"crosstalk-comments-livechat-sdk\"] = factory();\n})(this, () => {\nreturn ","function buildIframeUrl(config) {\n const baseUrl = 'https://widgets.crosstalk.cc/ai_summary';\n const params = new URLSearchParams();\n if (config.wp)\n params.append('wp', config.wp);\n if (config.url)\n params.append('url', config.url);\n if (config.theme)\n params.append('theme', config.theme);\n return `${baseUrl}?${params.toString()}`;\n}\nexport class CrossTalkAISummaryEmbed {\n constructor(container, config) {\n this.container = container;\n this.config = config;\n this.iframe = null;\n this.messageHandler = null;\n this.render();\n }\n setupMessageListener() {\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n }\n this.messageHandler = (event) => {\n if (this.iframe && event.source !== this.iframe.contentWindow) {\n return;\n }\n if (event.origin.includes('.crosstalk.cc')) {\n try {\n const msg = JSON.parse(event.data);\n if (msg.asize)\n this.iframe.style.height = `${msg.asize}px`;\n }\n catch (_a) { }\n }\n };\n window.addEventListener('message', this.messageHandler);\n }\n render() {\n this.container.innerHTML = '';\n this.iframe = document.createElement('iframe');\n this.iframe.src = buildIframeUrl(this.config);\n this.iframe.setAttribute(\"style\", \"width: 100%; scrollbar-width:thin !important\");\n this.iframe.setAttribute(\"frameborder\", \"0\");\n this.iframe.sandbox = \"allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups\";\n this.iframe.scrolling = \"no\";\n this.container.appendChild(this.iframe);\n this.setupMessageListener();\n }\n update(config) {\n this.config = { ...this.config, ...config };\n this.render();\n }\n destroy() {\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n this.messageHandler = null;\n }\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n }\n getIframe() {\n return this.iframe;\n }\n}\nexport function initAISummary(container, config) {\n return new CrossTalkAISummaryEmbed(container, config);\n}\nexport function autoInitAISummaries() {\n const aiDivs = document.querySelectorAll('div[data-crosstalk-ai-summary]');\n const aiEmbeds = [];\n aiDivs.forEach(aiDiv => {\n const config = {\n wp: aiDiv.dataset.wp || \"\",\n url: aiDiv.dataset.url || \"\",\n theme: aiDiv.dataset.theme || \"light\"\n };\n const instance = initAISummary(aiDiv, config);\n if (instance)\n aiEmbeds.push(instance);\n });\n return aiEmbeds;\n}\n","function buildIframeUrl(config) {\n const baseUrl = 'https://widgets.crosstalk.cc/comments';\n const params = new URLSearchParams();\n params.append('wp', config.wp);\n if (config.url)\n params.append('url', config.url);\n else if (config.pageID)\n params.append('pageID', config.pageID);\n if (config.theme)\n params.append('theme', config.theme);\n if (config.reactions !== undefined)\n params.append('reactions', String(config.reactions));\n return `${baseUrl}?${params.toString()}`;\n}\nexport class CrossTalkCommentsEmbed {\n constructor(container, config) {\n this.container = container;\n this.config = config;\n this.iframe = null;\n this.messageHandler = null;\n this.render();\n }\n setupMessageListener() {\n // Remove existing listener if any\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n }\n this.messageHandler = (event) => {\n // Basic security check - verify the message is from our iframe\n if (this.iframe && event.source !== this.iframe.contentWindow) {\n return;\n }\n if (event.origin.includes('.crosstalk.cc')) {\n try {\n const msg = JSON.parse(event.data);\n if (msg.csize)\n this.iframe.style.height = `${msg.csize}px`;\n }\n catch (_a) { }\n }\n };\n window.addEventListener('message', this.messageHandler);\n }\n render() {\n this.container.innerHTML = '';\n this.iframe = document.createElement('iframe');\n this.iframe.src = buildIframeUrl(this.config);\n this.iframe.setAttribute(\"style\", \"width: 100%; scrollbar-width:thin !important\");\n this.iframe.setAttribute(\"frameborder\", \"0\");\n this.iframe.sandbox = \"allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups\";\n this.iframe.scrolling = \"no\";\n this.container.appendChild(this.iframe);\n this.setupMessageListener();\n }\n update(config) {\n this.config = { ...this.config, ...config };\n this.render();\n }\n destroy() {\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n this.messageHandler = null;\n }\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n }\n getIframe() {\n return this.iframe;\n }\n}\nexport function initComments(container, config) {\n return new CrossTalkCommentsEmbed(container, config);\n}\nexport function autoInitComments() {\n const commentDivs = document.querySelectorAll('div[data-crosstalk-comments]');\n const commentEmbeds = [];\n commentDivs.forEach(commentsDiv => {\n const config = {\n wp: commentsDiv.dataset.wp,\n url: commentsDiv.dataset.url || \"\",\n pageID: commentsDiv.dataset.pageId || \"\",\n theme: commentsDiv.dataset.theme || \"light\",\n reactions: commentsDiv.dataset.reactions === \"true\" ? true : false\n };\n const instance = initComments(commentsDiv, config);\n if (instance)\n commentEmbeds.push(instance);\n });\n return commentEmbeds;\n}\n","function buildIframeUrl(config) {\n const baseUrl = 'https://widgets.crosstalk.cc/poll';\n const params = new URLSearchParams();\n params.append('wp', config.wp);\n if (config.url)\n params.append('url', config.url);\n else if (config.pageID)\n params.append('pageID', config.pageID);\n if (config.theme)\n params.append('theme', config.theme);\n if (config.pollID)\n params.append('pollID', config.pollID);\n return `${baseUrl}?${params.toString()}`;\n}\nexport class CrossTalkPollEmbed {\n constructor(container, config) {\n this.container = container;\n this.config = config;\n this.iframe = null;\n this.messageHandler = null;\n this.render();\n }\n setupMessageListener() {\n // Remove existing listener if any\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n }\n this.messageHandler = (event) => {\n // Basic security check - verify the message is from our iframe\n if (this.iframe && event.source !== this.iframe.contentWindow) {\n return;\n }\n if (event.origin.includes('.crosstalk.cc')) {\n try {\n const msg = JSON.parse(event.data);\n if (msg.psize)\n this.iframe.style.height = `${msg.psize}px`;\n }\n catch (_a) { }\n }\n };\n window.addEventListener('message', this.messageHandler);\n }\n render() {\n this.container.innerHTML = '';\n this.iframe = document.createElement('iframe');\n this.iframe.src = buildIframeUrl(this.config);\n this.iframe.setAttribute(\"style\", \"width: 100%; scrollbar-width:thin !important\");\n this.iframe.setAttribute(\"frameborder\", \"0\");\n this.iframe.sandbox = \"allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups\";\n this.iframe.scrolling = \"no\";\n this.container.appendChild(this.iframe);\n this.setupMessageListener();\n }\n update(config) {\n this.config = { ...this.config, ...config };\n this.render();\n }\n destroy() {\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n this.messageHandler = null;\n }\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n }\n getIframe() {\n return this.iframe;\n }\n}\nexport function initPoll(container, config) {\n return new CrossTalkPollEmbed(container, config);\n}\nexport function autoInitPolls() {\n const pollDivs = document.querySelectorAll('div[data-crosstalk-poll]');\n const pollEmbeds = [];\n pollDivs.forEach(pollDiv => {\n const config = {\n wp: pollDiv.dataset.wp,\n url: pollDiv.dataset.url || \"\",\n pageID: pollDiv.dataset.pageId || \"\",\n theme: pollDiv.dataset.theme || \"light\",\n pollID: pollDiv.dataset.pollId || \"\"\n };\n const instance = initPoll(pollDiv, config);\n if (instance)\n pollEmbeds.push(instance);\n });\n return pollEmbeds;\n}\n","function buildIframeUrl(config) {\n const baseUrl = 'https://widgets.crosstalk.cc/video';\n const params = new URLSearchParams();\n params.append('wp', config.wp);\n if (config.url)\n params.append('url', config.url);\n else if (config.pageID)\n params.append('pageID', config.pageID);\n if (config.theme)\n params.append('theme', config.theme);\n if (config.src && config.srcType) {\n params.append('src', config.src);\n params.append('srcType', config.srcType);\n }\n if (config.ytvid)\n params.append('ytvid', config.ytvid);\n if (config.rtvid)\n params.append('rtvid', config.rtvid);\n if (config.vkvid)\n params.append('vkvid', config.vkvid);\n if (config.vklive)\n params.append('vklive', config.vklive);\n if (config.vimeoid)\n params.append('vimeoid', config.vimeoid);\n return `${baseUrl}?${params.toString()}`; //params are auto encoded\n}\nexport class CrossTalkVideoPlayerEmbed {\n constructor(container, config) {\n this.container = container;\n this.config = config;\n this.iframe = null;\n this.messageHandler = null;\n this.render();\n }\n setupMessageListener() {\n // Remove existing listener if any\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n }\n this.messageHandler = (event) => {\n // Basic security check - verify the message is from our iframe\n if (this.iframe && event.source !== this.iframe.contentWindow) {\n return;\n }\n if (event.origin.includes('.crosstalk.cc')) {\n try {\n const msg = JSON.parse(event.data);\n if (msg.vsize)\n this.iframe.style.height = `${msg.vsize}px`;\n }\n catch (_a) { }\n }\n };\n window.addEventListener('message', this.messageHandler);\n }\n render() {\n this.container.innerHTML = '';\n this.iframe = document.createElement('iframe');\n this.iframe.src = buildIframeUrl(this.config);\n this.iframe.setAttribute(\"style\", \"width: 100%; scrollbar-width:thin !important\");\n this.iframe.setAttribute(\"frameborder\", \"0\");\n this.iframe.sandbox = \"allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups\";\n this.iframe.scrolling = \"auto\";\n this.container.appendChild(this.iframe);\n this.setupMessageListener();\n }\n update(config) {\n this.config = { ...this.config, ...config };\n this.render();\n }\n destroy() {\n if (this.messageHandler) {\n window.removeEventListener('message', this.messageHandler);\n this.messageHandler = null;\n }\n if (this.iframe && this.iframe.parentNode) {\n this.iframe.parentNode.removeChild(this.iframe);\n this.iframe = null;\n }\n }\n getIframe() {\n return this.iframe;\n }\n}\nexport function initPlayer(container, config) {\n return new CrossTalkVideoPlayerEmbed(container, config);\n}\nexport function autoInitPlayers() {\n const playerDivs = document.querySelectorAll('div[data-crosstalk-video-player]');\n const playerEmbeds = [];\n playerDivs.forEach(playerDiv => {\n const config = {\n wp: playerDiv.dataset.wp,\n url: playerDiv.dataset.url || \"\",\n pageID: playerDiv.dataset.pageId || \"\",\n theme: playerDiv.dataset.theme || \"light\",\n src: playerDiv.dataset.src || \"\",\n srcType: playerDiv.dataset.srcType || \"\",\n ytvid: playerDiv.dataset.ytId || \"\",\n rtvid: playerDiv.dataset.rtId || \"\",\n vkvid: playerDiv.dataset.vkId || \"\",\n vklive: playerDiv.dataset.vkLive || \"\",\n vimeoid: playerDiv.dataset.vimeoId || \"\"\n };\n const instance = initPlayer(playerDiv, config);\n if (instance)\n playerEmbeds.push(instance);\n });\n return playerEmbeds;\n}\n","import { autoInitAISummaries, initAISummary } from './CrossTalkAISummaryEmbed';\nimport { autoInitComments, initComments } from './CrossTalkCommentsEmbed';\nimport { autoInitPolls, initPoll } from './CrossTalkPollEmbed';\nimport { autoInitPlayers, initPlayer } from './CrossTalkVideoPlayerEmbed';\nconst CTCore = {\n // Core functions\n initComments,\n initPlayer,\n initPoll,\n initAISummary,\n initAll() {\n console.log('crosstalk initialised');\n autoInitComments();\n autoInitPlayers();\n autoInitPolls();\n autoInitAISummaries();\n return this;\n }\n};\nexport * from './CrossTalkCommentsEmbed';\nexport * from './CrossTalkVideoPlayerEmbed';\nexport * from './CrossTalkPollEmbed';\nexport * from './CrossTalkAISummaryEmbed';\nif (typeof window !== 'undefined') {\n console.log(\"in browser\");\n window.CTCore = CTCore;\n if (document.readyState === 'loading')\n document.addEventListener('DOMContentLoaded', () => CTCore.initAll());\n else\n CTCore.initAll();\n}\n"],"names":["root","factory","exports","module","define","amd","this","CrossTalkAISummaryEmbed","constructor","container","config","iframe","messageHandler","render","setupMessageListener","window","removeEventListener","event","source","contentWindow","origin","includes","msg","JSON","parse","data","asize","style","height","_a","addEventListener","innerHTML","document","createElement","src","params","URLSearchParams","wp","append","url","theme","toString","buildIframeUrl","setAttribute","sandbox","scrolling","appendChild","update","destroy","parentNode","removeChild","getIframe","initAISummary","CrossTalkCommentsEmbed","csize","pageID","undefined","reactions","String","initComments","CrossTalkPollEmbed","psize","pollID","initPoll","CrossTalkVideoPlayerEmbed","vsize","srcType","ytvid","rtvid","vkvid","vklive","vimeoid","initPlayer","CTCore","initAll","console","log","commentDivs","querySelectorAll","commentEmbeds","forEach","commentsDiv","instance","dataset","pageId","push","autoInitComments","playerDivs","playerEmbeds","playerDiv","ytId","rtId","vkId","vkLive","vimeoId","autoInitPlayers","pollDivs","pollEmbeds","pollDiv","pollId","autoInitPolls","aiDivs","aiEmbeds","aiDiv","autoInitAISummaries","readyState"],"ignoreList":[],"sourceRoot":""}
@@ -0,0 +1,15 @@
1
+ import { AISummaryOptions } from './types';
2
+ export declare class CrossTalkAISummaryEmbed {
3
+ private container;
4
+ private config;
5
+ private iframe;
6
+ private messageHandler;
7
+ constructor(container: HTMLElement, config: AISummaryOptions);
8
+ private setupMessageListener;
9
+ render(): void;
10
+ update(config: Partial<AISummaryOptions>): void;
11
+ destroy(): void;
12
+ getIframe(): HTMLIFrameElement | null;
13
+ }
14
+ export declare function initAISummary(container: HTMLElement, config: AISummaryOptions): CrossTalkAISummaryEmbed;
15
+ export declare function autoInitAISummaries(): CrossTalkAISummaryEmbed[];
@@ -12,3 +12,4 @@ export declare class CrossTalkCommentsEmbed {
12
12
  getIframe(): HTMLIFrameElement | null;
13
13
  }
14
14
  export declare function initComments(container: HTMLElement, config: CommentsEmbedOptions): CrossTalkCommentsEmbed;
15
+ export declare function autoInitComments(): CrossTalkCommentsEmbed[];
@@ -0,0 +1,15 @@
1
+ import { PollEmbedOptions } from './types';
2
+ export declare class CrossTalkPollEmbed {
3
+ private container;
4
+ private config;
5
+ private iframe;
6
+ private messageHandler;
7
+ constructor(container: HTMLElement, config: PollEmbedOptions);
8
+ private setupMessageListener;
9
+ render(): void;
10
+ update(config: Partial<PollEmbedOptions>): void;
11
+ destroy(): void;
12
+ getIframe(): HTMLIFrameElement | null;
13
+ }
14
+ export declare function initPoll(container: HTMLElement, config: PollEmbedOptions): CrossTalkPollEmbed;
15
+ export declare function autoInitPolls(): CrossTalkPollEmbed[];
@@ -12,3 +12,4 @@ export declare class CrossTalkVideoPlayerEmbed {
12
12
  getIframe(): HTMLIFrameElement | null;
13
13
  }
14
14
  export declare function initPlayer(container: HTMLElement, config: VideoPlayerEmbedOptions): CrossTalkVideoPlayerEmbed;
15
+ export declare function autoInitPlayers(): CrossTalkVideoPlayerEmbed[];
@@ -0,0 +1,5 @@
1
+ export * from './CrossTalkCommentsEmbed';
2
+ export * from './CrossTalkVideoPlayerEmbed';
3
+ export * from './CrossTalkPollEmbed';
4
+ export * from './CrossTalkAISummaryEmbed';
5
+ export type * from './types';
@@ -18,3 +18,15 @@ export interface VideoPlayerEmbedOptions {
18
18
  vklive?: string;
19
19
  vimeoid?: string;
20
20
  }
21
+ export interface PollEmbedOptions {
22
+ wp?: string;
23
+ url?: string;
24
+ pageID?: string;
25
+ theme?: string;
26
+ pollID?: string;
27
+ }
28
+ export interface AISummaryOptions {
29
+ wp?: string;
30
+ url?: string;
31
+ theme?: string;
32
+ }
package/package.json CHANGED
@@ -1,21 +1,50 @@
1
1
  {
2
2
  "name": "crosstalk-comments-livechat-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.5-beta.1",
4
4
  "description": "Add Comments, Live Chat, and Video Player Embeds to your website with CrossTalk Comments and Live Chat!",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "type": "module",
5
+ "main": "dist/crosstalk_sdk.js",
6
+ "module": "dist/crosstalk_sdk.js",
7
+ "browser": "dist/crosstalk_sdk.js",
8
+ "unpkg": "dist/crosstalk_sdk.min.js",
9
+ "jsdelivr": "dist/crosstalk_sdk.min.js",
10
+ "types": "dist/types/index.d.ts",
11
+
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/types/index.d.ts",
15
+ "import": "./dist/crosstalk_sdk.js",
16
+ "require": "./dist/crosstalk_sdk.js",
17
+ "browser": "./dist/crosstalk_sdk.js",
18
+ "default": "./dist/crosstalk_sdk.js"
19
+ }
20
+ },
21
+ "type": "commonjs",
8
22
  "displayName": "CrossTalk Comments & Live Chat Embed SDK",
9
23
  "homepage": "https://crosstalk.cc",
10
- "scripts": {
11
- "build": "tsc",
24
+ "scripts": {
25
+ "build": "npm run build:types && webpack --mode production",
26
+ "build:types": "tsc --project tsconfig.json --outDir dist/types --declaration --emitDeclarationOnly",
27
+ "build:dev": "webpack --mode development",
28
+ "watch": "webpack --mode development --watch",
12
29
  "prepublishOnly": "npm run build"
13
30
  },
14
- "keywords": ["comments", "live chat", "crosstalk", "hyvor talk", "audience Engagement", "disqus", "video player"],
31
+ "keywords": [
32
+ "comments",
33
+ "live chat",
34
+ "crosstalk",
35
+ "hyvor talk",
36
+ "audience Engagement",
37
+ "disqus",
38
+ "video player",
39
+ "polls"
40
+ ],
15
41
  "author": "CrossTalk Audience Engagement Platform",
16
42
  "license": "ISC",
17
43
  "devDependencies": {
18
- "typescript": "^5.0.0"
44
+ "typescript": "^5.9.3",
45
+ "webpack": "^5.104.1",
46
+ "webpack-cli": "^6.0.1",
47
+ "ts-loader": "^9.5.4"
19
48
  },
20
49
  "files": [
21
50
  "dist",
@@ -1,78 +0,0 @@
1
- function buildIframeUrl(config) {
2
- const baseUrl = 'https://widgets.crosstalk.cc/comments';
3
- const params = new URLSearchParams();
4
- params.append('wp', config.wp);
5
- if (config.url)
6
- params.append('url', config.url);
7
- else if (config.pageID)
8
- params.append('pageID', config.pageID);
9
- if (config.theme)
10
- params.append('theme', config.theme);
11
- if (config.reactions !== undefined)
12
- params.append('reactions', String(config.reactions));
13
- return `${baseUrl}?${params.toString()}`;
14
- }
15
- export class CrossTalkCommentsEmbed {
16
- constructor(container, config) {
17
- this.container = container;
18
- this.config = config;
19
- this.iframe = null;
20
- this.messageHandler = null;
21
- this.render();
22
- }
23
- setupMessageListener() {
24
- // Remove existing listener if any
25
- if (this.messageHandler) {
26
- window.removeEventListener('message', this.messageHandler);
27
- }
28
- this.messageHandler = (event) => {
29
- // Basic security check - verify the message is from our iframe
30
- if (this.iframe && event.source !== this.iframe.contentWindow) {
31
- return;
32
- }
33
- if (event.origin.includes('.crosstalk.cc')) {
34
- try {
35
- const msg = JSON.parse(event.data);
36
- if (msg.csize)
37
- this.iframe.style.height = `${msg.csize}px`;
38
- }
39
- catch (error) {
40
- console.warn('Invalid message received:', error);
41
- }
42
- }
43
- };
44
- window.addEventListener('message', this.messageHandler);
45
- }
46
- render() {
47
- this.container.innerHTML = '';
48
- this.iframe = document.createElement('iframe');
49
- this.iframe.src = buildIframeUrl(this.config);
50
- this.iframe.id = 'ctcommentsiframe';
51
- this.iframe.setAttribute("style", "width: 100%; scrollbar-width:thin !important");
52
- this.iframe.setAttribute("frameborder", "0");
53
- this.iframe.sandbox = "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups";
54
- this.iframe.scrolling = "no";
55
- this.container.appendChild(this.iframe);
56
- this.setupMessageListener();
57
- }
58
- update(config) {
59
- this.config = Object.assign(Object.assign({}, this.config), config);
60
- this.render();
61
- }
62
- destroy() {
63
- if (this.messageHandler) {
64
- window.removeEventListener('message', this.messageHandler);
65
- this.messageHandler = null;
66
- }
67
- if (this.iframe && this.iframe.parentNode) {
68
- this.iframe.parentNode.removeChild(this.iframe);
69
- this.iframe = null;
70
- }
71
- }
72
- getIframe() {
73
- return this.iframe;
74
- }
75
- }
76
- export function initComments(container, config) {
77
- return new CrossTalkCommentsEmbed(container, config);
78
- }
@@ -1,90 +0,0 @@
1
- function buildIframeUrl(config) {
2
- const baseUrl = 'https://widgets.crosstalk.cc/video';
3
- const params = new URLSearchParams();
4
- params.append('wp', config.wp);
5
- if (config.url)
6
- params.append('url', config.url);
7
- else if (config.pageID)
8
- params.append('pageID', config.pageID);
9
- if (config.theme)
10
- params.append('theme', config.theme);
11
- if (config.src && config.srcType) {
12
- params.append('src', config.src);
13
- params.append('srcType', config.srcType);
14
- }
15
- if (config.ytvid)
16
- params.append('ytvid', config.ytvid);
17
- if (config.rtvid)
18
- params.append('rtvid', config.rtvid);
19
- if (config.vkvid)
20
- params.append('vkvid', config.vkvid);
21
- if (config.vklive)
22
- params.append('vklive', config.vklive);
23
- if (config.vimeoid)
24
- params.append('vimeoid', config.vimeoid);
25
- return `${baseUrl}?${params.toString()}`;
26
- }
27
- export class CrossTalkVideoPlayerEmbed {
28
- constructor(container, config) {
29
- this.container = container;
30
- this.config = config;
31
- this.iframe = null;
32
- this.messageHandler = null;
33
- this.render();
34
- }
35
- setupMessageListener() {
36
- // Remove existing listener if any
37
- if (this.messageHandler) {
38
- window.removeEventListener('message', this.messageHandler);
39
- }
40
- this.messageHandler = (event) => {
41
- // Basic security check - verify the message is from our iframe
42
- if (this.iframe && event.source !== this.iframe.contentWindow) {
43
- return;
44
- }
45
- if (event.origin.includes('.crosstalk.cc')) {
46
- try {
47
- const msg = JSON.parse(event.data);
48
- if (msg.vsize)
49
- this.iframe.style.height = `${msg.vsize}px`;
50
- }
51
- catch (error) {
52
- console.warn('Invalid message received:', error);
53
- }
54
- }
55
- };
56
- window.addEventListener('message', this.messageHandler);
57
- }
58
- render() {
59
- this.container.innerHTML = '';
60
- this.iframe = document.createElement('iframe');
61
- this.iframe.src = buildIframeUrl(this.config);
62
- this.iframe.id = 'ctvidchatiframe';
63
- this.iframe.setAttribute("style", "width: 100%; scrollbar-width:thin !important");
64
- this.iframe.setAttribute("frameborder", "0");
65
- this.iframe.sandbox = "allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups";
66
- this.iframe.scrolling = "auto";
67
- this.container.appendChild(this.iframe);
68
- this.setupMessageListener();
69
- }
70
- update(config) {
71
- this.config = Object.assign(Object.assign({}, this.config), config);
72
- this.render();
73
- }
74
- destroy() {
75
- if (this.messageHandler) {
76
- window.removeEventListener('message', this.messageHandler);
77
- this.messageHandler = null;
78
- }
79
- if (this.iframe && this.iframe.parentNode) {
80
- this.iframe.parentNode.removeChild(this.iframe);
81
- this.iframe = null;
82
- }
83
- }
84
- getIframe() {
85
- return this.iframe;
86
- }
87
- }
88
- export function initPlayer(container, config) {
89
- return new CrossTalkVideoPlayerEmbed(container, config);
90
- }
@@ -1,12 +0,0 @@
1
- import { EmbedOptions } from './types';
2
- export declare class EmbedComponent1 {
3
- private container;
4
- private config;
5
- private iframe;
6
- constructor(container: HTMLElement, config: EmbedOptions);
7
- render(): void;
8
- update(config: Partial<EmbedOptions>): void;
9
- destroy(): void;
10
- getIframe(): HTMLIFrameElement | null;
11
- }
12
- export declare function createEmbedComponent1(container: HTMLElement, config: EmbedOptions): EmbedComponent1;
@@ -1,49 +0,0 @@
1
- function buildIframeUrl(config) {
2
- const baseUrl = 'https://example.com/embed';
3
- const params = new URLSearchParams();
4
- params.append('webPropertyID', config.webPropertyID);
5
- if (config.url) {
6
- params.append('url', config.url);
7
- }
8
- else if (config.pageID) {
9
- params.append('pageID', config.pageID);
10
- }
11
- return `${baseUrl}?${params.toString()}`;
12
- }
13
- export class EmbedComponent1 {
14
- constructor(container, config) {
15
- this.container = container;
16
- this.config = config;
17
- this.iframe = null;
18
- this.render();
19
- }
20
- render() {
21
- this.container.innerHTML = '';
22
- this.iframe = document.createElement('iframe');
23
- this.iframe.src = buildIframeUrl(this.config);
24
- this.iframe.title = 'Embed Widget 1';
25
- this.iframe.allowFullscreen = true;
26
- // Apply styles
27
- Object.assign(this.iframe.style, Object.assign({ border: 'none', width: '100%', height: '400px', borderRadius: '8px' }, this.config.style));
28
- if (this.config.className) {
29
- this.iframe.className = this.config.className;
30
- }
31
- this.container.appendChild(this.iframe);
32
- }
33
- update(config) {
34
- this.config = Object.assign(Object.assign({}, this.config), config);
35
- this.render();
36
- }
37
- destroy() {
38
- if (this.iframe && this.iframe.parentNode) {
39
- this.iframe.parentNode.removeChild(this.iframe);
40
- this.iframe = null;
41
- }
42
- }
43
- getIframe() {
44
- return this.iframe;
45
- }
46
- }
47
- export function createEmbedComponent1(container, config) {
48
- return new EmbedComponent1(container, config);
49
- }
@@ -1,12 +0,0 @@
1
- import { EmbedOptions } from './types';
2
- export declare class EmbedComponent2 {
3
- private container;
4
- private config;
5
- private iframe;
6
- constructor(container: HTMLElement, config: EmbedOptions);
7
- render(): void;
8
- update(config: Partial<EmbedOptions>): void;
9
- destroy(): void;
10
- getIframe(): HTMLIFrameElement | null;
11
- }
12
- export declare function createEmbedComponent2(container: HTMLElement, config: EmbedOptions): EmbedComponent2;
@@ -1,50 +0,0 @@
1
- function buildIframeUrl(config) {
2
- const baseUrl = 'https://example.com/embed/v2';
3
- const params = new URLSearchParams();
4
- params.append('webPropertyID', config.webPropertyID);
5
- params.append('component', 'v2');
6
- if (config.url) {
7
- params.append('url', config.url);
8
- }
9
- else if (config.pageID) {
10
- params.append('pageID', config.pageID);
11
- }
12
- return `${baseUrl}?${params.toString()}`;
13
- }
14
- export class EmbedComponent2 {
15
- constructor(container, config) {
16
- this.container = container;
17
- this.config = config;
18
- this.iframe = null;
19
- this.render();
20
- }
21
- render() {
22
- this.container.innerHTML = '';
23
- this.iframe = document.createElement('iframe');
24
- this.iframe.src = buildIframeUrl(this.config);
25
- this.iframe.title = 'Embed Widget 2';
26
- this.iframe.allowFullscreen = true;
27
- // Apply styles
28
- Object.assign(this.iframe.style, Object.assign({ border: '1px solid #e0e0e0', width: '100%', height: '500px', borderRadius: '4px', boxShadow: '0 2px 8px rgba(0,0,0,0.1)' }, this.config.style));
29
- if (this.config.className) {
30
- this.iframe.className = this.config.className;
31
- }
32
- this.container.appendChild(this.iframe);
33
- }
34
- update(config) {
35
- this.config = Object.assign(Object.assign({}, this.config), config);
36
- this.render();
37
- }
38
- destroy() {
39
- if (this.iframe && this.iframe.parentNode) {
40
- this.iframe.parentNode.removeChild(this.iframe);
41
- this.iframe = null;
42
- }
43
- }
44
- getIframe() {
45
- return this.iframe;
46
- }
47
- }
48
- export function createEmbedComponent2(container, config) {
49
- return new EmbedComponent2(container, config);
50
- }
@@ -1,12 +0,0 @@
1
- import { EmbedComponentProps } from './types';
2
- export declare class EmbedComponent extends HTMLElement {
3
- private iframe;
4
- private props;
5
- constructor(props: EmbedComponentProps);
6
- static get observedAttributes(): string[];
7
- connectedCallback(): void;
8
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
9
- private render;
10
- updateProps(newProps: Partial<EmbedComponentProps>): void;
11
- getIframe(): HTMLIFrameElement | null;
12
- }
package/dist/component.js DELETED
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.EmbedComponent = void 0;
30
- var EmbedComponent = /** @class */ (function (_super) {
31
- __extends(EmbedComponent, _super);
32
- function EmbedComponent(props) {
33
- var _this = _super.call(this) || this;
34
- _this.iframe = null;
35
- _this.props = props;
36
- _this.attachShadow({ mode: 'open' });
37
- _this.render();
38
- return _this;
39
- }
40
- Object.defineProperty(EmbedComponent, "observedAttributes", {
41
- get: function () {
42
- return ['src', 'width', 'height', 'title'];
43
- },
44
- enumerable: false,
45
- configurable: true
46
- });
47
- EmbedComponent.prototype.connectedCallback = function () {
48
- this.render();
49
- };
50
- EmbedComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
51
- if (oldValue !== newValue && this.iframe) {
52
- switch (name) {
53
- case 'src':
54
- this.iframe.src = newValue;
55
- break;
56
- case 'width':
57
- this.iframe.width = newValue;
58
- break;
59
- case 'height':
60
- this.iframe.height = newValue;
61
- break;
62
- case 'title':
63
- this.iframe.title = newValue;
64
- break;
65
- }
66
- }
67
- };
68
- EmbedComponent.prototype.render = function () {
69
- if (!this.shadowRoot)
70
- return;
71
- var _a = this.props, src = _a.src, _b = _a.width, width = _b === void 0 ? '100%' : _b, _c = _a.height, height = _c === void 0 ? '400px' : _c, _d = _a.className, className = _d === void 0 ? '' : _d, _e = _a.allowFullscreen, allowFullscreen = _e === void 0 ? true : _e, _f = _a.sandbox, sandbox = _f === void 0 ? ['allow-scripts', 'allow-same-origin'] : _f, _g = _a.allow, allow = _g === void 0 ? 'fullscreen' : _g, _h = _a.title, title = _h === void 0 ? 'Embedded Content' : _h, onLoad = _a.onLoad, onError = _a.onError, _j = _a.style, style = _j === void 0 ? {} : _j;
72
- this.iframe = document.createElement('iframe');
73
- this.iframe.src = src;
74
- this.iframe.width = width;
75
- this.iframe.height = height;
76
- this.iframe.className = "embed-iframe ".concat(className);
77
- this.iframe.title = title;
78
- this.iframe.allow = allow;
79
- if (allowFullscreen) {
80
- this.iframe.allow += ' fullscreen';
81
- }
82
- this.iframe.sandbox.value = sandbox.join(' ');
83
- // Apply custom styles
84
- Object.assign(this.iframe.style, style);
85
- // Add event listeners
86
- if (onLoad) {
87
- this.iframe.addEventListener('load', onLoad);
88
- }
89
- if (onError) {
90
- this.iframe.addEventListener('error', onError);
91
- }
92
- // Clear and append
93
- this.shadowRoot.innerHTML = '';
94
- this.shadowRoot.appendChild(this.iframe);
95
- };
96
- // Public method to update props
97
- EmbedComponent.prototype.updateProps = function (newProps) {
98
- this.props = __assign(__assign({}, this.props), newProps);
99
- this.render();
100
- };
101
- // Public method to get the iframe element
102
- EmbedComponent.prototype.getIframe = function () {
103
- return this.iframe;
104
- };
105
- return EmbedComponent;
106
- }(HTMLElement));
107
- exports.EmbedComponent = EmbedComponent;
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { CrossTalkCommentsEmbed, initComments } from './CrossTalkCommentsEmbed';
2
- export { CrossTalkVideoPlayerEmbed, initPlayer } from './CrossTalkVideoPlayerEmbed';
3
- export type { CommentsEmbedOptions, VideoPlayerEmbedOptions } from './types';
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- // Re-export everything from component files
2
- export { CrossTalkCommentsEmbed, initComments } from './CrossTalkCommentsEmbed';
3
- export { CrossTalkVideoPlayerEmbed, initPlayer } from './CrossTalkVideoPlayerEmbed';
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};