{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments/218592403","pull_request_review_id":156566000,"id":218592403,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODU5MjQwMw==","diff_hunk":"@@ -40,28 +40,28 @@ class AutoImporter {\n \n   constructor(componentsProvider, editor) {\n     this.componentsProvider = componentsProvider;\n-    this.componentsMap = {};\n+    this.componentsMap = componentsProvider.get();","path":"playground/src/auto-importer/auto-importer.js","position":null,"original_position":5,"commit_id":"f219e799c173584dd30c1a3d13e67cba3a162357","original_commit_id":"c13c672dc1d598781d7d882b826d1f63ab391477","user":{"login":"garanj","id":25058277,"node_id":"MDQ6VXNlcjI1MDU4Mjc3","avatar_url":"https://avatars2.githubusercontent.com/u/25058277?v=4","gravatar_id":"","url":"https://api.github.com/users/garanj","html_url":"https://github.com/garanj","followers_url":"https://api.github.com/users/garanj/followers","following_url":"https://api.github.com/users/garanj/following{/other_user}","gists_url":"https://api.github.com/users/garanj/gists{/gist_id}","starred_url":"https://api.github.com/users/garanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garanj/subscriptions","organizations_url":"https://api.github.com/users/garanj/orgs","repos_url":"https://api.github.com/users/garanj/repos","events_url":"https://api.github.com/users/garanj/events{/privacy}","received_events_url":"https://api.github.com/users/garanj/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2018-09-18T20:57:42Z","updated_at":"2018-09-18T20:57:42Z","html_url":"https://github.com/ampproject/amp-by-example/pull/1513#discussion_r218592403","pull_request_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments/218592403"},"html":{"href":"https://github.com/ampproject/amp-by-example/pull/1513#discussion_r218592403"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513"}},"in_reply_to_id":218481391},"pull_request":{"url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513","id":214639765,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0NjM5NzY1","html_url":"https://github.com/ampproject/amp-by-example/pull/1513","diff_url":"https://github.com/ampproject/amp-by-example/pull/1513.diff","patch_url":"https://github.com/ampproject/amp-by-example/pull/1513.patch","issue_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/1513","number":1513,"state":"open","locked":false,"title":"Importing component scripts (FR #1457)","user":{"login":"garanj","id":25058277,"node_id":"MDQ6VXNlcjI1MDU4Mjc3","avatar_url":"https://avatars2.githubusercontent.com/u/25058277?v=4","gravatar_id":"","url":"https://api.github.com/users/garanj","html_url":"https://github.com/garanj","followers_url":"https://api.github.com/users/garanj/followers","following_url":"https://api.github.com/users/garanj/following{/other_user}","gists_url":"https://api.github.com/users/garanj/gists{/gist_id}","starred_url":"https://api.github.com/users/garanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garanj/subscriptions","organizations_url":"https://api.github.com/users/garanj/orgs","repos_url":"https://api.github.com/users/garanj/repos","events_url":"https://api.github.com/users/garanj/events{/privacy}","received_events_url":"https://api.github.com/users/garanj/received_events","type":"User","site_admin":false},"body":"A start point for the FR from @tomayac #1457.\r\n\r\nIn summary, this PR adds the feature to automatically insert `<script>` elements for AMP components to the `<head>` element, when the user adds code requiring that component.\r\n\r\n## Frontend\r\n\r\nThe frontend adds a module `auto-importer` which listens for events from the AMP Validator. Where the validation result is a failure, the errors are filtered to determine whether any correspond to missing imports.\r\n\r\nThe resulting missing imports list is cross-referenced with the parsed state of the `<head>` element (as the former can sometimes report missing elements that are actually present), to arrive at a list of elements to insert.\r\n\r\nThe logic for insertion is as follows:\r\n\r\n*   If the AMP engine `<script>` element already exists, insert any missing `<script>` component elements directly beneath it.\r\n*   If the AMP engine does not exist, then insert both the AMP engine and required component elements as the last elements in the `<head>` element.\r\n\r\nCurrently more complex scenarios seeking to group together existing elements, sort them etc are not dealt with, but the output of parsing the `<head>` element does contain what would be required for this.\r\n\r\n## Backend\r\n\r\nThe frontend, on initialization, obtains a mapping of AMP component to version number from the backend, using the endpoint  `/playground/amp-component-versions`\r\n\r\nThis mapping is formed from the GitHub AMP extensions directory structure (thank you @sebastianbenz).\r\n\r\nThe mapping returned by the endpoint is stored in Memcache, backed by Datastore. Requests that cause a stale list to be served, trigger an update which is achieved through a named TaskQueue entry.\r\n\r\n## Demo\r\n\r\nAn demo can be seen [in this video](https://www.youtube.com/watch?v=IaUxHTxAauY)","created_at":"2018-09-11T13:50:08Z","updated_at":"2018-09-18T20:57:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2265e14fe1d8f78c3ec206a8853733e5d6c414fe","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513/commits","review_comments_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513/comments","review_comment_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/1513/comments","statuses_url":"https://api.github.com/repos/ampproject/amp-by-example/statuses/f219e799c173584dd30c1a3d13e67cba3a162357","head":{"label":"garanj:master","ref":"master","sha":"f219e799c173584dd30c1a3d13e67cba3a162357","user":{"login":"garanj","id":25058277,"node_id":"MDQ6VXNlcjI1MDU4Mjc3","avatar_url":"https://avatars2.githubusercontent.com/u/25058277?v=4","gravatar_id":"","url":"https://api.github.com/users/garanj","html_url":"https://github.com/garanj","followers_url":"https://api.github.com/users/garanj/followers","following_url":"https://api.github.com/users/garanj/following{/other_user}","gists_url":"https://api.github.com/users/garanj/gists{/gist_id}","starred_url":"https://api.github.com/users/garanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garanj/subscriptions","organizations_url":"https://api.github.com/users/garanj/orgs","repos_url":"https://api.github.com/users/garanj/repos","events_url":"https://api.github.com/users/garanj/events{/privacy}","received_events_url":"https://api.github.com/users/garanj/received_events","type":"User","site_admin":false},"repo":{"id":147034103,"node_id":"MDEwOlJlcG9zaXRvcnkxNDcwMzQxMDM=","name":"amp-by-example","full_name":"garanj/amp-by-example","private":false,"owner":{"login":"garanj","id":25058277,"node_id":"MDQ6VXNlcjI1MDU4Mjc3","avatar_url":"https://avatars2.githubusercontent.com/u/25058277?v=4","gravatar_id":"","url":"https://api.github.com/users/garanj","html_url":"https://github.com/garanj","followers_url":"https://api.github.com/users/garanj/followers","following_url":"https://api.github.com/users/garanj/following{/other_user}","gists_url":"https://api.github.com/users/garanj/gists{/gist_id}","starred_url":"https://api.github.com/users/garanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garanj/subscriptions","organizations_url":"https://api.github.com/users/garanj/orgs","repos_url":"https://api.github.com/users/garanj/repos","events_url":"https://api.github.com/users/garanj/events{/privacy}","received_events_url":"https://api.github.com/users/garanj/received_events","type":"User","site_admin":false},"html_url":"https://github.com/garanj/amp-by-example","description":"A hands-on introduction to Accelerated Mobile Pages (AMP) focusing on code and live samples.","fork":true,"url":"https://api.github.com/repos/garanj/amp-by-example","forks_url":"https://api.github.com/repos/garanj/amp-by-example/forks","keys_url":"https://api.github.com/repos/garanj/amp-by-example/keys{/key_id}","collaborators_url":"https://api.github.com/repos/garanj/amp-by-example/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/garanj/amp-by-example/teams","hooks_url":"https://api.github.com/repos/garanj/amp-by-example/hooks","issue_events_url":"https://api.github.com/repos/garanj/amp-by-example/issues/events{/number}","events_url":"https://api.github.com/repos/garanj/amp-by-example/events","assignees_url":"https://api.github.com/repos/garanj/amp-by-example/assignees{/user}","branches_url":"https://api.github.com/repos/garanj/amp-by-example/branches{/branch}","tags_url":"https://api.github.com/repos/garanj/amp-by-example/tags","blobs_url":"https://api.github.com/repos/garanj/amp-by-example/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/garanj/amp-by-example/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/garanj/amp-by-example/git/refs{/sha}","trees_url":"https://api.github.com/repos/garanj/amp-by-example/git/trees{/sha}","statuses_url":"https://api.github.com/repos/garanj/amp-by-example/statuses/{sha}","languages_url":"https://api.github.com/repos/garanj/amp-by-example/languages","stargazers_url":"https://api.github.com/repos/garanj/amp-by-example/stargazers","contributors_url":"https://api.github.com/repos/garanj/amp-by-example/contributors","subscribers_url":"https://api.github.com/repos/garanj/amp-by-example/subscribers","subscription_url":"https://api.github.com/repos/garanj/amp-by-example/subscription","commits_url":"https://api.github.com/repos/garanj/amp-by-example/commits{/sha}","git_commits_url":"https://api.github.com/repos/garanj/amp-by-example/git/commits{/sha}","comments_url":"https://api.github.com/repos/garanj/amp-by-example/comments{/number}","issue_comment_url":"https://api.github.com/repos/garanj/amp-by-example/issues/comments{/number}","contents_url":"https://api.github.com/repos/garanj/amp-by-example/contents/{+path}","compare_url":"https://api.github.com/repos/garanj/amp-by-example/compare/{base}...{head}","merges_url":"https://api.github.com/repos/garanj/amp-by-example/merges","archive_url":"https://api.github.com/repos/garanj/amp-by-example/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/garanj/amp-by-example/downloads","issues_url":"https://api.github.com/repos/garanj/amp-by-example/issues{/number}","pulls_url":"https://api.github.com/repos/garanj/amp-by-example/pulls{/number}","milestones_url":"https://api.github.com/repos/garanj/amp-by-example/milestones{/number}","notifications_url":"https://api.github.com/repos/garanj/amp-by-example/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/garanj/amp-by-example/labels{/name}","releases_url":"https://api.github.com/repos/garanj/amp-by-example/releases{/id}","deployments_url":"https://api.github.com/repos/garanj/amp-by-example/deployments","created_at":"2018-09-01T21:29:13Z","updated_at":"2018-09-18T20:57:13Z","pushed_at":"2018-09-18T20:57:10Z","git_url":"git://github.com/garanj/amp-by-example.git","ssh_url":"git@github.com:garanj/amp-by-example.git","clone_url":"https://github.com/garanj/amp-by-example.git","svn_url":"https://github.com/garanj/amp-by-example","homepage":"http://ampbyexample.com/","size":225957,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"f3cbb24e947b5daeff6b6d8ff3796c68a90bd5ac","user":{"login":"ampproject","id":14114390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTE0Mzkw","avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":51327024,"node_id":"MDEwOlJlcG9zaXRvcnk1MTMyNzAyNA==","name":"amp-by-example","full_name":"ampproject/amp-by-example","private":false,"owner":{"login":"ampproject","id":14114390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTE0Mzkw","avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ampproject/amp-by-example","description":"A hands-on introduction to Accelerated Mobile Pages (AMP) focusing on code and live samples.","fork":false,"url":"https://api.github.com/repos/ampproject/amp-by-example","forks_url":"https://api.github.com/repos/ampproject/amp-by-example/forks","keys_url":"https://api.github.com/repos/ampproject/amp-by-example/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amp-by-example/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amp-by-example/teams","hooks_url":"https://api.github.com/repos/ampproject/amp-by-example/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amp-by-example/events","assignees_url":"https://api.github.com/repos/ampproject/amp-by-example/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amp-by-example/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amp-by-example/tags","blobs_url":"https://api.github.com/repos/ampproject/amp-by-example/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amp-by-example/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amp-by-example/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amp-by-example/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amp-by-example/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amp-by-example/languages","stargazers_url":"https://api.github.com/repos/ampproject/amp-by-example/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amp-by-example/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amp-by-example/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amp-by-example/subscription","commits_url":"https://api.github.com/repos/ampproject/amp-by-example/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amp-by-example/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amp-by-example/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amp-by-example/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amp-by-example/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amp-by-example/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amp-by-example/merges","archive_url":"https://api.github.com/repos/ampproject/amp-by-example/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amp-by-example/downloads","issues_url":"https://api.github.com/repos/ampproject/amp-by-example/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amp-by-example/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amp-by-example/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amp-by-example/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amp-by-example/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amp-by-example/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amp-by-example/deployments","created_at":"2016-02-08T21:05:29Z","updated_at":"2018-09-18T09:04:24Z","pushed_at":"2018-09-18T20:57:12Z","git_url":"git://github.com/ampproject/amp-by-example.git","ssh_url":"git@github.com:ampproject/amp-by-example.git","clone_url":"https://github.com/ampproject/amp-by-example.git","svn_url":"https://github.com/ampproject/amp-by-example","homepage":"http://ampbyexample.com/","size":226417,"stargazers_count":687,"watchers_count":687,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":497,"mirror_url":null,"archived":false,"open_issues_count":142,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":497,"open_issues":142,"watchers":687,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513"},"html":{"href":"https://github.com/ampproject/amp-by-example/pull/1513"},"issue":{"href":"https://api.github.com/repos/ampproject/amp-by-example/issues/1513"},"comments":{"href":"https://api.github.com/repos/ampproject/amp-by-example/issues/1513/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amp-by-example/pulls/1513/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amp-by-example/statuses/f219e799c173584dd30c1a3d13e67cba3a162357"}},"author_association":"NONE"}}
{"actor":{"display_login":"garanj"}}