Index: gc_core/js/helpers.js ================================================================== --- gc_core/js/helpers.js +++ gc_core/js/helpers.js @@ -5,24 +5,24 @@ // In Firefox, there is no console.log in PromiseWorker, but there is worker.log. // In Thunderbird, you can’t access to console directly. So it’s required to pass a log function. let funcOutput = null; -export function setLogOutput (func) { +function setLogOutput (func) { funcOutput = func; } -export function echo (obj) { +function echo (obj) { if (funcOutput !== null) { funcOutput(obj); } else { console.log(obj); } return true; } -export function logerror (e, bStack=false) { +function logerror (e, bStack=false) { let sMsg = "\n" + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message; if (bStack) { sMsg += "\n--- Stack ---\n" + e.stack; } if (funcOutput !== null) { @@ -34,11 +34,11 @@ // load ressources in workers (suggested by Mozilla extensions reviewers) // for more options have a look here: https://gist.github.com/Noitidart/ec1e6b9a593ec7e3efed // if not in workers, use sdk/data.load() instead -export function loadFile (spf) { +function loadFile (spf) { try { let xRequest; if (typeof XMLHttpRequest !== "undefined") { xRequest = new XMLHttpRequest(); } @@ -58,21 +58,32 @@ } } // conversions -export function objectToMap (obj) { +function objectToMap (obj) { let m = new Map(); for (let param in obj) { //console.log(param + " " + obj[param]); m.set(param, obj[param]); } return m; } -export function mapToObject (m) { +function mapToObject (m) { let obj = {}; for (let [k, v] of m) { obj[k] = v; } return obj; } + +if (typeof(exports) !== 'undefined') { + // Used for Grammalecte library. + // In content scripts, these variable are directly reachable + exports.setLogOutput = setLogOutput; + exports.echo = echo; + exports.logerror = logerror; + exports.loadFile = loadFile; + exports.objectToMap = objectToMap; + exports.mapToObject = mapToObject; +} Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -29,11 +29,14 @@ # Firefox fx_identifier = French-GC@grammalecte.net fx_name = Grammalecte [fr] +fx_standard_path = C:\Program Files\Mozilla Firefox\firefox.exe +fx_beta_path = C:\Program Files\Mozilla Firefox Beta\firefox.exe fx_nightly_path = C:\Program Files (x86)\Nightly\firefox.exe + # Thunderbird tb_identifier = French-GC-TB@grammalecte.net tb_name = Grammalecte [fr] tb_debug_extension_path = _build/tb-debug.profile/extensions/French-GC-TB@grammalecte.net Index: gc_lang/fr/webext/gce_worker.js ================================================================== --- gc_lang/fr/webext/gce_worker.js +++ gc_lang/fr/webext/gce_worker.js @@ -1,16 +1,25 @@ -/* -import { echo } from "mymodule"; + +/* try { - echo("It works! At last!"); + console.log("BEFORE"); + //var myhelpers = require('./grammalecte/helpers.js'); + require(['./grammalecte/helpers.js'], function (foo) { + console.log("LOADING"); + echo("MODULE LOADED2"); + }); + console.log("AFTER"); } catch (e) { + console.log("\n" + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); console.error(e); -} -*/ -"use strict"; +}*/ + +echo("VA TE FAIRE FOUTRE"); + + let gce = null; // module: grammar checker engine let text = null; let tkz = null; // module: tokenizer let lxg = null; // module: lexicographer @@ -125,11 +134,6 @@ sendResponse({response: "response from background script"}); } browser.runtime.onMessage.addListener(handleMessage); -try { - loadGrammarChecker(); -} -catch (e) { - console.error(e); -} + Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -28,11 +28,11 @@ "default_popup": "panel/main.html", "default_title": "Grammalecte [fr]", "browser_style": false }, "background": { - "scripts": ["gce_worker.js"] + "scripts": ["require.js", "grammalecte/helpers.js", "gce_worker.js"] }, "web_accessible_resources": [ "beasts/frog.jpg", "beasts/turtle.jpg", "beasts/snake.jpg" Index: make.py ================================================================== --- make.py +++ make.py @@ -352,11 +352,11 @@ with helpers.cd("_build/xpi/"+sLang): os.system("jpm run -b nightly") if xArgs.web_ext: with helpers.cd("_build/webext/"+sLang): - os.system(r'web-ext run --firefox="' + dVars['fx_nightly_path'] + '" --browser-console') + os.system(r'web-ext run --firefox="' + dVars['fx_beta_path'] + '" --browser-console') # Thunderbird if xArgs.thunderbird: os.system("thunderbird -jsconsole -P debug") else: