From MozillaWiki
Jump to: navigation, search


There is some shared stuff that is accessible to apps if they want it:

How Things Work


When you build a profile without specifying DEBUG=1, build/webapp-zip.js is run and it recursively scans the directory sub-tree of your webapp, running a regex for files in "shared/" against all "js", "html", "html", and "css" files it finds. It then processes these paths based on the second-level sub-directory of shared as follows:

  • "js": Found files (ex: shared/js/NAME.js) are copied over, and an error is thrown if they do not exist.
  • "locales": shared/locales/NAME.ini and the contents of the shared/locales/NAME/ sub-directory tree are copied over.
  • "style": shared/style/NAME.css and the contents of the shared/style/NAME/ sub-directory tree except for any html files are copied over.


When you build a profile and specify DEBUG=1, b2g-desktop is run with httpd.js and it has special hackjob magic to try and do the right thing when it sees "shared" in the path.

How to Use shared stuff

Just reference it in your files, and the above magic will make the right thing happen. Probably.

What Is Available

JS (js/)

  • API's that should get uplifted to Web API's:
  • l10n.js - The localization API used by all gaia apps.
  • l10n_date.js builds on l10n.js to provide something akin to Intl.DateTimeFormat that allows for localized pretty date formatting, see the file for more info.
  • Helper Libraries (not currently expected to be uplifted to Web API's)
    • gesture_detector.js provides higher level touch events than provided by the DOM by using a state machine.
    • mediadb.js is "a simple interface to DeviceStorage and IndexedDB." The Gallery, Music, and Videos apps all use this since they have a lot in common.
  • workarounds until platform features are implemented:
  • shims
    • desktop.js - shims for mozTelephony and device buttons that don't exist on the desktop.

styles (style/)

There is an effort to create standardized HTML/CSS code for consistent UI across the built-in Gaia apps. This is known as the Gaia UI Building Blocks effort, and that repo is where things are being standardized via pull requests. Once they are standardized, they end up in the style/ directory here.

locales (locales/)

This currently just exists to support the l10n_date.js logic above, but maybe it will exist for other purposes in the future too?

elements (elements/)

This directory contains a set of the web components used around gaia.

Read gaia components page for detail