Skip to content

Instantly share code, notes, and snippets.

@teramako
Created January 28, 2010 05:22
Show Gist options
  • Save teramako/288460 to your computer and use it in GitHub Desktop.
Save teramako/288460 to your computer and use it in GitHub Desktop.
reboot/jetpack に関するメモ

Labs/Jetpack/Reboot に関してメモ

  • main.js には Components は使えない
    Error: Permission denied for moz-nullprincipal:{8d6c05eb-fc08-436a-adaa-f440a732c337} to get property XPCComponents.classes
  • まだ全容がつかめない

About manifest.json

{
  "mainScript": { // used "main.js"'s contents and filename if omitted
    "contents": "script content",
    "filename": "file url" //optional for debugging
  }, // これなんでこんな設計?
  "lib": ["path","to","lib","dir"],
  "capabilities": {
    "moduleName": ["params"]
  }
}

About "capabilities" written in manifest.json

  • 参照: jpx
  • jetpack-cap-factory-name.js の name を書くっぽい
  • 書いておくと、jsのグローバルオブジェクトとして name が使える。
  • たぶん、これ経由でないと XPCOM を使ったモジュールは使えないと思われる

sample

  • manifest.json { "capabilities": { "notifications": {} } }
  • main.js notifications.show("Hello World");

How to write

  • 参照: cfx
    • cfxと呼ばれるパッケージをしないといけないと思われる。
    • _exports_オブジェクトに describe, create を書く?
    • Components系が使える

sample

hoge.js exports.describe = function describe() "hoge description"; exports.create = function create(jetpack, params){ return { hello: function(){}, } }

require method

  • JavaScriptモジュールみたいな感じで、ファイルをロードできるのかな?

  • Feature からの場合は、manifest.json に lib プロパティを加えて、そのディレクトリないにファイルを配置

  • Components系が使えるかは呼び出し元のコンテキストによると思われる

    • Featureから呼び出す場合は、Componentsは使えない

    var windowUtils = require("window-utils");

How to write

これも exports オブジェクトがそのまま返り値となる感じ?

exports = {
  hogeProperty: "hello",
  hogeMethod: function() "world"
}

vim: sw=4 ts=4 et:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment