From cf3a35e9daaa5a456109943b4cfc87c0471118b8 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 2 Jun 2023 14:41:27 +0200 Subject: [PATCH] Enable the `import/no-cycle` ESLint plugin rule Having cyclical imports is obviously not a good idea, and this ESLint plugin rule can help detect those; please see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md --- .eslintrc | 1 + src/core/xfa/bind.js | 6 +- src/core/xfa/builder.js | 4 +- src/core/xfa/config.js | 3 +- src/core/xfa/data.js | 2 +- src/core/xfa/datasets.js | 5 +- src/core/xfa/factory.js | 2 +- src/core/xfa/fonts.js | 2 +- src/core/xfa/html_utils.js | 4 +- src/core/xfa/layout.js | 2 +- src/core/xfa/parser.js | 2 +- src/core/xfa/som.js | 37 +---- src/core/xfa/symbol_utils.js | 156 ++++++++++++++++++ src/core/xfa/template.js | 16 +- src/core/xfa/xdp.js | 9 +- src/core/xfa/xfa_object.js | 229 +++++++++++---------------- src/core/xfa/xhtml.js | 4 +- src/scripting_api/app.js | 15 +- src/scripting_api/app_utils.js | 31 ++++ src/scripting_api/event.js | 7 +- test/unit/xfa_parser_spec.js | 2 +- test/unit/xfa_serialize_data_spec.js | 2 +- 22 files changed, 328 insertions(+), 213 deletions(-) create mode 100644 src/core/xfa/symbol_utils.js create mode 100644 src/scripting_api/app_utils.js diff --git a/.eslintrc b/.eslintrc index 142a09b0748d0..5eb9d7eaceffc 100644 --- a/.eslintrc +++ b/.eslintrc @@ -37,6 +37,7 @@ "import/extensions": ["error", "always", { "ignorePackages": true, }], "import/first": "error", "import/named": "error", + "import/no-cycle": "error", "import/no-empty-named-blocks": "error", "import/no-mutable-exports": "error", "import/no-self-import": "error", diff --git a/src/core/xfa/bind.js b/src/core/xfa/bind.js index f2331581509d4..3fb5087c7cd1e 100644 --- a/src/core/xfa/bind.js +++ b/src/core/xfa/bind.js @@ -36,12 +36,10 @@ import { $removeChild, $setValue, $text, - XFAAttribute, - XFAObjectArray, - XmlObject, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { BindItems, Field, Items, SetProperty, Text } from "./template.js"; import { createDataNode, searchNode } from "./som.js"; +import { XFAAttribute, XFAObjectArray, XmlObject } from "./xfa_object.js"; import { NamespaceIds } from "./namespaces.js"; import { warn } from "../../shared/util.js"; diff --git a/src/core/xfa/builder.js b/src/core/xfa/builder.js index f99ae6c58457b..48400c3e224ab 100644 --- a/src/core/xfa/builder.js +++ b/src/core/xfa/builder.js @@ -23,12 +23,12 @@ import { $onChild, $resolvePrototypes, $root, - XFAObject, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { NamespaceSetUp } from "./setup.js"; import { Template } from "./template.js"; import { UnknownNamespace } from "./unknown.js"; import { warn } from "../../shared/util.js"; +import { XFAObject } from "./xfa_object.js"; class Root extends XFAObject { constructor(ids) { diff --git a/src/core/xfa/config.js b/src/core/xfa/config.js index 75e55f8ecc5ea..aef9aa5ee6167 100644 --- a/src/core/xfa/config.js +++ b/src/core/xfa/config.js @@ -14,9 +14,8 @@ */ import { $buildXFAObject, NamespaceIds } from "./namespaces.js"; +import { $content, $finalize } from "./symbol_utils.js"; import { - $content, - $finalize, ContentObject, IntegerObject, Option01, diff --git a/src/core/xfa/data.js b/src/core/xfa/data.js index 1a6c543721c62..7cfb6da8c3ea6 100644 --- a/src/core/xfa/data.js +++ b/src/core/xfa/data.js @@ -20,7 +20,7 @@ import { $setValue, $toString, $uid, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; class DataHandler { constructor(root, data) { diff --git a/src/core/xfa/datasets.js b/src/core/xfa/datasets.js index aed3e2f6e17d0..644c92ed57ff5 100644 --- a/src/core/xfa/datasets.js +++ b/src/core/xfa/datasets.js @@ -19,10 +19,9 @@ import { $namespaceId, $nodeName, $onChild, - XFAObject, - XmlObject, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { $buildXFAObject, NamespaceIds } from "./namespaces.js"; +import { XFAObject, XmlObject } from "./xfa_object.js"; const DATASETS_NS_ID = NamespaceIds.datasets.id; diff --git a/src/core/xfa/factory.js b/src/core/xfa/factory.js index e2f49c2435fd6..7f9f4f28d5e31 100644 --- a/src/core/xfa/factory.js +++ b/src/core/xfa/factory.js @@ -20,7 +20,7 @@ import { $text, $toHTML, $toPages, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { Binder } from "./bind.js"; import { DataHandler } from "./data.js"; import { FontFinder } from "./fonts.js"; diff --git a/src/core/xfa/fonts.js b/src/core/xfa/fonts.js index b7bdebafce717..844e2362c1f6b 100644 --- a/src/core/xfa/fonts.js +++ b/src/core/xfa/fonts.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { $globalData } from "./xfa_object.js"; +import { $globalData } from "./symbol_utils.js"; import { stripQuotes } from "./utils.js"; import { warn } from "../../shared/util.js"; diff --git a/src/core/xfa/html_utils.js b/src/core/xfa/html_utils.js index daa8634816d8c..a03590ef387e0 100644 --- a/src/core/xfa/html_utils.js +++ b/src/core/xfa/html_utils.js @@ -24,12 +24,12 @@ import { $pushGlyphs, $text, $toStyle, - XFAObject, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { createValidAbsoluteUrl, warn } from "../../shared/util.js"; import { getMeasurement, stripQuotes } from "./utils.js"; import { selectFont } from "./fonts.js"; import { TextMeasure } from "./text.js"; +import { XFAObject } from "./xfa_object.js"; function measureToString(m) { if (typeof m === "string") { diff --git a/src/core/xfa/layout.js b/src/core/xfa/layout.js index 21989a0a0d96b..e3442a24de372 100644 --- a/src/core/xfa/layout.js +++ b/src/core/xfa/layout.js @@ -20,7 +20,7 @@ import { $getTemplateRoot, $isSplittable, $isThereMoreWidth, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { measureToString } from "./html_utils.js"; // Subform and ExclGroup have a layout so they share these functions. diff --git a/src/core/xfa/parser.js b/src/core/xfa/parser.js index 27c7d98adddea..8b6bdd6995834 100644 --- a/src/core/xfa/parser.js +++ b/src/core/xfa/parser.js @@ -24,7 +24,7 @@ import { $onChild, $onText, $setId, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { XMLParserBase, XMLParserErrorCode } from "../xml_parser.js"; import { Builder } from "./builder.js"; import { warn } from "../../shared/util.js"; diff --git a/src/core/xfa/som.js b/src/core/xfa/som.js index 02011b05aa744..9d1c7ebb3b10a 100644 --- a/src/core/xfa/som.js +++ b/src/core/xfa/som.js @@ -14,17 +14,11 @@ */ import { - $appendChild, $getChildren, $getChildrenByClass, $getChildrenByName, $getParent, - $namespaceId, - XFAObject, - XFAObjectArray, - XmlObject, -} from "./xfa_object.js"; -import { NamespaceIds } from "./namespaces.js"; +} from "./symbol_utils.js"; import { warn } from "../../shared/util.js"; const namePattern = /^[^.[]+/; @@ -58,7 +52,6 @@ const shortcuts = new Map([ ]); const somCache = new WeakMap(); -const NS_DATASETS = NamespaceIds.datasets.id; function parseIndex(index) { index = index.trim(); @@ -193,7 +186,7 @@ function searchNode( const { name, cacheName, operator, index } = parsed[i]; const nodes = []; for (const node of root) { - if (!(node instanceof XFAObject)) { + if (!node.isXFAObject) { continue; } @@ -218,7 +211,7 @@ function searchNode( break; case operators.dotHash: children = node[$getChildrenByClass](name); - if (children instanceof XFAObjectArray) { + if (children.isXFAObjectArray) { children = children.children; } else { children = [children]; @@ -265,20 +258,6 @@ function searchNode( return root; } -function createNodes(root, path) { - let node = null; - for (const { name, index } of path) { - for (let i = 0, ii = !isFinite(index) ? 0 : index; i <= ii; i++) { - const nsId = root[$namespaceId] === NS_DATASETS ? -1 : root[$namespaceId]; - node = new XmlObject(nsId, name); - root[$appendChild](node); - } - - root = node; - } - return node; -} - function createDataNode(root, container, expr) { const parsed = parseExpression(expr); if (!parsed) { @@ -302,7 +281,7 @@ function createDataNode(root, container, expr) { const { name, operator, index } = parsed[i]; if (!isFinite(index)) { parsed[i].index = 0; - return createNodes(root, parsed.slice(i)); + return root.createNodes(parsed.slice(i)); } let children; @@ -315,7 +294,7 @@ function createDataNode(root, container, expr) { break; case operators.dotHash: children = root[$getChildrenByClass](name); - if (children instanceof XFAObjectArray) { + if (children.isXFAObjectArray) { children = children.children; } else { children = [children]; @@ -326,19 +305,19 @@ function createDataNode(root, container, expr) { } if (children.length === 0) { - return createNodes(root, parsed.slice(i)); + return root.createNodes(parsed.slice(i)); } if (index < children.length) { const child = children[index]; - if (!(child instanceof XFAObject)) { + if (!child.isXFAObject) { warn(`XFA - Cannot create a node.`); return null; } root = child; } else { parsed[i].index = index - children.length; - return createNodes(root, parsed.slice(i)); + return root.createNodes(parsed.slice(i)); } } return null; diff --git a/src/core/xfa/symbol_utils.js b/src/core/xfa/symbol_utils.js new file mode 100644 index 0000000000000..fc4c267d03bb0 --- /dev/null +++ b/src/core/xfa/symbol_utils.js @@ -0,0 +1,156 @@ +/* Copyright 2021 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. + */ + +// We use these symbols to avoid name conflict between tags +// and properties/methods names. +const $acceptWhitespace = Symbol(); +const $addHTML = Symbol(); +const $appendChild = Symbol(); +const $childrenToHTML = Symbol(); +const $clean = Symbol(); +const $cleanPage = Symbol(); +const $cleanup = Symbol(); +const $clone = Symbol(); +const $consumed = Symbol(); +const $content = Symbol("content"); +const $data = Symbol("data"); +const $dump = Symbol(); +const $extra = Symbol("extra"); +const $finalize = Symbol(); +const $flushHTML = Symbol(); +const $getAttributeIt = Symbol(); +const $getAttributes = Symbol(); +const $getAvailableSpace = Symbol(); +const $getChildrenByClass = Symbol(); +const $getChildrenByName = Symbol(); +const $getChildrenByNameIt = Symbol(); +const $getDataValue = Symbol(); +const $getExtra = Symbol(); +const $getRealChildrenByNameIt = Symbol(); +const $getChildren = Symbol(); +const $getContainedChildren = Symbol(); +const $getNextPage = Symbol(); +const $getSubformParent = Symbol(); +const $getParent = Symbol(); +const $getTemplateRoot = Symbol(); +const $globalData = Symbol(); +const $hasSettableValue = Symbol(); +const $ids = Symbol(); +const $indexOf = Symbol(); +const $insertAt = Symbol(); +const $isCDATAXml = Symbol(); +const $isBindable = Symbol(); +const $isDataValue = Symbol(); +const $isDescendent = Symbol(); +const $isNsAgnostic = Symbol(); +const $isSplittable = Symbol(); +const $isThereMoreWidth = Symbol(); +const $isTransparent = Symbol(); +const $isUsable = Symbol(); +const $lastAttribute = Symbol(); +const $namespaceId = Symbol("namespaceId"); +const $nodeName = Symbol("nodeName"); +const $nsAttributes = Symbol(); +const $onChild = Symbol(); +const $onChildCheck = Symbol(); +const $onText = Symbol(); +const $pushGlyphs = Symbol(); +const $popPara = Symbol(); +const $pushPara = Symbol(); +const $removeChild = Symbol(); +const $root = Symbol("root"); +const $resolvePrototypes = Symbol(); +const $searchNode = Symbol(); +const $setId = Symbol(); +const $setSetAttributes = Symbol(); +const $setValue = Symbol(); +const $tabIndex = Symbol(); +const $text = Symbol(); +const $toPages = Symbol(); +const $toHTML = Symbol(); +const $toString = Symbol(); +const $toStyle = Symbol(); +const $uid = Symbol("uid"); + +export { + $acceptWhitespace, + $addHTML, + $appendChild, + $childrenToHTML, + $clean, + $cleanPage, + $cleanup, + $clone, + $consumed, + $content, + $data, + $dump, + $extra, + $finalize, + $flushHTML, + $getAttributeIt, + $getAttributes, + $getAvailableSpace, + $getChildren, + $getChildrenByClass, + $getChildrenByName, + $getChildrenByNameIt, + $getContainedChildren, + $getDataValue, + $getExtra, + $getNextPage, + $getParent, + $getRealChildrenByNameIt, + $getSubformParent, + $getTemplateRoot, + $globalData, + $hasSettableValue, + $ids, + $indexOf, + $insertAt, + $isBindable, + $isCDATAXml, + $isDataValue, + $isDescendent, + $isNsAgnostic, + $isSplittable, + $isThereMoreWidth, + $isTransparent, + $isUsable, + $lastAttribute, + $namespaceId, + $nodeName, + $nsAttributes, + $onChild, + $onChildCheck, + $onText, + $popPara, + $pushGlyphs, + $pushPara, + $removeChild, + $resolvePrototypes, + $root, + $searchNode, + $setId, + $setSetAttributes, + $setValue, + $tabIndex, + $text, + $toHTML, + $toPages, + $toString, + $toStyle, + $uid, +}; diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index c8e4e56be6dee..d48e7118ec451 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -58,13 +58,7 @@ import { $toPages, $toStyle, $uid, - ContentObject, - Option01, - OptionObject, - StringObject, - XFAObject, - XFAObjectArray, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { $buildXFAObject, NamespaceIds } from "./namespaces.js"; import { addHTML, @@ -88,6 +82,14 @@ import { setPara, toStyle, } from "./html_utils.js"; +import { + ContentObject, + Option01, + OptionObject, + StringObject, + XFAObject, + XFAObjectArray, +} from "./xfa_object.js"; import { getBBox, getColor, diff --git a/src/core/xfa/xdp.js b/src/core/xfa/xdp.js index a4e201b364248..f3968672b864b 100644 --- a/src/core/xfa/xdp.js +++ b/src/core/xfa/xdp.js @@ -14,13 +14,8 @@ */ import { $buildXFAObject, NamespaceIds } from "./namespaces.js"; -import { - $namespaceId, - $nodeName, - $onChildCheck, - XFAObject, - XFAObjectArray, -} from "./xfa_object.js"; +import { $namespaceId, $nodeName, $onChildCheck } from "./symbol_utils.js"; +import { XFAObject, XFAObjectArray } from "./xfa_object.js"; const XDP_NS_ID = NamespaceIds.xdp.id; diff --git a/src/core/xfa/xfa_object.js b/src/core/xfa/xfa_object.js index ee49d2b3c9a5a..65d73485501b3 100644 --- a/src/core/xfa/xfa_object.js +++ b/src/core/xfa/xfa_object.js @@ -13,83 +13,72 @@ * limitations under the License. */ +import { + $acceptWhitespace, + $addHTML, + $appendChild, + $childrenToHTML, + $clean, + $cleanup, + $clone, + $consumed, + $content, + $dump, + $extra, + $finalize, + $flushHTML, + $getAttributeIt, + $getAttributes, + $getAvailableSpace, + $getChildren, + $getChildrenByClass, + $getChildrenByName, + $getChildrenByNameIt, + $getContainedChildren, + $getDataValue, + $getParent, + $getRealChildrenByNameIt, + $getSubformParent, + $getTemplateRoot, + $globalData, + $hasSettableValue, + $indexOf, + $insertAt, + $isBindable, + $isCDATAXml, + $isDataValue, + $isDescendent, + $isNsAgnostic, + $isSplittable, + $isThereMoreWidth, + $isTransparent, + $lastAttribute, + $namespaceId, + $nodeName, + $nsAttributes, + $onChild, + $onChildCheck, + $onText, + $popPara, + $pushPara, + $removeChild, + $resolvePrototypes, + $root, + $setId, + $setSetAttributes, + $setValue, + $text, + $toHTML, + $toString, + $toStyle, + $uid, +} from "./symbol_utils.js"; import { getInteger, getKeyword, HTMLResult } from "./utils.js"; import { shadow, utf8StringToString, warn } from "../../shared/util.js"; import { encodeToXmlString } from "../core_utils.js"; import { NamespaceIds } from "./namespaces.js"; import { searchNode } from "./som.js"; -// We use these symbols to avoid name conflict between tags -// and properties/methods names. -const $acceptWhitespace = Symbol(); -const $addHTML = Symbol(); -const $appendChild = Symbol(); -const $childrenToHTML = Symbol(); -const $clean = Symbol(); -const $cleanPage = Symbol(); -const $cleanup = Symbol(); -const $clone = Symbol(); -const $consumed = Symbol(); -const $content = Symbol("content"); -const $data = Symbol("data"); -const $dump = Symbol(); -const $extra = Symbol("extra"); -const $finalize = Symbol(); -const $flushHTML = Symbol(); -const $getAttributeIt = Symbol(); -const $getAttributes = Symbol(); -const $getAvailableSpace = Symbol(); -const $getChildrenByClass = Symbol(); -const $getChildrenByName = Symbol(); -const $getChildrenByNameIt = Symbol(); -const $getDataValue = Symbol(); -const $getExtra = Symbol(); -const $getRealChildrenByNameIt = Symbol(); -const $getChildren = Symbol(); -const $getContainedChildren = Symbol(); -const $getNextPage = Symbol(); -const $getSubformParent = Symbol(); -const $getParent = Symbol(); -const $getTemplateRoot = Symbol(); -const $globalData = Symbol(); -const $hasSettableValue = Symbol(); -const $ids = Symbol(); -const $indexOf = Symbol(); -const $insertAt = Symbol(); -const $isCDATAXml = Symbol(); -const $isBindable = Symbol(); -const $isDataValue = Symbol(); -const $isDescendent = Symbol(); -const $isNsAgnostic = Symbol(); -const $isSplittable = Symbol(); -const $isThereMoreWidth = Symbol(); -const $isTransparent = Symbol(); -const $isUsable = Symbol(); -const $lastAttribute = Symbol(); -const $namespaceId = Symbol("namespaceId"); -const $nodeName = Symbol("nodeName"); -const $nsAttributes = Symbol(); -const $onChild = Symbol(); -const $onChildCheck = Symbol(); -const $onText = Symbol(); -const $pushGlyphs = Symbol(); -const $popPara = Symbol(); -const $pushPara = Symbol(); -const $removeChild = Symbol(); -const $root = Symbol("root"); -const $resolvePrototypes = Symbol(); -const $searchNode = Symbol(); -const $setId = Symbol(); -const $setSetAttributes = Symbol(); -const $setValue = Symbol(); -const $tabIndex = Symbol(); -const $text = Symbol(); -const $toPages = Symbol(); -const $toHTML = Symbol(); -const $toString = Symbol(); -const $toStyle = Symbol(); -const $uid = Symbol("uid"); - const _applyPrototype = Symbol(); const _attributes = Symbol(); const _attributeNames = Symbol(); @@ -123,6 +112,29 @@ class XFAObject { this[$globalData] = null; } + get isXFAObject() { + return true; + } + + get isXFAObjectArray() { + return false; + } + + createNodes(path) { + let root = this, + node = null; + for (const { name, index } of path) { + for (let i = 0, ii = isFinite(index) ? index : 0; i <= ii; i++) { + const nsId = + root[$namespaceId] === NS_DATASETS ? -1 : root[$namespaceId]; + node = new XmlObject(nsId, name); + root[$appendChild](node); + } + root = node; + } + return node; + } + [$onChild](child) { if (!this[_hasChildren] || !this[$onChildCheck](child)) { return false; @@ -715,6 +727,14 @@ class XFAObjectArray { this[_children] = []; } + get isXFAObject() { + return false; + } + + get isXFAObjectArray() { + return true; + } + push(child) { const len = this[_children].length; if (len <= this[_max]) { @@ -1077,73 +1097,6 @@ class Option10 extends IntegerObject { } export { - $acceptWhitespace, - $addHTML, - $appendChild, - $childrenToHTML, - $clean, - $cleanPage, - $cleanup, - $clone, - $consumed, - $content, - $data, - $dump, - $extra, - $finalize, - $flushHTML, - $getAttributeIt, - $getAttributes, - $getAvailableSpace, - $getChildren, - $getChildrenByClass, - $getChildrenByName, - $getChildrenByNameIt, - $getContainedChildren, - $getDataValue, - $getExtra, - $getNextPage, - $getParent, - $getRealChildrenByNameIt, - $getSubformParent, - $getTemplateRoot, - $globalData, - $hasSettableValue, - $ids, - $indexOf, - $insertAt, - $isBindable, - $isCDATAXml, - $isDataValue, - $isDescendent, - $isNsAgnostic, - $isSplittable, - $isThereMoreWidth, - $isTransparent, - $isUsable, - $namespaceId, - $nodeName, - $nsAttributes, - $onChild, - $onChildCheck, - $onText, - $popPara, - $pushGlyphs, - $pushPara, - $removeChild, - $resolvePrototypes, - $root, - $searchNode, - $setId, - $setSetAttributes, - $setValue, - $tabIndex, - $text, - $toHTML, - $toPages, - $toString, - $toStyle, - $uid, ContentObject, IntegerObject, Option01, diff --git a/src/core/xfa/xhtml.js b/src/core/xfa/xhtml.js index 686b36ae39146..aff02378b6171 100644 --- a/src/core/xfa/xhtml.js +++ b/src/core/xfa/xhtml.js @@ -27,8 +27,7 @@ import { $pushGlyphs, $text, $toHTML, - XmlObject, -} from "./xfa_object.js"; +} from "./symbol_utils.js"; import { $buildXFAObject, NamespaceIds } from "./namespaces.js"; import { fixTextIndent, @@ -37,6 +36,7 @@ import { setFontFamily, } from "./html_utils.js"; import { getMeasurement, HTMLResult, stripQuotes } from "./utils.js"; +import { XmlObject } from "./xfa_object.js"; const XHTML_NS_ID = NamespaceIds.xhtml.id; const $richText = Symbol(); diff --git a/src/scripting_api/app.js b/src/scripting_api/app.js index 2b2a14308428a..acf1a7e228b21 100644 --- a/src/scripting_api/app.js +++ b/src/scripting_api/app.js @@ -13,18 +13,19 @@ * limitations under the License. */ +import { + FORMS_VERSION, + USERACTIVATION_CALLBACKID, + VIEWER_TYPE, + VIEWER_VARIATION, + VIEWER_VERSION, +} from "./app_utils.js"; import { Color } from "./color.js"; import { EventDispatcher } from "./event.js"; import { FullScreen } from "./fullscreen.js"; import { PDFObject } from "./pdf_object.js"; import { Thermometer } from "./thermometer.js"; -const VIEWER_TYPE = "PDF.js"; -const VIEWER_VARIATION = "Full"; -const VIEWER_VERSION = 21.00720099; -const FORMS_VERSION = 21.00720099; -const USERACTIVATION_CALLBACKID = 0; - class App extends PDFObject { constructor(data) { super(data); @@ -654,4 +655,4 @@ class App extends PDFObject { } } -export { App, USERACTIVATION_CALLBACKID }; +export { App }; diff --git a/src/scripting_api/app_utils.js b/src/scripting_api/app_utils.js new file mode 100644 index 0000000000000..d9a727a657bb0 --- /dev/null +++ b/src/scripting_api/app_utils.js @@ -0,0 +1,31 @@ +/* Copyright 2020 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 VIEWER_TYPE = "PDF.js"; +const VIEWER_VARIATION = "Full"; +const VIEWER_VERSION = 21.00720099; +const FORMS_VERSION = 21.00720099; + +const USERACTIVATION_CALLBACKID = 0; +const USERACTIVATION_MAXTIME_VALIDITY = 5000; + +export { + FORMS_VERSION, + USERACTIVATION_CALLBACKID, + USERACTIVATION_MAXTIME_VALIDITY, + VIEWER_TYPE, + VIEWER_VARIATION, + VIEWER_VERSION, +}; diff --git a/src/scripting_api/event.js b/src/scripting_api/event.js index 3549fa0e24091..20be536578355 100644 --- a/src/scripting_api/event.js +++ b/src/scripting_api/event.js @@ -13,9 +13,10 @@ * limitations under the License. */ -import { USERACTIVATION_CALLBACKID } from "./app.js"; - -const USERACTIVATION_MAXTIME_VALIDITY = 5000; +import { + USERACTIVATION_CALLBACKID, + USERACTIVATION_MAXTIME_VALIDITY, +} from "./app_utils.js"; class Event { constructor(data) { diff --git a/test/unit/xfa_parser_spec.js b/test/unit/xfa_parser_spec.js index 5e5aa43e43cd3..11e2036c2ba74 100644 --- a/test/unit/xfa_parser_spec.js +++ b/test/unit/xfa_parser_spec.js @@ -19,7 +19,7 @@ import { $getChildrenByClass, $getChildrenByName, $text, -} from "../../src/core/xfa/xfa_object.js"; +} from "../../src/core/xfa/symbol_utils.js"; import { Binder } from "../../src/core/xfa/bind.js"; import { searchNode } from "../../src/core/xfa/som.js"; import { XFAParser } from "../../src/core/xfa/parser.js"; diff --git a/test/unit/xfa_serialize_data_spec.js b/test/unit/xfa_serialize_data_spec.js index faeaf4c84a303..9a0d0974cd0d4 100644 --- a/test/unit/xfa_serialize_data_spec.js +++ b/test/unit/xfa_serialize_data_spec.js @@ -13,7 +13,7 @@ * limitations under the License. */ -import { $uid } from "../../src/core/xfa/xfa_object.js"; +import { $uid } from "../../src/core/xfa/symbol_utils.js"; import { DataHandler } from "../../src/core/xfa/data.js"; import { searchNode } from "../../src/core/xfa/som.js"; import { XFAParser } from "../../src/core/xfa/parser.js";