This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrading to latest ARC standards
- Loading branch information
Showing
95 changed files
with
9,349 additions
and
8,218 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
coverage/ | ||
test/ | ||
demo/ | ||
gen-tsd.json | ||
CONTRIBUTING.md | ||
.travis.yml | ||
index.html | ||
polymer.json | ||
karma.* | ||
husky.* | ||
commitlint.* | ||
.* | ||
*.config.* | ||
prettier.config.js |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"cSpell.words": [ | ||
"CURLE", | ||
"CURLOPT", | ||
"CUSTOMREQUEST", | ||
"Ccurl", | ||
"FOLLOWLOCATION", | ||
"HTTPHEADER", | ||
"Lcode", | ||
"POSTFIELDS", | ||
"clazz", | ||
"clike", | ||
"fitcontainer", | ||
"getheaders", | ||
"getresponse", | ||
"httplib", | ||
"klass", | ||
"libcurl", | ||
"prismjs", | ||
"scrollable", | ||
"setopt", | ||
"slist", | ||
"strerror", | ||
"tfprintf" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,7 @@ | ||
/** | ||
* DO NOT EDIT | ||
* | ||
* This file was automatically generated by | ||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations | ||
* | ||
* To modify these typings, edit the source file(s): | ||
* async-fetch-js-http-snippet.js | ||
*/ | ||
|
||
|
||
// tslint:disable:variable-name Describing an API that's defined elsewhere. | ||
// tslint:disable:no-any describes the API as best we are able today | ||
|
||
import {BaseCodeSnippet} from './base-code-snippet.js'; | ||
|
||
declare namespace ApiElements { | ||
|
||
/** | ||
* `fetch-js-http-snippet` | ||
* | ||
* A snippet for requests made in JavaScript using Fetch API. | ||
* | ||
* ### Styling | ||
* | ||
* See `http-code-snippets` for styling documentation. | ||
*/ | ||
class AsyncFetchJsHttpSnippet extends BaseCodeSnippet { | ||
readonly lang: any; | ||
constructor(); | ||
|
||
/** | ||
* Computes code for JavaScript (Fetch API). | ||
* | ||
* @returns Complete code for given arguments | ||
*/ | ||
_computeCommand(url: String|null, method: String|null, headers: Array<object|null>|null|undefined, payload: String|null): String|null; | ||
_createHeaders(headers: any): any; | ||
_createPayload(payload: any): any; | ||
} | ||
} | ||
import { AsyncFetchJsHttpSnippetElement } from './src/JavaScript/AsyncFetchJsHttpSnippetElement'; | ||
|
||
declare global { | ||
|
||
interface HTMLElementTagNameMap { | ||
"async-fetch-js-http-snippet": ApiElements.AsyncFetchJsHttpSnippet; | ||
"async-fetch-js-http-snippet": AsyncFetchJsHttpSnippetElement; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,3 @@ | ||
/** | ||
@license | ||
Copyright 2018 The Advanced REST client authors <[email protected]> | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy of | ||
the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
License for the specific language governing permissions and limitations under | ||
the License. | ||
*/ | ||
import { BaseCodeSnippet } from './base-code-snippet.js'; | ||
/** | ||
* `fetch-js-http-snippet` | ||
* | ||
* A snippet for requests made in JavaScript using Fetch API. | ||
* | ||
* ### Styling | ||
* | ||
* See `http-code-snippets` for styling documentation. | ||
* | ||
* @customElement | ||
* @demo demo/fetch-js.html Fetch (JavaScript) demo | ||
* @memberof ApiElements | ||
* @extends BaseCodeSnippet | ||
*/ | ||
class AsyncFetchJsHttpSnippet extends BaseCodeSnippet { | ||
get lang() { | ||
return 'javascript'; | ||
} | ||
import { AsyncFetchJsHttpSnippetElement } from './src/JavaScript/AsyncFetchJsHttpSnippetElement.js'; | ||
|
||
/** | ||
* Computes code for JavaScript (Fetch API). | ||
* @param {String} url | ||
* @param {String} method | ||
* @param {Array<Object>|undefined} headers | ||
* @param {String} payload | ||
* @return {String} Complete code for given arguments | ||
*/ | ||
_computeCommand(url, method, headers, payload) { | ||
if (!url || !method) { | ||
return ''; | ||
} | ||
const hasHeaders = !!(headers && headers instanceof Array && headers.length); | ||
const hasPayload = !!payload; | ||
const hasInit = hasHeaders || hasPayload || !!(method && method !== 'GET'); | ||
let result = '(async () => {\n'; | ||
|
||
if (hasInit) { | ||
if (hasHeaders) { | ||
result += this._createHeaders(headers); | ||
} | ||
if (hasPayload) { | ||
result += this._createPayload(payload); | ||
} | ||
result += ' const init = {\n'; | ||
result += ` method: '${method}'`; | ||
if (hasHeaders) { | ||
result += `,\n headers`; | ||
} | ||
if (hasPayload) { | ||
result += `,\n body`; | ||
} | ||
result += '\n'; | ||
result += ' };\n\n'; | ||
} | ||
|
||
result += ` const response = await fetch('${url}'`; | ||
if (hasInit) { | ||
result += ', init'; | ||
} | ||
result += ');\n'; | ||
result += ' console.log(`response status is ${response.status}`);\n'; | ||
result += ' const mediaType = response.headers.get(\'content-type\');\n'; | ||
result += ' let data;\n'; | ||
result += ' if (mediaType.includes(\'json\')) {\n'; | ||
result += ' data = await response.json();\n'; | ||
result += ' } else {\n'; | ||
result += ' data = await response.text();\n'; | ||
result += ' }\n'; | ||
result += ' console.log(data);\n'; | ||
result += '})();'; | ||
return result; | ||
} | ||
|
||
_createHeaders(headers) { | ||
let result = ' const headers = new Headers();\n'; | ||
for (let i = 0, len = headers.length; i < len; i++) { | ||
const h = headers[i]; | ||
result += ` headers.append('${h.name}', '${h.value}');\n`; | ||
} | ||
result += '\n'; | ||
return result; | ||
} | ||
|
||
_createPayload(payload) { | ||
// return ` const body = \`${payload}\`;\n\n`; | ||
let result = ' const body = `'; | ||
const list = payload.split('\n'); | ||
const size = list.length; | ||
list.forEach((line, i) => { | ||
const nl = i + 1 === size ? '' : '\n' | ||
const spaces = i === 0 ? '' : ' '; | ||
result += `${spaces}${line}${nl}`; | ||
}); | ||
result += '`;\n\n'; | ||
return result; | ||
} | ||
} | ||
window.customElements.define('async-fetch-js-http-snippet', AsyncFetchJsHttpSnippet); | ||
window.customElements.define('async-fetch-js-http-snippet', AsyncFetchJsHttpSnippetElement); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,2 @@ | ||
/** | ||
* DO NOT EDIT | ||
* | ||
* This file was automatically generated by | ||
* https://github.com/Polymer/tools/tree/master/packages/gen-typescript-declarations | ||
* | ||
* To modify these typings, edit the source file(s): | ||
* base-code-snippet.js | ||
*/ | ||
|
||
|
||
// tslint:disable:variable-name Describing an API that's defined elsewhere. | ||
// tslint:disable:no-any describes the API as best we are able today | ||
|
||
import {LitElement, html} from 'lit-element'; | ||
|
||
export {BaseCodeSnippet}; | ||
|
||
declare namespace ApiElements { | ||
|
||
/** | ||
* `base-code-snippet` | ||
* | ||
* A class to be used to extend other code snippets elements. | ||
* | ||
* Each child class has to have `lang` property to be used to recognize the | ||
* syntax. If syntax is different than the default PrismJs set then it has to | ||
* be imported into the DOM. | ||
* | ||
* Each child class must implement `_processCommand()` function which results | ||
* to a code to highlight. It takes 4 attributes (in order): url, method, | ||
* headers, and payload. | ||
* Mind that all atguments are optional. | ||
* | ||
* If the child class implements it's own template, it should contain | ||
* `<code></code>` inside the template where the highlighted value is | ||
* added. | ||
* | ||
* Parent element, presumably `http-code-snippets`, or main document | ||
* must include `prism-element/prism-highlighter.html` in it's DOM. | ||
* | ||
* ### Styling | ||
* | ||
* See `http-code-snippets` for styling documentation. | ||
*/ | ||
class BaseCodeSnippet extends LitElement { | ||
|
||
/** | ||
* Request URL | ||
*/ | ||
url: string|null|undefined; | ||
|
||
/** | ||
* HTTP method | ||
*/ | ||
method: string|null|undefined; | ||
|
||
/** | ||
* Parsed HTTP headers. | ||
* Each item contains `name` and `value` properties. | ||
*/ | ||
headers: Array<object|null>|null; | ||
|
||
/** | ||
* HTTP body (the message) | ||
*/ | ||
payload: string|null|undefined; | ||
readonly _code: any; | ||
|
||
/** | ||
* Enables compatibility with Anypoint components. | ||
*/ | ||
compatibility: boolean|null|undefined; | ||
constructor(); | ||
connectedCallback(): void; | ||
disconnectedCallback(): void; | ||
render(): any; | ||
_setProp(prop: any, value: any): void; | ||
_sop(prop: any, value: any): any; | ||
|
||
/** | ||
* Clears timeout from the debouncer if set. | ||
*/ | ||
_clearValueTimeout(): void; | ||
|
||
/** | ||
* Computes code value with debouncer. | ||
*/ | ||
_valuesChanged(): void; | ||
|
||
/** | ||
* Processes command by calling, respectively, `_computeCommand()` and | ||
* `_highlight()`. The result is added to the `<code>` block in the template. | ||
*/ | ||
_processCommand(): void; | ||
_computeCommand(): void; | ||
_highlight(code: any, lang: any): any; | ||
|
||
/** | ||
* Reads the host, port and path from the url. | ||
* This function uses URI library to parse the URL so you have to | ||
* include this library from bower_components if the element want to use it. | ||
*/ | ||
urlDetails(url: String|null): object|null; | ||
_copyToClipboard(): void; | ||
|
||
/** | ||
* Sends the `content-copy` event. | ||
* If the event is canceled then the logic from this element won't be | ||
* executed. Useful if current platform doesn't support `execCommand('copy')` | ||
* and has other way to manage clipboard. | ||
* | ||
* @param value The value to dispatch with the event. | ||
* @returns True if handler executed copy function. | ||
*/ | ||
_beforeCopy(value: String|null): Boolean|null; | ||
} | ||
} | ||
|
||
declare global { | ||
|
||
interface HTMLElementTagNameMap { | ||
"base-code-snippet": ApiElements.BaseCodeSnippet; | ||
} | ||
} | ||
// left for compatibility. Do not use this file. | ||
export { BaseCodeSnippet } from './src/BaseCodeSnippet' |
Oops, something went wrong.