ESMify some modules for m-c (bug 1824610)

This commit is contained in:
Calixte Denizet 2023-03-27 11:40:58 +02:00
parent 384bd96165
commit 5f5256b4c4
3 changed files with 12 additions and 20 deletions

View File

@ -13,10 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
"use strict"; export const PdfJsDefaultPreferences = Object.freeze(
var EXPORTED_SYMBOLS = ["PdfJsDefaultPreferences"];
var PdfJsDefaultPreferences = Object.freeze(
PDFJSDev.eval("DEFAULT_PREFERENCES") PDFJSDev.eval("DEFAULT_PREFERENCES")
); );

View File

@ -434,12 +434,15 @@ function createSandboxExternal(defines) {
saveComments: false, saveComments: false,
defines, defines,
}; };
return gulp.src("./src/pdf.sandbox.external.js").pipe( return gulp
transform("utf8", content => { .src("./src/pdf.sandbox.external.js")
content = preprocessor2.preprocessPDFJSCode(ctx, content); .pipe(rename("pdf.sandbox.external.sys.mjs"))
return `${licenseHeader}\n${content}`; .pipe(
}) transform("utf8", content => {
); content = preprocessor2.preprocessPDFJSCode(ctx, content);
return `${licenseHeader}\n${content}`;
})
);
} }
function createTemporaryScriptingBundle(defines, extraOptions = undefined) { function createTemporaryScriptingBundle(defines, extraOptions = undefined) {
@ -1381,7 +1384,7 @@ gulp.task(
.pipe(gulp.dest(MOZCENTRAL_L10N_DIR)), .pipe(gulp.dest(MOZCENTRAL_L10N_DIR)),
gulp.src("LICENSE").pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)), gulp.src("LICENSE").pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)),
gulp gulp
.src(FIREFOX_CONTENT_DIR + "PdfJsDefaultPreferences.jsm") .src(FIREFOX_CONTENT_DIR + "PdfJsDefaultPreferences.sys.mjs")
.pipe(transform("utf8", preprocessDefaultPreferences)) .pipe(transform("utf8", preprocessDefaultPreferences))
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR)), .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR)),
]); ]);

View File

@ -16,7 +16,7 @@
// In mozilla-central, this file is loaded as non-module script, // In mozilla-central, this file is loaded as non-module script,
// so it mustn't have any dependencies. // so it mustn't have any dependencies.
class SandboxSupportBase { export class SandboxSupportBase {
/** /**
* @param {DOMWindow} - win * @param {DOMWindow} - win
*/ */
@ -181,10 +181,3 @@ class SandboxSupportBase {
}; };
} }
} }
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
exports.SandboxSupportBase = SandboxSupportBase;
} else {
/* eslint-disable-next-line no-unused-vars, no-var */
var EXPORTED_SYMBOLS = ["SandboxSupportBase"];
}