@@ -112,14 +112,11 @@ function ace() {
112
112
function demo ( ) {
113
113
console . log ( '# kitchen sink ---------' ) ;
114
114
115
- var version , ref ;
115
+ var version = "" , ref = "" ;
116
116
try {
117
117
version = JSON . parse ( fs . readFileSync ( ACE_HOME + "/package.json" ) ) . version ;
118
118
ref = fs . readFileSync ( ACE_HOME + "/.git-ref" ) . toString ( ) ;
119
- } catch ( e ) {
120
- ref = "" ;
121
- version = "" ;
122
- }
119
+ } catch ( e ) { }
123
120
124
121
function changeComments ( data ) {
125
122
return ( data
@@ -131,16 +128,12 @@ function demo() {
131
128
. replace ( "%commit%" , ref )
132
129
) ;
133
130
}
134
-
135
- copy ( ACE_HOME + "/demo/kitchen-sink" , BUILD_DIR + "/demo/kitchen-sink" , {
136
- shallow : true ,
137
- replace : [ changeComments ] ,
138
- include : / \. ( c s s | h t m l ) $ /
139
- } ) ;
140
131
141
132
copy ( ACE_HOME + "/demo/kitchen-sink/docs/" , BUILD_DIR + "/demo/kitchen-sink/docs/" ) ;
142
133
143
134
copy . file ( ACE_HOME + "/demo/kitchen-sink/logo.png" , BUILD_DIR + "/demo/kitchen-sink/logo.png" ) ;
135
+ copy . file ( ACE_HOME + "/demo/kitchen-sink/styles.css" , BUILD_DIR + "/demo/kitchen-sink/styles.css" ) ;
136
+ copy . file ( ACE_HOME + "/kitchen-sink.html" , BUILD_DIR + "/kitchen-sink.html" , changeComments ) ;
144
137
145
138
buildSubmodule ( { } , {
146
139
require : [ "kitchen-sink/demo" ] ,
@@ -214,9 +207,9 @@ function buildAceModule(opts, callback) {
214
207
buildAceModule . dequeue = function ( ) {
215
208
if ( buildAceModule . running ) return ;
216
209
var call = buildAceModule . queue . shift ( ) ;
210
+ buildAceModule . running = call ;
217
211
if ( call )
218
212
buildAceModuleInternal . apply ( null , call ) ;
219
- buildAceModule . running = call ;
220
213
} ;
221
214
}
222
215
@@ -235,7 +228,7 @@ function buildAceModule(opts, callback) {
235
228
236
229
function buildAceModuleInternal ( opts , callback ) {
237
230
var cache = opts . cache == undefined ? CACHE : opts . cache ;
238
- var key = opts . require + "|" + opts . compress + "|" + opts . projectType ;
231
+ var key = opts . require + "|" + opts . projectType ;
239
232
if ( cache && cache . configs && cache . configs [ key ] )
240
233
return write ( null , cache . configs [ key ] ) ;
241
234
@@ -249,19 +242,23 @@ function buildAceModuleInternal(opts, callback) {
249
242
} ;
250
243
251
244
function write ( err , result ) {
252
- if ( opts . compress )
253
- result . code = compress ( result . code ) ;
254
-
255
- if ( cache && key ) {
245
+ if ( cache && key && ! ( cache . configs && cache . configs [ key ] ) ) {
256
246
cache . configs = cache . configs || Object . create ( null ) ;
257
247
cache . configs [ key ] = result ;
258
248
result . sources = result . sources . map ( function ( pkg ) {
259
249
return { deps : pkg . deps } ;
260
250
} ) ;
261
- }
251
+ }
262
252
263
253
if ( ! opts . outputFile )
264
254
return callback ( err , result ) ;
255
+
256
+ var code = result . code ;
257
+ if ( opts . compress ) {
258
+ if ( ! result . codeMin )
259
+ result . codeMin = compress ( result . code ) ;
260
+ code = result . codeMin ;
261
+ }
265
262
266
263
var targetDir = BUILD_DIR + "/src" ;
267
264
if ( opts . compress )
@@ -287,7 +284,6 @@ function buildAceModuleInternal(opts, callback) {
287
284
opts . noconflict ? ns : "" , projectType == "ext" ) ) ;
288
285
}
289
286
290
- var code = result . code ;
291
287
filters . forEach ( function ( f ) { code = f ( code ) ; } ) ;
292
288
293
289
build . writeToFile ( { code : code } , {
@@ -331,7 +327,7 @@ function buildSubmodule(options, extra, file, callback) {
331
327
options = extend ( extra , options ) ;
332
328
getLoadedFileList ( options , function ( coreFiles ) {
333
329
options . outputFile = file + ".js" ;
334
- options . ignore = coreFiles ;
330
+ options . ignore = options . ignore || coreFiles ;
335
331
options . quiet = true ;
336
332
buildAceModule ( options , callback ) ;
337
333
} ) ;
@@ -384,9 +380,10 @@ function buildAce(options) {
384
380
buildSubmodule ( options , {
385
381
projectType : "worker" ,
386
382
require : [ "ace/mode/" + name + "_worker" ] ,
383
+ ignore : [ ] ,
387
384
additional : [ {
388
385
id : "ace/worker/worker" ,
389
- loaderModule : true ,
386
+ transforms : [ ] ,
390
387
order : - 1000
391
388
} ] ,
392
389
} , "worker-" + name ) ;
@@ -467,9 +464,7 @@ function namespace(ns) {
467
464
return function ( text ) {
468
465
text = text
469
466
. toString ( )
470
- . replace ( 'var ACE_NAMESPACE = "";' , 'var ACE_NAMESPACE = "' + ns + '";' )
471
- // .replace(/(\.define)|([,;\n]|^\s*?)define\(/g, function(_, a, b) {
472
- // return a || b + ns + ".define(";
467
+ . replace ( / A C E _ N A M E S P A C E \s * = \s * " " / , 'ACE_NAMESPACE = "' + ns + '"' )
473
468
. replace ( / ( \. d e f i n e ) | \b d e f i n e \( / g, function ( _ , a ) {
474
469
return a || ns + ".define(" ;
475
470
} ) ;
@@ -551,20 +546,10 @@ function addSnippetFile(modeName) {
551
546
}
552
547
553
548
function compress ( text ) {
554
- return asciify ( require ( "dryice" ) . copy . filter . uglifyjs ( text ) ) ;
555
- // copy.filter.uglifyjs.options.ascii_only = true; doesn't work with some uglify.js versions
556
- function asciify ( text ) {
557
- return text . replace ( / [ \x00 - \x08 \x0b \x0c \x0e \x19 \x80 - \uffff ] / g, function ( c ) {
558
- c = c . charCodeAt ( 0 ) . toString ( 16 ) ;
559
- if ( c . length == 1 )
560
- return "\\x0" + c ;
561
- if ( c . length == 2 )
562
- return "\\x" + c ;
563
- if ( c . length == 3 )
564
- return "\\u0" + c ;
565
- return "\\u" + c ;
566
- } ) ;
567
- }
549
+ var ujs = require ( "dryice" ) . copy . filter . uglifyjs ;
550
+ ujs . options . mangle_toplevel = { except : [ "ACE_NAMESPACE" , "requirejs" ] } ;
551
+ ujs . options . beautify = { ascii_only : true , inline_script : true }
552
+ return ujs ( text ) ;
568
553
}
569
554
570
555
function extend ( base , extra ) {
0 commit comments