1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | function require(p, parent, orig){
|
10 | var path = require.resolve(p)
|
11 | , mod = require.modules[path];
|
12 |
|
13 |
|
14 | if (null == path) {
|
15 | orig = orig || p;
|
16 | parent = parent || 'root';
|
17 | throw new Error('failed to require "' + orig + '" from "' + parent + '"');
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | if (!mod.exports) {
|
24 | mod.exports = {};
|
25 | mod.client = mod.component = true;
|
26 | mod.call(mod.exports, mod, mod.exports, require.relative(path));
|
27 | }
|
28 |
|
29 | return mod.exports;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | require.modules = {};
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | require.aliases = {};
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | require.resolve = function(path){
|
59 | var orig = path
|
60 | , reg = path + '.js'
|
61 | , regJSON = path + '.json'
|
62 | , index = path + '/index.js'
|
63 | , indexJSON = path + '/index.json';
|
64 |
|
65 | return require.modules[reg] && reg
|
66 | || require.modules[regJSON] && regJSON
|
67 | || require.modules[index] && index
|
68 | || require.modules[indexJSON] && indexJSON
|
69 | || require.modules[orig] && orig
|
70 | || null;
|
71 | };
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | require.normalize = function(curr, path) {
|
83 | var segs = [];
|
84 |
|
85 |
|
86 | if ('.' != path[0]) return path;
|
87 |
|
88 | curr = curr.split('/');
|
89 | path = path.split('/');
|
90 |
|
91 | for (var i = 0; i < path.length; ++i) {
|
92 | if ('..' == path[i]) {
|
93 | curr.pop();
|
94 | } else if ('.' != path[i] && '' != path[i]) {
|
95 | segs.push(path[i]);
|
96 | }
|
97 | }
|
98 |
|
99 | return curr.concat(segs).join('/');
|
100 | };
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 | require.register = function(path, fn){
|
111 | require.modules[path] = fn;
|
112 | };
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | require.alias = function(from, to){
|
123 | var fn = require.modules[from];
|
124 | if (!fn) throw new Error('failed to alias "' + from + '", it does not exist');
|
125 | require.aliases[to] = from;
|
126 | };
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | require.relative = function(parent) {
|
137 | var p = require.normalize(parent, '..');
|
138 |
|
139 | |
140 |
|
141 |
|
142 |
|
143 | function fn(path){
|
144 | var orig = path;
|
145 | path = fn.resolve(path);
|
146 | var alias = require.aliases[path + '/index.js'];
|
147 | if (alias) path = alias;
|
148 | return require(path, parent, orig);
|
149 | }
|
150 |
|
151 | |
152 |
|
153 |
|
154 |
|
155 | fn.resolve = function(path){
|
156 |
|
157 |
|
158 |
|
159 | if ('.' != path[0]) {
|
160 | var segs = parent.split('/');
|
161 | var i = segs.lastIndexOf('deps') + 1;
|
162 | if (!i) i = 0;
|
163 | path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
|
164 | return path;
|
165 | }
|
166 | return require.normalize(p, path);
|
167 | };
|
168 |
|
169 | |
170 |
|
171 |
|
172 |
|
173 | fn.exists = function(path){
|
174 | return !! require.modules[fn.resolve(path)];
|
175 | };
|
176 |
|
177 | return fn;
|
178 | };require.register("autoscale-canvas/index.js", function(module, exports, require){
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | module.exports = function(canvas){
|
189 | var ctx = canvas.getContext('2d');
|
190 | var ratio = window.devicePixelRatio || 1;
|
191 | if (1 != ratio) {
|
192 | canvas.style.width = canvas.width + 'px';
|
193 | canvas.style.height = canvas.height + 'px';
|
194 | canvas.width *= ratio;
|
195 | canvas.height *= ratio;
|
196 | ctx.scale(ratio, ratio);
|
197 | }
|
198 | return canvas;
|
199 | };
|
200 | });
|