rocket-js 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.gitignore +0 -11
  2. data/Rakefile +33 -47
  3. data/lib/rocket/js.rb +0 -2
  4. data/lib/rocket/js/builder.rb +2 -2
  5. data/lib/rocket/js/cli.rb +1 -1
  6. data/rocket-js.gemspec +23 -80
  7. data/src/vendor/web-socket-js/FABridge.js +604 -0
  8. data/src/vendor/web-socket-js/README.txt +109 -0
  9. data/src/vendor/web-socket-js/WebSocketMain.swf +0 -0
  10. data/src/vendor/web-socket-js/WebSocketMainInsecure.zip +0 -0
  11. data/src/vendor/web-socket-js/flash-src/WebSocket.as +473 -0
  12. data/src/vendor/web-socket-js/flash-src/WebSocketMain.as +88 -0
  13. data/src/vendor/web-socket-js/flash-src/WebSocketMainInsecure.as +19 -0
  14. data/src/vendor/web-socket-js/flash-src/WebSocketStateEvent.as +32 -0
  15. data/src/vendor/web-socket-js/flash-src/bridge/FABridge.as +943 -0
  16. data/src/vendor/web-socket-js/flash-src/build.sh +10 -0
  17. data/src/vendor/web-socket-js/flash-src/com/adobe/net/proxies/RFC2817Socket.as +204 -0
  18. data/src/vendor/web-socket-js/flash-src/com/gsolo/encryption/MD5.as +375 -0
  19. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/Crypto.as +287 -0
  20. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/MozillaRootCertificates.as +3235 -0
  21. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509Certificate.as +218 -0
  22. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/cert/X509CertificateCollection.as +57 -0
  23. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/HMAC.as +82 -0
  24. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHMAC.as +27 -0
  25. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/IHash.as +21 -0
  26. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MAC.as +137 -0
  27. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD2.as +124 -0
  28. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/MD5.as +204 -0
  29. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA1.as +106 -0
  30. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA224.as +28 -0
  31. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHA256.as +115 -0
  32. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/hash/SHABase.as +71 -0
  33. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/ARC4.as +90 -0
  34. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/IPRNG.as +20 -0
  35. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/Random.as +119 -0
  36. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/prng/TLSPRF.as +142 -0
  37. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/rsa/RSAKey.as +339 -0
  38. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/AESKey.as +2797 -0
  39. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/BlowFishKey.as +375 -0
  40. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CBCMode.as +55 -0
  41. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFB8Mode.as +61 -0
  42. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CFBMode.as +64 -0
  43. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/CTRMode.as +58 -0
  44. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/DESKey.as +365 -0
  45. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ECBMode.as +86 -0
  46. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ICipher.as +21 -0
  47. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IMode.as +15 -0
  48. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IPad.as +32 -0
  49. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IStreamCipher.as +21 -0
  50. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/ISymmetricKey.as +35 -0
  51. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/IVMode.as +110 -0
  52. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/NullPad.as +34 -0
  53. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/OFBMode.as +52 -0
  54. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/PKCS5.as +44 -0
  55. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SSLPad.as +44 -0
  56. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as +60 -0
  57. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TLSPad.as +42 -0
  58. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/TripleDESKey.as +88 -0
  59. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/XTeaKey.as +94 -0
  60. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/aeskey.pl +29 -0
  61. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/dump.txt +2304 -0
  62. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/AESKeyTest.as +1220 -0
  63. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as +58 -0
  64. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BigIntegerTest.as +39 -0
  65. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/BlowFishKeyTest.as +148 -0
  66. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CBCModeTest.as +160 -0
  67. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFB8ModeTest.as +71 -0
  68. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CFBModeTest.as +98 -0
  69. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/CTRModeTest.as +109 -0
  70. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/DESKeyTest.as +112 -0
  71. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ECBModeTest.as +151 -0
  72. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/HMACTest.as +184 -0
  73. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ITestHarness.as +20 -0
  74. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD2Test.as +56 -0
  75. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/MD5Test.as +58 -0
  76. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/OFBModeTest.as +101 -0
  77. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/RSAKeyTest.as +92 -0
  78. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA1Test.as +198 -0
  79. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA224Test.as +58 -0
  80. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/SHA256Test.as +60 -0
  81. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TLSPRFTest.as +51 -0
  82. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TestCase.as +42 -0
  83. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/TripleDESKeyTest.as +59 -0
  84. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/XTeaKeyTest.as +66 -0
  85. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/BulkCiphers.as +102 -0
  86. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/CipherSuites.as +117 -0
  87. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/IConnectionState.as +14 -0
  88. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/ISecurityParameters.as +29 -0
  89. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/KeyExchanges.as +24 -0
  90. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/MACs.as +38 -0
  91. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLConnectionState.as +171 -0
  92. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLEvent.as +26 -0
  93. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/SSLSecurityParameters.as +340 -0
  94. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConfig.as +70 -0
  95. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSConnectionState.as +151 -0
  96. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEngine.as +895 -0
  97. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSError.as +39 -0
  98. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSEvent.as +27 -0
  99. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSecurityParameters.as +197 -0
  100. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocket.as +370 -0
  101. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSSocketEvent.as +26 -0
  102. data/src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tls/TLSTest.as +180 -0
  103. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BarrettReduction.as +90 -0
  104. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/BigInteger.as +1543 -0
  105. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/ClassicReduction.as +35 -0
  106. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/IReduction.as +11 -0
  107. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/MontgomeryReduction.as +85 -0
  108. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/NullReduction.as +34 -0
  109. data/src/vendor/web-socket-js/flash-src/com/hurlant/math/bi_internal.as +11 -0
  110. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/ArrayUtil.as +25 -0
  111. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Base64.as +189 -0
  112. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Hex.as +66 -0
  113. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/Memory.as +28 -0
  114. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ByteString.as +43 -0
  115. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/DER.as +210 -0
  116. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/IAsn1Type.as +21 -0
  117. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Integer.as +44 -0
  118. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/OID.as +35 -0
  119. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/ObjectIdentifier.as +112 -0
  120. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PEM.as +118 -0
  121. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/PrintableString.as +49 -0
  122. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Sequence.as +90 -0
  123. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Set.as +27 -0
  124. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/Type.as +94 -0
  125. data/src/vendor/web-socket-js/flash-src/com/hurlant/util/der/UTCTime.as +60 -0
  126. data/src/vendor/web-socket-js/sample.html +76 -0
  127. data/src/vendor/web-socket-js/swfobject.js +4 -0
  128. data/src/vendor/web-socket-js/web_socket.js +388 -0
  129. metadata +163 -30
  130. data/lib/rocket/js/version.rb +0 -14
  131. data/rocket-0.0.1.min.js +0 -45
data/.gitignore CHANGED
@@ -1,24 +1,13 @@
1
- ## MAC OS
2
1
  .DS_Store
3
-
4
- ## TEXTMATE
5
2
  *.tmproj
6
3
  tmtags
7
-
8
- ## EMACS
9
4
  *~
10
5
  \#*
11
6
  .\#*
12
-
13
- ## VIM
14
7
  *.swp
15
-
16
- ## PROJECT::GENERAL
17
8
  coverage
18
9
  rdoc
19
10
  pkg
20
-
21
- ## PROJECT::SPECIFIC
22
11
  *.rdb
23
12
  test/public/testing
24
13
  config/config.yml
data/Rakefile CHANGED
@@ -1,45 +1,49 @@
1
1
  # -*- ruby -*-
2
-
3
2
  $:.unshift(File.expand_path('../lib', __FILE__))
4
3
  $:.unshift(File.expand_path('../../rocket/lib/', __FILE__))
5
-
6
4
  require 'rspec/core/rake_task'
7
5
  require 'rake/rdoctask'
8
- require 'rocket/js/version'
6
+ require 'rocket/version'
9
7
 
10
- SUMMARY = %Q{JavaScript client library for Rocket server.}
11
- DESCRIPTION = %Q{
12
- This library is client that allows JavaScript clients to connect to the
13
- Rocket web socket server.
14
- }
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/ruby/**/*_spec.rb'
10
+ t.rspec_opts = %q[-I../rocket-core/lib -I../rocket/lib -Ilib -c -b]
11
+ end
15
12
 
16
- begin
17
- require 'jeweler'
18
- Jeweler::Tasks.new do |g|
19
- g.version = Rocket::JS.version
20
- g.name = "rocket-js"
21
- g.email = "chris@nu7hat.ch"
22
- g.homepage = "http://github.com/araneo/rocket"
23
- g.authors = ["Araneo", "Chris Kowalik"]
24
- g.summary = SUMMARY
25
- g.description = DESCRIPTION
26
- #g.add_dependency "rocket", "0.0.1"
27
- g.add_dependency "json", "~> 1.4"
28
- g.add_dependency "yui-compressor", "~> 0.9"
29
- g.add_development_dependency "rspec", "~> 2.0"
30
- g.add_development_dependency "mocha", "~> 0.9"
31
- g.add_development_dependency "jasmine", "~> 1.0"
32
- end
33
- Jeweler::GemcutterTasks.new
34
- rescue
35
- puts 'Jeweler is not available here'
13
+ RSpec::Core::RakeTask.new(:rcov) do |t|
14
+ t.rcov = true
15
+ t.rspec_opts = %q[-I../rocket-core/lib -I../rocket/lib -Ilib -c -b]
16
+ t.rcov_opts = %q[-I../rocket-core/lib -I../rocket/lib -Ilib -T -x "spec"]
17
+ end
18
+
19
+ Rake::RDocTask.new do |rdoc|
20
+ rdoc.title = "Rocket JavaScript Tools #{Rocket.version}"
21
+ rdoc.rdoc_dir = 'rdoc'
22
+ rdoc.rdoc_files.include('README*')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
25
+
26
+ desc "Build current version as a rubygem"
27
+ task :build do
28
+ sh "gem build rocket-js.gemspec"
29
+ sh "mkdir -p pkg"
30
+ sh "mv rocket-js-*.gem pkg/"
31
+ end
32
+
33
+ desc "Relase current version to rubygems.org"
34
+ task :release => :build do
35
+ sh "gem push pkg/rocket-js-#{Rocket.version}.gem"
36
+ end
37
+
38
+ desc "Perform installation via rubygems"
39
+ task :install => :build do
40
+ sh "gem install pkg/rocket-js-#{Rocket.version}.gem"
36
41
  end
37
42
 
38
43
  namespace :js do
39
44
  desc 'Bundle and minify source files.'
40
45
  task :build do
41
46
  require 'rocket-js'
42
- require 'rocket/js/builder'
43
47
  Rocket::JS::Builder.new(File.dirname(__FILE__), true).generate_script
44
48
  end
45
49
 
@@ -49,22 +53,4 @@ namespace :js do
49
53
  end
50
54
  end
51
55
 
52
- RSpec::Core::RakeTask.new(:spec) do |t|
53
- t.pattern = 'spec/ruby/**/*_spec.rb'
54
- t.rspec_opts = %q[-Ilib -c -b]
55
- end
56
-
57
- RSpec::Core::RakeTask.new(:rcov) do |t|
58
- t.rcov = true
59
- t.rspec_opts = %q[-Ilib -c -b]
60
- t.rcov_opts = %q[-Ilib -T -x "spec"]
61
- end
62
-
63
- Rake::RDocTask.new do |rdoc|
64
- rdoc.title = "Rocket JavaScript Tools #{Rocket::JS.version}"
65
- rdoc.rdoc_dir = 'rdoc'
66
- rdoc.rdoc_files.include('README*')
67
- rdoc.rdoc_files.include('lib/**/*.rb')
68
- end
69
-
70
56
  task :default => :spec
@@ -4,5 +4,3 @@ module Rocket
4
4
  autoload :CLI, 'rocket/js/cli'
5
5
  end # JS
6
6
  end # Rocket
7
-
8
- require 'rocket/js/version'
@@ -59,11 +59,11 @@ module Rocket
59
59
  end
60
60
 
61
61
  def save_script(source)
62
- scriptname = "rocket-#{Rocket::JS.version}#{'.min' if minified}.js"
62
+ scriptname = "rocket-#{Rocket.version}#{'.min' if minified}.js"
63
63
  File.open(File.expand_path(scriptname, dest), 'w+') {|f|
64
64
  contents = CONTENTS.map {|content|
65
65
  File.read(File.expand_path("../../../../src/#{content}", __FILE__))
66
- }.join("\n\n").sub(/<%= VERSION %>/, Rocket::JS.version)
66
+ }.join("\n\n").sub(/<%= VERSION %>/, Rocket.version)
67
67
 
68
68
  f.write(contents)
69
69
  f.write("\n\n")
@@ -6,7 +6,7 @@ module Rocket
6
6
 
7
7
  desc "Show version of used javascript library"
8
8
  def version
9
- puts "Rocket javascript library v#{Rocket::JS.version}"
9
+ puts "Rocket javascript library v#{Rocket.version}"
10
10
  end
11
11
 
12
12
  desc "Generate Rocket's javascript toolkit in given directory"
@@ -1,84 +1,27 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ # -*- ruby -*-
2
+ $:.unshift(File.expand_path('../lib', __FILE__))
3
+ $:.unshift(File.expand_path('../../rocket/lib', __FILE__))
4
+ require 'rocket/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{rocket-js}
8
- s.version = "0.0.1"
7
+ s.name = 'rocket-js'
8
+ s.version = Rocket.version
9
+ s.homepage = 'http://github.com/araneo/rocket'
10
+ s.email = ['chris@nu7hat.ch']
11
+ s.authors = ['Araneo Ltd.', 'Chris Kowalik']
12
+ s.summary = %q{JavaScript client library for Rocket server.}
13
+ s.description = %q{This library is client that allows JavaScript clients to connect to the Rocket web socket server.}
14
+ s.files = `git ls-files`.split("\n") + Dir["src/vendor/web-socket-js/**/*"]
15
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
16
+ s.require_paths = %w[lib]
17
+ s.extra_rdoc_files = %w[LICENSE README.md]
18
+ s.executables = %w[rocket-js]
19
+ s.default_executable = 'rocket-js'
9
20
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Araneo", "Chris Kowalik"]
12
- s.date = %q{2010-11-03}
13
- s.description = %q{
14
- This library is client that allows JavaScript clients to connect to the
15
- Rocket web socket server.
16
- }
17
- s.email = %q{chris@nu7hat.ch}
18
- s.extra_rdoc_files = [
19
- "LICENSE",
20
- "README.md"
21
- ]
22
- s.files = [
23
- ".gitignore",
24
- "LICENSE",
25
- "README.md",
26
- "Rakefile",
27
- "bin/rocket-js",
28
- "lib/rocket-js.rb",
29
- "lib/rocket/js.rb",
30
- "lib/rocket/js/builder.rb",
31
- "lib/rocket/js/cli.rb",
32
- "lib/rocket/js/version.rb",
33
- "rocket-0.0.1.min.js",
34
- "rocket-js.gemspec",
35
- "spec/js/app.rb",
36
- "spec/js/public/WebSocketMain.swf",
37
- "spec/js/public/favicon.ico",
38
- "spec/js/public/jquery-1.4.2.min.js",
39
- "spec/js/public/qunit.css",
40
- "spec/js/public/qunit.js",
41
- "spec/js/public/test.js",
42
- "spec/js/public/testing/WebSocketMain.swf",
43
- "spec/js/public/testing/WebSocketMainInsecure.zip",
44
- "spec/js/public/testing/rocket-0.0.1.js",
45
- "spec/js/views/index.erb",
46
- "spec/ruby/spec_helper.rb",
47
- "src/rocket.channels.js",
48
- "src/rocket.core.js",
49
- "src/rocket.defaults.js",
50
- "src/rocket.license.js",
51
- "src/vendor/json/json2.js"
52
- ]
53
- s.homepage = %q{http://github.com/araneo/rocket}
54
- s.rdoc_options = ["--charset=UTF-8"]
55
- s.require_paths = ["lib"]
56
- s.rubygems_version = %q{1.3.7}
57
- s.summary = %q{JavaScript client library for Rocket server.}
58
-
59
- if s.respond_to? :specification_version then
60
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
- s.specification_version = 3
62
-
63
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
- s.add_runtime_dependency(%q<json>, ["~> 1.4"])
65
- s.add_runtime_dependency(%q<yui-compressor>, ["~> 0.9"])
66
- s.add_development_dependency(%q<rspec>, ["~> 2.0"])
67
- s.add_development_dependency(%q<mocha>, ["~> 0.9"])
68
- s.add_development_dependency(%q<jasmine>, ["~> 1.0"])
69
- else
70
- s.add_dependency(%q<json>, ["~> 1.4"])
71
- s.add_dependency(%q<yui-compressor>, ["~> 0.9"])
72
- s.add_dependency(%q<rspec>, ["~> 2.0"])
73
- s.add_dependency(%q<mocha>, ["~> 0.9"])
74
- s.add_dependency(%q<jasmine>, ["~> 1.0"])
75
- end
76
- else
77
- s.add_dependency(%q<json>, ["~> 1.4"])
78
- s.add_dependency(%q<yui-compressor>, ["~> 0.9"])
79
- s.add_dependency(%q<rspec>, ["~> 2.0"])
80
- s.add_dependency(%q<mocha>, ["~> 0.9"])
81
- s.add_dependency(%q<jasmine>, ["~> 1.0"])
82
- end
21
+ s.add_runtime_dependency 'rocket-core', [Rocket.version]
22
+ s.add_runtime_dependency 'json', ['>= 1.4']
23
+ s.add_runtime_dependency 'yui-compressor', ['~> 0.9']
24
+ s.add_development_dependency 'rspec', ["~> 2.0"]
25
+ s.add_development_dependency 'mocha', [">= 0.9"]
26
+ s.add_development_dependency 'jasmine', ["~> 1.0"]
83
27
  end
84
-
@@ -0,0 +1,604 @@
1
+ /*
2
+ /*
3
+ Copyright 2006 Adobe Systems Incorporated
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
6
+ to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
15
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+
17
+ */
18
+
19
+
20
+ /*
21
+ * The Bridge class, responsible for navigating AS instances
22
+ */
23
+ function FABridge(target,bridgeName)
24
+ {
25
+ this.target = target;
26
+ this.remoteTypeCache = {};
27
+ this.remoteInstanceCache = {};
28
+ this.remoteFunctionCache = {};
29
+ this.localFunctionCache = {};
30
+ this.bridgeID = FABridge.nextBridgeID++;
31
+ this.name = bridgeName;
32
+ this.nextLocalFuncID = 0;
33
+ FABridge.instances[this.name] = this;
34
+ FABridge.idMap[this.bridgeID] = this;
35
+
36
+ return this;
37
+ }
38
+
39
+ // type codes for packed values
40
+ FABridge.TYPE_ASINSTANCE = 1;
41
+ FABridge.TYPE_ASFUNCTION = 2;
42
+
43
+ FABridge.TYPE_JSFUNCTION = 3;
44
+ FABridge.TYPE_ANONYMOUS = 4;
45
+
46
+ FABridge.initCallbacks = {};
47
+ FABridge.userTypes = {};
48
+
49
+ FABridge.addToUserTypes = function()
50
+ {
51
+ for (var i = 0; i < arguments.length; i++)
52
+ {
53
+ FABridge.userTypes[arguments[i]] = {
54
+ 'typeName': arguments[i],
55
+ 'enriched': false
56
+ };
57
+ }
58
+ }
59
+
60
+ FABridge.argsToArray = function(args)
61
+ {
62
+ var result = [];
63
+ for (var i = 0; i < args.length; i++)
64
+ {
65
+ result[i] = args[i];
66
+ }
67
+ return result;
68
+ }
69
+
70
+ function instanceFactory(objID)
71
+ {
72
+ this.fb_instance_id = objID;
73
+ return this;
74
+ }
75
+
76
+ function FABridge__invokeJSFunction(args)
77
+ {
78
+ var funcID = args[0];
79
+ var throughArgs = args.concat();//FABridge.argsToArray(arguments);
80
+ throughArgs.shift();
81
+
82
+ var bridge = FABridge.extractBridgeFromID(funcID);
83
+ return bridge.invokeLocalFunction(funcID, throughArgs);
84
+ }
85
+
86
+ FABridge.addInitializationCallback = function(bridgeName, callback)
87
+ {
88
+ var inst = FABridge.instances[bridgeName];
89
+ if (inst != undefined)
90
+ {
91
+ callback.call(inst);
92
+ return;
93
+ }
94
+
95
+ var callbackList = FABridge.initCallbacks[bridgeName];
96
+ if(callbackList == null)
97
+ {
98
+ FABridge.initCallbacks[bridgeName] = callbackList = [];
99
+ }
100
+
101
+ callbackList.push(callback);
102
+ }
103
+
104
+ // updated for changes to SWFObject2
105
+ function FABridge__bridgeInitialized(bridgeName) {
106
+ var objects = document.getElementsByTagName("object");
107
+ var ol = objects.length;
108
+ var activeObjects = [];
109
+ if (ol > 0) {
110
+ for (var i = 0; i < ol; i++) {
111
+ if (typeof objects[i].SetVariable != "undefined") {
112
+ activeObjects[activeObjects.length] = objects[i];
113
+ }
114
+ }
115
+ }
116
+ var embeds = document.getElementsByTagName("embed");
117
+ var el = embeds.length;
118
+ var activeEmbeds = [];
119
+ if (el > 0) {
120
+ for (var j = 0; j < el; j++) {
121
+ if (typeof embeds[j].SetVariable != "undefined") {
122
+ activeEmbeds[activeEmbeds.length] = embeds[j];
123
+ }
124
+ }
125
+ }
126
+ var aol = activeObjects.length;
127
+ var ael = activeEmbeds.length;
128
+ var searchStr = "bridgeName="+ bridgeName;
129
+ if ((aol == 1 && !ael) || (aol == 1 && ael == 1)) {
130
+ FABridge.attachBridge(activeObjects[0], bridgeName);
131
+ }
132
+ else if (ael == 1 && !aol) {
133
+ FABridge.attachBridge(activeEmbeds[0], bridgeName);
134
+ }
135
+ else {
136
+ var flash_found = false;
137
+ if (aol > 1) {
138
+ for (var k = 0; k < aol; k++) {
139
+ var params = activeObjects[k].childNodes;
140
+ for (var l = 0; l < params.length; l++) {
141
+ var param = params[l];
142
+ if (param.nodeType == 1 && param.tagName.toLowerCase() == "param" && param["name"].toLowerCase() == "flashvars" && param["value"].indexOf(searchStr) >= 0) {
143
+ FABridge.attachBridge(activeObjects[k], bridgeName);
144
+ flash_found = true;
145
+ break;
146
+ }
147
+ }
148
+ if (flash_found) {
149
+ break;
150
+ }
151
+ }
152
+ }
153
+ if (!flash_found && ael > 1) {
154
+ for (var m = 0; m < ael; m++) {
155
+ var flashVars = activeEmbeds[m].attributes.getNamedItem("flashVars").nodeValue;
156
+ if (flashVars.indexOf(searchStr) >= 0) {
157
+ FABridge.attachBridge(activeEmbeds[m], bridgeName);
158
+ break;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ return true;
164
+ }
165
+
166
+ // used to track multiple bridge instances, since callbacks from AS are global across the page.
167
+
168
+ FABridge.nextBridgeID = 0;
169
+ FABridge.instances = {};
170
+ FABridge.idMap = {};
171
+ FABridge.refCount = 0;
172
+
173
+ FABridge.extractBridgeFromID = function(id)
174
+ {
175
+ var bridgeID = (id >> 16);
176
+ return FABridge.idMap[bridgeID];
177
+ }
178
+
179
+ FABridge.attachBridge = function(instance, bridgeName)
180
+ {
181
+ var newBridgeInstance = new FABridge(instance, bridgeName);
182
+
183
+ FABridge[bridgeName] = newBridgeInstance;
184
+
185
+ /* FABridge[bridgeName] = function() {
186
+ return newBridgeInstance.root();
187
+ }
188
+ */
189
+ var callbacks = FABridge.initCallbacks[bridgeName];
190
+ if (callbacks == null)
191
+ {
192
+ return;
193
+ }
194
+ for (var i = 0; i < callbacks.length; i++)
195
+ {
196
+ callbacks[i].call(newBridgeInstance);
197
+ }
198
+ delete FABridge.initCallbacks[bridgeName]
199
+ }
200
+
201
+ // some methods can't be proxied. You can use the explicit get,set, and call methods if necessary.
202
+
203
+ FABridge.blockedMethods =
204
+ {
205
+ toString: true,
206
+ get: true,
207
+ set: true,
208
+ call: true
209
+ };
210
+
211
+ FABridge.prototype =
212
+ {
213
+
214
+
215
+ // bootstrapping
216
+
217
+ root: function()
218
+ {
219
+ return this.deserialize(this.target.getRoot());
220
+ },
221
+ //clears all of the AS objects in the cache maps
222
+ releaseASObjects: function()
223
+ {
224
+ return this.target.releaseASObjects();
225
+ },
226
+ //clears a specific object in AS from the type maps
227
+ releaseNamedASObject: function(value)
228
+ {
229
+ if(typeof(value) != "object")
230
+ {
231
+ return false;
232
+ }
233
+ else
234
+ {
235
+ var ret = this.target.releaseNamedASObject(value.fb_instance_id);
236
+ return ret;
237
+ }
238
+ },
239
+ //create a new AS Object
240
+ create: function(className)
241
+ {
242
+ return this.deserialize(this.target.create(className));
243
+ },
244
+
245
+
246
+ // utilities
247
+
248
+ makeID: function(token)
249
+ {
250
+ return (this.bridgeID << 16) + token;
251
+ },
252
+
253
+
254
+ // low level access to the flash object
255
+
256
+ //get a named property from an AS object
257
+ getPropertyFromAS: function(objRef, propName)
258
+ {
259
+ if (FABridge.refCount > 0)
260
+ {
261
+ throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
262
+ }
263
+ else
264
+ {
265
+ FABridge.refCount++;
266
+ retVal = this.target.getPropFromAS(objRef, propName);
267
+ retVal = this.handleError(retVal);
268
+ FABridge.refCount--;
269
+ return retVal;
270
+ }
271
+ },
272
+ //set a named property on an AS object
273
+ setPropertyInAS: function(objRef,propName, value)
274
+ {
275
+ if (FABridge.refCount > 0)
276
+ {
277
+ throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
278
+ }
279
+ else
280
+ {
281
+ FABridge.refCount++;
282
+ retVal = this.target.setPropInAS(objRef,propName, this.serialize(value));
283
+ retVal = this.handleError(retVal);
284
+ FABridge.refCount--;
285
+ return retVal;
286
+ }
287
+ },
288
+
289
+ //call an AS function
290
+ callASFunction: function(funcID, args)
291
+ {
292
+ if (FABridge.refCount > 0)
293
+ {
294
+ throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
295
+ }
296
+ else
297
+ {
298
+ FABridge.refCount++;
299
+ retVal = this.target.invokeASFunction(funcID, this.serialize(args));
300
+ retVal = this.handleError(retVal);
301
+ FABridge.refCount--;
302
+ return retVal;
303
+ }
304
+ },
305
+ //call a method on an AS object
306
+ callASMethod: function(objID, funcName, args)
307
+ {
308
+ if (FABridge.refCount > 0)
309
+ {
310
+ throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
311
+ }
312
+ else
313
+ {
314
+ FABridge.refCount++;
315
+ args = this.serialize(args);
316
+ retVal = this.target.invokeASMethod(objID, funcName, args);
317
+ retVal = this.handleError(retVal);
318
+ FABridge.refCount--;
319
+ return retVal;
320
+ }
321
+ },
322
+
323
+ // responders to remote calls from flash
324
+
325
+ //callback from flash that executes a local JS function
326
+ //used mostly when setting js functions as callbacks on events
327
+ invokeLocalFunction: function(funcID, args)
328
+ {
329
+ var result;
330
+ var func = this.localFunctionCache[funcID];
331
+
332
+ if(func != undefined)
333
+ {
334
+ result = this.serialize(func.apply(null, this.deserialize(args)));
335
+ }
336
+
337
+ return result;
338
+ },
339
+
340
+ // Object Types and Proxies
341
+
342
+ // accepts an object reference, returns a type object matching the obj reference.
343
+ getTypeFromName: function(objTypeName)
344
+ {
345
+ return this.remoteTypeCache[objTypeName];
346
+ },
347
+ //create an AS proxy for the given object ID and type
348
+ createProxy: function(objID, typeName)
349
+ {
350
+ var objType = this.getTypeFromName(typeName);
351
+ instanceFactory.prototype = objType;
352
+ var instance = new instanceFactory(objID);
353
+ this.remoteInstanceCache[objID] = instance;
354
+ return instance;
355
+ },
356
+ //return the proxy associated with the given object ID
357
+ getProxy: function(objID)
358
+ {
359
+ return this.remoteInstanceCache[objID];
360
+ },
361
+
362
+ // accepts a type structure, returns a constructed type
363
+ addTypeDataToCache: function(typeData)
364
+ {
365
+ var newType = new ASProxy(this, typeData.name);
366
+ var accessors = typeData.accessors;
367
+ for (var i = 0; i < accessors.length; i++)
368
+ {
369
+ this.addPropertyToType(newType, accessors[i]);
370
+ }
371
+
372
+ var methods = typeData.methods;
373
+ for (var i = 0; i < methods.length; i++)
374
+ {
375
+ if (FABridge.blockedMethods[methods[i]] == undefined)
376
+ {
377
+ this.addMethodToType(newType, methods[i]);
378
+ }
379
+ }
380
+
381
+
382
+ this.remoteTypeCache[newType.typeName] = newType;
383
+ return newType;
384
+ },
385
+
386
+ //add a property to a typename; used to define the properties that can be called on an AS proxied object
387
+ addPropertyToType: function(ty, propName)
388
+ {
389
+ var c = propName.charAt(0);
390
+ var setterName;
391
+ var getterName;
392
+ if(c >= "a" && c <= "z")
393
+ {
394
+ getterName = "get" + c.toUpperCase() + propName.substr(1);
395
+ setterName = "set" + c.toUpperCase() + propName.substr(1);
396
+ }
397
+ else
398
+ {
399
+ getterName = "get" + propName;
400
+ setterName = "set" + propName;
401
+ }
402
+ ty[setterName] = function(val)
403
+ {
404
+ this.bridge.setPropertyInAS(this.fb_instance_id, propName, val);
405
+ }
406
+ ty[getterName] = function()
407
+ {
408
+ return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName));
409
+ }
410
+ },
411
+
412
+ //add a method to a typename; used to define the methods that can be callefd on an AS proxied object
413
+ addMethodToType: function(ty, methodName)
414
+ {
415
+ ty[methodName] = function()
416
+ {
417
+ return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id, methodName, FABridge.argsToArray(arguments)));
418
+ }
419
+ },
420
+
421
+ // Function Proxies
422
+
423
+ //returns the AS proxy for the specified function ID
424
+ getFunctionProxy: function(funcID)
425
+ {
426
+ var bridge = this;
427
+ if (this.remoteFunctionCache[funcID] == null)
428
+ {
429
+ this.remoteFunctionCache[funcID] = function()
430
+ {
431
+ bridge.callASFunction(funcID, FABridge.argsToArray(arguments));
432
+ }
433
+ }
434
+ return this.remoteFunctionCache[funcID];
435
+ },
436
+
437
+ //reutrns the ID of the given function; if it doesnt exist it is created and added to the local cache
438
+ getFunctionID: function(func)
439
+ {
440
+ if (func.__bridge_id__ == undefined)
441
+ {
442
+ func.__bridge_id__ = this.makeID(this.nextLocalFuncID++);
443
+ this.localFunctionCache[func.__bridge_id__] = func;
444
+ }
445
+ return func.__bridge_id__;
446
+ },
447
+
448
+ // serialization / deserialization
449
+
450
+ serialize: function(value)
451
+ {
452
+ var result = {};
453
+
454
+ var t = typeof(value);
455
+ //primitives are kept as such
456
+ if (t == "number" || t == "string" || t == "boolean" || t == null || t == undefined)
457
+ {
458
+ result = value;
459
+ }
460
+ else if (value instanceof Array)
461
+ {
462
+ //arrays are serializesd recursively
463
+ result = [];
464
+ for (var i = 0; i < value.length; i++)
465
+ {
466
+ result[i] = this.serialize(value[i]);
467
+ }
468
+ }
469
+ else if (t == "function")
470
+ {
471
+ //js functions are assigned an ID and stored in the local cache
472
+ result.type = FABridge.TYPE_JSFUNCTION;
473
+ result.value = this.getFunctionID(value);
474
+ }
475
+ else if (value instanceof ASProxy)
476
+ {
477
+ result.type = FABridge.TYPE_ASINSTANCE;
478
+ result.value = value.fb_instance_id;
479
+ }
480
+ else
481
+ {
482
+ result.type = FABridge.TYPE_ANONYMOUS;
483
+ result.value = value;
484
+ }
485
+
486
+ return result;
487
+ },
488
+
489
+ //on deserialization we always check the return for the specific error code that is used to marshall NPE's into JS errors
490
+ // the unpacking is done by returning the value on each pachet for objects/arrays
491
+ deserialize: function(packedValue)
492
+ {
493
+
494
+ var result;
495
+
496
+ var t = typeof(packedValue);
497
+ if (t == "number" || t == "string" || t == "boolean" || packedValue == null || packedValue == undefined)
498
+ {
499
+ result = this.handleError(packedValue);
500
+ }
501
+ else if (packedValue instanceof Array)
502
+ {
503
+ result = [];
504
+ for (var i = 0; i < packedValue.length; i++)
505
+ {
506
+ result[i] = this.deserialize(packedValue[i]);
507
+ }
508
+ }
509
+ else if (t == "object")
510
+ {
511
+ for(var i = 0; i < packedValue.newTypes.length; i++)
512
+ {
513
+ this.addTypeDataToCache(packedValue.newTypes[i]);
514
+ }
515
+ for (var aRefID in packedValue.newRefs)
516
+ {
517
+ this.createProxy(aRefID, packedValue.newRefs[aRefID]);
518
+ }
519
+ if (packedValue.type == FABridge.TYPE_PRIMITIVE)
520
+ {
521
+ result = packedValue.value;
522
+ }
523
+ else if (packedValue.type == FABridge.TYPE_ASFUNCTION)
524
+ {
525
+ result = this.getFunctionProxy(packedValue.value);
526
+ }
527
+ else if (packedValue.type == FABridge.TYPE_ASINSTANCE)
528
+ {
529
+ result = this.getProxy(packedValue.value);
530
+ }
531
+ else if (packedValue.type == FABridge.TYPE_ANONYMOUS)
532
+ {
533
+ result = packedValue.value;
534
+ }
535
+ }
536
+ return result;
537
+ },
538
+ //increases the reference count for the given object
539
+ addRef: function(obj)
540
+ {
541
+ this.target.incRef(obj.fb_instance_id);
542
+ },
543
+ //decrease the reference count for the given object and release it if needed
544
+ release:function(obj)
545
+ {
546
+ this.target.releaseRef(obj.fb_instance_id);
547
+ },
548
+
549
+ // check the given value for the components of the hard-coded error code : __FLASHERROR
550
+ // used to marshall NPE's into flash
551
+
552
+ handleError: function(value)
553
+ {
554
+ if (typeof(value)=="string" && value.indexOf("__FLASHERROR")==0)
555
+ {
556
+ var myErrorMessage = value.split("||");
557
+ if(FABridge.refCount > 0 )
558
+ {
559
+ FABridge.refCount--;
560
+ }
561
+ throw new Error(myErrorMessage[1]);
562
+ return value;
563
+ }
564
+ else
565
+ {
566
+ return value;
567
+ }
568
+ }
569
+ };
570
+
571
+ // The root ASProxy class that facades a flash object
572
+
573
+ ASProxy = function(bridge, typeName)
574
+ {
575
+ this.bridge = bridge;
576
+ this.typeName = typeName;
577
+ return this;
578
+ };
579
+ //methods available on each ASProxy object
580
+ ASProxy.prototype =
581
+ {
582
+ get: function(propName)
583
+ {
584
+ return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, propName));
585
+ },
586
+
587
+ set: function(propName, value)
588
+ {
589
+ this.bridge.setPropertyInAS(this.fb_instance_id, propName, value);
590
+ },
591
+
592
+ call: function(funcName, args)
593
+ {
594
+ this.bridge.callASMethod(this.fb_instance_id, funcName, args);
595
+ },
596
+
597
+ addRef: function() {
598
+ this.bridge.addRef(this);
599
+ },
600
+
601
+ release: function() {
602
+ this.bridge.release(this);
603
+ }
604
+ };