@huddle01/iframe
Advanced tools
Comparing version 0.0.13-dev.0 to 0.0.13-dev.1
import HuddleIframe from './components/HuddleIframe'; | ||
import { IColorScheme, THuddleEventsMap, TLivestreamInput, TReaction } from './types'; | ||
declare const iframeApi: { | ||
declare class IFrameApi { | ||
initialize: (eventData: Partial<{ | ||
@@ -33,4 +33,5 @@ wallets: ("walletconnect" | "keplr" | "templewallet" | "phantom" | "beacon" | "okxwallet" | "suku" | "lens" | "ud" | "cyberconnect" | "*" | "metamask")[]; | ||
stopLiveStreaming: () => void; | ||
}; | ||
} | ||
declare const iframeApi: IFrameApi; | ||
declare const useEventListener: <K extends keyof THuddleEventsMap>(huddleEvent: K, cb: (data: THuddleEventsMap[K][0]) => void, dep?: unknown[]) => void; | ||
export { HuddleIframe, iframeApi, useEventListener }; |
@@ -346,2 +346,57 @@ 'use strict'; | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -467,4 +522,5 @@ _extends = Object.assign ? Object.assign.bind() : function (target) { | ||
}; | ||
var iframeApi = { | ||
initialize: zodErrHandler( /*#__PURE__*/function () { | ||
var IFrameApi = /*#__PURE__*/_createClass(function IFrameApi() { | ||
_classCallCheck(this, IFrameApi); | ||
_defineProperty(this, "initialize", zodErrHandler( /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventData) { | ||
@@ -489,4 +545,4 @@ return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
}; | ||
}()), | ||
muteMic: function muteMic() { | ||
}())); | ||
_defineProperty(this, "muteMic", function () { | ||
sendDataToIframe({ | ||
@@ -496,4 +552,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
unmuteMic: function unmuteMic() { | ||
}); | ||
_defineProperty(this, "unmuteMic", function () { | ||
sendDataToIframe({ | ||
@@ -503,4 +559,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
enableWebcam: function enableWebcam() { | ||
}); | ||
_defineProperty(this, "enableWebcam", function () { | ||
sendDataToIframe({ | ||
@@ -510,4 +566,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
disableWebcam: function disableWebcam() { | ||
}); | ||
_defineProperty(this, "disableWebcam", function () { | ||
sendDataToIframe({ | ||
@@ -517,4 +573,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
enableShare: function enableShare() { | ||
}); | ||
_defineProperty(this, "enableShare", function () { | ||
sendDataToIframe({ | ||
@@ -524,24 +580,18 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
disableShare: function () { | ||
var _disableShare = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
sendDataToIframe({ | ||
type: 'huddle01-iframe-from-parent', | ||
method: 'disableShare' | ||
}); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
function disableShare() { | ||
return _disableShare.apply(this, arguments); | ||
} | ||
return disableShare; | ||
}(), | ||
changeAvatarUrl: function changeAvatarUrl(avatarUrl) { | ||
}); | ||
_defineProperty(this, "disableShare", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
sendDataToIframe({ | ||
type: 'huddle01-iframe-from-parent', | ||
method: 'disableShare' | ||
}); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
}))); | ||
_defineProperty(this, "changeAvatarUrl", function (avatarUrl) { | ||
sendDataToIframe({ | ||
@@ -552,4 +602,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
sendReaction: function sendReaction(reaction) { | ||
}); | ||
_defineProperty(this, "sendReaction", function (reaction) { | ||
sendDataToIframe({ | ||
@@ -560,4 +610,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
lockRoom: function lockRoom() { | ||
}); | ||
_defineProperty(this, "lockRoom", function () { | ||
sendDataToIframe({ | ||
@@ -567,4 +617,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
unlockRoom: function unlockRoom() { | ||
}); | ||
_defineProperty(this, "unlockRoom", function () { | ||
sendDataToIframe({ | ||
@@ -574,4 +624,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
connectWallet: function connectWallet(token) { | ||
}); | ||
_defineProperty(this, "connectWallet", function (token) { | ||
var parsedJWT = parseJwt(token); | ||
@@ -589,4 +639,4 @@ | ||
}); | ||
}, | ||
setTheme: function setTheme(theme) { | ||
}); | ||
_defineProperty(this, "setTheme", function (theme) { | ||
sendDataToIframe({ | ||
@@ -597,4 +647,4 @@ method: 'theme', | ||
}); | ||
}, | ||
startRecording: function startRecording() { | ||
}); | ||
_defineProperty(this, "startRecording", function () { | ||
sendDataToIframe({ | ||
@@ -604,4 +654,4 @@ method: 'startRecording', | ||
}); | ||
}, | ||
stopRecording: function stopRecording() { | ||
}); | ||
_defineProperty(this, "stopRecording", function () { | ||
sendDataToIframe({ | ||
@@ -611,4 +661,4 @@ method: 'stopRecording', | ||
}); | ||
}, | ||
startLiveStreaming: function startLiveStreaming(eventData) { | ||
}); | ||
_defineProperty(this, "startLiveStreaming", function (eventData) { | ||
sendDataToIframe({ | ||
@@ -619,4 +669,4 @@ method: 'startLiveStreaming', | ||
}); | ||
}, | ||
stopLiveStreaming: function stopLiveStreaming() { | ||
}); | ||
_defineProperty(this, "stopLiveStreaming", function () { | ||
sendDataToIframe({ | ||
@@ -626,13 +676,135 @@ method: 'stopLiveStreaming', | ||
}); | ||
} | ||
}); | ||
}); | ||
var iframeApi = new IFrameApi(); | ||
// on: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => { | ||
// window.onmessage = (event: MessageEvent<any>) => { | ||
// if (event.data.eventData.event !== huddleEvent) return; | ||
// console.log('onmessage', event.data.eventData); | ||
// cb?.(); | ||
// }; | ||
// }, | ||
}; | ||
// const iframeApi = { | ||
// initialize: zodErrHandler(async (eventData: TClientConfig) => { | ||
// ClientConfigSchema.parse(eventData); | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'initialize', | ||
// eventData, | ||
// }); | ||
// }), | ||
// muteMic: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'muteMic', | ||
// }); | ||
// }, | ||
// unmuteMic: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'unmuteMic', | ||
// }); | ||
// }, | ||
// enableWebcam: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'enableWebcam', | ||
// }); | ||
// }, | ||
// disableWebcam: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'disableWebcam', | ||
// }); | ||
// }, | ||
// enableShare: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'enableShare', | ||
// }); | ||
// }, | ||
// disableShare: async () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'disableShare', | ||
// }); | ||
// }, | ||
// changeAvatarUrl: (avatarUrl: string) => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'changeAvatarUrl', | ||
// eventData: avatarUrl, | ||
// }); | ||
// }, | ||
// sendReaction: (reaction: TReaction) => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'sendReaction', | ||
// eventData: reaction, | ||
// }); | ||
// }, | ||
// lockRoom: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'lockRoom', | ||
// }); | ||
// }, | ||
// unlockRoom: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'unlockRoom', | ||
// }); | ||
// }, | ||
// connectWallet: (token: string) => { | ||
// const parsedJWT = parseJwt(token); | ||
// // console.log('connectWallet', { parsedJWT }); | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'connectWallet', | ||
// eventData: { token, parsedJWT }, | ||
// }); | ||
// }, | ||
// setTheme: (theme: IColorScheme) => { | ||
// sendDataToIframe({ | ||
// method: 'theme', | ||
// type: 'huddle01-iframe-from-parent', | ||
// eventData: theme, | ||
// }); | ||
// }, | ||
// startRecording: () => { | ||
// sendDataToIframe({ | ||
// method: 'startRecording', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// stopRecording: () => { | ||
// sendDataToIframe({ | ||
// method: 'stopRecording', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// startLiveStreaming: (eventData: TLivestreamInput) => { | ||
// sendDataToIframe({ | ||
// method: 'startLiveStreaming', | ||
// type: 'huddle01-iframe-from-parent', | ||
// eventData, | ||
// }); | ||
// }, | ||
// stopLiveStreaming: () => { | ||
// sendDataToIframe({ | ||
// method: 'stopLiveStreaming', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// // on: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => { | ||
// // window.onmessage = (event: MessageEvent<any>) => { | ||
// // if (event.data.eventData.event !== huddleEvent) return; | ||
// // console.log('onmessage', event.data.eventData); | ||
// // cb?.(); | ||
// // }; | ||
// // }, | ||
// }; | ||
var useEventListener = function useEventListener(huddleEvent, cb, dep) { | ||
@@ -639,0 +811,0 @@ React.useEffect(function () { |
@@ -346,2 +346,57 @@ 'use strict'; | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -467,4 +522,5 @@ _extends = Object.assign ? Object.assign.bind() : function (target) { | ||
}; | ||
var iframeApi = { | ||
initialize: zodErrHandler( /*#__PURE__*/function () { | ||
var IFrameApi = /*#__PURE__*/_createClass(function IFrameApi() { | ||
_classCallCheck(this, IFrameApi); | ||
_defineProperty(this, "initialize", zodErrHandler( /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventData) { | ||
@@ -489,4 +545,4 @@ return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
}; | ||
}()), | ||
muteMic: function muteMic() { | ||
}())); | ||
_defineProperty(this, "muteMic", function () { | ||
sendDataToIframe({ | ||
@@ -496,4 +552,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
unmuteMic: function unmuteMic() { | ||
}); | ||
_defineProperty(this, "unmuteMic", function () { | ||
sendDataToIframe({ | ||
@@ -503,4 +559,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
enableWebcam: function enableWebcam() { | ||
}); | ||
_defineProperty(this, "enableWebcam", function () { | ||
sendDataToIframe({ | ||
@@ -510,4 +566,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
disableWebcam: function disableWebcam() { | ||
}); | ||
_defineProperty(this, "disableWebcam", function () { | ||
sendDataToIframe({ | ||
@@ -517,4 +573,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
enableShare: function enableShare() { | ||
}); | ||
_defineProperty(this, "enableShare", function () { | ||
sendDataToIframe({ | ||
@@ -524,24 +580,18 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
disableShare: function () { | ||
var _disableShare = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
sendDataToIframe({ | ||
type: 'huddle01-iframe-from-parent', | ||
method: 'disableShare' | ||
}); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
function disableShare() { | ||
return _disableShare.apply(this, arguments); | ||
} | ||
return disableShare; | ||
}(), | ||
changeAvatarUrl: function changeAvatarUrl(avatarUrl) { | ||
}); | ||
_defineProperty(this, "disableShare", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
sendDataToIframe({ | ||
type: 'huddle01-iframe-from-parent', | ||
method: 'disableShare' | ||
}); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
}))); | ||
_defineProperty(this, "changeAvatarUrl", function (avatarUrl) { | ||
sendDataToIframe({ | ||
@@ -552,4 +602,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
sendReaction: function sendReaction(reaction) { | ||
}); | ||
_defineProperty(this, "sendReaction", function (reaction) { | ||
sendDataToIframe({ | ||
@@ -560,4 +610,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
lockRoom: function lockRoom() { | ||
}); | ||
_defineProperty(this, "lockRoom", function () { | ||
sendDataToIframe({ | ||
@@ -567,4 +617,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
unlockRoom: function unlockRoom() { | ||
}); | ||
_defineProperty(this, "unlockRoom", function () { | ||
sendDataToIframe({ | ||
@@ -574,4 +624,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
connectWallet: function connectWallet(token) { | ||
}); | ||
_defineProperty(this, "connectWallet", function (token) { | ||
var parsedJWT = parseJwt(token); | ||
@@ -589,4 +639,4 @@ | ||
}); | ||
}, | ||
setTheme: function setTheme(theme) { | ||
}); | ||
_defineProperty(this, "setTheme", function (theme) { | ||
sendDataToIframe({ | ||
@@ -597,4 +647,4 @@ method: 'theme', | ||
}); | ||
}, | ||
startRecording: function startRecording() { | ||
}); | ||
_defineProperty(this, "startRecording", function () { | ||
sendDataToIframe({ | ||
@@ -604,4 +654,4 @@ method: 'startRecording', | ||
}); | ||
}, | ||
stopRecording: function stopRecording() { | ||
}); | ||
_defineProperty(this, "stopRecording", function () { | ||
sendDataToIframe({ | ||
@@ -611,4 +661,4 @@ method: 'stopRecording', | ||
}); | ||
}, | ||
startLiveStreaming: function startLiveStreaming(eventData) { | ||
}); | ||
_defineProperty(this, "startLiveStreaming", function (eventData) { | ||
sendDataToIframe({ | ||
@@ -619,4 +669,4 @@ method: 'startLiveStreaming', | ||
}); | ||
}, | ||
stopLiveStreaming: function stopLiveStreaming() { | ||
}); | ||
_defineProperty(this, "stopLiveStreaming", function () { | ||
sendDataToIframe({ | ||
@@ -626,13 +676,135 @@ method: 'stopLiveStreaming', | ||
}); | ||
} | ||
}); | ||
}); | ||
var iframeApi = new IFrameApi(); | ||
// on: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => { | ||
// window.onmessage = (event: MessageEvent<any>) => { | ||
// if (event.data.eventData.event !== huddleEvent) return; | ||
// console.log('onmessage', event.data.eventData); | ||
// cb?.(); | ||
// }; | ||
// }, | ||
}; | ||
// const iframeApi = { | ||
// initialize: zodErrHandler(async (eventData: TClientConfig) => { | ||
// ClientConfigSchema.parse(eventData); | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'initialize', | ||
// eventData, | ||
// }); | ||
// }), | ||
// muteMic: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'muteMic', | ||
// }); | ||
// }, | ||
// unmuteMic: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'unmuteMic', | ||
// }); | ||
// }, | ||
// enableWebcam: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'enableWebcam', | ||
// }); | ||
// }, | ||
// disableWebcam: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'disableWebcam', | ||
// }); | ||
// }, | ||
// enableShare: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'enableShare', | ||
// }); | ||
// }, | ||
// disableShare: async () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'disableShare', | ||
// }); | ||
// }, | ||
// changeAvatarUrl: (avatarUrl: string) => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'changeAvatarUrl', | ||
// eventData: avatarUrl, | ||
// }); | ||
// }, | ||
// sendReaction: (reaction: TReaction) => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'sendReaction', | ||
// eventData: reaction, | ||
// }); | ||
// }, | ||
// lockRoom: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'lockRoom', | ||
// }); | ||
// }, | ||
// unlockRoom: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'unlockRoom', | ||
// }); | ||
// }, | ||
// connectWallet: (token: string) => { | ||
// const parsedJWT = parseJwt(token); | ||
// // console.log('connectWallet', { parsedJWT }); | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'connectWallet', | ||
// eventData: { token, parsedJWT }, | ||
// }); | ||
// }, | ||
// setTheme: (theme: IColorScheme) => { | ||
// sendDataToIframe({ | ||
// method: 'theme', | ||
// type: 'huddle01-iframe-from-parent', | ||
// eventData: theme, | ||
// }); | ||
// }, | ||
// startRecording: () => { | ||
// sendDataToIframe({ | ||
// method: 'startRecording', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// stopRecording: () => { | ||
// sendDataToIframe({ | ||
// method: 'stopRecording', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// startLiveStreaming: (eventData: TLivestreamInput) => { | ||
// sendDataToIframe({ | ||
// method: 'startLiveStreaming', | ||
// type: 'huddle01-iframe-from-parent', | ||
// eventData, | ||
// }); | ||
// }, | ||
// stopLiveStreaming: () => { | ||
// sendDataToIframe({ | ||
// method: 'stopLiveStreaming', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// // on: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => { | ||
// // window.onmessage = (event: MessageEvent<any>) => { | ||
// // if (event.data.eventData.event !== huddleEvent) return; | ||
// // console.log('onmessage', event.data.eventData); | ||
// // cb?.(); | ||
// // }; | ||
// // }, | ||
// }; | ||
var useEventListener = function useEventListener(huddleEvent, cb, dep) { | ||
@@ -639,0 +811,0 @@ React.useEffect(function () { |
@@ -338,2 +338,57 @@ import React, { useEffect } from 'react'; | ||
function _toPrimitive(input, hint) { | ||
if (typeof input !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (typeof res !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return typeof key === "symbol" ? key : String(key); | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperty(obj, key, value) { | ||
key = _toPropertyKey(key); | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _extends() { | ||
@@ -459,4 +514,5 @@ _extends = Object.assign ? Object.assign.bind() : function (target) { | ||
}; | ||
var iframeApi = { | ||
initialize: zodErrHandler( /*#__PURE__*/function () { | ||
var IFrameApi = /*#__PURE__*/_createClass(function IFrameApi() { | ||
_classCallCheck(this, IFrameApi); | ||
_defineProperty(this, "initialize", zodErrHandler( /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventData) { | ||
@@ -481,4 +537,4 @@ return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
}; | ||
}()), | ||
muteMic: function muteMic() { | ||
}())); | ||
_defineProperty(this, "muteMic", function () { | ||
sendDataToIframe({ | ||
@@ -488,4 +544,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
unmuteMic: function unmuteMic() { | ||
}); | ||
_defineProperty(this, "unmuteMic", function () { | ||
sendDataToIframe({ | ||
@@ -495,4 +551,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
enableWebcam: function enableWebcam() { | ||
}); | ||
_defineProperty(this, "enableWebcam", function () { | ||
sendDataToIframe({ | ||
@@ -502,4 +558,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
disableWebcam: function disableWebcam() { | ||
}); | ||
_defineProperty(this, "disableWebcam", function () { | ||
sendDataToIframe({ | ||
@@ -509,4 +565,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
enableShare: function enableShare() { | ||
}); | ||
_defineProperty(this, "enableShare", function () { | ||
sendDataToIframe({ | ||
@@ -516,24 +572,18 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
disableShare: function () { | ||
var _disableShare = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
sendDataToIframe({ | ||
type: 'huddle01-iframe-from-parent', | ||
method: 'disableShare' | ||
}); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
})); | ||
function disableShare() { | ||
return _disableShare.apply(this, arguments); | ||
} | ||
return disableShare; | ||
}(), | ||
changeAvatarUrl: function changeAvatarUrl(avatarUrl) { | ||
}); | ||
_defineProperty(this, "disableShare", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
sendDataToIframe({ | ||
type: 'huddle01-iframe-from-parent', | ||
method: 'disableShare' | ||
}); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
}))); | ||
_defineProperty(this, "changeAvatarUrl", function (avatarUrl) { | ||
sendDataToIframe({ | ||
@@ -544,4 +594,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
sendReaction: function sendReaction(reaction) { | ||
}); | ||
_defineProperty(this, "sendReaction", function (reaction) { | ||
sendDataToIframe({ | ||
@@ -552,4 +602,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
lockRoom: function lockRoom() { | ||
}); | ||
_defineProperty(this, "lockRoom", function () { | ||
sendDataToIframe({ | ||
@@ -559,4 +609,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
unlockRoom: function unlockRoom() { | ||
}); | ||
_defineProperty(this, "unlockRoom", function () { | ||
sendDataToIframe({ | ||
@@ -566,4 +616,4 @@ type: 'huddle01-iframe-from-parent', | ||
}); | ||
}, | ||
connectWallet: function connectWallet(token) { | ||
}); | ||
_defineProperty(this, "connectWallet", function (token) { | ||
var parsedJWT = parseJwt(token); | ||
@@ -581,4 +631,4 @@ | ||
}); | ||
}, | ||
setTheme: function setTheme(theme) { | ||
}); | ||
_defineProperty(this, "setTheme", function (theme) { | ||
sendDataToIframe({ | ||
@@ -589,4 +639,4 @@ method: 'theme', | ||
}); | ||
}, | ||
startRecording: function startRecording() { | ||
}); | ||
_defineProperty(this, "startRecording", function () { | ||
sendDataToIframe({ | ||
@@ -596,4 +646,4 @@ method: 'startRecording', | ||
}); | ||
}, | ||
stopRecording: function stopRecording() { | ||
}); | ||
_defineProperty(this, "stopRecording", function () { | ||
sendDataToIframe({ | ||
@@ -603,4 +653,4 @@ method: 'stopRecording', | ||
}); | ||
}, | ||
startLiveStreaming: function startLiveStreaming(eventData) { | ||
}); | ||
_defineProperty(this, "startLiveStreaming", function (eventData) { | ||
sendDataToIframe({ | ||
@@ -611,4 +661,4 @@ method: 'startLiveStreaming', | ||
}); | ||
}, | ||
stopLiveStreaming: function stopLiveStreaming() { | ||
}); | ||
_defineProperty(this, "stopLiveStreaming", function () { | ||
sendDataToIframe({ | ||
@@ -618,13 +668,135 @@ method: 'stopLiveStreaming', | ||
}); | ||
} | ||
}); | ||
}); | ||
var iframeApi = new IFrameApi(); | ||
// on: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => { | ||
// window.onmessage = (event: MessageEvent<any>) => { | ||
// if (event.data.eventData.event !== huddleEvent) return; | ||
// console.log('onmessage', event.data.eventData); | ||
// cb?.(); | ||
// }; | ||
// }, | ||
}; | ||
// const iframeApi = { | ||
// initialize: zodErrHandler(async (eventData: TClientConfig) => { | ||
// ClientConfigSchema.parse(eventData); | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'initialize', | ||
// eventData, | ||
// }); | ||
// }), | ||
// muteMic: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'muteMic', | ||
// }); | ||
// }, | ||
// unmuteMic: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'unmuteMic', | ||
// }); | ||
// }, | ||
// enableWebcam: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'enableWebcam', | ||
// }); | ||
// }, | ||
// disableWebcam: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'disableWebcam', | ||
// }); | ||
// }, | ||
// enableShare: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'enableShare', | ||
// }); | ||
// }, | ||
// disableShare: async () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'disableShare', | ||
// }); | ||
// }, | ||
// changeAvatarUrl: (avatarUrl: string) => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'changeAvatarUrl', | ||
// eventData: avatarUrl, | ||
// }); | ||
// }, | ||
// sendReaction: (reaction: TReaction) => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'sendReaction', | ||
// eventData: reaction, | ||
// }); | ||
// }, | ||
// lockRoom: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'lockRoom', | ||
// }); | ||
// }, | ||
// unlockRoom: () => { | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'unlockRoom', | ||
// }); | ||
// }, | ||
// connectWallet: (token: string) => { | ||
// const parsedJWT = parseJwt(token); | ||
// // console.log('connectWallet', { parsedJWT }); | ||
// sendDataToIframe({ | ||
// type: 'huddle01-iframe-from-parent', | ||
// method: 'connectWallet', | ||
// eventData: { token, parsedJWT }, | ||
// }); | ||
// }, | ||
// setTheme: (theme: IColorScheme) => { | ||
// sendDataToIframe({ | ||
// method: 'theme', | ||
// type: 'huddle01-iframe-from-parent', | ||
// eventData: theme, | ||
// }); | ||
// }, | ||
// startRecording: () => { | ||
// sendDataToIframe({ | ||
// method: 'startRecording', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// stopRecording: () => { | ||
// sendDataToIframe({ | ||
// method: 'stopRecording', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// startLiveStreaming: (eventData: TLivestreamInput) => { | ||
// sendDataToIframe({ | ||
// method: 'startLiveStreaming', | ||
// type: 'huddle01-iframe-from-parent', | ||
// eventData, | ||
// }); | ||
// }, | ||
// stopLiveStreaming: () => { | ||
// sendDataToIframe({ | ||
// method: 'stopLiveStreaming', | ||
// type: 'huddle01-iframe-from-parent', | ||
// }); | ||
// }, | ||
// // on: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => { | ||
// // window.onmessage = (event: MessageEvent<any>) => { | ||
// // if (event.data.eventData.event !== huddleEvent) return; | ||
// // console.log('onmessage', event.data.eventData); | ||
// // cb?.(); | ||
// // }; | ||
// // }, | ||
// }; | ||
var useEventListener = function useEventListener(huddleEvent, cb, dep) { | ||
@@ -631,0 +803,0 @@ useEffect(function () { |
{ | ||
"name": "@huddle01/iframe", | ||
"version": "0.0.13-dev.0", | ||
"version": "0.0.13-dev.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/huddle01-iframe.cjs.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
687352
3249