Permalink
Browse files

merge tsc runtime

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
1 parent f6be36f commit 9ff9ccca1aa5b3a28d3f42dbb18a733597de2f07 @ibdknox ibdknox committed Oct 1, 2016
Showing with 33,268 additions and 11 deletions.
  1. +14 −11 .gitignore
  2. +1 −0 Procfile
  3. +80 −0 examples/chat.eve
  4. +22 −0 examples/clock.eve
  5. +179 −0 examples/flappy.eve
  6. +46 −0 examples/fruity.eve
  7. +31 −0 examples/http.eve
  8. +9 −0 examples/memory.eve
  9. +24 −0 examples/server.eve
  10. +302 −0 examples/todomvc.css
  11. +177 −0 examples/todomvc.eve
  12. +136 −0 index.html
  13. +25 −0 package.json
  14. +995 −0 src/chevrotain.d.ts
  15. +411 −0 src/client.ts
  16. +347 −0 src/codemirror.css
  17. +14,407 −0 src/codemirror.js
  18. +3,339 −0 src/commonmark.js
  19. +134 −0 src/db.ts
  20. +3 −0 src/declarations.d.ts
  21. +1,352 −0 src/editor.ts
  22. +2,617 −0 src/join.ts
  23. +573 −0 src/microReact.js
  24. +546 −0 src/renderer.ts
  25. +150 −0 src/runtime/actions.ts
  26. +274 −0 src/runtime/block.ts
  27. +51 −0 src/runtime/browser.ts
  28. +663 −0 src/runtime/builder.ts
  29. +282 −0 src/runtime/changes.ts
  30. +28 −0 src/runtime/databases/browserSession.ts
  31. +79 −0 src/runtime/databases/http.ts
  32. +77 −0 src/runtime/databases/node/http.ts
  33. +109 −0 src/runtime/databases/node/server.ts
  34. +15 −0 src/runtime/databases/persisted.ts
  35. +159 −0 src/runtime/databases/system.ts
  36. +229 −0 src/runtime/indexes.ts
  37. +823 −0 src/runtime/join.ts
  38. +1,152 −0 src/runtime/parser.ts
  39. +171 −0 src/runtime/performance.ts
  40. +159 −0 src/runtime/providers/aggregate.ts
  41. +10 −0 src/runtime/providers/index.ts
  42. +184 −0 src/runtime/providers/logical.ts
  43. +252 −0 src/runtime/providers/math.ts
  44. +103 −0 src/runtime/providers/string.ts
  45. +200 −0 src/runtime/runtime.ts
  46. +121 −0 src/runtime/server.ts
  47. +82 −0 src/runtime/util/eavs.ts
  48. +6 −0 src/system.js
  49. +54 −0 src/util.ts
  50. +245 −0 src/uuid.js
  51. +2 −0 test/all.ts
  52. +50 −0 test/eavs.ts
  53. +1,756 −0 test/join.ts
  54. +12 −0 tsconfig.json
