Jetpack/FAQ: Difference between revisions

107 bytes removed ,  15 February 2012
Line 217: Line 217:
'''Can I use other CommonJS modules like node.js in my add-on? '''  
'''Can I use other CommonJS modules like node.js in my add-on? '''  


Not yet, although we plan to add this ability as soon as we can.  
Not yet, although we plan to add this ability.  


'''Can I use Add-on SDK / Add-on Builder modules in a traditional XUL extension? '''  
'''Can I use Add-on SDK / Add-on Builder modules in a traditional XUL extension? '''  


Not at the moment, although we hope to support this soon.  
Not yet, although we plan to add this ability.


'''Is there a Socket API in the Add-on SDK? '''  
'''Is there a Socket API in the Add-on SDK? '''  
Line 229: Line 229:
'''What's the local path on disk for my add-on's data directory? '''  
'''What's the local path on disk for my add-on's data directory? '''  


Although the data directory does currently map to a directory on your disk, it's best not to assume that this will continue to be the case. We're planning to stop unpacking .xpis pretty soon (not before 1.0, but soon afterwards, see [https://bugzilla.mozilla.org/show_bug.cgi?id=638742 bug 638742] for details), which means there won't even be a ""local path"" for files in the data/ directory. They'll be inside a ZIP file with an .xpi extension.
The add-on's <code>data</code> directory does not map to a particular location on disk. The <code>require("self").data.url(name)</code> function will give you a URL that's usable from within the addon itself (e.g. as a content script).
 
The <code>require("self").data.url(name)</code> function will give you a URL that's usable from within the addon itself (e.g. as a content-script), but that involves a mapping function that goes from URLs to resources, and those resources don't have to be real files on disk.  


'''How can I read from/write to a file? '''  
'''How can I read from/write to a file? '''  


You can use the file module in api-utils. However, if you just need some persistent storage and don't need the data to be available outside your add-on, you can use the simple-storage module in addon-kit.  
You can use the [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/docs/file.html <code>file</code>] module. However, if you just need some persistent storage and don't need the data to be available outside your add-on, you can use the [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/docs/simple-storage.html <code>simple-storage</code> module.  


'''How can I access data from my add-on's 'package.json' file, such as my add-on's name or version number? '''  
'''How can I access data from my add-on's 'package.json' file, such as my add-on's name or version number? '''  


At the moment there isn't a properly supported way to do this.  
Use the [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/docs/self.html <code>self</code> module.


'''How can I debug my add-on? '''  
'''How can I debug my add-on? '''  
Line 252: Line 250:
'''How can I localize strings appearing in my add-on? '''
'''How can I localize strings appearing in my add-on? '''


At the moment the Add-on SDK does not support localization of strings appearing in your add-on. This is something we're planning to add in a future release.
The 1.5 release of the SDK delivers the first stage of support for localization. See the [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/l10n.html tutorial]. Note that at the moment you can only localize strings appearing in code, not strings inside HTML content.
canmove, Confirmed users
737

edits