aboutsummaryrefslogtreecommitdiffstats
path: root/lib/init.client.moon
blob: c1aea073bec42366e8416e95ac915ff745e9d441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
export MODE, print, warn, relative, append, on_client
export window, document

window = js.global
{ :document, :console } = window

MODE = 'CLIENT'
print = console\log
warn = console\warn

package.path = '/?.shared.moon.lua;/?.client.moon.lua;/?.moon.lua;/?/init.moon.lua;/?.lua;/?/init.lua'

-- relative imports
relative = do
  _require = require

  (base, sub) ->
    sub = 0 unless 'number' == type sub

    for i=1, sub
      base = base\match '^(.*)%.%w+$'

    (name, x) ->
      name = base .. name if '.' == name\sub 1, 1
      _require name

append = document.body\appendChild
on_client = (f, ...) -> f ...