UNPKG

react-design-editor

Version:

Design Editor Tools with React.js + ant.design + fabric.js

1,248 lines 7.72 MB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); import React, { Component as Component$1, useRef } from "react"; import ReactDOM from "react-dom"; var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x2) { return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; } function getAugmentedNamespace(n2) { if (Object.prototype.hasOwnProperty.call(n2, "__esModule")) return n2; var f2 = n2.default; if (typeof f2 == "function") { var a2 = function a3() { if (this instanceof a3) { return Reflect.construct(f2, arguments, this.constructor); } return f2.apply(this, arguments); }; a2.prototype = f2.prototype; } else a2 = {}; Object.defineProperty(a2, "__esModule", { value: true }); Object.keys(n2).forEach(function(k) { var d2 = Object.getOwnPropertyDescriptor(n2, k); Object.defineProperty(a2, k, d2.get ? d2 : { enumerable: true, get: function() { return n2[k]; } }); }); return a2; } var jsxRuntime = { exports: {} }; var reactJsxRuntime_production_min = {}; /** @license React v16.14.0 * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var hasRequiredReactJsxRuntime_production_min; function requireReactJsxRuntime_production_min() { if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min; hasRequiredReactJsxRuntime_production_min = 1; var f2 = React, g2 = 60103; reactJsxRuntime_production_min.Fragment = 60107; if ("function" === typeof Symbol && Symbol.for) { var h2 = Symbol.for; g2 = h2("react.element"); reactJsxRuntime_production_min.Fragment = h2("react.fragment"); } var m2 = f2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n2 = Object.prototype.hasOwnProperty, p2 = { key: true, ref: true, __self: true, __source: true }; function q2(c2, a2, k) { var b2, d2 = {}, e2 = null, l2 = null; void 0 !== k && (e2 = "" + k); void 0 !== a2.key && (e2 = "" + a2.key); void 0 !== a2.ref && (l2 = a2.ref); for (b2 in a2) n2.call(a2, b2) && !p2.hasOwnProperty(b2) && (d2[b2] = a2[b2]); if (c2 && c2.defaultProps) for (b2 in a2 = c2.defaultProps, a2) void 0 === d2[b2] && (d2[b2] = a2[b2]); return { $$typeof: g2, type: c2, key: e2, ref: l2, props: d2, _owner: m2.current }; } reactJsxRuntime_production_min.jsx = q2; reactJsxRuntime_production_min.jsxs = q2; return reactJsxRuntime_production_min; } var reactJsxRuntime_development = {}; /** @license React v16.14.0 * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var hasRequiredReactJsxRuntime_development; function requireReactJsxRuntime_development() { if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development; hasRequiredReactJsxRuntime_development = 1; (function(exports) { if (process.env.NODE_ENV !== "production") { (function() { var React$1 = React; var REACT_ELEMENT_TYPE = 60103; var REACT_PORTAL_TYPE = 60106; exports.Fragment = 60107; var REACT_STRICT_MODE_TYPE = 60108; var REACT_PROFILER_TYPE = 60114; var REACT_PROVIDER_TYPE = 60109; var REACT_CONTEXT_TYPE = 60110; var REACT_FORWARD_REF_TYPE = 60112; var REACT_SUSPENSE_TYPE = 60113; var REACT_SUSPENSE_LIST_TYPE = 60120; var REACT_MEMO_TYPE = 60115; var REACT_LAZY_TYPE = 60116; var REACT_BLOCK_TYPE = 60121; var REACT_SERVER_BLOCK_TYPE = 60122; var REACT_FUNDAMENTAL_TYPE = 60117; var REACT_DEBUG_TRACING_MODE_TYPE = 60129; var REACT_LEGACY_HIDDEN_TYPE = 60131; if (typeof Symbol === "function" && Symbol.for) { var symbolFor = Symbol.for; REACT_ELEMENT_TYPE = symbolFor("react.element"); REACT_PORTAL_TYPE = symbolFor("react.portal"); exports.Fragment = symbolFor("react.fragment"); REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); REACT_PROFILER_TYPE = symbolFor("react.profiler"); REACT_PROVIDER_TYPE = symbolFor("react.provider"); REACT_CONTEXT_TYPE = symbolFor("react.context"); REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); REACT_BLOCK_TYPE = symbolFor("react.block"); REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); symbolFor("react.scope"); symbolFor("react.opaque.id"); REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); symbolFor("react.offscreen"); REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); } var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { if (maybeIterable === null || typeof maybeIterable !== "object") { return null; } var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; if (typeof maybeIterator === "function") { return maybeIterator; } return null; } var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function error(format2) { { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } printWarning("error", format2, args); } } function printWarning(level, format2, args) { { var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; var stack = ""; if (currentlyValidatingElement) { var name2 = getComponentName(currentlyValidatingElement.type); var owner = currentlyValidatingElement._owner; stack += describeComponentFrame(name2, currentlyValidatingElement._source, owner && getComponentName(owner.type)); } stack += ReactDebugCurrentFrame.getStackAddendum(); if (stack !== "") { format2 += "%s"; args = args.concat([stack]); } var argsWithFormat = args.map(function(item) { return "" + item; }); argsWithFormat.unshift("Warning: " + format2); Function.prototype.apply.call(console[level], console, argsWithFormat); } } var enableScopeAPI = false; function isValidElementType(type) { if (typeof type === "string" || typeof type === "function") { return true; } if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI) { return true; } if (typeof type === "object" && type !== null) { if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) { return true; } } return false; } var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function describeComponentFrame(name2, source, ownerName) { var sourceInfo = ""; if (source) { var path2 = source.fileName; var fileName = path2.replace(BEFORE_SLASH_RE, ""); { if (/^index\./.test(fileName)) { var match = path2.match(BEFORE_SLASH_RE); if (match) { var pathBeforeSlash = match[1]; if (pathBeforeSlash) { var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); fileName = folderName + "/" + fileName; } } } } sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; } else if (ownerName) { sourceInfo = " (created by " + ownerName + ")"; } return "\n in " + (name2 || "Unknown") + sourceInfo; } var Resolved = 1; function refineResolvedLazyComponent(lazyComponent) { return lazyComponent._status === Resolved ? lazyComponent._result : null; } function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return outerType.displayName || (functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName); } function getComponentName(type) { if (type == null) { return null; } { if (typeof type.tag === "number") { error("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."); } } if (typeof type === "function") { return type.displayName || type.name || null; } if (typeof type === "string") { return type; } switch (type) { case exports.Fragment: return "Fragment"; case REACT_PORTAL_TYPE: return "Portal"; case REACT_PROFILER_TYPE: return "Profiler"; case REACT_STRICT_MODE_TYPE: return "StrictMode"; case REACT_SUSPENSE_TYPE: return "Suspense"; case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList"; } if (typeof type === "object") { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: return getComponentName(type.render); case REACT_LAZY_TYPE: { var thenable = type; var resolvedThenable = refineResolvedLazyComponent(thenable); if (resolvedThenable) { return getComponentName(resolvedThenable); } break; } } } return null; } var loggedTypeFailures = {}; ReactSharedInternals.ReactDebugCurrentFrame; var currentlyValidatingElement = null; function setCurrentlyValidatingElement(element) { { currentlyValidatingElement = element; } } function checkPropTypes(typeSpecs, values, location, componentName, element) { { var has = Function.call.bind(Object.prototype.hasOwnProperty); for (var typeSpecName in typeSpecs) { if (has(typeSpecs, typeSpecName)) { var error$1 = void 0; try { if (typeof typeSpecs[typeSpecName] !== "function") { var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); err.name = "Invariant Violation"; throw err; } error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (ex) { error$1 = ex; } if (error$1 && !(error$1 instanceof Error)) { setCurrentlyValidatingElement(element); error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1); setCurrentlyValidatingElement(null); } if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) { loggedTypeFailures[error$1.message] = true; setCurrentlyValidatingElement(element); error("Failed %s type: %s", location, error$1.message); setCurrentlyValidatingElement(null); } } } } } var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; var hasOwnProperty = Object.prototype.hasOwnProperty; var RESERVED_PROPS = { key: true, ref: true, __self: true, __source: true }; var specialPropKeyWarningShown; var specialPropRefWarningShown; function hasValidRef(config2) { { if (hasOwnProperty.call(config2, "ref")) { var getter = Object.getOwnPropertyDescriptor(config2, "ref").get; if (getter && getter.isReactWarning) { return false; } } } return config2.ref !== void 0; } function hasValidKey(config2) { { if (hasOwnProperty.call(config2, "key")) { var getter = Object.getOwnPropertyDescriptor(config2, "key").get; if (getter && getter.isReactWarning) { return false; } } } return config2.key !== void 0; } function warnIfStringRefCannotBeAutoConverted(config2, self2) { { if (typeof config2.ref === "string" && ReactCurrentOwner.current && self2) ; } } function defineKeyPropWarningGetter(props, displayName) { { var warnAboutAccessingKey = function() { if (!specialPropKeyWarningShown) { specialPropKeyWarningShown = true; error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName); } }; warnAboutAccessingKey.isReactWarning = true; Object.defineProperty(props, "key", { get: warnAboutAccessingKey, configurable: true }); } } function defineRefPropWarningGetter(props, displayName) { { var warnAboutAccessingRef = function() { if (!specialPropRefWarningShown) { specialPropRefWarningShown = true; error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName); } }; warnAboutAccessingRef.isReactWarning = true; Object.defineProperty(props, "ref", { get: warnAboutAccessingRef, configurable: true }); } } var ReactElement = function(type, key, ref, self2, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, // Built-in properties that belong on the element type, key, ref, props, // Record the component responsible for creating this element. _owner: owner }; { element._store = {}; Object.defineProperty(element._store, "validated", { configurable: false, enumerable: false, writable: true, value: false }); Object.defineProperty(element, "_self", { configurable: false, enumerable: false, writable: false, value: self2 }); Object.defineProperty(element, "_source", { configurable: false, enumerable: false, writable: false, value: source }); if (Object.freeze) { Object.freeze(element.props); Object.freeze(element); } } return element; }; function jsxDEV(type, config2, maybeKey, source, self2) { { var propName; var props = {}; var key = null; var ref = null; if (maybeKey !== void 0) { key = "" + maybeKey; } if (hasValidKey(config2)) { key = "" + config2.key; } if (hasValidRef(config2)) { ref = config2.ref; warnIfStringRefCannotBeAutoConverted(config2, self2); } for (propName in config2) { if (hasOwnProperty.call(config2, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { props[propName] = config2[propName]; } } if (type && type.defaultProps) { var defaultProps = type.defaultProps; for (propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } if (key || ref) { var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type; if (key) { defineKeyPropWarningGetter(props, displayName); } if (ref) { defineRefPropWarningGetter(props, displayName); } } return ReactElement(type, key, ref, self2, source, ReactCurrentOwner.current, props); } } var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; ReactSharedInternals.ReactDebugCurrentFrame; function setCurrentlyValidatingElement$1(element) { currentlyValidatingElement = element; } var propTypesMisspellWarningShown; { propTypesMisspellWarningShown = false; } function isValidElement(object) { { return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } } function getDeclarationErrorAddendum() { { if (ReactCurrentOwner$1.current) { var name2 = getComponentName(ReactCurrentOwner$1.current.type); if (name2) { return "\n\nCheck the render method of `" + name2 + "`."; } } return ""; } } function getSourceInfoErrorAddendum(source) { { return ""; } } var ownerHasKeyUseWarning = {}; function getCurrentComponentErrorInfo(parentType) { { var info = getDeclarationErrorAddendum(); if (!info) { var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name; if (parentName) { info = "\n\nCheck the top-level render call using <" + parentName + ">."; } } return info; } } function validateExplicitKey(element, parentType) { { if (!element._store || element._store.validated || element.key != null) { return; } element._store.validated = true; var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { return; } ownerHasKeyUseWarning[currentComponentErrorInfo] = true; var childOwner = ""; if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) { childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; } setCurrentlyValidatingElement$1(element); error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner); setCurrentlyValidatingElement$1(null); } } function validateChildKeys(node, parentType) { { if (typeof node !== "object") { return; } if (Array.isArray(node)) { for (var i2 = 0; i2 < node.length; i2++) { var child = node[i2]; if (isValidElement(child)) { validateExplicitKey(child, parentType); } } } else if (isValidElement(node)) { if (node._store) { node._store.validated = true; } } else if (node) { var iteratorFn = getIteratorFn(node); if (typeof iteratorFn === "function") { if (iteratorFn !== node.entries) { var iterator = iteratorFn.call(node); var step; while (!(step = iterator.next()).done) { if (isValidElement(step.value)) { validateExplicitKey(step.value, parentType); } } } } } } } function validatePropTypes(element) { { var type = element.type; if (type === null || type === void 0 || typeof type === "string") { return; } var propTypes; if (typeof type === "function") { propTypes = type.propTypes; } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. type.$$typeof === REACT_MEMO_TYPE)) { propTypes = type.propTypes; } else { return; } if (propTypes) { var name2 = getComponentName(type); checkPropTypes(propTypes, element.props, "prop", name2, element); } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) { propTypesMisspellWarningShown = true; var _name = getComponentName(type); error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown"); } if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) { error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } } function validateFragmentProps(fragment) { { var keys = Object.keys(fragment.props); for (var i2 = 0; i2 < keys.length; i2++) { var key = keys[i2]; if (key !== "children" && key !== "key") { setCurrentlyValidatingElement$1(fragment); error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key); setCurrentlyValidatingElement$1(null); break; } } if (fragment.ref !== null) { setCurrentlyValidatingElement$1(fragment); error("Invalid attribute `ref` supplied to `React.Fragment`."); setCurrentlyValidatingElement$1(null); } } } function jsxWithValidation(type, props, key, isStaticChildren, source, self2) { { var validType = isValidElementType(type); if (!validType) { var info = ""; if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) { info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."; } var sourceInfo = getSourceInfoErrorAddendum(); if (sourceInfo) { info += sourceInfo; } else { info += getDeclarationErrorAddendum(); } var typeString; if (type === null) { typeString = "null"; } else if (Array.isArray(type)) { typeString = "array"; } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) { typeString = "<" + (getComponentName(type.type) || "Unknown") + " />"; info = " Did you accidentally export a JSX literal instead of a component?"; } else { typeString = typeof type; } error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info); } var element = jsxDEV(type, props, key, source, self2); if (element == null) { return element; } if (validType) { var children = props.children; if (children !== void 0) { if (isStaticChildren) { if (Array.isArray(children)) { for (var i2 = 0; i2 < children.length; i2++) { validateChildKeys(children[i2], type); } if (Object.freeze) { Object.freeze(children); } } else { error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); } } else { validateChildKeys(children, type); } } } if (type === exports.Fragment) { validateFragmentProps(element); } else { validatePropTypes(element); } return element; } } function jsxWithValidationStatic(type, props, key) { { return jsxWithValidation(type, props, key, true); } } function jsxWithValidationDynamic(type, props, key) { { return jsxWithValidation(type, props, key, false); } } var jsx = jsxWithValidationDynamic; var jsxs = jsxWithValidationStatic; exports.jsx = jsx; exports.jsxs = jsxs; })(); } })(reactJsxRuntime_development); return reactJsxRuntime_development; } var hasRequiredJsxRuntime; function requireJsxRuntime() { if (hasRequiredJsxRuntime) return jsxRuntime.exports; hasRequiredJsxRuntime = 1; if (process.env.NODE_ENV === "production") { jsxRuntime.exports = requireReactJsxRuntime_production_min(); } else { jsxRuntime.exports = requireReactJsxRuntime_development(); } return jsxRuntime.exports; } var jsxRuntimeExports = requireJsxRuntime(); var fabric = {}; const __viteBrowserExternal = {}; const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: __viteBrowserExternal }, Symbol.toStringTag, { value: "Module" })); const require$$2 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); var hasRequiredFabric; function requireFabric() { if (hasRequiredFabric) return fabric; hasRequiredFabric = 1; (function(exports) { /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ var fabric$1 = fabric$1 || { version: "4.6.0" }; { exports.fabric = fabric$1; } if (typeof document !== "undefined" && typeof window !== "undefined") { if (document instanceof (typeof HTMLDocument !== "undefined" ? HTMLDocument : Document)) { fabric$1.document = document; } else { fabric$1.document = document.implementation.createHTMLDocument(""); } fabric$1.window = window; } else { var jsdom = require$$2; var virtualWindow = new jsdom.JSDOM( decodeURIComponent("%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E"), { features: { FetchExternalResources: ["img"] }, resources: "usable" } ).window; fabric$1.document = virtualWindow.document; fabric$1.jsdomImplForWrapper = require$$2.implForWrapper; fabric$1.nodeCanvas = require$$2.Canvas; fabric$1.window = virtualWindow; DOMParser = fabric$1.window.DOMParser; } fabric$1.isTouchSupported = "ontouchstart" in fabric$1.window || "ontouchstart" in fabric$1.document || fabric$1.window && fabric$1.window.navigator && fabric$1.window.navigator.maxTouchPoints > 0; fabric$1.isLikelyNode = typeof Buffer !== "undefined" && typeof window === "undefined"; fabric$1.SHARED_ATTRIBUTES = [ "display", "transform", "fill", "fill-opacity", "fill-rule", "opacity", "stroke", "stroke-dasharray", "stroke-linecap", "stroke-dashoffset", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "id", "paint-order", "vector-effect", "instantiated_by_use", "clip-path" ]; fabric$1.DPI = 96; fabric$1.reNum = "(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)"; fabric$1.commaWsp = "(?:\\s+,?\\s*|,\\s*)"; fabric$1.rePathCommand = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig; fabric$1.reNonWord = /[ \n\.,;!\?\-]/; fabric$1.fontPaths = {}; fabric$1.iMatrix = [1, 0, 0, 1, 0, 0]; fabric$1.svgNS = "http://www.w3.org/2000/svg"; fabric$1.perfLimitSizeTotal = 2097152; fabric$1.maxCacheSideLimit = 4096; fabric$1.minCacheSideLimit = 256; fabric$1.charWidthsCache = {}; fabric$1.textureSize = 2048; fabric$1.disableStyleCopyPaste = false; fabric$1.enableGLFiltering = true; fabric$1.devicePixelRatio = fabric$1.window.devicePixelRatio || fabric$1.window.webkitDevicePixelRatio || fabric$1.window.mozDevicePixelRatio || 1; fabric$1.browserShadowBlurConstant = 1; fabric$1.arcToSegmentsCache = {}; fabric$1.boundsOfCurveCache = {}; fabric$1.cachesBoundsOfCurve = true; fabric$1.forceGLPutImageData = false; fabric$1.initFilterBackend = function() { if (fabric$1.enableGLFiltering && fabric$1.isWebglSupported && fabric$1.isWebglSupported(fabric$1.textureSize)) { console.log("max texture size: " + fabric$1.maxTextureSize); return new fabric$1.WebglFilterBackend({ tileSize: fabric$1.textureSize }); } else if (fabric$1.Canvas2dFilterBackend) { return new fabric$1.Canvas2dFilterBackend(); } }; if (typeof document !== "undefined" && typeof window !== "undefined") { window.fabric = fabric$1; } (function() { function _removeEventListener(eventName, handler) { if (!this.__eventListeners[eventName]) { return; } var eventListener = this.__eventListeners[eventName]; if (handler) { eventListener[eventListener.indexOf(handler)] = false; } else { fabric$1.util.array.fill(eventListener, false); } } function on(eventName, handler) { if (!this.__eventListeners) { this.__eventListeners = {}; } if (arguments.length === 1) { for (var prop in eventName) { this.on(prop, eventName[prop]); } } else { if (!this.__eventListeners[eventName]) { this.__eventListeners[eventName] = []; } this.__eventListeners[eventName].push(handler); } return this; } function _once(eventName, handler) { var _handler = (function() { handler.apply(this, arguments); this.off(eventName, _handler); }).bind(this); this.on(eventName, _handler); } function once(eventName, handler) { if (arguments.length === 1) { for (var prop in eventName) { _once.call(this, prop, eventName[prop]); } } else { _once.call(this, eventName, handler); } return this; } function off(eventName, handler) { if (!this.__eventListeners) { return this; } if (arguments.length === 0) { for (eventName in this.__eventListeners) { _removeEventListener.call(this, eventName); } } else if (arguments.length === 1 && typeof arguments[0] === "object") { for (var prop in eventName) { _removeEventListener.call(this, prop, eventName[prop]); } } else { _removeEventListener.call(this, eventName, handler); } return this; } function fire(eventName, options) { if (!this.__eventListeners) { return this; } var listenersForEvent = this.__eventListeners[eventName]; if (!listenersForEvent) { return this; } for (var i2 = 0, len = listenersForEvent.length; i2 < len; i2++) { listenersForEvent[i2] && listenersForEvent[i2].call(this, options || {}); } this.__eventListeners[eventName] = listenersForEvent.filter(function(value) { return value !== false; }); return this; } fabric$1.Observable = { fire, on, once, off }; })(); fabric$1.Collection = { _objects: [], /** * Adds objects to collection, Canvas or Group, then renders canvas * (if `renderOnAddRemove` is not `false`). * in case of Group no changes to bounding box are made. * Objects should be instances of (or inherit from) fabric.Object * Use of this function is highly discouraged for groups. * you can add a bunch of objects with the add method but then you NEED * to run a addWithUpdate call for the Group class or position/bbox will be wrong. * @param {...fabric.Object} object Zero or more fabric instances * @return {Self} thisArg * @chainable */ add: function() { this._objects.push.apply(this._objects, arguments); if (this._onObjectAdded) { for (var i2 = 0, length = arguments.length; i2 < length; i2++) { this._onObjectAdded(arguments[i2]); } } this.renderOnAddRemove && this.requestRenderAll(); return this; }, /** * Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`) * An object should be an instance of (or inherit from) fabric.Object * Use of this function is highly discouraged for groups. * you can add a bunch of objects with the insertAt method but then you NEED * to run a addWithUpdate call for the Group class or position/bbox will be wrong. * @param {Object} object Object to insert * @param {Number} index Index to insert object at * @param {Boolean} nonSplicing When `true`, no splicing (shifting) of objects occurs * @return {Self} thisArg * @chainable */ insertAt: function(object, index2, nonSplicing) { var objects = this._objects; if (nonSplicing) { objects[index2] = object; } else { objects.splice(index2, 0, object); } this._onObjectAdded && this._onObjectAdded(object); this.renderOnAddRemove && this.requestRenderAll(); return this; }, /** * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`) * @param {...fabric.Object} object Zero or more fabric instances * @return {Self} thisArg * @chainable */ remove: function() { var objects = this._objects, index2, somethingRemoved = false; for (var i2 = 0, length = arguments.length; i2 < length; i2++) { index2 = objects.indexOf(arguments[i2]); if (index2 !== -1) { somethingRemoved = true; objects.splice(index2, 1); this._onObjectRemoved && this._onObjectRemoved(arguments[i2]); } } this.renderOnAddRemove && somethingRemoved && this.requestRenderAll(); return this; }, /** * Executes given function for each object in this group * @param {Function} callback * Callback invoked with current object as first argument, * index - as second and an array of all objects - as third. * Callback is invoked in a context of Global Object (e.g. `window`) * when no `context` argument is given * * @param {Object} context Context (aka thisObject) * @return {Self} thisArg * @chainable */ forEachObject: function(callback, context) { var objects = this.getObjects(); for (var i2 = 0, len = objects.length; i2 < len; i2++) { callback.call(context, objects[i2], i2, objects); } return this; }, /** * Returns an array of children objects of this instance * Type parameter introduced in 1.3.10 * since 2.3.5 this method return always a COPY of the array; * @param {String} [type] When specified, only objects of this type are returned * @return {Array} */ getObjects: function(type) { if (typeof type === "undefined") { return this._objects.concat(); } return this._objects.filter(function(o2) { return o2.type === type; }); }, /** * Returns object at specified index * @param {Number} index * @return {Self} thisArg */ item: function(index2) { return this._objects[index2]; }, /** * Returns true if collection contains no objects * @return {Boolean} true if collection is empty */ isEmpty: function() { return this._objects.length === 0; }, /** * Returns a size of a collection (i.e: length of an array containing its objects) * @return {Number} Collection size */ size: function() { return this._objects.length; }, /** * Returns true if collection contains an object * @param {Object} object Object to check against * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects` * @return {Boolean} `true` if collection contains an object */ contains: function(object, deep) { if (this._objects.indexOf(object) > -1) { return true; } else if (deep) { return this._objects.some(function(obj) { return typeof obj.contains === "function" && obj.contains(object, true); }); } return false; }, /** * Returns number representation of a collection complexity * @return {Number} complexity */ complexity: function() { return this._objects.reduce(function(memo, current) { memo += current.complexity ? current.complexity() : 0; return memo; }, 0); } }; fabric$1.CommonMethods = { /** * Sets object's properties from options * @param {Object} [options] Options object */ _setOptions: function(options) { for (var prop in options) { this.set(prop, options[prop]); } }, /** * @private * @param {Object} [filler] Options object * @param {String} [property] property to set the Gradient to */ _initGradient: function(filler, property) { if (filler && filler.colorStops && !(filler instanceof fabric$1.Gradient)) { this.set(property, new fabric$1.Gradient(filler)); } }, /** * @private * @param {Object} [filler] Options object * @param {String} [property] property to set the Pattern to * @param {Function} [callback] callback to invoke after pattern load */ _initPattern: function(filler, property, callback) { if (filler && filler.source && !(filler instanceof fabric$1.Pattern)) { this.set(property, new fabric$1.Pattern(filler, callback)); } else { callback && callback(); } }, /** * @private */ _setObject: function(obj) { for (var prop in obj) { this._set(prop, obj[prop]); } }, /** * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`. * @param {String|Object} key Property name or object (if object, iterate over the object properties) * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one) * @return {fabric.Object} thisArg * @chainable */ set: function(key, value) { if (typeof key === "object") { this._setObject(key); } else { this._set(key, value); } return this; }, _set: function(key, value) { this[key] = value; }, /** * Toggles specified property from `true` to `false` or from `false` to `true` * @param {String} property Property to toggle * @return {fabric.Object} thisArg * @chainable */ toggle: function(property) { var value = this.get(property); if (typeof value === "boolean") { this.set(property, !value); } return this; }, /** * Basic getter * @param {String} property Property name * @return {*} value of a property */ get: function(property) { return this[property]; } }; (function(global2) { var sqrt = Math.sqrt, atan2 = Math.atan2, pow = Math.pow, PiBy180 = Math.PI / 180, PiBy2 = Math.PI / 2; fabric$1.util = { /** * Calculate the cos of an angle, avoiding returning floats for known results * @static * @memberOf fabric.util * @param {Number} angle the angle in radians or in degree * @return {Number} */ cos: function(angle) { if (angle === 0) { return 1; } if (angle < 0) { angle = -angle; } var angleSlice = angle / PiBy2; switch (angleSlice) { case 1: case 3: return 0; case 2: return -1; } return Math.cos(angle); }, /** * Calculate the sin of an angle, avoiding returning floats for known results * @static * @memberOf fabric.util * @param {Number} angle the angle in radians or in degree * @return {Number} */ sin: function(angle) { if (angle === 0) { return 0; } var angleSlice = angle / PiBy2, sign = 1; if (angle < 0) { sign = -1; } switch (angleSlice) { case 1: return sign; case 2: return 0; case 3: return -sign; } return Math.sin(angle); }, /** * Removes value from an array. * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf` * @static * @memberOf fabric.util * @param {Array} array * @param {*} value * @return {Array} original array */ removeFromArray: function(array, value) { var idx = array.indexOf(value); if (idx !== -1) { array.splice(idx, 1); } return array; }, /** * Returns random number between 2 specified ones. * @static * @memberOf fabric.util * @param {Number} min lower limit * @param {Number} max upper limit * @return {Number} random value (between min and max) */ getRandomInt: function(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }, /** * Transforms degrees to radians. * @static * @memberOf fabric.util * @param {Number} degrees value in degrees * @return {Number} value in radians */ degreesToRadians: function(degrees) { return degrees * PiBy180; }, /** * Transforms radians to degrees. * @static * @memberOf fabric.util * @param {Number} radians value in radians * @return {Number} value in degrees */ radiansToDegrees: function(radians) { return radians / PiBy180; }, /** * Rotates `point` around `origin` with `radians` * @static * @memberOf fabric.util * @param {fabric.Point} point The point to rotate * @param {fabric.Point} origin The origin of the rotation * @param {Number} radians The radians of the angle for the rotation * @return {fabric.Point} The new rotated point */ rotatePoint: function(point, origin, radians) { var newPoint = new fabric$1.Point(point.x - origin.x, point.y - origin.y), v2 = fabric$1.util.rotateVector(newPoint, radians); return new fabric$1.Point(v2.x, v2.y).addEquals(origin); }, /** * Rotates `vector` with `radians` * @static * @memberOf fabric.util * @param {Object} vector The vector to rotate (x and y) * @param {Number} radians The radians of the angle for the rotation * @return {Object} The new rotated point */ rotateVector: function(vector2, radians) { var sin = fabric$1.util.sin(radians), cos = fabric$1.util.cos(radians), rx = vector2.x * cos - vector2.y * sin, ry = vector2.x * sin + vector2.y * cos; return { x: rx, y: ry }; }, /** * Apply transform t to point p * @static * @memberOf fabric.util * @param {fabric.Point} p The point to transform * @param {Array} t The transform * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied * @return {fabric.Point} The transformed point */ transformPoint: function(p2, t2, ignoreOffset) { if (ignoreOffset) { return new fabric$1.Point( t2[0] * p2.x + t2[2] * p2.y, t2[1] * p2.x + t2[3] * p2.y ); } return new fabric$1.Point( t2[0] * p2.x + t2[2] * p2.y + t2[4], t2[1] * p2.x + t2[3] * p2.y + t2[5] ); }, /** * Returns coordinates of points's bounding rectangle (left, top, width, height) * @param {Array} points 4 points array * @param {Array}