diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28c73542..58acd00b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,13 +26,14 @@ jobs: - 4.10.x - 4.11.x - 4.12.x + - 4.13.x include: - os: ubuntu-latest - ocaml-compiler: 4.13.x + ocaml-compiler: 4.14.x - os: macos-latest - ocaml-compiler: 4.13.x + ocaml-compiler: 4.14.x - os: windows-latest - ocaml-compiler: 4.13.x + ocaml-compiler: 4.14.x runs-on: ${{ matrix.os }} @@ -44,7 +45,7 @@ jobs: git config --global core.ignorecase false - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use OCaml ${{ matrix.ocaml-compiler }} uses: ocaml/setup-ocaml@v2 @@ -62,23 +63,16 @@ jobs: - run: opam exec -- git diff --exit-code lint-fmt: - strategy: - matrix: - ocaml-compiler: - - 4.13.x - runs-on: ubuntu-latest - steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Use OCaml ${{ matrix.ocaml-compiler }} + - name: Use OCaml 4.14.x uses: ocaml/setup-ocaml@v2 with: - ocaml-compiler: ${{ matrix.ocaml-compiler }} + ocaml-compiler: 4.14.x dune-cache: true - - run: opam depext ocamlformat=$(cat .ocamlformat | grep version | cut -d '=' -f 2) --install - - - run: opam exec -- dune build @fmt + - name: Lint fmt + uses: ocaml/setup-ocaml/lint-fmt@v2 diff --git a/.ocamlformat b/.ocamlformat index 00be681f..d3bf218d 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -10,4 +10,4 @@ break-separators=before dock-collection-brackets=false margin=90 module-item-spacing=sparse -version=0.20.0 +version=0.21.0 diff --git a/CHANGES.md b/CHANGES.md index 280d19b0..27947458 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,814 +1,6 @@ -# dev (2021-??-??) - ?? -## Features/Changes -* Compiler: add --target-env flag, for JS runtime specific compilation targets (#1160). -* Compiler: static evaluation of backend_type (#1166) -* Compiler: speedup emitting js files (#1174) -* Compiler: simplify (a | 0) >>> 0 into (a >>> 0) (#1177) -* Compiler: improve static evaluation of cond (#1178) -* Compiler: be more consistent dealing with js vs ocaml strings (#984) -* Compiler: Compiler: add BigInt to provided symbols (fix #1168) (#1191) -* Compiler: use globalThis, drop joo_global_object #1193 -* Compiler: new -Werror flag to turn wanrings into errors (#1222) -* Compiler: make the inlining less agressive, reduce size, improve pref (#1220) -* Compiler: rename internal library js_of_ocaml-compiler.runtime to js_of_ocaml-compiler.runtime-files -* Lib: new runtime library to improve compatibility with Brr and gen_js_api -* Lib: add messageEvent to Dom_html (#1164) -* Lib: add PerformanceObserver API (#1164) -* Lib: add CSSStyleDeclaration.{setProperty, getPropertyValue, getPropertyPriority, removeProperty} (#1170) -* Lib: make window.{inner,outer}{Width,Height} non-optional -* Lib: introduce Js_of_ocaml.Js_error module, deprecate Js_of_ocaml.Js.Error exception. -* Lib: add deprecation warning for deprecated code -* PPX: json can now be derived for mutable records (#1184) -* Runtime: use crypto.getRandomValues when available (#1209) +# 5.0 (2022-11-02) - Lille +* Use jsoo_runtime instead of linkops(javascript) in META files (#2) -## Bug fixes -* Compiler: fix sourcemap warning for empty cma (#1169) -* Compiler: Strengthen bound checks. (#1172) -* Compiler: fix `--wrap-with-fun` under node (#653, #1171) -* Compiler: fix parsing of annotaions in js stubs (#1212, fix #1213) -* Ppx: allow apostrophe in lident (fix #1183) (#1192) -* Runtime: fix float parsing in hexadecimal form -* Runtime: fix implementation of caml_js_instanceof -* Graphics: fix mouse_{x,y} (#1206) - -# 3.11.0 (2021-10-06) - Lille - -## Features/Changes -* Compiler: setting tc_depth to 0 remove direct call from the tc optimization. -* Lib: add hidden, onfullscreenchange and onwebkitfullscreenchange to document -* Runtime: fixes for Windows, all tests pass -* Runtime: make all windows drive available on nodejs. -* Runtime: add support for Sys.mkdir and Sys.rmdir -* Runtime: make stdin work on nodejs -* Runtime: add support for Unix(stat,lstat,mkdir,rmdir,symlink,readlink,unlink,getuid) on nodejs. -* Runtime: add caml_raise_with_args - -## Bug fixes -* Compiler: fix toplevel generation (#1129, #1130, #1131) -* Compiler: fix predefined exn id with separate compilation -* Compiler: js stubs without 'Provides' should still allow 'Require' -* Runtime: fix handling of uncaugh exceptions -* Runtime: fix error handling of Sys.readdir -* Dune: make git version lookup more resilient - -# 3.10.0 (2021-08-30) - Lille -## Features/Changes -* Compiler: add support for OCaml 4.13 -* Compiler: new tool to check for missing primitives -* Compiler: drop support for OCaml 4.03 and bellow -* Lib: add offsetX and offsetY to Dom_html.mouseEvent -* Lib: add innerText property for Dom_html -* Runtime: add dummy implementation for many dummy primitives -* Runtime: add runtime for new float operation in 4.13 #1113 (by pmwhite) - -## Misc -* manual/rev_bindings.wiki: fix compilation error - -# 3.9.1 (2021-02-17) - Lille -## Features/Changes -* Runtime: add missing primitives for OCaml 4.12 - -## Bug fixes -* Compiler: fix handling of offsetclosure with 4.12 -* Compiler: fix ocaml_version parsing to support tilde - -# 3.9.0 (2021-02-15) - Lille -## Features/Changes -* Lib: add clipboardEvent to Dom_html and update appropriate function signatures -* Lib: add submitEvent to Dom_html and update appropriate function signatures -* Compiler: complete support for OCaml 4.12 -* Lib: expose API to attached and retrieve js errors to/from ocaml exceptions -* Lib: intersection observer API fixes - -## Bug fixes -* Compiler: fix a segmentation fault when `flat-float-array` mode is disabled. - -# 3.8.0 (2020-10-21) - London -## Features/Changes -* compiler, ppx_js, ppx_deriving_json: port PPX's to ppxlib (#1041) - -# 3.7.1 (2020-09-29) - London -## Features/Changes -* lib: Add Navigator.{vendor,maxTouchPoints} (#1062) -* lib: adds the intersection observer API (#1063) - -## Bug fixes -* compiler: revert of "Eliminate allocation of dummy function #1013" -* compiler: fix for #1051 (#1052), Ensure the overflow warning is always displayed -* runtime: add missing primitives for 4.11 -* lib: Fix resize-observer (#1058) - -# 3.7.0 (2020-08-05) - Lille -## Features/Changes -* Runtime: allow one to override xmlHttpRequest.create (#1002) -* Runtime: Change the semantic of MlBytes.toString, introduce MlBytes.toUtf16 -* Compiler: initial support for OCaml 4.11 -* Compiler: initial support for OCaml 4.12 -* Compiler: improve the javascript parser by relying on menhir - incremental api. -* Compiler: Eliminate allocation of dummy function #1013 - -## Bug fixes -* Compiler: fix code generation for recursive function under for-loops (#1009) -* Compiler: the jsoo compiler compiled to javascript was not behaving correctly - when parsing constant in the from the bytecode -* Compiler: make sure inline doesn't loop indefinitly (#1043) -* Compiler: fix bug generating invalid javascript for if-then construct (#1046) -* Compiler: do not use polymorphic comparison when joining float values (#1048) -* Lib: Rename msg to message in Worker (#1037) -* Lib: fix graphics_js when build with separate compilation (#1029) - -# 3.6.0 (2020-04-26) - Lille -## Features/Changes -* Compiler: change compilation scheme for branches (#948) -* Compiler: Introduce sub-command: link, build-runtime, build-fs (#987) -* Compiler: embed javascript runtime in the compiler (#978) -* Compiler: refactor javascript lexer/parser, add tests (#986) -* Runtime: clean runtime for string vs bytes -* Runtime: remove many old polyfill -* Runtime: add unix_isatty -* Runtime: optimize caml_call_gen (#996) -* Runtime: change representation of int64 (#905) -* Runtime: improve node.js backend for Sys.command (#979) -* Runtime: add javascript runtime for Str (#998) -* Lib: add closest method to element (#930) -* Lib: add several methods and functions to Typed_array (#970) -* Ppx: ppx_js behave better with merlin (#933) -* Misc: Cleanup Meta files (e.g. `js_of_ocaml.tyxml` is no longer valid library name) -* Misc: switch to ocamlformat.0.14 - -## Bug fixes -* Compiler: fix vardecl optim (#946) -* Compiler: restore optimization when generating if statements -* Compiler: fix javascript parser in the presence of line directives (#980) -* Runtime: Catch nodejs errors and re-raise them as Sys_error -* Runtime: fix caml_parse_sign_and_base and unsigned syntax -* Runtime: fix caml_js_wrap_meth_callback_strict (#996) -* Runtime: fix over-application of javascript callback (#996) -* Runtime: fix partial-application of javascript callback (#996) -* Runtime: fic caml_js_wrap_meth_callback_unsafe (#996) -* Lib: Fix the type of blur and focus event to be focusEvent (#929) - -# 3.5.2 (2019-12-14) - Hong Kong -## Features/Changes -* Misc: support for ocaml 4.10 -* Misc: ppx_deriving_json uses ppxlib >= 0.9 - -## Bug fixes -* Runtime: fix pseudo fs initialization (#931) - -# 3.5.1 (2019-11-16) - Hong Kong -## Features/Changes - -## Bug fixes -* Runtime: fix poly compare with null and undefined (#920) -* Lib: Deriving Json does not export an [import] unit -* Dynlink/toplevel: export all units when no export file is specified (#921) -* Ppx: ppx_deriving_json should allow [%to_json: t] syntax - -# 3.5.0 (2019-11-10) - Hong Kong -## Features/Changes -* Compiler: Improve testing of the compiler (Ty Overby) -* Compiler: Add several macros for making the runtime easier to maintain (#771) (Ty Overby) -* Compiler: Allow to emit one javascript per compilation unit (#783) -* Compiler: refactoring (#781, #782, #787, #795, #802) -* Compiler: more source map location for the javascript runtime (#795) -* Compiler: tune variable naming (#838) -* Compiler: Work around num lib incompatibility -* Compiler: escape '# 1.0+beta12) - -## Bug fixes -* Runtime: fix Sys.file_exists for the in-memory filesystem. -* Runtime: implement missing primitives: caml_nativeint_bswap, caml_floatarray_*, - caml_ba_change_layout -* Runtime: few other bugfixes. -* Compiler: fix compat with OCaml 4.06 - -# 3.0.0 (2017-06-23) - Hong Kong - -## Features/Changes -* Misc: switch to ppx instead of camlp4 -* Misc: always install deriving_json -* Misc: remove support for async_kernel, bin_prot -* Misc: remove support for ppx_driver -* Misc: split js_of_ocaml in multiple packages -* Misc: switch to jbuilder -* Misc: new pseudo filesystem support with better node support -* Compiler: sourcemap support is now optional -* Compiler: no more strong dep on yojson, b64, menhir, ocamllex -* Compiler: improve separate compilation workflow -* Runtime: add support for weakdef -* Syntaxes: add expect tests -* Syntaxes: switch to ocaml-migrate-parsetree and ppx_tools_versioned -* Lib: Add primitives in [Js.Unsafe] -* Lib: remove keycode module, replaced by Dom_html.Keyboard_code -* Lib: XmlHttpRequest, API change for perform functions. - -## Bug fixes -* Runtime: fix many stubs -* Lib: fix many signatures -* Compiler: fix performance of compilation passes (simpl,clean) -* Compiler: fix compat with OCaml 4.06 -* Toplevel: flush channels after execution. -* Toplevel: fix toplevel generation when using -export-unit - -# 2.8.4 (2016-12-21) - -## Features/Changes -* Compiler: new jsoo_link binary to link multiple javascript files - together and merging sourcemaps. -* Toplevel: improve generation of toplevels, one can now pass a - an export file containing units to export. (see jsoo_listunits) -* Lib: Provide a Js_of_ocaml (namespace) module to ease transition - with future version of js_of_ocaml - -## Bug fixes -* Compiler: fix separate compilation when facing empty unit inside a library -* Runtime: fix many javascript stubs -* Syntac: fix ppx deriving json - -# 2.8.3 (2016-11-04) - -## Features/Changes -* Runtime: complete support for 4.04 - -## Bug fixes -* Compiler: fix order of javascript files -* Compiler: fix Javascript lexer (newline inside strings) -* Compiler: fix bug in closure generation -* Compiler: fix regression in closure generation (introduced in 2.8) (#531) -* Compiler: fix code generation when static evaluation is disabled - -# 2.8.2 (2016-09-10) - -## Features/Changes -* Lib: add Dom_html.Keyboard_code & Dom_html.Keyboard_key (Corwin de Boor) -* Misc: update lib and runtime to work better with non browser environment -* Misc: initial support for 4.04 - -## Bug fixes -* Compiler: fix js output for x - -1 -* Compiler: fix parsing of annotations in the runtime -* Compiler: fix javascript minifier -* Compiler: various fixes for separate compilation. - -# 2.8.1 (2016-07-01) - -## Features/Changes -* Compiler: reduce memory usage for shortvar -* Lib: Add optional `prefix` arg to Jsonp.call -* Ppx: add ppx_driver compatibility - -## Bug fixes -* Lib: fix Js.object_keys, Js.export -* Lib: Async, do not ignore unhandled exceptions - -# 2.8 (2016-06-16) -## Features/Changes -* Compiler: allow dynlink of precompiled javascript file -* Compiler: Improve tailcall optimization -* Compiler: Improve pretty mode -* Compiler: More inlining and static evaluation -* Compiler: Better source map support, to leverage resolve_variable_names - in chrome DevTools -* Compiler: preserve as much as possible the initial OCaml variable names -* Lib: synchronize with tyxml 4.0.0 -* Lib: convert string/bigstring to/from typed_array -* Lib: add Tyxml_js.Register API. -* Lib: Support for Core_kernel and Async_kernel (32bit only). -* Lib: Mutation observer. -* Runtime: bigstring, caml_int32_bits_of_float, .. -* Runtime: better nodejs integration - -## Misc -* Support for OCaml 4.03 -* Toplevel with ppx syntax - -## Bug fixes -* Compiler: Fix float printing -* Compiler: fix separate compilation - -# 2.7 (2016-01-25) - -## Features/Changes -* Syntax: ppx_deriving -* Compiler: Add custom_header ability to jsoo generate file (Edgar Aroutiounian) -* Compiler: Bytecode parsing, improved performance -* Lib: add geolocation API (Stéphane Legrand) -* Lib: add Mutation observers API (Stéphane Legrand) -* Lib: add Jstable module (Drup) -* Lib: add WebWorker API (Grégoire Henry) -* Lib: Allow to customize 'in_channel' with specific 'refiller' (Grégoire Henry) -* Lib: Synchronized tyxml 3.6.0 - -## BugFixes -* Compiler: Fix compilation of the [match with exception] construct -* Compiler: fix compat with the upcoming ocaml 4.03 -* Lib: Tyxml_js, discrepancy between Firefox and Chromium -* Lib: various small fixes -* Runtime: Fix Big_int.square_big_int -* Runtime: graphics, fix draw_image with transparent pixel -* Ppx: fix for merlin - -# 2.6 (2015-07-15) - -## Features/Changes -* Compiler: Findlib is optional -* Compiler: improvement of sourcemap support (ie: inlinned sourcemap) -* Compiler: Support for separate compilation (compile cm{o,a} -> js) -* Compiler: more inlining -* Syntax: new ppx syntax -* Syntax: js object literal (camlp4 + ppx) -* Runtime: support for Dynlink -* Runtime: Support for upcoming release of Bin_prot, Core_kernel, Async_kernel -* Lib: add requestAnimationFrame -* Lib: complete Js.Math -* Lib: complete xmlHttpRequest - -## Misc -* Drop support for 3.12 - -## BugFixes -* Runtime: Fix caml_hash -* Lib: fix tyxml + svg -* Lib: various Api fixes - -# 2.5 (2014-09-30) - -## Features/Changes -* Compiler: SourceMap improvement -* Compiler: remove registration of unused named value (wrt runtime) -* Compiler: Smarter inlining, Constant sharing, Switch generation -* Lib: Dom binding: *AttributeNS, *AttributeNode*, borderRadius -* Runtime: improve performance of string, array allocation -* Misc: enable safestring for OCaml 4.02 -* Commandline: switch to Cmdliner. Better -help + manpage - -## BugFixes -* Compiler: workaround a bug in ocaml 4.02 wrt debug section. -* Compiler: bug when generating minified JavaScript. -* Runtime: fix Obj.tag -* Runtime: fix internalmod wrt ocaml4.02 - -# 2.4.1 (2014-08-28) - -## BugFixes -* Compiler: restore compatibility with ocaml 4.02 -* Runtime: fix caml_hash, Math.imul may give wrong results (#215) -* Lib: Graphics_js, update text drawing baseline -* Lib: Fix overuse of FormData in XmlHttpRequest (Tomohiro Matsuyama #214) - -# 2.4 (2014-08-08) - -## Features/Changes -* Runtime: support for num (Ryan Goulden) -* Lib: initial support for Dom_svg -* Lib: introduce Jsonp module -* Lib: introduce JSON object binding -* Lib: introduce DomContentLoaded -* lib: introduce eventSource -* Lib: introduce js_of_ocaml.toplevel package -* Lib: various improvement: textContent,outerHTML,unload event,css properties -* Lib: complete binding of Js.array -* Lib: change signature of Sys_js.register_autoload -* Lib: sync js_of_ocaml.tyxml with latest tyxml -* Tools: helpers to build toplevel: jsoo_mktop, jsoo_mkcmis - -## BugFixes -* Compiler: generate js files with default permission, was 0o600 - (#182) (Daniel Bünzli) -* Syntax: fix typing of method arguments -* Runtime: fix behaviour of Sys.argv (Tomohiro Matsuyama) -* Runtime: fix caml_js_meth_call -* Compiler: fix assert false when deadcode is off -* Compiler: fix compilation of Js.debugger - -# 2.3 (2014-06-30) - -## Features/Changes -* Lib: remove deprecated Event_arrow -* Lib: introduce js_of_ocaml.tyxml -* Lib: introduce js_of_ocaml.weak (that loads weak.js) - and remove predicate joo_weak -* Lib: introduce js_of_ocaml.log (Lwt logger) -* Lib: Dom_html.{range,selection} (Enguerrand Decorne) - -## BugFixes -* Compiler: fix traduction of Ult binop (#177) -* Compiler: fix the build of compiler.{cmxs,cma} (Stéphane Glondu) -* Compiler: fix traduction of logical shift right -* Runtime: fix marshaling (#176) -* Meta: update predicates (joo_* -> jsoo_*) -* Lib: fix class type Dom_html.optionElement - -# 2.2 (2014-05-15) - -## Features/Changes -* Runtime: improve blit_string perf -* Compiler: option to warn about unused js variable -* Lib: audio/videoElement - -## BugFixes -* Syntax: catch exception in syntax extension (#158) -* Compiler: compat with Node.js (global object) (#160) -* Runtime: fix graphics.js -* Lib: fix Dom.event interface - -# 2.1 (2014-04-28) - -## Features/Changes -* Runtime: bigarray comparison -* Compiler: allow to embed directory with -file dir_name=ext1,ext2:dest_path -* Compiler: can now output embedded files in a different js file -* Lib: js_of_ocaml.graphics -* Lib: Js.Unsafe.expr to embed JavasScript expression - to be used instead of Js.Unsafe.variable (or eval_string) -* Lib: Sys_js.js_of_ocaml_version && Sys_js.file_content -* OCamlbuild plugin: Add the OASIS support, document the API and add the tags - sourcemap (included in the meta-tag debug) and tailcall (#148) - (by Jacques-Pascal Deplaix) - -## BugFixes -* Syntax: Better type constraint (#84) -* Compiler: caml_failwith primitive was sometime missing (#147) -* Compiler: variable names used outside a program were - not marked as reserved (#146) -* Lib: fix WebGl interface - -# 2.0 (2014-04-11) - -## Features/Changes -* Compiler: generate shorter variable names -* Parsing and minifying of external javascript file (ie: runtime) - (by Hugo Heuzard) -* Compiler: JavaScript strict mode enabled -* Runtime: add support for recursive module (by Hugo Heuzard) -* Compiler: use trampoline to implement tailcall optim (by Hugo Heuzard) -* Improved OCaml toplevel UI (by Hugo Heuzard) -* Toplevel: support dynamic loading of cmo and cma files -* Runtime: add Bigarray support (contributed by Andrew Ray) -* Library: switch from "float Js.t" to just "float" for typing - JavaScript numbers -* Compiler: Add javascript file lookup using findlib - (+mypkg/myfile.js will read myfile.js from mypkg findlib directory) - (by Hugo Heuzard) -* Compiler: improve missing primitives & reserved name detection - (by Hugo Heuzard) -* Compiler: static evaluation of constant ("staticeval" optimisation) - (by Hugo Heuzard) -* Compiler: share constants (by Hugo Heuzard) -* Compiler: alias primitives (by Hugo Heuzard) -* Compiler: complete javascript ast (by Hugo Heuzard) -* Compiler: 'caml_format_int %d x' compiles to ""+x (by Hugo Heuzard) -* Add JavaScript file in META (to be used with ocamlfind) - (by Hugo Heuzard) -* Add Ocamlbuild plugin js_of_ocaml.ocamlbuild - (by Jacques-Pascal Deplaix) -* Add/Install classlist.js, weak.js -* Add Url.Current.protocol (by Vicent Balat) -* Dependency: deriving instead of deriving-ocsigen -* Runtime: log wrong string encoding issues to the console (by Hugo Heuzard) -* Add compiler_libs (by Pierre Chambart) -* Compile syntax extension to native code as well (by Hugo Heuzard) -* Add a JavaScript parser (extracted from facebook/pfff) -* Compiler: remove redundant 'var' (by Hugo Heuzard) -* Compiler: improve compact mode, remove unnecessary space, semicolon -* Runtime: Support in_channel and out_channel (by Hugo Heuzard) -* Compiler: option to embed files into the generated js - such files can be read using open_in (by Hugo Heuzard) -* Runtime: add cache for method lookup (by Hugo Heuzard) -* Compiler: experimental sourcemap support (by Hugo Heuzard) -* JavaScript Errors are now wrapped inside OCaml exceptions (by Hugo Heuzard) - -## BugFixes -* Compiler: js file is not create in case of error (by Hugo Heuzard) -* Fix compatibility when using type covn (by Hugo Heuzard) -* Fix md5 : incorrect for string where (length % 64) E 56..59 (by Grégoire Henry) -* Fix caml_js_new: when called with more than 8 arguments -* Address a number of integer overflow issues (by Hugo Heuzard) -* Fix float comparisons (NaN was not compared correctly) - -# 1.4 (2013-12-03) - -## Features/Changes -* Add missing primitives for OCaml 4.01 -* Improved Dom bindings (Hugo Heuzard and many other contributors) -* Add -linkall option to keep all provided primitives (Pierre Chambard) -* Improved tail-call optimization (Hugo Heuzard) -* Added optimization levels: -o {1,2,3} (Hugo Heuzard) - -## Bugfixes -* Fixed some incorrect Dom bindings -* Fixed hypot primitive (Pierre Chambard) -* Fixed tail call optimization bug (some incorrect code was - generated when the number of arguments did not match the number of - function parameters) -* Fixed a bug with empty strings -* Fixed weak.js (primitives for Weak module) - -# 1.3 (2012-11-28) - -## Features/Changes -* Runtime and toplevel updates to support OCaml 4.0 -* Add WebSocket bindings -* Added -debuginfo option to output source code location information - (patch by Kensuke Matsuzaki) -* Dom_html: added change, input and hashChange event bindings -* Adding Lwt_js_events.async_loop and buffered_loop - -## Bugfixes -* Fix array and string blitting with overlapping regions -* Url module: fix encoding of '+' -* Library: use 'this' instead of 'window' for better portability -* Dom_html: fix creation of elements with type or name attribute - under IE 9 -* Compiler: small fix to bytecode parsing that could result in - incorrect generated code -* Dom_html: fix mouse wheel event bindings -* Dom: fix the type of item methods -* Deriving_json: tail-recursive serialisation of lists (by Hugo Heuzard) -* Deriving_json: fix parsing of float arrays and polymorphic variants - (by Hugo Heuzard) - -# 1.2 (2012-06-02) - -## Features/Changes -* Improvements in the data-flow solver -* Add Dom_html.window##onscroll -* Dom_events.listen: handler should return boolean -* Add DOM drag/drop events - -## Bugfixes -* Fix #284 -* Fix return type of window##open_ - -# 1.1.1 (2012-03-15) - -## Misc -* add webgl example - -## Bugfixes -* Url parsing. -* webgl binding types - -# 1.1 (2012-02-24) - -## Libraries: -* Lots of new dom bindings -* WebGL -* Typed arrays -* Many speed improvement (marshal, strings, regexps) -* Many bug fixed - -## Compiler: -* Add -I option to select directories containing cmi files -* Fix compilation of mutually recursive functions occurring in loops -* In Javascript output, parenthesize numbers when followed by a dot -* Fix order of evaluation bug -* Fix compilation of loops in 'try ... with' body (close #263) - -## Misc: -* hyperbolic tree example - -# 1.0.9 (2011-11-30) - -* Bugfixe in polymorphic comparison. - -# 1.0.8 (2011-11-25) - -* Compatibility with deriving-0.3 -* Libraries: - * Adding Event_arrows.iter - * Events: adding Dom_html.stopPropagation and ?propagate parameter in Event_arrows - -# 1.0.7 (2011-11-18) - -## Libraries: -* Add Dom_html.buttonPressed -* Add functions to downcast Dom_html.event into mouseEvent, keyboardEvent, ... -* Add Dom.document.adoptNode -* removed Date.now() function, not supported by all browsers -* Allow to test the button associated to a Dom_html.mouseEvent -* Add localStorage and sessionStorage api - -## Bugfixes -* Deriving_json: fix string (un)marshaling (was broken for byte > 127) -* Do not emit string escape sequence \\v (not supported by IE8) -* Removed incorrect optimization of !(x < y) into (x ># y) -* Allow compilation on win32/msvc -* Open all files in binary mode - -# 1.0.6 (2011-09-28) - -## Libraries: -* add Dom_html.iFrameEliom##width -* add Dom_html.window##scroll -* add Dom.document##importNode - -## Bugfixes -* browser compatility for Regexp.search and check_headers (XmlHttpRequest.send). - -# 1.0.5 (2011-09-21) - -## Libraries: -* XmlHttpRequest: allow to cancel ta XHR after receiving the HTTP headers -* Added the [CSS.Angle] module to handle angles in CSS -## Bugfixes -* array_get/set bound check - -# 1.0.4 (2011-09-07) - -## Libraries: -* History API -* improvements of CSS module -* Add coercion and attribute manipulation functions in Dom module - -## Bugfixes -* fix typo in 'greater than or equal to' -* marshaling, unmarshaling and comparison - are not recursive anymore: avoid stack overflow -* use custom formatter to pretty print Javascript - code to avoid newlines where it is forbidden. -* fix type of Dom.nodeList.item (was optdef, is now opt) -* fixes for internet explorer. -* fixes for bug exposed by Berke Durak's tool jsure. - -# 1.0.3 (2011-07-13) - -## Libraries -* Add a CSS module -* export Form.form_elements -* add onsubmit method to Dom_html.formElement -* add classList property to dom elements - -## Bugfixes -* 'caml_int_of_string' was incorrect for negative number -* Fixed misparenthesized Javascript 'new' expressions - -# 1.0.2 (2011-04-13) - -## Compiler -* Switch licence to LGPL -* API to generate a function instead of a standalone program -* option to compile an OCaml toplevel -## Libraries -* Add an optional JSON deriving class -* Add Math.random binding -* Add scrollWidth/scrollHeight element methods to the DOM -* Add coercion function Dom_html.CoerceTo.element -* Renaming functions in XmlHttpRequest: - * send -> perform - * send_string -> perform_raw_url -## Bugfixes -* fix compilation of Int32/Nativeint -* fix compilation of self-recursive functions in loops -* fix to File module for when there is no FileReader class in the host browser -* fixed big in weak support - -# 1.0.1 (2011-01-26) - -* Allow use of Lwt.pause. -* Split ocamlfind packages in two: syntax and library. -## Bugfixes -* conversion of Int64 to string. -* typos. - -# 1.0 (2010-12-13) - -Initial release +# Js_of_ocaml 4.0.0 (2021-01-24) - Lille +* Misc: move js_of_ocaml-ocamlbuild out to its own repo + See Js_of_ocaml CHANGES.md for older logs \ No newline at end of file diff --git a/js_of_ocaml-ocamlbuild.opam b/js_of_ocaml-ocamlbuild.opam index 6e7c2e38..c5f23481 100644 --- a/js_of_ocaml-ocamlbuild.opam +++ b/js_of_ocaml-ocamlbuild.opam @@ -5,10 +5,8 @@ description: "An ocamlbuild plugin to compile to JavaScript using js_of_ocaml" maintainer: ["Ocsigen team "] authors: ["Ocsigen team "] -license: - "GPL-2.0-or-later AND LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception" +license: ["LGPL-2.1-or-later"] homepage: "https://github.com/ocsigen/js_of_ocaml-ocamlbuild" -doc: "https://github.com/ocsigen/js_of_ocaml-ocamlbuild" bug-reports: "https://github.com/ocsigen/js_of_ocaml-ocamlbuild/issues" depends: [ "dune" {>= "2.9"} diff --git a/ocamlbuild_js_of_ocaml.ml b/ocamlbuild_js_of_ocaml.ml index e31fd03f..37545fbf 100644 --- a/ocamlbuild_js_of_ocaml.ml +++ b/ocamlbuild_js_of_ocaml.ml @@ -25,10 +25,12 @@ let fold f = let l = ref [] in (try while true do - l @:= [ f () ] + match f () with + | None -> () + | Some x -> l := x :: !l done with _ -> ()); - !l + List.rev !l let split_comma = Str.split_delim (Str.regexp " *[, ] *") @@ -43,7 +45,7 @@ let ocamlfind cmd f = let cmd = p "ocamlfind query %s" (String.concat " " cmd) in Pack.My_unix.run_and_open cmd (fun ic -> fold (fun () -> f ic)) -let link_opts prod = +let packages_and_predicates prod = let all_pkgs, predicates = let tags = Tags.elements (tags_of_pathname prod) in let pkgs = fold_pflag (fun x -> Scanf.sscanf x "package(%[^)])") tags in @@ -53,32 +55,42 @@ let link_opts prod = (* Findlib usually set pkg_* predicate for all selected packages *) (* It doesn't do it with 'query' command, we have to it manually. *) let cmd = "-format" :: "pkg_%p" :: "-r" :: all_pkgs in - let predicates_pkgs = ocamlfind cmd (fun ic -> input_line ic) in - let all_predicates = - String.concat "," (("javascript" :: predicates) @ predicates_pkgs) - in + let predicates_pkgs = ocamlfind cmd (fun ic -> Some (input_line ic)) in + all_pkgs, predicates @ predicates_pkgs + +let old_linkopts prod = + let all_pkgs, all_predicates = packages_and_predicates prod in + let predicates = String.concat "," ("javascript" :: all_predicates) in (* query findlib for linking option *) - let cmd = "-o-format" :: "-r" :: "-predicates" :: all_predicates :: all_pkgs in - ocamlfind cmd (fun ic -> A (input_line ic)) + let cmd = "-o-format" :: "-r" :: "-predicates" :: predicates :: all_pkgs in + ocamlfind cmd (fun ic -> + let s = String.trim (input_line ic) in + if String.length s = 0 then None else Some s) + +let runtime_files prod = + let all_pkgs, all_predicates = packages_and_predicates prod in + let predicates = String.concat "," all_predicates in + (* query findlib for jsoo runtime files *) + let cmd = + "-format" :: "%+(jsoo_runtime)" :: "-r" :: "-predicates" :: predicates :: all_pkgs + in + ocamlfind cmd (fun ic -> + let s = String.trim (input_line ic) in + if String.length s = 0 then None else Some s) -let init () = +let init mode = let dep = "%.byte" in let prod = "%.js" in let f env _ = let dep = env dep in let prod = env prod in - let link_opts = link_opts prod in + let link_opts = + match mode with + | `Default -> List.map (fun x -> P x) (runtime_files prod) + | `Legacy -> List.map (fun x -> A x) (old_linkopts prod) + in let tags = tags_of_pathname prod ++ "js_of_ocaml" in - Cmd - (S - [ A "js_of_ocaml" - ; A "--no-runtime" - ; T tags - ; S link_opts - ; A "-o" - ; Px prod - ; P dep - ]) + Cmd (S [ A "js_of_ocaml"; T tags; S link_opts; A "-o"; Px prod; P dep ]) in rule "js_of_ocaml: .byte -> .js" ~dep ~prod f; flag [ "js_of_ocaml"; "debug" ] (S [ A "--pretty"; A "--debug-info"; A "--source-map" ]); @@ -93,7 +105,7 @@ let oasis_support ~executables = let aux x = if List.mem x executables then Pathname.update_extension "js" x else x in Options.targets := List.map aux !Options.targets -let dispatcher ?(oasis_executables = []) = function - | After_rules -> init () +let dispatcher ?(mode = `Default) ?(oasis_executables = []) = function + | After_rules -> init mode | After_options -> oasis_support ~executables:oasis_executables | _ -> () diff --git a/ocamlbuild_js_of_ocaml.mli b/ocamlbuild_js_of_ocaml.mli index 300beae4..93de8c06 100644 --- a/ocamlbuild_js_of_ocaml.mli +++ b/ocamlbuild_js_of_ocaml.mli @@ -50,7 +50,7 @@ Build a JavaScript program {b myprog.js} by calling the command: {[ - ocamlbuild -use-ocamlfind -plugin-tag "package(js_of_ocaml.ocamlbuild)" myprog.js + ocamlbuild -use-ocamlfind -plugin-tag "package(js_of_ocaml-ocamlbuild)" myprog.js ]} It will first build the bytecode {b myprog.byte} and finally produce {b myprog.js} (in {b _build}). @@ -81,16 +81,21 @@ {2 Dispatchers} *) val dispatcher : - ?oasis_executables:Ocamlbuild_plugin.Pathname.t list -> Ocamlbuild_plugin.hook -> unit + ?mode:[ `Default | `Legacy ] + -> ?oasis_executables:Ocamlbuild_plugin.Pathname.t list + -> Ocamlbuild_plugin.hook + -> unit (** The main dispatcher - [?oasis_executables] is the paths of the executables - (having the .byte extension) you want to compile - as a javascript executable. The former executables are still compiled. + [?mode:`Legacy] can be used to fallback to the old way of querying + findlib for javascript runtime files. - Side note: {!Ocamlbuild_plugin.dispatch} should be used only once as - it record only one function for an ocamlbuild module. -*) + [?oasis_executables] is the paths of the executables (having the + .byte extension) you want to compile as a javascript + executable. The former executables are still compiled. + + Side note: {!Ocamlbuild_plugin.dispatch} should be used only once + as it record only one function for an ocamlbuild module. *) (** {2 Low level functions} *) diff --git a/test/_tags b/test/_tags new file mode 100644 index 00000000..27621c65 --- /dev/null +++ b/test/_tags @@ -0,0 +1 @@ +true: package(base) diff --git a/test/dune b/test/dune new file mode 100644 index 00000000..610dbf86 --- /dev/null +++ b/test/dune @@ -0,0 +1,14 @@ +(rule + (alias runtest) + (deps + (source_tree .) + (package js_of_ocaml-ocamlbuild)) + (action + (progn + (run + ocamlbuild + -use-ocamlfind + -plugin-tag + "package(js_of_ocaml-ocamlbuild)" + test.js) + (run node _build/test.js)))) diff --git a/test/myocamlbuild.ml b/test/myocamlbuild.ml new file mode 100644 index 00000000..2dc3ad32 --- /dev/null +++ b/test/myocamlbuild.ml @@ -0,0 +1 @@ +let _ = Ocamlbuild_plugin.dispatch Ocamlbuild_js_of_ocaml.dispatcher diff --git a/test/test.ml b/test/test.ml new file mode 100644 index 00000000..49ea5b85 --- /dev/null +++ b/test/test.ml @@ -0,0 +1 @@ +let () = assert (not Base.Exported_for_specific_uses.am_testing)