envjs 0.2.0 → 0.3.0
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/CHANGELOG.rdoc +5 -0
- data/Manifest.txt +0 -2
- data/Wakefile +2 -19
- data/bin/envjsrb +12 -9
- data/lib/envjs/env.js +4 -5
- data/lib/envjs/event_loop.js +2 -2
- data/lib/envjs/net/file.rb +0 -6
- data/lib/envjs/options.rb +3 -3
- data/lib/envjs/runtime.rb +22 -107
- data/lib/envjs/static.js +1 -0
- data/lib/envjs.rb +1 -1
- data/src/window/event.js +2 -4
- data/src/window/location.js +2 -1
- data/src/xpath/implementation.js +1 -0
- metadata +6 -8
- data/test/vendor/jQuery/README +0 -2
- data/test/vendor/prototype-1.6.0.3.js +0 -4320
data/CHANGELOG.rdoc
CHANGED
data/Manifest.txt
CHANGED
data/Wakefile
CHANGED
@@ -1,24 +1,7 @@
|
|
1
|
-
|
2
|
-
begin; require 'wake/deps'; rescue LoadError; end
|
1
|
+
# -*- mode: ruby -*-
|
3
2
|
|
4
|
-
watch
|
5
|
-
File.directory? md[0] and raise Wake::Refresh
|
6
|
-
end
|
7
|
-
|
8
|
-
watch( %r(env-js.wake), :modified ) do |md|
|
9
|
-
raise Wake::Refresh
|
10
|
-
end
|
11
|
-
|
12
|
-
watch( %r((^src/.*)\.js$), [:load, :created, :modified], nil, :batch => :js ) do
|
3
|
+
watch %r{(^src/.*)\.js$} do
|
13
4
|
cmd = "rake johnson:compile"
|
14
5
|
puts cmd
|
15
6
|
system cmd
|
16
7
|
end
|
17
|
-
|
18
|
-
Signal.trap('QUIT') do
|
19
|
-
EM.stop
|
20
|
-
end
|
21
|
-
|
22
|
-
# Local Variables:
|
23
|
-
# mode:ruby
|
24
|
-
# End:
|
data/bin/envjsrb
CHANGED
@@ -138,25 +138,20 @@ if ARGV.length > 0
|
|
138
138
|
uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
|
139
139
|
|
140
140
|
if uri.scheme == "about" and uri.opaque == "blank"
|
141
|
+
# $stderr.puts "wait before set about"
|
141
142
|
RUNTIME.wait
|
142
143
|
RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
|
143
144
|
about_blank = true
|
144
145
|
elsif uri.path =~ /\.x?html?$/ || uri.scheme =~ %r(^https?)
|
145
|
-
|
146
|
-
|
147
|
-
# that wanted this
|
148
|
-
if !about_blank
|
149
|
-
RUNTIME.wait
|
150
|
-
RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
|
151
|
-
end
|
152
|
-
|
153
|
-
RUNTIME.wait
|
146
|
+
# $stderr.puts "wait before set real" if RUNTIME.evaluate("window.location.href") != "about:blank"
|
147
|
+
RUNTIME.wait if RUNTIME.evaluate("window.location.href") != "about:blank"
|
154
148
|
# RUNTIME.evaluate("window.location = 'file://#{Pathname.new(file).realpath}'", file, 1)
|
155
149
|
RUNTIME.evaluate("window.location = '#{uri_s}'", file, 1)
|
156
150
|
about_blank = false
|
157
151
|
else
|
158
152
|
RUNTIME.top_level_load uri_s
|
159
153
|
RUNTIME.load uri_s
|
154
|
+
RUNTIME.top_level_load nil
|
160
155
|
end
|
161
156
|
end
|
162
157
|
rescue Johnson::Error => je
|
@@ -168,6 +163,14 @@ if ARGV.length > 0
|
|
168
163
|
|
169
164
|
RUNTIME.wait
|
170
165
|
|
166
|
+
if !$wake_info.empty?
|
167
|
+
puts "<wake><![CDATA["
|
168
|
+
puts $wake_info.join("\n")
|
169
|
+
puts "]]></wake>"
|
170
|
+
$stdout.flush
|
171
|
+
end
|
172
|
+
|
173
|
+
|
171
174
|
else
|
172
175
|
|
173
176
|
prep
|
data/lib/envjs/env.js
CHANGED
@@ -1868,7 +1868,8 @@ $w.__defineSetter__("location", function(url){
|
|
1868
1868
|
}
|
1869
1869
|
// print("ft",window.location.href,$location,url);
|
1870
1870
|
}
|
1871
|
-
|
1871
|
+
// debug("l",url,$w.location);
|
1872
|
+
if( !$location || ( $location == "about:blank" && url !== "about:blank" ) ) {
|
1872
1873
|
// $w.__loadAWindowsDocument__(url);
|
1873
1874
|
$env.load(url);
|
1874
1875
|
} else {
|
@@ -2326,13 +2327,11 @@ $w.dispatchEvent = function(event, bubbles){
|
|
2326
2327
|
};
|
2327
2328
|
|
2328
2329
|
$w.__defineGetter__('onerror', function(){
|
2329
|
-
|
2330
|
-
//$w.dispatchEvent('error');
|
2331
|
-
};
|
2330
|
+
return $onerror;
|
2332
2331
|
});
|
2333
2332
|
|
2334
2333
|
$w.__defineSetter__('onerror', function(fn){
|
2335
|
-
|
2334
|
+
return $onerror = fn;
|
2336
2335
|
});
|
2337
2336
|
|
2338
2337
|
/*$w.__defineGetter__('onload', function(){
|
data/lib/envjs/event_loop.js
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
var $env = {};
|
8
8
|
$env.sync = function(f){return f;};
|
9
9
|
$env.error = function(s){
|
10
|
-
|
10
|
+
debug("timer error: "+s);
|
11
11
|
if (s.stack) {
|
12
|
-
|
12
|
+
debug("timer error: "+s.stack);
|
13
13
|
}
|
14
14
|
};
|
15
15
|
$env.sleep = function(t){ Ruby.sleep(t/1000.); };
|
data/lib/envjs/net/file.rb
CHANGED
@@ -4,10 +4,6 @@ require 'envjs/net'
|
|
4
4
|
|
5
5
|
class Envjs::Net::File < Net::Protocol
|
6
6
|
|
7
|
-
class << self
|
8
|
-
attr_accessor :on_open
|
9
|
-
end
|
10
|
-
|
11
7
|
class Get
|
12
8
|
attr_accessor :path
|
13
9
|
def initialize path
|
@@ -36,8 +32,6 @@ class Envjs::Net::File < Net::Protocol
|
|
36
32
|
class Response
|
37
33
|
def initialize path
|
38
34
|
@path = path
|
39
|
-
on_open = Envjs::Net::File.on_open
|
40
|
-
on_open and on_open.call( path )
|
41
35
|
@file = File.new @path
|
42
36
|
@body = @file.read
|
43
37
|
@code = @file.nil? ? "404" : "200";
|
data/lib/envjs/options.rb
CHANGED
data/lib/envjs/runtime.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'envjs'
|
2
2
|
require "open-uri"
|
3
3
|
require 'pathname'
|
4
|
-
begin
|
5
|
-
require 'fsdb'
|
6
|
-
rescue LoadError; end
|
7
4
|
require 'envjs/net/file'
|
8
5
|
|
6
|
+
$wake_info = []
|
7
|
+
|
9
8
|
module Envjs::Runtime
|
10
9
|
|
11
10
|
def self.extended object
|
@@ -103,6 +102,7 @@ debug = function() {
|
|
103
102
|
}
|
104
103
|
}
|
105
104
|
Ruby['$stderr'].print("\n");
|
105
|
+
Ruby['$stderr'].flush();
|
106
106
|
};
|
107
107
|
EOJS
|
108
108
|
|
@@ -141,98 +141,20 @@ EOJS
|
|
141
141
|
# calling this from JS is hosed; the ruby side is confused, maybe because HTTPHeaders is mixed in?
|
142
142
|
master.add_req_field = lambda { |r,k,v| r.add_field(k,v) }
|
143
143
|
|
144
|
-
db = lambda do
|
145
|
-
$envjsrb_deps && ( @db ||= FSDB::Database.new $envjsrb_deps )
|
146
|
-
end
|
147
|
-
|
148
144
|
top_level_js = nil
|
149
145
|
|
150
146
|
add_dep = nil
|
151
147
|
|
152
|
-
clear_deps = lambda do |w|
|
153
|
-
begin
|
154
|
-
if db.call
|
155
|
-
loc = w
|
156
|
-
begin loc = w.location; rescue; end
|
157
|
-
loc && ( loc = loc.to_s )
|
158
|
-
if ( loc !~ %r((http?s|file|about):) )
|
159
|
-
begin
|
160
|
-
loc = "file://" + Pathname(loc).realpath.to_s
|
161
|
-
rescue Errno::ENOENT; end
|
162
|
-
end
|
163
|
-
# $stderr.puts "clear", loc
|
164
|
-
if loc and loc != "about:blank"
|
165
|
-
paths = db.call[loc+".on.yml"] || []
|
166
|
-
paths.each do |path|
|
167
|
-
# $stderr.print "#{path} not by #{loc}\n";
|
168
|
-
db.call[path+".by.yml"].delete loc
|
169
|
-
end
|
170
|
-
# $stderr.print "#{loc} not on anything\n";
|
171
|
-
db.call.delete loc+".on.yml"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
add_dep.call( nil, loc )
|
175
|
-
rescue Exception => e; $stderr.puts e, e.class; $stderr.puts e.backtrace; end
|
176
|
-
end
|
177
|
-
|
178
|
-
if $envjsrb_deps
|
179
|
-
Envjs::Net::File.on_open = clear_deps
|
180
|
-
end
|
181
|
-
|
182
148
|
add_dep = lambda do |w, f|
|
183
|
-
if
|
184
|
-
|
185
|
-
begin loc = w.location; rescue Exception; end
|
186
|
-
loc && ( loc = loc.to_s )
|
187
|
-
if ( loc && loc !~ %r((http?s|file|about):) )
|
188
|
-
loc = "file://" + Pathname(loc).realpath.to_s
|
189
|
-
end
|
190
|
-
path = f
|
191
|
-
if ( path !~ %r((http?s|file|about):) )
|
192
|
-
begin
|
193
|
-
path = "file://" + Pathname(path).realpath.to_s
|
194
|
-
rescue Errno::ENOENT
|
195
|
-
return
|
196
|
-
end
|
197
|
-
end
|
198
|
-
if !loc || loc == "about:blank"
|
199
|
-
uri = URI.parse top_level_js
|
200
|
-
if uri.scheme == nil
|
201
|
-
uri.scheme = "file"
|
202
|
-
begin
|
203
|
-
uri.path = Pathname.new(uri.path).realpath.to_s
|
204
|
-
rescue Errno::ENOENT; end
|
205
|
-
uri = URI.parse uri.to_s
|
206
|
-
end
|
207
|
-
uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
|
208
|
-
|
209
|
-
# tll = "file://" + Pathname(top_level_js).realpath.to_s
|
210
|
-
|
211
|
-
tll = uri_s
|
212
|
-
|
213
|
-
if ( tll != path )
|
214
|
-
loc = tll
|
215
|
-
end
|
216
|
-
end
|
217
|
-
if loc and loc != "about:blank"
|
218
|
-
on = db.call[loc+".on.yml"] || []
|
219
|
-
on << path
|
220
|
-
on.uniq!
|
221
|
-
db.call[loc+".on.yml"] = on
|
222
|
-
by = db.call[path+".by.yml"] || []
|
223
|
-
by << loc
|
224
|
-
by.uniq!
|
225
|
-
db.call[path+".by.yml"] = by
|
226
|
-
# $stderr.print "#{loc} on #{path}: #{db.call[loc+'.on.yml'].join(' ')}\n"
|
227
|
-
# $stderr.print "#{path} by #{loc}: #{db.call[path+'.by.yml'].join(' ')}\n"
|
228
|
-
end
|
149
|
+
if $envjsrb_wake
|
150
|
+
$wake_info << "##file://#{f}"
|
229
151
|
end
|
230
152
|
end
|
231
153
|
|
232
154
|
(class << self; self; end).send :define_method, :top_level_load do |path|
|
233
|
-
|
234
|
-
|
235
|
-
|
155
|
+
if $envjsrb_wake
|
156
|
+
$wake_info << "##{path}" if path
|
157
|
+
end
|
236
158
|
end
|
237
159
|
|
238
160
|
master.load = lambda { |*files|
|
@@ -270,7 +192,7 @@ EOJS
|
|
270
192
|
end
|
271
193
|
}
|
272
194
|
|
273
|
-
|
195
|
+
( class << self; self; end ).send :define_method, :load do |*files|
|
274
196
|
files.map { |f|
|
275
197
|
# Hmmm ...
|
276
198
|
|
@@ -285,11 +207,22 @@ EOJS
|
|
285
207
|
uri_s = uri.to_s.sub %r(^file:/([^/])), 'file:///\1'
|
286
208
|
|
287
209
|
if uri.scheme == "file"
|
288
|
-
|
210
|
+
begin
|
211
|
+
super uri.path
|
212
|
+
rescue Exception => e
|
213
|
+
if outer["$inner"]["onerror"]
|
214
|
+
# outer["$inner"]["onerror"].call e
|
215
|
+
evaluate("function(fn,scope,e){fn.call(scope,e)}").call(outer["$inner"]["onerror"], outer["$inner"], e)
|
216
|
+
else
|
217
|
+
raise e
|
218
|
+
end
|
219
|
+
end
|
289
220
|
elsif uri.scheme == "data"
|
290
221
|
raise "implement 1"
|
222
|
+
elsif uri.scheme == "javascript"
|
223
|
+
evaluate(URI.decode(uri.opaque),URI.decode(uri_s),1)
|
291
224
|
else
|
292
|
-
raise "hell 1"
|
225
|
+
raise "hell 1: " + uri.inspect
|
293
226
|
end
|
294
227
|
|
295
228
|
# v = open(uri_s).read.gsub(/\A#!.*$/, '')
|
@@ -391,22 +324,6 @@ EOJS
|
|
391
324
|
|
392
325
|
master.load.call Envjs::EVENT_LOOP, global
|
393
326
|
|
394
|
-
if false
|
395
|
-
static_outer = new_split_global_outer
|
396
|
-
static_inner = new_split_global_inner static_outer
|
397
|
-
|
398
|
-
master.symbols.each do |symbol|
|
399
|
-
static_inner[symbol] = master[symbol]
|
400
|
-
end
|
401
|
-
|
402
|
-
static_inner["$inner"] = static_inner
|
403
|
-
static_inner["$master"] = master
|
404
|
-
|
405
|
-
master.load.call Envjs::STATIC, static_inner
|
406
|
-
|
407
|
-
master["static"] = static_inner
|
408
|
-
end
|
409
|
-
if true
|
410
327
|
static = new_global
|
411
328
|
|
412
329
|
master.symbols.each do |symbol|
|
@@ -418,9 +335,7 @@ if true
|
|
418
335
|
# fake it ...
|
419
336
|
static["isInner"] = true
|
420
337
|
master.load.call Envjs::STATIC, static
|
421
|
-
|
422
338
|
master["static"] = static
|
423
|
-
end
|
424
339
|
|
425
340
|
master.load.call Envjs::ENVJS, inner
|
426
341
|
|
data/lib/envjs/static.js
CHANGED
@@ -18991,6 +18991,7 @@ __extend__(XPathResult.prototype, {
|
|
18991
18991
|
});
|
18992
18992
|
|
18993
18993
|
|
18994
|
+
var alert = $error;
|
18994
18995
|
// ENVJS changes:
|
18995
18996
|
// DOM_ => DOMNode.
|
18996
18997
|
// case insensitive test on node names
|
data/lib/envjs.rb
CHANGED
data/src/window/event.js
CHANGED
@@ -224,13 +224,11 @@ $w.dispatchEvent = function(event, bubbles){
|
|
224
224
|
};
|
225
225
|
|
226
226
|
$w.__defineGetter__('onerror', function(){
|
227
|
-
|
228
|
-
//$w.dispatchEvent('error');
|
229
|
-
};
|
227
|
+
return $onerror;
|
230
228
|
});
|
231
229
|
|
232
230
|
$w.__defineSetter__('onerror', function(fn){
|
233
|
-
|
231
|
+
return $onerror = fn;
|
234
232
|
});
|
235
233
|
|
236
234
|
/*$w.__defineGetter__('onload', function(){
|
data/src/window/location.js
CHANGED
@@ -34,7 +34,8 @@ $w.__defineSetter__("location", function(url){
|
|
34
34
|
}
|
35
35
|
// print("ft",window.location.href,$location,url);
|
36
36
|
}
|
37
|
-
|
37
|
+
// debug("l",url,$w.location);
|
38
|
+
if( !$location || ( $location == "about:blank" && url !== "about:blank" ) ) {
|
38
39
|
// $w.__loadAWindowsDocument__(url);
|
39
40
|
$env.load(url);
|
40
41
|
} else {
|
data/src/xpath/implementation.js
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Resig
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-03-
|
19
|
+
date: 2010-03-29 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -43,9 +43,9 @@ dependencies:
|
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
segments:
|
45
45
|
- 0
|
46
|
-
-
|
47
|
-
-
|
48
|
-
version: 0.
|
46
|
+
- 5
|
47
|
+
- 0
|
48
|
+
version: 0.5.0
|
49
49
|
type: :development
|
50
50
|
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
@@ -375,8 +375,6 @@ files:
|
|
375
375
|
- test/unit/scope.js
|
376
376
|
- test/unit/timer.js
|
377
377
|
- test/unit/window.js
|
378
|
-
- test/vendor/jQuery/README
|
379
|
-
- test/vendor/prototype-1.6.0.3.js
|
380
378
|
- test/x.js
|
381
379
|
- test/y.js
|
382
380
|
has_rdoc: true
|
data/test/vendor/jQuery/README
DELETED