import RBush from 'rbush/rbush.js'; export { default as RBush } from 'rbush/rbush.js'; import { isNumber, distanceSquareRoot, getTotalLength, clamp, min, max, isNumberEqual, mod, isString, isNil, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isBoolean, isObject, isUndefined, getPointAtLength } from '@antv/util'; import { color } from 'd3-color'; import { vec3, mat3, mat4, vec4, quat as quat$1, vec2 } from 'gl-matrix'; import { Arc, Cubic, Quad, Polyline as Polyline$1, Line as Line$1 } from '@antv/g-math'; import EventEmitter from 'eventemitter3'; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type */ var PropertySyntax; (function (PropertySyntax) { /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate */ PropertySyntax["COORDINATE"] = ""; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color */ PropertySyntax["COLOR"] = ""; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint */ PropertySyntax["PAINT"] = ""; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number */ PropertySyntax["NUMBER"] = ""; /** * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle */ PropertySyntax["ANGLE"] = ""; /** * with range 0..1 * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value */ PropertySyntax["OPACITY_VALUE"] = ""; /** * with range 0..Infinity */ PropertySyntax["SHADOW_BLUR"] = ""; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length */ PropertySyntax["LENGTH"] = ""; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage */ PropertySyntax["PERCENTAGE"] = ""; PropertySyntax["LENGTH_PERCENTAGE"] = " | "; PropertySyntax["LENGTH_PERCENTAGE_12"] = "[ | ]{1,2}"; /** * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax */ PropertySyntax["LENGTH_PERCENTAGE_14"] = "[ | ]{1,4}"; /** * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts */ PropertySyntax["LIST_OF_POINTS"] = ""; PropertySyntax["PATH"] = ""; /** * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax */ PropertySyntax["FILTER"] = ""; PropertySyntax["Z_INDEX"] = ""; PropertySyntax["OFFSET_DISTANCE"] = ""; PropertySyntax["DEFINED_PATH"] = ""; PropertySyntax["MARKER"] = ""; PropertySyntax["TRANSFORM"] = ""; PropertySyntax["TRANSFORM_ORIGIN"] = ""; PropertySyntax["TEXT"] = ""; PropertySyntax["TEXT_TRANSFORM"] = ""; })(PropertySyntax || (PropertySyntax = {})); function _regeneratorRuntime() { _regeneratorRuntime = function () { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function (obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function (skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function () { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function (exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function (type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function (record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function (finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function (tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function (iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } // These units are iterated through, so be careful when adding or changing the // order. var UnitType; (function (UnitType) { UnitType[UnitType["kUnknown"] = 0] = "kUnknown"; UnitType[UnitType["kNumber"] = 1] = "kNumber"; UnitType[UnitType["kPercentage"] = 2] = "kPercentage"; // Length units UnitType[UnitType["kEms"] = 3] = "kEms"; // kExs, UnitType[UnitType["kPixels"] = 4] = "kPixels"; // kCentimeters, // kMillimeters, // kInches, // kPoints, // kPicas, // kQuarterMillimeters, // https://drafts.csswg.org/css-values-4/#viewport-relative-lengths // // See also IsViewportPercentageLength. // kViewportWidth, // kViewportHeight, // kViewportInlineSize, // kViewportBlockSize, // kViewportMin, // kViewportMax, // kSmallViewportWidth, // kSmallViewportHeight, // kSmallViewportInlineSize, // kSmallViewportBlockSize, // kSmallViewportMin, // kSmallViewportMax, // kLargeViewportWidth, // kLargeViewportHeight, // kLargeViewportInlineSize, // kLargeViewportBlockSize, // kLargeViewportMin, // kLargeViewportMax, // kDynamicViewportWidth, // kDynamicViewportHeight, // kDynamicViewportInlineSize, // kDynamicViewportBlockSize, // kDynamicViewportMin, // kDynamicViewportMax, // https://drafts.csswg.org/css-contain-3/#container-lengths // // See also IsContainerPercentageLength. // kContainerWidth, // kContainerHeight, // kContainerInlineSize, // kContainerBlockSize, // kContainerMin, // kContainerMax, UnitType[UnitType["kRems"] = 5] = "kRems"; // kChs, // kUserUnits, // The SVG term for unitless lengths // Angle units UnitType[UnitType["kDegrees"] = 6] = "kDegrees"; UnitType[UnitType["kRadians"] = 7] = "kRadians"; UnitType[UnitType["kGradians"] = 8] = "kGradians"; UnitType[UnitType["kTurns"] = 9] = "kTurns"; // Time units UnitType[UnitType["kMilliseconds"] = 10] = "kMilliseconds"; UnitType[UnitType["kSeconds"] = 11] = "kSeconds"; // kHertz, // kKilohertz, // Resolution // kDotsPerPixel, // kDotsPerInch, // kDotsPerCentimeter, // Other units // kFraction, UnitType[UnitType["kInteger"] = 12] = "kInteger"; // This value is used to handle quirky margins in reflow roots (body, td, // and th) like WinIE. The basic idea is that a stylesheet can use the value // __qem (for quirky em) instead of em. When the quirky value is used, if // you're in quirks mode, the margin will collapse away inside a table cell. // This quirk is specified in the HTML spec but our impl is different. // TODO: Remove this. crbug.com/443952 // kQuirkyEms, })(UnitType || (UnitType = {})); var UnitCategory; (function (UnitCategory) { UnitCategory[UnitCategory["kUNumber"] = 0] = "kUNumber"; UnitCategory[UnitCategory["kUPercent"] = 1] = "kUPercent"; UnitCategory[UnitCategory["kULength"] = 2] = "kULength"; UnitCategory[UnitCategory["kUAngle"] = 3] = "kUAngle"; UnitCategory[UnitCategory["kUTime"] = 4] = "kUTime"; // kUFrequency, // kUResolution, UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther"; })(UnitCategory || (UnitCategory = {})); var ValueRange; (function (ValueRange) { ValueRange[ValueRange["kAll"] = 0] = "kAll"; ValueRange[ValueRange["kNonNegative"] = 1] = "kNonNegative"; ValueRange[ValueRange["kInteger"] = 2] = "kInteger"; ValueRange[ValueRange["kNonNegativeInteger"] = 3] = "kNonNegativeInteger"; ValueRange[ValueRange["kPositiveInteger"] = 4] = "kPositiveInteger"; })(ValueRange || (ValueRange = {})); var Nested; (function (Nested) { Nested[Nested["kYes"] = 0] = "kYes"; Nested[Nested["kNo"] = 1] = "kNo"; })(Nested || (Nested = {})); var ParenLess; (function (ParenLess) { ParenLess[ParenLess["kYes"] = 0] = "kYes"; ParenLess[ParenLess["kNo"] = 1] = "kNo"; })(ParenLess || (ParenLess = {})); // This file specifies the unit strings used in CSSPrimitiveValues. var data = [{ name: 'em', unit_type: UnitType.kEms }, // { // name: 'ex', // unit_type: UnitType.kExs, // }, { name: 'px', unit_type: UnitType.kPixels }, // { // name: "cm", // unit_type: UnitType.kCentimeters, // }, // { // name: "mm", // unit_type: UnitType.kMillimeters, // }, // { // name: "q", // unit_type: UnitType.kQuarterMillimeters, // }, // { // name: "in", // unit_type: UnitType.kInches, // }, // { // name: "pt", // unit_type: UnitType.kPoints, // }, // { // name: "pc", // unit_type: UnitType.kPicas, // }, { name: 'deg', unit_type: UnitType.kDegrees }, { name: 'rad', unit_type: UnitType.kRadians }, { name: 'grad', unit_type: UnitType.kGradians }, { name: 'ms', unit_type: UnitType.kMilliseconds }, { name: 's', unit_type: UnitType.kSeconds }, // { // name: "hz", // unit_type: UnitType.kHertz, // }, // { // name: "khz", // unit_type: UnitType.kKilohertz, // }, // { // name: "dpi", // unit_type: "kDotsPerInch", // }, // { // name: "dpcm", // unit_type: "kDotsPerCentimeter", // }, // { // name: "dppx", // unit_type: "kDotsPerPixel", // }, // { // name: "x", // unit_type: "kDotsPerPixel", // }, // { // name: "vw", // unit_type: "kViewportWidth", // }, // { // name: "vh", // unit_type: "kViewportHeight", // }, // { // name: "vi", // unit_type: "kViewportInlineSize", // }, // { // name: "vb", // unit_type: "kViewportBlockSize", // }, // { // name: "vmin", // unit_type: UnitType.kViewportMin, // }, // { // name: "vmax", // unit_type: UnitType.kViewportMax, // }, // { // name: "svw", // unit_type: "kSmallViewportWidth", // }, // { // name: "svh", // unit_type: "kSmallViewportHeight", // }, // { // name: "svi", // unit_type: "kSmallViewportInlineSize", // }, // { // name: "svb", // unit_type: "kSmallViewportBlockSize", // }, // { // name: "svmin", // unit_type: "kSmallViewportMin", // }, // { // name: "svmax", // unit_type: "kSmallViewportMax", // }, // { // name: "lvw", // unit_type: "kLargeViewportWidth", // }, // { // name: "lvh", // unit_type: "kLargeViewportHeight", // }, // { // name: "lvi", // unit_type: "kLargeViewportInlineSize", // }, // { // name: "lvb", // unit_type: "kLargeViewportBlockSize", // }, // { // name: "lvmin", // unit_type: UnitType.kLargeViewportMin, // }, // { // name: "lvmax", // unit_type: UnitType.kLargeViewportMax, // }, // { // name: "dvw", // unit_type: UnitType.kDynamicViewportWidth, // }, // { // name: "dvh", // unit_type: UnitType.kDynamicViewportHeight, // }, // { // name: "dvi", // unit_type: UnitType.kDynamicViewportInlineSize, // }, // { // name: "dvb", // unit_type: UnitType.kDynamicViewportBlockSize, // }, // { // name: "dvmin", // unit_type: UnitType.kDynamicViewportMin, // }, // { // name: "dvmax", // unit_type: UnitType.kDynamicViewportMax, // }, // { // name: "cqw", // unit_type: UnitType.kContainerWidth, // }, // { // name: "cqh", // unit_type: UnitType.kContainerHeight, // }, // { // name: "cqi", // unit_type: UnitType.kContainerInlineSize, // }, // { // name: "cqb", // unit_type: UnitType.kContainerBlockSize, // }, // { // name: "cqmin", // unit_type: UnitType.kContainerMin, // }, // { // name: "cqmax", // unit_type: UnitType.kContainerMax, // }, { name: 'rem', unit_type: UnitType.kRems }, // { // name: 'fr', // unit_type: UnitType.kFraction, // }, { name: 'turn', unit_type: UnitType.kTurns } // { // name: 'ch', // unit_type: UnitType.kChs, // }, // { // name: '__qem', // unit_type: UnitType.kQuirkyEms, // }, ]; var CSSStyleValueType; (function (CSSStyleValueType) { CSSStyleValueType[CSSStyleValueType["kUnknownType"] = 0] = "kUnknownType"; CSSStyleValueType[CSSStyleValueType["kUnparsedType"] = 1] = "kUnparsedType"; CSSStyleValueType[CSSStyleValueType["kKeywordType"] = 2] = "kKeywordType"; // Start of CSSNumericValue subclasses CSSStyleValueType[CSSStyleValueType["kUnitType"] = 3] = "kUnitType"; CSSStyleValueType[CSSStyleValueType["kSumType"] = 4] = "kSumType"; CSSStyleValueType[CSSStyleValueType["kProductType"] = 5] = "kProductType"; CSSStyleValueType[CSSStyleValueType["kNegateType"] = 6] = "kNegateType"; CSSStyleValueType[CSSStyleValueType["kInvertType"] = 7] = "kInvertType"; CSSStyleValueType[CSSStyleValueType["kMinType"] = 8] = "kMinType"; CSSStyleValueType[CSSStyleValueType["kMaxType"] = 9] = "kMaxType"; CSSStyleValueType[CSSStyleValueType["kClampType"] = 10] = "kClampType"; // End of CSSNumericValue subclasses CSSStyleValueType[CSSStyleValueType["kTransformType"] = 11] = "kTransformType"; CSSStyleValueType[CSSStyleValueType["kPositionType"] = 12] = "kPositionType"; CSSStyleValueType[CSSStyleValueType["kURLImageType"] = 13] = "kURLImageType"; CSSStyleValueType[CSSStyleValueType["kColorType"] = 14] = "kColorType"; CSSStyleValueType[CSSStyleValueType["kUnsupportedColorType"] = 15] = "kUnsupportedColorType"; })(CSSStyleValueType || (CSSStyleValueType = {})); // function parseCSSStyleValue(propertyName: string, value: string): CSSStyleValue[] { // // const propertyId = cssPropertyID(propertyName); // // if (propertyId === CSSPropertyID.kInvalid) { // // return []; // // } // // const customPropertyName = propertyId === CSSPropertyID.kVariable ? propertyName : null; // // return fromString(propertyId, customPropertyName, value); // return []; // } var stringToUnitType = function stringToUnitType(name) { return data.find(function (item) { return item.name === name; }).unit_type; }; var unitFromName = function unitFromName(name) { if (!name) { return UnitType.kUnknown; } if (name === 'number') { return UnitType.kNumber; } if (name === 'percent' || name === '%') { return UnitType.kPercentage; } return stringToUnitType(name); }; var unitTypeToUnitCategory = function unitTypeToUnitCategory(type) { switch (type) { case UnitType.kNumber: case UnitType.kInteger: return UnitCategory.kUNumber; case UnitType.kPercentage: return UnitCategory.kUPercent; case UnitType.kPixels: // case UnitType.kCentimeters: // case UnitType.kMillimeters: // case UnitType.kQuarterMillimeters: // case UnitType.kInches: // case UnitType.kPoints: // case UnitType.kPicas: // case UnitType.kUserUnits: return UnitCategory.kULength; case UnitType.kMilliseconds: case UnitType.kSeconds: return UnitCategory.kUTime; case UnitType.kDegrees: case UnitType.kRadians: case UnitType.kGradians: case UnitType.kTurns: return UnitCategory.kUAngle; // case UnitType.kHertz: // case UnitType.kKilohertz: // return UnitCategory.kUFrequency; // case UnitType.kDotsPerPixel: // case UnitType.kDotsPerInch: // case UnitType.kDotsPerCentimeter: // return UnitCategory.kUResolution; default: return UnitCategory.kUOther; } }; var canonicalUnitTypeForCategory = function canonicalUnitTypeForCategory(category) { // The canonical unit type is chosen according to the way // CSSPropertyParser.ValidUnit() chooses the default unit in each category // (based on unitflags). switch (category) { case UnitCategory.kUNumber: return UnitType.kNumber; case UnitCategory.kULength: return UnitType.kPixels; case UnitCategory.kUPercent: return UnitType.kPercentage; // return UnitType.kUnknown; // Cannot convert between numbers and percent. case UnitCategory.kUTime: return UnitType.kSeconds; case UnitCategory.kUAngle: return UnitType.kDegrees; // case UnitCategory.kUFrequency: // return UnitType.kHertz; // case UnitCategory.kUResolution: // return UnitType.kDotsPerPixel; default: return UnitType.kUnknown; } }; /** * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/css_primitive_value.cc#353 */ var conversionToCanonicalUnitsScaleFactor = function conversionToCanonicalUnitsScaleFactor(unit_type) { var factor = 1.0; // FIXME: the switch can be replaced by an array of scale factors. switch (unit_type) { // These are "canonical" units in their respective categories. case UnitType.kPixels: // case UnitType.kUserUnits: case UnitType.kDegrees: case UnitType.kSeconds: // case UnitType.kHertz: break; case UnitType.kMilliseconds: factor = 0.001; break; // case UnitType.kCentimeters: // // factor = kCssPixelsPerCentimeter; // break; // case UnitType.kDotsPerCentimeter: // // factor = 1 / kCssPixelsPerCentimeter; // break; // case UnitType.kMillimeters: // // factor = kCssPixelsPerMillimeter; // break; // case UnitType.kQuarterMillimeters: // // factor = kCssPixelsPerQuarterMillimeter; // break; // case UnitType.kInches: // // factor = kCssPixelsPerInch; // break; // case UnitType.kDotsPerInch: // // factor = 1 / kCssPixelsPerInch; // break; // case UnitType.kPoints: // // factor = kCssPixelsPerPoint; // break; // case UnitType.kPicas: // // factor = kCssPixelsPerPica; // break; case UnitType.kRadians: factor = 180 / Math.PI; break; case UnitType.kGradians: factor = 0.9; break; case UnitType.kTurns: factor = 360; break; } return factor; }; var unitTypeToString = function unitTypeToString(type) { switch (type) { case UnitType.kNumber: case UnitType.kInteger: // case UnitType.kUserUnits: return ''; case UnitType.kPercentage: return '%'; case UnitType.kEms: // case UnitType.kQuirkyEms: return 'em'; // case UnitType.kExs: // return 'ex'; case UnitType.kRems: return 'rem'; // case UnitType.kChs: // return 'ch'; case UnitType.kPixels: return 'px'; // case UnitType.kCentimeters: // return 'cm'; // case UnitType.kDotsPerPixel: // return 'dppx'; // case UnitType.kDotsPerInch: // return 'dpi'; // case UnitType.kDotsPerCentimeter: // return 'dpcm'; // case UnitType.kMillimeters: // return 'mm'; // case UnitType.kQuarterMillimeters: // return 'q'; // case UnitType.kInches: // return 'in'; // case UnitType.kPoints: // return 'pt'; // case UnitType.kPicas: // return 'pc'; case UnitType.kDegrees: return 'deg'; case UnitType.kRadians: return 'rad'; case UnitType.kGradians: return 'grad'; case UnitType.kMilliseconds: return 'ms'; case UnitType.kSeconds: return 's'; // case UnitType.kHertz: // return 'hz'; // case UnitType.kKilohertz: // return 'khz'; case UnitType.kTurns: return 'turn'; } return ''; }; /** * CSSStyleValue is the base class for all CSS values accessible from Typed OM. * Values that are not yet supported as specific types are also returned as base CSSStyleValues. * * Spec @see https://drafts.css-houdini.org/css-typed-om/#stylevalue-objects * Docs @see https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleValue */ var CSSStyleValue = /*#__PURE__*/function () { function CSSStyleValue() {} // static parse(propertyName: string, value: string): CSSStyleValue { // return parseCSSStyleValue(propertyName, value)[0]; // } // static parseAll(propertyName: string, value: string): CSSStyleValue[] { // return parseCSSStyleValue(propertyName, value); // } CSSStyleValue.isAngle = function isAngle(unit) { return unit === UnitType.kDegrees || unit === UnitType.kRadians || unit === UnitType.kGradians || unit === UnitType.kTurns; } // static isViewportPercentageLength(type: UnitType) { // return type >= UnitType.kViewportWidth && type <= UnitType.kDynamicViewportMax; // } // static isContainerPercentageLength(type: UnitType) { // return type >= UnitType.kContainerWidth && type <= UnitType.kContainerMax; // } ; CSSStyleValue.isLength = function isLength(type) { // return (type >= UnitType.kEms && type <= UnitType.kUserUnits) || type == UnitType.kQuirkyEms; return type >= UnitType.kEms && type < UnitType.kDegrees; }; CSSStyleValue.isRelativeUnit = function isRelativeUnit(type) { return type === UnitType.kPercentage || type === UnitType.kEms || // type === UnitType.kExs || type === UnitType.kRems // type === UnitType.kChs || // this.isViewportPercentageLength(type) || // this.isContainerPercentageLength(type) ; }; CSSStyleValue.isTime = function isTime(unit) { return unit === UnitType.kSeconds || unit === UnitType.kMilliseconds; } // protected abstract toCSSValue(): CSSValue; ; var _proto = CSSStyleValue.prototype; _proto.toString = function toString() { return this.buildCSSText(Nested.kNo, ParenLess.kNo, ''); }; _proto.isNumericValue = function isNumericValue() { return this.getType() >= CSSStyleValueType.kUnitType && this.getType() <= CSSStyleValueType.kClampType; }; return CSSStyleValue; }(); /** * CSSColorValue is the base class used for the various CSS color interfaces. * * @see https://drafts.css-houdini.org/css-typed-om-1/#colorvalue-objects */ var CSSColorValue = /*#__PURE__*/function (_CSSStyleValue) { _inheritsLoose(CSSColorValue, _CSSStyleValue); function CSSColorValue(colorSpace) { var _this; _this = _CSSStyleValue.call(this) || this; _this.colorSpace = void 0; _this.colorSpace = colorSpace; return _this; } var _proto = CSSColorValue.prototype; _proto.getType = function getType() { return CSSStyleValueType.kColorType; } // buildCSSText(n: Nested, p: ParenLess, result: string): string { // let text = ''; // if (this.colorSpace === 'rgb') { // text = `rgba(${this.channels.join(',')},${this.alpha})`; // } // return (result += text); // } /** * @see https://drafts.css-houdini.org/css-typed-om-1/#dom-csscolorvalue-to */; _proto.to = function to(colorSpace) { return this; }; return CSSColorValue; }(CSSStyleValue); var GradientType; (function (GradientType) { GradientType[GradientType["Constant"] = 0] = "Constant"; GradientType[GradientType["LinearGradient"] = 1] = "LinearGradient"; GradientType[GradientType["RadialGradient"] = 2] = "RadialGradient"; })(GradientType || (GradientType = {})); var CSSGradientValue = /*#__PURE__*/function (_CSSStyleValue) { _inheritsLoose(CSSGradientValue, _CSSStyleValue); function CSSGradientValue(type, value) { var _this; _this = _CSSStyleValue.call(this) || this; _this.type = void 0; _this.value = void 0; _this.type = type; _this.value = value; return _this; } var _proto = CSSGradientValue.prototype; _proto.clone = function clone() { return new CSSGradientValue(this.type, this.value); }; _proto.buildCSSText = function buildCSSText(n, p, result) { return result; }; _proto.getType = function getType() { return CSSStyleValueType.kColorType; }; return CSSGradientValue; }(CSSStyleValue); /** * CSSKeywordValue represents CSS Values that are specified as keywords * eg. 'initial' * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl */ var CSSKeywordValue = /*#__PURE__*/function (_CSSStyleValue) { _inheritsLoose(CSSKeywordValue, _CSSStyleValue); function CSSKeywordValue(value) { var _this; _this = _CSSStyleValue.call(this) || this; _this.value = void 0; _this.value = value; return _this; } var _proto = CSSKeywordValue.prototype; _proto.clone = function clone() { return new CSSKeywordValue(this.value); }; _proto.getType = function getType() { return CSSStyleValueType.kKeywordType; }; _proto.buildCSSText = function buildCSSText(n, p, result) { return result + this.value; }; return CSSKeywordValue; }(CSSStyleValue); function memoize(func, resolver) { if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') { throw new TypeError('Expected a function'); } var memoized = function memoized() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var key = resolver ? resolver.apply(this, args) : args[0]; var cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; memoized.cache = new (memoize.Cache || Map)(); return memoized; } memoize.Cache = Map; var camelCase = memoize(function (str) { if (str === void 0) { str = ''; } return str.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); }); var kebabize = function kebabize(str) { return str.split('').map(function (letter, idx) { return letter.toUpperCase() === letter ? "" + (idx !== 0 ? '-' : '') + letter.toLowerCase() : letter; }).join(''); }; function DCHECK(bool) { if (!bool) { throw new Error(); } } function isFunction(func) { return typeof func === 'function'; } function isSymbol(value) { // @see https://github.com/lodash/lodash/blob/master/isSymbol.js return typeof value === 'symbol'; } var definedProps = function definedProps(obj) { return Object.fromEntries(Object.entries(obj).filter(function (_ref) { var v = _ref[1]; return v !== undefined; })); }; var FORMAT_ATTR_MAP = { d: { alias: 'path' }, strokeDasharray: { alias: 'lineDash' }, strokeWidth: { alias: 'lineWidth' }, textAnchor: { alias: 'textAlign' }, src: { alias: 'img' } }; var formatAttributeName = memoize(function (name) { var attributeName = camelCase(name); var map = FORMAT_ATTR_MAP[attributeName]; attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName; return attributeName; }); // type CSSNumericBaseType = // | 'length' // | 'angle' // | 'time' // | 'frequency' // | 'resolution' // | 'flex' // | 'percent'; // https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype // interface CSSNumericType { // length: number; // angle: number; // time: number; // frequency: number; // resolution: number; // flex: number; // percent: number; // percentHint: CSSNumericBaseType; // } var formatInfinityOrNaN = function formatInfinityOrNaN(number, suffix) { if (suffix === void 0) { suffix = ''; } var result = ''; if (!Number.isFinite(number)) { if (number > 0) result = 'infinity';else result = '-infinity'; } else { DCHECK(Number.isNaN(number)); result = 'NaN'; } return result += suffix; }; var toCanonicalUnit = function toCanonicalUnit(unit) { return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit)); }; /** * CSSNumericValue is the base class for numeric and length typed CSS Values. * @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects * @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue * @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl */ /** * Represents numeric values that can be expressed as a single number plus a * unit (or a naked number or percentage). * @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue */ var CSSUnitValue = /*#__PURE__*/function (_CSSStyleValue) { _inheritsLoose(CSSUnitValue, _CSSStyleValue); function CSSUnitValue(value, unitOrName) { var _this; if (unitOrName === void 0) { unitOrName = UnitType.kNumber; } _this = _CSSStyleValue.call(this) || this; _this.unit = void 0; _this.value = void 0; var unit; if (typeof unitOrName === 'string') { unit = unitFromName(unitOrName); } else { unit = unitOrName; } _this.unit = unit; _this.value = value; return _this; } var _proto = CSSUnitValue.prototype; _proto.clone = function clone() { return new CSSUnitValue(this.value, this.unit); }; _proto.equals = function equals(other) { var other_unit_value = other; return this.value === other_unit_value.value && this.unit === other_unit_value.unit; }; _proto.getType = function getType() { return CSSStyleValueType.kUnitType; }; _proto.convertTo = function convertTo(target_unit) { if (this.unit === target_unit) { return new CSSUnitValue(this.value, this.unit); } // Instead of defining the scale factors for every unit to every other unit, // we simply convert to the canonical unit and back since we already have // the scale factors for canonical units. var canonical_unit = toCanonicalUnit(this.unit); if (canonical_unit !== toCanonicalUnit(target_unit) || canonical_unit === UnitType.kUnknown) { return null; } var scale_factor = conversionToCanonicalUnitsScaleFactor(this.unit) / conversionToCanonicalUnitsScaleFactor(target_unit); return new CSSUnitValue(this.value * scale_factor, target_unit); }; _proto.buildCSSText = function buildCSSText(n, p, result) { var text; switch (this.unit) { case UnitType.kUnknown: // FIXME break; case UnitType.kInteger: text = Number(this.value).toFixed(0); break; case UnitType.kNumber: case UnitType.kPercentage: case UnitType.kEms: // case UnitType.kQuirkyEms: // case UnitType.kExs: case UnitType.kRems: // case UnitType.kChs: case UnitType.kPixels: // case UnitType.kCentimeters: // case UnitType.kDotsPerPixel: // case UnitType.kDotsPerInch: // case UnitType.kDotsPerCentimeter: // case UnitType.kMillimeters: // case UnitType.kQuarterMillimeters: // case UnitType.kInches: // case UnitType.kPoints: // case UnitType.kPicas: // case UnitType.kUserUnits: case UnitType.kDegrees: case UnitType.kRadians: case UnitType.kGradians: case UnitType.kMilliseconds: case UnitType.kSeconds: // case UnitType.kHertz: // case UnitType.kKilohertz: case UnitType.kTurns: // case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction: { var kMinInteger = -999999; var kMaxInteger = 999999; var value = this.value; var unit = unitTypeToString(this.unit); if (value < kMinInteger || value > kMaxInteger) { var _unit = unitTypeToString(this.unit); if (!Number.isFinite(value) || Number.isNaN(value)) { text = formatInfinityOrNaN(value, _unit); } else { text = value + (_unit || ''); } } else { text = "" + value + unit; } } } result += text; return result; }; return CSSUnitValue; }(CSSStyleValue); var Opx = new CSSUnitValue(0, 'px'); var Lpx = new CSSUnitValue(1, 'px'); var Odeg = new CSSUnitValue(0, 'deg'); /** * The CSSRGB class represents the CSS rgb()/rgba() functions. * * @see https://drafts.css-houdini.org/css-typed-om-1/#cssrgb */ var CSSRGB = /*#__PURE__*/function (_CSSColorValue) { _inheritsLoose(CSSRGB, _CSSColorValue); function CSSRGB(r, g, b, alpha, /** * 'transparent' & 'none' has the same rgba data */ isNone) { var _this; if (alpha === void 0) { alpha = 1; } if (isNone === void 0) { isNone = false; } _this = _CSSColorValue.call(this, 'rgb') || this; _this.r = void 0; _this.g = void 0; _this.b = void 0; _this.alpha = void 0; _this.isNone = void 0; _this.r = r; _this.g = g; _this.b = b; _this.alpha = alpha; _this.isNone = isNone; return _this; } var _proto = CSSRGB.prototype; _proto.clone = function clone() { return new CSSRGB(this.r, this.g, this.b, this.alpha); }; _proto.buildCSSText = function buildCSSText(n, p, result) { return result + ("rgba(" + this.r + "," + this.g + "," + this.b + "," + this.alpha + ")"); }; return CSSRGB; }(CSSColorValue); /** * holds useful CSS-related methods. * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS * * * CSS Typed OM @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/factory_functions * * register property @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty * * CSS Layout API */ var CSS = { /** * * @see https://drafts.csswg.org/css-values-4/#number-value */ number: function number(n) { return new CSSUnitValue(n); }, /** * * @see https://drafts.csswg.org/css-values-4/#percentage-value */ percent: function percent(n) { return new CSSUnitValue(n, '%'); }, /** * */ px: function px(n) { return new CSSUnitValue(n, 'px'); }, /** * */ em: function em(n) { return new CSSUnitValue(n, 'em'); }, rem: function rem(n) { return new CSSUnitValue(n, 'rem'); }, /** * */ deg: function deg(n) { return new CSSUnitValue(n, 'deg'); }, /** * */ grad: function grad(n) { return new CSSUnitValue(n, 'grad'); }, /** * */ rad: function rad(n) { return new CSSUnitValue(n, 'rad'); }, /** * */ turn: function turn(n) { return new CSSUnitValue(n, 'turn'); }, /** *