@makano/rew 1.2.56 → 1.2.58
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/civet/main.js +17239 -0
- package/lib/rew/cli/cli.js +3 -2
- package/lib/rew/cli/utils.js +20 -9
- package/lib/rew/const/default.js +2 -1
- package/lib/rew/const/ext.js +5 -0
- package/lib/rew/const/opt.js +7 -3
- package/lib/rew/const/usage.js +15 -0
- package/lib/rew/functions/fs.js +6 -1
- package/lib/rew/functions/import.js +12 -7
- package/lib/rew/functions/require.js +1 -1
- package/lib/rew/functions/stdout.js +4 -0
- package/lib/rew/main.js +1 -13
- package/lib/rew/modules/compiler.js +92 -28
- package/lib/rew/modules/context.js +12 -0
- package/lib/rew/modules/runtime.js +31 -13
- package/lib/rew/pkgs/serve.js +7 -4
- package/lib/rew/pkgs/web.js +5 -4
- package/package.json +5 -3
- package/runtime.d.ts +103 -62
- package/jsconfig.json +0 -13
- package/lib/coffeescript/browser.js +0 -156
- package/lib/coffeescript/cake.js +0 -134
- package/lib/coffeescript/coffeescript.js +0 -465
- package/lib/coffeescript/command.js +0 -832
- package/lib/coffeescript/grammar.js +0 -1930
- package/lib/coffeescript/helpers.js +0 -513
- package/lib/coffeescript/index.js +0 -230
- package/lib/coffeescript/lexer.js +0 -2316
- package/lib/coffeescript/nodes.js +0 -9784
- package/lib/coffeescript/optparse.js +0 -258
- package/lib/coffeescript/parser.js +0 -20384
- package/lib/coffeescript/register.js +0 -120
- package/lib/coffeescript/repl.js +0 -328
- package/lib/coffeescript/rewriter.js +0 -1448
- package/lib/coffeescript/scope.js +0 -191
- package/lib/coffeescript/sourcemap.js +0 -244
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@makano/rew",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.58",
|
4
4
|
"description": "A simple coffescript runtime and app manager",
|
5
5
|
"main": "main.js",
|
6
6
|
"directories": {
|
@@ -32,6 +32,9 @@
|
|
32
32
|
"license": "ISC",
|
33
33
|
"dependencies": {
|
34
34
|
"@babel/core": "^7.24.6",
|
35
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
36
|
+
"@babel/plugin-proposal-decorators": "^7.24.7",
|
37
|
+
"@babel/plugin-transform-class-static-block": "^7.24.7",
|
35
38
|
"@babel/preset-env": "^7.24.7",
|
36
39
|
"@babel/preset-react": "^7.24.6",
|
37
40
|
"@babel/preset-typescript": "^7.24.7",
|
@@ -48,6 +51,5 @@
|
|
48
51
|
"vite": "^5.2.13",
|
49
52
|
"vm": "^0.1.0",
|
50
53
|
"yargs": "^17.7.2"
|
51
|
-
}
|
52
|
-
"devDependencies": {}
|
54
|
+
}
|
53
55
|
}
|
package/runtime.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
interface ImportOptions {
|
2
4
|
/**
|
3
5
|
* Determines how to import the given module
|
@@ -61,7 +63,8 @@ interface ModuleConf extends ModuleConfOptionCenter {
|
|
61
63
|
name: string,
|
62
64
|
defaults?: any
|
63
65
|
) => {
|
64
|
-
write: (value: any, ifExists?: boolean) =>
|
66
|
+
write: (value: any, ifExists?: boolean) => any;
|
67
|
+
// @ts-ignore
|
65
68
|
read: (to?: string | object) => string | object | Buffer;
|
66
69
|
fileRoot: string;
|
67
70
|
exists: boolean;
|
@@ -109,8 +112,8 @@ interface ModuleRuneDB {
|
|
109
112
|
interface ModuleRune {
|
110
113
|
db(dbname: string, data?: object, encryptionKey?: string): ModuleRuneDB;
|
111
114
|
genKey(secret: string): string;
|
112
|
-
push(...values: any[]):
|
113
|
-
pop(...values: any[]):
|
115
|
+
push(...values: any[]): any;
|
116
|
+
pop(...values: any[]): any;
|
114
117
|
}
|
115
118
|
|
116
119
|
interface ModuleThreads {
|
@@ -120,12 +123,40 @@ interface ModuleThreads {
|
|
120
123
|
on: (event: string, callback: (data) => void) => void;
|
121
124
|
off: (event: string, callback: (data) => void) => void;
|
122
125
|
emit: (event: string, data: any) => void;
|
123
|
-
get: () => Promise
|
126
|
+
get: () => Promise<any>;
|
124
127
|
stop: () => void;
|
125
128
|
};
|
126
129
|
};
|
127
130
|
}
|
128
131
|
|
132
|
+
|
133
|
+
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
|
134
|
+
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
|
135
|
+
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
|
136
|
+
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
|
137
|
+
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
138
|
+
: import("undici-types").RequestInit;
|
139
|
+
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
|
140
|
+
: import("undici-types").ResponseInit;
|
141
|
+
// @ts-ignore
|
142
|
+
type _File = typeof globalThis extends { onmessage: any } ? {} : import("node:buffer").File;
|
143
|
+
|
144
|
+
interface Request {}
|
145
|
+
declare var Request: typeof globalThis extends {
|
146
|
+
onmessage: any;
|
147
|
+
Request: infer T;
|
148
|
+
} ? T
|
149
|
+
: typeof import("undici-types").Request;
|
150
|
+
|
151
|
+
interface ResponseInit extends _ResponseInit {}
|
152
|
+
|
153
|
+
interface Response extends _Response {}
|
154
|
+
declare var Response: typeof globalThis extends {
|
155
|
+
onmessage: any;
|
156
|
+
Response: infer T;
|
157
|
+
} ? T
|
158
|
+
: typeof import("undici-types").Response;
|
159
|
+
|
129
160
|
type GenericTraps = Record<string, any>;
|
130
161
|
|
131
162
|
type IRequestStrict = {
|
@@ -156,7 +187,8 @@ type StatusErrorObject = {
|
|
156
187
|
error?: string;
|
157
188
|
[key: string]: any;
|
158
189
|
};
|
159
|
-
|
190
|
+
|
191
|
+
interface StatusError extends Error {
|
160
192
|
status: number;
|
161
193
|
[key: string]: any;
|
162
194
|
constructor(status?: number, body?: StatusErrorObject | string);
|
@@ -262,12 +294,9 @@ interface ErrorLike extends Error {
|
|
262
294
|
type ErrorBody = string | object;
|
263
295
|
interface ErrorFormatter {
|
264
296
|
(statusCode?: number, body?: ErrorBody): Response;
|
265
|
-
(error: ErrorLike): Response;
|
266
|
-
}
|
267
|
-
{
|
268
297
|
}
|
269
298
|
|
270
|
-
|
299
|
+
type IttyRouter = <
|
271
300
|
RequestType extends IRequest = IRequest,
|
272
301
|
Args extends any[] = any[],
|
273
302
|
ResponseType = any
|
@@ -277,7 +306,7 @@ const IttyRouter: <
|
|
277
306
|
...other
|
278
307
|
}?: IttyRouterOptions) => IttyRouterType<RequestType, Args, ResponseType>;
|
279
308
|
|
280
|
-
|
309
|
+
type Router = <
|
281
310
|
RequestType = IRequest,
|
282
311
|
Args extends any[] = any[],
|
283
312
|
ResponseType = any
|
@@ -291,7 +320,7 @@ const Router: <
|
|
291
320
|
ResponseType
|
292
321
|
>;
|
293
322
|
|
294
|
-
|
323
|
+
type AutoRouter = <
|
295
324
|
RequestType extends IRequest = IRequest,
|
296
325
|
Args extends any[] = any[],
|
297
326
|
ResponseType = any
|
@@ -307,32 +336,18 @@ const AutoRouter: <
|
|
307
336
|
ResponseType
|
308
337
|
>;
|
309
338
|
|
310
|
-
|
339
|
+
type createResponse = (
|
311
340
|
format?: string,
|
312
341
|
transform?: ((body: any) => any) | undefined
|
313
342
|
) => ResponseFormatter;
|
314
343
|
|
315
|
-
|
316
|
-
|
317
|
-
const statusR: (status: number, options?: ResponseInit) => Response;
|
344
|
+
type statusR = (status: number, options?: ResponseInit) => Response;
|
318
345
|
|
319
|
-
|
346
|
+
type withContent = (request: IRequest) => Promise<void>;
|
320
347
|
|
321
|
-
|
348
|
+
type withCookies = (r: IRequest) => void;
|
322
349
|
|
323
|
-
|
324
|
-
|
325
|
-
const jpegR: ResponseFormatter;
|
326
|
-
|
327
|
-
const pngR: ResponseFormatter;
|
328
|
-
|
329
|
-
const webpR: ResponseFormatter;
|
330
|
-
|
331
|
-
const withContent: (request: IRequest) => Promise<void>;
|
332
|
-
|
333
|
-
const withCookies: (r: IRequest) => void;
|
334
|
-
|
335
|
-
const withParams: (request: IRequest) => void;
|
350
|
+
type withParams = (request: IRequest) => void;
|
336
351
|
|
337
352
|
type CorsOptions = {
|
338
353
|
credentials?: true;
|
@@ -353,7 +368,7 @@ type CorsPair = {
|
|
353
368
|
preflight: Preflight;
|
354
369
|
corsify: Corsify;
|
355
370
|
};
|
356
|
-
|
371
|
+
type cors = (options?: CorsOptions) => {
|
357
372
|
corsify: (response: Response, request?: Request) => Response;
|
358
373
|
preflight: (request: Request) => Response | undefined;
|
359
374
|
};
|
@@ -362,7 +377,9 @@ interface ModuleServeRouter extends RouterType {
|
|
362
377
|
to(server: ModuleServeServer): any;
|
363
378
|
}
|
364
379
|
|
365
|
-
interface
|
380
|
+
interface ResponseType{}
|
381
|
+
|
382
|
+
declare class ModuleServeServerOptions {
|
366
383
|
handler?: (req: RequestLike, res: ResponseType) => any;
|
367
384
|
routers?: ModuleServeRouter[];
|
368
385
|
fetch?: (req: RequestLike) => ResponseType | Promise<ResponseType>;
|
@@ -372,7 +389,7 @@ interface ModuleServeServer {
|
|
372
389
|
_server: any;
|
373
390
|
routers: Record<string, ModuleServeRouter>;
|
374
391
|
|
375
|
-
handleRequest: typeof ModuleServeServerOptions.handler;
|
392
|
+
handleRequest: typeof ModuleServeServerOptions.prototype.handler;
|
376
393
|
listen: this;
|
377
394
|
port: (port: number) => this;
|
378
395
|
log: (string: string) => this;
|
@@ -388,7 +405,7 @@ interface ModuleServeFileRouterOptions {
|
|
388
405
|
onError?: () => any;
|
389
406
|
}
|
390
407
|
|
391
|
-
class ModuleServe {
|
408
|
+
declare class ModuleServe {
|
392
409
|
router({
|
393
410
|
id,
|
394
411
|
type,
|
@@ -403,26 +420,29 @@ class ModuleServe {
|
|
403
420
|
o: ModuleServeFileRouterOptions
|
404
421
|
): (req: RequestLike) => ResponseType | Promise<ResponseType>;
|
405
422
|
|
406
|
-
cors
|
407
|
-
json
|
408
|
-
error
|
409
|
-
png
|
410
|
-
jpeg
|
411
|
-
webp
|
412
|
-
text
|
413
|
-
html
|
414
|
-
status
|
423
|
+
cors: cors;
|
424
|
+
json: ResponseFormatter;
|
425
|
+
error: ResponseFormatter;
|
426
|
+
png: ResponseFormatter;
|
427
|
+
jpeg: ResponseFormatter;
|
428
|
+
webp: ResponseFormatter;
|
429
|
+
text: ResponseFormatter;
|
430
|
+
html: ResponseFormatter;
|
431
|
+
status: statusR;
|
415
432
|
|
416
|
-
createResponse
|
433
|
+
createResponse: createResponse;
|
417
434
|
|
418
|
-
withContent
|
419
|
-
withCookies
|
420
|
-
withParams
|
435
|
+
withContent: withContent;
|
436
|
+
withCookies: withCookies;
|
437
|
+
withParams: withParams;
|
421
438
|
|
439
|
+
// @ts-ignore
|
422
440
|
Request = Request;
|
441
|
+
// @ts-ignore
|
423
442
|
Response = Response;
|
424
443
|
}
|
425
444
|
|
445
|
+
// @ts-ignore
|
426
446
|
type nodable = Element | Node | any;
|
427
447
|
interface Node {
|
428
448
|
type: string;
|
@@ -461,7 +481,7 @@ interface ModuleWebState {
|
|
461
481
|
subscribe(callback: CallableFunction): this;
|
462
482
|
}
|
463
483
|
|
464
|
-
class ModuleWeb {
|
484
|
+
declare class ModuleWeb {
|
465
485
|
create(options: ModuleWebPageOptions): ModuleWebPage;
|
466
486
|
isNode(node: any): boolean;
|
467
487
|
isTextNode(node: any): boolean;
|
@@ -471,12 +491,13 @@ class ModuleWeb {
|
|
471
491
|
createElement(...args: any[]): ElementNode;
|
472
492
|
|
473
493
|
state(value): ModuleWebState | any;
|
494
|
+
// @ts-ignore
|
474
495
|
useState(states: State[], callback: CallableFunction): any;
|
475
496
|
|
476
497
|
bundle(filePath: string, options?: Record<string, any>): string;
|
477
498
|
}
|
478
499
|
|
479
|
-
class Stack<T = any> {
|
500
|
+
declare class Stack<T = any> {
|
480
501
|
constructor();
|
481
502
|
push(item: T): void;
|
482
503
|
pop(): T | undefined;
|
@@ -485,7 +506,7 @@ class Stack<T = any> {
|
|
485
506
|
toArray(): T[];
|
486
507
|
}
|
487
508
|
|
488
|
-
class Queue<T = any> {
|
509
|
+
declare class Queue<T = any> {
|
489
510
|
constructor();
|
490
511
|
enqueue(item: T): void;
|
491
512
|
dequeue(): T | undefined;
|
@@ -494,7 +515,7 @@ class Queue<T = any> {
|
|
494
515
|
toArray(): T[];
|
495
516
|
}
|
496
517
|
|
497
|
-
class LinkedList<T = any> {
|
518
|
+
declare class LinkedList<T = any> {
|
498
519
|
constructor();
|
499
520
|
append(value: T): void;
|
500
521
|
prepend(value: T): void;
|
@@ -503,7 +524,7 @@ class LinkedList<T = any> {
|
|
503
524
|
toArray(): T[];
|
504
525
|
}
|
505
526
|
|
506
|
-
namespace LinkedList {
|
527
|
+
declare namespace LinkedList {
|
507
528
|
class Node<T = any> {
|
508
529
|
constructor(value: T);
|
509
530
|
value: T;
|
@@ -511,14 +532,14 @@ namespace LinkedList {
|
|
511
532
|
}
|
512
533
|
}
|
513
534
|
|
514
|
-
class BinaryTree<T = any> {
|
535
|
+
declare class BinaryTree<T = any> {
|
515
536
|
constructor();
|
516
537
|
insert(value: T): void;
|
517
538
|
find(value: T): BinaryTree.Node<T> | null;
|
518
539
|
toArray(): T[];
|
519
540
|
}
|
520
541
|
|
521
|
-
namespace BinaryTree {
|
542
|
+
declare namespace BinaryTree {
|
522
543
|
class Node<T = any> {
|
523
544
|
constructor(value: T);
|
524
545
|
value: T;
|
@@ -527,7 +548,7 @@ namespace BinaryTree {
|
|
527
548
|
}
|
528
549
|
}
|
529
550
|
|
530
|
-
class DoublyLinkedList<T = any> {
|
551
|
+
declare class DoublyLinkedList<T = any> {
|
531
552
|
constructor();
|
532
553
|
append(value: T): void;
|
533
554
|
prepend(value: T): void;
|
@@ -536,7 +557,7 @@ class DoublyLinkedList<T = any> {
|
|
536
557
|
toArray(): T[];
|
537
558
|
}
|
538
559
|
|
539
|
-
namespace DoublyLinkedList {
|
560
|
+
declare namespace DoublyLinkedList {
|
540
561
|
class Node<T = any> {
|
541
562
|
constructor(value: T);
|
542
563
|
value: T;
|
@@ -545,20 +566,26 @@ namespace DoublyLinkedList {
|
|
545
566
|
}
|
546
567
|
}
|
547
568
|
|
548
|
-
interface ModuleData {
|
569
|
+
declare interface ModuleData {
|
549
570
|
Stack: typeof Stack;
|
550
571
|
Queue: typeof Queue;
|
551
|
-
|
552
|
-
|
553
|
-
|
572
|
+
BinaryTree: typeof BinaryTree;
|
573
|
+
DoublyLinkedList: typeof DoublyLinkedList;
|
574
|
+
LinkedList: typeof LinkedList;
|
554
575
|
}
|
555
576
|
|
556
577
|
interface ModuleStream {
|
578
|
+
// @ts-ignore
|
557
579
|
Readable: Readable,
|
580
|
+
// @ts-ignore
|
558
581
|
Writable: Writable,
|
582
|
+
// @ts-ignore
|
559
583
|
Transform: Transform,
|
584
|
+
// @ts-ignore
|
560
585
|
Duplex: Duplex,
|
586
|
+
// @ts-ignore
|
561
587
|
pipeline: pipeline,
|
588
|
+
// @ts-ignore
|
562
589
|
finished: finished
|
563
590
|
}
|
564
591
|
|
@@ -575,8 +602,9 @@ declare function imp(path: "data", options?: ImportOptions): ModuleData;
|
|
575
602
|
declare function imp(path: "stream", options?: ImportOptions): ModuleStream;
|
576
603
|
declare function imp(path: string, options?: ImportOptions): any;
|
577
604
|
|
578
|
-
declare const inc
|
605
|
+
declare const inc: typeof imp;
|
579
606
|
|
607
|
+
// @ts-ignore
|
580
608
|
declare function require(moduleName: string): any;
|
581
609
|
|
582
610
|
interface Module {
|
@@ -587,10 +615,12 @@ interface Module {
|
|
587
615
|
compiled: string;
|
588
616
|
}
|
589
617
|
|
618
|
+
// @ts-ignore
|
590
619
|
declare const module: Module;
|
591
620
|
|
592
621
|
interface Imports {
|
593
622
|
meta: {
|
623
|
+
// @ts-ignore
|
594
624
|
url: URL,
|
595
625
|
main: boolean
|
596
626
|
};
|
@@ -599,6 +629,7 @@ interface Imports {
|
|
599
629
|
|
600
630
|
declare const imports: Imports;
|
601
631
|
|
632
|
+
// @ts-ignore
|
602
633
|
declare const process: {
|
603
634
|
argv: string[];
|
604
635
|
target: ReturnType<typeof emitter>;
|
@@ -842,6 +873,7 @@ declare function curl(
|
|
842
873
|
*/
|
843
874
|
o?: string;
|
844
875
|
}
|
876
|
+
// @ts-ignore
|
845
877
|
): Promise<Response>;
|
846
878
|
|
847
879
|
/**
|
@@ -874,7 +906,9 @@ declare function curl(
|
|
874
906
|
|
875
907
|
declare function print(...args: any[]): void;
|
876
908
|
declare namespace print {
|
909
|
+
// @ts-ignore
|
877
910
|
const stdout: WriteStream;
|
911
|
+
// @ts-ignore
|
878
912
|
const stdin: ReadStream;
|
879
913
|
}
|
880
914
|
|
@@ -886,8 +920,10 @@ declare const extname: (path: string) => string;
|
|
886
920
|
declare const pjoin: (...paths: string[]) => string;
|
887
921
|
declare const presolve: (...paths: string[]) => string;
|
888
922
|
|
923
|
+
// @ts-ignore
|
889
924
|
declare function exports(value: any): any;
|
890
925
|
|
926
|
+
|
891
927
|
declare function pub(value: any): any;
|
892
928
|
declare function pub(name: string, value: any): any;
|
893
929
|
|
@@ -898,5 +934,10 @@ declare const opt: {
|
|
898
934
|
pop: (key: string) => any;
|
899
935
|
};
|
900
936
|
|
937
|
+
declare const JSX: any;
|
938
|
+
declare const TYPES: any;
|
939
|
+
declare const DECORATORS: any;
|
940
|
+
declare function using(fn: any, ...args: any[]): any;
|
941
|
+
|
901
942
|
declare function wait(fn: CallableFunction, ...args: any[]): any;
|
902
|
-
declare function clear(): void;
|
943
|
+
declare function clear(): void;
|
package/jsconfig.json
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
// Generated by CoffeeScript 2.7.0
|
2
|
-
(function () {
|
3
|
-
// This **Browser** compatibility layer extends core CoffeeScript functions
|
4
|
-
// to make things work smoothly when compiling code directly in the browser.
|
5
|
-
// We add support for loading remote Coffee scripts via **XHR**, and
|
6
|
-
// `text/coffeescript` script tags, source maps via data-URLs, and so on.
|
7
|
-
var CoffeeScript,
|
8
|
-
compile,
|
9
|
-
indexOf = [].indexOf;
|
10
|
-
|
11
|
-
CoffeeScript = require('./coffeescript');
|
12
|
-
|
13
|
-
({ compile } = CoffeeScript);
|
14
|
-
|
15
|
-
// Use `window.eval` to evaluate code, rather than just `eval`, to run the
|
16
|
-
// script in a clean global scope rather than inheriting the scope of the
|
17
|
-
// CoffeeScript compiler. (So that `cake test:browser` also works in Node,
|
18
|
-
// use either `window.eval` or `global.eval` as appropriate).
|
19
|
-
CoffeeScript.eval = function (code, options = {}) {
|
20
|
-
var globalRoot;
|
21
|
-
if (options.bare == null) {
|
22
|
-
options.bare = true;
|
23
|
-
}
|
24
|
-
globalRoot = typeof window !== 'undefined' && window !== null ? window : global;
|
25
|
-
return globalRoot['eval'](compile(code, options));
|
26
|
-
};
|
27
|
-
|
28
|
-
// Running code does not provide access to this scope.
|
29
|
-
CoffeeScript.run = function (code, options = {}) {
|
30
|
-
options.bare = true;
|
31
|
-
options.shiftLine = true;
|
32
|
-
return Function(compile(code, options))();
|
33
|
-
};
|
34
|
-
|
35
|
-
// Export this more limited `CoffeeScript` than what is exported by
|
36
|
-
// `index.coffee`, which is intended for a Node environment.
|
37
|
-
module.exports = CoffeeScript;
|
38
|
-
|
39
|
-
// If we’re not in a browser environment, we’re finished with the public API.
|
40
|
-
if (typeof window === 'undefined' || window === null) {
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
|
44
|
-
// Include source maps where possible. If we’ve got a base64 encoder, a
|
45
|
-
// JSON serializer, and tools for escaping unicode characters, we’re good to go.
|
46
|
-
// Ported from https://developer.mozilla.org/en-US/docs/DOM/window.btoa
|
47
|
-
if (typeof btoa !== 'undefined' && btoa !== null && typeof JSON !== 'undefined' && JSON !== null) {
|
48
|
-
compile = function (code, options = {}) {
|
49
|
-
options.inlineMap = true;
|
50
|
-
return CoffeeScript.compile(code, options);
|
51
|
-
};
|
52
|
-
}
|
53
|
-
|
54
|
-
// Load a remote script from the current domain via XHR.
|
55
|
-
CoffeeScript.load = function (url, callback, options = {}, hold = false) {
|
56
|
-
var xhr;
|
57
|
-
options.sourceFiles = [url];
|
58
|
-
xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new window.XMLHttpRequest();
|
59
|
-
xhr.open('GET', url, true);
|
60
|
-
if ('overrideMimeType' in xhr) {
|
61
|
-
xhr.overrideMimeType('text/plain');
|
62
|
-
}
|
63
|
-
xhr.onreadystatechange = function () {
|
64
|
-
var param, ref;
|
65
|
-
if (xhr.readyState === 4) {
|
66
|
-
if ((ref = xhr.status) === 0 || ref === 200) {
|
67
|
-
param = [xhr.responseText, options];
|
68
|
-
if (!hold) {
|
69
|
-
CoffeeScript.run(...param);
|
70
|
-
}
|
71
|
-
} else {
|
72
|
-
throw new Error(`Could not load ${url}`);
|
73
|
-
}
|
74
|
-
if (callback) {
|
75
|
-
return callback(param);
|
76
|
-
}
|
77
|
-
}
|
78
|
-
};
|
79
|
-
return xhr.send(null);
|
80
|
-
};
|
81
|
-
|
82
|
-
// Activate CoffeeScript in the browser by having it compile and evaluate
|
83
|
-
// all script tags with a content-type of `text/coffeescript`.
|
84
|
-
// This happens on page load.
|
85
|
-
CoffeeScript.runScripts = function () {
|
86
|
-
var coffees, coffeetypes, execute, i, index, j, len, s, script, scripts;
|
87
|
-
scripts = window.document.getElementsByTagName('script');
|
88
|
-
coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
|
89
|
-
coffees = (function () {
|
90
|
-
var j, len, ref, results;
|
91
|
-
results = [];
|
92
|
-
for (j = 0, len = scripts.length; j < len; j++) {
|
93
|
-
s = scripts[j];
|
94
|
-
if (((ref = s.type), indexOf.call(coffeetypes, ref) >= 0)) {
|
95
|
-
results.push(s);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
return results;
|
99
|
-
})();
|
100
|
-
index = 0;
|
101
|
-
execute = function () {
|
102
|
-
var param;
|
103
|
-
param = coffees[index];
|
104
|
-
if (param instanceof Array) {
|
105
|
-
CoffeeScript.run(...param);
|
106
|
-
index++;
|
107
|
-
return execute();
|
108
|
-
}
|
109
|
-
};
|
110
|
-
for (i = j = 0, len = coffees.length; j < len; i = ++j) {
|
111
|
-
script = coffees[i];
|
112
|
-
(function (script, i) {
|
113
|
-
var options, source;
|
114
|
-
options = {
|
115
|
-
literate: script.type === coffeetypes[1],
|
116
|
-
};
|
117
|
-
source = script.src || script.getAttribute('data-src');
|
118
|
-
if (source) {
|
119
|
-
options.filename = source;
|
120
|
-
return CoffeeScript.load(
|
121
|
-
source,
|
122
|
-
function (param) {
|
123
|
-
coffees[i] = param;
|
124
|
-
return execute();
|
125
|
-
},
|
126
|
-
options,
|
127
|
-
true,
|
128
|
-
);
|
129
|
-
} else {
|
130
|
-
// `options.filename` defines the filename the source map appears as
|
131
|
-
// in Developer Tools. If a script tag has an `id`, use that as the
|
132
|
-
// filename; otherwise use `coffeescript`, or `coffeescript1` etc.,
|
133
|
-
// leaving the first one unnumbered for the common case that there’s
|
134
|
-
// only one CoffeeScript script block to parse.
|
135
|
-
options.filename = script.id && script.id !== '' ? script.id : `coffeescript${i !== 0 ? i : ''}`;
|
136
|
-
options.sourceFiles = ['embedded'];
|
137
|
-
return (coffees[i] = [script.innerHTML, options]);
|
138
|
-
}
|
139
|
-
})(script, i);
|
140
|
-
}
|
141
|
-
return execute();
|
142
|
-
};
|
143
|
-
|
144
|
-
// Listen for window load, both in decent browsers and in IE.
|
145
|
-
// Only attach this event handler on startup for the
|
146
|
-
// non-ES module version of the browser compiler, to preserve
|
147
|
-
// backward compatibility while letting the ES module version
|
148
|
-
// be importable without side effects.
|
149
|
-
if (this === window) {
|
150
|
-
if (window.addEventListener) {
|
151
|
-
window.addEventListener('DOMContentLoaded', CoffeeScript.runScripts, false);
|
152
|
-
} else {
|
153
|
-
window.attachEvent('onload', CoffeeScript.runScripts);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
}).call(this);
|