From 84338a07cd3de56f0e8dcb42c09ef930568ac436 Mon Sep 17 00:00:00 2001 From: nirav Date: Tue, 26 Aug 2025 02:23:16 +0545 Subject: [PATCH 1/3] release 3.14 with error log removals --- website/package.json | 2 +- .../components/Sigmond/C2CWidgetInternal.tsx | 60 +++++++++++++++---- website/src/types/signalwire-call-widget.d.ts | 1 + yarn.lock | 31 +++++++--- 4 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 website/src/types/signalwire-call-widget.d.ts diff --git a/website/package.json b/website/package.json index a8ae8370a..9e548d28c 100644 --- a/website/package.json +++ b/website/package.json @@ -45,7 +45,7 @@ "@double-great/alt-text": "^3.1.0", "@material/web": "^2.3.0", "@mdx-js/react": "^3.0.1", - "@niravcodes/call-widget": "^3.0.0", + "@signalwire/call-widget": "^3.0.0", "@popperjs/core": "^2.11.8", "@signalwire/docusaurus-plugin-llms-txt": "1.2.1", "canvas": "^3.1.2", diff --git a/website/src/components/Sigmond/C2CWidgetInternal.tsx b/website/src/components/Sigmond/C2CWidgetInternal.tsx index 2e6aa7023..00cbafc10 100644 --- a/website/src/components/Sigmond/C2CWidgetInternal.tsx +++ b/website/src/components/Sigmond/C2CWidgetInternal.tsx @@ -15,9 +15,14 @@ export default function C2CWidgetInternal({ token: string; }) { const rootRef = useRef(null); + const showContactFormRef = useRef(null); useEffect(() => { - import("@niravcodes/call-widget"); + const loadWidget = async () => { + const module = await import("@signalwire/call-widget"); + showContactFormRef.current = module.showContactForm; + }; + loadWidget(); }, []); // react doesn't like other scripts controlling the DOM, @@ -27,19 +32,50 @@ export default function C2CWidgetInternal({ useEffect(() => { if (rootRef.current) { rootRef.current.innerHTML = ""; - const widget = document.createElement("c2c-widget"); - - widget.setAttribute("buttonId", buttonId); - widget.setAttribute( - "callDetails", - JSON.stringify({ - destination, - supportsVideo, - supportsAudio, - }), - ); + const widget = document.createElement("call-widget"); + + widget.setAttribute("button-id", buttonId); widget.setAttribute("token", token); + widget.setAttribute("support-video", supportsVideo.toString()); + widget.setAttribute("support-audio", supportsAudio.toString()); + widget.setAttribute("destination", destination); + + const handleBeforeDial = (event: any) => { + const approve = event.detail.approve; + const reject = event.detail.reject; + + event.detail.hasListeners = true; + + if (!showContactFormRef.current) { + console.error("showContactForm not loaded yet"); + reject(); + return; + } + + showContactFormRef.current( + { + onSubmit: (data: any) => { + (widget as any).newCallVariable({ + email: data.email, + name: data.name, + phone: data.number, + }); + approve(); + }, + onCancel: () => { + reject(); + }, + }, + widget, + ); + }; + + widget.addEventListener("beforeDial", handleBeforeDial); rootRef.current.appendChild(widget); + + return () => { + widget.removeEventListener("beforeDial", handleBeforeDial); + }; } return () => { if (rootRef.current) { diff --git a/website/src/types/signalwire-call-widget.d.ts b/website/src/types/signalwire-call-widget.d.ts new file mode 100644 index 000000000..767df6f28 --- /dev/null +++ b/website/src/types/signalwire-call-widget.d.ts @@ -0,0 +1 @@ +declare module "@signalwire/call-widget"; diff --git a/yarn.lock b/yarn.lock index 3ecb4d041..e4992a7a3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2591,14 +2591,6 @@ "@emnapi/runtime" "^1.4.5" "@tybys/wasm-util" "^0.10.0" -"@niravcodes/call-widget@^3.0.0": - version "3.0.0" - resolved "https://registry.npmjs.org/@niravcodes/call-widget/-/call-widget-3.0.0.tgz" - integrity sha512-byP0+XLwmMBYSiQ+APiO6//Y1OlthJQiR6ZbSQ3yqMHE+s/BZxdk0J9a2svCm7rCtDmKTXYw0xl5frmoyzzkUw== - dependencies: - "@signalwire/js" dev - nanomorph "^5.4.3" - "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" @@ -2929,6 +2921,15 @@ resolved "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz" integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== +"@signalwire/call-widget@^3.0.0": + version "3.13.0" + resolved "https://registry.yarnpkg.com/@signalwire/call-widget/-/call-widget-3.13.0.tgz#3f6679e5a547446d9fda42cab9e1e78401822ea3" + integrity sha512-P+mHr4hws+lIgNHEhR7txatUrnzeh+cpxoMxGbMCT2pZEaYm9JhJPU3ubGFloJ+h3uIGUuzmuSyGg3gzOXRbYg== + dependencies: + "@signalwire/js" "3.29.1" + nanomorph "^5.4.3" + showdown "^2.1.0" + "@signalwire/core@4.3.1": version "4.3.1" resolved "https://registry.npmjs.org/@signalwire/core/-/core-4.3.1.tgz" @@ -2958,7 +2959,7 @@ unified "^11" unist-util-visit "^5" -"@signalwire/js@3.29.1", "@signalwire/js@dev": +"@signalwire/js@3.29.1": version "3.29.1" resolved "https://registry.yarnpkg.com/@signalwire/js/-/js-3.29.1.tgz#d39def63d80942aa35abcd1504a13e9476255298" integrity sha512-YIu1NTul4zaFk0yNXve3k41GaAlYChopbjSTmB4skyCUDNtRAdasc+xOqEcSWzDFpkKQTeIYXPC4mWA8kliwcg== @@ -4982,6 +4983,11 @@ commander@^8.3.0: resolved "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz" integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== +commander@^9.0.0: + version "9.5.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" + integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== + common-path-prefix@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz" @@ -11459,6 +11465,13 @@ should@^13.2.1: should-type-adaptors "^1.0.1" should-util "^1.0.0" +showdown@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/showdown/-/showdown-2.1.0.tgz#1251f5ed8f773f0c0c7bfc8e6fd23581f9e545c5" + integrity sha512-/6NVYu4U819R2pUIk79n67SYgJHWCce0a5xTP979WbNp0FL9MN1I1QK662IDU1b6JzKTvmhgI7T7JYIxBi3kMQ== + dependencies: + commander "^9.0.0" + shx@^0.3.4: version "0.3.4" resolved "https://registry.npmjs.org/shx/-/shx-0.3.4.tgz" From bca49abc541d6a93539682ff8b8bcd36e81e0fff Mon Sep 17 00:00:00 2001 From: nirav Date: Tue, 26 Aug 2025 02:29:04 +0545 Subject: [PATCH 2/3] use v3.14 --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index e4992a7a3..b74eb69c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2922,7 +2922,7 @@ integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== "@signalwire/call-widget@^3.0.0": - version "3.13.0" + version "3.14.0" resolved "https://registry.yarnpkg.com/@signalwire/call-widget/-/call-widget-3.13.0.tgz#3f6679e5a547446d9fda42cab9e1e78401822ea3" integrity sha512-P+mHr4hws+lIgNHEhR7txatUrnzeh+cpxoMxGbMCT2pZEaYm9JhJPU3ubGFloJ+h3uIGUuzmuSyGg3gzOXRbYg== dependencies: From 91462c9eed44474dc276191b86b9c9ec5a27119c Mon Sep 17 00:00:00 2001 From: nirav Date: Tue, 26 Aug 2025 02:52:54 +0545 Subject: [PATCH 3/3] use 3.15 --- website/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/website/package.json b/website/package.json index 9e548d28c..df3b472f8 100644 --- a/website/package.json +++ b/website/package.json @@ -45,8 +45,8 @@ "@double-great/alt-text": "^3.1.0", "@material/web": "^2.3.0", "@mdx-js/react": "^3.0.1", - "@signalwire/call-widget": "^3.0.0", "@popperjs/core": "^2.11.8", + "@signalwire/call-widget": "^3.15.0", "@signalwire/docusaurus-plugin-llms-txt": "1.2.1", "canvas": "^3.1.2", "clsx": "^2.1.1", diff --git a/yarn.lock b/yarn.lock index b74eb69c8..df4b5fce3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2921,10 +2921,10 @@ resolved "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz" integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== -"@signalwire/call-widget@^3.0.0": - version "3.14.0" - resolved "https://registry.yarnpkg.com/@signalwire/call-widget/-/call-widget-3.13.0.tgz#3f6679e5a547446d9fda42cab9e1e78401822ea3" - integrity sha512-P+mHr4hws+lIgNHEhR7txatUrnzeh+cpxoMxGbMCT2pZEaYm9JhJPU3ubGFloJ+h3uIGUuzmuSyGg3gzOXRbYg== +"@signalwire/call-widget@^3.15.0": + version "3.15.0" + resolved "https://registry.yarnpkg.com/@signalwire/call-widget/-/call-widget-3.15.0.tgz#cb93d5c2d38e34ae9c9304e9ab85ef904ac8dd2a" + integrity sha512-pQRNtEsYHPpSf6KZFpPjR1vMQNzJKQiaUHJvWJURcc9U6esuEMoR5XzYLFbMNsohKA4YZI7E05hhVMk3hfsKFw== dependencies: "@signalwire/js" "3.29.1" nanomorph "^5.4.3"