From 69ad0d9861cca421b837a66724556c9c1b6c4d68 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 18 Oct 2023 20:13:10 +0200 Subject: [PATCH] Only bundle `NullL10n` in GENERIC builds (bug 1859818) --- gulpfile.mjs | 4 ++++ test/unit/unit_test.html | 1 + tsconfig.json | 5 +++-- web/annotation_editor_layer_builder.js | 2 +- web/annotation_layer_builder.js | 2 +- web/pdf_page_view.js | 2 +- web/pdf_viewer.js | 2 +- web/stubs.js | 18 ++++++++++++++++++ web/viewer-geckoview.html | 1 + web/viewer.html | 1 + 10 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 web/stubs.js diff --git a/gulpfile.mjs b/gulpfile.mjs index b28477bd7..0656b31b0 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -254,6 +254,7 @@ function createWebpackConfig( "web-alt_text_manager": "web/alt_text_manager.js", "web-annotation_editor_params": "web/annotation_editor_params.js", "web-com": "", + "web-l10n_utils": "web/stubs.js", "web-pdf_attachment_viewer": "web/pdf_attachment_viewer.js", "web-pdf_cursor_tools": "web/pdf_cursor_tools.js", "web-pdf_document_properties": "web/pdf_document_properties.js", @@ -284,10 +285,12 @@ function createWebpackConfig( libraryAlias["display-node_utils"] = "src/display/node_utils.js"; viewerAlias["web-com"] = "web/genericcom.js"; + viewerAlias["web-l10n_utils"] = "web/l10n_utils.js"; viewerAlias["web-print_service"] = "web/pdf_print_service.js"; } else if (bundleDefines.MOZCENTRAL) { if (bundleDefines.GECKOVIEW) { const gvAlias = { + "web-l10n_utils": "web/stubs.js", "web-toolbar": "web/toolbar-geckoview.js", }; for (const key in viewerAlias) { @@ -1556,6 +1559,7 @@ function buildLibHelper(bundleDefines, inputStream, outputDir) { "display-node_utils": "./node_utils.js", "fluent-bundle": "../../../node_modules/@fluent/bundle/esm/index.js", "fluent-dom": "../../../node_modules/@fluent/dom/esm/index.js", + "web-l10n_utils": "../web/l10n_utils.js", }, }; const licenseHeaderLibre = fs diff --git a/test/unit/unit_test.html b/test/unit/unit_test.html index b0a70c8d1..2260c0301 100644 --- a/test/unit/unit_test.html +++ b/test/unit/unit_test.html @@ -29,6 +29,7 @@ "web-alt_text_manager": "../../web/alt_text_manager.js", "web-annotation_editor_params": "../../web/annotation_editor_params.js", "web-com": "../../web/genericcom.js", + "web-l10n_utils": "../../web/l10n_utils.js", "web-pdf_attachment_viewer": "../../web/pdf_attachment_viewer.js", "web-pdf_cursor_tools": "../../web/pdf_cursor_tools.js", "web-pdf_document_properties": "../../web/pdf_document_properties.js", diff --git a/tsconfig.json b/tsconfig.json index 95c19044a..b2930b5bf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,14 +9,15 @@ "forceConsistentCasingInFileNames": true, "moduleResolution": "node", "paths": { + "pdfjs-lib": ["./src/pdf"], "display-fetch_stream": ["./src/display/fetch_stream"], "display-l10n_utils": ["./web/l10n_utils"], "display-network": ["./src/display/network"], "display-node_stream": ["./src/display/node_stream"], "display-node_utils": ["./src/display/node_utils"], - "pdfjs-lib": ["./src/pdf"], "fluent-bundle": ["./node_modules/@fluent/bundle/esm/index.js"], - "fluent-dom": ["./node_modules/@fluent/dom/esm/index.js"] + "fluent-dom": ["./node_modules/@fluent/dom/esm/index.js"], + "web-l10n_utils": ["./web/l10n_utils"] } }, "files": [ diff --git a/web/annotation_editor_layer_builder.js b/web/annotation_editor_layer_builder.js index a6f1bbe08..3bc368cff 100644 --- a/web/annotation_editor_layer_builder.js +++ b/web/annotation_editor_layer_builder.js @@ -25,7 +25,7 @@ /** @typedef {import("../src/display/annotation_layer.js").AnnotationLayer} AnnotationLayer */ import { AnnotationEditorLayer } from "pdfjs-lib"; -import { NullL10n } from "./l10n_utils.js"; +import { NullL10n } from "web-l10n_utils"; /** * @typedef {Object} AnnotationEditorLayerBuilderOptions diff --git a/web/annotation_layer_builder.js b/web/annotation_layer_builder.js index f20a18204..43cb1d9c5 100644 --- a/web/annotation_layer_builder.js +++ b/web/annotation_layer_builder.js @@ -25,7 +25,7 @@ /** @typedef {import("./text_accessibility.js").TextAccessibilityManager} TextAccessibilityManager */ import { AnnotationLayer } from "pdfjs-lib"; -import { NullL10n } from "./l10n_utils.js"; +import { NullL10n } from "web-l10n_utils"; import { PresentationModeState } from "./ui_utils.js"; /** diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 24353a6e4..5768483cf 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -42,7 +42,7 @@ import { import { AnnotationEditorLayerBuilder } from "./annotation_editor_layer_builder.js"; import { AnnotationLayerBuilder } from "./annotation_layer_builder.js"; import { compatibilityParams } from "./app_options.js"; -import { NullL10n } from "./l10n_utils.js"; +import { NullL10n } from "web-l10n_utils"; import { SimpleLinkService } from "./pdf_link_service.js"; import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js"; import { TextAccessibilityManager } from "./text_accessibility.js"; diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 71e10f0bf..c56698045 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -63,7 +63,7 @@ import { VERTICAL_PADDING, watchScroll, } from "./ui_utils.js"; -import { NullL10n } from "./l10n_utils.js"; +import { NullL10n } from "web-l10n_utils"; import { PDFPageView } from "./pdf_page_view.js"; import { PDFRenderingQueue } from "./pdf_rendering_queue.js"; import { SimpleLinkService } from "./pdf_link_service.js"; diff --git a/web/stubs.js b/web/stubs.js new file mode 100644 index 000000000..333ab1a5e --- /dev/null +++ b/web/stubs.js @@ -0,0 +1,18 @@ +/* Copyright 2023 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const NullL10n = null; + +export { NullL10n }; diff --git a/web/viewer-geckoview.html b/web/viewer-geckoview.html index 59a312db7..927694887 100644 --- a/web/viewer-geckoview.html +++ b/web/viewer-geckoview.html @@ -62,6 +62,7 @@ See https://github.com/adobe-type-tools/cmap-resources "web-alt_text_manager": "./stubs-geckoview.js", "web-annotation_editor_params": "./stubs-geckoview.js", "web-com": "./genericcom.js", + "web-l10n_utils": "./l10n_utils.js", "web-pdf_attachment_viewer": "./stubs-geckoview.js", "web-pdf_cursor_tools": "./stubs-geckoview.js", "web-pdf_document_properties": "./stubs-geckoview.js", diff --git a/web/viewer.html b/web/viewer.html index 6d77da0f2..47d3929a5 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -71,6 +71,7 @@ See https://github.com/adobe-type-tools/cmap-resources "web-alt_text_manager": "./alt_text_manager.js", "web-annotation_editor_params": "./annotation_editor_params.js", "web-com": "./genericcom.js", + "web-l10n_utils": "./l10n_utils.js", "web-pdf_attachment_viewer": "./pdf_attachment_viewer.js", "web-pdf_cursor_tools": "./pdf_cursor_tools.js", "web-pdf_document_properties": "./pdf_document_properties.js",