Change Log
All notable changes to this project will be documented in this file. This project tries to adhere to Semantic Versioning, even before v1.0.
Changes are grouped as follows:
- Added for new features.
- Changed for changes in existing functionality.
- Deprecated for once-stable features removed in upcoming releases.
- Removed for deprecated features removed in this release.
- Fixed for any bug fixes.
- Security to invite users to upgrade in case of vulnerabilities.
- Performance changes related to speed and efficiency.
1.8.1 - 2023-11-09
Fixed
Arraymethods should handle elements inserted during the iteration (#2602)- Assign correct values to duplicated underscore parameters (#2606)
Added
- Support an
IOargument ofKernel.printf(#2605)
Performance
- Fix a performance regression introduced by freezing support (#2609)
1.8.0 - 2023-10-26
Highlights
Hash is now bridged to JavaScript Map
This change brings a lot of benefits, but also some incompatibilities. The main benefit is that Hash now is both more performant and relies on native JavaScript capabilities.
This improves interoperability with JavaScript. As a downside, applications reaching for internal Hash data structures will need to be updated.
Interacting with Hash from JavaScript is easier than ever:
hash = `new Map([['a', 1], ['b', 2]])`
hash # => {a: 1, b: 2}
`console.log(hash)` # => Map(2) {"a" => 1, "b" => 2}
`hash.get('a')` # => 1
`hash.set('c', 3)`
hash # => {a: 1, b: 2, c: 3}
hash.keys # => ["a", "b", "c"]
hash.values # => [1, 2, 3]
Performance improvements
This release brings a lot of performance improvements, our tests on Asciidoctor show a 25% improvement in performance, but we've seen up to 66% performance improvement on some applications.
Changelog
Deprecated
- Deprecate using x-string to access JavaScript without an explicit magic-comment (#2543)
Compatibility
- Add a magic-comment that will disable x-string compilation to JavaScript (#2543)
- Pass value in
PromiseV2#alwaysjust likePromiseV1#alwaysdoes it (#2579) #hashnow returns integers (#2582)- Improve
Range#include?/member?/cover?/===(#2598) - Make
Module#define_methodmore compatible with CRuby (#2593) Hash#clonemust freeze clone if original is frozen, butHash#dupmust not (#2603)
Fixed
- Fix
Kernel#Floatwithexception:option (#2532) - Fix
Kernel#Integerwithexception:option (#2531) - Fix
String#splitwith limit and capturing regexp (#2544) - Fix
switchwith Object-wrapped values (#2542) - Fix non-direct subclasses of bridged classes not calling the original constructor (#2546)
- Regexp.escape: Cast to String or drop exception (#2552)
- Propagate removal of method from included/prepended modules (#2553)
- Restore
nodejs/yamlfunctionality (#2551) - Fix sine
Range#sizeedge cases (#2541) - Use a Map instead of a POJO for the jsid_cache (#2584)
- Fix
String#object_id,String#__id__,String#hashto match CRuby's behavior (#2576) - Lowercase response headers in
SimpleServerfor rack 3.0 compatibility (#2578) - Fix
Module#cloneandModule#dupto properly copy methods (#2572) - Chrome runner fix: support code that contains
</script>(#2581) - Do not skip
$truthywhen left hand side of a comparison isself(#2596) - Unexpected
return/breakshould raiseLocalJumpError(#2591)
Added
- SourceMap support for
Kernel#eval(#2534) - Add
CGI::Util#escapeURIComponentandCGI::Util#unescapeURIComponent(#2566) CGI::Utilimplement additional methods (#2601)
Changed
- Change compilation of Regexp nodes that may contain advanced features, so if invalid that they would raise at runtime, not parse-time (#2548)
Hashis now bridged to JavaScriptMapand support for non-symbol keys in keyword arguments (#2568)
Documentation
Performance
- Improve performance of
Array#intersect?and#intersection(#2533) Proc#call: Refactor for performance (#2541)- Opal.stub_for: optimize (#2541)
- Hash: Optimize
#to_a(#2541) - Array: Optimize
#collect/#map(#2541) - Optimize argument slicing in runtime for performance (#2555)
- Closure: Generate a JavaScript object, not an Error, gain up to 15% on Asciidoctor (#2556)
- Optimize
String#splitandString#start_with(#2560) - Compute
$@dynamically (#2592) - Optimize the
$prophelper (#2597) - Improve
Array.push()performance when pushing many items (#2565) - Optimize
Opal.instance_methods(#2600)
Internal
- Update rubocop (#2535)
- Match3Node Cleanup (#2541)
- IFlipFlop/EFlipFlop: Refactor for readability (#2541)
- ForRewriter: Refactor for readability (#2541)
1.7.4 - 2023-09-14
Fixed
- Use a Map instead of a POJO for the jsid_cache (#2584)
- Lowercase response headers in
SimpleServerfor rack 3.0 compatibility (#2578) - Fix
switchwith Object-wrapped values (#2542) - Regexp.escape: Cast to String or drop exception (#2552)
- Chrome runner fix: support code that contains
</script>(#2581)
1.7.3 - 2023-03-23
Fixed
- Disallow to define a singleton class for Number (#2521)
- Fix eval with parser gem v3.2.1 (#2526)
- Fix certain encoding issues when using Prefork (#2527)
- Fix Chrome CDP interface connection (#2528)
- Fix for Opal::Cache::FileCache.dir_writable? (#2529)
- Fix Array#sample randomness (#2530)
1.7.2 - 2023-01-20
Fixed
1.7.1 - 2023-01-05
Added
- Add safari runner (#2513)
Fixed
- Fix CLI file reading for macOS (#2510)
- Make Date/Time.parse on Firefox more compatible with Chrome and Ruby (#2506)
- Safari/WebKit can now parse code compiled with lookbehind regexps, failing at runtime instead (#2511)
- Fix
--watchignoring some directories (e.g.tmp) (#2509) - Fix rake dist not generating libraries correctly for the CDN (#2515)
- Prefork: output processed files in a correct, deterministic order (#2516)
- Fix the handling of ARGV for the opal executable (#2518)
Internal
- Platform specific spec filters (#2508)
- Run Firefox specs by default (#2507)
- Run Safari specs by default (#2513)
- [mspec_opal] Avoid lookbehind Regexp for compatibility with various javascript engines (#2512)
1.7.0 - 2022-12-26
Added
- Update benchmarking and CLI runners, added support for Deno and Firefox (#2490, #2492, #2494, #2495, #2497, #2491, #2496)
- Ruby 3.2 support branch (#2500)
Setnow part of the corelib- Anonymous rest keyword and block arguments can be passed to calls:
call(**, &) Refinement#refined_classhas been addedModule#refinementshas been addedModule#const_addedhas been addedProc#parametersnow accepts lambda keywordClass#attached_objecthas been added, inverse ofsingleton_classHash#shiftnow returnsnilinstead of passingnilto thedefault_proc
- Added
--watchand--outputoptions to the CLI for live compilation (#2485)
Performance
- Replace all occurences of
'$'+namewith a cached helper, saving about 2% in performance (#2481) - Optimize argument passing and arity checks (#2499)
- Targeted patches for Opal-Parser, saves up to 12% during compilation (#2482)
Internal
- MSpec & Ruby Spec update (#2486)
Fixed
- Remove throws from runtime (#2484)
1.6.1 - 2022-12-09
Fixed
- Fix builder.dup breaking Tilt support (#2479)
Changed
- Build also opal variants for the CDN: opal/mini.js etc. (#2489)
1.6.0 - 2022-11-24
Changed
Performance
- Improve method block performance for runtime (#2449)
- Uninline non-typical argument handling (#2419)
- Logic optimization of runtime.js (#2415)
- Windows support for
performance:compareCI check (#2450) - Improve block performance for even more cases (#2465)
Added
- Added support for
#freezeand#frozen?(#2444, #2468) - Add CLI support for ESM, at least for Chrome, NodeJS, QuickJS and GJS (#2435)
- Support exit in Chrome CLI Runner, both sync and async (#2439)
- Make sure the Server CLI Runner can pick up changes in sources (#2436)
- Delegate and ruby2_keywords (#2446)
- Source code can now be embedded in the compiled file to improve development/debugging, e.g. RSpec reports,
Proc#source_location(#2440) - Added
Kernel#caller_locations(#2440) Opal::Builder::Preforkfor blazingly fast multicore compilation times (#2263, #2462, #2454, #2469, #2475)- Add
Opal::BuilderProcessors::RubyERBProcessor(#2470)
Fixed
- Closure tracking support fixes a whole array of bugs handling
break/next/retry/ … (#2357) - Fix an edge case of if in the most complex form not returning (#2433)
String#lengthis now available when usingopal/mini(#2438)- Auto-await produced invalid code (#2440)
- Fix
Enumerable#collect_concatand#flat_mapimplementation (#2440) - Improved await support for PromiseV1 (#2440)
- Compilation error occurs while compiling
being/endreturning acase/when(#2459) - Ensure UTF-8 encoding of
.sourcesContentof source maps (#2451) - Benchmarks require string/unpack (#2453)
- Fix compilation of a call:
gets&.chomp(#2473) - Fix specs on Windows (#2460)
- Make opal CLI tool work again with pipes (#2474)
Internal
- GitHub Workflows security hardening (#2432)
- Retry if file cache write operation exits with Zlib::BufError (#2463)
- Eliminate redundant
var constructorinallocate_class(#2452) - Fix
performance:compareasset size calculation (#2457) - Fix a few specs after the Opal RSpec 1.0 (alpha) release (#2471, #2472)
1.5.1 - 2022-07-20
Fixed
- Make
Time.newnot depend onDate.prototype.getTimezoneOffset()(#2426) - Fix exception during
Hash#each_valueif keys get deleted during loop (#2427) - Fix scan_until and check_until implementation of StringScanner (#2420)
New Contributors
- @Leon0402 made their first contribution in https://github.com/opal/opal/pull/2420
Full Changelog: https://github.com/opal/opal/compare/v1.5.0...v1.5.1
1.5.0 - 2022-04-13
Added
- Introduce timezone support for Time by @hmdne in https://github.com/opal/opal/pull/2394
- DateTime and Date refactor by @hmdne in https://github.com/opal/opal/pull/2398
- Implement
Number#prev_float/#next_floatby @takaram in https://github.com/opal/opal/pull/2404 - Support
binding.irbanywhere in the code, for both browsers and node by @hmdne in https://github.com/opal/opal/pull/2392 and https://github.com/opal/opal/pull/2408 - Added
URI.decode_www_formby @HoneyryderChuck in https://github.com/opal/opal/pull/2387
Changed
- Move
MathIE11-supporting polyfills to a separate file by @hmdne in https://github.com/opal/opal/pull/2395 Stringmethods always return Strings even when overloaded by @hmdne in https://github.com/opal/opal/pull/2413- Misc changes extracted from DCE work by @elia in https://github.com/opal/opal/pull/2414
aliascalls will not add the "old name" method to the list of stubs for method missing
- Optimize writer/setter methods (up to 4% performance gain!) by @hmdne in https://github.com/opal/opal/pull/2402
- Also fixed few edge cases of conditional calls combined with setters, e.g.
foo&.bar = 123
- Also fixed few edge cases of conditional calls combined with setters, e.g.
Performance
- Runtime optimization by @hmdne in https://github.com/opal/opal/pull/2383
- Improve performance of argument coertion, fast-track
Integer,String, and calling the designed coertion method - Optimize
Array#[]=by moving the implementation to JavaScript and inlining type checks - Optimize internal runtime passing of block-options
- Improve performance of argument coertion, fast-track
- Compile
casestatements asswitchwhenever possible by @hmdne in https://github.com/opal/opal/pull/2411 - Improve performance with optimized common method/iter implementation shortcuts by @hmdne in https://github.com/opal/opal/pull/2401
Fixed
- Fix
Regexp.new, replace\Ato^and\zto$by @ysakasin in https://github.com/opal/opal/pull/2079 - Fix exception during
Hash#eachandHash#each_keyif keys get deleted during the loop by @janbiedermann in https://github.com/opal/opal/pull/2403 - Fix defining multiple methods with the same block by @elia in https://github.com/opal/opal/pull/2397
- Correct
String#to_procandmethod_missingcompatibility by @hmdne in https://github.com/opal/opal/pull/2418 - Exit REPL respecting the exit status number by @janbiedermann in https://github.com/opal/opal/pull/2396
Internal
- Rewriters refactor, fix interaction between cache and inverted runner by @hmdne in https://github.com/opal/opal/pull/2400
- releasing.md: add a step to prepare for next release by @hmdne in https://github.com/opal/opal/pull/2407
New Contributors
- @HoneyryderChuck made their first contribution in https://github.com/opal/opal/pull/2387
Full Changelog: https://github.com/opal/opal/compare/v1.4.1...v1.5.0
1.4.1 - 2022-01-12
Changed
- PromiseV2 is now declared a stable interface! (#2380)
Fixed
- Args named with JS reserved words weren't always renamed when zsuper was involved (#2385)
1.4.0 - 2021-12-24
Added
- Implement
chomp:option forString#each_lineand#lines(#2355) - Ruby 3.1 support and some older Ruby features we missed (#2347)
- Use parser in 3.1 mode to support new language-level features like hashes/kwargs value omission, the pin operator for pattern matching
Array#intersect?String#stripandString#lstripto also remove NUL bytesInteger.try_convertpublic,private,protected,module_functionnow return their argumentsClass#descendants,Class#subclasses- (<=1.8)
Kernel#local_variables - (<=2.3) Set local variables for regexp named captures (
/(?<b>a)/ =~ 'a'=>b = 'a') - Remove deprecated
NIL,TRUE,FALSEconstants String#unpackandString#unpack1to support anoffset:kwargMatchData#match,MatchData#match_length- Enumerable modernization
Enumerable#tallyto support an optional hash accumulatorEnumerable#each_{cons,slice}to return selfEnumerable#compactRefinementbecomes its own class nowStruct#keyword_init?- (pre-3.1) Large Enumerator rework
- Introduce
Enumerator::ArithmeticSequence - Introduce
Enumerator::Chain - Introduce
Enumerator#+to createEnumerator::Chains Enumerator#{rewind,peek,peek_values,next,next_values}- Improve corelib support for beginless/endless ranges and
ArithmeticSequencesString#[],Array#[],Array#[]=,Array#fill,Array#values_at
Range#stepandNumeric#stepreturn anArithmeticSequencewhenNumericvalues are in play- Introduce
Range#% Enumerator::Yielder#to_proc- Fix #2367
- (2.7)
UnboundMethod#bind_call - (Opal)
{Kernel,BasicObject}#{inspect,p,pp,method_missing}may work with JS native values now, also they now correctly report cycles Enumerable#sumuses Kahan's summation algorithm to reduce error with floating point valuesFile.dirnamesupports a newlevelargument
- Vendor in
optparseandshellwords(#2326) - Preliminary support for compiling the whole
bin/opalwith Opal (#2326)
Fixed
- Fix coertion for
Array#drop(#2371) - Fix coertion for
File.absolute_path(#2372) - Fix some
IO#putsedge cases (no args, empty array, nested array, …) (#2372) - Preserve UNC path prefix on File.join (#2366)
- Methods on
Kernel,BasicObject,Booleanwill never return boxed values anymore (#2293)false.tap{}will now correctly return a JS value offalse, notObject(false)
- opal-parser doesn't break on
<<~ENDstrings anymore (#2364) - Fix error reporting at the early stage of loading (#2326)
Changed
- Various outputted code size optimizations - 19% improvement for minified unmangled AsciiDoctor bundle - see: https://opalrb.com/blog/2021/11/24/optimizing-opal-output-for-size/ (#2356)
- Second round of code size optimizations - 3% improvement for AsciiDoctor bundle on top of the first round - 23% total - see: https://github.com/opal/opal/pull/2365/commits (#2365)
- The calls to
==,!=and===changed their semantics slightly: it's impossible to monkey patch those calls forStringandNumber, but on other classes they can now returnniland it will be handled correctly - The calls to
!changed their semantics slightly: it's impossible to monkey patch this call forBooleanorNilClass.
- The calls to
- Refactored the structure of the internal
stdlib/nodejsfolder (#2374)- Added
nodejs/basewith just I/O, exit, and ARGV management - Moved
Process::Statusto corelib - Fixed requires to be more robust
- Added
Removed
- Removed
nodejs/irbfrom stdlib as it's been broken for some time (#2374) - Removed
Kernel#node_requirefromnodejs/kernelas it's been deprecated for a long time (#2374)
1.3.2 - 2021-11-10
Fixed
- Update documentation (#2350)
- Fix
IO#getsgetting an extra char under some circumstances (#2349) - Raise a
TypeErrorinstead ofUndefinedMethodif not a string is passed to__send__(#2346) - Do not modify
$~when callingString#scanfrom internal methods (#2353) - Stop interpreting falsey values as a missing constant in
Module#const_get(#2354)
1.3.1 - 2021-11-03
Fixed
- Fix REPL if bundler environment isn't set (#2338)
- Fix Chrome runner if bundler environment isn't set and make it work on other Unixes (#2339)
Proc#bindingto return a binding ifBindingis defined (#2341, #2340)Array#zipto correctlyyield(#2342, #1611)String#scanto correctlyyield(#2342, #1660)
1.3.0 - 2021-10-27
Added
- Add support for
retry(#2264) - Modernize Exceptions (#2264)
- Add
#cause,#backtrace_locations,#full_messagetoException - Normalize backtraces across platforms
- Add
Thread::Backtrace::Location - Output Exception#full_message on uncaught exceptions (#2269)
- Add
- TracePoint
:classsupport (#2049) - Implement the Flip-Flop operators (#2261)
- Add
JS[]to access properties on the global object (#2259) - Add
ENV.fetchto the Nodejs implementation ofENV(#2259) - Opal::Cache, an optional compiler cache (enabled by default) (#2242, #2278, #2329)
- Alias for gvars, alias on main (#2270)
- Support for GJS (GNOME's JavaScript runtime) runner (#2280)
- Scope variables support for
eval()(#2256) - Add support for
Kernel#binding(#2256) - A (mostly) correct support for refinements (#2256)
- Add support for ECMAScript modules with an
--esmCLI option (#2286) - Implement
Regexp#namesand add named captures support (#2272) - REPL improvements: (#2285)
- Colored output & history support
lsto show available constants and variable
- Add
Method#===as an alias toMethod#call, works the same asProc#===(#2305) - Add
IO#getsandIO#read_procalong with other supporting methods (#2309)- Support
#getson most platforms, including browsers (viaprompt) - Move the REPL to a
--replCLI option of the main executable - Completely refactor IO, now supporting methods like
#each_linethroughout the entire IO chain - Add a runner for MiniRacer (as
miniracer) - Support Windows on the Chrome runner
- Support Windows on the REPL
- Platforms an IO implementations should either set
IO#read_procor overwriteIO#sysread
- Support
- [experimental] Add support for JavaScript async/await (#2221)
- Enable the feature by adding a magic comment:
# await: true - The magic comment can be also used to mark specific method patterns to be awaited
(e.g.
# await: *_await, sleepwill make any method ending in_awaitor namedsleepto be awaited) - Add
Kernel#__await__as a bridge to theawaitkeyword (inspired by CoffeeScript await support) - Require
opal/awaitto get additional support - Read more on the newly added documentation page
- Enable the feature by adding a magic comment:
- Better interoperability between legacy Promise (v1) and native Promise (v2) (#2221)
- Add
PromiseV1as an alias to the original (legacy) Promise class - Add
#to_v1and#to_v2to both classes Promise#to_nwill convert it to a native Promise (v2)
- Add
- Add
Opal::Config.esmto enable/disable ES modules (#2316)- If Config.esm is enabled, SimpleServer does type="module"
- Add new rack-esm example
- Add a QuickJS (https://bellard.org/quickjs/) runner (#2331)
- Add
IO#fileno,Method#curry,Buffer#to_s,Pathname.pwd(#2332) - Add NodeJS support for
ARGF,ENV.{inspect,to_h,to_hash,merge},File.{delete,unlink},Kernel#system,Kernel#`,Process::Status(#2332) - Introduce
__dir__support (#2323) - Full autoload support (#2323)
- Now compatible with
opal-zeitwerkandisomorfeus - Allow toplevel autoloads
- Allow dynamic autoloads (e.g. can be hooked to fetch a URL upon autoload with a custom loader)
- Allow overwriting
require(e.g. like rubygems does) - Allow autoloading trees with
require_tree "./foo", autoload: true - Add Module#autoload?
- Now compatible with
- Autoload parts of the corelib (#2323)
Fixed
- Fixed multiple line
Regexpliteral to not generate invalid syntax as JavaScript (#1616) - Fix
Kernel#{throw,catch}along withUncaughtThrowError(#2264) - Update source-map-support to fix an off-by-one error (#2264)
- Source map: lines should start from 1, not 0 (#2273)
- Allow for multiple underscored args with the same name in strict mode (#2292)
- Show instance variables in
Kernel#inspect(#2285) 0.digitswas returning an empty array in strict mode (#2301)- Non Integer numbers were responding to
#digits(#2301) - Correctly delete hash members when dealing with boxed strings (#2306)
- Escape string components in interpolated strings (
dstrs) correctly (#2308) - Don't try to return the JS
debuggerstatement, just returnnil(#2307) - Retain the
-while stringifying-0.0(#2304) - Fix super support for rest args and re-assignments with implicit arguments (#2315)
- Fix calling
Regexp#last_matchwhen$~is nil (#2328) - Windows support for chrome runner (#2324)
- Use correct node separator for NODE_PATH on Windows
- Pass dir and emulate exec a bit on Windows
- Use Gem.win_platform?, match supported platform to ruby, simplify run
- NodeJS: Drop the first
--argument inARGV(#2332) - Fix
Object#requirenot pointing toKernel#require(#2323)
Changed
- Fast-track bad constant names passed to
Struct.new(#2259) - Renamed internal
superrelated helpers,find_super_dispatcheris nowfind_super,find_iter_super_dispatcheris nowfind_block_super(#2090) - The
opal-replCLI now requires files to be passed with--require(or-r) instead of the bare filename (#2309) Processis now a Module, not a Class - just like in MRI (#2332)s = StringIO.new("a"); s << "b"; s.stringnow returns "b", like MRI, but Opal used to return "ab" (#2309)
Internal
- Switch from jshint to ESLint (#2289)
- Switch from UglifyJS to Terser (#2318)
- [CI] Performance regression check (#2276, #2282)
1.2.0 - 2021-07-28
Added
- Support for multiple arguments in Hash#merge!, update (#2187)
- Support for Ruby 3.0 forward arguments:
def a(...) puts(...) end(#2153) - Support for beginless and endless ranges:
(1..),(..1)(#2150) - Preliminary support for
**nilargument - see #2240 to note limitations (#2152) - Support for
Random::Formatterswhich add methods#{hex,base64,urlsafe_base64,uuid,random_float,random_number,alphanumeric}toRandomandSecureRandom(#2218) - Basic support for ObjectSpace finalizers and ObjectSpace::WeakMap (#2247)
- A more robust support for encodings (especially binary strings) (#2235)
- Support for
"\x80"syntax in String literals (#2235) - Added
String#+@,String#-@(#2235) - Support for
begin <CODE> end while <CONDITION>(#2255) - Added Hash#except and
Hash#except!(#2243) - Parser 3.0: Implement pattern matching (as part of this
{Array,Hash,Struct}#{deconstruct,deconstruct_keys} methods were added)(#2243) - [experimental] Reimplement Promise to make it bridged with JS native Promise, this new implementation can be used by requiring
promise/v2(#2220)
Fixed
- Encoding lookup was working only with uppercase names, not giving any errors for wrong ones (#2181, #2183, #2190)
- Fix
Number#to_iwith huge number (#2191) - Add regexp support to
String#start_with(#2198) String#bytesnow works in strict mode (#2194)- Fix nested module inclusion (#2053)
- SecureRandom is now cryptographically secure on most platforms (#2218, #2170)
- Fix performance regression for
Array#unshifton v8 > 7.1 (#2116) - String subclasses now call
#initializewith multiple arguments correctly (with a limitation caused by the String immutability issue, that a source string must be the first argument and#initializecan't change its value) (#2238, #2185) - Number#step is moved to Numeric (#2100)
- Fix class Class < superclass for invalid superclasses (#2123)
- Fix
String#unpack("U*")on binary strings with latin1 high characters, fix performance regression on that call (#2235, #2189, #2129, #2099, #2094, #2000, #2128) - Fix
String#to_jsonoutput on some edge cases (#2235) - Rework class variables to support inheritance correctly (#2251)
- ISO-8859-1 and US-ASCII encodings are now separated as in MRI (#2235)
String#bno longer modifies object strings in-place (#2235)- Parser::Builder::Default.check_lvar_name patch (#2195)
Changed
String#unpack,Array#pack,String#chars,String#length,Number#chr, and (only partially)String#+are now encoding aware (#2235)String#inspectnow uses\xfor binary stirngs (#2235)if RUBY_ENGINE == "opal"and friends are now outputing less JS code (#2159, #1965)Array:to_a,slice/[],uniq,*,difference/-,intersection/&,union/|, flatten now return Array, not a subclass, as Ruby 3.0 does (#2237)Array:difference,intersection,unionnow accept multiple arguments (#2237)
Deprecated
- Stopped testing Opal on Ruby 2.5 since it reached EOL.
Removed
- Removed support for the outdated
c_lexer, it was optional and didn't work for the last few releases of parser (#2235)
1.1.1 - 2021-02-23
Fixed
- The default runner (nodejs) wasn't starting to a bad require in the improved stack-traces (#2182)
1.1.0 - 2021-02-19
Added
- Basic support for
uplevel:keyword argument inKernel#warn(#2006) - Added a
#respond_to_missing?implementation forBasicObject,Delegator,OpenStruct, that's meant for future support in the Opal runtime, which currently ignores it (#2007) Opal::Compiler#magic_commentsthat allows to access magic-comments format and converts it to a hash (#2038)- Use magic-comments to declare helpers required by the file (#2038)
Opal.$$is now a shortcut forOpal.const_get_relative(#2038)Opal.$$$is now a shortcut forOpal.const_get_qualified(#2038)- Added support for
globalThisas the generic global object accessor (#2047) Opal::Compiler#magic_commentsthat allows to access magic-comments format and converts it to a hash- Use magic-comments to declare helpers required by the file
Opal.$$is now a shortcut forOpal.const_get_relativeOpal.$$$is now a shortcut forOpal.const_get_qualified- Source-map support for Node.js in the default runner (#2045)
- SecureRandom#hex(n) (#2050)
- Added a generic implementation of Kernel#caller and #warn(uplevel:) that works with sourcemaps in Node.js and Chrome (#2065)
- Added support for numblocks
-> { _1 + _2 }.call(3, 4) # => 7(#2149) - Support
<internal:…>and<js:…>in stacktraces, like MRI we now distinguish internal lines from lib/app lines (#2154) Array#difference,Array#intersection,Array#unionas aliases respectively toArray#{-,&,|}(#2151)- Aliases
filter{,!}toselect{,!}throughout the corelib classes (#2151) Enumerable#filter_map,Enumerable#tally(#2151)- Alias
Kernel#thenforKernel#yield_self(#2151) - Method chaining:
{Proc,Method}#{<<,>>}(#2151) - Added Integer#to_d (#2006)
- Added a compiler option
use_strictwhich can also be set by theuse_strictmagic comment (#1959) - Add
--rbrequire (-q)option toopalcommand line executable (#2120)
Fixed
- Array#delete_if (#2069)
- Array#keep_if (#2069)
- Array#reject! (#2069)
- Array#select! (#2069)
- Struct#dup (#1995)
- Integer#gcdlcm (#1972)
- Enumerable#to_h (#1979)
- Enumerator#size (#1980)
- Enumerable#min (#1982)
- Enumerable#min_by (#1985)
- Enumerable#max_by (#1985)
- Set#intersect? (#1988)
- Set#disjoint? (#1988)
- Set#keep_if (#1987)
- Set#select! (#1987)
- Set#reject! (#1987)
- String#unicode_normalize (#2175)
- Module#alias_method (#1983)
- Enumerable#minmax_by (#1981)
- Enumerator#each_with_index (#1990)
- Range#== (#1992)
- Range#each (#1991)
- Enumerable#zip (#1986)
- String#getbyte (#2141)
- Struct#dup not copying
$$data(#1995) - Fixed usage of semicolon in single-line backticks (#2004)
- Module#attr with multiple arguments (#2003)
PathReaderused to try to read missing files instead of respecting themissing_require_severityconfiguration value (#2044)- Removed some unused variables from the runtime (#2052)
- Fixed a typo in the runtime (#2054)
- Fix Regexp interpolation, previously interpolating with other regexps was broken (#2062)
- Set match on StringScanner#skip and StringScanner#scan_until (#2061)
- Fix ruby 2.7 warnings (#2071)
- Improve the --help descriptions (#2146)
- Remove BasicObject#class (#2166)
- Time#strftime %j leading zeros (#2161)
- Fix
call { true or next }producing invalid code (#2160) define_methodcan now be called on the main object (#2029)- Fix nested for-loops (#2033)
- Fix Number#round for Integers (#2030)
- Fix parsing Unicode characters from Opal (#2073)
- Integer#===: improve Integer recognition (#2089)
- Regexp: ensure ignoreCase is never undefined (#2098)
- Hash#delete: ensure String keys are converted to values (#2106)
- Array#shift: improve performance on v8 >7.1 (#2115)
- Array#pop(1): improve performance (#2130)
- Object#pretty_inspect (#2139)
- Fix conversion from UTF-8 to bytes (#2138)
- Restore compatibility with Chrome 38, used by Cordova and many mobile browsers (#2109)
Changed
- Updated outdated parser version (#2013)
- Nashorn has been deprecated but GraalVM still supports it (#1997)
- "opal/mini" now includes "opal/io" (#2002)
- Regexps assigned to constants are now frozen (#2007)
Opal.$$changed from being the constant cache of Object to being a shortcut forOpal.const_get_relative(#2038)- Moved REPL implementation from bin/ to its own lib/ file as
opal/repl.rb(#2048) Encoding.default_externalis now initialized with__ENCODING__(#2072)- Keep the MersenneTwister implementation private (#2108)
- Change parser to 3.0 (#2148)
- Fix forwarding a rescued error to a global var:
rescue => $gvar(#2154) - Now using Parser v3.0 and targeting Ruby 3.0 (#2156)
Comparable#clampto support a Range argument (#2151)#to_hmethod to support a block (shortform for.map(&block).to_h) (#2151)- BigDecimal is now a subclass of Numeric (#2006)
- PP to be rebased on upstream Ruby version (#2083)
- String to report UTF-8 encoding by default, as MRI does (#2117)
- Don't output "Failed to load WithCLexer, using pure Ruby lexer" warning unless in $DEBUG mode (#2174)
Deprecated
- Requiring nodejs/stacktrace has been deprecated, source-maps are already supported by the default Node.js runner or by requiring https://github.com/evanw/node-source-map-support before loading code compiled by Opal (#2045)
Removed
- Removed special compilation for the
Opal.truthy?andOpal.falsy?helpers (#2076) - Removed the deprecated
taintingcompiler config option (#2072)
1.0.5 - 2020-12-23
Fixed
- [Backported] Add --rbrequire (-q) option to opal cmdline tool (#2120)
- Improve the --help descriptions (#2146)
1.0.4 - 2020-12-13
Fixed
- [Backported] Using the
--map/-PCLI option was only working in conjunction with other options (#1974)
1.0.3 - 2020-02-01
Fixed
- Fixed compiling code with Unicode chars from Opal with opal-parser (#2074)
1.0.2 - 2019-12-15
- Increase the timeout for starting Chrome within the Chrome runner (#2037)
- Run the Opal code within the body inside Chrome runner, it fixes an issue in opal-rspec (#2037)
1.0.1 - 2019-12-08
Changed
- Relaxed parser version requirement (#2013)
1.0.0 - 2019-05-12
Added
- Added
Module#prependand completely overhauled the module and class inheritance system (#1826) - Methods and properties are now assigned with
Object.defineProperty()as non-enumerable (#1821) - Backtrace now includes the location inside the source file for syntax errors (#1814)
- Added support for a faster C-implemented lexer, it's enough to add
gem 'c_lexerto theGemfile(#1806) - Added
Date#to_nthat returns the JavaScript Date object (in native.rb). (#1779, #1792) - Added
Array#pack(supports onlyC, S, L, Q, c, s, l, q, A, aformats). (#1723) - Added
String#unpack(supports onlyC, S, L, Q, S>, L>, Q>, c, s, l, q, n, N, v, V, U, w, A, a, Z, B, b, H, h, u, M, mformats). (#1723) - Added
File#symlink?for Node.js. (#1725) - Added
Dir#globfor Node.js (does not support flags). (#1727) - Added support for a static folder in the "server" CLI runner via the
OPAL_CLI_RUNNERS_SERVER_STATIC_FOLDERenv var - Added the CLI option
--runner-optionsthat allows passing arbitrary options to the selected runner, currently the only runner making use of them isserveracceptingportandstatic_folder - Added a short helper to navigate constants manually: E.g.
Opal.$$.Regexp.$$.IGNORECASE(see docs for "Compiled Ruby") - Added initial support for OpenURI module (using XMLHttpRequest on browser and xmlhttprequest on Node). (#1735)
- Added
String#prependto the list of unsupported methods (because String are immutable in JavaScript) Added methods (most introduced in 2.4/2.5):
Array#prepend(#1757)Array#append(#1757)Array#max(#1757)Array#min(#1757)Complex#finite?(#1757)Complex#infinite?(#1757)Complex#infinite?(#1757)Date#to_time(#1757)Date#next_year(#1885)Date#prev_year(#1885)Hash#slice(#1757)Hash#transform_keys(#1757)Hash#transform_keys!(#1757)Numeric#finite?(#1757)Numeric#infinite?(#1757)Numeric#infinite?(#1757)Integer#allbits?(#1757)Integer#anybits?(#1757)Integer#digits(#1757)Integer#nobits?(#1757)Integer#pow(#1757)Integer#remainder(#1757)Integer.sqrt(#1757)Random.urandom(#1757)String#delete_prefix(#1757)String#delete_suffix(#1757)String#casecmp?(#1757)Kernel#yield_self(#1757)String#unpack1(#1757)String#to_r(#1842)String#to_c(#1842)String#match?(#1842)String#unicode_normalizereturns self (#1842)String#unicode_normalized?returns true (#1842)String#[]=throwsNotImplementedError(#1836)
Added support of the
patternargument forEnumerable#all?,Enumerable#any?,Enumerable#none?. (#1757)Added
ndigitsoption support toNumber#floor,Number#ceil,Number#truncate. (#1757)Added
keyandreceiverattributes to theKeyError. (#1757)Extended
Struct.newto supportkeyword_initoption. (#1757)Added a new
Opal::Config.missing_require_severityoption and relative--missing-requireCLI flag. This option will command how the builder will behave when a required file is missing. Previously the behavior was undefined and partly controlled bydynamic_require_severity. Not to be confused with the runtime config optionOpal.config.missing_require_severity;which controls the runtime behavior.Added
Matrix(along with the internal MRI utilityE2MM)Use shorter helpers for constant lookups,
$$for relative (nesting) lookups and$$$for absolute (qualified) lookupsAdd support for the Mersenne Twister random generator, the same used by CRuby/MRI (#657 & #1891)
[Nodejs] Added support for binary data in
OpenURI(#1911, #1920)[Nodejs] Added support for binary data in
File#read(#1919, #1921)[Nodejs] Added support for
File#readlines(#1882)[Nodejs] Added support for
ENV#[],ENV#[]=,ENV#key?,ENV#has_key?,ENV#include?,ENV#member?,ENV#empty?,ENV#keys,ENV#deleteandENV#to_s(#1928)
Changed
- BREAKING The dot (
.) character is no longer replaced with [\s\S] in a multiline regexp passed to Regexp#match and Regexp#match? (#1796, #1795)- You're advised to always use [\s\S] instead of . in a multiline regexp, which is portable between Ruby and JavaScript
- BREAKING
Kernel#format(andsprintfalias) are now in a dedicated modulecorelib/kernel/formatand available exclusively inopal(#1930)- Previously the methods were part of the
corelib/kernelmodule and available in bothopalandopal/mini
- Previously the methods were part of the
- Filename extensions are no longer stripped from filenames internally, resulting in better error reporting (#1804)
- The internal API for CLI runners has changed, now it's just a callable object
- The
--mapCLI option now works only in conjunction with--compile(or--runner compiler) - The
nodeCLI runner now adds itsNODE_PATHentry instead of replacing the ENV var altogether - Added
--disable-web-securityoption flag to the Chrome headless runner to be able to doXMLHttpRequest - Migrated parser to 2.5. Bump RUBY_VERSION to 2.5.0.
- Exceptions raised during the compilation now add to the backtrace the current location of the opal file if available (#1814).
- Better use of
displayNameon functions and methods and more readable temp variable names (#1910) - Source-maps are now inlined and already contain sources, incredibly more stable and precise (#1856)
Deprecated
- The CLI
--server-port 1234option is now deprecated in favor of using--runner-options='{"port": 1234}' - Including
::Nativeis now deprecated because it generates conflicts with core classes in constant lookups (bothNative::ObjectandNative::Arrayexist). InsteadNative::Werappershould be used. - Using
node_require 'my_module'to access the nativerequire()function in Node.js is deprecated in favor of`require('my_module')`because static builders need to parse the call in order to function (#1886).
Removed
- The
nodeCLI runner no longer supports passing extra node options via theNODE_OPTenv var, instead Node.js natively supports theNODE_OPTIONSenv var. - The gem "hike" is no longer an external dependency and is now an internal dependency available as
Opal::Hike(#1881) - Removed the internal Opal class
Marshal::BinaryString(#1914) - Removed Racc, as it's now replaced by the parser gem (#1880)
Fixed
- Fix handling of trailing semicolons and JavaScript returns inside x-strings, the behavior is now well defined and covered by proper specs (#1776)
- Fixed singleton method definition to return method name. (#1757)
- Allow passing number of months to
Date#next_monthandDate#prev_month. (#1757) - Fixed
patternargument handling forEnumerable#grepandEnumerable#grep_v. (#1757) - Raise
ArgumentErrorinstead ofTypeErrorfromNumeric#stepwhen step is not a number. (#1757) - At run-time
LoadErrorwasn't being raised even withOpal.config.missing_require_severity;set to'error'. - Fixed
Kernel#public_methodsto return instance methods if the argument is set to false. (#1848) - Fixed an issue in
String#gsubthat made it start an infinite loop when used recursively. (#1879) Kernel#exitwas using status 0 when a number or a generic object was provided, now accepts numbers and tries to convert objects with#to_int(#1898, #1808).- Fixed metaclass inheritance in subclasses of Module (#1901)
Method#to_procnow correctly sets parameters and arity on the resulting Proc (#1903)- Fixed bridged classes having their prototype removed from the original chain by separating them from the Ruby class (#1909)
- Improve
String#to_procperformance (#1888) - Fixed/updated the examples (#1887)
Opal.ancestors()now returns false for when provided with JS-falsy objects (#1839)- When subclassing now the constant is set before calling
::inherited(#1838) String#to_symnow returns the string literal (#1835)String#centernow correctly checks length (#1833)redoinsidewhilenow works properly (#1820)- Fixed compilation of empty/whitespace-only x-strings (#1811)
- Fix
||=assignments on constants when the constant is not yet defined (#1935) - Fix
String#chompto return an empty String whenarg == self(#1936) - Fix methods of
Comparablewhen<=>does not return Numeric (#1945) - Fix
Class#native_aliaserror message (#1946) - Fix
gmt_offset(aliasutc_offset) should return 0 if the date is UTC (#1941) exceptionDetails.stackTracecan be undefined (#1955)- Implement
String#each_codepointandString#codepoints(#1944, #1947) - [internal] Terminate statement with semi-colon and remove unecessary semi-colon (#1948)
- Some steps toward "strict mode" (#1953)
- Preserve
Exception.stack, in some cases the backtrace was lost (#1963) - Make
String#ascii_only?a little less wrong (#1951) - Minor fixes to
::Native(#1957)
0.11.4 - 2018-11-07
Fixed
Kernel#exitwas using status 0 when a number or a generic object was provided, now accepts numbers and tries to convert objects with#to_int.
0.11.3 - 2018-08-28
Fixed
- Fixed
Array#dupwhenmethod_missingsupport was disabled
0.11.2 - 2018-08-24
Fixed
- Remove symlink that caused problems on Windows
0.11.1 - 2018-07-17
Added
- Added support for a static folder in the "server" CLI runner via the
OPAL_CLI_RUNNERS_SERVER_STATIC_FOLDERenv var - Added ability to pass the port to the "server" CLI runner using the
OPAL_CLI_RUNNERS_SERVER_PORT(explicit option passed via CLI is still working but deprecated) - Added a new
Opal::Config.missing_require_severityoption and relative--missing-requireCLI flag. This option will command how the builder will behave when a required file is missing. Previously the behavior was undefined and partly controlled bydynamic_require_severity. Not to be confused with the runtime config optionOpal.config.missing_require_severity;which controls the runtime behavior. - At run-time
LoadErrorwasn't being raised even withOpal.config.missing_require_severity;set to'error'.
0.11.0 - 2017-12-08
Added
- Added support for complex (
0b1110i) and rational (0b1111r) number literals. (#1487) - Added 2.3.0 methods:
Array#bsearch_indexArray#digEnumerable#chunk_whileEnumerable#grep_vEnumerable#slice_afterEnumerable#slice_whenHash#>Hash#<Hash#>=Hash#>=Hash#digHash#fetch_valuesHash#to_procStruct#digKernel#itself
- Added safe navigator (
&.) support. (#1532) - Added Random class with seed support. The following methods were reworked to use it:
Kernel.randKernel.srandArray#shuffleArray#shuffle!Array#sample
- Added rudimental history support to
opal-repl, just create the history file (~/.opal-repl-history) and it record the last 1000 lines - Added
JS::Errorerror class that can be used to catch any JS error. - Added
Method#source_locationandMethod#comments. - Added a deprecation API that can be set to raise on deprecation with:
Opal.raise_on_deprecation = true - Added
Opal::SimpleServeras the quickest way to get up and running with Opal:rackup -ropal -ropal/simple_server -b 'Opal.append_path("app"); run Opal::SimpleServer.new' - Added
String#ascii_only?(#1592) - Added
StringScanner#matched_size(#1595) - Added
Hash#compare_by_identity(#1657)
Removed
- Dropped support for IE8 and below, and restricted Safari and Opera support to the last two versions
- Dropped support for PhantomJS as it was abandoned.
Changed
- Removed self-written lexer/parser. Now uses parser/ast gems to convert source code to AST. (#1465)
- Migrated parser to 2.3. Bump RUBY_VERSION to 2.3.0.
- Changed to be 2.3 compliant:
Enumerable#chunk(to take only a a block)Enumerable#slice_before(to raise proper argument errors)Number#positive?(to return false for 0)
- Use meaningful names for temporary variables in compiled JavaScript (e.g. for
def foowasTMP_123, nowTMP_foo_123) - Dynamic require severity now defaults to
:ignoremeaning that by default aLoadErrorwill be raised at runtime instead of compile time.
Deprecated
require 'opal/serverandOpal::Serverare deprecated in favor ofrequire 'opal/sprockets/server'andOpal::Sprockets::Server(now part of the opal-sprockets gem).
Removed
- Removed
yamlfrom stdlib, the older implementation was only available for NodeJS and not tested. Replace withrequire 'nodejs/yaml' - Extracted sprockets support to
opal-sprocketswhich should allow for wider support and less coupling (e.g. theopalgem will now be able to improve the compiler without worrying aboutsprocketsupdates). All the old behavior is preserved except forOpal::Serverthat has becomeOpal::Sprockets::Server(see Deprecated section above).
Changed
- Strip Regexp flags that are unsupported by browsers (backport), previously they were ignored, lately most of them now raise an error for unknown flags.
Fixed
Newly compliant with the Ruby Spec Suite:
Module#class_variablesModule#class_variable_getModule#class_variable_setModule#remove_class_variableModule#include?Numeric#step(#1512)
Improvements for Range class (#1486)
- Moved private/tainted/untrusted specs to not supported
- Conforming
Range#to_sandRange#inspect - Starting
Range#bsearchimplementation - Simple
Range#stepimplementation - Fixing
Range#minfor empty Ranges - Fixing
Range#last(n)Range#first(n)and one edge case ofRange#each - Fixing some
Range#stepissues on String ranges - Simple
Range#bsearchimplementation, passes about half the specs - Minor styling improvements. Fixed size of
Range#step. - Compile complex ranges to "Range.new" so there will be a check for begin and end to be comparable.
Fixed
defined?for methods raising exceptionsFixed
Kernel#loop(to catchStopIterationerror)Fixed inheritance from the
Moduleclass.Fixed using
--preloadalong with--no-opalfor CLIFixed
Integer("0")raisingArgumentErrorinstead of parsing as 0Fixed
JSON#parseto raiseJSON::ParserErrorfor invalid inputModule#append_featuresnow detects cyclic includesProcess.clock_gettime(Process::CLOCK_MONOTONIC)will now return true monotonic values or raiseErrno::EINVALif no monotonic clock is availableOpal::Builder no longer always raises an error when a dependency isn't found and instead respects
dynamic_require_severityvalueFixed a constant reference to
Sprockets::FileNotFoundthat previously pointed toOpal::Sprocketsinstead of::Sprockets.
0.10.6 - 2018-06-21
Changed
- Strip Regexp flags that are unsupported by browsers (backport), previously they were ignored, lately most of them now raise an error for unknown flags.
Fixed
- Fixed a constant reference to
Sprockets::FileNotFoundthat previously pointed toOpal::Sprocketsinstead of::Sprockets.
0.10.5 - 2017-06-21
Fixed
- Fix
Time#zonefor zones expressed numerically
0.10.4 - 2017-05-06
Changed
- Better
Opal::Configoptions documentation and organization - Always cache source-maps at build-time so they're available once enabled
0.10.3 - 2016-10-31
Fixed
- Fixed inheritance from the
Moduleclass (#1476) - Fixed source map server with url-encoded paths
- Silence Sprockets 3.7 deprecations, full support for Sprockets 4 will be available in Opal 0.11
- Don't print the full stack trace with deprecation messages
0.10.2 - 2016-09-09
Changed
- Avoid special utf-8 chars in method names, now they start with
$$
0.10.1 - 2016-07-06
Fixed
- Fixed
-Loption for compiling requires as modules (#1510)
0.10.0 - 2016-07-04
Added
- Pathname#relative_path_from
- Source maps now include method names
Module#included_modulesworks- Internal runtime cleanup (#1241)
- Make it easier to add custom runners for the CLI (#1261)
- Add Rack v2 compatibility (#1260)
- Newly compliant with the Ruby Spec Suite:
Array#slice!Array#repeated_combinationArray#repeated_permutationArray#sort_by!Enumerable#sortEnumerable#maxEnumerable#each_entry(#1303)Module#const_setModule#module_evalwith a string
- Add
-L/--libraryoption to compile only the code of the library (#1281) - Implement
Kernel.openmethod (#1218) - Generate meaningful names for functions representing Ruby methods
- Implement
Pathname#joinandPathname#+methods (#1301) - Added support for
begin;rescue;else;end. - Implement
File.extnamemethod (#1219) - Added support for keyword arguments as lambda parameters.
- Super works with define_method blocks
- Added support for kwsplats.
- Added support for squiggly heredoc.
- Implement
Method#parametersandProc#parameters. - Implement
File.new("path").mtime,File.mtime("path"),File.stat("path").mtime. - if-conditions now support
nullandundefinedas falsy values (#867) - Implement IO.read method for Node.js (#1332)
- Implement IO.each_line method for Node.js (#1221)
- Generate
opal-builder.jsto ease the compilation of Ruby library from JavaScript (#1290)
Changed
- Remove deprecation of
Opal::Environmentafter popular request - Setting
Opal::Config.dynamic_require_severitywill no longer affectOpal.dynamic_require_severitywhich now needs to be explicitly set if it differs from the default value of"warning"(See also theOpal.dynamic_require_severityrename below). - The new default for
Opal::Config.dynamic_require_severityis now:warning Opal.dynamic_require_severityandOPAL_CONFIGare now merged intoOpal.config.missing_require_severity(defaults toerror, the expected ruby behavior) andOpal.config.unsupported_features_severity(defaults towarning, e.g. a one-time heads up that freezing isn't supported). Added variable__OPAL_COMPILER_CONFIG__that contains compiler options that may be used in runtime.Hashinstances should now list the string map ($$smap) as the first key, making debugging easier (most hashes will just have keys there).- Handle Pathname object in Pathname constructor
Deprecated
Opal::Processor.stubbed_filesandOpal::Processor.stub_filein favor ofOpal::Config.stubbed_files
Removed
- Removed the previously deprecated
Opal::Fragment#to_code - Removed the previously deprecated
Opal::Processor.load_asset_code - Removed the previously deprecated acceptance of a boolean as single argument to
Opal::Server.new
Fixed
Module#ancestorsand shared code like====andis_a?deal with singleton class modules better (#1449)Class#to_snow shows correct names for singleton classesPathname#absolute?andPathname#relative?now work properlyFile::dirnameandFile::basenameare now Rubyspec compliantSourceMap::VLQpatch (#1075)Regexp::newno longer throws error when the expression ends in \\superworks properly with overwritten alias methods (#1384)NoMethodErrordoes not need a name to be instantiatedmethod_addedfix for singleton class cases- Super now works properly with blocks (#1237)
- Fix using more than two
rescuein sequence (#1269) - Fixed inheritance for
Arraysubclasses. - Always populate all stub_subscribers with all method stubs, as a side effect of this now
method_missingon bridged classes now works reliably (#1273) - Fix
Hash#instance_variablesto not return#defaultand#default_proc(#1258) - Fix
Module#namewhen constant was created usingOpal.cdecl(constant declare) likeChildClass = Class.new(BaseClass)(#1259) - Fix issue with JavaScript
nilreturn paths being treated as true (#1274) - Fix
Array#to_n,Hash#to_n,Struct#to_nwhen the object contains native objects (#1249, #1256) breaksemantics are now correct, except for the case in which a lambda containing abreakis passed to ayield(#1250)- Avoid double "/" when
Opal::Sprockets.javascript_include_tagreceives a prefix with a trailing slash. - Fixed context of evaluation for
Kernel#evalandBasicObject#instance_eval - Fix
Module#===to use all ancestors of the passed object (#1284) - Fix
Struct.newto be almost compatible with Rubyspec (#1251) - Fix
Enumerator#with_indexto return the result of the previously called method. - Improved
Date.parseto cover most date formatting cases. - Fixed
Module#const_getfor dynamically created constants. - Fixed
File.dirnameto return joined String instead of Array. - Fixed multiple assignment for constants, i.e., allowing
A, B = 1, 2. - Fixed
Number#[]with negative number. Now(-1)[1]returns 1. - Fixed parsing of pre-defined
$-?global variables. - Fixed parsing of unicode constants.
- Fixed parsing of quoted heredoc identifier.
- Fixed parsing of mass assignment of method call without parentheses.
- Fixed parsing of
%I{}lists. - Fixed parsing of
%{}lists when list item contains same brackets. - Fixed an issue with
"-"inside the second arg ofString#tr - Fixed Base64 and enabled specs
- Fixed method definition in method body.
- Partially implemented
Marshal.load/Marshal.dump. In order to use it requireopal/full. - Fixed docs for Compiled Ruby - Native section. Rename opal variable to win since window was causing error
- Fixed the
--mapoption, now correclty outputs the sourcemap as json
Removed
- Remove support for configuring Opal via
Opal::Processor, the correct place isOpal::Config - Remove
Opal.processwhich used to be an alias toSprockets::Environment#[]
0.9.4 - 2016-06-20
Fixed
Rebuilt the gem with Rubygems 2.4.8 as building with 2.5.1+ would make the gem un-installable
Removed all symlinks from
node_moduledirectories to avoid further issues building the gem
0.9.3 - 2016-06-16
Fixed
Hash#initializenow accepts JSnullas well asundefined, restoring its 0.8 behavior
0.9.2 - 2016-01-09
Fixed
- Rebuilt the gem with Ruby 2.2 as building with 2.3 would make the gem un-installable
0.9.1 - 2016-01-09
Fixed
- Backport rack2 compatibility (#1260)
- Fixed issue with JS nil return paths being treated as true (#1274)
- Fix using more than two
rescuein sequence (#1269)
0.9.0 - 2015-12-20
Added
- A
consolewrapper has been added to the stdlib, requiring it will make available the$consoleglobal variable. method_added,method_removedandmethod_undefinedreflection now works.singleton_method_added,singleton_method_removedandsingleton_method_undefinedreflection now works.- Now you can bridge a native class to a Ruby class that inherits from another Ruby class
Numericsemantics are now compliant with Ruby.Complexhas been fully implemented.Rationalhas been fully implemented.Kernel#raisenow properly re-raises exceptions (regardless of how many levels deep you are) and works properly if supplied a class that has an exception method.Exception#exception,Exception::exception,Exception#message, andException#to_sare fully implemented- You can make direct JavaScript method calls on using the
recv.JS.methodsyntax. Has support for method calls, final callback (as a block), property getter and setter (via#[]and#[]=), splats, JavaScript keywords (via the::JSmodule) and global functions (afterrequire "js"). Set#superset?,Set#subset?, and the respectiveproper_variant of each are now implementedNameErrorandNoMethodError- add#nameand#argsattributesRegExp#matchnow works correctly in multiline mode with white spaceBasicObject#instance_evalnow can accept a string argument (afterrequire "opal-parser")Adds Nashorn (Java 8+ Javascript engine) runner
bundle exec bin/opal -R nashorn -r nashorn hello.rbNewly compliant with the Ruby Spec Suite:
Enumerable#chunkEnumerable#each_consEnumerable#minmaxRange#to_a(#1246)Modulecomparison methods:#<#<=#<=>#>#>=OpenStruct#method_missingOpenStruct#inspectOpenStruct#to_sOpenStruct#delete_field
Changed
- Renamed:
Hash.keys=>Hash.$$keysHash.map=>Hash.$$mapHash.smap=>Hash.$$smap
Kernel#ppno longer forwards arguments directly toconsole.log, this behavior has been replaced by stdlib's ownconsole.rb(see above).Opal::Sprockets.javascript_include_taghas been added to allow easy debug mode (i.e. with source maps) when including a sprockets asset into an HTML page.
Deprecated
Opal::Processor.load_asset_code(sprockets, name)has been deprecated in favor ofOpal::Sprockets.load_asset(name, sprockets).
Fixed
- Fixed usage of JavaScript keywords as instance variable names for:
Kernel#instance_variable_setKernel#instance_variable_getKernel#instance_variables
Struct#hashnow works properly based on struct contents- No longer crashes when calling a method with an opt arg followed by an optional kwarg when called without the kwarg
- Operator methods (e.g.
+,<, etc.) can be handled bymethod_missing - Fix issue where passing a block after a parameter and a hash was causing block to not be passed (e.g.
method1 some_param, 'a' => 1, &block) - Method defs issued inside
Module#instance_evalandClass#instance_eval, and the respectiveexecnow create class methods - Now with enabled arity checks calling a method with more arguments than those supported by its signature raises an
ArgumentErroras well. - Previously arity checks would raise an error without clearing the block for a method, that could lead to strange bugs in case the error was rescued.
Regexp#===returns false when the right hand side of the expression cannot be coereced to a string (instead of throwing aTypeError)Regexp#optionshas been optimized and correctly returns 0 when called on a Regexp literal without any options (e.g.//)- Fix
Kernel#exitto allow exit inside#at_exit - Fixed a number of syntax errors (e.g. #1224 #1225 #1227 #1231 #1233 #1226)
- Fixed
Native()when used withArrayinstances containing native objects (which weren't wrapped properly) – #1212 - Fix
Array#to_n,Hash#to_n,Struct#to_nwhen the object contains native objects (#1249) - Internal cleanup and lots of bugs!
0.8.1 - 2015-10-12
Removed
- Use official Sprockets processor cache keys API:
The old cache key hack has been removed.
Add
Opal::Processor.cache_keyandOpal::Processor.reset_cache_key!to reset it as it’s cached but should change wheneverOpal::Configchanges.
Fixed
- Fix an issue for which a Pathname was passed instead of a String to Sprockets.
0.8.0 - 2015-07-16
Added
Hash[]implementation fully compliant with rubyspecNewly compliant with the Ruby Spec Suite:
Array#bsearchArray#combinationArray#permutationArray#productArray#rotate!Array#rotateArray#sampleArray#to_hArray#values_atArray#zipEnumerator#with_indexKernel#===Kernel#ArrayKernel#FloatKernel#HashKernel#IntegerKernel#StringKernel#formatKernel#sprintfMatchData#==MatchData#eql?MatchData#values_atModule#instance_methodsRegexp#matchString#%String#===String#==String#[]String#each_lineString#eql?String#indexString#inspectString#linesString#matchString#nextString#octString#scanString#sliceString#splitString#succString#to_iString#try_convert
Changed
- Updated to Sprockets v3.0.
- Enable operator inlining by default in the compiler.
Removed
- Removed
minitestfrom stdlib. It's not part of MRI and it never belonged there, checkout theopal-minitestgem instead.
Fixed
- Delegate dependency management directly to Sprockets (when used) making sourcemaps swift again.
This means code generated by sprockets will always need to be bootstrapped via
Opal.loadorOpal.require. LuckilyOpal::Processor.load_asset_code(sprockets, name)does just that in the right way. - Fix
Promise#always. - Fix
String#splitwhen no match is found and a limit is provided - Fix
require_tree(".")when used from file at the root of the assets paths - Parser: Allow trailing comma in paren arglists, after normal args as well as assoc args.
- Parser: Fix parsing of parens following divide operator without a space.
- Parser: Fix bug where keyword arguments could not be parsed if method definition did not have parens around arguments.
-
Module#const_getnow accepts a scoped constant name -
Regexp#===sets global match data vars
0.7.2 - 2015-04-23
- Remove Sprockets 3.0 support (focus moved to upcoming 0.8)
- Fix version number consistency.
0.7.1 - 2015-02-13
- CLI options
-dand-vnow set respectively$DEBUGand$VERBOSE - Fixed a bug that would make the
-vCLI option wait for STDIN input - Add the
-E/--no-exitCLI option to skip implicitKernel#exitcall - Now the CLI implicitly calls
Kernel#exitat the end of the script, thus makingat_exitblocks be respected.
0.7.0 - 2015-02-01
Stop keyword-arg variable names leaking to global javascript scope
Class#native_classnow also exposesMyClass.new(Ruby) asOpal.global.MyClass.new()(JS)Add CRuby (MRI) tests harness to start checking Opal against them too.
Add Minitest to the stdlib.
Add
Date#<=>with specs.Show extended info and context upon parsing, compiling and building errors.
Support keyword arguments in method calls and definitions.
Fix
begin/rescueblocks to evaluate to last expression.Add support for
RUBY_ENGINE/RUBY_PLATFORM != "opal"pre-processor directives.if RUBY_ENGINE != "opal" # this code never compiles endFix donating methods defined in modules. This ensures that if a class includes more than one module, then the methods defined on the class respect the order in which the modules are included.
Improved support for recursive
Hashfor both#inspectand#hash.Optimized
Hashimplementation forStringandSymbol, they have a separate hash-table in which they're used as both keys and hashes.Added real
#hash/eql?support, previously was relying on.toString().String#to_procnow uses__send__instead ofsendfor calling methods on receivers.Deprecated
Opal::Sprockets::Environment. It can easily be replaced byOpal::Serveror by appendingOpal.pathsto aSprockets::Environment:Sprockets::Environment.new.tap { |e| Opal.paths.each {|p| e.append_path(p)} }Add
Setmethods#classify,#collect!,#map!,#subtract#replace,#differenceand#eql?Support
module_functionwithout args to toggle module functions.Fix bug where command calls with no space and sym arg were incorrectly parsed.
Add some
StringScannermethods.Add
Date#<<andDate#>>implementations.Support nested directories using
require_treedirective.Fix bug where Exception subclasses could not have methods defined on them.
Fix symbols with interpolations
:"#{foo}"Implement $1..N matchers and rewrite support for $~, $', $& and $`.
Implement
Regexp.last_match.Fixed
-@unary op. precedence with a numeric and followed by a method call (e.g.-1.foowas parsed as-(1.foo))require_relative(with strings) is now preprocessed, expanded and added toCompiler#requiresRewritten the require system to respect requires position (previously all the requires were stacked up at the top of the file)
Implement for-loop syntax
Add Array#|
Fix Range.new to raise
ArgumentErroron contructor values that cannot be comparedFix compiler bug where Contiguous strings were not getting concatenated.
Cleanup generated code for constant access. All constant lookups now go through
$scope.get('CONST_NAME')to produce cleaner code and a unified place for const missing dispatch.Remove
const_missingoption from compiler. All constant lookups are now strict.Add initial support for Module#autoload.
Fix
Enumerator#with_index,Numeric#round.
0.6.3 - 2014-11-23
- Fix
Regexp.escapeinternal regexp
0.6.2 - 2014-04-24
Added Range#size
opalexecutable now reads STDIN when no file or-eare passedopalexecutable doesn't exit after showing version on-vif other options are passed(Internal) improved the mspec runner
0.6.1 - 2014-04-14
Updated RubySpec to master and added
rubysl-*specs. Thanks to Mike Owens (@mieko)Added
Kernel#require_remote(url)inopal-parserthat requires files with basic synchronous ajax GET requests. It is used to load<scripts type="text/ruby" src="…url…">.Various parsing fixes (Hash parsing,
defreturns method name, cleanupcore/util, Enumerator fixes)Added
#native_reader,#native_writerand#native_accessoras class methods donated byinclude NativeAdded specs for Sprockets' processors (both .js.rb and .opalerb), backported from
opal-railsSet 2.1.1 as RUBY_VERSION
Add
opal-buildcommand utility to easily build libraries to jsAdd
opal-replto gemspec executables, previously was only available by using Opal from sourceFix parsing
=>in hash literals where it would sometimes incorrectly parse as a key name.
0.6.0 - 2014-03-05
Fix parsing of escapes in single-strings ('foo\n'). Only ' and \ characters now get escaped in single quoted strings. Also, more escape sequences in double-quoted strings are now supported:
\a,\v,\f,\e,\s, octal (\314), hex (\xff) and unicode (\u1234).Sourcemaps revamp. Lexer now tracks column and line info for every token to produce much more accurate sourcemaps. All method calls are now located on the correct source line, and multi-line xstrings are now split to generate a map line-to-line for long inline javascript parts.
Merged sprockets support from
opal-sprocketsdirectly into Opal. For the next release, the exernalopal-sprocketsgem is no longer needed. This commit addsOpal::Processor,Opal::ServerandOpal::Environment.Introduce pre-processed if directives to hide code from Opal. Two special constant checks now take place in the compiler. Either
RUBY_ENGINEorRUBY_PLATFORMwhen== "opal". Both if and unless statements can pick up these logic checks:if RUBY_ENGINE == "opal" # this code compiles else # this code never compiles endUnless:
unless RUBY_ENGINE == "opal" # this code never compiles endThis is particularly useful for avoiding
require()statements being picked up, which are included at compile time.Add special
debuggermethod to compiler. Compiles down to javascriptdebuggerkeyword to start in-browser debug console.Add missing string escapes to
read_escapein lexer. Now most ruby escape sequences are properly detected and handled in string parsing.Disable escapes inside x-strings. This means no more double escaping all characters in x-strings and backticks. (
\n=>\n).Add
time.rbto stdlib and movedTime.parse()andTime.iso8601()methods there.!is now treated as an unary method call on the object. Opal now parsed!as a def method name, and implements the method onBasicObject,NilClassandBoolean.Fixed bug where true/false as object literals from javascript were not correctly being detected as truthy/falsy respectively. This is due to the javascript "feature" where
new Boolean(false) !== false.Moved
native.rbto stdlib. Native support must now be explicitly required into Opal.Nativeis also now a module, instead of a top level class. Also addedNative::Object#respond_to?.Remove all core
#as_json()methods fromjson.rb. Added them externally toopal-activesupport.Kernel#respond_to?now calls#respond_to_missing?for compliance.Fix various
Stringmethods and add relevant rubyspecs for them.#chars,#to_f,#clone,#split.Fix
Arraymethod compliance:#first,#fetch,#insert,#delete_at,#last,#splice,.try_convert.Fix compliance of
Kernel#extendand ensure it calls#extended()hook.Fix bug where sometimes the wrong regexp flags would be generated in the output javascript.
Support parsing
__END__constructs in ruby code, inside the lexer. The content is gathered up by use of the parser. The special constantDATAis then available inside the ruby code to read the content.Support single character strings (using ? prefix) with escaped characters.
Fix lexer to detect dereferencing on local variables even when whitespace is present (
a = 0; a [0]parses as a deference on a).Fix various
Structmethods. Fixed#eachand#each_pairto return self. AddStruct.[]as synonym forStruct.new.Implemented some
Enumerablemethods:#collect_concat,#flat_map,#reject,#reverse_each,#partitionand#zip.Support any Tilt template for
index_pathinOpal::Server. All index files are now run throughTilt(now supports haml etc).Fix code generation of
op_asgn_1calls (foo[val] += 10).Add
base64to stdlib.Add promises implementation to stdlib.
Add
Mathmodule to corelib.Use
//#instead of//@deprecated syntax for sourceMappingURL.Implicitly require
erbfrom stdlib when including erb templates.Fix
Regexp.escapeto also escape '(' character.Support '<' and '>' as matching pairs in string boundrys
%q<hi>.Opal::Serverno longer searches for an index file if not specified.Move
MathandEncodingto stdlib. Can be required usingrequire 'math', etc.Fix some stdlib
Datemethods.Fix
Regexp.escapeto properly escape \n, \t, \r, \f characters.Add
Regexp.quoteas an alias ofescape.
0.5.5 - 2013-11-25
Fix regression: add
%i[foo bar]style words back to lexerMove corelib from
opal/coretoopal/corelib. This stops files incore/clashing with user files.
0.5.4 - 2013-11-20
- Reverted
RUBY_VERSIONto1.9.3. Opal0.6.0will be the first release for2.0.0.
0.5.3 - 2013-11-20
Opal now targets ruby 2.0.0
Named function inside class body now generates with
$prefix, e.g.$MyClass. This makes it easier to wrap/bridge native functions.Support Array subclasses
Various fixes to
String,Kerneland other core classesFix
Method#callto use correct receiverFix
Module#define_methodto call#to_procon explicit argumentFix
super()dispatches on class methodsSupport
yield()calls from inside a block (inside a method)Cleanup string parsing inside lexer
Cleanup parser/lexer to use
tandkprefixes for all tokens
0.5.2 - 2013-11-11
- Include native into corelib for 0.5.x
0.5.1 - 2013-11-10
Move all corelib under
core/directory to prevent filename clashes withrequireMove
native.rbinto stdlib - must now be explicitly requiredImplement
BasicObject#__id__Cleanup and fix various
Enumerablemethods
0.5.0 - 2013-11-03
- Optimized_operators is no longer a compiler option
- Replace
Opal.bridge_class()withclass Foo < `bar`syntax - Expose
Opal.bridge_class()for bridging native prototypes - Source maps improvements
- Massive Rubyspec cleanup + passing specs
- Massive Corelib/Stdlib cleanup + fixes
- Massive internal cleanup + fixes
See the full diff for more details (almost 800 commits)
0.4.4 - 2013-08-13
- Remove native object method calls
- Add Struct class
- Add method stubs as method_missing option, stubs enabled by default
- Native is now used to wrap native objects directly
- Fix Hash.new and Hash.allocate for subclasses
- Generate sourcemaps from fragments
- Allow blocks to be passed to zsuper (no args) calls
- Fix yield when given 1 or multiple arguments for block destructuring
0.4.3 - 2013-07-24
- Re-implement class system. Classes are now real objects instead of converted Procs. This allows classes to properly inherit methods from each other.
- Fix exception hierarchy. Not all standard exception classes were subclassing the correct parent classes, this is now fixed.
- Move ERB into stdlib. The erb compiler/parser has also been moved into lib/
- Opal::Builder class. A simple port/clone of sprockets general building. This allows us to build projects similar to the way opal-sprockets does.
- Move json.rb to stdlib.
0.4.2 - 2013-07-03
Added
Kernel#rand. (fntzr)Restored the
bin/opalexecutable in gemspec.Now
.valueOf()is used in#to_nof Boolean, Numeric, Regexp and String to return the naked JavaScript value instead of a wrapping object.Parser now wraps or-ops in paranthesis to stop variable order from leaking out when minified by uglify. We now have code in this format:
(((tmp = lhs) !== false || !==nil) ? tmp : rhs).
0.4.1 - 2013-06-16
- Move sprockets logic out to external opal-sprockets gem. That now handles the compiling and loading of opal files in sprockets.
0.4.0 - 2013-06-15
Added fragments to parser. All parser methods now generate one or more Fragments which store the original sexp. This allows us to enumerate over them after parsing to map generated lines back to original line numbers.
Reverted
nullfornil. Too buggy at this time.Add Opal::SprocketsParser as Parser subclass for handling parsing for sprockets environment. This subclass handles require statements and stores them for sprockets to use.
Add :irb option to parser to keep top level lvars stored inside opal runtime so that an irb session can be persisted and maintain access to local variables.
Add Opal::Environment#use_gem() helper to add a gem to opals load path.
Stop pre-setting ivars to
nil. This is no longer needed asnilis nownullorundefined.Use
nullasnilin opal. This allows us to send methods tonullandundefined, and both act asnil. This makes opal a much better javascript citizen. REVERTEDAdd Enumerable#none? with specs.
Add Opal.block_send() runtime helper for sending methods to an object which uses a block.
Remove _klass variable for denoting ruby classes, and use constructor instead. constructor is a javascript property used for the same purpose, and this makes opal fit in as a better js citizen.
Add Class.bridge_class method to bridge a native constructor into an opal class which will set it up with all methods from Object, as well as giving it a scope and name.
Added native #[]= and #to_h methods, for setting properties and converting to a hash respectivaly.
Fix bug where '::' was parsed as :colon2 instead of :colon3 when in an args scope. Fixes #213
Remove lots of properties added to opal classes. This makes normal js constructors a lot closer to opal classes, making is easier to treat js classes as opal classes.
Merge Hash.from_native into Hash.new
0.3.44 - 2013-05-31
Cleanup runtime, and remove various flags and functions from opal objects and classes (moving them to runtime methods).
Remove some activesupport methods into external lib.
Add/fix lots of String methods, with specs.
Add more methods to MatchData class.
Implement $' and $` variables.
Opal can now call methods on all native objects, via method missing dispatcher.
Add Opal::Environment as custom sprockets subclass which adds all opal load paths automatically.
0.3.43 - 2013-05-02
Stop inlining respond_to? inside the parser. This now fully respects an object overriding respond_to?.
Expose
Opal.eval()function when parser is loaded for parsing and running strings of ruby code.Add erb to corelib (as well as compiler to gem lib). ERB files with .opalerb extension will automatically be compiled into Template constant.
Added some examples into examples/ dir.
Add Opal.send() javascript function for sending methods to ruby objects.
Native class for wrapping and interacting with native objects and function calls.
Add local_storage to stdlib as a basic wrapper around localStorage.
Make method_missing more performant by reusing same dispatch function instead of reallocating one for each run.
Fix Kernel#format to work in firefox. String.prototype.replace() had different semantics for empty matching groups which was breaking Kernel#format.
0.3.42 - 2013-03-21
Fix/add lots of language specs.
Seperate sprockets support out to opal-sprockets gem.
Support %r[foo] style regexps.
Use mspec to run specs on corelib and runtime. Rubyspecs are now used, where possible to be as compliant as possible.
0.3.41 - 2013-02-26
Remove bin/opal - no longer required for building sources.
Depreceate Opal::Environment. The Opal::Server class provides a better method of using the opal load paths. Opal.paths still stores a list of load paths for generic sprockets based apps to use.
0.3.40 - 2013-02-23
Add Opal::Server as an easy to configure rack server for testing and running Opal based apps.
Added optional arity check mode for parser. When turned on, every method will have code which checks the argument arity. Off by default.
Exception subclasses now relfect their name in webkit/firefox debuggers to show both their class name and message.
Add Class#const_set. Trying to access undefined constants by a literal constant will now also raise a NameError.
0.3.39 - 2013-02-20
Fix bug where methods defined on a parent class after subclass was defined would not given subclass access to method. Subclasses are now also tracked by superclass, by a private '_inherited' property.
Fix bug where classes defined by
Class.newdid not have a constant scope.Move Date out of opal.rb loading, as it is part of stdlib not corelib.
Fix for defining methods inside metaclass, or singleton_class scopes.
0.3.38 - 2013-02-19
Add Native module used for wrapping objects to forward calls as native calls.
Support method_missing for all objects. Feature can be enabled/disabled on
Opal::Processor.Hash can now use any ruby object as a key.
Move to Sprockets based building via
Opal::Processor.
0.3.37 - 2013-02-15
- Extract the JavaScript runtime to
opal/runtime.js - Add core
template.rbfor the basis of template libraries for Opal
0.3.36 - 2013-02-08
- Use Ruby
requiredirective inside Sprockets - Depreceate
Opal.processin favour ofOpal::Environment
0.3.35 - 2013-02-05
- Internal cleanup
0.3.34 - 2013-02-05
- Fix bug where camelcased lvars could parse as constants
- Add
Array#shuffle - Migrate to Sprockets-based building
- Move ERB to separate gem
0.3.33 - 2013-01-18
- Implement attr_reader/writer/accessor for dynamic uses
- Hash internals update