Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .babelrc

This file was deleted.

39 changes: 0 additions & 39 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in the repo.
* @902seanryan @aberkie @deycorinne
* @pbs/springroll-game-reviewers
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
docs
components
node_modules
*.log
*.log
# OSX
.DS_Store
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
tabWidth: 2,
useTabs: false,
proseWrap: 'preserve',
parser: 'babel',
parser: 'typescript',
printWidth: 80,
arrowParens: 'avoid'
};
35 changes: 0 additions & 35 deletions Bellhop.d.ts

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.0.0] - 2026-07-10

### Changed

- Converted Bellhop project to Typescript [ticket](https://pbskids.atlassian.net/browse/SR-38)

## [3.6.0] - 2024-10-25

### Changed
Expand Down
101 changes: 101 additions & 0 deletions dist/Bellhop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { BellhopEventDispatcher, BellhopEvent } from './BellhopEventDispatcher';
type DebugCallback = (opts: {
isChild: boolean;
received: boolean;
message: unknown;
}) => void;
type RespondData = object | string | number | boolean | (() => unknown) | (() => Promise<unknown>);
/**
* Abstract communication layer between the iframe
* and the parent DOM
*/
export declare class Bellhop extends BellhopEventDispatcher {
/** The instance ID for bellhop */
id: string;
/** If we are connected to another instance of bellhop */
connected: boolean;
/** If this instance represents an iframe instance */
isChild: boolean;
/** If we are currently trying to connect */
connecting: boolean;
/** If debug mode is turned on */
debug: boolean | DebugCallback;
/** If using cross-domain, the domain to post to */
origin: string | null;
/** If the current environment supports the connection */
supported: boolean;
/** Save any sends to wait until after we're done connecting */
_sendLater: Array<{
type: string;
data: unknown;
}>;
/** The iframe element */
iframe: HTMLIFrameElement | null;
/**
* Handle messages in the window
* @param message the post message received from another bellhop instance
*/
receive: (message: MessageEvent) => void;
/**
* Creates an instance of Bellhop.
* @param id the id of the Bellhop instance
*/
constructor(id?: string | number);
/**
* Handle the initial connected message
* @param message the message received from the other bellhop instance
*/
private onConnectionReceived;
/**
* Setup the connection
* @param iframe The iframe to communicate with. If no value is set, the assumption
* is that we're the child trying to communicate with our window.parent
* @param origin The domain to communicate with if different from the current.
*/
connect(iframe?: HTMLIFrameElement, origin?: string): void;
/**
* Disconnect if there are any open connections
*/
disconnect(): void;
/**
* Send an event to the connected instance
* @param type name/type of the event
* @param data Additional data to send along with event
*/
send(type: string, data?: unknown): void;
/**
* A convenience method for sending and listening to create
* a singular link for fetching data. This is the same as calling send
* and then getting a response right away with the same event.
* @param event The name of the event
* @param callback The callback to call after, takes event object as one argument
* @param data Optional data to pass along
* @param runOnce If we only want to fetch once and then remove the listener
*/
fetch(event: string, callback: (e: BellhopEvent) => void, data?: unknown, runOnce?: boolean): void;
/**
* A convenience method for listening to an event and then responding with some data
* right away. Automatically removes the listener
* @param event The name of the event
* @param data The object to pass back.
* May also be a function; the return value (or resolved value) will be sent as data in this case.
* @param runOnce If we only want to respond once and then remove the listener
*/
respond(event: string, data?: RespondData, runOnce?: boolean): void;
/**
* Send either the default log message or the callback provided if debug
* is enabled
*/
logDebugMessage(received: boolean | undefined, message: unknown): void;
/**
* Destroy and don't use after this
*/
destroy(): void;
/**
* Returns the correct parent element for Bellhop's context
* @readonly
*/
get target(): Window | null;
}
export {};
//# sourceMappingURL=Bellhop.d.ts.map
1 change: 1 addition & 0 deletions dist/Bellhop.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/Bellhop.spec.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=Bellhop.spec.d.ts.map
1 change: 1 addition & 0 deletions dist/Bellhop.spec.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions dist/BellhopEventDispatcher.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export interface BellhopEvent {
type: string;
data: unknown;
}
/**
* Generic event dispatcher
*/
export declare class BellhopEventDispatcher {
/** The collection of event listeners keyed by event name */
private _listeners;
constructor();
/**
* Add an event listener to listen to an event from either the parent or iframe
* @param name The name of the event to listen for
* @param callback The handler when an event is triggered
* @param priority The priority of the event listener. Higher numbers are handled first.
*/
on(name: string, callback: (event: BellhopEvent) => void, priority?: number): void;
/**
* Sorts listeners added by .on() by priority
*/
private listenerSorter;
/**
* Remove an event listener
* @param name The name of event to listen for. If callback is undefined, remove all listeners for this name.
* @param callback The optional handler when an event is triggered, if no callback
* is set then all listeners by type are removed
*/
off(name: string, callback?: (event: BellhopEvent) => void): void;
/**
* Trigger any event handlers for an event type
* @param event The event to send
* @param data optional data to send to other areas in the app that are listening for this event
*/
trigger(event: BellhopEvent | string, data?: unknown): void;
/**
* Reset the listeners object
*/
destroy(): void;
}
//# sourceMappingURL=BellhopEventDispatcher.d.ts.map
1 change: 1 addition & 0 deletions dist/BellhopEventDispatcher.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading