Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@huddle01/iframe

Package Overview
Dependencies
Maintainers
5
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@huddle01/iframe - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/huddle01-iframe.cjs.d.ts

9

dist/declarations/src/index.d.ts
import HuddleIframe from './components/HuddleIframe';
declare const api: {
initialize: (data: {
export type THuddleEvents = 'lobby:joined' | 'lobby:failed' | 'room:joined' | 'room:failed' | 'room:new-peer' | 'room:peer-left' | 'room:recording-started' | 'room:recording-stopped' | 'room:livestream-started' | 'room:livestream-stopped';
declare const huddleIframe: {
initialize: (eventData: {
background?: string | undefined;
gradientAndMesh?: boolean | undefined;
wallets?: ("*" | "metamask" | "walletconnect" | "keplr" | "templewallet" | "lens" | "ud" | "cyberconnect" | "phantom")[] | undefined;
}) => Promise<void>;

@@ -14,2 +16,3 @@ muteMic: () => void;

};
export { HuddleIframe, api };
declare const useEventListner: (huddleEvent: THuddleEvents, cb: (data?: any) => void) => void;
export { HuddleIframe, huddleIframe, useEventListner };
import { z } from 'zod';
export declare const AllowedWallets: {
readonly all: "*";
readonly injected: "metamask";
readonly walletconnect: "walletconnect";
readonly keplr: "keplr";
readonly templewallet: "templewallet";
readonly lens: "lens";
readonly ud: "ud";
readonly cyberconnect: "cyberconnect";
};
export declare const ClientConfigSchema: z.ZodObject<{
background: z.ZodOptional<z.ZodString>;
gradientAndMesh: z.ZodOptional<z.ZodBoolean>;
wallets: z.ZodOptional<z.ZodArray<z.ZodEnum<["*", "metamask", "walletconnect", "keplr", "templewallet", "lens", "ud", "cyberconnect", "phantom"]>, "many">>;
}, "strip", z.ZodTypeAny, {
background?: string | undefined;
gradientAndMesh?: boolean | undefined;
wallets?: ("*" | "metamask" | "walletconnect" | "keplr" | "templewallet" | "lens" | "ud" | "cyberconnect" | "phantom")[] | undefined;
}, {
background?: string | undefined;
gradientAndMesh?: boolean | undefined;
wallets?: ("*" | "metamask" | "walletconnect" | "keplr" | "templewallet" | "lens" | "ud" | "cyberconnect" | "phantom")[] | undefined;
}>;
export type TClientConfig = z.infer<typeof ClientConfigSchema>;

@@ -5,6 +5,6 @@ import { api } from '..';

method: keyof typeof api;
data?: any;
eventData?: any;
}
export declare const sendDataToIframe: (data: IData) => void;
export declare const sendDataToIframe: (eventData: IData) => void;
export declare const zodErrHandler: <T extends any[], U>(func: (...args: T) => PromiseLike<U>) => (...args: T) => Promise<U>;
export {};
{
"name": "@huddle01/iframe",
"version": "0.0.1",
"version": "0.0.2",
"description": "",
"main": "dist/iframe.cjs.js",
"main": "dist/huddle01-iframe.cjs.js",
"scripts": {

@@ -7,0 +7,0 @@ "fix": "pnpm preconstruct fix",

@@ -0,1 +1,3 @@

import { useEffect } from 'react';
import HuddleIframe from './components/HuddleIframe';

@@ -5,7 +7,19 @@ import { ClientConfigSchema, TClientConfig } from './types';

const api = {
initialize: zodErrHandler(async (data: TClientConfig) => {
export type THuddleEvents =
| 'lobby:joined'
| 'lobby:failed'
| 'room:joined'
| 'room:failed'
| 'room:new-peer'
| 'room:peer-left'
| 'room:recording-started'
| 'room:recording-stopped'
| 'room:livestream-started'
| 'room:livestream-stopped';
const huddleIframe = {
initialize: zodErrHandler(async (eventData: TClientConfig) => {
console.log('initialize');
ClientConfigSchema.parse(data);
ClientConfigSchema.parse(eventData);

@@ -15,3 +29,3 @@ sendDataToIframe({

method: 'initialize',
data,
eventData,
});

@@ -55,4 +69,31 @@ }),

},
// 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?.();
// };
// },
};
export { HuddleIframe, api };
const useEventListner = (
huddleEvent: THuddleEvents,
cb: (data?: any) => void
) => {
useEffect(() => {
const handleIframe = (
event: MessageEvent<{ eventData: { data?: any; event: THuddleEvents } }>
) => {
if (!event || event?.data.eventData?.event !== huddleEvent) return;
cb(event.data.eventData.data);
};
window.addEventListener('message', handleIframe);
return () => {
window.removeEventListener('message', handleIframe);
};
}, []);
};
export { HuddleIframe, huddleIframe, useEventListner };
import { z } from 'zod';
export const AllowedWallets = {
all: '*',
injected: 'metamask',
walletconnect: 'walletconnect',
keplr: 'keplr',
templewallet: 'templewallet',
// or
lens: 'lens',
ud: 'ud',
cyberconnect: 'cyberconnect',
} as const;
export const ClientConfigSchema = z.object({
background: z.string().optional(),
gradientAndMesh: z.boolean().optional(),
wallets: z
.array(
z.enum([
'*',
'metamask',
'walletconnect',
'keplr',
'templewallet',
'lens',
'ud',
'cyberconnect',
'phantom',
])
)
.optional(),
});
export type TClientConfig = z.infer<typeof ClientConfigSchema>;

@@ -6,6 +6,6 @@ import { api } from '..';

method: keyof typeof api;
data?: any;
eventData?: any;
}
export const sendDataToIframe = (data: IData) => {
export const sendDataToIframe = (eventData: IData) => {
const huddleIframe: HTMLIFrameElement = document.getElementById(

@@ -15,3 +15,3 @@ 'huddle01-iframe'

if (huddleIframe?.contentWindow)
huddleIframe.contentWindow.postMessage(data || null, '*');
huddleIframe.contentWindow.postMessage(eventData || null, '*');
else console.log('huddleIframe is null');

@@ -18,0 +18,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc