選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

bundle.js 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. var require = function (file, cwd) {
  2. var resolved = require.resolve(file, cwd || '/');
  3. var mod = require.modules[resolved];
  4. if (!mod) throw new Error(
  5. 'Failed to resolve module ' + file + ', tried ' + resolved
  6. );
  7. var res = mod._cached ? mod._cached : mod();
  8. return res;
  9. }
  10. require.paths = [];
  11. require.modules = {};
  12. require.extensions = [".js",".coffee"];
  13. require._core = {
  14. 'assert': true,
  15. 'events': true,
  16. 'fs': true,
  17. 'path': true,
  18. 'vm': true
  19. };
  20. require.resolve = (function () {
  21. return function (x, cwd) {
  22. if (!cwd) cwd = '/';
  23. if (require._core[x]) return x;
  24. var path = require.modules.path();
  25. var y = cwd || '.';
  26. if (x.match(/^(?:\.\.?\/|\/)/)) {
  27. var m = loadAsFileSync(path.resolve(y, x))
  28. || loadAsDirectorySync(path.resolve(y, x));
  29. if (m) return m;
  30. }
  31. var n = loadNodeModulesSync(x, y);
  32. if (n) return n;
  33. throw new Error("Cannot find module '" + x + "'");
  34. function loadAsFileSync (x) {
  35. if (require.modules[x]) {
  36. return x;
  37. }
  38. for (var i = 0; i < require.extensions.length; i++) {
  39. var ext = require.extensions[i];
  40. if (require.modules[x + ext]) return x + ext;
  41. }
  42. }
  43. function loadAsDirectorySync (x) {
  44. x = x.replace(/\/+$/, '');
  45. var pkgfile = x + '/package.json';
  46. if (require.modules[pkgfile]) {
  47. var pkg = require.modules[pkgfile]();
  48. var b = pkg.browserify;
  49. if (typeof b === 'object' && b.main) {
  50. var m = loadAsFileSync(path.resolve(x, b.main));
  51. if (m) return m;
  52. }
  53. else if (typeof b === 'string') {
  54. var m = loadAsFileSync(path.resolve(x, b));
  55. if (m) return m;
  56. }
  57. else if (pkg.main) {
  58. var m = loadAsFileSync(path.resolve(x, pkg.main));
  59. if (m) return m;
  60. }
  61. }
  62. return loadAsFileSync(x + '/index');
  63. }
  64. function loadNodeModulesSync (x, start) {
  65. var dirs = nodeModulesPathsSync(start);
  66. for (var i = 0; i < dirs.length; i++) {
  67. var dir = dirs[i];
  68. var m = loadAsFileSync(dir + '/' + x);
  69. if (m) return m;
  70. var n = loadAsDirectorySync(dir + '/' + x);
  71. if (n) return n;
  72. }
  73. var m = loadAsFileSync(x);
  74. if (m) return m;
  75. }
  76. function nodeModulesPathsSync (start) {
  77. var parts;
  78. if (start === '/') parts = [ '' ];
  79. else parts = path.normalize(start).split('/');
  80. var dirs = [];
  81. for (var i = parts.length - 1; i >= 0; i--) {
  82. if (parts[i] === 'node_modules') continue;
  83. var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
  84. dirs.push(dir);
  85. }
  86. return dirs;
  87. }
  88. };
  89. })();
  90. require.alias = function (from, to) {
  91. var path = require.modules.path();
  92. var res = null;
  93. try {
  94. res = require.resolve(from + '/package.json', '/');
  95. }
  96. catch (err) {
  97. res = require.resolve(from, '/');
  98. }
  99. var basedir = path.dirname(res);
  100. var keys = (Object.keys || function (obj) {
  101. var res = [];
  102. for (var key in obj) res.push(key)
  103. return res;
  104. })(require.modules);
  105. for (var i = 0; i < keys.length; i++) {
  106. var key = keys[i];
  107. if (key.slice(0, basedir.length + 1) === basedir + '/') {
  108. var f = key.slice(basedir.length);
  109. require.modules[to + f] = require.modules[basedir + f];
  110. }
  111. else if (key === basedir) {
  112. require.modules[to] = require.modules[basedir];
  113. }
  114. }
  115. };
  116. require.define = function (filename, fn) {
  117. var dirname = require._core[filename]
  118. ? ''
  119. : require.modules.path().dirname(filename)
  120. ;
  121. var require_ = function (file) {
  122. return require(file, dirname)
  123. };
  124. require_.resolve = function (name) {
  125. return require.resolve(name, dirname);
  126. };
  127. require_.modules = require.modules;
  128. require_.define = require.define;
  129. var module_ = { exports : {} };
  130. require.modules[filename] = function () {
  131. require.modules[filename]._cached = module_.exports;
  132. fn.call(
  133. module_.exports,
  134. require_,
  135. module_,
  136. module_.exports,
  137. dirname,
  138. filename
  139. );
  140. require.modules[filename]._cached = module_.exports;
  141. return module_.exports;
  142. };
  143. };
  144. if (typeof process === 'undefined') process = {};
  145. if (!process.nextTick) process.nextTick = (function () {
  146. var queue = [];
  147. var canPost = typeof window !== 'undefined'
  148. && window.postMessage && window.addEventListener
  149. ;
  150. if (canPost) {
  151. window.addEventListener('message', function (ev) {
  152. if (ev.source === window && ev.data === 'browserify-tick') {
  153. ev.stopPropagation();
  154. if (queue.length > 0) {
  155. var fn = queue.shift();
  156. fn();
  157. }
  158. }
  159. }, true);
  160. }
  161. return function (fn) {
  162. if (canPost) {
  163. queue.push(fn);
  164. window.postMessage('browserify-tick', '*');
  165. }
  166. else setTimeout(fn, 0);
  167. };
  168. })();
  169. if (!process.title) process.title = 'browser';
  170. if (!process.binding) process.binding = function (name) {
  171. if (name === 'evals') return require('vm')
  172. else throw new Error('No such module')
  173. };
  174. if (!process.cwd) process.cwd = function () { return '.' };
  175. require.define("path", function (require, module, exports, __dirname, __filename) {
  176. function filter (xs, fn) {
  177. var res = [];
  178. for (var i = 0; i < xs.length; i++) {
  179. if (fn(xs[i], i, xs)) res.push(xs[i]);
  180. }
  181. return res;
  182. }
  183. // resolves . and .. elements in a path array with directory names there
  184. // must be no slashes, empty elements, or device names (c:\) in the array
  185. // (so also no leading and trailing slashes - it does not distinguish
  186. // relative and absolute paths)
  187. function normalizeArray(parts, allowAboveRoot) {
  188. // if the path tries to go above the root, `up` ends up > 0
  189. var up = 0;
  190. for (var i = parts.length; i >= 0; i--) {
  191. var last = parts[i];
  192. if (last == '.') {
  193. parts.splice(i, 1);
  194. } else if (last === '..') {
  195. parts.splice(i, 1);
  196. up++;
  197. } else if (up) {
  198. parts.splice(i, 1);
  199. up--;
  200. }
  201. }
  202. // if the path is allowed to go above the root, restore leading ..s
  203. if (allowAboveRoot) {
  204. for (; up--; up) {
  205. parts.unshift('..');
  206. }
  207. }
  208. return parts;
  209. }
  210. // Regex to split a filename into [*, dir, basename, ext]
  211. // posix version
  212. var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
  213. // path.resolve([from ...], to)
  214. // posix version
  215. exports.resolve = function() {
  216. var resolvedPath = '',
  217. resolvedAbsolute = false;
  218. for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
  219. var path = (i >= 0)
  220. ? arguments[i]
  221. : process.cwd();
  222. // Skip empty and invalid entries
  223. if (typeof path !== 'string' || !path) {
  224. continue;
  225. }
  226. resolvedPath = path + '/' + resolvedPath;
  227. resolvedAbsolute = path.charAt(0) === '/';
  228. }
  229. // At this point the path should be resolved to a full absolute path, but
  230. // handle relative paths to be safe (might happen when process.cwd() fails)
  231. // Normalize the path
  232. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  233. return !!p;
  234. }), !resolvedAbsolute).join('/');
  235. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  236. };
  237. // path.normalize(path)
  238. // posix version
  239. exports.normalize = function(path) {
  240. var isAbsolute = path.charAt(0) === '/',
  241. trailingSlash = path.slice(-1) === '/';
  242. // Normalize the path
  243. path = normalizeArray(filter(path.split('/'), function(p) {
  244. return !!p;
  245. }), !isAbsolute).join('/');
  246. if (!path && !isAbsolute) {
  247. path = '.';
  248. }
  249. if (path && trailingSlash) {
  250. path += '/';
  251. }
  252. return (isAbsolute ? '/' : '') + path;
  253. };
  254. // posix version
  255. exports.join = function() {
  256. var paths = Array.prototype.slice.call(arguments, 0);
  257. return exports.normalize(filter(paths, function(p, index) {
  258. return p && typeof p === 'string';
  259. }).join('/'));
  260. };
  261. exports.dirname = function(path) {
  262. var dir = splitPathRe.exec(path)[1] || '';
  263. var isWindows = false;
  264. if (!dir) {
  265. // No dirname
  266. return '.';
  267. } else if (dir.length === 1 ||
  268. (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
  269. // It is just a slash or a drive letter with a slash
  270. return dir;
  271. } else {
  272. // It is a full dirname, strip trailing slash
  273. return dir.substring(0, dir.length - 1);
  274. }
  275. };
  276. exports.basename = function(path, ext) {
  277. var f = splitPathRe.exec(path)[2] || '';
  278. // TODO: make this comparison case-insensitive on windows?
  279. if (ext && f.substr(-1 * ext.length) === ext) {
  280. f = f.substr(0, f.length - ext.length);
  281. }
  282. return f;
  283. };
  284. exports.extname = function(path) {
  285. return splitPathRe.exec(path)[3] || '';
  286. };
  287. });
  288. require.define("vm", function (require, module, exports, __dirname, __filename) {
  289. var Object_keys = function (obj) {
  290. if (Object.keys) return Object.keys(obj)
  291. else {
  292. var res = [];
  293. for (var key in obj) res.push(key)
  294. return res;
  295. }
  296. };
  297. var forEach = function (xs, fn) {
  298. if (xs.forEach) return xs.forEach(fn)
  299. else for (var i = 0; i < xs.length; i++) {
  300. fn(xs[i], i, xs);
  301. }
  302. };
  303. var Script = exports.Script = function NodeScript (code) {
  304. if (!(this instanceof Script)) return new Script(code);
  305. this.code = code;
  306. };
  307. var iframe = document.createElement('iframe');
  308. if (!iframe.style) iframe.style = {};
  309. iframe.style.display = 'none';
  310. var iframeCapable = true; // until proven otherwise
  311. if (navigator.appName === 'Microsoft Internet Explorer') {
  312. var m = navigator.appVersion.match(/\bMSIE (\d+\.\d+);/);
  313. if (m && parseFloat(m[1]) <= 9.0) {
  314. iframeCapable = false;
  315. }
  316. }
  317. Script.prototype.runInNewContext = function (context) {
  318. if (!context) context = {};
  319. if (!iframeCapable) {
  320. var keys = Object_keys(context);
  321. var args = [];
  322. for (var i = 0; i < keys.length; i++) {
  323. args.push(context[keys[i]]);
  324. }
  325. var fn = new Function(keys, 'return ' + this.code);
  326. return fn.apply(null, args);
  327. }
  328. document.body.appendChild(iframe);
  329. var win = iframe.contentWindow
  330. || (window.frames && window.frames[window.frames.length - 1])
  331. || window[window.length - 1]
  332. ;
  333. forEach(Object_keys(context), function (key) {
  334. win[key] = context[key];
  335. iframe[key] = context[key];
  336. });
  337. if (win.eval) {
  338. // chrome and ff can just .eval()
  339. var res = win.eval(this.code);
  340. }
  341. else {
  342. // this works in IE9 but not anything newer
  343. iframe.setAttribute('src',
  344. 'javascript:__browserifyVmResult=(' + this.code + ')'
  345. );
  346. if ('__browserifyVmResult' in win) {
  347. var res = win.__browserifyVmResult;
  348. }
  349. else {
  350. iframeCapable = false;
  351. res = this.runInThisContext(context);
  352. }
  353. }
  354. forEach(Object_keys(win), function (key) {
  355. context[key] = win[key];
  356. });
  357. document.body.removeChild(iframe);
  358. return res;
  359. };
  360. Script.prototype.runInThisContext = function () {
  361. return eval(this.code); // maybe...
  362. };
  363. Script.prototype.runInContext = function (context) {
  364. // seems to be just runInNewContext on magical context objects which are
  365. // otherwise indistinguishable from objects except plain old objects
  366. // for the parameter segfaults node
  367. return this.runInNewContext(context);
  368. };
  369. forEach(Object_keys(Script.prototype), function (name) {
  370. exports[name] = Script[name] = function (code) {
  371. var s = Script(code);
  372. return s[name].apply(s, [].slice.call(arguments, 1));
  373. };
  374. });
  375. exports.createScript = function (code) {
  376. return exports.Script(code);
  377. };
  378. exports.createContext = Script.createContext = function (context) {
  379. // not really sure what this one does
  380. // seems to just make a shallow copy
  381. var copy = {};
  382. forEach(Object_keys(context), function (key) {
  383. copy[key] = context[key];
  384. });
  385. return copy;
  386. };
  387. });
  388. require.define("/entry.js", function (require, module, exports, __dirname, __filename) {
  389. var vm = require('vm');
  390. $(function () {
  391. var res = vm.runInNewContext('a + 5', { a : 100 });
  392. $('#res').text(res);
  393. });
  394. });
  395. require("/entry.js");