diff --git a/_oasis b/_oasis index ff0e394..250300e 100644 --- a/_oasis +++ b/_oasis @@ -1,6 +1,6 @@ OASISFormat: 0.4 Name: nodejs -Version: 0.0.1 +Version: 0.1 Synopsis: OCaml bindings for nodejs Authors: Edgar Aroutiounian Maintainers: Edgar Aroutiounian @@ -10,9 +10,11 @@ Plugins: META (0.4), DevFiles (0.4) BuildTools: ocamlbuild Description: - These are OCaml bindings to Nodejs + Write OCaml, run on node - Get all the power of the Nodejs ecosystem with the type safety of OCaml + These are js_of_ocaml bindings to the node JavaScript API. + Get all the power of the node ecosystem with the type safety + of OCaml. Library nodejs Path: src @@ -20,6 +22,6 @@ Library nodejs # Every time you add a new module be sure to add it here to # InternalModules field InternalModules: - Http, Url, Nodejs_globals, Net, Events, Fs, Process + Http, Url, Net, Events, Fs, Process CompiledObject: byte BuildDepends: js_of_ocaml, js_of_ocaml.ppx diff --git a/examples/Makefile b/examples/Makefile index a875bf3..be4b77d 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -8,7 +8,7 @@ define colorecho endef run:all clean - # @npm install socket.io express + @npm install socket.io express node chat_server.js all: @@ -18,8 +18,9 @@ all: # clean: # @rm -f chat_server2.cmi chat_server2.cmo \ # chat_server2.cmt a.out + clean: @rm -f chat_server.cmi chat_server.cmo \ -# chat_server.cmt a.out + chat_server.cmt a.out .PHONY:clean diff --git a/opam/descr b/opam/descr index 357762e..9bc42ce 100644 --- a/opam/descr +++ b/opam/descr @@ -1,4 +1,5 @@ -OCaml bindings for nodejs +Write OCaml, run on node -These are OCaml bindings to Nodejs Get all the power of the Nodejs -ecosystem with the type safety of OCaml. +These are js_of_ocaml bindings to the node JavaScript API. +Get all the power of the node ecosystem with the type safety +of OCaml. \ No newline at end of file diff --git a/opam/opam b/opam/opam index 7b8feaa..6fb2749 100644 --- a/opam/opam +++ b/opam/opam @@ -1,11 +1,12 @@ opam-version: "1.2" name: "nodejs" -version: "0.0.1" +version: "0.1" maintainer: "Edgar Aroutiounian " authors: [ "Edgar Aroutiounian " ] license: "BSD-3-clause" homepage: "https://github.com/fxfactorial/ocaml-nodejs" bug-reports: "https://github.com/fxfactorial/ocaml-nodejs/issues" +dev-repo: "https://github.com/fxfactorial/ocaml-nodejs.git" build: [ ["oasis" "setup"] ["ocaml" "setup.ml" "-configure" "--prefix" prefix] diff --git a/src/events.ml b/src/events.ml index 2598951..3380538 100644 --- a/src/events.ml +++ b/src/events.ml @@ -19,4 +19,4 @@ class type events = object end let require () : events Js.t = - Nodejs_globals.require (Js.string "events") + Nodejs_globals.require "events" diff --git a/src/fs.ml b/src/fs.ml index 549beef..87c2aba 100644 --- a/src/fs.ml +++ b/src/fs.ml @@ -6,4 +6,4 @@ class type fs = object end let require () : fs Js.t = - Nodejs_globals.require (Js.string "fs") + Nodejs_globals.require "fs" diff --git a/src/http.ml b/src/http.ml index 95d7f41..1302d50 100644 --- a/src/http.ml +++ b/src/http.ml @@ -107,4 +107,4 @@ class type http = object end let require () : http Js.t = - Nodejs_globals.require (Js.string "http") + Nodejs_globals.require "http" diff --git a/src/net.ml b/src/net.ml index a138ee8..2a41c9c 100644 --- a/src/net.ml +++ b/src/net.ml @@ -5,4 +5,4 @@ class type net = object end let require () : net Js.t = - Nodejs_globals.require (Js.string "net") + Nodejs_globals.require "net" diff --git a/src/nodejs_globals.ml b/src/nodejs_globals.ml index f3cc051..2169406 100644 --- a/src/nodejs_globals.ml +++ b/src/nodejs_globals.ml @@ -1,8 +1,14 @@ -let require (s : Js.js_string Js.t) = - Js.Unsafe.fun_call (Js.Unsafe.js_expr "require") [|Js.Unsafe.inject s|] +let require s = + Js.Unsafe.fun_call + (Js.Unsafe.js_expr "require") + [|Js.Unsafe.inject (Js.string s)|] let console : Js.Unsafe.any Js.t = Js.Unsafe.global##.console -let __filename () : Js.js_string Js.t = Js.Unsafe.global##.__filename +let __filename () = + (Js.Unsafe.eval_string "__filename" : Js.js_string Js.t) + |> Js.to_string -let __dirname () : Js.js_string Js.t = Js.Unsafe.global##.__dirname +let __dirname () = + (Js.Unsafe.eval_string "__dirname" : Js.js_string Js.t) + |> Js.to_string diff --git a/src/process.ml b/src/process.ml index c507e46..4e87726 100644 --- a/src/process.ml +++ b/src/process.ml @@ -1,5 +1,9 @@ class type process = object + method version : Js.js_string Js.t Js.readonly_prop + + method platform : Js.js_string Js.t Js.readonly_prop + end let process : process Js.t = Js.Unsafe.global##.process diff --git a/src/url.ml b/src/url.ml index b195959..32ad7b5 100644 --- a/src/url.ml +++ b/src/url.ml @@ -3,4 +3,4 @@ class type url = object end let require () : url Js.t = - Nodejs_globals.require (Js.string "url") + Nodejs_globals.require "url"