View
@@ -42,14 +42,17 @@ luac.out
lua_modules/
*~
-build/continuation_templates.h
-build/eve
-build/path.c
-build/Eve.xcodeproj/xcuserdata
-build/Eve.xcodeproj/*/xcuserdata
-build/lua
-build/luajit-2.0
-build/*.js
-
-build/*.js
-build/*.js.map
+build/
+node_modules/
+
+experimental/build/continuation_templates.h
+experimental/build/eve
+experimental/build/path.c
+experimental/build/Eve.xcodeproj/xcuserdata
+experimental/build/Eve.xcodeproj/*/xcuserdata
+experimental/build/lua
+experimental/build/luajit-2.0
+experimental/build/*.js
+
+experimental/build/*.js
+experimental/build/*.js.map
View
@@ -0,0 +1 @@
+web: ./node_modules/.bin/tsc && cp src/*.js build/src/ && cp ./node_modules/chevrotain/lib/chevrotain.js build/src/ && node build/src/runtime/server.js
View
@@ -0,0 +1,80 @@
+# Chat
+
+add a user for this sesion on connect
+
+```
+ commit
+ [#user @me]
+```
+
+build the chat pane
+
+```
+ match
+ channel = "general"
+ bind
+ [#div class: "chat-pane" children:
+ [#div #chat-messages class: "chat-messages" channel]
+ [#input #channel-input autofocus: true channel]]
+```
+
+draw messages
+
+```
+ match (@session, @shared)
+ parent = [#chat-messages channel]
+ id = [#message name time message channel]
+ bind
+ parent.children += [#div id, class: "chat-message", children:
+ [#div class: "chat-user", text: name]
+ [#div class: "chat-time", text: time]
+ [#div class: "chat-message", text: message]]
+```
+
+handle chat keydowns
+
+```
+ match
+ event = [#keydown element, key: "enter"]
+ element = [#channel-input channel value]
+ [#user name]
+ [#time hours minutes seconds]
+ commit
+ element.value := ""
+ commit @shared
+ [#message event name, time: "{{hours}}:{{minutes}}", message: value, channel]
+```
+
+
+remove events
+~~~
+ match
+ c = if event = [#keydown] then event
+ if event = [#keyup] then event
+ if event = [#click] then event
+ if event = [#double-click] then event
+ if event = [#change] then event
+ if event = [#blur] then event
+ if event = [#focus] then event
+ commit
+ c := none
+~~~
+
+hash changes
+~~~
+ match
+ change = [#url-change hash-segment]
+ commit
+ change := none
+ url = [#url]
+ url.hash-segment := hash-segment
+~~~
+
+update values
+~~~
+ match
+ [#change element value]
+ commit
+ element.value := value
+~~~
+
View
@@ -0,0 +1,22 @@
+# Clock
+draw a clock hand
+```
+ match
+ hand = [#clock-hand angle length]
+ x2 = 50 + (length * sin[angle])
+ y2 = 50 - (length * cos[angle])
+ bind
+ hand <- [#line, x1: 50, y1: 50, x2, y2]
+```
+
+draw a clock
+```
+ match
+ [#time hours minutes seconds]
+ bind
+ [#svg viewBox: "0 0 100 100", width: "300px", children:
+ [#circle cx: 50, cy: 50, r: 45, fill: "#0B79CE"]
+ [#clock-hand @hour-hand angle: 30 * hours, length: 30, stroke: "#023963"]
+ [#clock-hand @minute-hand angle: 6 * minutes, length: 40, stroke: "#023963"]
+ [#clock-hand @second-hand angle: 6 * seconds, length: 40, stroke: "#ce0b46"]]
+```
View
@@ -0,0 +1,179 @@
+
+remove clicks
+```
+ match
+ c = [#click]
+ commit
+ c := none
+```
+
+# Flappy bird in Eve
+
+Add a flappy eve and a world for it to flap in
+```
+ commit
+ [#player #self name: "eve" x: 25 y: 50 velocity: 0]
+ [@world screen: "menu" frame: 0 distance: 0 best: 0 gravity: -0.061]
+ [#obstacle gap: 35 offset: 0]
+ [#obstacle gap: 35 offset: -1]
+```
+
+Draw the game world!
+```
+ commit
+ [#div style: [user-select: "none" -webkit-user-select: "none" -moz-user-select: "none"] children:
+ [#svg @game-window viewBox: "10 0 80 100", width: 480 children:
+ [#rect x: 0 y: 0 width: 100 height: 53 fill: "rgb(112, 197, 206)" sort: 0]
+ [#image x: 0 y: 52 width: 100 height: 43 preserveAspectRatio: "xMinYMin slice" href: "https://cdn.rawgit.com/bhauman/flappy-bird-demo/master/resources/public/imgs/background.png" sort: 1]
+ [#rect x: 0 y: 95 width: 100 height: 5 fill: "rgb(222, 216, 149)" sort: 0]]]
+```
+
+
+## Screens
+This handles the game's miscellaneous screens. It's currently pretty simple, but you could expand it to include changes to other purpose-specific screens.
+
+Draw the main menu
+```
+ match
+ [@world screen: "menu"]
+ svg = [@game-window]
+ bind
+ svg.children += [#text x: 50 y: 45 text-anchor: "middle" font-size: 6 text: "Click the screen to begin!" sort: 10]
+```
+
+Keep score
+```
+ match
+ world = [@world distance]
+ bind
+ world.score := floor[value: distance]
+```
+
+Draw the game over final score
+```
+ match
+ [@world screen: "game over" score best]
+ svg = [@game-window]
+ bind
+ svg.children += [#text x: 50 y: 30 text-anchor: "middle" font-size: 6 text: "Game Over :(" sort: 10]
+ svg.children += [#text x: 50 y: 55 text-anchor: "middle" font-size: 6 text: "Score {{score}}" sort: 10]
+ svg.children += [#text x: 50 y: 65 text-anchor: "middle" font-size: 6 text: "Best {{best}}" sort: 10]
+ svg.children += [#text x: 50 y: 85 text-anchor: "middle" font-size: 4 text: "Click to play again!" sort: 10]
+```
+
+Start the game
+```
+ match
+ [#click #direct-target]
+ // world = [@world screen: "menu"]
+ world = if w = [@world screen: "menu"] then w
+ else [@world screen: "game over"]
+ neue = if world = [@world score best] score > best then score
+ else if world = [@world best] then best
+ player = [#player]
+ commit
+ [#div text: "let's do this!"]
+ world <- [screen: "game" distance: 0 best: neue]
+ player <- [x: 25 y: 50 velocity: 0]
+```
+
+
+## Run the actual game
+Every 2 distance a wild obstacle appears
+```
+ match
+ [@world distance]
+ obstacle = [#obstacle offset]
+ obstacle-distance = distance + offset
+ obstacle-distance >= 0
+ bind
+ obstacle <- [x: 100 - (50 * mod[value: obstacle-distance, by: 2])]
+```
+
+Readjust the height of the gap every time the obstacle resets
+```
+ match
+ [@world screen: "game" frame]
+ obstacle = [#obstacle x > 90]
+ height = random[seed: "{{obstacle}}{{frame}}"] * 30 + 5
+ commit
+ obstacle.height := height
+```
+
+Draw the player
+```
+ match
+ svg = [@game-window]
+ player = [#player x y]
+ imgs = "https://cdn.rawgit.com/bhauman/flappy-bird-demo/master/resources/public/imgs"
+ bind
+ sprite = [#image player width: 10 height: 10 href: "http://i.imgur.com/sp68LtM.gif" sort: 8]
+ sprite.x := x - 5
+ sprite.y := y - 5
+ svg.children += sprite
+```
+
+Draw the obstacles
+```
+ match
+ svg = [@game-window]
+ obstacle = [#obstacle x height gap]
+ bottom-height = height + gap
+ imgs = "https://cdn.rawgit.com/bhauman/flappy-bird-demo/master/resources/public/imgs"
+
+ bind
+ sprite-group = [#svg @obs-spr obstacle sort: 2 overflow: "visible" children:
+ [#image y: 0 width: 10 height, preserveAspectRatio: "none" href: "{{imgs}}/pillar-bkg.png" sort: 1]
+ [#image x: -1 y: height - 5 width: 12 height: 5 href: "{{imgs}}/lower-pillar-head.png" sort: 2]
+ [#image y: bottom-height width: 10 height: 90 - bottom-height, preserveAspectRatio: "none" href: "{{imgs}}/pillar-bkg.png" sort: 1]
+ [#image x: -1 y: bottom-height width: 12 height: 5 href: "{{imgs}}/lower-pillar-head.png" sort: 2]]
+ [#div text: "spg {{sprite-group}} {{x}}"]
+ sprite-group.x := x
+ svg.children += sprite-group
+```
+
+Flap the player
+```
+ match
+ [#click #direct-target]
+ [@world screen: "game"]
+ player = [#player #self]
+ commit
+ player.velocity := 1.17 // In rare cases this can create a duplicate velocity. If this happens, things will get bad fast.
+```
+
+As time moves gently forward, winter turns to spring
+```
+ match
+ [#time frames]
+ world = [@world screen: "game" frame != frames gravity]
+ player = [#player y velocity]
+ not([#click])
+ commit
+ world.frame := frames
+ world.distance := world.distance + 1 / 60
+ player <- [y: y - velocity, velocity: velocity + gravity]
+```
+
+Lose the game if the player hits the ground
+```
+ match
+ world = [@world screen: "game"]
+ [#player y > 85] // ground height + player radius
+ commit
+ world.screen := "game over"
+```
+
+Lose the game if the player hits an obstacle
+```
+ match
+ world = [@world screen: "game"]
+ [#player x y]
+ [#obstacle x: obstacle-x height gap]
+ ∂x = abs[value: obstacle-x + 5 - x] - 10 // distance between the edges of player and obstacle (offset of 1/2 obstacle width because origin is on the left)
+ ∂x < 0
+ collision = if y - 5 <= height then true
+ else if y + 5 >= gap + height then true
+ commit
+ world.screen := "game over"
+```
View
@@ -0,0 +1,46 @@
+Add some fruits to the system
+```
+ commit
+ [#fruit @lemon color: "yellow"]
+ [#fruit @cherry color: "red"]
+ [#fruit @orange color: "orange"]
+ [#fruit @apple color: "green"]
+ [#fruit @banana color: "yellow"]
+ [#fruit #exotic @lychee color: "white"]
+ [#fruit @papaya color: "yellow"]
+ [#fruit @kiwi color: "green"]
+```
+
+Draw a list of fruits
+```
+ match
+ [#fruit color name]
+ bind
+ [#div ix: name, text: name, style: [color]]
+```
+
+make yo
+```
+ match
+ v = [#click element]
+ element = [not(children) text]
+ commit
+ element.children += [#div element zig:v text:"yo"]
+```
+
+trash yo
+```
+ match
+ [#click element]
+ element = [children]
+ commit
+ element.children -= children
+```
+
+remove clicks
+```
+ match
+ c = [#click]
+ commit
+ c := none
+```
View
@@ -0,0 +1,31 @@
+cool stuff
+
+```
+ bind
+ [#button text: "send a request to google"]
+```
+
+```
+ match
+ [#click]
+ commit @http
+ [#request @google url: "https://jsonplaceholder.typicode.com/posts/"]
+```
+
+```
+ match @http
+ [#request @google response: [json]]
+ json = [#array]
+ lookup[record: json, attribute, value: [title body]]
+ bind
+ [#div text: "{{title}}"]
+ [#div text: "{{body}}"]
+```
+
+```
+ match @http
+ r = [#request not(response)]
+ total = count[given: r]
+ bind
+ [#div text: "Requests in flight: {{total}}"]
+```
Oops, something went wrong.

0 comments on commit 9ff9ccc

Please sign in to comment.