{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/frontend/pulls/comments/122200313","pull_request_review_id":44294344,"id":122200313,"diff_hunk":"@@ -0,0 +1,25 @@\n+package uiComponent.core\n+\n+import java.io.Reader\n+import javax.script._\n+\n+import jdk.nashorn.api.scripting.JSObject\n+\n+import scala.util.Try\n+\n+class JavascriptEngine() {\n+  import JavascriptEngine._\n+\n+  private lazy val bindings = shared.createBindings()","path":"common/app/uiComponent/core/JavascriptEngine.scala","position":null,"original_position":13,"commit_id":"a85995495769301aeb20ddfb4863998b5a7a2d6a","original_commit_id":"81c8e0ed153040231edfce34559c3c19311040a9","user":{"login":"TBonnin","id":233326,"avatar_url":"https://avatars1.githubusercontent.com/u/233326?v=3","gravatar_id":"","url":"https://api.github.com/users/TBonnin","html_url":"https://github.com/TBonnin","followers_url":"https://api.github.com/users/TBonnin/followers","following_url":"https://api.github.com/users/TBonnin/following{/other_user}","gists_url":"https://api.github.com/users/TBonnin/gists{/gist_id}","starred_url":"https://api.github.com/users/TBonnin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBonnin/subscriptions","organizations_url":"https://api.github.com/users/TBonnin/orgs","repos_url":"https://api.github.com/users/TBonnin/repos","events_url":"https://api.github.com/users/TBonnin/events{/privacy}","received_events_url":"https://api.github.com/users/TBonnin/received_events","type":"User","site_admin":false},"body":"I had read it. That's why I made `JavascriptEngine` a class with its own bindings, to avoid mixing scripts evaluation.\r\n\r\nI made it a bit simpler now by making `JavascriptEngine` a pure object where functions take a `SimpleScriptContext` as a implicit param. https://github.com/guardian/frontend/pull/17141/files#diff-6a1a33938043036ec3d005e3fc9107afR11\r\nEach `JavascriptRenderer` will create its own `SimpleScriptContext`","created_at":"2017-06-15T13:20:08Z","updated_at":"2017-06-15T13:20:08Z","html_url":"https://github.com/guardian/frontend/pull/17141#discussion_r122200313","pull_request_url":"https://api.github.com/repos/guardian/frontend/pulls/17141","_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments/122200313"},"html":{"href":"https://github.com/guardian/frontend/pull/17141#discussion_r122200313"},"pull_request":{"href":"https://api.github.com/repos/guardian/frontend/pulls/17141"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/frontend/pulls/17141","id":125622513,"html_url":"https://github.com/guardian/frontend/pull/17141","diff_url":"https://github.com/guardian/frontend/pull/17141.diff","patch_url":"https://github.com/guardian/frontend/pull/17141.patch","issue_url":"https://api.github.com/repos/guardian/frontend/issues/17141","number":17141,"state":"open","locked":false,"title":"[Do Not Merge] POC: Javascript rending inside the JVM 🙀 ","user":{"login":"TBonnin","id":233326,"avatar_url":"https://avatars1.githubusercontent.com/u/233326?v=3","gravatar_id":"","url":"https://api.github.com/users/TBonnin","html_url":"https://github.com/TBonnin","followers_url":"https://api.github.com/users/TBonnin/followers","following_url":"https://api.github.com/users/TBonnin/following{/other_user}","gists_url":"https://api.github.com/users/TBonnin/gists{/gist_id}","starred_url":"https://api.github.com/users/TBonnin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBonnin/subscriptions","organizations_url":"https://api.github.com/users/TBonnin/orgs","repos_url":"https://api.github.com/users/TBonnin/repos","events_url":"https://api.github.com/users/TBonnin/events{/privacy}","received_events_url":"https://api.github.com/users/TBonnin/received_events","type":"User","site_admin":false},"body":"Prototype to show that running javascript in the JVM is possible 😊 :\r\nThis is rendering a very simple javascript \"component\".\r\n\r\nIt should be quite simple to use:\r\n1. Declare a case class extending `UIComponentState` to hold the state of your root component. Must have a method to serialize it into `json`\r\n```\r\ncase class MyState(field1: String, field2: ...) extends UIComponentState {\r\n    def asJson: JsValue = ...\r\n}\r\n```\r\n2. Declare your root component by extending `UIComponent`, specifying the javascript entry point and the type of state it supports\r\n```\r\nobject MyComponent extends UIComponent[MyState](\"js/myComponent.js\")\r\n```\r\n3. Construct your state and call `render` on your component (passing the state you want to render)\r\n```\r\nval state = Some(MyState(\"title\", somethingElse, ...))\r\nButtonComponent.render(state)\r\n```\r\n\r\nIt is faster than I thought it would be :smile:: the speed of rendering the very simple component in js is similar to using twirl\r\nHowever I would like to push the test further and run more complete javascript app to see how it behaves under load. @SiAdcock @sndrs I need your help here\r\n","created_at":"2017-06-14T15:17:00Z","updated_at":"2017-06-15T13:20:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c26a04c2238c039f540e787174b9dc368f10da5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/guardian/frontend/pulls/17141/commits","review_comments_url":"https://api.github.com/repos/guardian/frontend/pulls/17141/comments","review_comment_url":"https://api.github.com/repos/guardian/frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/frontend/issues/17141/comments","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/a85995495769301aeb20ddfb4863998b5a7a2d6a","head":{"label":"guardian:tbonnin/js-jvm","ref":"tbonnin/js-jvm","sha":"a85995495769301aeb20ddfb4863998b5a7a2d6a","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/frontend/deployments","created_at":"2012-05-18T15:39:15Z","updated_at":"2017-06-15T10:08:05Z","pushed_at":"2017-06-15T13:17:33Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"https://www.theguardian.com","size":523069,"stargazers_count":3575,"watchers_count":3575,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":384,"mirror_url":null,"open_issues_count":53,"forks":384,"open_issues":53,"watchers":3575,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"b1f7facf39b840cbeeb3baef5c5f601a3a41e150","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars3.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/frontend/deployments","created_at":"2012-05-18T15:39:15Z","updated_at":"2017-06-15T10:08:05Z","pushed_at":"2017-06-15T13:17:33Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"https://www.theguardian.com","size":523069,"stargazers_count":3575,"watchers_count":3575,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":384,"mirror_url":null,"open_issues_count":53,"forks":384,"open_issues":53,"watchers":3575,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/17141"},"html":{"href":"https://github.com/guardian/frontend/pull/17141"},"issue":{"href":"https://api.github.com/repos/guardian/frontend/issues/17141"},"comments":{"href":"https://api.github.com/repos/guardian/frontend/issues/17141/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/frontend/pulls/17141/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/frontend/pulls/17141/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/frontend/statuses/a85995495769301aeb20ddfb4863998b5a7a2d6a"}}}}
{"actor":{"display_login":"TBonnin"}}