mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move the isNodeJS
-helper into the src/shared/util.js
file
With the changes in the previous patch the `isNodeJS`-helper no longer needs to live in its own file, which helps get rid of a closure in the *built* files.
This commit is contained in:
parent
67303b16f1
commit
3a886e7264
19 changed files with 34 additions and 48 deletions
|
@ -19,6 +19,7 @@ import {
|
|||
getVerbosityLevel,
|
||||
info,
|
||||
InvalidPDFException,
|
||||
isNodeJS,
|
||||
MissingPDFException,
|
||||
PasswordException,
|
||||
PromiseCapability,
|
||||
|
@ -39,7 +40,6 @@ import { LocalPdfManager, NetworkPdfManager } from "./pdf_manager.js";
|
|||
import { AnnotationFactory } from "./annotation.js";
|
||||
import { clearGlobalCaches } from "./cleanup_helper.js";
|
||||
import { incrementalUpdate } from "./writer.js";
|
||||
import { isNodeJS } from "../shared/is_node.js";
|
||||
import { MessageHandler } from "../shared/message_handler.js";
|
||||
import { PDFWorkerStream } from "./worker_stream.js";
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
info,
|
||||
InvalidPDFException,
|
||||
isArrayBuffer,
|
||||
isNodeJS,
|
||||
MAX_IMAGE_SIZE_TO_CACHE,
|
||||
MissingPDFException,
|
||||
PasswordException,
|
||||
|
@ -59,7 +60,6 @@ import {
|
|||
import { FontFaceObject, FontLoader } from "./font_loader.js";
|
||||
import { CanvasGraphics } from "./canvas.js";
|
||||
import { GlobalWorkerOptions } from "./worker_options.js";
|
||||
import { isNodeJS } from "../shared/is_node.js";
|
||||
import { MessageHandler } from "../shared/message_handler.js";
|
||||
import { Metadata } from "./metadata.js";
|
||||
import { OptionalContentConfig } from "./optional_content_config.js";
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
IDENTITY_MATRIX,
|
||||
ImageKind,
|
||||
info,
|
||||
isNodeJS,
|
||||
OPS,
|
||||
shadow,
|
||||
TextRenderingMode,
|
||||
|
@ -37,7 +38,6 @@ import {
|
|||
TilingPattern,
|
||||
} from "./pattern_helper.js";
|
||||
import { convertBlackAndWhiteToRGBA } from "../shared/image_utils.js";
|
||||
import { isNodeJS } from "../shared/is_node.js";
|
||||
|
||||
// <canvas> contexts store most of the state we need natively.
|
||||
// However, PDF needs a bit more state, which we store here.
|
||||
|
|
|
@ -17,12 +17,12 @@ import {
|
|||
assert,
|
||||
bytesToString,
|
||||
FeatureTest,
|
||||
isNodeJS,
|
||||
shadow,
|
||||
string32,
|
||||
unreachable,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { isNodeJS } from "../shared/is_node.js";
|
||||
|
||||
class FontLoader {
|
||||
#systemFonts = new Set();
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
BaseFilterFactory,
|
||||
BaseStandardFontDataFactory,
|
||||
} from "./base_factory.js";
|
||||
import { isNodeJS } from "../shared/is_node.js";
|
||||
import { isNodeJS } from "../shared/util.js";
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error(
|
||||
|
|
|
@ -19,12 +19,12 @@ import {
|
|||
FONT_IDENTITY_MATRIX,
|
||||
IDENTITY_MATRIX,
|
||||
ImageKind,
|
||||
isNodeJS,
|
||||
OPS,
|
||||
TextRenderingMode,
|
||||
Util,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { isNodeJS } from "../shared/is_node.js";
|
||||
|
||||
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) {
|
||||
throw new Error(
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/* Copyright 2018 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.
|
||||
*/
|
||||
/* globals process */
|
||||
|
||||
// NW.js / Electron is a browser context, but copies some Node.js objects; see
|
||||
// http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
|
||||
// https://www.electronjs.org/docs/api/process#processversionselectron-readonly
|
||||
// https://www.electronjs.org/docs/api/process#processtype-readonly
|
||||
const isNodeJS =
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
typeof process === "object" &&
|
||||
process + "" === "[object process]" &&
|
||||
!process.versions.nw &&
|
||||
!(process.versions.electron && process.type && process.type !== "browser");
|
||||
|
||||
export { isNodeJS };
|
|
@ -12,6 +12,18 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals process */
|
||||
|
||||
// NW.js / Electron is a browser context, but copies some Node.js objects; see
|
||||
// http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
|
||||
// https://www.electronjs.org/docs/api/process#processversionselectron-readonly
|
||||
// https://www.electronjs.org/docs/api/process#processtype-readonly
|
||||
const isNodeJS =
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
typeof process === "object" &&
|
||||
process + "" === "[object process]" &&
|
||||
!process.versions.nw &&
|
||||
!(process.versions.electron && process.type && process.type !== "browser");
|
||||
|
||||
const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
|
||||
const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
|
||||
|
@ -1056,6 +1068,7 @@ export {
|
|||
InvalidPDFException,
|
||||
isArrayBuffer,
|
||||
isArrayEqual,
|
||||
isNodeJS,
|
||||
LINE_DESCENT_FACTOR,
|
||||
LINE_FACTOR,
|
||||
MAX_IMAGE_SIZE_TO_CACHE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue