@homekynd/hk-embed-sdk 0.0.0

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 ADDED
@@ -0,0 +1,147 @@
1
+ <p align="center">
2
+ <img width="160" height="160" alt="package-logo" src="https://github.com/user-attachments/assets/29f58a51-4163-4411-bc5b-3caac89c5e5b" />
3
+ </p>
4
+
5
+ <h1 align="center">HKEmbed SDK</h1>
6
+
7
+ #### A lightweight SDK for embedding Homekynd applications into your website with secure authentication and seamless integration.
8
+
9
+ ---
10
+
11
+ ## Installation
12
+
13
+ Contact your Homekynd representative to get access credentials, then install via npm:
14
+
15
+ ```bash
16
+ npm install @homekynd/hk-embed-sdk #TODO: Update with the correct command after the deployment flow is ready
17
+ ```
18
+
19
+ > [!IMPORTANT]
20
+ > This package requires authentication credentials provided by Homekynd. Contact support@homekynd.com for access.
21
+
22
+ ## Quick Start
23
+
24
+ ### For React Applications
25
+
26
+ ```tsx
27
+ import React from 'react';
28
+ import { HKReactEmbed } from '@homekynd/hk-embed-sdk';
29
+
30
+ 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
+ );
40
+ }
41
+ ```
42
+
43
+ ### For Vanilla JavaScript
44
+
45
+ ```html
46
+ <!DOCTYPE html>
47
+ <html>
48
+ <head>
49
+ <title>My Website</title>
50
+ </head>
51
+ <body>
52
+ <div id="homekynd-embed" style="width: 100%; height: 600px;"></div>
53
+
54
+ <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
+ });
64
+ </script>
65
+ </body>
66
+ </html>
67
+ ```
68
+
69
+ ## Configuration Options
70
+
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) |
80
+
81
+ ## Common Examples
82
+
83
+ ### Full Width Embed
84
+
85
+ ```tsx
86
+ <HKReactEmbed
87
+ clientId="your-client-id"
88
+ apiKey="your-api-key"
89
+ width="100%"
90
+ height="500px"
91
+ />
92
+ ```
93
+
94
+ ### Fixed Size Embed
95
+
96
+ ```tsx
97
+ <HKReactEmbed
98
+ clientId="your-client-id"
99
+ apiKey="your-api-key"
100
+ width={800}
101
+ height={600}
102
+ />
103
+ ```
104
+
105
+ ### Responsive Embed
106
+
107
+ ```tsx
108
+ <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
+ }}
118
+ />
119
+ ```
120
+
121
+ ## Troubleshooting
122
+
123
+ ### The embed doesn't load
124
+ - ✅ Check that your `clientId` and `apiKey` are correct
125
+ - ✅ Verify your credentials are active (contact support if needed)
126
+ - ✅ Ensure the container element exists before initializing
127
+
128
+ ### The embed appears but shows an error
129
+ - ✅ Your credentials may be expired or inactive
130
+ - ✅ Check the browser console for specific error messages
131
+ - ✅ Contact Homekynd support with the error details
132
+
133
+ ### Styling issues
134
+ - ✅ Make sure the container has explicit width/height
135
+ - ✅ Check for CSS conflicts in your application
136
+ - ✅ Use the `style` prop (React) for custom styling
137
+
138
+ ## Need Help?
139
+
140
+ - 📧 **Support**: support@homekynd.com
141
+ - 📖 **Documentation**: Additional resources available in your client portal
142
+
143
+ ## License
144
+
145
+ This software is proprietary to Homekynd, Inc. Usage is restricted to authorized clients and partners under the terms of your service agreement with Homekynd.
146
+
147
+ **© 2025 Homekynd, Inc. All rights reserved.**
@@ -0,0 +1,22 @@
1
+ var HKEmbed=(function(y,P){"use strict";const h="http://localhost:3000";async function G(u,t){try{const n=await fetch(`${h}/api/v1/company/generate-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_secret:u,id:t})}),l=await n.json();if(n.ok)return l.token;console.error("Error fetching token: please confirm your API Secret and Client ID",l)}catch(n){console.error("Fetch error:",n)}}const V={root:"/company",renders:"/renders",spaces:"/spaces"};class U{container;iframe;currentToken;created=!1;constructor(t){const{container:n}=t;if(!n)throw new Error("Container element is required");this.container=n,this.create(t)}async create(t){if(this.created)return;const{clientId:n,apiKey:l,path:c="root",width:o="100%",height:m="100%",enablePathSync:R=!0}=t,v=new URL(window.location.href),b=v.searchParams.get("ifpath")||V[c],O=h.endsWith("/")?h:h+"/",p=b.startsWith("/")?b.substring(1):b,w=new URL(p,O),k=await G(l,n);this.currentToken=k,k&&w.searchParams.set("token",k);const f=document.createElement("iframe");return f.src=w.toString(),f.style.border="0",f.style.width=isNaN(Number(o))?o:`${o}px`,f.style.height=isNaN(Number(m))?m:`${m}px`,console.log("applying user styles/sizing"),this.iframe=f,f.onload=()=>{this.currentToken&&this.sendMessage({type:"SET_TOKEN",token:this.currentToken})},this.container.innerHTML="",this.container.appendChild(f),R&&(v.searchParams.set("ifpath",b),window.history.replaceState({},"",v.toString())),this.setupMessageHandling(),this.created=!0,{sendMessage:this.sendMessage.bind(this),onMessage:this.onMessage.bind(this)}}setupMessageHandling(){window.addEventListener("message",t=>{t.data?.type==="ROUTE_CHANGE"&&this.onRouteChange(t.data.path)})}onRouteChange(t){this.inputParentRoute(t),this.inputIframeRoute(t)}inputParentRoute(t){const n=new URL(window.location.href);n.searchParams.set("ifpath",t),window.history.replaceState({},"",n.toString())}inputIframeRoute(t){if(!this.iframe)return;const n=new URL(this.iframe.src),l=h.endsWith("/")?h:h+"/",c=t.startsWith("/")?t.substring(1):t,o=new URL(c,l);n.pathname!==o.pathname&&(this.iframe.src=o.toString())}sendMessage(t){if(this.iframe?.contentWindow){const n=new URL(h).origin;this.iframe.contentWindow.postMessage(t,n)}}onMessage(t){window.addEventListener("message",n=>{t(n.data)})}}var S={exports:{}},g={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var M;function q(){if(M)return g;M=1;var u=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(l,c,o){var m=null;if(o!==void 0&&(m=""+o),c.key!==void 0&&(m=""+c.key),"key"in c){o={};for(var R in c)R!=="key"&&(o[R]=c[R])}else o=c;return c=o.ref,{$$typeof:u,type:l,key:m,ref:c!==void 0?c:null,props:o}}return g.Fragment=t,g.jsx=n,g.jsxs=n,g}var T={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var L;function K(){return L||(L=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case ee:return"Profiler";case Q:return"StrictMode";case ae:return"Suspense";case oe:return"SuspenseList";case ie:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case k:return"Portal";case te:return(e.displayName||"Context")+".Provider";case re:return(e._context.displayName||"Context")+".Consumer";case ne:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case W:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function t(e){return""+e}function n(e){try{t(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),t(e)}}function l(e){if(e===f)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===W)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=A.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function m(e){if(F.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function a(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function v(){var e=u(this.type);return H[e]||(H[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function Y(e,r,a,s,E,d,N,x){return a=d.ref,e={$$typeof:w,type:e,key:r,props:d,_owner:E},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function b(e,r,a,s,E,d,N,x){var i=r.children;if(i!==void 0)if(s)if(ue(i)){for(s=0;s<i.length;s++)O(i[s]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else O(i);if(F.call(r,"key")){i=u(e);var _=Object.keys(r).filter(function(le){return le!=="key"});s=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",z[i+s]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,s,i,_,i),z[i+s]=!0)}if(i=null,a!==void 0&&(n(a),i=""+a),m(r)&&(n(r.key),i=""+r.key),"key"in r){a={};for(var C in r)C!=="key"&&(a[C]=r[C])}else a=r;return i&&R(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),Y(e,i,d,E,c(),a,N,x)}function O(e){typeof e=="object"&&e!==null&&e.$$typeof===w&&e._store&&(e._store.validated=1)}var p=P,w=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),te=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),A=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,ue=Array.isArray,j=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var D,H={},$=p.react_stack_bottom_frame.bind(p,o)(),J=j(l(o)),z={};T.Fragment=f,T.jsx=function(e,r,a,s,E){var d=1e4>A.recentlyCreatedOwnerStacks++;return b(e,r,a,!1,s,E,d?Error("react-stack-top-frame"):$,d?j(l(e)):J)},T.jsxs=function(e,r,a,s,E){var d=1e4>A.recentlyCreatedOwnerStacks++;return b(e,r,a,!0,s,E,d?Error("react-stack-top-frame"):$,d?j(l(e)):J)}})()),T}var I;function X(){return I||(I=1,process.env.NODE_ENV==="production"?S.exports=q():S.exports=K()),S.exports}var B=X();const Z=u=>{const t=P.useRef(null),n=P.useRef(null);return P.useLayoutEffect(()=>(t.current&&!n.current&&(n.current=new U({...u,container:t.current})),()=>{n.current=null}),[u]),B.jsx("div",{ref:t,style:u.style})};return y.HKEmbed=U,y.HKReactEmbed=Z,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),y})({},React);
@@ -0,0 +1,22 @@
1
+ (function(h,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(h=typeof globalThis<"u"?globalThis:h||self,E(h.HKEmbed={},h.React))})(this,(function(h,E){"use strict";const p="http://localhost:3000";async function G(u,t){try{const n=await fetch(`${p}/api/v1/company/generate-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_secret:u,id:t})}),l=await n.json();if(n.ok)return l.token;console.error("Error fetching token: please confirm your API Secret and Client ID",l)}catch(n){console.error("Fetch error:",n)}}const V={root:"/company",renders:"/renders",spaces:"/spaces"};class U{container;iframe;currentToken;created=!1;constructor(t){const{container:n}=t;if(!n)throw new Error("Container element is required");this.container=n,this.create(t)}async create(t){if(this.created)return;const{clientId:n,apiKey:l,path:c="root",width:o="100%",height:m="100%",enablePathSync:b=!0}=t,k=new URL(window.location.href),T=k.searchParams.get("ifpath")||V[c],O=p.endsWith("/")?p:p+"/",_=T.startsWith("/")?T.substring(1):T,y=new URL(_,O),P=await G(l,n);this.currentToken=P,P&&y.searchParams.set("token",P);const f=document.createElement("iframe");return f.src=y.toString(),f.style.border="0",f.style.width=isNaN(Number(o))?o:`${o}px`,f.style.height=isNaN(Number(m))?m:`${m}px`,console.log("applying user styles/sizing"),this.iframe=f,f.onload=()=>{this.currentToken&&this.sendMessage({type:"SET_TOKEN",token:this.currentToken})},this.container.innerHTML="",this.container.appendChild(f),b&&(k.searchParams.set("ifpath",T),window.history.replaceState({},"",k.toString())),this.setupMessageHandling(),this.created=!0,{sendMessage:this.sendMessage.bind(this),onMessage:this.onMessage.bind(this)}}setupMessageHandling(){window.addEventListener("message",t=>{t.data?.type==="ROUTE_CHANGE"&&this.onRouteChange(t.data.path)})}onRouteChange(t){this.inputParentRoute(t),this.inputIframeRoute(t)}inputParentRoute(t){const n=new URL(window.location.href);n.searchParams.set("ifpath",t),window.history.replaceState({},"",n.toString())}inputIframeRoute(t){if(!this.iframe)return;const n=new URL(this.iframe.src),l=p.endsWith("/")?p:p+"/",c=t.startsWith("/")?t.substring(1):t,o=new URL(c,l);n.pathname!==o.pathname&&(this.iframe.src=o.toString())}sendMessage(t){if(this.iframe?.contentWindow){const n=new URL(p).origin;this.iframe.contentWindow.postMessage(t,n)}}onMessage(t){window.addEventListener("message",n=>{t(n.data)})}}var S={exports:{}},v={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var M;function q(){if(M)return v;M=1;var u=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(l,c,o){var m=null;if(o!==void 0&&(m=""+o),c.key!==void 0&&(m=""+c.key),"key"in c){o={};for(var b in c)b!=="key"&&(o[b]=c[b])}else o=c;return c=o.ref,{$$typeof:u,type:l,key:m,ref:c!==void 0?c:null,props:o}}return v.Fragment=t,v.jsx=n,v.jsxs=n,v}var w={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var L;function K(){return L||(L=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case ee:return"Profiler";case Q:return"StrictMode";case ae:return"Suspense";case oe:return"SuspenseList";case ie:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case P:return"Portal";case te:return(e.displayName||"Context")+".Provider";case re:return(e._context.displayName||"Context")+".Consumer";case ne:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case W:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function t(e){return""+e}function n(e){try{t(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),t(e)}}function l(e){if(e===f)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===W)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=A.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function m(e){if(F.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function b(e,r){function a(){D||(D=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function k(){var e=u(this.type);return H[e]||(H[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function Y(e,r,a,s,R,d,x,N){return a=d.ref,e={$$typeof:y,type:e,key:r,props:d,_owner:R},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:k}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function T(e,r,a,s,R,d,x,N){var i=r.children;if(i!==void 0)if(s)if(ue(i)){for(s=0;s<i.length;s++)O(i[s]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else O(i);if(F.call(r,"key")){i=u(e);var g=Object.keys(r).filter(function(le){return le!=="key"});s=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",z[i+s]||(g=0<g.length?"{"+g.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,s,i,g,i),z[i+s]=!0)}if(i=null,a!==void 0&&(n(a),i=""+a),m(r)&&(n(r.key),i=""+r.key),"key"in r){a={};for(var C in r)C!=="key"&&(a[C]=r[C])}else a=r;return i&&b(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),Y(e,i,d,R,c(),a,x,N)}function O(e){typeof e=="object"&&e!==null&&e.$$typeof===y&&e._store&&(e._store.validated=1)}var _=E,y=Symbol.for("react.transitional.element"),P=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),te=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),A=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,ue=Array.isArray,j=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(e){return e()}};var D,H={},$=_.react_stack_bottom_frame.bind(_,o)(),J=j(l(o)),z={};w.Fragment=f,w.jsx=function(e,r,a,s,R){var d=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,a,!1,s,R,d?Error("react-stack-top-frame"):$,d?j(l(e)):J)},w.jsxs=function(e,r,a,s,R){var d=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,a,!0,s,R,d?Error("react-stack-top-frame"):$,d?j(l(e)):J)}})()),w}var I;function X(){return I||(I=1,process.env.NODE_ENV==="production"?S.exports=q():S.exports=K()),S.exports}var B=X();const Z=u=>{const t=E.useRef(null),n=E.useRef(null);return E.useLayoutEffect(()=>(t.current&&!n.current&&(n.current=new U({...u,container:t.current})),()=>{n.current=null}),[u]),B.jsx("div",{ref:t,style:u.style})};h.HKEmbed=U,h.HKReactEmbed=Z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.cjs ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),E="http://localhost:3000";async function ne(u,t){try{const n=await fetch(`${E}/api/v1/company/generate-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_secret:u,id:t})}),l=await n.json();if(n.ok)return l.token;console.error("Error fetching token: please confirm your API Secret and Client ID",l)}catch(n){console.error("Fetch error:",n)}}const ae={root:"/company",renders:"/renders",spaces:"/spaces"};class H{container;iframe;currentToken;created=!1;constructor(t){const{container:n}=t;if(!n)throw new Error("Container element is required");this.container=n,this.create(t)}async create(t){if(this.created)return;const{clientId:n,apiKey:l,path:c="root",width:o="100%",height:m="100%",enablePathSync:R=!0}=t,g=new URL(window.location.href),p=g.searchParams.get("ifpath")||ae[c],y=E.endsWith("/")?E:E+"/",b=p.startsWith("/")?p.substring(1):p,T=new URL(b,y),v=await ne(l,n);this.currentToken=v,v&&T.searchParams.set("token",v);const f=document.createElement("iframe");return f.src=T.toString(),f.style.border="0",f.style.width=isNaN(Number(o))?o:`${o}px`,f.style.height=isNaN(Number(m))?m:`${m}px`,console.log("applying user styles/sizing"),this.iframe=f,f.onload=()=>{this.currentToken&&this.sendMessage({type:"SET_TOKEN",token:this.currentToken})},this.container.innerHTML="",this.container.appendChild(f),R&&(g.searchParams.set("ifpath",p),window.history.replaceState({},"",g.toString())),this.setupMessageHandling(),this.created=!0,{sendMessage:this.sendMessage.bind(this),onMessage:this.onMessage.bind(this)}}setupMessageHandling(){window.addEventListener("message",t=>{t.data?.type==="ROUTE_CHANGE"&&this.onRouteChange(t.data.path)})}onRouteChange(t){this.inputParentRoute(t),this.inputIframeRoute(t)}inputParentRoute(t){const n=new URL(window.location.href);n.searchParams.set("ifpath",t),window.history.replaceState({},"",n.toString())}inputIframeRoute(t){if(!this.iframe)return;const n=new URL(this.iframe.src),l=E.endsWith("/")?E:E+"/",c=t.startsWith("/")?t.substring(1):t,o=new URL(c,l);n.pathname!==o.pathname&&(this.iframe.src=o.toString())}sendMessage(t){if(this.iframe?.contentWindow){const n=new URL(E).origin;this.iframe.contentWindow.postMessage(t,n)}}onMessage(t){window.addEventListener("message",n=>{t(n.data)})}}var P={exports:{}},w={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var F;function oe(){if(F)return w;F=1;var u=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(l,c,o){var m=null;if(o!==void 0&&(m=""+o),c.key!==void 0&&(m=""+c.key),"key"in c){o={};for(var R in c)R!=="key"&&(o[R]=c[R])}else o=c;return c=o.ref,{$$typeof:u,type:l,key:m,ref:c!==void 0?c:null,props:o}}return w.Fragment=t,w.jsx=n,w.jsxs=n,w}var k={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var D;function se(){return D||(D=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case z:return"Profiler";case J:return"StrictMode";case K:return"Suspense";case B:return"SuspenseList";case Q:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case v:return"Portal";case V:return(e.displayName||"Context")+".Provider";case G:return(e._context.displayName||"Context")+".Consumer";case X:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Z:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case U:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function t(e){return""+e}function n(e){try{t(e);var r=!1}catch{r=!0}if(r){r=console;var a=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),t(e)}}function l(e){if(e===f)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===U)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function c(){var e=O.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function m(e){if(M.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function a(){L||(L=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}function g(){var e=u(this.type);return I[e]||(I[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function C(e,r,a,s,h,d,j,N){return a=d.ref,e={$$typeof:T,type:e,key:r,props:d,_owner:h},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:g}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:j}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function p(e,r,a,s,h,d,j,N){var i=r.children;if(i!==void 0)if(s)if(re(i)){for(s=0;s<i.length;s++)y(i[s]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(i);if(M.call(r,"key")){i=u(e);var _=Object.keys(r).filter(function(te){return te!=="key"});s=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",W[i+s]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,s,i,_,i),W[i+s]=!0)}if(i=null,a!==void 0&&(n(a),i=""+a),m(r)&&(n(r.key),i=""+r.key),"key"in r){a={};for(var x in r)x!=="key"&&(a[x]=r[x])}else a=r;return i&&R(a,typeof e=="function"?e.displayName||e.name||"Unknown":e),C(e,i,d,h,c(),a,j,N)}function y(e){typeof e=="object"&&e!==null&&e.$$typeof===T&&e._store&&(e._store.validated=1)}var b=S,T=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),J=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),V=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),ee=Symbol.for("react.client.reference"),O=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,re=Array.isArray,A=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(e){return e()}};var L,I={},Y=b.react_stack_bottom_frame.bind(b,o)(),$=A(l(o)),W={};k.Fragment=f,k.jsx=function(e,r,a,s,h){var d=1e4>O.recentlyCreatedOwnerStacks++;return p(e,r,a,!1,s,h,d?Error("react-stack-top-frame"):Y,d?A(l(e)):$)},k.jsxs=function(e,r,a,s,h){var d=1e4>O.recentlyCreatedOwnerStacks++;return p(e,r,a,!0,s,h,d?Error("react-stack-top-frame"):Y,d?A(l(e)):$)}})()),k}var q;function ie(){return q||(q=1,process.env.NODE_ENV==="production"?P.exports=oe():P.exports=se()),P.exports}var ce=ie();const ue=u=>{const t=S.useRef(null),n=S.useRef(null);return S.useLayoutEffect(()=>(t.current&&!n.current&&(n.current=new H({...u,container:t.current})),()=>{n.current=null}),[u]),ce.jsx("div",{ref:t,style:u.style})};exports.HKEmbed=H;exports.HKReactEmbed=ue;
@@ -0,0 +1,49 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+
3
+ export declare type GenericMessageObject = any;
4
+
5
+ export declare class HKEmbed {
6
+ private container;
7
+ private iframe?;
8
+ private currentToken?;
9
+ private created;
10
+ constructor(options: HKEmbedConfigVanilla);
11
+ private create;
12
+ private setupMessageHandling;
13
+ private onRouteChange;
14
+ private inputParentRoute;
15
+ private inputIframeRoute;
16
+ private sendMessage;
17
+ private onMessage;
18
+ }
19
+
20
+ export declare interface HKEmbedConfigContainer {
21
+ container: HTMLElement;
22
+ }
23
+
24
+ export declare interface HKEmbedConfigOptions {
25
+ clientId: string;
26
+ apiKey: string;
27
+ path?: HKPathKey;
28
+ width?: string | number;
29
+ height?: string | number;
30
+ enablePathSync?: boolean;
31
+ }
32
+
33
+ export declare interface HKEmbedConfigReact extends HKEmbedConfigStyles, HKEmbedConfigOptions {
34
+ }
35
+
36
+ export declare interface HKEmbedConfigStyles {
37
+ style?: React.CSSProperties;
38
+ }
39
+
40
+ export declare interface HKEmbedConfigVanilla extends HKEmbedConfigContainer, HKEmbedConfigOptions {
41
+ }
42
+
43
+ export declare type HKPath = Record<HKPathKey, string>;
44
+
45
+ export declare type HKPathKey = "root" | "renders" | "spaces";
46
+
47
+ export declare const HKReactEmbed: (options: HKEmbedConfigReact) => JSX.Element;
48
+
49
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,380 @@
1
+ import te, { useRef as W, useLayoutEffect as ne } from "react";
2
+ const E = "http://localhost:3000";
3
+ async function ae(u, t) {
4
+ try {
5
+ const n = await fetch(`${E}/api/v1/company/generate-token`, {
6
+ method: "POST",
7
+ headers: {
8
+ "Content-Type": "application/json"
9
+ },
10
+ body: JSON.stringify({ api_secret: u, id: t })
11
+ }), l = await n.json();
12
+ if (n.ok)
13
+ return l.token;
14
+ console.error(
15
+ "Error fetching token: please confirm your API Secret and Client ID",
16
+ l
17
+ );
18
+ } catch (n) {
19
+ console.error("Fetch error:", n);
20
+ }
21
+ }
22
+ const oe = {
23
+ root: "/company",
24
+ renders: "/renders",
25
+ spaces: "/spaces"
26
+ };
27
+ class se {
28
+ container;
29
+ iframe;
30
+ currentToken;
31
+ created = !1;
32
+ constructor(t) {
33
+ const { container: n } = t;
34
+ if (!n) throw new Error("Container element is required");
35
+ this.container = n, this.create(t);
36
+ }
37
+ async create(t) {
38
+ if (this.created) return;
39
+ const {
40
+ clientId: n,
41
+ apiKey: l,
42
+ path: c = "root",
43
+ width: o = "100%",
44
+ height: m = "100%",
45
+ enablePathSync: R = !0
46
+ } = t, T = new URL(window.location.href), p = T.searchParams.get("ifpath") || oe[c], y = E.endsWith("/") ? E : E + "/", b = p.startsWith("/") ? p.substring(1) : p, g = new URL(b, y), v = await ae(l, n);
47
+ this.currentToken = v, v && g.searchParams.set("token", v);
48
+ const f = document.createElement("iframe");
49
+ return f.src = g.toString(), f.style.border = "0", f.style.width = isNaN(Number(o)) ? o : `${o}px`, f.style.height = isNaN(Number(m)) ? m : `${m}px`, console.log("applying user styles/sizing"), this.iframe = f, f.onload = () => {
50
+ this.currentToken && this.sendMessage({
51
+ type: "SET_TOKEN",
52
+ token: this.currentToken
53
+ });
54
+ }, this.container.innerHTML = "", this.container.appendChild(f), R && (T.searchParams.set("ifpath", p), window.history.replaceState({}, "", T.toString())), this.setupMessageHandling(), this.created = !0, {
55
+ sendMessage: this.sendMessage.bind(this),
56
+ onMessage: this.onMessage.bind(this)
57
+ };
58
+ }
59
+ setupMessageHandling() {
60
+ window.addEventListener("message", (t) => {
61
+ t.data?.type === "ROUTE_CHANGE" && this.onRouteChange(t.data.path);
62
+ });
63
+ }
64
+ onRouteChange(t) {
65
+ this.inputParentRoute(t), this.inputIframeRoute(t);
66
+ }
67
+ inputParentRoute(t) {
68
+ const n = new URL(window.location.href);
69
+ n.searchParams.set("ifpath", t), window.history.replaceState({}, "", n.toString());
70
+ }
71
+ inputIframeRoute(t) {
72
+ if (!this.iframe) return;
73
+ const n = new URL(this.iframe.src), l = E.endsWith("/") ? E : E + "/", c = t.startsWith("/") ? t.substring(1) : t, o = new URL(c, l);
74
+ n.pathname !== o.pathname && (this.iframe.src = o.toString());
75
+ }
76
+ sendMessage(t) {
77
+ if (this.iframe?.contentWindow) {
78
+ const n = new URL(E).origin;
79
+ this.iframe.contentWindow.postMessage(t, n);
80
+ }
81
+ }
82
+ onMessage(t) {
83
+ window.addEventListener("message", (n) => {
84
+ t(n.data);
85
+ });
86
+ }
87
+ }
88
+ var P = { exports: {} }, w = {};
89
+ /**
90
+ * @license React
91
+ * react-jsx-runtime.production.js
92
+ *
93
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
94
+ *
95
+ * This source code is licensed under the MIT license found in the
96
+ * LICENSE file in the root directory of this source tree.
97
+ */
98
+ var F;
99
+ function ie() {
100
+ if (F) return w;
101
+ F = 1;
102
+ var u = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
103
+ function n(l, c, o) {
104
+ var m = null;
105
+ if (o !== void 0 && (m = "" + o), c.key !== void 0 && (m = "" + c.key), "key" in c) {
106
+ o = {};
107
+ for (var R in c)
108
+ R !== "key" && (o[R] = c[R]);
109
+ } else o = c;
110
+ return c = o.ref, {
111
+ $$typeof: u,
112
+ type: l,
113
+ key: m,
114
+ ref: c !== void 0 ? c : null,
115
+ props: o
116
+ };
117
+ }
118
+ return w.Fragment = t, w.jsx = n, w.jsxs = n, w;
119
+ }
120
+ var k = {};
121
+ /**
122
+ * @license React
123
+ * react-jsx-runtime.development.js
124
+ *
125
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
126
+ *
127
+ * This source code is licensed under the MIT license found in the
128
+ * LICENSE file in the root directory of this source tree.
129
+ */
130
+ var D;
131
+ function ce() {
132
+ return D || (D = 1, process.env.NODE_ENV !== "production" && (function() {
133
+ function u(e) {
134
+ if (e == null) return null;
135
+ if (typeof e == "function")
136
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
137
+ if (typeof e == "string") return e;
138
+ switch (e) {
139
+ case f:
140
+ return "Fragment";
141
+ case z:
142
+ return "Profiler";
143
+ case J:
144
+ return "StrictMode";
145
+ case X:
146
+ return "Suspense";
147
+ case B:
148
+ return "SuspenseList";
149
+ case Z:
150
+ return "Activity";
151
+ }
152
+ if (typeof e == "object")
153
+ switch (typeof e.tag == "number" && console.error(
154
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
155
+ ), e.$$typeof) {
156
+ case v:
157
+ return "Portal";
158
+ case G:
159
+ return (e.displayName || "Context") + ".Provider";
160
+ case H:
161
+ return (e._context.displayName || "Context") + ".Consumer";
162
+ case V:
163
+ var r = e.render;
164
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
165
+ case K:
166
+ return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
167
+ case C:
168
+ r = e._payload, e = e._init;
169
+ try {
170
+ return u(e(r));
171
+ } catch {
172
+ }
173
+ }
174
+ return null;
175
+ }
176
+ function t(e) {
177
+ return "" + e;
178
+ }
179
+ function n(e) {
180
+ try {
181
+ t(e);
182
+ var r = !1;
183
+ } catch {
184
+ r = !0;
185
+ }
186
+ if (r) {
187
+ r = console;
188
+ var a = r.error, s = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
189
+ return a.call(
190
+ r,
191
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
192
+ s
193
+ ), t(e);
194
+ }
195
+ }
196
+ function l(e) {
197
+ if (e === f) return "<>";
198
+ if (typeof e == "object" && e !== null && e.$$typeof === C)
199
+ return "<...>";
200
+ try {
201
+ var r = u(e);
202
+ return r ? "<" + r + ">" : "<...>";
203
+ } catch {
204
+ return "<...>";
205
+ }
206
+ }
207
+ function c() {
208
+ var e = S.A;
209
+ return e === null ? null : e.getOwner();
210
+ }
211
+ function o() {
212
+ return Error("react-stack-top-frame");
213
+ }
214
+ function m(e) {
215
+ if (U.call(e, "key")) {
216
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
217
+ if (r && r.isReactWarning) return !1;
218
+ }
219
+ return e.key !== void 0;
220
+ }
221
+ function R(e, r) {
222
+ function a() {
223
+ L || (L = !0, console.error(
224
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
225
+ r
226
+ ));
227
+ }
228
+ a.isReactWarning = !0, Object.defineProperty(e, "key", {
229
+ get: a,
230
+ configurable: !0
231
+ });
232
+ }
233
+ function T() {
234
+ var e = u(this.type);
235
+ return M[e] || (M[e] = !0, console.error(
236
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
237
+ )), e = this.props.ref, e !== void 0 ? e : null;
238
+ }
239
+ function N(e, r, a, s, h, d, A, j) {
240
+ return a = d.ref, e = {
241
+ $$typeof: g,
242
+ type: e,
243
+ key: r,
244
+ props: d,
245
+ _owner: h
246
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
247
+ enumerable: !1,
248
+ get: T
249
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
250
+ configurable: !1,
251
+ enumerable: !1,
252
+ writable: !0,
253
+ value: 0
254
+ }), Object.defineProperty(e, "_debugInfo", {
255
+ configurable: !1,
256
+ enumerable: !1,
257
+ writable: !0,
258
+ value: null
259
+ }), Object.defineProperty(e, "_debugStack", {
260
+ configurable: !1,
261
+ enumerable: !1,
262
+ writable: !0,
263
+ value: A
264
+ }), Object.defineProperty(e, "_debugTask", {
265
+ configurable: !1,
266
+ enumerable: !1,
267
+ writable: !0,
268
+ value: j
269
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
270
+ }
271
+ function p(e, r, a, s, h, d, A, j) {
272
+ var i = r.children;
273
+ if (i !== void 0)
274
+ if (s)
275
+ if (ee(i)) {
276
+ for (s = 0; s < i.length; s++)
277
+ y(i[s]);
278
+ Object.freeze && Object.freeze(i);
279
+ } else
280
+ console.error(
281
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
282
+ );
283
+ else y(i);
284
+ if (U.call(r, "key")) {
285
+ i = u(e);
286
+ var _ = Object.keys(r).filter(function(re) {
287
+ return re !== "key";
288
+ });
289
+ s = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", $[i + s] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
290
+ `A props object containing a "key" prop is being spread into JSX:
291
+ let props = %s;
292
+ <%s {...props} />
293
+ React keys must be passed directly to JSX without using spread:
294
+ let props = %s;
295
+ <%s key={someKey} {...props} />`,
296
+ s,
297
+ i,
298
+ _,
299
+ i
300
+ ), $[i + s] = !0);
301
+ }
302
+ if (i = null, a !== void 0 && (n(a), i = "" + a), m(r) && (n(r.key), i = "" + r.key), "key" in r) {
303
+ a = {};
304
+ for (var x in r)
305
+ x !== "key" && (a[x] = r[x]);
306
+ } else a = r;
307
+ return i && R(
308
+ a,
309
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
310
+ ), N(
311
+ e,
312
+ i,
313
+ d,
314
+ h,
315
+ c(),
316
+ a,
317
+ A,
318
+ j
319
+ );
320
+ }
321
+ function y(e) {
322
+ typeof e == "object" && e !== null && e.$$typeof === g && e._store && (e._store.validated = 1);
323
+ }
324
+ var b = te, g = Symbol.for("react.transitional.element"), v = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), J = Symbol.for("react.strict_mode"), z = Symbol.for("react.profiler"), H = Symbol.for("react.consumer"), G = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), K = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), Q = Symbol.for("react.client.reference"), S = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, ee = Array.isArray, O = console.createTask ? console.createTask : function() {
325
+ return null;
326
+ };
327
+ b = {
328
+ react_stack_bottom_frame: function(e) {
329
+ return e();
330
+ }
331
+ };
332
+ var L, M = {}, I = b.react_stack_bottom_frame.bind(
333
+ b,
334
+ o
335
+ )(), Y = O(l(o)), $ = {};
336
+ k.Fragment = f, k.jsx = function(e, r, a, s, h) {
337
+ var d = 1e4 > S.recentlyCreatedOwnerStacks++;
338
+ return p(
339
+ e,
340
+ r,
341
+ a,
342
+ !1,
343
+ s,
344
+ h,
345
+ d ? Error("react-stack-top-frame") : I,
346
+ d ? O(l(e)) : Y
347
+ );
348
+ }, k.jsxs = function(e, r, a, s, h) {
349
+ var d = 1e4 > S.recentlyCreatedOwnerStacks++;
350
+ return p(
351
+ e,
352
+ r,
353
+ a,
354
+ !0,
355
+ s,
356
+ h,
357
+ d ? Error("react-stack-top-frame") : I,
358
+ d ? O(l(e)) : Y
359
+ );
360
+ };
361
+ })()), k;
362
+ }
363
+ var q;
364
+ function ue() {
365
+ return q || (q = 1, process.env.NODE_ENV === "production" ? P.exports = ie() : P.exports = ce()), P.exports;
366
+ }
367
+ var le = ue();
368
+ const de = (u) => {
369
+ const t = W(null), n = W(null);
370
+ return ne(() => (t.current && !n.current && (n.current = new se({
371
+ ...u,
372
+ container: t.current
373
+ })), () => {
374
+ n.current = null;
375
+ }), [u]), /* @__PURE__ */ le.jsx("div", { ref: t, style: u.style });
376
+ };
377
+ export {
378
+ se as HKEmbed,
379
+ de as HKReactEmbed
380
+ };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@homekynd/hk-embed-sdk",
3
+ "private": false,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "unpkg": "dist/hk-embed.iife.js",
9
+ "jsdelivr": "dist/hk-embed.iife.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "scripts": {
27
+ "dev:vanilla": "cp src/dev/vanilla.html index.html && vite",
28
+ "dev:react": "cp src/dev/react.html index.html && vite",
29
+ "build": "tsc -b && vite build",
30
+ "lint": "eslint .",
31
+ "preview": "vite preview",
32
+ "prepare": "husky",
33
+ "publish:private": "npm publish --access restricted"
34
+ },
35
+ "lint-staged": {
36
+ "**/*": "prettier --write --ignore-unknown"
37
+ },
38
+ "dependencies": {
39
+ "react": "^19.1.1",
40
+ "react-dom": "^19.1.1",
41
+ "vite-plugin-dts": "^4.5.4"
42
+ },
43
+ "devDependencies": {
44
+ "@eslint/js": "^9.33.0",
45
+ "@types/node": "^24.3.0",
46
+ "@types/react": "^19.1.10",
47
+ "@types/react-dom": "^19.1.7",
48
+ "@vitejs/plugin-react": "^5.0.0",
49
+ "eslint": "^9.33.0",
50
+ "eslint-plugin-react-hooks": "^5.2.0",
51
+ "eslint-plugin-react-refresh": "^0.4.20",
52
+ "globals": "^16.3.0",
53
+ "husky": "^9.1.7",
54
+ "lint-staged": "^16.1.6",
55
+ "prettier": "3.6.2",
56
+ "typescript": "~5.8.3",
57
+ "typescript-eslint": "^8.39.1",
58
+ "vite": "^7.1.2"
59
+ }
60
+ }