1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 15:48:06 +02:00

Ensure that all import and require statements, in the entire code-base, have a .js file extension

In order to eventually get rid of SystemJS and start using native `import`s instead, we'll need to provide "complete" file identifiers since otherwise there'll be MIME type errors when attempting to use `import`.
This commit is contained in:
Jonas Jenwald 2020-01-02 12:00:16 +01:00
parent b833f84307
commit 36881e3770
125 changed files with 453 additions and 443 deletions

View file

@ -42,10 +42,10 @@
function initializePDFJS(callback) {
Promise.all([
SystemJS.import("pdfjs/core/fonts"),
SystemJS.import("pdfjs/core/stream"),
SystemJS.import("pdfjs/core/primitives"),
SystemJS.import("pdfjs/core/cmap"),
SystemJS.import("pdfjs/core/fonts.js"),
SystemJS.import("pdfjs/core/stream.js"),
SystemJS.import("pdfjs/core/primitives.js"),
SystemJS.import("pdfjs/core/cmap.js"),
]).then(function(modules) {
var fonts = modules[0],
stream = modules[1],

View file

@ -19,7 +19,7 @@ import {
AnnotationFactory,
getQuadPoints,
MarkupAnnotation,
} from "../../src/core/annotation";
} from "../../src/core/annotation.js";
import {
AnnotationBorderStyleType,
AnnotationFieldFlag,
@ -27,11 +27,11 @@ import {
AnnotationType,
stringToBytes,
stringToUTF8String,
} from "../../src/shared/util";
import { createIdFactory, XRefMock } from "./test_utils";
import { Dict, Name, Ref } from "../../src/core/primitives";
import { Lexer, Parser } from "../../src/core/parser";
import { StringStream } from "../../src/core/stream";
} from "../../src/shared/util.js";
import { createIdFactory, XRefMock } from "./test_utils.js";
import { Dict, Name, Ref } from "../../src/core/primitives.js";
import { Lexer, Parser } from "../../src/core/parser.js";
import { StringStream } from "../../src/core/stream.js";
describe("annotation", function() {
class PDFManagerMock {

View file

@ -19,7 +19,7 @@ import {
NodeCanvasFactory,
NodeFileReaderFactory,
TEST_PDFS_PATH,
} from "./test_utils";
} from "./test_utils.js";
import {
createPromiseCapability,
FontType,
@ -31,23 +31,23 @@ import {
PasswordResponses,
PermissionFlag,
StreamType,
} from "../../src/shared/util";
} from "../../src/shared/util.js";
import {
DOMCanvasFactory,
RenderingCancelledException,
StatTimer,
} from "../../src/display/display_utils";
} from "../../src/display/display_utils.js";
import {
getDocument,
PDFDataRangeTransport,
PDFDocumentProxy,
PDFPageProxy,
PDFWorker,
} from "../../src/display/api";
import { AutoPrintRegExp } from "../../web/ui_utils";
import { GlobalWorkerOptions } from "../../src/display/worker_options";
import { isNodeJS } from "../../src/shared/is_node";
import { Metadata } from "../../src/display/metadata";
} from "../../src/display/api.js";
import { AutoPrintRegExp } from "../../web/ui_utils.js";
import { GlobalWorkerOptions } from "../../src/display/worker_options.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { Metadata } from "../../src/display/metadata.js";
describe("api", function() {
let basicApiFileName = "basicapi.pdf";

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { bidi } from "../../src/core/bidi";
import { bidi } from "../../src/core/bidi.js";
describe("bidi", function() {
it("should mark text as RTL if more than 30% of text is RTL", function() {

View file

@ -19,9 +19,9 @@ import {
CFFFDSelect,
CFFParser,
CFFStrings,
} from "../../src/core/cff_parser";
import { SEAC_ANALYSIS_ENABLED } from "../../src/core/fonts";
import { Stream } from "../../src/core/stream";
} from "../../src/core/cff_parser.js";
import { SEAC_ANALYSIS_ENABLED } from "../../src/core/fonts.js";
import { Stream } from "../../src/core/stream.js";
describe("CFFParser", function() {
function createWithNullProto(obj) {

View file

@ -13,10 +13,10 @@
* limitations under the License.
*/
import { setVerbosityLevel, VerbosityLevel } from "../../src/shared/util";
import { isNodeJS } from "../../src/shared/is_node";
import { PDFNodeStream } from "../../src/display/node_stream";
import { setPDFNetworkStreamFactory } from "../../src/display/api";
import { setVerbosityLevel, VerbosityLevel } from "../../src/shared/util.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { PDFNodeStream } from "../../src/display/node_stream.js";
import { setPDFNetworkStreamFactory } from "../../src/display/api.js";
// Ensure that this script only runs in Node.js environments.
if (!isNodeJS) {

View file

@ -13,12 +13,12 @@
* limitations under the License.
*/
import { CMap, CMapFactory, IdentityCMap } from "../../src/core/cmap";
import { DOMCMapReaderFactory } from "../../src/display/display_utils";
import { isNodeJS } from "../../src/shared/is_node";
import { Name } from "../../src/core/primitives";
import { NodeCMapReaderFactory } from "./test_utils";
import { StringStream } from "../../src/core/stream";
import { CMap, CMapFactory, IdentityCMap } from "../../src/core/cmap.js";
import { DOMCMapReaderFactory } from "../../src/display/display_utils.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { Name } from "../../src/core/primitives.js";
import { NodeCMapReaderFactory } from "./test_utils.js";
import { StringStream } from "../../src/core/stream.js";
var cMapUrl = {
dom: "../../external/bcmaps/",

View file

@ -13,11 +13,11 @@
* limitations under the License.
*/
import { Dict, Name, Ref } from "../../src/core/primitives";
import { Stream, StringStream } from "../../src/core/stream";
import { ColorSpace } from "../../src/core/colorspace";
import { PDFFunctionFactory } from "../../src/core/function";
import { XRefMock } from "./test_utils";
import { Dict, Name, Ref } from "../../src/core/primitives.js";
import { Stream, StringStream } from "../../src/core/stream.js";
import { ColorSpace } from "../../src/core/colorspace.js";
import { PDFFunctionFactory } from "../../src/core/function.js";
import { XRefMock } from "./test_utils.js";
describe("colorspace", function() {
describe("ColorSpace", function() {

View file

@ -13,12 +13,12 @@
* limitations under the License.
*/
import { Dict, Ref } from "../../src/core/primitives";
import { Dict, Ref } from "../../src/core/primitives.js";
import {
getInheritableProperty,
toRomanNumerals,
} from "../../src/core/core_utils";
import { XRefMock } from "./test_utils";
} from "../../src/core/core_utils.js";
import { XRefMock } from "./test_utils.js";
describe("core_utils", function() {
describe("getInheritableProperty", function() {

View file

@ -24,13 +24,13 @@ import {
CipherTransformFactory,
PDF17,
PDF20,
} from "../../src/core/crypto";
import { Dict, Name } from "../../src/core/primitives";
} from "../../src/core/crypto.js";
import { Dict, Name } from "../../src/core/primitives.js";
import {
PasswordException,
PasswordResponses,
stringToBytes,
} from "../../src/shared/util";
} from "../../src/shared/util.js";
describe("crypto", function() {
function hex2binary(s) {

View file

@ -13,10 +13,10 @@
* limitations under the License.
*/
import { buildGetDocumentParams, NodeCanvasFactory } from "./test_utils";
import { DOMCanvasFactory } from "../../src/display/display_utils";
import { getDocument } from "../../src/display/api";
import { isNodeJS } from "../../src/shared/is_node";
import { buildGetDocumentParams, NodeCanvasFactory } from "./test_utils.js";
import { DOMCanvasFactory } from "../../src/display/display_utils.js";
import { getDocument } from "../../src/display/api.js";
import { isNodeJS } from "../../src/shared/is_node.js";
function getTopLeftPixel(canvasContext) {
let imgData = canvasContext.getImageData(0, 0, 1, 1);

View file

@ -14,12 +14,12 @@
*/
/* globals __non_webpack_require__ */
import { setStubs, unsetStubs } from "../../examples/node/domstubs";
import { buildGetDocumentParams } from "./test_utils";
import { getDocument } from "../../src/display/api";
import { isNodeJS } from "../../src/shared/is_node";
import { NativeImageDecoding } from "../../src/shared/util";
import { SVGGraphics } from "../../src/display/svg";
import { setStubs, unsetStubs } from "../../examples/node/domstubs.js";
import { buildGetDocumentParams } from "./test_utils.js";
import { getDocument } from "../../src/display/api.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { NativeImageDecoding } from "../../src/shared/util.js";
import { SVGGraphics } from "../../src/display/svg.js";
const XLINK_NS = "http://www.w3.org/1999/xlink";

View file

@ -20,8 +20,8 @@ import {
getFilenameFromUrl,
isValidFetchUrl,
PDFDateString,
} from "../../src/display/display_utils";
import { isNodeJS } from "../../src/shared/is_node";
} from "../../src/display/display_utils.js";
import { isNodeJS } from "../../src/shared/is_node.js";
describe("display_utils", function() {
describe("DOMCanvasFactory", function() {

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { createIdFactory } from "./test_utils";
import { createIdFactory } from "./test_utils.js";
describe("document", function() {
describe("Page", function() {

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { getEncoding } from "../../src/core/encodings";
import { getEncoding } from "../../src/core/encodings.js";
describe("encodings", function() {
describe("getEncoding", function() {

View file

@ -13,13 +13,13 @@
* limitations under the License.
*/
import { createIdFactory, XRefMock } from "./test_utils";
import { Dict, Name } from "../../src/core/primitives";
import { FormatError, OPS } from "../../src/shared/util";
import { Stream, StringStream } from "../../src/core/stream";
import { OperatorList } from "../../src/core/operator_list";
import { PartialEvaluator } from "../../src/core/evaluator";
import { WorkerTask } from "../../src/core/worker";
import { createIdFactory, XRefMock } from "./test_utils.js";
import { Dict, Name } from "../../src/core/primitives.js";
import { FormatError, OPS } from "../../src/shared/util.js";
import { Stream, StringStream } from "../../src/core/stream.js";
import { OperatorList } from "../../src/core/operator_list.js";
import { PartialEvaluator } from "../../src/core/evaluator.js";
import { WorkerTask } from "../../src/core/worker.js";
describe("evaluator", function() {
function HandlerMock() {

View file

@ -14,8 +14,8 @@
*/
/* eslint no-var: error */
import { AbortException } from "../../src/shared/util";
import { PDFFetchStream } from "../../src/display/fetch_stream";
import { AbortException } from "../../src/shared/util.js";
import { PDFFetchStream } from "../../src/display/fetch_stream.js";
describe("fetch_stream", function() {
const pdfUrl = new URL("../pdfs/tracemonkey.pdf", window.location).href;

View file

@ -16,9 +16,9 @@
import {
PostScriptCompiler,
PostScriptEvaluator,
} from "../../src/core/function";
import { PostScriptLexer, PostScriptParser } from "../../src/core/ps_parser";
import { StringStream } from "../../src/core/stream";
} from "../../src/core/function.js";
import { PostScriptLexer, PostScriptParser } from "../../src/core/ps_parser.js";
import { StringStream } from "../../src/core/stream.js";
describe("function", function() {
beforeEach(function() {

View file

@ -43,42 +43,42 @@
function initializePDFJS(callback) {
Promise.all(
[
"pdfjs/display/api",
"pdfjs/display/worker_options",
"pdfjs/display/network",
"pdfjs/display/fetch_stream",
"pdfjs/shared/is_node",
"pdfjs-test/unit/annotation_spec",
"pdfjs-test/unit/api_spec",
"pdfjs-test/unit/bidi_spec",
"pdfjs-test/unit/cff_parser_spec",
"pdfjs-test/unit/cmap_spec",
"pdfjs-test/unit/colorspace_spec",
"pdfjs-test/unit/core_utils_spec",
"pdfjs-test/unit/crypto_spec",
"pdfjs-test/unit/custom_spec",
"pdfjs-test/unit/display_svg_spec",
"pdfjs-test/unit/display_utils_spec",
"pdfjs-test/unit/document_spec",
"pdfjs-test/unit/encodings_spec",
"pdfjs-test/unit/evaluator_spec",
"pdfjs-test/unit/function_spec",
"pdfjs-test/unit/fetch_stream_spec",
"pdfjs-test/unit/message_handler_spec",
"pdfjs-test/unit/metadata_spec",
"pdfjs-test/unit/murmurhash3_spec",
"pdfjs-test/unit/network_spec",
"pdfjs-test/unit/network_utils_spec",
"pdfjs-test/unit/parser_spec",
"pdfjs-test/unit/pdf_find_controller_spec",
"pdfjs-test/unit/pdf_find_utils_spec",
"pdfjs-test/unit/pdf_history_spec",
"pdfjs-test/unit/primitives_spec",
"pdfjs-test/unit/stream_spec",
"pdfjs-test/unit/type1_parser_spec",
"pdfjs-test/unit/ui_utils_spec",
"pdfjs-test/unit/unicode_spec",
"pdfjs-test/unit/util_spec",
"pdfjs/display/api.js",
"pdfjs/display/worker_options.js",
"pdfjs/display/network.js",
"pdfjs/display/fetch_stream.js",
"pdfjs/shared/is_node.js",
"pdfjs-test/unit/annotation_spec.js",
"pdfjs-test/unit/api_spec.js",
"pdfjs-test/unit/bidi_spec.js",
"pdfjs-test/unit/cff_parser_spec.js",
"pdfjs-test/unit/cmap_spec.js",
"pdfjs-test/unit/colorspace_spec.js",
"pdfjs-test/unit/core_utils_spec.js",
"pdfjs-test/unit/crypto_spec.js",
"pdfjs-test/unit/custom_spec.js",
"pdfjs-test/unit/display_svg_spec.js",
"pdfjs-test/unit/display_utils_spec.js",
"pdfjs-test/unit/document_spec.js",
"pdfjs-test/unit/encodings_spec.js",
"pdfjs-test/unit/evaluator_spec.js",
"pdfjs-test/unit/function_spec.js",
"pdfjs-test/unit/fetch_stream_spec.js",
"pdfjs-test/unit/message_handler_spec.js",
"pdfjs-test/unit/metadata_spec.js",
"pdfjs-test/unit/murmurhash3_spec.js",
"pdfjs-test/unit/network_spec.js",
"pdfjs-test/unit/network_utils_spec.js",
"pdfjs-test/unit/parser_spec.js",
"pdfjs-test/unit/pdf_find_controller_spec.js",
"pdfjs-test/unit/pdf_find_utils_spec.js",
"pdfjs-test/unit/pdf_history_spec.js",
"pdfjs-test/unit/primitives_spec.js",
"pdfjs-test/unit/stream_spec.js",
"pdfjs-test/unit/type1_parser_spec.js",
"pdfjs-test/unit/ui_utils_spec.js",
"pdfjs-test/unit/unicode_spec.js",
"pdfjs-test/unit/util_spec.js",
].map(function(moduleName) {
return SystemJS.import(moduleName);
})

View file

@ -17,9 +17,9 @@ import {
AbortException,
createPromiseCapability,
UnknownErrorException,
} from "../../src/shared/util";
import { LoopbackPort } from "../../src/display/api";
import { MessageHandler } from "../../src/shared/message_handler";
} from "../../src/shared/util.js";
import { LoopbackPort } from "../../src/display/api.js";
import { MessageHandler } from "../../src/shared/message_handler.js";
describe("message_handler", function() {
// Sleep function to wait for sometime, similar to setTimeout but faster.

View file

@ -13,8 +13,8 @@
* limitations under the License.
*/
import { isEmptyObj } from "../../src/shared/util";
import { Metadata } from "../../src/display/metadata";
import { isEmptyObj } from "../../src/shared/util.js";
import { Metadata } from "../../src/display/metadata.js";
describe("metadata", function() {
it("should handle valid metadata", function() {

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { MurmurHash3_64 } from "../../src/core/murmurhash3";
import { MurmurHash3_64 } from "../../src/core/murmurhash3.js";
describe("MurmurHash3_64", function() {
it("instantiates without seed", function() {

View file

@ -13,8 +13,8 @@
* limitations under the License.
*/
import { AbortException } from "../../src/shared/util";
import { PDFNetworkStream } from "../../src/display/network";
import { AbortException } from "../../src/shared/util.js";
import { PDFNetworkStream } from "../../src/display/network.js";
describe("network", function() {
var pdf1 = new URL("../pdfs/tracemonkey.pdf", window.location).href;

View file

@ -18,11 +18,11 @@ import {
extractFilenameFromHeader,
validateRangeRequestCapabilities,
validateResponseStatus,
} from "../../src/display/network_utils";
} from "../../src/display/network_utils.js";
import {
MissingPDFException,
UnexpectedResponseException,
} from "../../src/shared/util";
} from "../../src/shared/util.js";
describe("network_utils", function() {
describe("validateRangeRequestCapabilities", function() {

View file

@ -14,9 +14,9 @@
*/
/* globals __non_webpack_require__ */
import { AbortException, assert } from "../../src/shared/util";
import { isNodeJS } from "../../src/shared/is_node";
import { PDFNodeStream } from "../../src/display/node_stream";
import { AbortException, assert } from "../../src/shared/util.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { PDFNodeStream } from "../../src/display/node_stream.js";
// Make sure that we only running this script is Node.js environments.
assert(isNodeJS);

View file

@ -14,10 +14,10 @@
*/
/* eslint no-var: error */
import { Lexer, Linearization, Parser } from "../../src/core/parser";
import { FormatError } from "../../src/shared/util";
import { Name } from "../../src/core/primitives";
import { StringStream } from "../../src/core/stream";
import { Lexer, Linearization, Parser } from "../../src/core/parser.js";
import { FormatError } from "../../src/shared/util.js";
import { Name } from "../../src/core/primitives.js";
import { StringStream } from "../../src/core/stream.js";
describe("parser", function() {
describe("Parser", function() {

View file

@ -13,11 +13,11 @@
* limitations under the License.
*/
import { buildGetDocumentParams } from "./test_utils";
import { EventBus } from "../../web/ui_utils";
import { getDocument } from "../../src/display/api";
import { PDFFindController } from "../../web/pdf_find_controller";
import { SimpleLinkService } from "../../web/pdf_link_service";
import { buildGetDocumentParams } from "./test_utils.js";
import { EventBus } from "../../web/ui_utils.js";
import { getDocument } from "../../src/display/api.js";
import { PDFFindController } from "../../web/pdf_find_controller.js";
import { SimpleLinkService } from "../../web/pdf_link_service.js";
class MockLinkService extends SimpleLinkService {
constructor() {

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { CharacterType, getCharacterType } from "../../web/pdf_find_utils";
import { CharacterType, getCharacterType } from "../../web/pdf_find_utils.js";
describe("pdf_find_utils", function() {
describe("getCharacterType", function() {

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { isDestArraysEqual, isDestHashesEqual } from "../../web/pdf_history";
import { isDestArraysEqual, isDestHashesEqual } from "../../web/pdf_history.js";
describe("pdf_history", function() {
describe("isDestHashesEqual", function() {

View file

@ -24,8 +24,8 @@ import {
Name,
Ref,
RefSet,
} from "../../src/core/primitives";
import { XRefMock } from "./test_utils";
} from "../../src/core/primitives.js";
import { XRefMock } from "./test_utils.js";
describe("primitives", function() {
describe("Name", function() {

View file

@ -13,8 +13,8 @@
* limitations under the License.
*/
import { PredictorStream, Stream } from "../../src/core/stream";
import { Dict } from "../../src/core/primitives";
import { PredictorStream, Stream } from "../../src/core/stream.js";
import { Dict } from "../../src/core/primitives.js";
describe("stream", function() {
beforeEach(function() {

View file

@ -13,10 +13,10 @@
* limitations under the License.
*/
import { assert, CMapCompressionType } from "../../src/shared/util";
import { isNodeJS } from "../../src/shared/is_node";
import { isRef } from "../../src/core/primitives";
import { Page } from "../../src/core/document";
import { assert, CMapCompressionType } from "../../src/shared/util.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { isRef } from "../../src/core/primitives.js";
import { Page } from "../../src/core/document.js";
class DOMFileReaderFactory {
static async fetch(params) {

View file

@ -13,9 +13,9 @@
* limitations under the License.
*/
import { SEAC_ANALYSIS_ENABLED } from "../../src/core/fonts";
import { StringStream } from "../../src/core/stream";
import { Type1Parser } from "../../src/core/type1_parser";
import { SEAC_ANALYSIS_ENABLED } from "../../src/core/fonts.js";
import { StringStream } from "../../src/core/stream.js";
import { Type1Parser } from "../../src/core/type1_parser.js";
describe("Type1Parser", function() {
it("splits tokens", function() {

View file

@ -25,9 +25,9 @@ import {
moveToEndOfArray,
waitOnEventOrTimeout,
WaitOnType,
} from "../../web/ui_utils";
import { createObjectURL } from "../../src/shared/util";
import { isNodeJS } from "../../src/shared/is_node";
} from "../../web/ui_utils.js";
import { createObjectURL } from "../../src/shared/util.js";
import { isNodeJS } from "../../src/shared/is_node.js";
describe("ui_utils", function() {
describe("binary search", function() {

View file

@ -16,14 +16,14 @@
import {
getDingbatsGlyphsUnicode,
getGlyphsUnicode,
} from "../../src/core/glyphlist";
} from "../../src/core/glyphlist.js";
import {
getNormalizedUnicodes,
getUnicodeForGlyph,
getUnicodeRangeFor,
mapSpecialUnicodeValues,
reverseIfRtl,
} from "../../src/core/unicode";
} from "../../src/core/unicode.js";
describe("unicode", function() {
describe("mapSpecialUnicodeValues", function() {

View file

@ -29,7 +29,7 @@ import {
string32,
stringToBytes,
stringToPDFString,
} from "../../src/shared/util";
} from "../../src/shared/util.js";
describe("util", function() {
describe("bytesToString", function() {