@homekynd/hk-embed-sdk 0.0.5 → 0.0.6
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/dist/index.cjs +1 -22
- package/dist/index.d.ts +2 -2
- package/dist/index.js +132 -356
- package/package.json +7 -9
- package/dist/hk-embed.iife.js +0 -22
- package/dist/hk-embed.umd.js +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
|
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;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
2
|
|
|
3
3
|
export declare type GenericMessageObject = any;
|
|
4
4
|
|
|
@@ -44,6 +44,6 @@ export declare type HKPath = Record<HKPathKey, string>;
|
|
|
44
44
|
|
|
45
45
|
export declare type HKPathKey = "root" | "renders" | "spaces";
|
|
46
46
|
|
|
47
|
-
export declare const HKReactEmbed:
|
|
47
|
+
export declare const HKReactEmbed: default_2.FC<HKEmbedConfigReact>;
|
|
48
48
|
|
|
49
49
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,380 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
var U = Object.defineProperty, L = Object.defineProperties;
|
|
2
|
+
var T = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var E = Object.getOwnPropertySymbols;
|
|
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) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
I.call(e, t) && g(n, t, e[t]);
|
|
8
|
+
if (E)
|
|
9
|
+
for (var t of E(e))
|
|
10
|
+
N.call(e, t) && g(n, t, e[t]);
|
|
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) => {
|
|
15
|
+
var s = (a) => {
|
|
16
|
+
try {
|
|
17
|
+
c(t.next(a));
|
|
18
|
+
} catch (f) {
|
|
19
|
+
i(f);
|
|
20
|
+
}
|
|
21
|
+
}, d = (a) => {
|
|
22
|
+
try {
|
|
23
|
+
c(t.throw(a));
|
|
24
|
+
} catch (f) {
|
|
25
|
+
i(f);
|
|
26
|
+
}
|
|
27
|
+
}, c = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(s, d);
|
|
28
|
+
c((t = t.apply(n, e)).next());
|
|
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* () {
|
|
34
|
+
try {
|
|
35
|
+
const t = yield fetch(`${o}/api/v1/company/generate-token`, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json"
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify({ api_secret: n, id: e })
|
|
41
|
+
}), r = yield t.json();
|
|
42
|
+
if (t.ok)
|
|
43
|
+
return r.token;
|
|
44
|
+
console.error(
|
|
45
|
+
"Error fetching token: please confirm your API Secret and Client ID",
|
|
46
|
+
r
|
|
47
|
+
);
|
|
48
|
+
} catch (t) {
|
|
49
|
+
console.error("Fetch error:", t);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
21
52
|
}
|
|
22
|
-
const
|
|
53
|
+
const K = {
|
|
23
54
|
root: "/company",
|
|
24
55
|
renders: "/renders",
|
|
25
56
|
spaces: "/spaces"
|
|
26
57
|
};
|
|
27
|
-
class
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const { container:
|
|
34
|
-
if (!
|
|
35
|
-
this.container =
|
|
58
|
+
class O {
|
|
59
|
+
constructor(e) {
|
|
60
|
+
u(this, "container");
|
|
61
|
+
u(this, "iframe");
|
|
62
|
+
u(this, "currentToken");
|
|
63
|
+
u(this, "created", !1);
|
|
64
|
+
const { container: t } = e;
|
|
65
|
+
if (!t) throw new Error("Container element is required");
|
|
66
|
+
this.container = t, this.create(e);
|
|
36
67
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
create(e) {
|
|
69
|
+
return w(this, null, function* () {
|
|
70
|
+
if (this.created) return;
|
|
71
|
+
const {
|
|
72
|
+
clientId: t,
|
|
73
|
+
apiKey: r,
|
|
74
|
+
path: i = "root",
|
|
75
|
+
width: s = "100%",
|
|
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);
|
|
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 = () => {
|
|
82
|
+
this.currentToken && this.sendMessage({
|
|
83
|
+
type: "SET_TOKEN",
|
|
84
|
+
token: this.currentToken
|
|
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, {
|
|
87
|
+
sendMessage: this.sendMessage.bind(this),
|
|
88
|
+
onMessage: this.onMessage.bind(this)
|
|
89
|
+
};
|
|
90
|
+
});
|
|
58
91
|
}
|
|
59
92
|
setupMessageHandling() {
|
|
60
|
-
window.addEventListener("message", (
|
|
61
|
-
|
|
93
|
+
window.addEventListener("message", (e) => {
|
|
94
|
+
var t;
|
|
95
|
+
((t = e.data) == null ? void 0 : t.type) === "ROUTE_CHANGE" && this.onRouteChange(e.data.path);
|
|
62
96
|
});
|
|
63
97
|
}
|
|
64
|
-
onRouteChange(
|
|
65
|
-
this.inputParentRoute(
|
|
98
|
+
onRouteChange(e) {
|
|
99
|
+
this.inputParentRoute(e), this.inputIframeRoute(e);
|
|
66
100
|
}
|
|
67
|
-
inputParentRoute(
|
|
68
|
-
const
|
|
69
|
-
|
|
101
|
+
inputParentRoute(e) {
|
|
102
|
+
const t = new URL(window.location.href);
|
|
103
|
+
t.searchParams.set("ifpath", e), window.history.replaceState({}, "", t.toString());
|
|
70
104
|
}
|
|
71
|
-
inputIframeRoute(
|
|
105
|
+
inputIframeRoute(e) {
|
|
72
106
|
if (!this.iframe) return;
|
|
73
|
-
const
|
|
74
|
-
|
|
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);
|
|
108
|
+
t.pathname !== s.pathname && (this.iframe.src = s.toString());
|
|
75
109
|
}
|
|
76
|
-
sendMessage(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
110
|
+
sendMessage(e) {
|
|
111
|
+
var t;
|
|
112
|
+
if ((t = this.iframe) != null && t.contentWindow) {
|
|
113
|
+
const r = new URL(o).origin;
|
|
114
|
+
this.iframe.contentWindow.postMessage(e, r);
|
|
80
115
|
}
|
|
81
116
|
}
|
|
82
|
-
onMessage(
|
|
83
|
-
window.addEventListener("message", (
|
|
84
|
-
t
|
|
117
|
+
onMessage(e) {
|
|
118
|
+
window.addEventListener("message", (t) => {
|
|
119
|
+
e(t.data);
|
|
85
120
|
});
|
|
86
121
|
}
|
|
87
122
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
}
|
|
123
|
+
const x = (n) => {
|
|
124
|
+
const e = P(null), t = P(null), [r, i] = p.useState(!1), s = v(
|
|
125
|
+
() => n,
|
|
126
|
+
[
|
|
127
|
+
n.clientId,
|
|
128
|
+
n.apiKey,
|
|
129
|
+
n.path,
|
|
130
|
+
n.width,
|
|
131
|
+
n.height,
|
|
132
|
+
n.enablePathSync
|
|
133
|
+
]
|
|
134
|
+
);
|
|
135
|
+
return k(() => {
|
|
136
|
+
i(!0);
|
|
137
|
+
}, []), (typeof window != "undefined" ? C : k)(() => {
|
|
138
|
+
if (!(!r || typeof window == "undefined")) {
|
|
139
|
+
if (e.current && !t.current)
|
|
140
|
+
try {
|
|
141
|
+
t.current = new O(b(R({}, s), {
|
|
142
|
+
container: e.current
|
|
143
|
+
}));
|
|
144
|
+
} catch (c) {
|
|
145
|
+
console.error("Error creating HKEmbed:", c);
|
|
173
146
|
}
|
|
174
|
-
return
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
}
|
|
147
|
+
return () => {
|
|
148
|
+
t.current && (t.current = null);
|
|
149
|
+
};
|
|
206
150
|
}
|
|
207
|
-
|
|
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 });
|
|
151
|
+
}, [s, r]), r ? /* @__PURE__ */ p.createElement("div", { ref: e, style: n.style }) : /* @__PURE__ */ p.createElement("div", { ref: e, style: n.style });
|
|
376
152
|
};
|
|
377
153
|
export {
|
|
378
|
-
|
|
379
|
-
|
|
154
|
+
O as HKEmbed,
|
|
155
|
+
x as HKReactEmbed
|
|
380
156
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homekynd/hk-embed-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
|
-
"unpkg": "dist/hk-embed.iife.js",
|
|
9
|
-
"jsdelivr": "dist/hk-embed.iife.js",
|
|
10
8
|
"types": "dist/index.d.ts",
|
|
11
9
|
"exports": {
|
|
12
10
|
".": {
|
|
@@ -36,17 +34,17 @@
|
|
|
36
34
|
"**/*": "prettier --write --ignore-unknown"
|
|
37
35
|
},
|
|
38
36
|
"peerDependencies": {
|
|
39
|
-
"react": "
|
|
40
|
-
"react-dom": "
|
|
37
|
+
"react": ">=16.8.0",
|
|
38
|
+
"react-dom": ">=16.8.0"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
43
41
|
"vite-plugin-dts": "^4.5.4",
|
|
44
|
-
"react": "^
|
|
45
|
-
"react-dom": "^
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"react-dom": "^18.3.1",
|
|
46
44
|
"@eslint/js": "^9.33.0",
|
|
47
45
|
"@types/node": "^24.3.0",
|
|
48
|
-
"@types/react": "^
|
|
49
|
-
"@types/react-dom": "^
|
|
46
|
+
"@types/react": "^18.3.17",
|
|
47
|
+
"@types/react-dom": "^18.3.0",
|
|
50
48
|
"@vitejs/plugin-react": "^5.0.0",
|
|
51
49
|
"eslint": "^9.33.0",
|
|
52
50
|
"eslint-plugin-react-hooks": "^5.2.0",
|
package/dist/hk-embed.iife.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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);
|
package/dist/hk-embed.umd.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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"})}));
|