(module namespace mzscheme
(require (lib "mred.ss" "mred")
(lib "etc.ss")
"runtime.ss"
"standard-library.ss")
(define (require-spec module-name . path)
`(file ,(path->string (apply build-path (this-expression-source-directory) 'up (append path (list module-name))))))
(define runtime (require-spec "runtime.ss" "runtime"))
(define standard-library (require-spec "standard-library.ss" "runtime"))
(define debug (require-spec "debug.ss"))
(define (make-javascript-namespace)
(let ([ns (make-namespace-with-mred)])
(parameterize ([current-namespace ns])
(dynamic-require runtime #f)
(dynamic-require standard-library #f)
(dynamic-require debug #f)
(let ([path1 ((current-module-name-resolver) runtime #f #f)]
[path2 ((current-module-name-resolver) standard-library #f #f)]
[path3 ((current-module-name-resolver) debug #f #f)])
(namespace-attach-module ns path1)
(namespace-attach-module ns path2)
(namespace-attach-module ns path3)))
(reset-javascript-namespace! ns)
ns))
(define (reset-javascript-namespace! ns)
(parameterize ([current-namespace ns])
(let ([global-object (dynamic-require runtime 'global-object)]
[install-standard-library! (dynamic-require standard-library 'install-standard-library!)])
(install-standard-library! global-object)))
(void))
(provide make-javascript-namespace reset-javascript-namespace!))