From 6a0659a88a146c7ed3be39eb6e296c83551f0902 Mon Sep 17 00:00:00 2001 From: Leo Wu Date: Thu, 14 Mar 2019 10:37:55 +0000 Subject: [PATCH] Fix the issue not be able to use image from different origin --- example/bundle.js | 7850 ++++++++++++++++++++++++++------------------- lib/index.js | 1 + 2 files changed, 4465 insertions(+), 3386 deletions(-) diff --git a/example/bundle.js b/example/bundle.js index eb72b02..80891c9 100644 --- a/example/bundle.js +++ b/example/bundle.js @@ -1,13 +1,102 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0x0001 && c <= 0x007F) { - out += str.charAt(i); - } else if (c > 0x07FF) { - out += String.fromCharCode(0xE0 | c >> 12 & 0x0F); - out += String.fromCharCode(0x80 | c >> 6 & 0x3F); - out += String.fromCharCode(0x80 | c >> 0 & 0x3F); - } else { - out += String.fromCharCode(0xC0 | c >> 6 & 0x1F); - out += String.fromCharCode(0x80 | c >> 0 & 0x3F); - } + utf16to8(str) { + var out, i, len, c; + out = ""; + len = str.length; + for (i = 0; i < len; i++) { + c = str.charCodeAt(i); + if (c >= 0x0001 && c <= 0x007F) { + out += str.charAt(i); + } else if (c > 0x07FF) { + out += String.fromCharCode(0xE0 | c >> 12 & 0x0F); + out += String.fromCharCode(0x80 | c >> 6 & 0x3F); + out += String.fromCharCode(0x80 | c >> 0 & 0x3F); + } else { + out += String.fromCharCode(0xC0 | c >> 6 & 0x1F); + out += String.fromCharCode(0x80 | c >> 0 & 0x3F); + } + } + return out; + } + + update() { + var value = this.utf16to8(this.props.value); + var qrcode = qr(value); + var canvas = getDOMNode(this.refs.canvas); + + var ctx = canvas.getContext('2d'); + var cells = qrcode.modules; + var tileW = this.props.size / cells.length; + var tileH = this.props.size / cells.length; + var scale = (window.devicePixelRatio || 1) / getBackingStorePixelRatio(ctx); + canvas.height = canvas.width = this.props.size * scale; + ctx.scale(scale, scale); + + cells.forEach(function (row, rdx) { + row.forEach(function (cell, cdx) { + ctx.fillStyle = cell ? this.props.fgColor : this.props.bgColor; + var w = Math.ceil((cdx + 1) * tileW) - Math.floor(cdx * tileW); + var h = Math.ceil((rdx + 1) * tileH) - Math.floor(rdx * tileH); + ctx.fillRect(Math.round(cdx * tileW), Math.round(rdx * tileH), w, h); + }, this); + }, this); + + if (this.props.logo) { + var self = this; + var size = this.props.size; + var image = document.createElement('img'); + image.setAttribute('crossOrigin', 'anonymous'); + image.src = this.props.logo; + image.onload = function () { + var dwidth = self.props.logoWidth || size * 0.2; + var dheight = self.props.logoHeight || image.height / image.width * dwidth; + var dx = (size - dwidth) / 2; + var dy = (size - dheight) / 2; + image.width = dwidth; + image.height = dheight; + ctx.drawImage(image, dx, dy, dwidth, dheight); + }; + } } - return out; - }, - - update: function () { - var value = this.utf16to8(this.props.value); - var qrcode = qr(value); - var canvas = getDOMNode(this.refs.canvas); - - var ctx = canvas.getContext('2d'); - var cells = qrcode.modules; - var tileW = this.props.size / cells.length; - var tileH = this.props.size / cells.length; - var scale = window.devicePixelRatio / getBackingStorePixelRatio(ctx); - canvas.height = canvas.width = this.props.size * scale; - ctx.scale(scale, scale); - - cells.forEach(function (row, rdx) { - row.forEach(function (cell, cdx) { - ctx.fillStyle = cell ? this.props.fgColor : this.props.bgColor; - var w = Math.ceil((cdx + 1) * tileW) - Math.floor(cdx * tileW); - var h = Math.ceil((rdx + 1) * tileH) - Math.floor(rdx * tileH); - ctx.fillRect(Math.round(cdx * tileW), Math.round(rdx * tileH), w, h); - }, this); - }, this); - - if (this.props.logo) { - var size = this.props.size; - var image = document.createElement('img'); - image.src = this.props.logo; - image.onload = function () { - var dwidth = size * 0.25; - var dx = (size - dwidth) / 2; - var dheight = image.height / image.width * dwidth; - var dy = (size - dheight) / 2; - image.width = dwidth; - image.height = dheight; - ctx.drawImage(image, dx, dy, dwidth, dheight); - }; + + render() { + return React.createElement('canvas', { + style: { height: this.props.size, width: this.props.size }, + height: this.props.size, + width: this.props.size, + ref: 'canvas' + }); } - }, +} - render: function () { - return React.createElement('canvas', { - style: { height: this.props.size, width: this.props.size }, - height: this.props.size, - width: this.props.size, - ref: 'canvas' - }); - } -}); +QRCode.propTypes = { + value: PropTypes.string.isRequired, + size: PropTypes.number, + bgColor: PropTypes.string, + fgColor: PropTypes.string, + logo: PropTypes.string, + logoWidth: PropTypes.number, + logoHeight: PropTypes.number +}; + +QRCode.defaultProps = { + size: 128, + bgColor: '#FFFFFF', + fgColor: '#000000', + value: 'http://facebook.github.io/react/' +}; module.exports = QRCode; -},{"qr.js":31,"react":170}],4:[function(require,module,exports){ -(function (process){ +},{"prop-types":11,"qr.js":13,"react":179,"react-dom":23}],4:[function(require,module,exports){ +"use strict"; + /** - * Copyright 2013-2015, Facebook, Inc. - * - * 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 + * Copyright (c) 2013-present, Facebook, Inc. * - * 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. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @providesModule EventListener - * @typechecks + * */ -'use strict'; - -var emptyFunction = require('./emptyFunction'); +function makeEmptyFunction(arg) { + return function () { + return arg; + }; +} /** - * Upstream version of event listener. Does not take into account specific - * nature of platform. + * This function accepts and discards inputs; it has no side effects. This is + * primarily useful idiomatically for overridable function endpoints which + * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ -var EventListener = { - /** - * Listen to DOM events during the bubble phase. - * - * @param {DOMEventTarget} target DOM element to register listener on. - * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. - * @param {function} callback Callback function. - * @return {object} Object with a `remove` method. - */ - listen: function (target, eventType, callback) { - if (target.addEventListener) { - target.addEventListener(eventType, callback, false); - return { - remove: function () { - target.removeEventListener(eventType, callback, false); - } - }; - } else if (target.attachEvent) { - target.attachEvent('on' + eventType, callback); - return { - remove: function () { - target.detachEvent('on' + eventType, callback); - } - }; - } - }, - - /** - * Listen to DOM events during the capture phase. - * - * @param {DOMEventTarget} target DOM element to register listener on. - * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. - * @param {function} callback Callback function. - * @return {object} Object with a `remove` method. - */ - capture: function (target, eventType, callback) { - if (target.addEventListener) { - target.addEventListener(eventType, callback, true); - return { - remove: function () { - target.removeEventListener(eventType, callback, true); - } - }; - } else { - if (process.env.NODE_ENV !== 'production') { - console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); - } - return { - remove: emptyFunction - }; - } - }, +var emptyFunction = function emptyFunction() {}; - registerDefault: function () {} +emptyFunction.thatReturns = makeEmptyFunction; +emptyFunction.thatReturnsFalse = makeEmptyFunction(false); +emptyFunction.thatReturnsTrue = makeEmptyFunction(true); +emptyFunction.thatReturnsNull = makeEmptyFunction(null); +emptyFunction.thatReturnsThis = function () { + return this; +}; +emptyFunction.thatReturnsArgument = function (arg) { + return arg; }; -module.exports = EventListener; -}).call(this,require('_process')) -},{"./emptyFunction":11,"_process":1}],5:[function(require,module,exports){ +module.exports = emptyFunction; +},{}],5:[function(require,module,exports){ +(function (process){ /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2013-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @providesModule ExecutionEnvironment */ 'use strict'; -var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); - /** - * Simple, lightweight module assisting with the detection and context of - * Worker. Helps avoid circular dependencies and allows code to reason about - * whether or not they are in a Worker, even if they never include the main - * `ReactWorker` dependency. + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. */ -var ExecutionEnvironment = { - - canUseDOM: canUseDOM, - canUseWorkers: typeof Worker !== 'undefined', +var validateFormat = function validateFormat(format) {}; - canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), +if (process.env.NODE_ENV !== 'production') { + validateFormat = function validateFormat(format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} - canUseViewport: canUseDOM && !!window.screen, +function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); - isInWorker: !canUseDOM // For now, this is true - might change in the future. + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error(format.replace(/%s/g, function () { + return args[argIndex++]; + })); + error.name = 'Invariant Violation'; + } -}; + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} -module.exports = ExecutionEnvironment; -},{}],6:[function(require,module,exports){ +module.exports = invariant; +}).call(this,require('_process')) +},{"_process":1}],6:[function(require,module,exports){ +(function (process){ /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * - * @providesModule camelize - * @typechecks */ -"use strict"; +'use strict'; -var _hyphenPattern = /-(.)/g; +var emptyFunction = require('./emptyFunction'); /** - * Camelcases a hyphenated string, for example: - * - * > camelize('background-color') - * < "backgroundColor" - * - * @param {string} string - * @return {string} + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. */ -function camelize(string) { - return string.replace(_hyphenPattern, function (_, character) { - return character.toUpperCase(); - }); -} -module.exports = camelize; -},{}],7:[function(require,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule camelizeStyleName - * @typechecks - */ +var warning = emptyFunction; -'use strict'; +if (process.env.NODE_ENV !== 'production') { + var printWarning = function printWarning(format) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } -var camelize = require('./camelize'); + var argIndex = 0; + var message = 'Warning: ' + format.replace(/%s/g, function () { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; -var msPattern = /^-ms-/; + warning = function warning(condition, format) { + if (format === undefined) { + throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); + } -/** - * Camelcases a hyphenated CSS property name, for example: - * - * > camelizeStyleName('background-color') - * < "backgroundColor" - * > camelizeStyleName('-moz-transition') - * < "MozTransition" - * > camelizeStyleName('-ms-transition') - * < "msTransition" - * - * As Andi Smith suggests - * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix - * is converted to lowercase `ms`. - * - * @param {string} string - * @return {string} - */ -function camelizeStyleName(string) { - return camelize(string.replace(msPattern, 'ms-')); + if (format.indexOf('Failed Composite propType: ') === 0) { + return; // Ignore CompositeComponent proptype check. + } + + if (!condition) { + for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + + printWarning.apply(undefined, [format].concat(args)); + } + }; } -module.exports = camelizeStyleName; -},{"./camelize":6}],8:[function(require,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule containsNode - * @typechecks - */ +module.exports = warning; +}).call(this,require('_process')) +},{"./emptyFunction":4,"_process":1}],7:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ 'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; -var isTextNode = require('./isTextNode'); +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } -/*eslint-disable no-bitwise */ + return Object(val); +} -/** - * Checks if a given DOM node contains or is another DOM node. - * - * @param {?DOMNode} outerNode Outer DOM node. - * @param {?DOMNode} innerNode Inner DOM node. - * @return {boolean} True if `outerNode` contains or is `innerNode`. - */ -function containsNode(_x, _x2) { - var _again = true; +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } - _function: while (_again) { - var outerNode = _x, - innerNode = _x2; - _again = false; + // Detect buggy property enumeration order in older V8 versions. - if (!outerNode || !innerNode) { - return false; - } else if (outerNode === innerNode) { - return true; - } else if (isTextNode(outerNode)) { - return false; - } else if (isTextNode(innerNode)) { - _x = outerNode; - _x2 = innerNode.parentNode; - _again = true; - continue _function; - } else if (outerNode.contains) { - return outerNode.contains(innerNode); - } else if (outerNode.compareDocumentPosition) { - return !!(outerNode.compareDocumentPosition(innerNode) & 16); - } else { - return false; - } - } + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } } -module.exports = containsNode; -},{"./isTextNode":21}],9:[function(require,module,exports){ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule createArrayFromMixed - * @typechecks - */ +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; -'use strict'; + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); -var toArray = require('./toArray'); + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; +},{}],8:[function(require,module,exports){ +(function (process){ /** - * Perform a heuristic test to determine if an object is "array-like". - * - * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" - * Joshu replied: "Mu." - * - * This function determines if its argument has "array nature": it returns - * true if the argument is an actual array, an `arguments' object, or an - * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). - * - * It will return false for other array-like objects like Filelist. + * Copyright (c) 2013-present, Facebook, Inc. * - * @param {*} obj - * @return {boolean} + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ -function hasArrayNature(obj) { - return( - // not null/false - !!obj && ( - // arrays are objects, NodeLists are functions in Safari - typeof obj == 'object' || typeof obj == 'function') && - // quacks like an array - 'length' in obj && - // not window - !('setInterval' in obj) && - // no DOM node should be considered an array-like - // a 'select' element has 'length' and 'item' properties on IE8 - typeof obj.nodeType != 'number' && ( - // a real array - Array.isArray(obj) || - // arguments - 'callee' in obj || - // HTMLCollection/NodeList - 'item' in obj) - ); + +'use strict'; + +if (process.env.NODE_ENV !== 'production') { + var invariant = require('fbjs/lib/invariant'); + var warning = require('fbjs/lib/warning'); + var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); + var loggedTypeFailures = {}; } /** - * Ensure that the argument is an array by wrapping it in an array if it is not. - * Creates a copy of the argument if it is already an array. - * - * This is mostly useful idiomatically: - * - * var createArrayFromMixed = require('createArrayFromMixed'); - * - * function takesOneOrMoreThings(things) { - * things = createArrayFromMixed(things); - * ... - * } - * - * This allows you to treat `things' as an array, but accept scalars in the API. - * - * If you need to convert an array-like object, like `arguments`, into an array - * use toArray instead. + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. * - * @param {*} obj - * @return {array} + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private */ -function createArrayFromMixed(obj) { - if (!hasArrayNature(obj)) { - return [obj]; - } else if (Array.isArray(obj)) { - return obj.slice(); - } else { - return toArray(obj); +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + if (process.env.NODE_ENV !== 'production') { + for (var typeSpecName in typeSpecs) { + if (typeSpecs.hasOwnProperty(typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]); + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + warning(!error || error instanceof 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); + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); + } + } + } } } -module.exports = createArrayFromMixed; -},{"./toArray":29}],10:[function(require,module,exports){ -(function (process){ +module.exports = checkPropTypes; + +}).call(this,require('_process')) +},{"./lib/ReactPropTypesSecret":12,"_process":1,"fbjs/lib/invariant":5,"fbjs/lib/warning":6}],9:[function(require,module,exports){ /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2013-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule createNodesFromMarkup - * @typechecks + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ -/*eslint-disable fb-www/unsafe-html*/ - 'use strict'; -var ExecutionEnvironment = require('./ExecutionEnvironment'); +var emptyFunction = require('fbjs/lib/emptyFunction'); +var invariant = require('fbjs/lib/invariant'); +var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret'); -var createArrayFromMixed = require('./createArrayFromMixed'); -var getMarkupWrap = require('./getMarkupWrap'); -var invariant = require('./invariant'); +module.exports = function() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } + invariant( + false, + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use PropTypes.checkPropTypes() to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + }; + shim.isRequired = shim; + function getShim() { + return shim; + }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. + var ReactPropTypes = { + array: shim, + bool: shim, + func: shim, + number: shim, + object: shim, + string: shim, + symbol: shim, + + any: shim, + arrayOf: getShim, + element: shim, + instanceOf: getShim, + node: shim, + objectOf: getShim, + oneOf: getShim, + oneOfType: getShim, + shape: getShim, + exact: getShim + }; -/** - * Dummy container used to render all markup. - */ -var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; + ReactPropTypes.checkPropTypes = emptyFunction; + ReactPropTypes.PropTypes = ReactPropTypes; -/** - * Pattern used by `getNodeName`. - */ -var nodeNamePattern = /^\s*<(\w+)/; + return ReactPropTypes; +}; +},{"./lib/ReactPropTypesSecret":12,"fbjs/lib/emptyFunction":4,"fbjs/lib/invariant":5}],10:[function(require,module,exports){ +(function (process){ /** - * Extracts the `nodeName` of the first element in a string of markup. + * Copyright (c) 2013-present, Facebook, Inc. * - * @param {string} markup String of markup. - * @return {?string} Node name of the supplied markup. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ -function getNodeName(markup) { - var nodeNameMatch = markup.match(nodeNamePattern); - return nodeNameMatch && nodeNameMatch[1].toLowerCase(); -} -/** - * Creates an array containing the nodes rendered from the supplied markup. The - * optionally supplied `handleScript` function will be invoked once for each - *