[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
+ 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
@ -86,9 +86,9 @@ viewer, 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
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.
</p>
<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-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-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_LEGACY-dist.zip">Beta (vBETA_VERSION)</a>
</span>
</div>
<div class="col-md-4">

View File

@ -8,7 +8,7 @@
//
// 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
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.
var CMAP_URL = "../../../node_modules/pdfjs-dist/cmaps/";

View File

@ -14,7 +14,7 @@ var stream = require("stream");
require("./domstubs.js").setStubs(global);
// 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.
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
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.

View File

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

View File

@ -147,7 +147,7 @@ class WorkerMessageHandler {
throw new Error(
"The browser/environment lacks native support for critical " +
"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": [
"clitests_helper.js"