Sha256: 76d813f60da5156fdf684f8994e7ae72e8879f04caff4076cba50c0fe3171183

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

(scoped
  (defvar sibilant {})
  (defun error (str) (throw str))
  (defun inspect (item) (if item.to-source (item.to-source) (item.to-string)))
  (set window 'sibilant sibilant)

  (defvar exports {})
  (include "../include/functional")
  (include "../src/core")

  ($ (thunk
       (defvar sibilant window.sibilant
               scripts [])

       (defun eval-with-try-catch (js)
         (try (eval js) (progn (console.log js) (throw e))))

       (defun sibilant.script-loaded ()
         (defvar
          lisp null
          js   null)
         (when (not (sibilant.load-next-script))
           (chain ($ "script[type=\"text/sibilant\"]:not([src])")
             (each (thunk
                     (setf lisp (chain ($ this)
                                  (text)
                                  (replace /(^\s*\/\/\<!\[CDATA\[)|(\/\/\]\]>\s*$)/g ""
                                           ))
                           js (sibilant.translate-all lisp))

                     (chain ($ this) (data 'js js))
                     (eval-with-try-catch js))))))

       (setf scripts ($.make-array (chain
                                       ($ "script[type=\"text/sibilant\"][src]") (map (thunk this.src)))))

       (defun sibilant.load-next-script ()
         (defvar next-script (scripts.shift))
         (when (defined? next-script)
           ($.get next-script (lambda (data)
                                (eval-with-try-catch  (sibilant.translate-all data))
                                (sibilant.script-loaded)))
           true))

       (sibilant.load-next-script))))

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sibilant-0.0.4 js/sibilant/src/browser.sibilant
sibilant-0.0.3 js/sibilant/src/browser.sibilant
sibilant-0.0.2 js/sibilant/src/browser.sibilant