[api-minor] Rename -es5 to -legacy, to reduce confusion over what's actually supported (issue 12976)

*Please note that this will also require some edits of the Wiki.*
This commit is contained in:
Jonas Jenwald 2021-02-09 18:28:48 +01:00
parent 31098c404d
commit 0068dba009
10 changed files with 85 additions and 63 deletions

View File

@ -29,7 +29,7 @@ nullish coalescing.
+ Modern browsers: https://mozilla.github.io/pdf.js/web/viewer.html + Modern browsers: https://mozilla.github.io/pdf.js/web/viewer.html
+ Older browsers: https://mozilla.github.io/pdf.js/es5/web/viewer.html + Older browsers: https://mozilla.github.io/pdf.js/legacy/web/viewer.html
### Browser Extensions ### Browser Extensions
@ -86,9 +86,9 @@ viewer, run:
If you need to support older browsers, run: If you need to support older browsers, run:
$ gulp generic-es5 $ gulp generic-legacy
This will generate `pdf.js` and `pdf.worker.js` in the `build/generic/build/` directory (respectively `build/generic-es5/build/`). This will generate `pdf.js` and `pdf.worker.js` in the `build/generic/build/` directory (respectively `build/generic-legacy/build/`).
Both scripts are needed but only `pdf.js` needs to be included since `pdf.worker.js` will Both scripts are needed but only `pdf.js` needs to be included since `pdf.worker.js` will
be loaded by `pdf.js`. The PDF.js files are large and should be minified for production. be loaded by `pdf.js`. The PDF.js files are large and should be minified for production.

View File

@ -54,8 +54,8 @@ Before downloading PDF.js please take a moment to understand the different layer
Includes the generic build of PDF.js and the viewer. Includes the generic build of PDF.js and the viewer.
</p> </p>
<span class="GROUP_CLASS"> <span class="GROUP_CLASS">
<a type="button" class="btn btn-primary" href="https://github.com/mozilla/pdf.js/releases/download/vSTABLE_VERSION/pdfjs-STABLE_VERSION-es5-dist.zip">Stable (vSTABLE_VERSION)</a> <a type="button" class="btn btn-primary" href="https://github.com/mozilla/pdf.js/releases/download/vSTABLE_VERSION/pdfjs-STABLE_VERSION_LEGACY-dist.zip">Stable (vSTABLE_VERSION)</a>
<a type="button" class="btn btn-warning HIDDEN_CLASS" href="https://github.com/mozilla/pdf.js/releases/download/vBETA_VERSION/pdfjs-BETA_VERSION-es5-dist.zip">Beta (vBETA_VERSION)</a> <a type="button" class="btn btn-warning HIDDEN_CLASS" href="https://github.com/mozilla/pdf.js/releases/download/vBETA_VERSION/pdfjs-BETA_VERSION_LEGACY-dist.zip">Beta (vBETA_VERSION)</a>
</span> </span>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">

View File

@ -8,7 +8,7 @@
// //
// Run `gulp dist-install` to generate 'pdfjs-dist' npm package files. // Run `gulp dist-install` to generate 'pdfjs-dist' npm package files.
var pdfjsLib = require("pdfjs-dist/es5/build/pdf.js"); var pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js");
// Loading file from file system into typed array // Loading file from file system into typed array
var pdfPath = process.argv[2] || "../../web/compressed.tracemonkey-pldi-09.pdf"; var pdfPath = process.argv[2] || "../../web/compressed.tracemonkey-pldi-09.pdf";

View File

@ -48,7 +48,7 @@ NodeCanvasFactory.prototype = {
}, },
}; };
var pdfjsLib = require("pdfjs-dist/es5/build/pdf.js"); var pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js");
// Some PDFs need external cmaps. // Some PDFs need external cmaps.
var CMAP_URL = "../../../node_modules/pdfjs-dist/cmaps/"; var CMAP_URL = "../../../node_modules/pdfjs-dist/cmaps/";

View File

@ -14,7 +14,7 @@ var stream = require("stream");
require("./domstubs.js").setStubs(global); require("./domstubs.js").setStubs(global);
// Run `gulp dist-install` to generate 'pdfjs-dist' npm package files. // Run `gulp dist-install` to generate 'pdfjs-dist' npm package files.
var pdfjsLib = require("pdfjs-dist/es5/build/pdf.js"); var pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js");
// Some PDFs need external cmaps. // Some PDFs need external cmaps.
var CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/"; var CMAP_URL = "../../node_modules/pdfjs-dist/cmaps/";

