Merge pull request #16543 from Snuffleupagus/limit-more-to-GENERIC
Limit more code to GENERIC builds
This commit is contained in:
		
						commit
						a37f7d2477
					
				| @ -1552,6 +1552,9 @@ class PDFPageProxy { | |||||||
|     annotationMode = AnnotationMode.ENABLE, |     annotationMode = AnnotationMode.ENABLE, | ||||||
|     printAnnotationStorage = null, |     printAnnotationStorage = null, | ||||||
|   } = {}) { |   } = {}) { | ||||||
|  |     if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) { | ||||||
|  |       throw new Error("Not implemented: getOperatorList"); | ||||||
|  |     } | ||||||
|     function operatorListChanged() { |     function operatorListChanged() { | ||||||
|       if (intentState.operatorList.lastChunk) { |       if (intentState.operatorList.lastChunk) { | ||||||
|         intentState.opListReadCapability.resolve(intentState.operatorList); |         intentState.opListReadCapability.resolve(intentState.operatorList); | ||||||
|  | |||||||
| @ -21,21 +21,17 @@ import { | |||||||
|   ImageKind, |   ImageKind, | ||||||
|   OPS, |   OPS, | ||||||
|   TextRenderingMode, |   TextRenderingMode, | ||||||
|   unreachable, |  | ||||||
|   Util, |   Util, | ||||||
|   warn, |   warn, | ||||||
| } from "../shared/util.js"; | } from "../shared/util.js"; | ||||||
| import { isNodeJS } from "../shared/is_node.js"; | import { isNodeJS } from "../shared/is_node.js"; | ||||||
| 
 | 
 | ||||||
| /** @type {any} */ | if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) { | ||||||
| // eslint-disable-next-line import/no-mutable-exports
 |   throw new Error( | ||||||
| let SVGGraphics = class { |     'Module "SVGGraphics" shall not be used outside GENERIC builds.' | ||||||
|   constructor() { |   ); | ||||||
|     unreachable("Not implemented: SVGGraphics"); |  | ||||||
| } | } | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { |  | ||||||
| const SVG_DEFAULTS = { | const SVG_DEFAULTS = { | ||||||
|   fontStyle: "normal", |   fontStyle: "normal", | ||||||
|   fontWeight: "normal", |   fontWeight: "normal", | ||||||
| @ -51,11 +47,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|   contentType = "", |   contentType = "", | ||||||
|   forceDataSchema = false |   forceDataSchema = false | ||||||
| ) { | ) { | ||||||
|     if ( |   if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) { | ||||||
|       URL.createObjectURL && |  | ||||||
|       typeof Blob !== "undefined" && |  | ||||||
|       !forceDataSchema |  | ||||||
|     ) { |  | ||||||
|     return URL.createObjectURL(new Blob([data], { type: contentType })); |     return URL.createObjectURL(new Blob([data], { type: contentType })); | ||||||
|   } |   } | ||||||
|   // Blob/createObjectURL is not available, falling back to data schema.
 |   // Blob/createObjectURL is not available, falling back to data schema.
 | ||||||
| @ -177,9 +169,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|       }); |       }); | ||||||
|       return output instanceof Uint8Array ? output : new Uint8Array(output); |       return output instanceof Uint8Array ? output : new Uint8Array(output); | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|         warn( |       warn("Not compressing PNG because zlib.deflateSync is unavailable: " + e); | ||||||
|           "Not compressing PNG because zlib.deflateSync is unavailable: " + e |  | ||||||
|         ); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return deflateSyncUncompressed(literals); |     return deflateSyncUncompressed(literals); | ||||||
| @ -378,7 +368,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|   // eslint-disable-next-line no-inner-declarations
 |  | ||||||
| function opListToTree(opList) { | function opListToTree(opList) { | ||||||
|   let opTree = []; |   let opTree = []; | ||||||
|   const tmp = []; |   const tmp = []; | ||||||
| @ -406,7 +395,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|  * @param value {number} - The float number to format. |  * @param value {number} - The float number to format. | ||||||
|  * @returns {string} |  * @returns {string} | ||||||
|  */ |  */ | ||||||
|   // eslint-disable-next-line no-inner-declarations
 |  | ||||||
| function pf(value) { | function pf(value) { | ||||||
|   if (Number.isInteger(value)) { |   if (Number.isInteger(value)) { | ||||||
|     return value.toString(); |     return value.toString(); | ||||||
| @ -432,7 +420,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|  * @param m {Array} - The transform matrix to format. |  * @param m {Array} - The transform matrix to format. | ||||||
|  * @returns {string} |  * @returns {string} | ||||||
|  */ |  */ | ||||||
|   // eslint-disable-next-line no-inner-declarations
 |  | ||||||
| function pm(m) { | function pm(m) { | ||||||
|   if (m[4] === 0 && m[5] === 0) { |   if (m[4] === 0 && m[5] === 0) { | ||||||
|     if (m[1] === 0 && m[2] === 0) { |     if (m[1] === 0 && m[2] === 0) { | ||||||
| @ -463,7 +450,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
| let maskCount = 0; | let maskCount = 0; | ||||||
| let shadingCount = 0; | let shadingCount = 0; | ||||||
| 
 | 
 | ||||||
|   SVGGraphics = class { | class SVGGraphics { | ||||||
|   constructor(commonObjs, objs, forceDataSchema = false) { |   constructor(commonObjs, objs, forceDataSchema = false) { | ||||||
|     deprecated( |     deprecated( | ||||||
|       "The SVG back-end is no longer maintained and *may* be removed in the future." |       "The SVG back-end is no longer maintained and *may* be removed in the future." | ||||||
| @ -731,14 +718,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|           this.nextLine(); |           this.nextLine(); | ||||||
|           break; |           break; | ||||||
|         case OPS.transform: |         case OPS.transform: | ||||||
|             this.transform( |           this.transform(args[0], args[1], args[2], args[3], args[4], args[5]); | ||||||
|               args[0], |  | ||||||
|               args[1], |  | ||||||
|               args[2], |  | ||||||
|               args[3], |  | ||||||
|               args[4], |  | ||||||
|               args[5] |  | ||||||
|             ); |  | ||||||
|           break; |           break; | ||||||
|         case OPS.constructPath: |         case OPS.constructPath: | ||||||
|           this.constructPath(args[0], args[1]); |           this.constructPath(args[0], args[1]); | ||||||
| @ -892,11 +872,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
| 
 | 
 | ||||||
|       x += charWidth; |       x += charWidth; | ||||||
|     } |     } | ||||||
|       current.tspan.setAttributeNS( |     current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" ")); | ||||||
|         null, |  | ||||||
|         "x", |  | ||||||
|         current.xcoords.map(pf).join(" ") |  | ||||||
|       ); |  | ||||||
|     if (vertical) { |     if (vertical) { | ||||||
|       current.tspan.setAttributeNS( |       current.tspan.setAttributeNS( | ||||||
|         null, |         null, | ||||||
| @ -1328,15 +1304,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|         case OPS.curveTo3: |         case OPS.curveTo3: | ||||||
|           x = args[j + 2]; |           x = args[j + 2]; | ||||||
|           y = args[j + 3]; |           y = args[j + 3]; | ||||||
|             d.push( |           d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y)); | ||||||
|               "C", |  | ||||||
|               pf(args[j]), |  | ||||||
|               pf(args[j + 1]), |  | ||||||
|               pf(x), |  | ||||||
|               pf(y), |  | ||||||
|               pf(x), |  | ||||||
|               pf(y) |  | ||||||
|             ); |  | ||||||
|           j += 4; |           j += 4; | ||||||
|           break; |           break; | ||||||
|         case OPS.closePath: |         case OPS.closePath: | ||||||
| @ -1741,7 +1709,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { | |||||||
|     } |     } | ||||||
|     return this.tgrp; |     return this.tgrp; | ||||||
|   } |   } | ||||||
|   }; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export { SVGGraphics }; | export { SVGGraphics }; | ||||||
|  | |||||||
| @ -69,7 +69,6 @@ import { AnnotationEditorLayer } from "./display/editor/annotation_editor_layer. | |||||||
| import { AnnotationEditorUIManager } from "./display/editor/tools.js"; | import { AnnotationEditorUIManager } from "./display/editor/tools.js"; | ||||||
| import { AnnotationLayer } from "./display/annotation_layer.js"; | import { AnnotationLayer } from "./display/annotation_layer.js"; | ||||||
| import { GlobalWorkerOptions } from "./display/worker_options.js"; | import { GlobalWorkerOptions } from "./display/worker_options.js"; | ||||||
| import { SVGGraphics } from "./display/svg.js"; |  | ||||||
| import { XfaLayer } from "./display/xfa_layer.js"; | import { XfaLayer } from "./display/xfa_layer.js"; | ||||||
| 
 | 
 | ||||||
| /* eslint-disable-next-line no-unused-vars */ | /* eslint-disable-next-line no-unused-vars */ | ||||||
| @ -79,6 +78,11 @@ const pdfjsVersion = | |||||||
| const pdfjsBuild = | const pdfjsBuild = | ||||||
|   typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0; |   typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0; | ||||||
| 
 | 
 | ||||||
|  | const SVGGraphics = | ||||||
|  |   typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC") | ||||||
|  |     ? require("./display/svg.js").SVGGraphics | ||||||
|  |     : null; | ||||||
|  | 
 | ||||||
| export { | export { | ||||||
|   AbortException, |   AbortException, | ||||||
|   AnnotationEditorLayer, |   AnnotationEditorLayer, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user