rsence-pre 2.2.0.13 → 2.2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0.13.pre
1
+ 2.2.0.14.pre
@@ -26,6 +26,12 @@
26
26
  #
27
27
  # A list of javascript dependencies to include in the html
28
28
  :deps: [ ]
29
+ #
30
+ # Boot library:
31
+ :boot_lib: core
32
+ #
33
+ # Default additional libraries to use:
34
+ :default_libs: []
29
35
  #
30
36
  # The settings for the main plugin
31
37
  :main_plugin:
@@ -315,14 +321,23 @@
315
321
  graphics:
316
322
  - svgcontrol
317
323
 
318
- # Special packages that include other packages (not used currently)
324
+ # Special packages that include other packages
319
325
  :compound_packages:
320
- allinone:
326
+ rsence:
321
327
  - core
322
328
  - default_theme
323
329
  - controls
324
330
  - lists
325
331
  - datetime
332
+ - graphics
333
+ - servermessage
334
+ std_widgets:
335
+ - default_theme
336
+ - controls
337
+ - lists
338
+ - datetime
339
+ - graphics
340
+ - servermessage
326
341
 
327
342
  # List of variables and other names beginning
328
343
  # with a underscore that should not be obfuscated
@@ -7,11 +7,11 @@
7
7
  */
8
8
 
9
9
  // Starts the synchronization upon page load.