View File

@ -9,6 +9,6 @@ generated by the build scripts.
For usage with older browsers or environments, without support for modern For usage with older browsers or environments, without support for modern
features such as e.g. `async`/`await`, `ReadableStream`, optional chaining, and features such as e.g. `async`/`await`, `ReadableStream`, optional chaining, and
nullish coalescing; please see the `es5` folder. nullish coalescing; please see the `legacy` folder.
See https://github.com/mozilla/pdf.js for learning and contributing. See https://github.com/mozilla/pdf.js for learning and contributing.

View File

@ -48,14 +48,14 @@ var EXTENSION_SRC_DIR = "extensions/";
var BASELINE_DIR = BUILD_DIR + "baseline/"; var BASELINE_DIR = BUILD_DIR + "baseline/";
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + "mozcentral.baseline/"; var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + "mozcentral.baseline/";
var GENERIC_DIR = BUILD_DIR + "generic/"; var GENERIC_DIR = BUILD_DIR + "generic/";
var GENERIC_ES5_DIR = BUILD_DIR + "generic-es5/"; var GENERIC_LEGACY_DIR = BUILD_DIR + "generic-legacy/";
var COMPONENTS_DIR = BUILD_DIR + "components/"; var COMPONENTS_DIR = BUILD_DIR + "components/";
var COMPONENTS_ES5_DIR = BUILD_DIR + "components-es5/"; var COMPONENTS_LEGACY_DIR = BUILD_DIR + "components-legacy/";
var IMAGE_DECODERS_DIR = BUILD_DIR + "image_decoders/"; var IMAGE_DECODERS_DIR = BUILD_DIR + "image_decoders/";
var IMAGE_DECODERS_ES5_DIR = BUILD_DIR + "image_decoders-es5/"; var IMAGE_DECODERS_LEGACY_DIR = BUILD_DIR + "image_decoders-legacy/";
var DEFAULT_PREFERENCES_DIR = BUILD_DIR + "default_preferences/"; var DEFAULT_PREFERENCES_DIR = BUILD_DIR + "default_preferences/";
var MINIFIED_DIR = BUILD_DIR + "minified/"; var MINIFIED_DIR = BUILD_DIR + "minified/";
var MINIFIED_ES5_DIR = BUILD_DIR + "minified-es5/"; var MINIFIED_LEGACY_DIR = BUILD_DIR + "minified-legacy/";
var JSDOC_BUILD_DIR = BUILD_DIR + "jsdoc/"; var JSDOC_BUILD_DIR = BUILD_DIR + "jsdoc/";
var GH_PAGES_DIR = BUILD_DIR + "gh-pages/"; var GH_PAGES_DIR = BUILD_DIR + "gh-pages/";
var SRC_DIR = "src/"; var SRC_DIR = "src/";
@ -876,7 +876,7 @@ gulp.task(
// Builds the generic production viewer that should be compatible with most // Builds the generic production viewer that should be compatible with most
// older HTML5 browsers. // older HTML5 browsers.
gulp.task( gulp.task(
"generic-es5", "generic-legacy",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences", "default_preferences",
@ -890,13 +890,13 @@ gulp.task(
}, },
function () { function () {
console.log(); console.log();
console.log("### Creating generic (ES5) viewer"); console.log("### Creating generic (legacy) viewer");
var defines = builder.merge(DEFINES, { var defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return buildGeneric(defines, GENERIC_ES5_DIR); return buildGeneric(defines, GENERIC_LEGACY_DIR);
} }
) )
); );
@ -931,17 +931,17 @@ gulp.task(
); );
gulp.task( gulp.task(
"components-es5", "components-legacy",
gulp.series("buildnumber", function () { gulp.series("buildnumber", function () {
console.log(); console.log();
console.log("### Creating generic (ES5) components"); console.log("### Creating generic (legacy) components");
var defines = builder.merge(DEFINES, { var defines = builder.merge(DEFINES, {
COMPONENTS: true, COMPONENTS: true,
GENERIC: true, GENERIC: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return buildComponents(defines, COMPONENTS_ES5_DIR); return buildComponents(defines, COMPONENTS_LEGACY_DIR);
}) })
); );
@ -962,10 +962,10 @@ gulp.task(
); );
gulp.task( gulp.task(
"image_decoders-es5", "image_decoders-legacy",
gulp.series("buildnumber", function () { gulp.series("buildnumber", function () {
console.log(); console.log();
console.log("### Creating (ES5) image decoders"); console.log("### Creating (legacy) image decoders");
var defines = builder.merge(DEFINES, { var defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
IMAGE_DECODERS: true, IMAGE_DECODERS: true,
@ -973,7 +973,7 @@ gulp.task(
}); });
return createImageDecodersBundle(defines).pipe( return createImageDecodersBundle(defines).pipe(
gulp.dest(IMAGE_DECODERS_ES5_DIR) gulp.dest(IMAGE_DECODERS_LEGACY_DIR)
); );
}) })
); );
@ -1033,7 +1033,7 @@ gulp.task(
); );
gulp.task( gulp.task(
"minified-es5-pre", "minified-legacy-pre",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences", "default_preferences",
@ -1048,14 +1048,14 @@ gulp.task(
}, },
function () { function () {
console.log(); console.log();
console.log("### Creating minified (ES5) viewer"); console.log("### Creating minified (legacy) viewer");
var defines = builder.merge(DEFINES, { var defines = builder.merge(DEFINES, {
MINIFIED: true, MINIFIED: true,
GENERIC: true, GENERIC: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return buildMinified(defines, MINIFIED_ES5_DIR); return buildMinified(defines, MINIFIED_LEGACY_DIR);
} }
) )
); );
@ -1138,9 +1138,9 @@ gulp.task(
); );
gulp.task( gulp.task(
"minified-es5", "minified-legacy",
gulp.series("minified-es5-pre", async function (done) { gulp.series("minified-legacy-pre", async function (done) {
await parseMinified(MINIFIED_ES5_DIR); await parseMinified(MINIFIED_LEGACY_DIR);
done(); done();
}) })
); );
@ -1468,7 +1468,7 @@ gulp.task(
); );
gulp.task( gulp.task(
"lib-es5", "lib-legacy",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences", "default_preferences",
@ -1488,8 +1488,8 @@ gulp.task(
}); });
return merge([ return merge([
buildLib(defines, "build/lib-es5/"), buildLib(defines, "build/lib-legacy/"),
createSandboxBundle(defines).pipe(gulp.dest("build/lib-es5/")), createSandboxBundle(defines).pipe(gulp.dest("build/lib-legacy/")),
]); ]);
} }
) )
@ -1507,7 +1507,7 @@ function compressPublish(targetName, dir) {
gulp.task( gulp.task(
"publish", "publish",
gulp.series("generic", "generic-es5", function (done) { gulp.series("generic", "generic-legacy", function (done) {
var version = JSON.parse( var version = JSON.parse(
fs.readFileSync(BUILD_DIR + "version.json").toString() fs.readFileSync(BUILD_DIR + "version.json").toString()
).version; ).version;
@ -1520,7 +1520,10 @@ gulp.task(
gulp.dest(".") gulp.dest(".")
), ),
compressPublish("pdfjs-" + version + "-dist.zip", GENERIC_DIR), compressPublish("pdfjs-" + version + "-dist.zip", GENERIC_DIR),
compressPublish("pdfjs-" + version + "-es5-dist.zip", GENERIC_ES5_DIR), compressPublish(
"pdfjs-" + version + "-legacy-dist.zip",
GENERIC_LEGACY_DIR
),
]); ]);
}) })
); );
@ -1674,7 +1677,7 @@ gulp.task("baseline", function (done) {
gulp.task( gulp.task(
"unittestcli", "unittestcli",
gulp.series("testing-pre", "lib-es5", function (done) { gulp.series("testing-pre", "lib-legacy", function (done) {
var options = [ var options = [
"node_modules/jasmine/bin/jasmine", "node_modules/jasmine/bin/jasmine",
"JASMINE_CONFIG_PATH=test/unit/clitests.json", "JASMINE_CONFIG_PATH=test/unit/clitests.json",
@ -1846,8 +1849,11 @@ gulp.task("gh-pages-prepare", function () {
.src(GENERIC_DIR + "**/*", { base: GENERIC_DIR, stripBOM: false }) .src(GENERIC_DIR + "**/*", { base: GENERIC_DIR, stripBOM: false })
.pipe(gulp.dest(GH_PAGES_DIR)), .pipe(gulp.dest(GH_PAGES_DIR)),
vfs vfs
.src(GENERIC_ES5_DIR + "**/*", { base: GENERIC_ES5_DIR, stripBOM: false }) .src(GENERIC_LEGACY_DIR + "**/*", {
.pipe(gulp.dest(GH_PAGES_DIR + "es5/")), base: GENERIC_LEGACY_DIR,
stripBOM: false,
})
.pipe(gulp.dest(GH_PAGES_DIR + "legacy/")),
gulp gulp
.src("test/features/**/*", { base: "test/" }) .src("test/features/**/*", { base: "test/" })
.pipe(gulp.dest(GH_PAGES_DIR)), .pipe(gulp.dest(GH_PAGES_DIR)),
@ -1865,20 +1871,36 @@ gulp.task("wintersmith", function (done) {
done(error); done(error);
return; return;
} }
const { stableVersion, betaVersion } = config;
// Create appropriate file names for the legacy builds. This logic can be
// removed and/or simplified, once the stable version is past the cutoff.
const CUTOFF_VERSION = "2.7.570";
replaceInFile(
GH_PAGES_DIR + "/getting_started/index.html",
/STABLE_VERSION_LEGACY/g,
stableVersion + (stableVersion <= CUTOFF_VERSION ? "-es5" : "-legacy")
);
replaceInFile(
GH_PAGES_DIR + "/getting_started/index.html",
/BETA_VERSION_LEGACY/g,
betaVersion + (betaVersion <= CUTOFF_VERSION ? "-es5" : "-legacy")
);
replaceInFile( replaceInFile(
GH_PAGES_DIR + "/getting_started/index.html", GH_PAGES_DIR + "/getting_started/index.html",
/STABLE_VERSION/g, /STABLE_VERSION/g,
config.stableVersion stableVersion
); );
replaceInFile( replaceInFile(
GH_PAGES_DIR + "/getting_started/index.html", GH_PAGES_DIR + "/getting_started/index.html",
/BETA_VERSION/g, /BETA_VERSION/g,
config.betaVersion betaVersion
); );
// Hide the beta version button if there is only a stable version. // Hide the beta version button if there is only a stable version.
const groupClass = config.betaVersion ? "btn-group-vertical centered" : ""; const groupClass = betaVersion ? "btn-group-vertical centered" : "";
const hiddenClass = config.betaVersion ? "" : "hidden"; const hiddenClass = betaVersion ? "" : "hidden";
replaceInFile( replaceInFile(
GH_PAGES_DIR + "/getting_started/index.html", GH_PAGES_DIR + "/getting_started/index.html",
/GROUP_CLASS/g, /GROUP_CLASS/g,
@ -1926,7 +1948,7 @@ gulp.task(
"web", "web",
gulp.series( gulp.series(
"generic", "generic",
"generic-es5", "generic-legacy",
"jsdoc", "jsdoc",
"gh-pages-prepare", "gh-pages-prepare",
"wintersmith", "wintersmith",
@ -1990,14 +2012,14 @@ gulp.task(
"dist-pre", "dist-pre",
gulp.series( gulp.series(
"generic", "generic",
"generic-es5", "generic-legacy",
"components", "components",
"components-es5", "components-legacy",
"image_decoders", "image_decoders",
"image_decoders-es5", "image_decoders-legacy",
"lib", "lib",
"minified", "minified",
"minified-es5", "minified-legacy",
"types", "types",
function () { function () {
console.log(); console.log();
@ -2033,11 +2055,11 @@ gulp.task(
.pipe(gulp.dest(DIST_DIR + "build/")), .pipe(gulp.dest(DIST_DIR + "build/")),
gulp gulp
.src([ .src([
GENERIC_ES5_DIR + "build/{pdf,pdf.worker,pdf.sandbox}.js", GENERIC_LEGACY_DIR + "build/{pdf,pdf.worker,pdf.sandbox}.js",
GENERIC_ES5_DIR + "build/{pdf,pdf.worker,pdf.sandbox}.js.map", GENERIC_LEGACY_DIR + "build/{pdf,pdf.worker,pdf.sandbox}.js.map",
SRC_DIR + "pdf.worker.entry.js", SRC_DIR + "pdf.worker.entry.js",
]) ])
.pipe(gulp.dest(DIST_DIR + "es5/build/")), .pipe(gulp.dest(DIST_DIR + "legacy/build/")),
gulp gulp
.src(MINIFIED_DIR + "build/pdf.js") .src(MINIFIED_DIR + "build/pdf.js")
.pipe(rename("pdf.min.js")) .pipe(rename("pdf.min.js"))
@ -2055,35 +2077,35 @@ gulp.task(
.pipe(rename("pdf.image_decoders.min.js")) .pipe(rename("pdf.image_decoders.min.js"))
.pipe(gulp.dest(DIST_DIR + "image_decoders/")), .pipe(gulp.dest(DIST_DIR + "image_decoders/")),
gulp gulp
.src(MINIFIED_ES5_DIR + "build/pdf.js") .src(MINIFIED_LEGACY_DIR + "build/pdf.js")
.pipe(rename("pdf.min.js")) .pipe(rename("pdf.min.js"))
.pipe(gulp.dest(DIST_DIR + "es5/build/")), .pipe(gulp.dest(DIST_DIR + "legacy/build/")),
gulp gulp
.src(MINIFIED_ES5_DIR + "build/pdf.worker.js") .src(MINIFIED_LEGACY_DIR + "build/pdf.worker.js")
.pipe(rename("pdf.worker.min.js")) .pipe(rename("pdf.worker.min.js"))
.pipe(gulp.dest(DIST_DIR + "es5/build/")), .pipe(gulp.dest(DIST_DIR + "legacy/build/")),
gulp gulp
.src(MINIFIED_ES5_DIR + "build/pdf.sandbox.js") .src(MINIFIED_LEGACY_DIR + "build/pdf.sandbox.js")
.pipe(rename("pdf.sandbox.min.js")) .pipe(rename("pdf.sandbox.min.js"))
.pipe(gulp.dest(DIST_DIR + "es5/build/")), .pipe(gulp.dest(DIST_DIR + "legacy/build/")),
gulp gulp
.src(MINIFIED_ES5_DIR + "image_decoders/pdf.image_decoders.js") .src(MINIFIED_LEGACY_DIR + "image_decoders/pdf.image_decoders.js")
.pipe(rename("pdf.image_decoders.min.js")) .pipe(rename("pdf.image_decoders.min.js"))
.pipe(gulp.dest(DIST_DIR + "es5/image_decoders/")), .pipe(gulp.dest(DIST_DIR + "legacy/image_decoders/")),
gulp gulp
.src(COMPONENTS_DIR + "**/*", { base: COMPONENTS_DIR }) .src(COMPONENTS_DIR + "**/*", { base: COMPONENTS_DIR })
.pipe(gulp.dest(DIST_DIR + "web/")), .pipe(gulp.dest(DIST_DIR + "web/")),
gulp gulp
.src(COMPONENTS_ES5_DIR + "**/*", { base: COMPONENTS_ES5_DIR }) .src(COMPONENTS_LEGACY_DIR + "**/*", { base: COMPONENTS_LEGACY_DIR })
.pipe(gulp.dest(DIST_DIR + "es5/web/")), .pipe(gulp.dest(DIST_DIR + "legacy/web/")),
gulp gulp
.src(IMAGE_DECODERS_DIR + "**/*", { base: IMAGE_DECODERS_DIR }) .src(IMAGE_DECODERS_DIR + "**/*", { base: IMAGE_DECODERS_DIR })
.pipe(gulp.dest(DIST_DIR + "image_decoders/")), .pipe(gulp.dest(DIST_DIR + "image_decoders/")),
gulp gulp
.src(IMAGE_DECODERS_ES5_DIR + "**/*", { .src(IMAGE_DECODERS_LEGACY_DIR + "**/*", {
base: IMAGE_DECODERS_ES5_DIR, base: IMAGE_DECODERS_LEGACY_DIR,
}) })
.pipe(gulp.dest(DIST_DIR + "es5/image_decoders/")), .pipe(gulp.dest(DIST_DIR + "legacy/image_decoders/")),
gulp gulp
.src(LIB_DIR + "**/*", { base: LIB_DIR }) .src(LIB_DIR + "**/*", { base: LIB_DIR })
.pipe(gulp.dest(DIST_DIR + "lib/")), .pipe(gulp.dest(DIST_DIR + "lib/")),

View File

@ -147,7 +147,7 @@ class WorkerMessageHandler {
throw new Error( throw new Error(
"The browser/environment lacks native support for critical " + "The browser/environment lacks native support for critical " +
"functionality used by the PDF.js library (e.g. `ReadableStream`); " + "functionality used by the PDF.js library (e.g. `ReadableStream`); " +
"please use an `es5`-build instead." "please use a `legacy`-build instead."
); );
} }
} }

View File

@ -1,5 +1,5 @@
{ {
"spec_dir": "build/lib-es5/test/unit", "spec_dir": "build/lib-legacy/test/unit",
"helpers": [ "helpers": [
"clitests_helper.js" "clitests_helper.js"