Skip to content
padolsey edited this page Jun 27, 2012 · 1 revision

Here we outline the structure and terminology of bonsaiJS.

Terminology

  • Bootstrapper: The general name given to the code that initiates the RendererController and the RunnerContext, enabling them to communicate.
  • Player: The exposed API on the parent page. It will initiate the RendererController, which will, in turn, initiate the relevant RunnerContext (iframe or worker).
  • RunnerContext: The context where the runner runs. The RunnerContext creates this context. This is either an iframe or a worker.
  • [part of RunnerContext] RunnerContext creator: Creates the context. E.g. creates an <iframe>.
  • [part of RunnerContext] RunnerContext bootstrap: Initiating logic within context. Provides way to load files/scripts/sub-movies within the context.
  • RendererController: Initiates and controls the RunnerContext and the Renderer.
  • Renderer: The actual renderer. E.g. the SVG renderer.
  • Runner: The actual runner, i.e. the bonsai stage and the bonsai API. The runner is what runs the actual movie file(s).

Responsibilities

_dev/build loaders

  • [Name needs to be decided -- it's currently confusing]
  • This file is loaded in the parent page and within the context (iframe/window)
  • It provides IF branches for dealing with each of those environments. In the parent env it sets up the player and requests RunnerContext-creation script (in dev mode). In the context env it requires the relevant RunnerContext bootstrap file and runs it.

RunnerContext creator

  • Must provide init and destroy methods
  • Must provide load method (accepting url parameter for loading movie/plugin scripts): This method should fire a loadScript message to the accompanying bootstrap.
  • Must provide run method (accepting code parameter for running inline movie/plugin code): This method should fire a runScript message to the accompanying bootstrap.

RendererController

  • Initiates [but does not instantiate] the RunnerContext
  • Responsible for passing messages between the renderer and the runner context. It acts as a proxy between:
  • AssetController <-> Renderer
  • RunnerContext <-> Renderer

RunnerContext bootstrap

  • Module must be a function: called by _dev/_build iframe/worker
  • Must instantiate a Stage
  • Must provide stageInstance.loadSubMovie
  • Must listen for and process runScript message
  • Must listen for and process loadScript message [synchronous -- order is relevant]

Directory Structure

bonsai/
  src/
    asset/           (asset loaders/handlers used between Runner and Renderer)
    bootstrapper/    (files related to bootstrapping, i.e. context creators/bootstrap)
    renderer/        (files related to the renderers)
      svg/
    runner/          (the actual runner -- Bonsai API)
    *                (misc. files used in more than one place)