@homekynd/hk-embed-sdk 0.0.6 → 0.0.7

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/README.md CHANGED
@@ -1,21 +1,31 @@
1
+ A lightweight SDK for embedding Homekynd applications into your website with secure authentication and seamless integration.
2
+
3
+ ---
4
+
1
5
  <p align="center">
2
6
  <img width="160" height="160" alt="package-logo" src="https://storage.googleapis.com/hk-prod-main/hk-sdk-logo.png" />
3
7
  </p>
4
8
 
5
9
  <h1 align="center">HKEmbed SDK</h1>
6
10
 
7
- #### A lightweight SDK for embedding Homekynd applications into your website with secure authentication and seamless integration.
8
-
9
- ---
10
-
11
11
  ## Installation
12
12
 
13
- Contact your Homekynd representative to get access credentials, then install via npm:
13
+ Contact your Homekynd representative to get access credentials, then choose one of the installation methods below:
14
+
15
+ ### NPM Package
14
16
 
15
17
  ```bash
16
18
  npm install @homekynd/hk-embed-sdk
17
19
  ```
18
20
 
21
+ ### CDN
22
+
23
+ ```html
24
+ <script src="https://storage.googleapis.com/hk-prod-main/sdk/hk-sdk.cdn.x.x.x.umd.js"></script>
25
+ ```
26
+
27
+ Replace `x.x.x` with the desired version number (e.g., `1.0.0`, `2.1.3`).
28
+
19
29
  > [!IMPORTANT]
20
30
  > This package requires authentication credentials provided by Homekynd. Contact support@homekynd.com for access.
21
31
 
@@ -24,59 +34,93 @@ npm install @homekynd/hk-embed-sdk
24
34
  ### For React Applications
25
35
 
26
36
  ```tsx
27
- import React from 'react';
28
- import { HKReactEmbed } from '@homekynd/hk-embed-sdk';
37
+ import React from "react";
38
+ import { HKReactEmbed } from "@homekynd/hk-embed-sdk";
29
39
 
30
40
  function MyComponent() {
31
- return (
32
- <HKReactEmbed
33
- clientId="your-client-id"
34
- apiKey="your-api-key"
35
- width="100%"
36
- height="600px"
37
- style={{ border: '1px solid #ddd', borderRadius: '8px' }}
38
- />
39
- );
41
+ return (
42
+ <HKReactEmbed
43
+ clientId="your-client-id"
44
+ apiKey="your-api-key"
45
+ width="100%"
46
+ height="600px"
47
+ style={{ border: "1px solid #ddd", borderRadius: "8px" }}
48
+ />
49
+ );
40
50
  }
41
51
  ```
42
52
 
43
- ### For Vanilla JavaScript
53
+ ### Configuration Options React
54
+
55
+ | Option | Type | Required | Default | Description |
56
+ | ---------- | --------------------- | -------- | -------- | ----------------------------------------- |
57
+ | `clientId` | `string` | ✅ Yes | - | Your Homekynd client ID |
58
+ | `apiKey` | `string` | ✅ Yes | - | Your Homekynd API key |
59
+ | `width` | `string \| number` | No | `"100%"` | Embed width (e.g., "500px", "100%", 500) |
60
+ | `height` | `string \| number` | No | `"100%"` | Embed height (e.g., "400px", "50vh", 400) |
61
+ | `path` | `string` | No | `"root"` | Initial page to load |
62
+ | `style` | `React.CSSProperties` | No | - | Custom styles |
63
+
64
+ ### For Vanilla JavaScript (NPM)
44
65
 
45
66
  ```html
46
67
  <!DOCTYPE html>
47
68
  <html>
48
- <head>
69
+ <head>
49
70
  <title>My Website</title>
50
- </head>
51
- <body>
71
+ </head>
72
+ <body>
52
73
  <div id="homekynd-embed" style="width: 100%; height: 600px;"></div>
53
-
74
+
54
75
  <script type="module">
55
- import { HKEmbed } from '@homekynd/hk-embed-sdk';
56
-
57
- new HKEmbed({
58
- container: document.getElementById('homekynd-embed'),
59
- clientId: 'your-client-id',
60
- apiKey: 'your-api-key',
61
- width: '100%',
62
- height: '600px'
63
- });
76
+ import { HKEmbed } from "@homekynd/hk-embed-sdk";
77
+
78
+ new HKEmbed({
79
+ container: document.getElementById("homekynd-embed"),
80
+ clientId: "your-client-id",
81
+ apiKey: "your-api-key",
82
+ width: "100%",
83
+ height: "600px",
84
+ });
64
85
  </script>
65
- </body>
86
+ </body>
66
87
  </html>
67
88
  ```
68
89
 
69
- ## Configuration Options
90
+ ### For Vanilla JavaScript (CDN)
70
91
 
71
- | Option | Type | Required | Default | Description |
72
- |--------|------|----------|---------|-------------|
73
- | `clientId` | `string` | ✅ Yes | - | Your Homekynd client ID |
74
- | `apiKey` | `string` | ✅ Yes | - | Your Homekynd API key |
75
- | `container` | `HTMLElement` | ✅ Yes* | - | Container element (*Vanilla JS only) |
76
- | `width` | `string \| number` | No | `"100%"` | Embed width (e.g., "500px", "100%", 500) |
77
- | `height` | `string \| number` | No | `"100%"` | Embed height (e.g., "400px", "50vh", 400) |
78
- | `path` | `string` | No | `"root"` | Initial page to load |
79
- | `style` | `React.CSSProperties` | No | - | Custom styles (*React only) |
92
+ ```html
93
+ <!DOCTYPE html>
94
+ <html>
95
+ <head>
96
+ <script src="https://storage.googleapis.com/hk-prod-main/sdk/hk-sdk.cdn.x.x.x.umd.js"></script>
97
+ </head>
98
+
99
+ <body>
100
+ <div id="homekynd-embed"></div>
101
+ <script>
102
+ new HkEmbed({
103
+ container: document.getElementById("homekynd-embed"),
104
+ clientId: "your-client-id",
105
+ apiKey: "your-api-key",
106
+ width: "100%",
107
+ height: "600px",
108
+ });
109
+ </script>
110
+ </body>
111
+ </html>
112
+ ```
113
+
114
+ ### Configuration Options Vanilla
115
+
116
+ | Option | Type | Required | Default | Description |
117
+ | ----------- | ------------------ | -------- | -------- | ----------------------------------------- |
118
+ | `clientId` | `string` | ✅ Yes | - | Your Homekynd client ID |
119
+ | `apiKey` | `string` | ✅ Yes | - | Your Homekynd API key |
120
+ | `container` | `HTMLElement` | ✅ Yes | - | Container element |
121
+ | `width` | `string \| number` | No | `"100%"` | Embed width (e.g., "500px", "100%", 500) |
122
+ | `height` | `string \| number` | No | `"100%"` | Embed height (e.g., "400px", "50vh", 400) |
123
+ | `path` | `string` | No | `"root"` | Initial page to load |
80
124
 
81
125
  ## Common Examples
82
126
 
@@ -84,10 +128,10 @@ function MyComponent() {
84
128
 
85
129
  ```tsx
86
130
  <HKReactEmbed
87
- clientId="your-client-id"
88
- apiKey="your-api-key"
89
- width="100%"
90
- height="500px"
131
+ clientId="your-client-id"
132
+ apiKey="your-api-key"
133
+ width="100%"
134
+ height="500px"
91
135
  />
92
136
  ```
93
137
 
@@ -95,10 +139,10 @@ function MyComponent() {
95
139
 
96
140
  ```tsx
97
141
  <HKReactEmbed
98
- clientId="your-client-id"
99
- apiKey="your-api-key"
100
- width={800}
101
- height={600}
142
+ clientId="your-client-id"
143
+ apiKey="your-api-key"
144
+ width={800}
145
+ height={600}
102
146
  />
103
147
  ```
104
148
 
@@ -106,31 +150,34 @@ function MyComponent() {
106
150
 
107
151
  ```tsx
108
152
  <HKReactEmbed
109
- clientId="your-client-id"
110
- apiKey="your-api-key"
111
- width="100%"
112
- height="70vh"
113
- style={{
114
- minHeight: '400px',
115
- maxWidth: '1200px',
116
- margin: '0 auto'
117
- }}
153
+ clientId="your-client-id"
154
+ apiKey="your-api-key"
155
+ width="100%"
156
+ height="70vh"
157
+ style={{
158
+ minHeight: "400px",
159
+ maxWidth: "1200px",
160
+ margin: "0 auto",
161
+ }}
118
162
  />
119
163
  ```
120
164
 
121
165
  ## Troubleshooting
122
166
 
123
167
  ### The embed doesn't load
168
+
124
169
  - ✅ Check that your `clientId` and `apiKey` are correct
125
170
  - ✅ Verify your credentials are active (contact support if needed)
126
171
  - ✅ Ensure the container element exists before initializing
127
172
 
128
173
  ### The embed appears but shows an error
174
+
129
175
  - ✅ Your credentials may be expired or inactive
130
176
  - ✅ Check the browser console for specific error messages
131
177
  - ✅ Contact Homekynd support with the error details
132
178
 
133
179
  ### Styling issues
180
+
134
181
  - ✅ Make sure the container has explicit width/height
135
182
  - ✅ Check for CSS conflicts in your application
136
183
  - ✅ Use the `style` prop (React) for custom styling
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var k=Object.defineProperty,U=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var w=(n,e,t)=>e in n?k(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,R=(n,e)=>{for(var t in e||(e={}))T.call(e,t)&&w(n,t,e[t]);if(E)for(var t of E(e))H.call(e,t)&&w(n,t,e[t]);return n},b=(n,e)=>U(n,L(e));var f=(n,e,t)=>w(n,typeof e!="symbol"?e+"":e,t);var y=(n,e,t)=>new Promise((r,o)=>{var s=a=>{try{h(t.next(a))}catch(l){o(l)}},u=a=>{try{h(t.throw(a))}catch(l){o(l)}},h=a=>a.done?r(a.value):Promise.resolve(a.value).then(s,u);h((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),c="https://staging.homekynd.com/";function I(n,e){return y(this,null,function*(){try{const t=yield fetch(`${c}/api/v1/company/generate-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_secret:n,id:e})}),r=yield t.json();if(t.ok)return r.token;console.error("Error fetching token: please confirm your API Secret and Client ID",r)}catch(t){console.error("Fetch error:",t)}})}const N={root:"/company",renders:"/renders",spaces:"/spaces"};class P{constructor(e){f(this,"container");f(this,"iframe");f(this,"currentToken");f(this,"created",!1);const{container:t}=e;if(!t)throw new Error("Container element is required");this.container=t,this.create(e)}create(e){return y(this,null,function*(){if(this.created)return;const{clientId:t,apiKey:r,path:o="root",width:s="100%",height:u="100%",enablePathSync:h=!0}=e,a=new URL(window.location.href),m=a.searchParams.get("ifpath")||N[o],S=c.endsWith("/")?c:c+"/",M=m.startsWith("/")?m.substring(1):m,p=new URL(M,S),g=yield I(r,t);this.currentToken=g,g&&p.searchParams.set("token",g);const d=document.createElement("iframe");return d.src=p.toString(),d.style.border="0",d.style.width=isNaN(Number(s))?s:`${s}px`,d.style.height=isNaN(Number(u))?u:`${u}px`,this.iframe=d,d.onload=()=>{this.currentToken&&this.sendMessage({type:"SET_TOKEN",token:this.currentToken})},this.container.innerHTML="",this.container.appendChild(d),h&&(a.searchParams.set("ifpath",m),window.history.replaceState({},"",a.toString())),this.setupMessageHandling(),this.created=!0,{sendMessage:this.sendMessage.bind(this),onMessage:this.onMessage.bind(this)}})}setupMessageHandling(){window.addEventListener("message",e=>{var t;((t=e.data)==null?void 0:t.type)==="ROUTE_CHANGE"&&this.onRouteChange(e.data.path)})}onRouteChange(e){this.inputParentRoute(e),this.inputIframeRoute(e)}inputParentRoute(e){const t=new URL(window.location.href);t.searchParams.set("ifpath",e),window.history.replaceState({},"",t.toString())}inputIframeRoute(e){if(!this.iframe)return;const t=new URL(this.iframe.src),r=c.endsWith("/")?c:c+"/",o=e.startsWith("/")?e.substring(1):e,s=new URL(o,r);t.pathname!==s.pathname&&(this.iframe.src=s.toString())}sendMessage(e){var t;if((t=this.iframe)!=null&&t.contentWindow){const r=new URL(c).origin;this.iframe.contentWindow.postMessage(e,r)}}onMessage(e){window.addEventListener("message",t=>{e(t.data)})}}const v=n=>{const e=i.useRef(null),t=i.useRef(null),[r,o]=i.useState(!1),s=i.useMemo(()=>n,[n.clientId,n.apiKey,n.path,n.width,n.height,n.enablePathSync]);return i.useEffect(()=>{o(!0)},[]),(typeof window!="undefined"?i.useLayoutEffect:i.useEffect)(()=>{if(!(!r||typeof window=="undefined")){if(e.current&&!t.current)try{t.current=new P(b(R({},s),{container:e.current}))}catch(h){console.error("Error creating HKEmbed:",h)}return()=>{t.current&&(t.current=null)}}},[s,r]),r?i.createElement("div",{ref:e,style:n.style}):i.createElement("div",{ref:e,style:n.style})};exports.HKEmbed=P;exports.HKReactEmbed=v;
1
+ "use strict";var M=Object.defineProperty,U=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var g=(n,e,t)=>e in n?M(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,R=(n,e)=>{for(var t in e||(e={}))T.call(e,t)&&g(n,t,e[t]);if(E)for(var t of E(e))H.call(e,t)&&g(n,t,e[t]);return n},b=(n,e)=>U(n,L(e));var f=(n,e,t)=>g(n,typeof e!="symbol"?e+"":e,t);var w=(n,e,t)=>new Promise((r,o)=>{var s=a=>{try{c(t.next(a))}catch(l){o(l)}},u=a=>{try{c(t.throw(a))}catch(l){o(l)}},c=a=>a.done?r(a.value):Promise.resolve(a.value).then(s,u);c((t=t.apply(n,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),I="https://app.homekynd.com";function N(n,e){return w(this,null,function*(){try{const t=yield fetch(`${I}/api/v1/company/generate-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_secret:n,id:e})}),r=yield t.json();if(t.ok)return r.token;console.error("Error fetching token: please confirm your API Secret and Client ID",r)}catch(t){console.error("Fetch error:",t)}})}const v={root:"/company",renders:"/renders",spaces:"/spaces"},d="https://app.homekynd.com";class S{constructor(e){f(this,"container");f(this,"iframe");f(this,"currentToken");f(this,"created",!1);const{container:t}=e;if(!t)throw new Error("Container element is required");this.container=t,this.create(e)}create(e){return w(this,null,function*(){if(this.created)return;const{clientId:t,apiKey:r,path:o="root",width:s="100%",height:u="100%",enablePathSync:c=!0}=e,a=new URL(window.location.href),m=a.searchParams.get("ifpath")||v[o],P=d.endsWith("/")?d:d+"/",k=m.startsWith("/")?m.substring(1):m,y=new URL(k,P),p=yield N(r,t);this.currentToken=p,p&&y.searchParams.set("token",p);const h=document.createElement("iframe");return h.src=y.toString(),h.style.border="0",h.style.width=isNaN(Number(s))?s:`${s}px`,h.style.height=isNaN(Number(u))?u:`${u}px`,this.iframe=h,h.onload=()=>{this.currentToken&&this.sendMessage({type:"SET_TOKEN",token:this.currentToken})},this.container.innerHTML="",this.container.appendChild(h),c&&(a.searchParams.set("ifpath",m),window.history.replaceState({},"",a.toString())),this.setupMessageHandling(),this.created=!0,{sendMessage:this.sendMessage.bind(this),onMessage:this.onMessage.bind(this)}})}setupMessageHandling(){window.addEventListener("message",e=>{var t;((t=e.data)==null?void 0:t.type)==="ROUTE_CHANGE"&&this.onRouteChange(e.data.path)})}onRouteChange(e){this.inputParentRoute(e),this.inputIframeRoute(e)}inputParentRoute(e){const t=new URL(window.location.href);t.searchParams.set("ifpath",e),window.history.replaceState({},"",t.toString())}inputIframeRoute(e){if(!this.iframe)return;const t=new URL(this.iframe.src),r=d.endsWith("/")?d:d+"/",o=e.startsWith("/")?e.substring(1):e,s=new URL(o,r);t.pathname!==s.pathname&&(this.iframe.src=s.toString())}sendMessage(e){var t;if((t=this.iframe)!=null&&t.contentWindow){const r=new URL(d).origin;this.iframe.contentWindow.postMessage(e,r)}}onMessage(e){window.addEventListener("message",t=>{e(t.data)})}}const K=n=>{const e=i.useRef(null),t=i.useRef(null),[r,o]=i.useState(!1),s=i.useMemo(()=>n,[n.clientId,n.apiKey,n.path,n.width,n.height,n.enablePathSync]);return i.useEffect(()=>{o(!0)},[]),(typeof window!="undefined"?i.useLayoutEffect:i.useEffect)(()=>{if(!(!r||typeof window=="undefined")){if(e.current&&!t.current)try{t.current=new S(b(R({},s),{container:e.current}))}catch(c){console.error("Error creating HKEmbed:",c)}return()=>{t.current&&(t.current=null)}}},[s,r]),r?i.createElement("div",{ref:e,style:n.style}):i.createElement("div",{ref:e,style:n.style})};exports.HKEmbed=S;exports.HKReactEmbed=K;
package/dist/index.js CHANGED
@@ -1,38 +1,38 @@
1
- var U = Object.defineProperty, L = Object.defineProperties;
1
+ var L = Object.defineProperty, M = Object.defineProperties;
2
2
  var T = Object.getOwnPropertyDescriptors;
3
3
  var E = Object.getOwnPropertySymbols;
4
4
  var I = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
5
- var g = (n, e, t) => e in n ? U(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, R = (n, e) => {
5
+ var p = (n, e, t) => e in n ? L(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, R = (n, e) => {
6
6
  for (var t in e || (e = {}))
7
- I.call(e, t) && g(n, t, e[t]);
7
+ I.call(e, t) && p(n, t, e[t]);
8
8
  if (E)
9
9
  for (var t of E(e))
10
- N.call(e, t) && g(n, t, e[t]);
10
+ N.call(e, t) && p(n, t, e[t]);
11
11
  return n;
12
- }, b = (n, e) => L(n, T(e));
13
- var u = (n, e, t) => g(n, typeof e != "symbol" ? e + "" : e, t);
14
- var w = (n, e, t) => new Promise((r, i) => {
12
+ }, b = (n, e) => M(n, T(e));
13
+ var u = (n, e, t) => p(n, typeof e != "symbol" ? e + "" : e, t);
14
+ var g = (n, e, t) => new Promise((r, i) => {
15
15
  var s = (a) => {
16
16
  try {
17
- c(t.next(a));
17
+ o(t.next(a));
18
18
  } catch (f) {
19
19
  i(f);
20
20
  }
21
21
  }, d = (a) => {
22
22
  try {
23
- c(t.throw(a));
23
+ o(t.throw(a));
24
24
  } catch (f) {
25
25
  i(f);
26
26
  }
27
- }, c = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(s, d);
28
- c((t = t.apply(n, e)).next());
27
+ }, o = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(s, d);
28
+ o((t = t.apply(n, e)).next());
29
29
  });
30
- import p, { useRef as P, useMemo as v, useEffect as k, useLayoutEffect as C } from "react";
31
- const o = "https://staging.homekynd.com/";
32
- function H(n, e) {
33
- return w(this, null, function* () {
30
+ import w, { useRef as k, useMemo as v, useEffect as P, useLayoutEffect as C } from "react";
31
+ const H = "https://app.homekynd.com";
32
+ function K(n, e) {
33
+ return g(this, null, function* () {
34
34
  try {
35
- const t = yield fetch(`${o}/api/v1/company/generate-token`, {
35
+ const t = yield fetch(`${H}/api/v1/company/generate-token`, {
36
36
  method: "POST",
37
37
  headers: {
38
38
  "Content-Type": "application/json"
@@ -50,12 +50,12 @@ function H(n, e) {
50
50
  }
51
51
  });
52
52
  }
53
- const K = {
53
+ const O = {
54
54
  root: "/company",
55
55
  renders: "/renders",
56
56
  spaces: "/spaces"
57
- };
58
- class O {
57
+ }, h = "https://app.homekynd.com";
58
+ class W {
59
59
  constructor(e) {
60
60
  u(this, "container");
61
61
  u(this, "iframe");
@@ -66,7 +66,7 @@ class O {
66
66
  this.container = t, this.create(e);
67
67
  }
68
68
  create(e) {
69
- return w(this, null, function* () {
69
+ return g(this, null, function* () {
70
70
  if (this.created) return;
71
71
  const {
72
72
  clientId: t,
@@ -74,16 +74,16 @@ class O {
74
74
  path: i = "root",
75
75
  width: s = "100%",
76
76
  height: d = "100%",
77
- enablePathSync: c = !0
78
- } = e, a = new URL(window.location.href), l = a.searchParams.get("ifpath") || K[i], M = o.endsWith("/") ? o : o + "/", S = l.startsWith("/") ? l.substring(1) : l, y = new URL(S, M), m = yield H(r, t);
77
+ enablePathSync: o = !0
78
+ } = e, a = new URL(window.location.href), l = a.searchParams.get("ifpath") || O[i], S = h.endsWith("/") ? h : h + "/", U = l.startsWith("/") ? l.substring(1) : l, y = new URL(U, S), m = yield K(r, t);
79
79
  this.currentToken = m, m && y.searchParams.set("token", m);
80
- const h = document.createElement("iframe");
81
- return h.src = y.toString(), h.style.border = "0", h.style.width = isNaN(Number(s)) ? s : `${s}px`, h.style.height = isNaN(Number(d)) ? d : `${d}px`, this.iframe = h, h.onload = () => {
80
+ const c = document.createElement("iframe");
81
+ return c.src = y.toString(), c.style.border = "0", c.style.width = isNaN(Number(s)) ? s : `${s}px`, c.style.height = isNaN(Number(d)) ? d : `${d}px`, this.iframe = c, c.onload = () => {
82
82
  this.currentToken && this.sendMessage({
83
83
  type: "SET_TOKEN",
84
84
  token: this.currentToken
85
85
  });
86
- }, this.container.innerHTML = "", this.container.appendChild(h), c && (a.searchParams.set("ifpath", l), window.history.replaceState({}, "", a.toString())), this.setupMessageHandling(), this.created = !0, {
86
+ }, this.container.innerHTML = "", this.container.appendChild(c), o && (a.searchParams.set("ifpath", l), window.history.replaceState({}, "", a.toString())), this.setupMessageHandling(), this.created = !0, {
87
87
  sendMessage: this.sendMessage.bind(this),
88
88
  onMessage: this.onMessage.bind(this)
89
89
  };
@@ -104,13 +104,13 @@ class O {
104
104
  }
105
105
  inputIframeRoute(e) {
106
106
  if (!this.iframe) return;
107
- const t = new URL(this.iframe.src), r = o.endsWith("/") ? o : o + "/", i = e.startsWith("/") ? e.substring(1) : e, s = new URL(i, r);
107
+ const t = new URL(this.iframe.src), r = h.endsWith("/") ? h : h + "/", i = e.startsWith("/") ? e.substring(1) : e, s = new URL(i, r);
108
108
  t.pathname !== s.pathname && (this.iframe.src = s.toString());
109
109
  }
110
110
  sendMessage(e) {
111
111
  var t;
112
112
  if ((t = this.iframe) != null && t.contentWindow) {
113
- const r = new URL(o).origin;
113
+ const r = new URL(h).origin;
114
114
  this.iframe.contentWindow.postMessage(e, r);
115
115
  }
116
116
  }
@@ -120,8 +120,8 @@ class O {
120
120
  });
121
121
  }
122
122
  }
123
- const x = (n) => {
124
- const e = P(null), t = P(null), [r, i] = p.useState(!1), s = v(
123
+ const $ = (n) => {
124
+ const e = k(null), t = k(null), [r, i] = w.useState(!1), s = v(
125
125
  () => n,
126
126
  [
127
127
  n.clientId,
@@ -132,25 +132,25 @@ const x = (n) => {
132
132
  n.enablePathSync
133
133
  ]
134
134
  );
135
- return k(() => {
135
+ return P(() => {
136
136
  i(!0);
137
- }, []), (typeof window != "undefined" ? C : k)(() => {
137
+ }, []), (typeof window != "undefined" ? C : P)(() => {
138
138
  if (!(!r || typeof window == "undefined")) {
139
139
  if (e.current && !t.current)
140
140
  try {
141
- t.current = new O(b(R({}, s), {
141
+ t.current = new W(b(R({}, s), {
142
142
  container: e.current
143
143
  }));
144
- } catch (c) {
145
- console.error("Error creating HKEmbed:", c);
144
+ } catch (o) {
145
+ console.error("Error creating HKEmbed:", o);
146
146
  }
147
147
  return () => {
148
148
  t.current && (t.current = null);
149
149
  };
150
150
  }
151
- }, [s, r]), r ? /* @__PURE__ */ p.createElement("div", { ref: e, style: n.style }) : /* @__PURE__ */ p.createElement("div", { ref: e, style: n.style });
151
+ }, [s, r]), r ? /* @__PURE__ */ w.createElement("div", { ref: e, style: n.style }) : /* @__PURE__ */ w.createElement("div", { ref: e, style: n.style });
152
152
  };
153
153
  export {
154
- O as HKEmbed,
155
- x as HKReactEmbed
154
+ W as HKEmbed,
155
+ $ as HKReactEmbed
156
156
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@homekynd/hk-embed-sdk",
3
3
  "private": false,
4
- "version": "0.0.6",
4
+ "version": "0.0.7",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -25,6 +25,10 @@
25
25
  "dev:vanilla": "cp src/dev/vanilla.html index.html && vite",
26
26
  "dev:react": "cp src/dev/react.html index.html && vite",
27
27
  "build": "tsc -b && vite build",
28
+ "build:cdn:dev": "vite build --mode development --config vite.config.cdn.js",
29
+ "build:cdn:staging": "vite build --mode staging --config vite.config.cdn.js",
30
+ "build:cdn:production": "vite build --mode production --config vite.config.cdn.js",
31
+ "build:cdn": "npm run build:cdn:dev && npm run build:cdn:staging && npm run build:cdn:production",
28
32
  "lint": "eslint .",
29
33
  "preview": "vite preview",
30
34
  "prepare": "husky",