-
Notifications
You must be signed in to change notification settings - Fork 1
/
utterances.74a2fd99.js.map
1 lines (1 loc) Β· 82.6 KB
/
utterances.74a2fd99.js.map
1
{"version":3,"sources":["deparam.ts","repo-regex.ts","utterances-api.ts","oauth.ts","page-attributes.ts","encoding.ts","github.ts","time-ago.ts","measure.ts","reactions.ts","comment-component.ts","timeline-component.ts","repo-config.ts","new-comment-component.ts","theme.ts","utterances.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAM,SAAU,OAAV,CAAkB,KAAlB,EAA+B;AACnC,MAAI,KAAJ;AACA,MAAM,IAAI,GAAG,KAAb;AACA,MAAM,MAAM,GAAG,oBAAf;;AACA,MAAM,MAAM,GAAG,SAAT,MAAS,CAAC,CAAD,EAAU;AAAK,WAAA,kBAAkB,CAAC,CAAC,CAAC,OAAF,CAAU,IAAV,EAAgB,GAAhB,CAAD,CAAlB;AAAwC,GAAtE;;AACA,MAAM,MAAM,GAA2B,EAAvC;;AAEA,SAAO,KAAK,GAAG,MAAM,CAAC,IAAP,CAAY,KAAZ,CAAf,EAAmC;AACjC,IAAA,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAD,CAAN,CAAP,CAAN,GAA2B,MAAM,CAAC,KAAK,CAAC,CAAD,CAAN,CAAjC;AACD;;AACD,SAAO,MAAP;AACD;;AAEK,SAAU,KAAV,CAAgB,GAAhB,EAA2C;AAC/C,MAAM,KAAK,GAAG,EAAd;;AACA,OAAK,IAAM,IAAX,IAAmB,GAAnB,EAAwB;AACtB,QAAI,GAAG,CAAC,cAAJ,CAAmB,IAAnB,KAA4B,GAAG,CAAC,IAAD,CAAnC,EAA2C;AACzC,MAAA,KAAK,CAAC,IAAN,CAAc,kBAAkB,CAAC,IAAD,CAAlB,GAAwB,GAAxB,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EAAe,IAAI,GAAK,+BAAI,IAA5B;;AACR,cAAI,OAAO,CAAC,OAAR,CAAgB,MAAhB,MAA4B,CAAC,CAAjC,EAAoC;AAClC,mBAAA,CAAA,CAAA,CAAA;AACD;;AAED,UAAA,QAAQ,CAAC,aAAT,CAAuB,WAAvB,EAAqC,gBAArC,CAAuD,kBAAvD,CAA0E,aAA1E,EAAyF,iFAExE,MAFwE,GAElE,4CAFkE,GAErB,KAFqB,GAEhB,GAFgB,GAEZ,IAFY,GAER,mIAFQ,GAIzD,KAJyD,GAIpD,GAJoD,GAIhD,IAJgD,GAI5C,qIAJ4C,GAOpE,MAPoE,GAO9D,+FAP8D,GAS1E,IAAI,CAAC,SAAL,CAAe;AAAE,YAAA,OAAO,EAAE,CAAC,MAAD;AAAX,WAAf,EAAsC,IAAtC,EAA4C,CAA5C,CAT0E,GAS5B,yBAT7D;AAWA;AACA,gBAAM,IAAI,KAAJ,CAAU,uBAAV,CAAN;;;;AACD","file":"utterances.74a2fd99.js","sourceRoot":"..\\src","sourcesContent":["export function deparam(query: string): Record<string, string> {\r\n let match: RegExpExecArray | null;\r\n const plus = /\\+/g;\r\n const search = /([^&=]+)=?([^&]*)/g;\r\n const decode = (s: string) => decodeURIComponent(s.replace(plus, ' '));\r\n const params: Record<string, string> = {};\r\n // tslint:disable-next-line:no-conditional-assignment\r\n while (match = search.exec(query)) {\r\n params[decode(match[1])] = decode(match[2]);\r\n }\r\n return params;\r\n}\r\n\r\nexport function param(obj: Record<string, string>) {\r\n const parts = [];\r\n for (const name in obj) {\r\n if (obj.hasOwnProperty(name) && obj[name]) {\r\n parts.push(`${encodeURIComponent(name)}=${encodeURIComponent(obj[name])}`);\r\n }\r\n }\r\n return parts.join('&');\r\n}\r\n","export default /^([\\w-_]+)\\/([\\w-_.]+)$/i;\r\n","// export const UTTERANCES_API = 'http://localhost:5000';\r\nexport const UTTERANCES_API = 'https://api.utteranc.es';\r\n","import { UTTERANCES_API } from './utterances-api';\r\nimport { param } from './deparam';\r\n\r\nexport const token = { value: null as null | string };\r\n\r\n// tslint:disable-next-line:variable-name\r\nexport function getLoginUrl(redirect_uri: string) {\r\n return `${UTTERANCES_API}/authorize?${param({ redirect_uri })}`;\r\n}\r\n\r\nexport async function loadToken(): Promise<string | null> {\r\n if (token.value) {\r\n return token.value;\r\n }\r\n const url = `${UTTERANCES_API}/token`;\r\n const response = await fetch(url, { method: 'POST', mode: 'cors', credentials: 'include' });\r\n if (response.ok) {\r\n const t = await response.json();\r\n token.value = t;\r\n return t;\r\n }\r\n return null;\r\n}\r\n","import { deparam } from './deparam';\r\nimport repoRegex from './repo-regex';\r\nimport { token } from './oauth';\r\n\r\nfunction readPageAttributes() {\r\n const params = deparam(location.search.substr(1));\r\n\r\n let issueTerm: string | null = null;\r\n let issueNumber: number | null = null;\r\n if ('issue-term' in params) {\r\n issueTerm = params['issue-term'];\r\n if (issueTerm !== undefined) {\r\n if (issueTerm === '') {\r\n throw new Error('When issue-term is specified, it cannot be blank.');\r\n }\r\n if (['title', 'url', 'pathname', 'og:title'].indexOf(issueTerm) !== -1) {\r\n if (!params[issueTerm]) {\r\n throw new Error(`Unable to find \"${issueTerm}\" metadata.`);\r\n }\r\n issueTerm = params[issueTerm];\r\n }\r\n }\r\n } else if ('issue-number' in params) {\r\n issueNumber = +params['issue-number'];\r\n if (issueNumber.toString(10) !== params['issue-number']) {\r\n throw new Error(`issue-number is invalid. \"${params['issue-number']}`);\r\n }\r\n } else {\r\n throw new Error('\"issue-term\" or \"issue-number\" must be specified.');\r\n }\r\n\r\n if (!('repo' in params)) {\r\n throw new Error('\"repo\" is required.');\r\n }\r\n\r\n if (!('origin' in params)) {\r\n throw new Error('\"origin\" is required.');\r\n }\r\n\r\n const matches = repoRegex.exec(params.repo);\r\n if (matches === null) {\r\n throw new Error(`Invalid repo: \"${params.repo}\"`);\r\n }\r\n\r\n if (params.token) {\r\n token.value = params.token;\r\n }\r\n\r\n return {\r\n owner: matches[1],\r\n repo: matches[2],\r\n issueTerm,\r\n issueNumber,\r\n autocreate: params.autocreate,\r\n origin: params.origin,\r\n url: params.url,\r\n title: params.title,\r\n description: params.description,\r\n label: params.label,\r\n theme: params.theme || 'github-light'\r\n };\r\n}\r\n\r\nexport const pageAttributes = readPageAttributes();\r\n","declare function escape(str: string): string;\r\n\r\nexport function decodeBase64UTF8(encoded: string) {\r\n encoded = encoded.replace(/\\s/g, '');\r\n return decodeURIComponent(escape(atob(encoded)));\r\n}\r\n","import { token } from './oauth';\r\nimport { decodeBase64UTF8 } from './encoding';\r\nimport { UTTERANCES_API } from './utterances-api';\r\n\r\nconst GITHUB_API = 'https://api.github.com/';\r\nconst GITHUB_ENCODING__HTML_JSON = 'application/vnd.github.VERSION.html+json';\r\nconst GITHUB_ENCODING__HTML = 'application/vnd.github.VERSION.html';\r\nconst GITHUB_ENCODING__REACTIONS_PREVIEW = 'application/vnd.github.squirrel-girl-preview';\r\n\r\nexport const PAGE_SIZE = 25;\r\n\r\nexport type ReactionID = '+1' | '-1' | 'laugh' | 'hooray' | 'confused' | 'heart' | 'rocket' | 'eyes';\r\n\r\nexport const reactionTypes: ReactionID[] = ['+1', '-1', 'laugh', 'hooray', 'confused', 'heart', 'rocket', 'eyes'];\r\n\r\nlet owner: string;\r\nlet repo: string;\r\nconst branch = 'master';\r\n\r\nexport function setRepoContext(context: { owner: string; repo: string; }) {\r\n owner = context.owner;\r\n repo = context.repo;\r\n}\r\n\r\nfunction githubRequest(relativeUrl: string, init?: RequestInit) {\r\n init = init || {};\r\n init.mode = 'cors';\r\n init.cache = 'no-cache'; // force conditional request\r\n const request = new Request(GITHUB_API + relativeUrl, init);\r\n request.headers.set('Accept', GITHUB_ENCODING__REACTIONS_PREVIEW);\r\n if (!/^search\\//.test(relativeUrl) && token.value !== null) {\r\n request.headers.set('Authorization', `token ${token.value}`);\r\n }\r\n return request;\r\n}\r\n\r\nconst rateLimit = {\r\n standard: {\r\n limit: Number.MAX_VALUE,\r\n remaining: Number.MAX_VALUE,\r\n reset: 0\r\n },\r\n search: {\r\n limit: Number.MAX_VALUE,\r\n remaining: Number.MAX_VALUE,\r\n reset: 0\r\n }\r\n};\r\n\r\nfunction processRateLimit(response: Response) {\r\n const limit = response.headers.get('X-RateLimit-Limit')!;\r\n const remaining = response.headers.get('X-RateLimit-Remaining')!;\r\n const reset = response.headers.get('X-RateLimit-Reset')!;\r\n\r\n const isSearch = /\\/search\\//.test(response.url);\r\n const rate = isSearch ? rateLimit.search : rateLimit.standard;\r\n\r\n rate.limit = +limit;\r\n rate.remaining = +remaining;\r\n rate.reset = +reset;\r\n\r\n if (response.status === 403 && rate.remaining === 0) {\r\n const resetDate = new Date(0);\r\n resetDate.setUTCSeconds(rate.reset);\r\n const mins = Math.round((resetDate.getTime() - new Date().getTime()) / 1000 / 60);\r\n const apiType = isSearch ? 'search API' : 'non-search APIs';\r\n // tslint:disable-next-line:no-console\r\n console.warn(`Rate limit exceeded for ${apiType}. Resets in ${mins} minute${mins === 1 ? '' : 's'}.`);\r\n }\r\n}\r\n\r\nexport function readRelNext(response: Response) {\r\n const link = response.headers.get('link');\r\n if (link === null) {\r\n return 0;\r\n }\r\n const match = /\\?page=([2-9][0-9]*)>; rel=\"next\"/.exec(link);\r\n if (match === null) {\r\n return 0;\r\n }\r\n return +match[1];\r\n}\r\n\r\nfunction githubFetch(request: Request): Promise<Response> {\r\n return fetch(request).then(response => {\r\n if (response.status === 401) {\r\n token.value = null;\r\n }\r\n if (response.status === 403) {\r\n response.json().then(data => {\r\n if (data.message === 'Resource not accessible by integration') {\r\n window.dispatchEvent(new CustomEvent('not-installed'));\r\n }\r\n });\r\n }\r\n\r\n processRateLimit(response);\r\n\r\n if (request.method === 'GET'\r\n && [401, 403].indexOf(response.status) !== -1\r\n && request.headers.has('Authorization')\r\n ) {\r\n request.headers.delete('Authorization');\r\n return githubFetch(request);\r\n }\r\n return response;\r\n });\r\n}\r\n\r\nexport function loadJsonFile<T>(path: string, html = false) {\r\n const request = githubRequest(`repos/${owner}/${repo}/contents/${path}?ref=${branch}`);\r\n if (html) {\r\n request.headers.set('accept', GITHUB_ENCODING__HTML);\r\n }\r\n return githubFetch(request).then<FileContentsResponse | string>(response => {\r\n if (response.status === 404) {\r\n throw new Error(`Repo \"${owner}/${repo}\" does not have a file named \"${path}\" in the \"${branch}\" branch.`);\r\n }\r\n if (!response.ok) {\r\n throw new Error(`Error fetching ${path}.`);\r\n }\r\n return html ? response.text() : response.json();\r\n }).then<T>(file => {\r\n if (html) {\r\n return file;\r\n }\r\n const { content } = file as FileContentsResponse;\r\n const decoded = decodeBase64UTF8(content);\r\n return JSON.parse(decoded);\r\n });\r\n}\r\n\r\nexport function loadIssueByTerm(term: string) {\r\n const q = `\"${term}\" type:issue in:title repo:${owner}/${repo}`;\r\n const request = githubRequest(`search/issues?q=${encodeURIComponent(q)}&sort=created&order=asc`);\r\n return githubFetch(request).then<IssueSearchResponse>(response => {\r\n if (!response.ok) {\r\n throw new Error('Error fetching issue via search.');\r\n }\r\n return response.json();\r\n }).then(results => {\r\n if (results.total_count === 0) {\r\n return null;\r\n }\r\n if (results.total_count > 1) {\r\n // tslint:disable-next-line:no-console\r\n console.warn(`Multiple issues match \"${q}\".`);\r\n }\r\n term = term.toLowerCase();\r\n for (const result of results.items) {\r\n if (result.title.toLowerCase().indexOf(term) !== -1) {\r\n return result;\r\n }\r\n }\r\n // tslint:disable-next-line:no-console\r\n console.warn(`Issue search results do not contain an issue with title matching \"${term}\". Using first result.`);\r\n return results.items[0];\r\n });\r\n}\r\n\r\nexport function loadIssueByNumber(issueNumber: number) {\r\n const request = githubRequest(`repos/${owner}/${repo}/issues/${issueNumber}`);\r\n return githubFetch(request).then<Issue>(response => {\r\n if (!response.ok) {\r\n throw new Error('Error fetching issue via issue number.');\r\n }\r\n return response.json();\r\n });\r\n}\r\n\r\nfunction commentsRequest(issueNumber: number, page: number) {\r\n const url = `repos/${owner}/${repo}/issues/${issueNumber}/comments?page=${page}&per_page=${PAGE_SIZE}`;\r\n const request = githubRequest(url);\r\n const accept = `${GITHUB_ENCODING__HTML_JSON},${GITHUB_ENCODING__REACTIONS_PREVIEW}`;\r\n request.headers.set('Accept', accept);\r\n return request;\r\n}\r\n\r\nexport function loadCommentsPage(issueNumber: number, page: number): Promise<IssueComment[]> {\r\n const request = commentsRequest(issueNumber, page);\r\n return githubFetch(request).then(response => {\r\n if (!response.ok) {\r\n throw new Error('Error fetching comments.');\r\n }\r\n return response.json();\r\n });\r\n}\r\n\r\nexport function loadUser(): Promise<User | null> {\r\n if (token.value === null) {\r\n return Promise.resolve(null);\r\n }\r\n return githubFetch(githubRequest('user'))\r\n .then(response => {\r\n if (response.ok) {\r\n return response.json();\r\n }\r\n return null;\r\n });\r\n}\r\n\r\nexport function createIssue(issueTerm: string, documentUrl: string, title: string, description: string, label: string) {\r\n const url = `${UTTERANCES_API}/repos/${owner}/${repo}/issues${label ? `?label=${encodeURIComponent(label)}` : ''}`;\r\n const request = new Request(url, {\r\n method: 'POST',\r\n body: JSON.stringify({\r\n title: issueTerm,\r\n body: `# ${title}\\n\\n${description}\\n\\n[${documentUrl}](${documentUrl})`\r\n })\r\n });\r\n request.headers.set('Accept', GITHUB_ENCODING__REACTIONS_PREVIEW);\r\n request.headers.set('Authorization', `token ${token.value}`);\r\n return fetch(request).then<Issue>(response => {\r\n if (!response.ok) {\r\n throw new Error('Error creating comments container issue');\r\n }\r\n return response.json();\r\n });\r\n}\r\n\r\nexport function postComment(issueNumber: number, markdown: string) {\r\n const url = `repos/${owner}/${repo}/issues/${issueNumber}/comments`;\r\n const body = JSON.stringify({ body: markdown });\r\n const request = githubRequest(url, { method: 'POST', body });\r\n const accept = `${GITHUB_ENCODING__HTML_JSON},${GITHUB_ENCODING__REACTIONS_PREVIEW}`;\r\n request.headers.set('Accept', accept);\r\n return githubFetch(request).then<IssueComment>(response => {\r\n if (!response.ok) {\r\n throw new Error('Error posting comment.');\r\n }\r\n return response.json();\r\n });\r\n}\r\n\r\nexport async function toggleReaction(url: string, content: ReactionID) {\r\n url = url.replace(GITHUB_API, '');\r\n // We don't know if the reaction exists or not. Attempt to create it. If the GitHub\r\n // API responds that the reaction already exists, delete it.\r\n const body = JSON.stringify({ content });\r\n const postRequest = githubRequest(url, { method: 'POST', body });\r\n postRequest.headers.set('Accept', GITHUB_ENCODING__REACTIONS_PREVIEW);\r\n const response = await githubFetch(postRequest);\r\n const reaction: Reaction = response.ok ? await response.json() : null;\r\n if (response.status === 201) { // reaction created.\r\n return { reaction, deleted: false };\r\n }\r\n if (response.status !== 200) {\r\n throw new Error('expected \"201 reaction created\" or \"200 reaction already exists\"');\r\n }\r\n // reaction already exists... delete.\r\n const deleteRequest = githubRequest(`reactions/${reaction.id}`, { method: 'DELETE' });\r\n deleteRequest.headers.set('Accept', GITHUB_ENCODING__REACTIONS_PREVIEW);\r\n await githubFetch(deleteRequest);\r\n return { reaction, deleted: true };\r\n}\r\n\r\nexport function renderMarkdown(text: string) {\r\n const body = JSON.stringify({ text, mode: 'gfm', context: `${owner}/${repo}` });\r\n return githubFetch(githubRequest('markdown', { method: 'POST', body }))\r\n .then(response => response.text());\r\n}\r\n\r\ninterface IssueSearchResponse {\r\n total_count: number;\r\n incomplete_results: boolean;\r\n items: Issue[];\r\n}\r\n\r\nexport interface User {\r\n login: string;\r\n id: number;\r\n avatar_url: string;\r\n gravatar_id: string;\r\n url: string;\r\n html_url: string;\r\n followers_url: string;\r\n following_url: string;\r\n gists_url: string;\r\n starred_url: string;\r\n subscriptions_url: string;\r\n organizations_url: string;\r\n repos_url: string;\r\n events_url: string;\r\n received_events_url: string;\r\n type: string;\r\n}\r\n\r\nexport type CommentAuthorAssociation =\r\n 'COLLABORATOR'\r\n | 'CONTRIBUTOR'\r\n | 'FIRST_TIMER'\r\n | 'FIRST_TIME_CONTRIBUTOR'\r\n | 'MEMBER'\r\n | 'NONE'\r\n | 'OWNER';\r\n\r\nexport interface Reactions {\r\n url: string;\r\n total_count: number;\r\n '+1': number;\r\n '-1': number;\r\n laugh: number;\r\n hooray: number;\r\n confused: number;\r\n heart: number;\r\n rocket: number;\r\n eyes: number;\r\n}\r\n\r\nexport interface Reaction {\r\n id: number;\r\n user: User;\r\n content: ReactionID;\r\n created_at: string;\r\n}\r\n\r\nexport interface Issue {\r\n url: string;\r\n repository_url: string;\r\n labels_url: string;\r\n comments_url: string;\r\n events_url: string;\r\n html_url: string;\r\n id: number;\r\n number: number;\r\n title: string;\r\n user: User;\r\n locked: boolean;\r\n labels: {\r\n url: string;\r\n name: string;\r\n color: string;\r\n }[];\r\n state: string;\r\n assignee: null; // todo,\r\n milestone: null; // todo,\r\n comments: number;\r\n created_at: string;\r\n updated_at: string;\r\n closed_at: null; // todo,\r\n pull_request: {\r\n html_url: null; // todo,\r\n diff_url: null; // todo,\r\n patch_url: null; // todo\r\n };\r\n body: string;\r\n score: number;\r\n reactions: Reactions;\r\n author_association: CommentAuthorAssociation;\r\n}\r\n\r\ninterface FileContentsResponse {\r\n type: string;\r\n encoding: string;\r\n size: number;\r\n name: string;\r\n path: string;\r\n content: string;\r\n sha: string;\r\n url: string;\r\n git_url: string;\r\n html_url: string;\r\n download_url: string;\r\n}\r\n\r\nexport interface IssueComment {\r\n id: number;\r\n url: string;\r\n html_url: string;\r\n body_html: string;\r\n user: User;\r\n created_at: string;\r\n updated_at: string;\r\n author_association: CommentAuthorAssociation;\r\n reactions: Reactions;\r\n}\r\n\r\n/*\r\nquery IssueComments($owner: String!, $repo: String!, $issueQuery: String!) {\r\n search(query: $issueQuery, type: ISSUE, first: 1) {\r\n issueCount\r\n edges {\r\n node {\r\n ... on Issue {\r\n id\r\n title,\r\n comments(first: 100) {\r\n \ttotalCount\r\n edges {\r\n node {\r\n id,\r\n createdAt,\r\n bodyHTML,\r\n author {\r\n avatarUrl,\r\n login\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n rateLimit {\r\n cost\r\n limit\r\n remaining\r\n resetAt\r\n }\r\n\r\n repository(owner: $owner, name: $repo) {\r\n object(expression: \"master:utterances.json\") {\r\n ... on Blob {\r\n text\r\n }\r\n }\r\n }\r\n}\r\n\r\n{\r\n \"issueQuery\": \"user:jdanyow repo:utterances-demo debug\",\r\n \"owner\": \"jdanyow\",\r\n \"repo\": \"utterances-demo\"\r\n}\r\n*/\r\n","// todo: take a dependency on some relative time library.\r\n\r\nconst thresholds = [\r\n 1000, 'second',\r\n 1000 * 60, 'minute',\r\n 1000 * 60 * 60, 'hour',\r\n 1000 * 60 * 60 * 24, 'day',\r\n 1000 * 60 * 60 * 24 * 7, 'week',\r\n 1000 * 60 * 60 * 24 * 27, 'month'\r\n];\r\n\r\nconst formatOptions: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric', year: 'numeric' };\r\n\r\nexport function timeAgo(current: number, value: Date) {\r\n const elapsed = current - value.getTime();\r\n if (elapsed < 5000) {\r\n return 'just now';\r\n }\r\n let i = 0;\r\n while (i + 2 < thresholds.length && elapsed * 1.1 > thresholds[i + 2]) {\r\n i += 2;\r\n }\r\n\r\n const divisor = thresholds[i] as number;\r\n const text = thresholds[i + 1] as string;\r\n const units = Math.round(elapsed / divisor);\r\n\r\n if (units > 3 && i === thresholds.length - 2) {\r\n return `on ${value.toLocaleDateString(undefined, formatOptions)}`;\r\n }\r\n return units === 1 ? `${text === 'hour' ? 'an' : 'a'} ${text} ago` : `${units} ${text}s ago`;\r\n}\r\n","export interface ResizeMessage {\r\n type: 'resize';\r\n height: number;\r\n}\r\n\r\nlet hostOrigin: string;\r\n\r\nexport function startMeasuring(origin: string) {\r\n hostOrigin = origin;\r\n addEventListener('resize', scheduleMeasure);\r\n addEventListener('load', scheduleMeasure);\r\n}\r\n\r\nlet lastHeight = -1;\r\n\r\nfunction measure() {\r\n const height = document.body.scrollHeight;\r\n if (height === lastHeight) {\r\n return;\r\n }\r\n lastHeight = height;\r\n const message: ResizeMessage = { type: 'resize', height };\r\n parent.postMessage(message, hostOrigin);\r\n}\r\n\r\nlet lastMeasure = 0;\r\n\r\nexport function scheduleMeasure() {\r\n const now = Date.now();\r\n if (now - lastMeasure > 50) {\r\n lastMeasure = now;\r\n setTimeout(measure, 50);\r\n }\r\n}\r\n","import { toggleReaction, ReactionID, reactionTypes } from './github';\r\nimport { getLoginUrl } from './oauth';\r\nimport { pageAttributes } from './page-attributes';\r\nimport { scheduleMeasure } from './measure';\r\n\r\nexport const reactionNames: Record<ReactionID, string> = {\r\n '+1': 'Thumbs Up',\r\n '-1': 'Thumbs Down',\r\n 'laugh': 'Laugh',\r\n 'hooray': 'Hooray',\r\n 'confused': 'Confused',\r\n 'heart': 'Heart',\r\n 'rocket': 'Rocket',\r\n 'eyes': 'Eyes'\r\n};\r\n\r\nexport const reactionEmoji: Record<ReactionID, string> = {\r\n '+1': 'π',\r\n '-1': 'π',\r\n 'laugh': 'οΈπ',\r\n 'hooray': 'οΈπ',\r\n 'confused': 'π',\r\n 'heart': 'β€οΈ',\r\n 'rocket': 'π',\r\n 'eyes': 'π'\r\n};\r\n\r\nexport function getReactionHtml(url: string, reaction: ReactionID, disabled: boolean, count: number) {\r\n return `\r\n <button\r\n reaction\r\n type=\"submit\"\r\n action=\"javascript:\"\r\n formaction=\"${url}\"\r\n class=\"btn BtnGroup-item btn-outline reaction-button\"\r\n value=\"${reaction}\"\r\n aria-label=\"Toggle ${reactionNames[reaction]} reaction\"\r\n reaction-count=\"${count}\"\r\n ${disabled ? 'disabled' : ''}>\r\n ${reactionEmoji[reaction]}\r\n </button>`;\r\n}\r\n\r\nexport function enableReactions(authenticated: boolean) {\r\n const submitReaction = async (event: Event) => {\r\n const button = event.target instanceof HTMLElement && event.target.closest('button');\r\n if (!button) {\r\n return;\r\n }\r\n if (!button.hasAttribute('reaction')) {\r\n return;\r\n }\r\n event.preventDefault();\r\n if (!authenticated) {\r\n return;\r\n }\r\n button.disabled = true;\r\n const parentMenu = button.closest('details');\r\n if (parentMenu) {\r\n parentMenu.open = false;\r\n }\r\n const url = button.formAction;\r\n const id = button.value as ReactionID;\r\n const { deleted } = await toggleReaction(url, id);\r\n const selector = `button[reaction][formaction=\"${url}\"][value=\"${id}\"],[reaction-count][reaction-url=\"${url}\"]`;\r\n const elements = Array.from(document.querySelectorAll(selector));\r\n const delta = deleted ? -1 : 1;\r\n for (const element of elements) {\r\n element.setAttribute(\r\n 'reaction-count',\r\n (parseInt(element.getAttribute('reaction-count')!, 10) + delta).toString());\r\n }\r\n button.disabled = false;\r\n scheduleMeasure();\r\n };\r\n addEventListener('click', submitReaction, true);\r\n}\r\n\r\nexport function getReactionsMenuHtml(url: string, align: 'center' | 'right') {\r\n const position = align === 'center' ? 'left: 50%;transform: translateX(-50%)' : 'right:6px';\r\n const alignmentClass = align === 'center' ? '' : 'Popover-message--top-right';\r\n const getButtonAndSpan = (id: ReactionID) => getReactionHtml(url, id, false, 0)\r\n + `<span class=\"reaction-name\" aria-hidden=\"true\">${reactionNames[id]}</span>`;\r\n return `\r\n <details class=\"details-overlay details-popover reactions-popover\">\r\n <summary ${align === 'center' ? 'tabindex=\"-1\"' : ''}>${addReactionSvgs}</summary>\r\n <div class=\"Popover\" style=\"${position}\">\r\n <form class=\"Popover-message ${alignmentClass} box-shadow-large\" action=\"javascript:\">\r\n <span class=\"reaction-name\">Pick your reaction</span>\r\n <div class=\"BtnGroup\">\r\n ${reactionTypes.slice(0, 4).map(getButtonAndSpan).join('')}\r\n </div>\r\n <div class=\"BtnGroup\">\r\n ${reactionTypes.slice(4).map(getButtonAndSpan).join('')}\r\n </div>\r\n </form>\r\n </div>\r\n </details>`;\r\n}\r\n\r\nexport function getSignInToReactMenuHtml(align: 'center' | 'right') {\r\n const position = align === 'center' ? 'left: 50%;transform: translateX(-50%)' : 'right:6px';\r\n const alignmentClass = align === 'center' ? '' : 'Popover-message--top-right';\r\n return `\r\n <details class=\"details-overlay details-popover reactions-popover\">\r\n <summary aria-label=\"Reactions Menu\">${addReactionSvgs}</summary>\r\n <div class=\"Popover\" style=\"${position}\">\r\n <div class=\"Popover-message ${alignmentClass} box-shadow-large\" style=\"padding: 16px\">\r\n <span><a href=\"${getLoginUrl(pageAttributes.url)}\" target=\"_top\">Sign in</a> to add your reaction.</span>\r\n </div>\r\n </div>\r\n </details>`;\r\n}\r\n\r\n// tslint:disable-next-line:max-line-length\r\nconst addReactionSvgs = `<svg class=\"octicon\" style=\"margin-right:3px\" viewBox=\"0 0 7 16\" version=\"1.1\" width=\"7\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 4H3v3H0v1h3v3h1V8h3V7H4V4z\"></path></svg><svg class=\"octicon\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M8 0C3.58 0 0 3.58 0 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm4.81 12.81a6.72 6.72 0 0 1-2.17 1.45c-.83.36-1.72.53-2.64.53-.92 0-1.81-.17-2.64-.53-.81-.34-1.55-.83-2.17-1.45a6.773 6.773 0 0 1-1.45-2.17A6.59 6.59 0 0 1 1.21 8c0-.92.17-1.81.53-2.64.34-.81.83-1.55 1.45-2.17.62-.62 1.36-1.11 2.17-1.45A6.59 6.59 0 0 1 8 1.21c.92 0 1.81.17 2.64.53.81.34 1.55.83 2.17 1.45.62.62 1.11 1.36 1.45 2.17.36.83.53 1.72.53 2.64 0 .92-.17 1.81-.53 2.64-.34.81-.83 1.55-1.45 2.17zM4 6.8v-.59c0-.66.53-1.19 1.2-1.19h.59c.66 0 1.19.53 1.19 1.19v.59c0 .67-.53 1.2-1.19 1.2H5.2C4.53 8 4 7.47 4 6.8zm5 0v-.59c0-.66.53-1.19 1.2-1.19h.59c.66 0 1.19.53 1.19 1.19v.59c0 .67-.53 1.2-1.19 1.2h-.59C9.53 8 9 7.47 9 6.8zm4 3.2c-.72 1.88-2.91 3-5 3s-4.28-1.13-5-3c-.14-.39.23-1 .66-1h8.59c.41 0 .89.61.75 1z\"></path></svg>`;\r\n","import { CommentAuthorAssociation, IssueComment, reactionTypes } from './github';\r\nimport { timeAgo } from './time-ago';\r\nimport { scheduleMeasure } from './measure';\r\nimport { getReactionsMenuHtml, getReactionHtml, getSignInToReactMenuHtml } from './reactions';\r\n\r\nconst avatarArgs = '?v=3&s=88';\r\nconst displayAssociations: Record<CommentAuthorAssociation, string> = {\r\n COLLABORATOR: 'Collaborator',\r\n CONTRIBUTOR: 'Contributor',\r\n MEMBER: 'Member',\r\n OWNER: 'Owner',\r\n FIRST_TIME_CONTRIBUTOR: 'First time contributor',\r\n FIRST_TIMER: 'First timer',\r\n NONE: ''\r\n};\r\n\r\nexport class CommentComponent {\r\n public readonly element: HTMLElement;\r\n\r\n constructor(\r\n public comment: IssueComment,\r\n private currentUser: string | null,\r\n locked: boolean\r\n ) {\r\n const { user, html_url, created_at, body_html, author_association, reactions } = comment;\r\n this.element = document.createElement('article');\r\n this.element.classList.add('timeline-comment');\r\n if (user.login === currentUser) {\r\n this.element.classList.add('current-user');\r\n }\r\n const association = displayAssociations[author_association];\r\n const reactionCount = reactionTypes.reduce((sum, id) => sum + reactions[id], 0);\r\n let headerReactionsMenu = '';\r\n let footerReactionsMenu = '';\r\n if (!locked) {\r\n if (currentUser) {\r\n headerReactionsMenu = getReactionsMenuHtml(comment.reactions.url, 'right');\r\n footerReactionsMenu = getReactionsMenuHtml(comment.reactions.url, 'center');\r\n } else {\r\n headerReactionsMenu = getSignInToReactMenuHtml('right');\r\n footerReactionsMenu = getSignInToReactMenuHtml('center');\r\n }\r\n }\r\n this.element.innerHTML = `\r\n <a class=\"avatar\" href=\"${user.html_url}\" target=\"_blank\" tabindex=\"-1\">\r\n <img alt=\"@${user.login}\" height=\"44\" width=\"44\"\r\n src=\"${user.avatar_url}${avatarArgs}\">\r\n </a>\r\n <div class=\"comment\">\r\n <header class=\"comment-header\">\r\n <span class=\"comment-meta\">\r\n <a class=\"text-link\" href=\"${user.html_url}\" target=\"_blank\"><strong>${user.login}</strong></a>\r\n commented\r\n <a class=\"text-link\" href=\"${html_url}\" target=\"_blank\">${timeAgo(Date.now(), new Date(created_at))}</a>\r\n </span>\r\n <div class=\"comment-actions\">\r\n ${association ? `<span class=\"author-association-badge\">${association}</span>` : ''}\r\n ${headerReactionsMenu}\r\n </div>\r\n </header>\r\n <div class=\"markdown-body markdown-body-scrollable\">\r\n ${body_html}\r\n </div>\r\n <div class=\"comment-footer\" reaction-count=\"${reactionCount}\" reaction-url=\"${reactions.url}\">\r\n <form class=\"reaction-list BtnGroup\" action=\"javascript:\">\r\n ${reactionTypes.map(id => getReactionHtml(reactions.url, id, !currentUser || locked, reactions[id])).join('')}\r\n </form>\r\n ${footerReactionsMenu}\r\n </div>\r\n </div>`;\r\n\r\n const markdownBody = this.element.querySelector('.markdown-body')!;\r\n const emailToggle = markdownBody.querySelector('.email-hidden-toggle a') as HTMLAnchorElement;\r\n if (emailToggle) {\r\n const emailReply = markdownBody.querySelector('.email-hidden-reply') as HTMLDivElement;\r\n emailToggle.onclick = event => {\r\n event.preventDefault();\r\n emailReply.classList.toggle('expanded');\r\n };\r\n }\r\n\r\n processRenderedMarkdown(markdownBody);\r\n }\r\n\r\n public setCurrentUser(currentUser: string | null) {\r\n if (this.currentUser === currentUser) {\r\n return;\r\n }\r\n this.currentUser = currentUser;\r\n\r\n if (this.comment.user.login === this.currentUser) {\r\n this.element.classList.add('current-user');\r\n } else {\r\n this.element.classList.remove('current-user');\r\n }\r\n }\r\n}\r\n\r\nexport function processRenderedMarkdown(markdownBody: Element) {\r\n Array.from(markdownBody.querySelectorAll<HTMLAnchorElement>(':not(.email-hidden-toggle) > a'))\r\n .forEach(a => { a.target = '_top'; a.rel = 'noopener noreferrer'; });\r\n Array.from(markdownBody.querySelectorAll<HTMLImageElement>('img'))\r\n .forEach(img => img.onload = scheduleMeasure);\r\n Array.from(markdownBody.querySelectorAll<HTMLAnchorElement>('a.commit-tease-sha'))\r\n .forEach(a => a.href = 'https://github.com' + a.pathname);\r\n}\r\n","import { User, Issue, IssueComment } from './github';\r\nimport { CommentComponent } from './comment-component';\r\nimport { scheduleMeasure } from './measure';\r\n\r\nexport class TimelineComponent {\r\n public readonly element: HTMLElement;\r\n private readonly timeline: CommentComponent[] = [];\r\n private readonly countAnchor: HTMLAnchorElement;\r\n private readonly marker: Node;\r\n private count: number = 0;\r\n\r\n constructor(\r\n private user: User | null,\r\n private issue: Issue | null\r\n ) {\r\n this.element = document.createElement('main');\r\n this.element.classList.add('timeline');\r\n this.element.innerHTML = `\r\n <h1 class=\"timeline-header\">\r\n <a class=\"text-link\" target=\"_blank\"></a>\r\n <em>\r\n - powered by\r\n <a class=\"text-link\" href=\"https://utteranc.es\" target=\"_blank\">utteranc.es</a>\r\n </em>\r\n </h1>`;\r\n this.countAnchor = this.element.firstElementChild!.firstElementChild as HTMLAnchorElement;\r\n this.marker = document.createComment('marker');\r\n this.element.appendChild(this.marker);\r\n this.setIssue(this.issue);\r\n this.renderCount();\r\n }\r\n\r\n public setUser(user: User | null) {\r\n this.user = user;\r\n const login = user ? user.login : null;\r\n for (let i = 0; i < this.timeline.length; i++) {\r\n this.timeline[i].setCurrentUser(login);\r\n }\r\n scheduleMeasure();\r\n }\r\n\r\n public setIssue(issue: Issue | null) {\r\n this.issue = issue;\r\n if (issue) {\r\n this.count = issue.comments;\r\n this.countAnchor.href = issue.html_url;\r\n this.renderCount();\r\n } else {\r\n this.countAnchor.removeAttribute('href');\r\n }\r\n }\r\n\r\n public insertComment(comment: IssueComment, incrementCount: boolean) {\r\n const component = new CommentComponent(\r\n comment,\r\n this.user ? this.user.login : null,\r\n this.issue!.locked);\r\n\r\n const index = this.timeline.findIndex(x => x.comment.id >= comment.id);\r\n if (index === -1) {\r\n this.timeline.push(component);\r\n this.element.insertBefore(component.element, this.marker);\r\n } else {\r\n const next = this.timeline[index];\r\n const remove = next.comment.id === comment.id;\r\n this.element.insertBefore(component.element, next.element);\r\n this.timeline.splice(index, remove ? 1 : 0, component);\r\n if (remove) {\r\n next.element.remove();\r\n }\r\n }\r\n\r\n if (incrementCount) {\r\n this.count++;\r\n this.renderCount();\r\n }\r\n\r\n scheduleMeasure();\r\n }\r\n\r\n public insertPageLoader(insertAfter: IssueComment, count: number, callback: () => void) {\r\n const { element: insertAfterElement } = this.timeline.find(x => x.comment.id >= insertAfter.id)!;\r\n insertAfterElement.insertAdjacentHTML('afterend', `\r\n <div class=\"page-loader\">\r\n <div class=\"zigzag\"></div>\r\n <button type=\"button\" class=\"btn btn-outline btn-large\">\r\n ${count} hidden items<br/>\r\n <span>Load more...</span>\r\n </button>\r\n </div>\r\n `);\r\n const element = insertAfterElement.nextElementSibling!;\r\n const button = element.lastElementChild! as HTMLButtonElement;\r\n const statusSpan = button.lastElementChild!;\r\n button.onclick = callback;\r\n\r\n return {\r\n setBusy() {\r\n statusSpan.textContent = 'Loading...';\r\n button.disabled = true;\r\n },\r\n remove() {\r\n button.onclick = null;\r\n element.remove();\r\n }\r\n };\r\n }\r\n\r\n private renderCount() {\r\n this.countAnchor.textContent = `${this.count} Comment${this.count === 1 ? '' : 's'}`;\r\n }\r\n}\r\n","import { loadJsonFile } from './github';\r\nimport { pageAttributes } from './page-attributes';\r\n\r\nexport interface RepoConfig {\r\n origins: string[];\r\n}\r\n\r\nlet promise: Promise<RepoConfig>;\r\n\r\nexport function getRepoConfig() {\r\n if (!promise) {\r\n promise = loadJsonFile<RepoConfig>('utterances.json').then(\r\n data => {\r\n if (!Array.isArray(data.origins)) {\r\n data.origins = [];\r\n }\r\n return data;\r\n },\r\n () => ({\r\n origins: [pageAttributes.origin]\r\n })\r\n );\r\n }\r\n\r\n return promise;\r\n}\r\n","import { pageAttributes as page } from './page-attributes';\r\nimport { User, renderMarkdown } from './github';\r\nimport { scheduleMeasure } from './measure';\r\nimport { processRenderedMarkdown } from './comment-component';\r\nimport { getRepoConfig } from './repo-config';\r\nimport { getLoginUrl } from './oauth';\r\n\r\n// tslint:disable-next-line:max-line-length\r\nconst anonymousAvatar = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 14 16\" version=\"1.1\"><path fill=\"rgb(179,179,179)\" fill-rule=\"evenodd\" d=\"M8 10.5L9 14H5l1-3.5L5.25 9h3.5L8 10.5zM10 6H4L2 7h10l-2-1zM9 2L7 3 5 2 4 5h6L9 2zm4.03 7.75L10 9l1 2-2 3h3.22c.45 0 .86-.31.97-.75l.56-2.28c.14-.53-.19-1.08-.72-1.22zM4 9l-3.03.75c-.53.14-.86.69-.72 1.22l.56 2.28c.11.44.52.75.97.75H5l-2-3 1-2z\"></path></svg>`;\r\n// base64 encoding works in IE, Edge. UTF-8 does not.\r\nconst anonymousAvatarUrl = `data:image/svg+xml;base64,${btoa(anonymousAvatar)}`;\r\n\r\nconst nothingToPreview = 'Nothing to preview';\r\n\r\nexport class NewCommentComponent {\r\n public readonly element: HTMLElement;\r\n\r\n private avatarAnchor: HTMLAnchorElement;\r\n private avatar: HTMLImageElement;\r\n private form: HTMLFormElement;\r\n private textarea: HTMLTextAreaElement;\r\n private preview: HTMLDivElement;\r\n private submitButton: HTMLButtonElement;\r\n private signInAnchor: HTMLAnchorElement;\r\n\r\n private submitting = false;\r\n private renderTimeout = 0;\r\n\r\n constructor(\r\n private user: User | null,\r\n private readonly submit: (markdown: string) => Promise<void>\r\n ) {\r\n this.element = document.createElement('article');\r\n this.element.classList.add('timeline-comment');\r\n\r\n this.element.innerHTML = `\r\n <a class=\"avatar\" target=\"_blank\" tabindex=\"-1\">\r\n <img height=\"44\" width=\"44\">\r\n </a>\r\n <form class=\"comment\" accept-charset=\"UTF-8\" action=\"javascript:\">\r\n <header class=\"new-comment-header tabnav\">\r\n <div class=\"tabnav-tabs\" role=\"tablist\">\r\n <button type=\"button\" class=\"tabnav-tab tab-write\"\r\n role=\"tab\" aria-selected=\"true\">\r\n Write\r\n </button>\r\n <button type=\"button\" class=\"tabnav-tab tab-preview\"\r\n role=\"tab\">\r\n Preview\r\n </button>\r\n </div>\r\n </header>\r\n <div class=\"comment-body\">\r\n <textarea class=\"form-control\" placeholder=\"Leave a comment\" aria-label=\"comment\"></textarea>\r\n <div class=\"markdown-body\" style=\"display: none\">\r\n ${nothingToPreview}\r\n </div>\r\n </div>\r\n <footer class=\"new-comment-footer\">\r\n <a class=\"text-link markdown-info\" tabindex=\"-1\" target=\"_blank\"\r\n href=\"https://guides.github.com/features/mastering-markdown/\">\r\n <svg class=\"octicon v-align-bottom\" viewBox=\"0 0 16 16\" version=\"1.1\"\r\n width=\"16\" height=\"16\" aria-hidden=\"true\">\r\n <path fill-rule=\"evenodd\" d=\"M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15\r\n 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4\r\n 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z\">\r\n </path>\r\n </svg>\r\n Styling with Markdown is supported\r\n </a>\r\n <button class=\"btn btn-primary\" type=\"submit\">Comment</button>\r\n <a class=\"btn btn-primary\" href=\"${getLoginUrl(page.url)}\" target=\"_top\">Sign in to comment</a>\r\n </footer>\r\n </form>`;\r\n\r\n this.avatarAnchor = this.element.firstElementChild as HTMLAnchorElement;\r\n this.avatar = this.avatarAnchor.firstElementChild as HTMLImageElement;\r\n this.form = this.avatarAnchor.nextElementSibling as HTMLFormElement;\r\n this.textarea = this.form!.firstElementChild!.nextElementSibling!.firstElementChild as HTMLTextAreaElement;\r\n this.preview = this.form!.firstElementChild!.nextElementSibling!.lastElementChild as HTMLDivElement;\r\n this.signInAnchor = this.form!.lastElementChild!.lastElementChild! as HTMLAnchorElement;\r\n this.submitButton = this.signInAnchor.previousElementSibling! as HTMLButtonElement;\r\n\r\n this.setUser(user);\r\n this.submitButton.disabled = true;\r\n\r\n this.textarea.addEventListener('input', this.handleInput);\r\n this.form.addEventListener('submit', this.handleSubmit);\r\n this.form.addEventListener('click', this.handleClick);\r\n this.form.addEventListener('keydown', this.handleKeyDown);\r\n handleTextAreaResize(this.textarea);\r\n }\r\n\r\n public setUser(user: User | null) {\r\n this.user = user;\r\n this.submitButton.hidden = !user;\r\n this.signInAnchor.hidden = !!user;\r\n if (user) {\r\n this.avatarAnchor.href = user.html_url;\r\n this.avatar.alt = '@' + user.login;\r\n this.avatar.src = user.avatar_url + '?v=3&s=88';\r\n this.textarea.disabled = false;\r\n this.textarea.placeholder = 'Leave a comment';\r\n } else {\r\n this.avatarAnchor.removeAttribute('href');\r\n this.avatar.alt = '@anonymous';\r\n this.avatar.src = anonymousAvatarUrl;\r\n this.textarea.disabled = true;\r\n this.textarea.placeholder = 'Sign in to comment';\r\n }\r\n }\r\n\r\n public clear() {\r\n this.textarea.value = '';\r\n }\r\n\r\n private handleInput = () => {\r\n getRepoConfig(); // preload repo config\r\n const text = this.textarea.value;\r\n const isWhitespace = /^\\s*$/.test(text);\r\n this.submitButton.disabled = isWhitespace;\r\n if (this.textarea.scrollHeight < 450 && this.textarea.offsetHeight < this.textarea.scrollHeight) {\r\n this.textarea.style.height = `${this.textarea.scrollHeight}px`;\r\n scheduleMeasure();\r\n }\r\n\r\n clearTimeout(this.renderTimeout);\r\n if (isWhitespace) {\r\n this.preview.textContent = nothingToPreview;\r\n } else {\r\n this.preview.textContent = 'Loading preview...';\r\n this.renderTimeout = setTimeout(\r\n () => renderMarkdown(text).then(html => this.preview.innerHTML = html)\r\n .then(() => processRenderedMarkdown(this.preview))\r\n .then(scheduleMeasure),\r\n 500);\r\n }\r\n }\r\n\r\n private handleSubmit = async (event: Event) => {\r\n event.preventDefault();\r\n if (this.submitting) {\r\n return;\r\n }\r\n this.submitting = true;\r\n this.textarea.disabled = true;\r\n this.submitButton.disabled = true;\r\n await this.submit(this.textarea.value).catch(() => 0);\r\n this.submitting = false;\r\n this.textarea.disabled = !this.user;\r\n this.textarea.value = '';\r\n this.submitButton.disabled = false;\r\n this.handleClick({ ...event, target: this.form.querySelector('.tabnav-tab.tab-write') });\r\n this.preview.textContent = nothingToPreview;\r\n }\r\n\r\n private handleClick = ({ target }: Event) => {\r\n if (!(target instanceof HTMLButtonElement) || !target.classList.contains('tabnav-tab')) {\r\n return;\r\n }\r\n if (target.getAttribute('aria-selected') === 'true') {\r\n return;\r\n }\r\n this.form.querySelector('.tabnav-tab[aria-selected=\"true\"]')!.setAttribute('aria-selected', 'false');\r\n target.setAttribute('aria-selected', 'true');\r\n const isPreview = target.classList.contains('tab-preview');\r\n this.textarea.style.display = isPreview ? 'none' : '';\r\n this.preview.style.display = isPreview ? '' : 'none';\r\n scheduleMeasure();\r\n }\r\n\r\n private handleKeyDown = ({ which, ctrlKey }: KeyboardEvent) => {\r\n if (which === 13 && ctrlKey && !this.submitButton.disabled) {\r\n this.form.dispatchEvent(new CustomEvent('submit'));\r\n }\r\n }\r\n}\r\n\r\nfunction handleTextAreaResize(textarea: HTMLTextAreaElement) {\r\n const stopTracking = () => {\r\n removeEventListener('mousemove', scheduleMeasure);\r\n removeEventListener('mouseup', stopTracking);\r\n };\r\n const track = () => {\r\n addEventListener('mousemove', scheduleMeasure);\r\n addEventListener('mouseup', stopTracking);\r\n };\r\n textarea.addEventListener('mousedown', track);\r\n}\r\n","export function loadTheme(theme: string, origin: string) {\r\n return new Promise(resolve => {\r\n const link = document.createElement('link');\r\n link.rel = 'stylesheet';\r\n link.setAttribute('crossorigin', 'anonymous');\r\n link.onload = resolve;\r\n link.href = `/stylesheets/themes/${theme}/utterances.css`;\r\n document.head.appendChild(link);\r\n\r\n addEventListener('message', event => {\r\n if (event.origin === origin && event.data.type === 'set-theme') {\r\n link.href = `/stylesheets/themes/${event.data.theme}/utterances.css`;\r\n }\r\n });\r\n });\r\n}\r\n","import { pageAttributes as page } from './page-attributes';\r\nimport {\r\n Issue,\r\n setRepoContext,\r\n loadIssueByTerm,\r\n loadIssueByNumber,\r\n loadCommentsPage,\r\n loadUser,\r\n postComment,\r\n createIssue,\r\n PAGE_SIZE,\r\n IssueComment\r\n} from './github';\r\nimport { TimelineComponent } from './timeline-component';\r\nimport { NewCommentComponent } from './new-comment-component';\r\nimport { startMeasuring, scheduleMeasure } from './measure';\r\nimport { loadTheme } from './theme';\r\nimport { getRepoConfig } from './repo-config';\r\nimport { loadToken } from './oauth';\r\nimport { enableReactions } from './reactions';\r\n\r\nsetRepoContext(page);\r\n\r\nfunction loadIssue(): Promise<Issue | null> {\r\n if (page.issueNumber !== null) {\r\n return loadIssueByNumber(page.issueNumber);\r\n }\r\n return loadIssueByTerm(page.issueTerm as string);\r\n}\r\n\r\nasync function bootstrap() {\r\n await loadToken();\r\n // tslint:disable-next-line:prefer-const\r\n let [issue, user] = await Promise.all([\r\n loadIssue(),\r\n loadUser(),\r\n loadTheme(page.theme, page.origin)\r\n ]);\r\n\r\n startMeasuring(page.origin);\r\n\r\n const timeline = new TimelineComponent(user, issue);\r\n document.body.appendChild(timeline.element);\r\n\r\n if (issue && issue.comments > 0) {\r\n renderComments(issue, timeline);\r\n }\r\n\r\n scheduleMeasure();\r\n\r\n if (issue && issue.locked) {\r\n return;\r\n }\r\n\r\n if (!issue && page.autocreate) {\r\n await assertOrigin();\r\n issue = await createIssue(\r\n page.issueTerm as string,\r\n page.url,\r\n page.title,\r\n page.description || '',\r\n page.label\r\n );\r\n timeline.setIssue(issue);\r\n }\r\n\r\n enableReactions(!!user);\r\n\r\n const submit = async (markdown: string) => {\r\n await assertOrigin();\r\n if (!issue) {\r\n issue = await createIssue(\r\n page.issueTerm as string,\r\n page.url,\r\n page.title,\r\n page.description || '',\r\n page.label\r\n );\r\n timeline.setIssue(issue);\r\n }\r\n const comment = await postComment(issue.number, markdown);\r\n timeline.insertComment(comment, true);\r\n newCommentComponent.clear();\r\n };\r\n\r\n const newCommentComponent = new NewCommentComponent(user, submit);\r\n timeline.element.appendChild(newCommentComponent.element);\r\n}\r\n\r\nbootstrap();\r\n\r\naddEventListener('not-installed', function handleNotInstalled() {\r\n removeEventListener('not-installed', handleNotInstalled);\r\n document.querySelector('.timeline')!.insertAdjacentHTML('afterbegin', `\r\n <div class=\"flash flash-error\">\r\n Error: utterances is not installed on <code>${page.owner}/${page.repo}</code>.\r\n If you own this repo,\r\n <a href=\"https://github.com/apps/utterances\" target=\"_top\"><strong>install the app</strong></a>.\r\n Read more about this change in\r\n <a href=\"https://github.com/utterance/utterances/pull/25\" target=\"_top\">the PR</a>.\r\n </div>`);\r\n scheduleMeasure();\r\n});\r\n\r\nasync function renderComments(issue: Issue, timeline: TimelineComponent) {\r\n const renderPage = (page: IssueComment[]) => {\r\n for (const comment of page) {\r\n timeline.insertComment(comment, false);\r\n }\r\n };\r\n\r\n const pageCount = Math.ceil(issue.comments / PAGE_SIZE);\r\n // always load the first page.\r\n const pageLoads = [loadCommentsPage(issue.number, 1)];\r\n // if there are multiple pages, load the last page.\r\n if (pageCount > 1) {\r\n pageLoads.push(loadCommentsPage(issue.number, pageCount));\r\n }\r\n // if the last page is small, load the penultimate page.\r\n if (pageCount > 2 && issue.comments % PAGE_SIZE < 3) {\r\n pageLoads.push(loadCommentsPage(issue.number, pageCount - 1));\r\n }\r\n // await all loads to reduce jank.\r\n const pages = await Promise.all(pageLoads);\r\n for (const page of pages) {\r\n renderPage(page);\r\n }\r\n // enable loading hidden pages.\r\n let hiddenPageCount = pageCount - pageLoads.length;\r\n let nextHiddenPage = 2;\r\n const renderLoader = (afterPage: IssueComment[]) => {\r\n if (hiddenPageCount === 0) {\r\n return;\r\n }\r\n const load = async () => {\r\n loader.setBusy();\r\n const page = await loadCommentsPage(issue.number, nextHiddenPage);\r\n loader.remove();\r\n renderPage(page);\r\n hiddenPageCount--;\r\n nextHiddenPage++;\r\n renderLoader(page);\r\n };\r\n const afterComment = afterPage.pop()!;\r\n const loader = timeline.insertPageLoader(afterComment, hiddenPageCount * PAGE_SIZE, load);\r\n };\r\n renderLoader(pages[0]);\r\n}\r\n\r\nexport async function assertOrigin() {\r\n const { origins } = await getRepoConfig();\r\n const { origin, owner, repo } = page;\r\n if (origins.indexOf(origin) !== -1) {\r\n return;\r\n }\r\n\r\n document.querySelector('.timeline')!.lastElementChild!.insertAdjacentHTML('beforebegin', `\r\n <div class=\"flash flash-error flash-not-installed\">\r\n Error: <code>${origin}</code> is not permitted to post to <code>${owner}/${repo}</code>.\r\n Confirm this is the correct repo for this site's comments. If you own this repo,\r\n <a href=\"https://github.com/${owner}/${repo}/edit/master/utterances.json\" target=\"_top\">\r\n <strong>update the utterances.json</strong>\r\n </a>\r\n to include <code>${origin}</code> in the list of origins.<br/><br/>\r\n Suggested configuration:<br/>\r\n <pre><code>${JSON.stringify({ origins: [origin] }, null, 2)}</code></pre>\r\n </div>`);\r\n scheduleMeasure();\r\n throw new Error('Origin not permitted.');\r\n}\r\n"]}