10
- LOAD(
11
- function(){
10
+ COMM.AutoSyncStarter = {
11
+ start: function(){
12
12
  COMM.urlResponder=COMM.URLResponder.nu();
13
13
  COMM.Transporter.url=COMM.Transporter.HelloUrl;
14
14
  COMM.Transporter.stop=false;
15
15
  COMM.Transporter.sync();
16
16
  }
17
- );
17
+ };
@@ -35,6 +35,18 @@ COMM.JSLoader = HClass.extend({
35
35
  console.log("failed to load js: "+_resp.url);
36
36
  },
37
37
 
38
+ _formatUrl: function( _jsName ){
39
+ var
40
+ _this = this,
41
+ _isFullUrl = _jsName.slice(0,7) === 'http://' || _jsName.slice(0,8) === 'https://',
42
+ _url = _isFullUrl?_jsName:_this.uri+_jsName+'.js';
43
+ return _url;
44
+ },
45
+ loaded: function(_jsName){
46
+ var _url = this._formatUrl( _jsName );
47
+ this._loadedJS.push( _url );
48
+ },
49
+
38
50
  /** = Description
39
51
  * Loads a js package using the name.
40
52
  *
@@ -51,12 +63,13 @@ COMM.JSLoader = HClass.extend({
51
63
  *
52
64
  **/
53
65
  load: function(_jsName){
54
- var _this = this,
55
- _isFullUrl = _jsName.slice(0,7) === 'http://' || _jsName.slice(0,8) === 'https://',
56
- _url = _isFullUrl?_jsName:_this.uri+_jsName+'.js';
66
+ var
67
+ _this = this,
68
+ _url = _this._formatUrl( _jsName );
57
69
  if((_this._loadedJS.indexOf(_url)!==-1)) {
58
70
  return;
59
71
  }
72
+ // console.log('jsLoader load:',_url);
60
73
  COMM.Queue.pause();
61
74
  _this._loadedJS.push(_url);
62
75
  if(BROWSER_TYPE.symbian && _isFullUrl){
@@ -18,6 +18,8 @@ var RSence = {
18
18
  COMM.ClientPrefix=_clientPrefix;
19
19
  COMM.Transporter.HelloUrl=_helloUrl;
20
20
  HThemeManager.themePath=_clientPrefix+'/themes';
21
+ HThemeManager._start();
22
+ COMM.AutoSyncStarter.start();
21
23
  },
22
24
 
23
25
  // Structure reserved for JSONRenderer instances remotely populated by the server
@@ -388,6 +388,27 @@ HThemeManager = HClass.extend({
388
388
  _cssTmpl = _cssTmpl.replace( this._variable_match, eval( RegExp.$1 ) );
389
389
  }
390
390
  return _cssTmpl;
391
+ },
392
+
393
+ _initFns: [],
394
+ _pushStarted: false,
395
+ _pushStart: function( _fn ){
396
+ if(this._pushStarted){
397
+ _fn();
398
+ }
399
+ else{
400
+ this._initFns.push( _fn );
401
+ }
402
+ },
403
+ _start: function(){
404
+ var
405
+ _this = this,
406
+ i = 0;
407
+ _this._pushStarted = true;
408
+ for( ; i<_this._initFns.length; i++){
409
+ _this._initFns[i]();
410
+ }
411
+ _this._initFns = [];
391
412
  }
392
413
 
393
414
  });
@@ -283,6 +283,12 @@ module RSence
283
283
  # Check the required dependencies until everything is loaded.
284
284
  dependencies.each do |dependency|
285
285
  unless ses[:deps].include?( dependency )
286
+ if RSence.config[:client_pkg][:compound_packages].include?( dependency )
287
+ RSence.config[:client_pkg][:compound_packages][dependency].each do |pkg_name|
288
+ ses[:deps].push( pkg_name )
289
+ msg.reply(%{jsLoader.loaded("#{pkg_name}");})
290
+ end
291
+ end
286
292
  ses[:deps].push( dependency )
287
293
  msg.reply(%{jsLoader.load("#{dependency}");})
288
294
  end
data/lib/session/msg.rb CHANGED
@@ -251,6 +251,9 @@ module RSence
251
251
  ## The response status should always be 200 (OK)
252
252
  @response.status = 200
253
253
 
254
+ @value_buffer.delete( :new ) if @value_buffer[:new].empty?
255
+ @value_buffer.delete( :set ) if @value_buffer[:set].empty?
256
+ @value_buffer.delete( :del ) if @value_buffer[:del].empty?
254
257
  buffer = [
255
258
  @ses_key,
256
259
  @value_buffer,
@@ -10,6 +10,11 @@
10
10
  require 'jsmin_c'
11
11
  require 'jscompress'
12
12
  require 'html_min'
13
+ begin
14
+ require 'coffee-script'
15
+ rescue LoadError
16
+ warn "CoffeeScript not installed. Install the 'coffee-script' gem to enable."
17
+ end
13
18
 
14
19
 
15
20
  class ClientPkgBuild
@@ -99,7 +104,7 @@ class ClientPkgBuild
99
104
  :gzip => gz_css
100
105
  }
101
106
  @theme_sizes[ theme_name ][:css][0] += File.stat( src_file_css ).size
102
- @theme_sizes[ theme_name ][:css][1] += css_data.size
107
+ @theme_sizes[ theme_name ][:css][1] += css_data.bytesize
103
108
  @css_by_theme[ theme_name ][ bundle_name ] = css_data
104
109
  end
105
110
  end
@@ -113,17 +118,18 @@ class ClientPkgBuild
113
118
  :gzip => gz_html
114
119
  }
115
120
  @theme_sizes[ theme_name ][:html][0] += File.stat( src_file_html ).size
116
- @theme_sizes[ theme_name ][:html][1] += html_data.size
121
+ @theme_sizes[ theme_name ][:html][1] += html_data.bytesize
117
122
  @html_by_theme[ theme_name ][ bundle_name ] = html_data
118
123
  end
119
124
  end
120
125
  tgt_hash_gfx = tgt_hash_theme[:gfx]
121
126
  gfx_size = read_gfx( src_path_theme, tgt_hash_gfx )
127
+ puts "gfx size of #{bundle_name}: #{gfx_size.inspect}"
122
128
  @theme_sizes[ theme_name ][:gfx] += gfx_size
123
129
  end
124
130
  end
125
131
 
126
- def add_bundle( bundle_name, bundle_path, entries )
132
+ def add_bundle( bundle_name, bundle_path, entries, has_coffee=false )
127
133
  has_themes = entries.include?( 'themes' ) and File.directory?( File.join( bundle_path, 'themes' ) )
128
134
  if @bundles_found.has_key?( bundle_name )
129
135
  @logger.log( "JSBuilder ERROR: duplicate bundles with the name #{bundle_name.inspect} found." )
@@ -136,11 +142,15 @@ class ClientPkgBuild
136
142
  warn "JSBuilder WARNING: bundle name #{bundle_name.inspect} does not belong to any package, skipping.." if ARGV.include?('-d')
137
143
  return true
138
144
  end
139
- js_data = read_file( File.join( bundle_path, bundle_name+'.js' ) )
145
+ if has_coffee
146
+ js_data = CoffeeScript.compile( read_file( File.join( bundle_path, bundle_name+'.js' ) ) )
147
+ else
148
+ js_data = read_file( File.join( bundle_path, bundle_name+'.js' ) )
149
+ end
140
150
  @bundles_found[ bundle_name ] = {
141
151
  :path => bundle_path,
142
152
  :js_data => js_data,
143
- :js_size => js_data.size,
153
+ :js_size => js_data.bytesize,
144
154
  :has_themes => has_themes
145
155
  }
146
156
  if has_themes
@@ -157,10 +167,13 @@ class ClientPkgBuild
157
167
  # the name of src_dir (src_dir itself is a full path)
158
168
  dir_name = File.split( src_dir )[1]
159
169
  # bundles are defined as directories with a js file of the same name plus the 'js.inc' tagfile
160
- is_bundle = ( not dir_entries.include?( 'disabled' ) ) and ( dir_entries.include?( dir_name+'.js' ) or dir_entries.include?( 'main.js' ) )
170
+ not_disabled = ( not dir_entries.include?( 'disabled' ) )
171
+ has_js = dir_entries.include?( dir_name+'.js' ) #or dir_entries.include?( 'main.js' )
172
+ has_coffee = dir_entries.include?( dir_name+'.coffee' ) #or dir_entries.include?( 'main.coffee' )
173
+ is_bundle = not_disabled and ( has_js or has_coffee )
161
174
  # if src_dir is detected as a bundle, handle it in add_bundle
162
175
  if is_bundle
163
- add_bundle( dir_name, src_dir, dir_entries )
176
+ add_bundle( dir_name, src_dir, dir_entries, has_coffee )
164
177
  end
165
178
  # descend into the sub-directory:
166
179
  dir_entries.each do | dir_entry |
@@ -193,27 +206,19 @@ class ClientPkgBuild
193
206
  @logger.log( " : | |" )
194
207
  end
195
208
  @destination_files.each_key do | package_name |
196
- jsc_data = @destination_files[package_name]
197
- unless @debug
198
- unless @no_whitespace_removal
199
- jsc_data = @jsmin.minimize( jsc_data ) #.strip
200
- end
201
- unless @no_obfuscation
202
- jsc_data = pre_convert( jsc_data )
203
- end
204
- end
205
- @js[package_name] = jsc_data.strip
209
+ jsc_data = process_js( @destination_files[package_name] )
210
+ @js[package_name] = jsc_data
206
211
  unless @no_gzip
207
- gz_data = gzip_string( @js[package_name] )
212
+ gz_data = gzip_string( jsc_data )
208
213
  @gz[package_name] = gz_data
209
214
  end
210
215
  unless @quiet
211
- js_size = @destination_files[ package_name ].size
212
- jsc_size = jsc_data.size
216
+ js_size = @destination_files[ package_name ].bytesize
217
+ jsc_size = jsc_data.bytesize
213
218
  if @no_gzip
214
219
  gz_size = -1
215
220
  else
216
- gz_size = gz_data.size
221
+ gz_size = gz_data.bytesize
217
222
  end
218
223
  print_stat( package_name, js_size, jsc_size, gz_size )
219
224
  end
@@ -234,6 +239,17 @@ class ClientPkgBuild
234
239
  end
235
240
  return js.strip
236
241
  end
242
+
243
+ def process_js( src_in )
244
+ if @debug
245
+ return src_in
246
+ else
247
+ src_out = src_in
248
+ src_out = @jsmin.minimize( src_out ) unless @no_whitespace_removal
249
+ src_out = pre_convert( src_out ) unless @no_obfuscation
250
+ return src_out.strip
251
+ end
252
+ end
237
253
 
238
254
  def build_themes
239
255
  unless @quiet
@@ -250,24 +266,21 @@ class ClientPkgBuild
250
266
  theme_html_js_arr.push "HThemeManager._tmplCache[#{theme_name.to_json}]=#{html_templates.to_json}; "
251
267
  theme_html_js_arr.push "HNoComponentCSS.push(#{theme_name.to_json});"
252
268
  theme_html_js_arr.push "HNoCommonCSS.push(#{theme_name.to_json});"
253
- theme_html_js_arr.push "HThemeManager._cssUrl( #{theme_name.to_json}, #{(theme_name+'_theme').to_json}, HThemeManager.themePath, null );"
254
- theme_html_js_arr.push "HThemeManager.useCSS(#{theme_css_template_data.to_json}); "
255
- theme_html_js = theme_html_js_arr.join('')
256
- unless @debug
257
- unless @no_whitespace_removal
258
- theme_html_js = @jsmin.minimize( theme_html_js ) #.strip
259
- end
260
- unless @no_obfuscation
261
- theme_html_js = pre_convert( theme_html_js )
262
- end
263
- end
264
- @js[theme_name+'_theme'] = theme_html_js.strip
269
+ theme_html_js_arr.push %{
270
+ HThemeManager._pushStart( function(){
271
+ var _this = HThemeManager;
272
+ _this._cssUrl( #{theme_name.to_json}, #{(theme_name+'_theme').to_json}, _this.themePath, null );
273
+ _this.useCSS(#{theme_css_template_data.to_json});
274
+ } );
275
+ }
276
+ theme_html_js = process_js( theme_html_js_arr.join('') )
277
+ @js[theme_name+'_theme'] = theme_html_js
265
278
  unless @no_gzip
266
279
  theme_html_gz = gzip_string( @js[theme_name+'_theme'] )
267
280
  @gz[theme_name+'_theme'] = theme_html_gz
268
281
  end
269
282
  unless @quiet
270
- print_stat( "#{theme_name}/html", @theme_sizes[theme_name][:html][0], @theme_sizes[theme_name][:html][1], theme_html_gz.size )
283
+ print_stat( "#{theme_name}/html", @theme_sizes[theme_name][:html][0], @theme_sizes[theme_name][:html][1], theme_html_gz.bytesize )
271
284
  end
272
285
  @themes[theme_name][:css][theme_name+'_theme'] = {
273
286
  :data => theme_css_template_data,
@@ -278,13 +291,43 @@ class ClientPkgBuild
278
291
  @themes[theme_name][:css][theme_name+'_theme'][:gzip] = theme_css_template_data_gz
279
292
  end
280
293
  unless @quiet
281
- print_stat( "#{theme_name}/css", @theme_sizes[theme_name][:css][0], @theme_sizes[theme_name][:css][1], theme_css_template_data_gz.size )
294
+ print_stat( "#{theme_name}/css", @theme_sizes[theme_name][:css][0], @theme_sizes[theme_name][:css][1], theme_css_template_data_gz.bytesize )
282
295
  print_stat( "#{theme_name}/gfx", @theme_sizes[theme_name][:gfx], -1, -1 )
283
296
  @logger.log( '' )
284
297
  end
285
298
  end
286
299
  end
287
300
 
301
+ def build_compound_packages
302
+ unless @quiet
303
+ @logger.log( '' )
304
+ @logger.log( "Compound package..............: Original | Minimized | Compressed" )
305
+ @logger.log( " : | |" )
306
+ end
307
+ @compound_config.each do |pkg_name, js_order|
308
+ pkg_parts = []
309
+ js_order.each do |js_pkg|
310
+ pkg_part = @js[ js_pkg ]
311
+ pkg_parts.push( pkg_part )
312
+ end
313
+ js_src = pkg_parts.join('')
314
+ @js[ pkg_name ] = js_src
315
+ unless @no_gzip
316
+ gz_data = gzip_string( js_src )
317
+ @gz[ pkg_name ] = gz_data
318
+ end
319
+ unless @quiet
320
+ js_size = js_src.bytesize
321
+ if @no_gzip
322
+ gz_size = -1
323
+ else
324
+ gz_size = gz_data.bytesize
325
+ end
326
+ print_stat( pkg_name, js_size, -1, gz_size )
327
+ end
328
+ end
329
+ end
330
+
288
331
  def run
289
332
 
290
333
  time_start = Time.now.to_f*10000
@@ -326,8 +369,9 @@ class ClientPkgBuild
326
369
  end
327
370
 
328
371
  build_indexes
329
- minimize_data
330
372
  build_themes
373
+ minimize_data
374
+ build_compound_packages
331
375
 
332
376
  ms_taken = ((Time.now.to_f*10000)-time_start).to_i/10.0
333
377
  @logger.log( "Time taken: #{ms_taken}ms\n\n" )
@@ -505,6 +549,7 @@ class ClientPkgBuild
505
549
  @no_whitespace_removal = config[:no_whitespace_removal]
506
550
  @debug = RSence.args[:debug]
507
551
  @quiet = (not RSence.args[:verbose])
552
+ @compound_config = config[:compound_packages]
508
553
  end
509
554
 
510
555
  def find_newer( src_dir, newer_than )
data/plugins/main/main.rb CHANGED
@@ -69,14 +69,18 @@ class MainPlugin < Plugin
69
69
  @conf[:deps].each do |dep|
70
70
  deps_src += %{<script src="#{dep}" type="text/javascript"></script>}
71
71
  end
72
+ deps_src += %{<script src="__CLIENT_BASE__/js/#{@conf[:boot_lib]}.js"></script>}
73
+ @conf[:default_libs].each do |dep|
74
+ deps_src += %{<script src="__CLIENT_BASE__/js/#{dep}.js"></script>}
75
+ end
72
76
  client_base = File.join(@bconf[:h],client_rev)
73
77
 
78
+ index_html.gsub!( '__SCRIPT_DEPS__', deps_src )
74
79
  index_html.gsub!( '__CLIENT_BASE__', client_base )
75
80
  index_html.gsub!( '__DEFAULT_TITLE__', @conf[:title] )
76
81
  index_html.gsub!( '__CLIENT_REV__', client_rev )
77
82
  index_html.gsub!( '__CLIENT_HELLO__', @bconf[:hello] )
78
83
  index_html.gsub!( '__NOSCRIPT__', @conf[:noscript] )
79
- index_html.gsub!( '__SCRIPT_DEPS__', deps_src )
80
84
 
81
85
  return index_html
82
86
  end
@@ -234,10 +238,46 @@ class MainPlugin < Plugin
234
238
  restore_ses( msg )
235
239
  end
236
240
 
241
+ def index_deps_setup( msg )
242
+ ses = msg.session
243
+ if not ses.has_key?( :deps )
244
+ # make an array of dependencies for this session, if not already done
245
+ ses[:deps] = []
246
+ end
247
+ compound_pkgs = RSence.config[:client_pkg][:compound_packages]
248
+ boot_dep = @conf[:boot_lib]
249
+ unless ses[:deps].include?( boot_dep )
250
+ if compound_pkgs.include?( boot_dep )
251
+ compound_pkgs[ boot_dep ].each do |pkg_name|
252
+ ses[:deps].push( pkg_name )
253
+ msg.reply(%{jsLoader.loaded("#{pkg_name}");})
254
+ end
255
+ end
256
+ ses[:deps].push( boot_dep )
257
+ msg.reply(%{jsLoader.loaded("#{boot_dep}");})
258
+ if boot_dep == 'rsence'
259
+ ses[:deps].push( 'std_widgets' )
260
+ msg.reply(%{jsLoader.loaded("std_widgets");})
261
+ end
262
+ end
263
+ @conf[:default_libs].each do |dep_lib|
264
+ unless ses[:deps].include?( dep_lib )
265
+ if compound_pkgs.include?( dep_lib )
266
+ compound_pkgs[ dep_lib ].each do |pkg_name|
267
+ ses[:deps].push( pkg_name )
268
+ msg.reply(%{jsLoader.loaded("#{pkg_name}");})
269
+ end
270
+ end
271
+ ses[:deps].push( dep_lib )
272
+ msg.reply(%{jsLoader.loaded("#{dep_lib}");})
273
+ end
274
+ end
275
+ end
237
276
 
238
277
  # Called once when a session is restored or cloned using the cookie's ses_key
239
278
  def restore_ses( msg )
240
279
  super
280
+ index_deps_setup( msg )
241
281
  ## Resets session data to defaults
242
282
  ses = get_ses( msg )
243
283
  ses[:boot] = 0
@@ -4,7 +4,6 @@
4
4
  <title>__DEFAULT_TITLE__</title>
5
5
  <style type="text/css">body{margin:0;padding:0;background-color:#ddd;font-family:Arial,sans-serif;}</style>
6
6
  __SCRIPT_DEPS__
7
- <script src="__CLIENT_BASE__/js/core.js"></script>
8
7
  <!--[if lt IE 7]><script src="__CLIENT_BASE__/js/iefix.js"></script><![endif]-->
9
8
 
10
9
  <script>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsence-pre
3
3
  version: !ruby/object:Gem::Version
4
- hash: 101
4
+ hash: 99
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
9
  - 0
10
- - 13
11
- version: 2.2.0.13
10
+ - 14
11
+ version: 2.2.0.14
12
12
  platform: ruby
13
13
  authors:
14
14
  - Riassence Inc.
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-07-23 00:00:00 Z
19
+ date: 2011-07-26 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rsence-deps