new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _crypto = _interopRequireDefault(require("crypto"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function md5(bytes) {
|
||||
if (Array.isArray(bytes)) {
|
||||
bytes = Buffer.from(bytes);
|
||||
} else if (typeof bytes === 'string') {
|
||||
bytes = Buffer.from(bytes, 'utf8');
|
||||
}
|
||||
|
||||
return _crypto.default.createHash('md5').update(bytes).digest();
|
||||
}
|
||||
|
||||
var _default = md5;
|
||||
exports.default = _default;
|
||||
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
var _ = {
|
||||
sum: require('lodash/sum'),
|
||||
flatten: require('lodash/flatten'),
|
||||
};
|
||||
var chalk = require('chalk');
|
||||
|
||||
/**
|
||||
* The paginator returns a subset of the choices if the list is too long.
|
||||
*/
|
||||
|
||||
class Paginator {
|
||||
constructor(screen, options = {}) {
|
||||
const { isInfinite = true } = options;
|
||||
this.lastIndex = 0;
|
||||
this.screen = screen;
|
||||
this.isInfinite = isInfinite;
|
||||
}
|
||||
|
||||
paginate(output, active, pageSize) {
|
||||
pageSize = pageSize || 7;
|
||||
var lines = output.split('\n');
|
||||
|
||||
if (this.screen) {
|
||||
lines = this.screen.breakLines(lines);
|
||||
active = _.sum(lines.map((lineParts) => lineParts.length).splice(0, active));
|
||||
lines = _.flatten(lines);
|
||||
}
|
||||
|
||||
// Make sure there's enough lines to paginate
|
||||
if (lines.length <= pageSize) {
|
||||
return output;
|
||||
}
|
||||
const visibleLines = this.isInfinite
|
||||
? this.getInfiniteLines(lines, active, pageSize)
|
||||
: this.getFiniteLines(lines, active, pageSize);
|
||||
this.lastIndex = active;
|
||||
return (
|
||||
visibleLines.join('\n') +
|
||||
'\n' +
|
||||
chalk.dim('(Move up and down to reveal more choices)')
|
||||
);
|
||||
}
|
||||
|
||||
getInfiniteLines(lines, active, pageSize) {
|
||||
if (this.pointer === undefined) {
|
||||
this.pointer = 0;
|
||||
}
|
||||
var middleOfList = Math.floor(pageSize / 2);
|
||||
// Move the pointer only when the user go down and limit it to the middle of the list
|
||||
if (
|
||||
this.pointer < middleOfList &&
|
||||
this.lastIndex < active &&
|
||||
active - this.lastIndex < pageSize
|
||||
) {
|
||||
this.pointer = Math.min(middleOfList, this.pointer + active - this.lastIndex);
|
||||
}
|
||||
|
||||
// Duplicate the lines so it give an infinite list look
|
||||
var infinite = _.flatten([lines, lines, lines]);
|
||||
var topIndex = Math.max(0, active + lines.length - this.pointer);
|
||||
|
||||
return infinite.splice(topIndex, pageSize);
|
||||
}
|
||||
|
||||
getFiniteLines(lines, active, pageSize) {
|
||||
var topIndex = active - pageSize / 2;
|
||||
if (topIndex < 0) {
|
||||
topIndex = 0;
|
||||
} else if (topIndex + pageSize > lines.length) {
|
||||
topIndex = lines.length - pageSize;
|
||||
}
|
||||
return lines.splice(topIndex, pageSize);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Paginator;
|
||||
@@ -0,0 +1,10 @@
|
||||
export declare const dirty_components: any[];
|
||||
export declare const intros: {
|
||||
enabled: boolean;
|
||||
};
|
||||
export declare const binding_callbacks: any[];
|
||||
export declare function schedule_update(): void;
|
||||
export declare function tick(): Promise<void>;
|
||||
export declare function add_render_callback(fn: any): void;
|
||||
export declare function add_flush_callback(fn: any): void;
|
||||
export declare function flush(): void;
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { MessageObject } from './types';
|
||||
import { $locale } from './stores/locale';
|
||||
import { init } from './configs';
|
||||
import { registerLocaleLoader } from './includes/loaderQueue';
|
||||
import { getLocaleFromHostname, getLocaleFromPathname, getLocaleFromNavigator, getLocaleFromQueryString, getLocaleFromHash } from './includes/localeGetters';
|
||||
import { $dictionary, $locales, addMessages } from './stores/dictionary';
|
||||
import { $isLoading } from './stores/loading';
|
||||
import { $format, $formatDate, $formatNumber, $formatTime, $getJSON } from './stores/formatters';
|
||||
import { getDateFormatter, getNumberFormatter, getTimeFormatter, getMessageFormatter } from './includes/formatters';
|
||||
export declare function defineMessages(i: Record<string, MessageObject>): Record<string, MessageObject>;
|
||||
export declare function waitLocale(locale?: string): Promise<void>;
|
||||
export { init, addMessages, registerLocaleLoader as register, $locale as locale, $dictionary as dictionary, $locales as locales, $isLoading as isLoading, $format as format, $format as _, $format as t, $formatDate as date, $formatNumber as number, $formatTime as time, $getJSON as json, getDateFormatter, getNumberFormatter, getTimeFormatter, getMessageFormatter, getLocaleFromHostname, getLocaleFromPathname, getLocaleFromNavigator, getLocaleFromQueryString, getLocaleFromHash, };
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/operator/ignoreElements';
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"auto-changelog","version":"2.2.1","files":{"templates/compact.hbs":{"checkedAt":1678887829154,"integrity":"sha512-h7TW43PpiNN6C2OBVI+WJsdGKEk+tBlbuRoDeGpofvbfljTWy9STjduaaApL4pgEsQ12Gb/otTalYGlLLBBmxg==","mode":420,"size":923},"templates/json.hbs":{"checkedAt":1678887829154,"integrity":"sha512-ksWN+G1AmFNWJ4mKOgCi3M1wr4yzA7GDzLyE7AkHdhiQIbGPTEvG1M8Hpaaw9VRFUSH5US2F6DBexFEib1MbqA==","mode":420,"size":18},"templates/keepachangelog.hbs":{"checkedAt":1678887829154,"integrity":"sha512-jayWzuC68CmcR5yQIuUdoXzU3HhTelyWbrlyLkHGxDA8lSeKyFblNf6PM+8EqHfa5rcTTbXHU4Jet+5JKd2dSA==","mode":420,"size":1184},"src/index.js":{"checkedAt":1678887829154,"integrity":"sha512-Uvfx3y+TiuXmE9NrbO/9LisBk1+wQafuP453veFWU8NZofd9hhT2Jybjd1k7A5Cna2N4a7Yc0UNWTVY61ltJTQ==","mode":493,"size":154},"src/remote.js":{"checkedAt":1678887829161,"integrity":"sha512-wAkKE1L7akU5xAh5WIVa+4yG0EYpUz8rTk/A/CTd4FSYlBV5By8oFtXD28WRMK5reMOmW5z6iV9/J/Nlid5hSQ==","mode":420,"size":3375},"src/utils.js":{"checkedAt":1678887829167,"integrity":"sha512-lxXRYUtyNQ3q8CepXcl704vi0R9mE4ITHvd18UhQYYMKmnNv91s8k2tA0pnFqbG0cktG23h6MkAU1SEEPuS6Iw==","mode":420,"size":2750},"src/releases.js":{"checkedAt":1678887829161,"integrity":"sha512-AqLz35hV58O5xd8qSeqn4ntTBPNVjXbneH3ybpe9w5WBbIdw8AHowHmsPFVrEgvORLAvGIs4dKDaVm4h1r9uuw==","mode":420,"size":2722},"src/commits.js":{"checkedAt":1678887829161,"integrity":"sha512-diZW0FWMjrkzVS+GeQOAmo5zqGm24kfa59j80zhqbvOGLmAxOiw6LXeLxF1lmI4p3TOIxlQYHOH7ZMykIh9OgQ==","mode":420,"size":4270},"src/tags.js":{"checkedAt":1678887829167,"integrity":"sha512-FdUgKC8dYsWuW0LzX0iR6iYstgBvCKOyHvgbbYp4A2o2sk3h+7zqM+uDa7QbTXzzgGCdnPri2vShdMFev8tCSQ==","mode":420,"size":2727},"src/template.js":{"checkedAt":1678887829167,"integrity":"sha512-L852QsEzNMgE7Rz75zUzUi0ANFAXq/TwdmfeX0Pdyjr1U5M5aODA8JX673FYkmzqj3aY1JFWq1t1p/HLvg2Pzw==","mode":420,"size":2615},"src/run.js":{"checkedAt":1678887829167,"integrity":"sha512-BrJNn08659lTVS/IUHFYGYhZ6LDBLmx4mD/dlqFLcemMaoGD9gBCQ2QHT1xacZn0FG5yRMPFk3jR2SjH/UiLBg==","mode":420,"size":5499},"CONTRIBUTING.md":{"checkedAt":1678887829182,"integrity":"sha512-I+N7RQ4mklc9CAlr5vmHQLHJv0jkWQpWGQhxpn30HJlww6Cy3MZXlch96Ju5tmEDd8uIWDX/hQRU5C1M/23GVg==","mode":420,"size":922},"LICENSE.md":{"checkedAt":1678887829182,"integrity":"sha512-dqy0Hxr41se/yDEMx/5vsa8aD/f61xc+ehg+l7EPWioEBfXA2IDB+rNF2AK3DoX8nil7lGRdnntmTG0gaHW0yA==","mode":420,"size":1091},"package.json":{"checkedAt":1678887829175,"integrity":"sha512-Sm5sSRjpogJoQjkLDNJqGk3bpmPSC/MHQ+0ADp21EccRx6kVYwAkp1eatjoU08RaI0yVWtk1v7CPe1Es7FD6UA==","mode":420,"size":2505},"CHANGELOG.md":{"checkedAt":1678887829185,"integrity":"sha512-MnA7nmVC7By3SDz4NIjVIo9cttECGcNcnafwIrXhfQoiwkgxVdTuxZTvCDkoXonN55tTrTp6/48ZKr/bJ3A73Q==","mode":420,"size":28053},"README.md":{"checkedAt":1678887829192,"integrity":"sha512-zTy2TJNNEKqG5GNAiab/h5jDPnOjPJb3985VhaFpPjVSXGIVFKXYjJUBywoKtNsggKmALWPy13RhZK1k3NONOQ==","mode":420,"size":12945}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"name":"tslib","version":"1.14.1","files":{"tslib.es6.html":{"checkedAt":1678887830118,"integrity":"sha512-aoAR2zaxE9UtcXO4kE9FbPBgIZEVk7u3Z+nEPmDo6rwcYth07KxrVZejVEdy2XmKvkkcb8O/XM9UK3bPc1iMPw==","mode":420,"size":36},"tslib.html":{"checkedAt":1678887830118,"integrity":"sha512-4dCvZ5WYJpcbIJY4RPUhOBbFud1156Rr7RphuR12/+mXKUeIpCxol2/uWL4WDFNNlSH909M2AY4fiLWJo8+fTw==","mode":420,"size":32},"test/validateModuleExportsMatchCommonJS/index.js":{"checkedAt":1678887830111,"integrity":"sha512-xVfc6Ue5k5CIcU0BPJpBfo040Itj7+dOweMJ99CDAuviekkxB4wTGkDOIjMV1PZ53WJB+aipj2xI5rcXiaT8cA==","mode":420,"size":824},"tslib.es6.js":{"checkedAt":1678887830111,"integrity":"sha512-gQP2x1VN5mZ7aKEh3OlIKjoFLUxChqCeThg3QMJacLPnroUdeEsYLxRzoKlN6Q/Gzyb7rTUh5cISB6/C3cl7zQ==","mode":420,"size":10274},"modules/index.js":{"checkedAt":1678887830111,"integrity":"sha512-aZWdWA2SHtDRKU5KSZBN+b1oDQcqqv2kx7ZW1M0lXoaC7oO3wU7WWKVbRDtUBrEhEUnB/hcEViY4ZpnNiuto4A==","mode":420,"size":943},"tslib.js":{"checkedAt":1678887830118,"integrity":"sha512-8l0HmhYnEA0z8NJS/CK9U1tDk9x3ILCrx38WfJilyI+B9XGgYBD73NP74vJeC1zg7YJCwZmHvZIrR1gMnKLY8g==","mode":420,"size":13204},"package.json":{"checkedAt":1678887830118,"integrity":"sha512-6zdzuH07kfTNLZKoDCHd/xMYnFAfHhfAYYPz4LMcyVr2bJnFt+NrOT2feyP69WbZwc1iN5TDbineHflnCOGavQ==","mode":420,"size":915},"modules/package.json":{"checkedAt":1678887830130,"integrity":"sha512-vm8hQn5MuoMkjJYvBBHTAtsdrcuXmVrKZwL3FEq32oGiKFhY562FoUQTbXv24wk0rwJVpgribUCOIU98IaS9Mg==","mode":420,"size":26},"README.md":{"checkedAt":1678887830130,"integrity":"sha512-f5gnoIAERp1Xhy37XlQbxFbrpmhdfmUER5ffNVTAuka017hUnZQXjzpisWuuuLOCf3HuulUhy+ak7/pO+QhcpQ==","mode":420,"size":3447},"CopyrightNotice.txt":{"checkedAt":1678887830130,"integrity":"sha512-oeL8IRggYkzPQ0Q8DbBukWGsG/4vr40bD8utORy9ff1luhXcq1N+pCo1spcSfSUTUJ+7gJ0GvWZrO46asNC5EA==","mode":420,"size":824},"LICENSE.txt":{"checkedAt":1678887830137,"integrity":"sha512-9cs1Im06/fLAPBpXOY8fHMD2LgUM3kREaKlOX7S6fLWwbG5G+UqlUrqdkTKloRPeDghECezxOiUfzvW6lnEjDg==","mode":420,"size":655},"tslib.d.ts":{"checkedAt":1678887830130,"integrity":"sha512-ocbLCmqW6sFtkrGysFY8AzOdSEQpsvTVQ73tBIHwuuTex5RNxRpZSLIs8/pjIFQkx/dFyiGBtygQZQgpKmbPYA==","mode":420,"size":2714},"test/validateModuleExportsMatchCommonJS/package.json":{"checkedAt":1678887830130,"integrity":"sha512-eLEVXKKLjhFD99X9SXl2NJ2puv/O0+YUxqy2po41hBEwtDJfAEYFqzNZHZPSOHQWomiAQ5zxbfqNhJVKG4ePoQ==","mode":420,"size":71}}}
|
||||
@@ -0,0 +1,503 @@
|
||||
'use strict'
|
||||
|
||||
let MapGenerator = require('./map-generator')
|
||||
let { isClean } = require('./symbols')
|
||||
let stringify = require('./stringify')
|
||||
let warnOnce = require('./warn-once')
|
||||
let Result = require('./result')
|
||||
let parse = require('./parse')
|
||||
let Root = require('./root')
|
||||
|
||||
const TYPE_TO_CLASS_NAME = {
|
||||
root: 'Root',
|
||||
atrule: 'AtRule',
|
||||
rule: 'Rule',
|
||||
decl: 'Declaration',
|
||||
comment: 'Comment'
|
||||
}
|
||||
|
||||
const PLUGIN_PROPS = {
|
||||
postcssPlugin: true,
|
||||
prepare: true,
|
||||
Once: true,
|
||||
Root: true,
|
||||
Declaration: true,
|
||||
Rule: true,
|
||||
AtRule: true,
|
||||
Comment: true,
|
||||
DeclarationExit: true,
|
||||
RuleExit: true,
|
||||
AtRuleExit: true,
|
||||
CommentExit: true,
|
||||
RootExit: true,
|
||||
OnceExit: true
|
||||
}
|
||||
|
||||
const NOT_VISITORS = {
|
||||
postcssPlugin: true,
|
||||
prepare: true,
|
||||
Once: true
|
||||
}
|
||||
|
||||
const CHILDREN = 0
|
||||
|
||||
function isPromise(obj) {
|
||||
return typeof obj === 'object' && typeof obj.then === 'function'
|
||||
}
|
||||
|
||||
function getEvents(node) {
|
||||
let key = false
|
||||
let type = TYPE_TO_CLASS_NAME[node.type]
|
||||
if (node.type === 'decl') {
|
||||
key = node.prop.toLowerCase()
|
||||
} else if (node.type === 'atrule') {
|
||||
key = node.name.toLowerCase()
|
||||
}
|
||||
|
||||
if (key && node.append) {
|
||||
return [
|
||||
type,
|
||||
type + '-' + key,
|
||||
CHILDREN,
|
||||
type + 'Exit',
|
||||
type + 'Exit-' + key
|
||||
]
|
||||
} else if (key) {
|
||||
return [type, type + '-' + key, type + 'Exit', type + 'Exit-' + key]
|
||||
} else if (node.append) {
|
||||
return [type, CHILDREN, type + 'Exit']
|
||||
} else {
|
||||
return [type, type + 'Exit']
|
||||
}
|
||||
}
|
||||
|
||||
function toStack(node) {
|
||||
let events
|
||||
if (node.type === 'root') {
|
||||
events = ['Root', CHILDREN, 'RootExit']
|
||||
} else {
|
||||
events = getEvents(node)
|
||||
}
|
||||
|
||||
return {
|
||||
node,
|
||||
events,
|
||||
eventIndex: 0,
|
||||
visitors: [],
|
||||
visitorIndex: 0,
|
||||
iterator: 0
|
||||
}
|
||||
}
|
||||
|
||||
function cleanMarks(node) {
|
||||
node[isClean] = false
|
||||
if (node.nodes) node.nodes.forEach(i => cleanMarks(i))
|
||||
return node
|
||||
}
|
||||
|
||||
let postcss = {}
|
||||
|
||||
class LazyResult {
|
||||
constructor(processor, css, opts) {
|
||||
this.stringified = false
|
||||
this.processed = false
|
||||
|
||||
let root
|
||||
if (typeof css === 'object' && css !== null && css.type === 'root') {
|
||||
root = cleanMarks(css)
|
||||
} else if (css instanceof LazyResult || css instanceof Result) {
|
||||
root = cleanMarks(css.root)
|
||||
if (css.map) {
|
||||
if (typeof opts.map === 'undefined') opts.map = {}
|
||||
if (!opts.map.inline) opts.map.inline = false
|
||||
opts.map.prev = css.map
|
||||
}
|
||||
} else {
|
||||
let parser = parse
|
||||
if (opts.syntax) parser = opts.syntax.parse
|
||||
if (opts.parser) parser = opts.parser
|
||||
if (parser.parse) parser = parser.parse
|
||||
|
||||
try {
|
||||
root = parser(css, opts)
|
||||
} catch (error) {
|
||||
this.processed = true
|
||||
this.error = error
|
||||
}
|
||||
}
|
||||
|
||||
this.result = new Result(processor, root, opts)
|
||||
this.helpers = { ...postcss, result: this.result, postcss }
|
||||
this.plugins = this.processor.plugins.map(plugin => {
|
||||
if (typeof plugin === 'object' && plugin.prepare) {
|
||||
return { ...plugin, ...plugin.prepare(this.result) }
|
||||
} else {
|
||||
return plugin
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
return 'LazyResult'
|
||||
}
|
||||
|
||||
get processor() {
|
||||
return this.result.processor
|
||||
}
|
||||
|
||||
get opts() {
|
||||
return this.result.opts
|
||||
}
|
||||
|
||||
get css() {
|
||||
return this.stringify().css
|
||||
}
|
||||
|
||||
get content() {
|
||||
return this.stringify().content
|
||||
}
|
||||
|
||||
get map() {
|
||||
return this.stringify().map
|
||||
}
|
||||
|
||||
get root() {
|
||||
return this.sync().root
|
||||
}
|
||||
|
||||
get messages() {
|
||||
return this.sync().messages
|
||||
}
|
||||
|
||||
warnings() {
|
||||
return this.sync().warnings()
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.css
|
||||
}
|
||||
|
||||
then(onFulfilled, onRejected) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!('from' in this.opts)) {
|
||||
warnOnce(
|
||||
'Without `from` option PostCSS could generate wrong source map ' +
|
||||
'and will not find Browserslist config. Set it to CSS file path ' +
|
||||
'or to `undefined` to prevent this warning.'
|
||||
)
|
||||
}
|
||||
}
|
||||
return this.async().then(onFulfilled, onRejected)
|
||||
}
|
||||
|
||||
catch(onRejected) {
|
||||
return this.async().catch(onRejected)
|
||||
}
|
||||
|
||||
finally(onFinally) {
|
||||
return this.async().then(onFinally, onFinally)
|
||||
}
|
||||
|
||||
async() {
|
||||
if (this.error) return Promise.reject(this.error)
|
||||
if (this.processed) return Promise.resolve(this.result)
|
||||
if (!this.processing) {
|
||||
this.processing = this.runAsync()
|
||||
}
|
||||
return this.processing
|
||||
}
|
||||
|
||||
sync() {
|
||||
if (this.error) throw this.error
|
||||
if (this.processed) return this.result
|
||||
this.processed = true
|
||||
|
||||
if (this.processing) {
|
||||
throw this.getAsyncError()
|
||||
}
|
||||
|
||||
for (let plugin of this.plugins) {
|
||||
let promise = this.runOnRoot(plugin)
|
||||
if (isPromise(promise)) {
|
||||
throw this.getAsyncError()
|
||||
}
|
||||
}
|
||||
|
||||
this.prepareVisitors()
|
||||
if (this.hasListener) {
|
||||
let root = this.result.root
|
||||
while (!root[isClean]) {
|
||||
root[isClean] = true
|
||||
this.walkSync(root)
|
||||
}
|
||||
if (this.listeners.OnceExit) {
|
||||
this.visitSync(this.listeners.OnceExit, root)
|
||||
}
|
||||
}
|
||||
|
||||
return this.result
|
||||
}
|
||||
|
||||
stringify() {
|
||||
if (this.error) throw this.error
|
||||
if (this.stringified) return this.result
|
||||
this.stringified = true
|
||||
|
||||
this.sync()
|
||||
|
||||
let opts = this.result.opts
|
||||
let str = stringify
|
||||
if (opts.syntax) str = opts.syntax.stringify
|
||||
if (opts.stringifier) str = opts.stringifier
|
||||
if (str.stringify) str = str.stringify
|
||||
|
||||
let map = new MapGenerator(str, this.result.root, this.result.opts)
|
||||
let data = map.generate()
|
||||
this.result.css = data[0]
|
||||
this.result.map = data[1]
|
||||
|
||||
return this.result
|
||||
}
|
||||
|
||||
walkSync(node) {
|
||||
node[isClean] = true
|
||||
let events = getEvents(node)
|
||||
for (let event of events) {
|
||||
if (event === CHILDREN) {
|
||||
if (node.nodes) {
|
||||
node.each(child => {
|
||||
if (!child[isClean]) this.walkSync(child)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
let visitors = this.listeners[event]
|
||||
if (visitors) {
|
||||
if (this.visitSync(visitors, node.toProxy())) return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitSync(visitors, node) {
|
||||
for (let [plugin, visitor] of visitors) {
|
||||
this.result.lastPlugin = plugin
|
||||
let promise
|
||||
try {
|
||||
promise = visitor(node, this.helpers)
|
||||
} catch (e) {
|
||||
throw this.handleError(e, node.proxyOf)
|
||||
}
|
||||
if (node.type !== 'root' && !node.parent) return true
|
||||
if (isPromise(promise)) {
|
||||
throw this.getAsyncError()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runOnRoot(plugin) {
|
||||
this.result.lastPlugin = plugin
|
||||
try {
|
||||
if (typeof plugin === 'object' && plugin.Once) {
|
||||
return plugin.Once(this.result.root, this.helpers)
|
||||
} else if (typeof plugin === 'function') {
|
||||
return plugin(this.result.root, this.result)
|
||||
}
|
||||
} catch (error) {
|
||||
throw this.handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
getAsyncError() {
|
||||
throw new Error('Use process(css).then(cb) to work with async plugins')
|
||||
}
|
||||
|
||||
handleError(error, node) {
|
||||
let plugin = this.result.lastPlugin
|
||||
try {
|
||||
if (node) node.addToError(error)
|
||||
this.error = error
|
||||
if (error.name === 'CssSyntaxError' && !error.plugin) {
|
||||
error.plugin = plugin.postcssPlugin
|
||||
error.setMessage()
|
||||
} else if (plugin.postcssVersion) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
let pluginName = plugin.postcssPlugin
|
||||
let pluginVer = plugin.postcssVersion
|
||||
let runtimeVer = this.result.processor.version
|
||||
let a = pluginVer.split('.')
|
||||
let b = runtimeVer.split('.')
|
||||
|
||||
if (a[0] !== b[0] || parseInt(a[1]) > parseInt(b[1])) {
|
||||
console.error(
|
||||
'Unknown error from PostCSS plugin. Your current PostCSS ' +
|
||||
'version is ' +
|
||||
runtimeVer +
|
||||
', but ' +
|
||||
pluginName +
|
||||
' uses ' +
|
||||
pluginVer +
|
||||
'. Perhaps this is the source of the error below.'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// istanbul ignore next
|
||||
if (console && console.error) console.error(err)
|
||||
}
|
||||
return error
|
||||
}
|
||||
|
||||
async runAsync() {
|
||||
this.plugin = 0
|
||||
for (let i = 0; i < this.plugins.length; i++) {
|
||||
let plugin = this.plugins[i]
|
||||
let promise = this.runOnRoot(plugin)
|
||||
if (isPromise(promise)) {
|
||||
try {
|
||||
await promise
|
||||
} catch (error) {
|
||||
throw this.handleError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.prepareVisitors()
|
||||
if (this.hasListener) {
|
||||
let root = this.result.root
|
||||
while (!root[isClean]) {
|
||||
root[isClean] = true
|
||||
let stack = [toStack(root)]
|
||||
while (stack.length > 0) {
|
||||
let promise = this.visitTick(stack)
|
||||
if (isPromise(promise)) {
|
||||
try {
|
||||
await promise
|
||||
} catch (e) {
|
||||
let node = stack[stack.length - 1].node
|
||||
throw this.handleError(e, node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.listeners.OnceExit) {
|
||||
for (let [plugin, visitor] of this.listeners.OnceExit) {
|
||||
this.result.lastPlugin = plugin
|
||||
try {
|
||||
await visitor(root, this.helpers)
|
||||
} catch (e) {
|
||||
throw this.handleError(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.processed = true
|
||||
return this.stringify()
|
||||
}
|
||||
|
||||
prepareVisitors() {
|
||||
this.listeners = {}
|
||||
let add = (plugin, type, cb) => {
|
||||
if (!this.listeners[type]) this.listeners[type] = []
|
||||
this.listeners[type].push([plugin, cb])
|
||||
}
|
||||
for (let plugin of this.plugins) {
|
||||
if (typeof plugin === 'object') {
|
||||
for (let event in plugin) {
|
||||
if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) {
|
||||
throw new Error(
|
||||
`Unknown event ${event} in ${plugin.postcssPlugin}. ` +
|
||||
`Try to update PostCSS (${this.processor.version} now).`
|
||||
)
|
||||
}
|
||||
if (!NOT_VISITORS[event]) {
|
||||
if (typeof plugin[event] === 'object') {
|
||||
for (let filter in plugin[event]) {
|
||||
if (filter === '*') {
|
||||
add(plugin, event, plugin[event][filter])
|
||||
} else {
|
||||
add(
|
||||
plugin,
|
||||
event + '-' + filter.toLowerCase(),
|
||||
plugin[event][filter]
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (typeof plugin[event] === 'function') {
|
||||
add(plugin, event, plugin[event])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hasListener = Object.keys(this.listeners).length > 0
|
||||
}
|
||||
|
||||
visitTick(stack) {
|
||||
let visit = stack[stack.length - 1]
|
||||
let { node, visitors } = visit
|
||||
|
||||
if (node.type !== 'root' && !node.parent) {
|
||||
stack.pop()
|
||||
return
|
||||
}
|
||||
|
||||
if (visitors.length > 0 && visit.visitorIndex < visitors.length) {
|
||||
let [plugin, visitor] = visitors[visit.visitorIndex]
|
||||
visit.visitorIndex += 1
|
||||
if (visit.visitorIndex === visitors.length) {
|
||||
visit.visitors = []
|
||||
visit.visitorIndex = 0
|
||||
}
|
||||
this.result.lastPlugin = plugin
|
||||
try {
|
||||
return visitor(node.toProxy(), this.helpers)
|
||||
} catch (e) {
|
||||
throw this.handleError(e, node)
|
||||
}
|
||||
}
|
||||
|
||||
if (visit.iterator !== 0) {
|
||||
let iterator = visit.iterator
|
||||
let child
|
||||
while ((child = node.nodes[node.indexes[iterator]])) {
|
||||
node.indexes[iterator] += 1
|
||||
if (!child[isClean]) {
|
||||
child[isClean] = true
|
||||
stack.push(toStack(child))
|
||||
return
|
||||
}
|
||||
}
|
||||
visit.iterator = 0
|
||||
delete node.indexes[iterator]
|
||||
}
|
||||
|
||||
let events = visit.events
|
||||
while (visit.eventIndex < events.length) {
|
||||
let event = events[visit.eventIndex]
|
||||
visit.eventIndex += 1
|
||||
if (event === CHILDREN) {
|
||||
if (node.nodes && node.nodes.length) {
|
||||
node[isClean] = true
|
||||
visit.iterator = node.getIterator()
|
||||
}
|
||||
return
|
||||
} else if (this.listeners[event]) {
|
||||
visit.visitors = this.listeners[event]
|
||||
return
|
||||
}
|
||||
}
|
||||
stack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
LazyResult.registerPostcss = dependant => {
|
||||
postcss = dependant
|
||||
}
|
||||
|
||||
module.exports = LazyResult
|
||||
LazyResult.default = LazyResult
|
||||
|
||||
Root.registerLazyResult(LazyResult)
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"Commands:": "Komennot:",
|
||||
"Options:": "Valinnat:",
|
||||
"Examples:": "Esimerkkejä:",
|
||||
"boolean": "totuusarvo",
|
||||
"count": "lukumäärä",
|
||||
"string": "merkkijono",
|
||||
"number": "numero",
|
||||
"array": "taulukko",
|
||||
"required": "pakollinen",
|
||||
"default": "oletusarvo",
|
||||
"default:": "oletusarvo:",
|
||||
"choices:": "vaihtoehdot:",
|
||||
"aliases:": "aliakset:",
|
||||
"generated-value": "generoitu-arvo",
|
||||
"Not enough non-option arguments: got %s, need at least %s": {
|
||||
"one": "Liian vähän argumentteja, jotka eivät ole valintoja: annettu %s, vaaditaan vähintään %s",
|
||||
"other": "Liian vähän argumentteja, jotka eivät ole valintoja: annettu %s, vaaditaan vähintään %s"
|
||||
},
|
||||
"Too many non-option arguments: got %s, maximum of %s": {
|
||||
"one": "Liikaa argumentteja, jotka eivät ole valintoja: annettu %s, sallitaan enintään %s",
|
||||
"other": "Liikaa argumentteja, jotka eivät ole valintoja: annettu %s, sallitaan enintään %s"
|
||||
},
|
||||
"Missing argument value: %s": {
|
||||
"one": "Argumentin arvo puuttuu: %s",
|
||||
"other": "Argumentin arvot puuttuvat: %s"
|
||||
},
|
||||
"Missing required argument: %s": {
|
||||
"one": "Pakollinen argumentti puuttuu: %s",
|
||||
"other": "Pakollisia argumentteja puuttuu: %s"
|
||||
},
|
||||
"Unknown argument: %s": {
|
||||
"one": "Tuntematon argumenttn: %s",
|
||||
"other": "Tuntemattomia argumentteja: %s"
|
||||
},
|
||||
"Invalid values:": "Virheelliset arvot:",
|
||||
"Argument: %s, Given: %s, Choices: %s": "Argumentti: %s, Annettu: %s, Vaihtoehdot: %s",
|
||||
"Argument check failed: %s": "Argumentin tarkistus epäonnistui: %s",
|
||||
"Implications failed:": "Riippuvia argumentteja puuttuu:",
|
||||
"Not enough arguments following: %s": "Argumentin perässä ei ole tarpeeksi argumentteja: %s",
|
||||
"Invalid JSON config file: %s": "Epävalidi JSON-asetustiedosto: %s",
|
||||
"Path to JSON config file": "JSON-asetustiedoston polku",
|
||||
"Show help": "Näytä ohje",
|
||||
"Show version number": "Näytä versionumero",
|
||||
"Did you mean %s?": "Tarkoititko %s?",
|
||||
"Arguments %s and %s are mutually exclusive" : "Argumentit %s ja %s eivät ole yhteensopivat",
|
||||
"Positionals:": "Sijaintiparametrit:",
|
||||
"command": "komento"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"132":"J E F G A B BC"},B:{"132":"C K L H M N O","388":"P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"132":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"132":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB","388":"EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"1":"sB 6B 7B 8B NC","132":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B"},F:{"132":"0 G B C H M N O v w x y z OC PC QC RC qB 9B SC rB","388":"1 2 3 4 5 6 7 8 9 AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d"},G:{"1":"sB 6B 7B 8B","132":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B"},H:{"132":"nC"},I:{"132":"tB I oC pC qC rC AC sC tC","388":"D"},J:{"132":"E A"},K:{"132":"A B C qB 9B rB","388":"e"},L:{"388":"D"},M:{"132":"D"},N:{"132":"A B"},O:{"388":"uC"},P:{"132":"I","388":"vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"388":"1B"},R:{"388":"8C"},S:{"132":"9C"}},B:4,C:"CSS text-indent"};
|
||||
@@ -0,0 +1,28 @@
|
||||
const ora = require('ora');
|
||||
const { format } = require('./util');
|
||||
|
||||
const noop = Promise.resolve();
|
||||
|
||||
class Spinner {
|
||||
constructor({ container = {} } = {}) {
|
||||
this.config = container.config;
|
||||
this.ora = container.ora || ora;
|
||||
}
|
||||
show({ enabled = true, task, label, external = false, context }) {
|
||||
if (!enabled) return noop;
|
||||
|
||||
const { config } = this;
|
||||
this.isSpinnerDisabled = !config.isCI || config.isVerbose || config.isDryRun || config.isDebug;
|
||||
this.canForce = !config.isCI && !config.isVerbose && !config.isDryRun && !config.isDebug;
|
||||
|
||||
const awaitTask = task();
|
||||
|
||||
if (!this.isSpinnerDisabled || (external && this.canForce)) {
|
||||
const text = format(label, context);
|
||||
this.ora.promise(awaitTask, text);
|
||||
}
|
||||
return awaitTask;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Spinner;
|
||||
@@ -0,0 +1,551 @@
|
||||
# request.js
|
||||
|
||||
> Send parameterized requests to GitHub’s APIs with sensible defaults in browsers and Node
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/request)
|
||||
[](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amaster)
|
||||
|
||||
`@octokit/request` is a request library for browsers & node that makes it easier
|
||||
to interact with [GitHub’s REST API](https://developer.github.com/v3/) and
|
||||
[GitHub’s GraphQL API](https://developer.github.com/v4/guides/forming-calls/#the-graphql-endpoint).
|
||||
|
||||
It uses [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) to parse
|
||||
the passed options and sends the request using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
([node-fetch](https://github.com/bitinn/node-fetch) in Node).
|
||||
|
||||
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Features](#features)
|
||||
- [Usage](#usage)
|
||||
- [REST API example](#rest-api-example)
|
||||
- [GraphQL example](#graphql-example)
|
||||
- [Alternative: pass `method` & `url` as part of options](#alternative-pass-method--url-as-part-of-options)
|
||||
- [Authentication](#authentication)
|
||||
- [request()](#request)
|
||||
- [`request.defaults()`](#requestdefaults)
|
||||
- [`request.endpoint`](#requestendpoint)
|
||||
- [Special cases](#special-cases)
|
||||
- [The `data` parameter – set request body directly](#the-data-parameter-%E2%80%93-set-request-body-directly)
|
||||
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
|
||||
- [LICENSE](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Features
|
||||
|
||||
🤩 1:1 mapping of REST API endpoint documentation, e.g. [Add labels to an issue](https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue) becomes
|
||||
|
||||
```js
|
||||
request("POST /repos/{owner}/{repo}/issues/{number}/labels", {
|
||||
mediaType: {
|
||||
previews: ["symmetra"],
|
||||
},
|
||||
owner: "octokit",
|
||||
repo: "request.js",
|
||||
number: 1,
|
||||
labels: ["🐛 bug"],
|
||||
});
|
||||
```
|
||||
|
||||
👶 [Small bundle size](https://bundlephobia.com/result?p=@octokit/request@5.0.3) (\<4kb minified + gzipped)
|
||||
|
||||
😎 [Authenticate](#authentication) with any of [GitHubs Authentication Strategies](https://github.com/octokit/auth.js).
|
||||
|
||||
👍 Sensible defaults
|
||||
|
||||
- `baseUrl`: `https://api.github.com`
|
||||
- `headers.accept`: `application/vnd.github.v3+json`
|
||||
- `headers.agent`: `octokit-request.js/<current version> <OS information>`, e.g. `octokit-request.js/1.2.3 Node.js/10.15.0 (macOS Mojave; x64)`
|
||||
|
||||
👌 Simple to test: mock requests by passing a custom fetch method.
|
||||
|
||||
🧐 Simple to debug: Sets `error.request` to request options causing the error (with redacted credentials).
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/request</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { request } from "https://cdn.skypack.dev/@octokit/request";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/request</code>
|
||||
|
||||
```js
|
||||
const { request } = require("@octokit/request");
|
||||
// or: import { request } from "@octokit/request";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### REST API example
|
||||
|
||||
```js
|
||||
// Following GitHub docs formatting:
|
||||
// https://developer.github.com/v3/repos/#list-organization-repositories
|
||||
const result = await request("GET /orgs/{org}/repos", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
console.log(`${result.data.length} repos found.`);
|
||||
```
|
||||
|
||||
### GraphQL example
|
||||
|
||||
For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/octokit/graphql.js#readme)
|
||||
|
||||
```js
|
||||
const result = await request("POST /graphql", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
query: `query ($login: String!) {
|
||||
organization(login: $login) {
|
||||
repositories(privacy: PRIVATE) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
login: "octokit",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Alternative: pass `method` & `url` as part of options
|
||||
|
||||
Alternatively, pass in a method and a url
|
||||
|
||||
```js
|
||||
const result = await request({
|
||||
method: "GET",
|
||||
url: "/orgs/{org}/repos",
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
The simplest way to authenticate a request is to set the `Authorization` header directly, e.g. to a [personal access token](https://github.com/settings/tokens/).
|
||||
|
||||
```js
|
||||
const requestWithAuth = request.defaults({
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
});
|
||||
const result = await requestWithAuth("GET /user");
|
||||
```
|
||||
|
||||
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
|
||||
|
||||
```js
|
||||
const { createAppAuth } = require("@octokit/auth-app");
|
||||
const auth = createAppAuth({
|
||||
appId: process.env.APP_ID,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
installationId: 123,
|
||||
});
|
||||
const requestWithAuth = request.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
mediaType: {
|
||||
previews: ["machine-man"],
|
||||
},
|
||||
});
|
||||
|
||||
const { data: app } = await requestWithAuth("GET /app");
|
||||
const { data: app } = await requestWithAuth(
|
||||
"POST /repos/{owner}/{repo}/issues",
|
||||
{
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
title: "Hello from the engine room",
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## request()
|
||||
|
||||
`request(route, options)` or `request(options)`.
|
||||
|
||||
**Options**
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
name
|
||||
</th>
|
||||
<th align=left>
|
||||
type
|
||||
</th>
|
||||
<th align=left>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>route</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
**Required**. If <code>route</code> is set it has to be a string consisting of the request method and URL, e.g. <code>GET /orgs/{org}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
The base URL that <code>route</code> or <code>url</code> will be prefixed with, if they use relative paths. <em>Defaults to <code>https://api.github.com</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<th align=left>
|
||||
<code>options.headers</code>
|
||||
</th>
|
||||
<td>
|
||||
Object
|
||||
</td>
|
||||
<td>
|
||||
Custom headers. Passed headers are merged with defaults:<br>
|
||||
<em><code>headers['user-agent']</code> defaults to <code>octokit-rest.js/1.2.3</code> (where <code>1.2.3</code> is the released version)</em>.<br>
|
||||
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code>.<br> Use <code>options.mediaType.{format,previews}</code> to request API previews and custom media types.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.mediaType.format</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Media type param, such as `raw`, `html`, or `full`. See <a href="https://developer.github.com/v3/media/">Media Types</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.mediaType.previews</code>
|
||||
</th>
|
||||
<td>
|
||||
Array of strings
|
||||
</td>
|
||||
<td>
|
||||
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://developer.github.com/v3/previews/">API Previews</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.method</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>Get</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.url</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
**Required**. A path or full URL which may contain <code>:variable</code> or <code>{variable}</code> placeholders,
|
||||
e.g. <code>/orgs/{org}/repos</code>. The <code>url</code> is parsed using <a href="https://github.com/bramstein/url-template">url-template</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.data</code>
|
||||
</th>
|
||||
<td>
|
||||
Any
|
||||
</td>
|
||||
<td>
|
||||
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The `data` parameter"</a> below.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.agent</code>
|
||||
</th>
|
||||
<td>
|
||||
<a href="https://nodejs.org/api/http.html#http_class_http_agent">http(s).Agent</a> instance
|
||||
</td>
|
||||
<td>
|
||||
Node only. Useful for custom proxy, certificate, or dns lookup.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.fetch</code>
|
||||
</th>
|
||||
<td>
|
||||
Function
|
||||
</td>
|
||||
<td>
|
||||
Custom replacement for <a href="https://github.com/bitinn/node-fetch">built-in fetch method</a>. Useful for testing or request hooks.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.hook</code>
|
||||
</th>
|
||||
<td>
|
||||
Function
|
||||
</td>
|
||||
<td>
|
||||
Function with the signature <code>hook(request, endpointOptions)</code>, where <code>endpointOptions</code> are the parsed options as returned by <a href="https://github.com/octokit/endpoint.js#endpointmergeroute-options-or-endpointmergeoptions"><code>endpoint.merge()</code></a>, and <code>request</code> is <a href="https://github.com/octokit/request.js#request"><code>request()</code></a>. This option works great in conjuction with <a href="https://github.com/gr2m/before-after-hook">before-after-hook</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<a name="options-request-signal"></a><code>options.request.signal</code>
|
||||
</th>
|
||||
<td>
|
||||
<a href="https://github.com/bitinn/node-fetch/tree/e996bdab73baf996cf2dbf25643c8fe2698c3249#request-cancellation-with-abortsignal">new AbortController().signal</a>
|
||||
</td>
|
||||
<td>
|
||||
Use an <code>AbortController</code> instance to cancel a request. In node you can only cancel streamed requests.
|
||||
</td>
|
||||
</tr>
|
||||
<th align=left>
|
||||
<code>options.request.log</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>object</code>
|
||||
</td>
|
||||
<td>
|
||||
Used for internal logging. Defaults to <a href="https://developer.mozilla.org/en-US/docs/Web/API/console"><code>console</code></a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.timeout</code>
|
||||
</th>
|
||||
<td>
|
||||
Number
|
||||
</td>
|
||||
<td>
|
||||
Node only. Request/response timeout in ms, it resets on redirect. 0 to disable (OS limit applies). <a href="#options-request-signal">options.request.signal</a> is recommended instead.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
All other options except `options.request.*` will be passed depending on the `method` and `url` options.
|
||||
|
||||
1. If the option key is a placeholder in the `url`, it will be used as replacement. For example, if the passed options are `{url: '/orgs/{org}/repos', org: 'foo'}` the returned `options.url` is `https://api.github.com/orgs/foo/repos`
|
||||
2. If the `method` is `GET` or `HEAD`, the option is passed as query parameter
|
||||
3. Otherwise the parameter is passed in the request body as JSON key.
|
||||
|
||||
**Result**
|
||||
|
||||
`request` returns a promise and resolves with 4 keys
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
key
|
||||
</th>
|
||||
<th align=left>
|
||||
type
|
||||
</th>
|
||||
<th align=left>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th align=left><code>status</code></th>
|
||||
<td>Integer</td>
|
||||
<td>Response status status</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>url</code></th>
|
||||
<td>String</td>
|
||||
<td>URL of response. If a request results in redirects, this is the final URL. You can send a <code>HEAD</code> request to retrieve it without loading the full response body.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>headers</code></th>
|
||||
<td>Object</td>
|
||||
<td>All response headers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>data</code></th>
|
||||
<td>Any</td>
|
||||
<td>The response body as returned from server. If the response is JSON then it will be parsed into an object</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
If an error occurs, the `error` instance has additional properties to help with debugging
|
||||
|
||||
- `error.status` The http response status code
|
||||
- `error.request` The request options such as `method`, `url` and `data`
|
||||
- `error.response` The http response object with `url`, `headers`, and `data`
|
||||
|
||||
## `request.defaults()`
|
||||
|
||||
Override or set default options. Example:
|
||||
|
||||
```js
|
||||
const myrequest = require("@octokit/request").defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
org: "my-project",
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
myrequest(`GET /orgs/{org}/repos`);
|
||||
```
|
||||
|
||||
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
||||
|
||||
```js
|
||||
const myProjectRequest = request.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
const myProjectRequestWithAuth = myProjectRequest.defaults({
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`myProjectRequest` now defaults the `baseUrl`, `headers['user-agent']`,
|
||||
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
||||
by the global default.
|
||||
|
||||
## `request.endpoint`
|
||||
|
||||
See https://github.com/octokit/endpoint.js. Example
|
||||
|
||||
```js
|
||||
const options = request.endpoint("GET /orgs/{org}/repos", {
|
||||
org: "my-project",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
// {
|
||||
// method: 'GET',
|
||||
// url: 'https://api.github.com/orgs/my-project/repos?type=private',
|
||||
// headers: {
|
||||
// accept: 'application/vnd.github.v3+json',
|
||||
// authorization: 'token 0000000000000000000000000000000000000001',
|
||||
// 'user-agent': 'octokit/endpoint.js v1.2.3'
|
||||
// }
|
||||
// }
|
||||
```
|
||||
|
||||
All of the [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) API can be used:
|
||||
|
||||
- [`octokitRequest.endpoint()`](#endpoint)
|
||||
- [`octokitRequest.endpoint.defaults()`](#endpointdefaults)
|
||||
- [`octokitRequest.endpoint.merge()`](#endpointdefaults)
|
||||
- [`octokitRequest.endpoint.parse()`](#endpointmerge)
|
||||
|
||||
## Special cases
|
||||
|
||||
<a name="data-parameter"></a>
|
||||
|
||||
### The `data` parameter – set request body directly
|
||||
|
||||
Some endpoints such as [Render a Markdown document in raw mode](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode) don’t have parameters that are sent as request body keys, instead the request body needs to be set directly. In these cases, set the `data` parameter.
|
||||
|
||||
```js
|
||||
const response = await request("POST /markdown/raw", {
|
||||
data: "Hello world github/linguist#1 **cool**, and #1!",
|
||||
headers: {
|
||||
accept: "text/html;charset=utf-8",
|
||||
"content-type": "text/plain",
|
||||
},
|
||||
});
|
||||
|
||||
// Request is sent as
|
||||
//
|
||||
// {
|
||||
// method: 'post',
|
||||
// url: 'https://api.github.com/markdown/raw',
|
||||
// headers: {
|
||||
// accept: 'text/html;charset=utf-8',
|
||||
// 'content-type': 'text/plain',
|
||||
// 'user-agent': userAgent
|
||||
// },
|
||||
// body: 'Hello world github/linguist#1 **cool**, and #1!'
|
||||
// }
|
||||
//
|
||||
// not as
|
||||
//
|
||||
// {
|
||||
// ...
|
||||
// body: '{"data": "Hello world github/linguist#1 **cool**, and #1!"}'
|
||||
// }
|
||||
```
|
||||
|
||||
### Set parameters for both the URL/query and the request body
|
||||
|
||||
There are API endpoints that accept both query parameters as well as a body. In that case you need to add the query parameters as templates to `options.url`, as defined in the [RFC 6570 URI Template specification](https://tools.ietf.org/html/rfc6570).
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
request(
|
||||
"POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
|
||||
{
|
||||
name: "example.zip",
|
||||
label: "short description",
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
"content-length": 14,
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
data: "Hello, world!",
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/operators/merge';
|
||||
@@ -0,0 +1,139 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { isArray } from '../util/isArray';
|
||||
import { fromArray } from './fromArray';
|
||||
import { Operator } from '../Operator';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { TeardownLogic, ObservableInput } from '../types';
|
||||
import { OuterSubscriber } from '../OuterSubscriber';
|
||||
import { InnerSubscriber } from '../InnerSubscriber';
|
||||
import { subscribeToResult } from '../util/subscribeToResult';
|
||||
|
||||
// tslint:disable:max-line-length
|
||||
export function race<A>(arg: [ObservableInput<A>]): Observable<A>;
|
||||
export function race<A, B>(arg: [ObservableInput<A>, ObservableInput<B>]): Observable<A | B>;
|
||||
export function race<A, B, C>(arg: [ObservableInput<A>, ObservableInput<B>, ObservableInput<C>]): Observable<A | B | C>;
|
||||
export function race<A, B, C, D>(arg: [ObservableInput<A>, ObservableInput<B>, ObservableInput<C>, ObservableInput<D>]): Observable<A | B | C | D>;
|
||||
export function race<A, B, C, D, E>(arg: [ObservableInput<A>, ObservableInput<B>, ObservableInput<C>, ObservableInput<D>, ObservableInput<E>]): Observable<A | B | C | D | E>;
|
||||
export function race<T>(arg: ObservableInput<T>[]): Observable<T>;
|
||||
export function race(arg: ObservableInput<any>[]): Observable<{}>;
|
||||
|
||||
export function race<A>(a: ObservableInput<A>): Observable<A>;
|
||||
export function race<A, B>(a: ObservableInput<A>, b: ObservableInput<B>): Observable<A | B>;
|
||||
export function race<A, B, C>(a: ObservableInput<A>, b: ObservableInput<B>, c: ObservableInput<C>): Observable<A | B | C>;
|
||||
export function race<A, B, C, D>(a: ObservableInput<A>, b: ObservableInput<B>, c: ObservableInput<C>, d: ObservableInput<D>): Observable<A | B | C | D>;
|
||||
export function race<A, B, C, D, E>(a: ObservableInput<A>, b: ObservableInput<B>, c: ObservableInput<C>, d: ObservableInput<D>, e: ObservableInput<E>): Observable<A | B | C | D | E>;
|
||||
// tslint:enable:max-line-length
|
||||
|
||||
export function race<T>(observables: ObservableInput<T>[]): Observable<T>;
|
||||
export function race(observables: ObservableInput<any>[]): Observable<{}>;
|
||||
export function race<T>(...observables: ObservableInput<T>[]): Observable<T>;
|
||||
export function race(...observables: ObservableInput<any>[]): Observable<{}>;
|
||||
|
||||
/**
|
||||
* Returns an Observable that mirrors the first source Observable to emit an item.
|
||||
*
|
||||
* ## Example
|
||||
* ### Subscribes to the observable that was the first to start emitting.
|
||||
*
|
||||
* ```ts
|
||||
* import { race, interval } from 'rxjs';
|
||||
* import { mapTo } from 'rxjs/operators';
|
||||
*
|
||||
* const obs1 = interval(1000).pipe(mapTo('fast one'));
|
||||
* const obs2 = interval(3000).pipe(mapTo('medium one'));
|
||||
* const obs3 = interval(5000).pipe(mapTo('slow one'));
|
||||
*
|
||||
* race(obs3, obs1, obs2)
|
||||
* .subscribe(
|
||||
* winner => console.log(winner)
|
||||
* );
|
||||
*
|
||||
* // result:
|
||||
* // a series of 'fast one'
|
||||
* ```
|
||||
*
|
||||
* @param {...Observables} ...observables sources used to race for which Observable emits first.
|
||||
* @return {Observable} an Observable that mirrors the output of the first Observable to emit an item.
|
||||
* @static true
|
||||
* @name race
|
||||
* @owner Observable
|
||||
*/
|
||||
export function race<T>(...observables: ObservableInput<any>[]): Observable<T> {
|
||||
// if the only argument is an array, it was most likely called with
|
||||
// `race([obs1, obs2, ...])`
|
||||
if (observables.length === 1) {
|
||||
if (isArray(observables[0])) {
|
||||
observables = observables[0] as Observable<any>[];
|
||||
} else {
|
||||
return observables[0] as Observable<T>;
|
||||
}
|
||||
}
|
||||
|
||||
return fromArray(observables, undefined).lift(new RaceOperator<T>());
|
||||
}
|
||||
|
||||
export class RaceOperator<T> implements Operator<T, T> {
|
||||
call(subscriber: Subscriber<T>, source: any): TeardownLogic {
|
||||
return source.subscribe(new RaceSubscriber(subscriber));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @ignore
|
||||
* @extends {Ignored}
|
||||
*/
|
||||
export class RaceSubscriber<T> extends OuterSubscriber<T, T> {
|
||||
private hasFirst: boolean = false;
|
||||
private observables: Observable<any>[] = [];
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
constructor(destination: Subscriber<T>) {
|
||||
super(destination);
|
||||
}
|
||||
|
||||
protected _next(observable: any): void {
|
||||
this.observables.push(observable);
|
||||
}
|
||||
|
||||
protected _complete() {
|
||||
const observables = this.observables;
|
||||
const len = observables.length;
|
||||
|
||||
if (len === 0) {
|
||||
this.destination.complete!();
|
||||
} else {
|
||||
for (let i = 0; i < len && !this.hasFirst; i++) {
|
||||
const observable = observables[i];
|
||||
const subscription = subscribeToResult(this, observable, undefined, i)!;
|
||||
|
||||
if (this.subscriptions) {
|
||||
this.subscriptions.push(subscription);
|
||||
}
|
||||
this.add(subscription);
|
||||
}
|
||||
this.observables = null!;
|
||||
}
|
||||
}
|
||||
|
||||
notifyNext(_outerValue: T, innerValue: T,
|
||||
outerIndex: number): void {
|
||||
if (!this.hasFirst) {
|
||||
this.hasFirst = true;
|
||||
|
||||
for (let i = 0; i < this.subscriptions.length; i++) {
|
||||
if (i !== outerIndex) {
|
||||
let subscription = this.subscriptions[i];
|
||||
|
||||
subscription.unsubscribe();
|
||||
this.remove(subscription);
|
||||
}
|
||||
}
|
||||
|
||||
this.subscriptions = null!;
|
||||
}
|
||||
|
||||
this.destination.next!(innerValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WebSocketSubject.js","sources":["../../src/observable/dom/WebSocketSubject.ts"],"names":[],"mappings":";;;;;AAAA,iEAA4D"}
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/operator/throttle");
|
||||
//# sourceMappingURL=throttle.js.map
|
||||
Reference in New Issue
Block a user