new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export function hostReportError(err) {
|
||||
setTimeout(() => { throw err; }, 0);
|
||||
}
|
||||
//# sourceMappingURL=hostReportError.js.map
|
||||
@@ -0,0 +1,181 @@
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const arrayUnion = require('array-union');
|
||||
const merge2 = require('merge2');
|
||||
const fastGlob = require('fast-glob');
|
||||
const dirGlob = require('dir-glob');
|
||||
const gitignore = require('./gitignore');
|
||||
const {FilterStream, UniqueStream} = require('./stream-utils');
|
||||
|
||||
const DEFAULT_FILTER = () => false;
|
||||
|
||||
const isNegative = pattern => pattern[0] === '!';
|
||||
|
||||
const assertPatternsInput = patterns => {
|
||||
if (!patterns.every(pattern => typeof pattern === 'string')) {
|
||||
throw new TypeError('Patterns must be a string or an array of strings');
|
||||
}
|
||||
};
|
||||
|
||||
const checkCwdOption = (options = {}) => {
|
||||
if (!options.cwd) {
|
||||
return;
|
||||
}
|
||||
|
||||
let stat;
|
||||
try {
|
||||
stat = fs.statSync(options.cwd);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stat.isDirectory()) {
|
||||
throw new Error('The `cwd` option must be a path to a directory');
|
||||
}
|
||||
};
|
||||
|
||||
const getPathString = p => p.stats instanceof fs.Stats ? p.path : p;
|
||||
|
||||
const generateGlobTasks = (patterns, taskOptions) => {
|
||||
patterns = arrayUnion([].concat(patterns));
|
||||
assertPatternsInput(patterns);
|
||||
checkCwdOption(taskOptions);
|
||||
|
||||
const globTasks = [];
|
||||
|
||||
taskOptions = {
|
||||
ignore: [],
|
||||
expandDirectories: true,
|
||||
...taskOptions
|
||||
};
|
||||
|
||||
for (const [index, pattern] of patterns.entries()) {
|
||||
if (isNegative(pattern)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const ignore = patterns
|
||||
.slice(index)
|
||||
.filter(pattern => isNegative(pattern))
|
||||
.map(pattern => pattern.slice(1));
|
||||
|
||||
const options = {
|
||||
...taskOptions,
|
||||
ignore: taskOptions.ignore.concat(ignore)
|
||||
};
|
||||
|
||||
globTasks.push({pattern, options});
|
||||
}
|
||||
|
||||
return globTasks;
|
||||
};
|
||||
|
||||
const globDirs = (task, fn) => {
|
||||
let options = {};
|
||||
if (task.options.cwd) {
|
||||
options.cwd = task.options.cwd;
|
||||
}
|
||||
|
||||
if (Array.isArray(task.options.expandDirectories)) {
|
||||
options = {
|
||||
...options,
|
||||
files: task.options.expandDirectories
|
||||
};
|
||||
} else if (typeof task.options.expandDirectories === 'object') {
|
||||
options = {
|
||||
...options,
|
||||
...task.options.expandDirectories
|
||||
};
|
||||
}
|
||||
|
||||
return fn(task.pattern, options);
|
||||
};
|
||||
|
||||
const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern];
|
||||
|
||||
const getFilterSync = options => {
|
||||
return options && options.gitignore ?
|
||||
gitignore.sync({cwd: options.cwd, ignore: options.ignore}) :
|
||||
DEFAULT_FILTER;
|
||||
};
|
||||
|
||||
const globToTask = task => glob => {
|
||||
const {options} = task;
|
||||
if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) {
|
||||
options.ignore = dirGlob.sync(options.ignore);
|
||||
}
|
||||
|
||||
return {
|
||||
pattern: glob,
|
||||
options
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = async (patterns, options) => {
|
||||
const globTasks = generateGlobTasks(patterns, options);
|
||||
|
||||
const getFilter = async () => {
|
||||
return options && options.gitignore ?
|
||||
gitignore({cwd: options.cwd, ignore: options.ignore}) :
|
||||
DEFAULT_FILTER;
|
||||
};
|
||||
|
||||
const getTasks = async () => {
|
||||
const tasks = await Promise.all(globTasks.map(async task => {
|
||||
const globs = await getPattern(task, dirGlob);
|
||||
return Promise.all(globs.map(globToTask(task)));
|
||||
}));
|
||||
|
||||
return arrayUnion(...tasks);
|
||||
};
|
||||
|
||||
const [filter, tasks] = await Promise.all([getFilter(), getTasks()]);
|
||||
const paths = await Promise.all(tasks.map(task => fastGlob(task.pattern, task.options)));
|
||||
|
||||
return arrayUnion(...paths).filter(path_ => !filter(getPathString(path_)));
|
||||
};
|
||||
|
||||
module.exports.sync = (patterns, options) => {
|
||||
const globTasks = generateGlobTasks(patterns, options);
|
||||
|
||||
const tasks = [];
|
||||
for (const task of globTasks) {
|
||||
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
|
||||
tasks.push(...newTask);
|
||||
}
|
||||
|
||||
const filter = getFilterSync(options);
|
||||
|
||||
let matches = [];
|
||||
for (const task of tasks) {
|
||||
matches = arrayUnion(matches, fastGlob.sync(task.pattern, task.options));
|
||||
}
|
||||
|
||||
return matches.filter(path_ => !filter(path_));
|
||||
};
|
||||
|
||||
module.exports.stream = (patterns, options) => {
|
||||
const globTasks = generateGlobTasks(patterns, options);
|
||||
|
||||
const tasks = [];
|
||||
for (const task of globTasks) {
|
||||
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
|
||||
tasks.push(...newTask);
|
||||
}
|
||||
|
||||
const filter = getFilterSync(options);
|
||||
const filterStream = new FilterStream(p => !filter(p));
|
||||
const uniqueStream = new UniqueStream();
|
||||
|
||||
return merge2(tasks.map(task => fastGlob.stream(task.pattern, task.options)))
|
||||
.pipe(filterStream)
|
||||
.pipe(uniqueStream);
|
||||
};
|
||||
|
||||
module.exports.generateGlobTasks = generateGlobTasks;
|
||||
|
||||
module.exports.hasMagic = (patterns, options) => []
|
||||
.concat(patterns)
|
||||
.some(pattern => fastGlob.isDynamicPattern(pattern, options));
|
||||
|
||||
module.exports.gitignore = gitignore;
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"2":"C K L H M N O 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:{"2":"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:{"2":"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 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:{"2":"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 sB 6B 7B 8B NC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 G B C 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 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 OC PC QC RC qB 9B SC rB"},G:{"2":"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 sB 6B 7B 8B"},H:{"2":"nC"},I:{"2":"tB I D oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"2":"A B C e qB 9B rB"},L:{"2":"D"},M:{"2":"D"},N:{"2":"A B"},O:{"2":"uC"},P:{"2":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"2":"9C"}},B:7,C:"CSS3 attr() function for all properties"};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"partition.js","sources":["../../src/add/operator/partition.ts"],"names":[],"mappings":";;AAAA,8CAA4C"}
|
||||
@@ -0,0 +1,214 @@
|
||||
'use strict'
|
||||
|
||||
let { fileURLToPath, pathToFileURL } = require('url')
|
||||
let { resolve, isAbsolute } = require('path')
|
||||
let { nanoid } = require('nanoid/non-secure')
|
||||
|
||||
let terminalHighlight = require('./terminal-highlight')
|
||||
let CssSyntaxError = require('./css-syntax-error')
|
||||
let PreviousMap = require('./previous-map')
|
||||
|
||||
let fromOffsetCache = Symbol('fromOffset cache')
|
||||
|
||||
let pathAvailable = Boolean(resolve && isAbsolute)
|
||||
|
||||
class Input {
|
||||
constructor(css, opts = {}) {
|
||||
if (
|
||||
css === null ||
|
||||
typeof css === 'undefined' ||
|
||||
(typeof css === 'object' && !css.toString)
|
||||
) {
|
||||
throw new Error(`PostCSS received ${css} instead of CSS string`)
|
||||
}
|
||||
|
||||
this.css = css.toString()
|
||||
|
||||
if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
|
||||
this.hasBOM = true
|
||||
this.css = this.css.slice(1)
|
||||
} else {
|
||||
this.hasBOM = false
|
||||
}
|
||||
|
||||
if (opts.from) {
|
||||
if (
|
||||
!pathAvailable ||
|
||||
/^\w+:\/\//.test(opts.from) ||
|
||||
isAbsolute(opts.from)
|
||||
) {
|
||||
this.file = opts.from
|
||||
} else {
|
||||
this.file = resolve(opts.from)
|
||||
}
|
||||
}
|
||||
|
||||
if (pathAvailable) {
|
||||
let map = new PreviousMap(this.css, opts)
|
||||
if (map.text) {
|
||||
this.map = map
|
||||
let file = map.consumer().file
|
||||
if (!this.file && file) this.file = this.mapResolve(file)
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.file) {
|
||||
this.id = '<input css ' + nanoid(6) + '>'
|
||||
}
|
||||
if (this.map) this.map.file = this.from
|
||||
}
|
||||
|
||||
fromOffset(offset) {
|
||||
let lastLine, lineToIndex
|
||||
if (!this[fromOffsetCache]) {
|
||||
let lines = this.css.split('\n')
|
||||
lineToIndex = new Array(lines.length)
|
||||
let prevIndex = 0
|
||||
|
||||
for (let i = 0, l = lines.length; i < l; i++) {
|
||||
lineToIndex[i] = prevIndex
|
||||
prevIndex += lines[i].length + 1
|
||||
}
|
||||
|
||||
this[fromOffsetCache] = lineToIndex
|
||||
} else {
|
||||
lineToIndex = this[fromOffsetCache]
|
||||
}
|
||||
lastLine = lineToIndex[lineToIndex.length - 1]
|
||||
|
||||
let min = 0
|
||||
if (offset >= lastLine) {
|
||||
min = lineToIndex.length - 1
|
||||
} else {
|
||||
let max = lineToIndex.length - 2
|
||||
let mid
|
||||
while (min < max) {
|
||||
mid = min + ((max - min) >> 1)
|
||||
if (offset < lineToIndex[mid]) {
|
||||
max = mid - 1
|
||||
} else if (offset >= lineToIndex[mid + 1]) {
|
||||
min = mid + 1
|
||||
} else {
|
||||
min = mid
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
line: min + 1,
|
||||
col: offset - lineToIndex[min] + 1
|
||||
}
|
||||
}
|
||||
|
||||
error(message, line, column, opts = {}) {
|
||||
let result
|
||||
if (!column) {
|
||||
let pos = this.fromOffset(line)
|
||||
line = pos.line
|
||||
column = pos.col
|
||||
}
|
||||
let origin = this.origin(line, column)
|
||||
if (origin) {
|
||||
result = new CssSyntaxError(
|
||||
message,
|
||||
origin.line,
|
||||
origin.column,
|
||||
origin.source,
|
||||
origin.file,
|
||||
opts.plugin
|
||||
)
|
||||
} else {
|
||||
result = new CssSyntaxError(
|
||||
message,
|
||||
line,
|
||||
column,
|
||||
this.css,
|
||||
this.file,
|
||||
opts.plugin
|
||||
)
|
||||
}
|
||||
|
||||
result.input = { line, column, source: this.css }
|
||||
if (this.file) {
|
||||
if (pathToFileURL) {
|
||||
result.input.url = pathToFileURL(this.file).toString()
|
||||
}
|
||||
result.input.file = this.file
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
origin(line, column) {
|
||||
if (!this.map) return false
|
||||
let consumer = this.map.consumer()
|
||||
|
||||
let from = consumer.originalPositionFor({ line, column })
|
||||
if (!from.source) return false
|
||||
|
||||
let fromUrl
|
||||
|
||||
if (isAbsolute(from.source)) {
|
||||
fromUrl = pathToFileURL(from.source)
|
||||
} else {
|
||||
fromUrl = new URL(
|
||||
from.source,
|
||||
this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile)
|
||||
)
|
||||
}
|
||||
|
||||
let result = {
|
||||
url: fromUrl.toString(),
|
||||
line: from.line,
|
||||
column: from.column
|
||||
}
|
||||
|
||||
if (fromUrl.protocol === 'file:') {
|
||||
if (fileURLToPath) {
|
||||
result.file = fileURLToPath(fromUrl)
|
||||
} else {
|
||||
// istanbul ignore next
|
||||
throw new Error(`file: protocol is not available in this PostCSS build`);
|
||||
}
|
||||
}
|
||||
|
||||
let source = consumer.sourceContentFor(from.source)
|
||||
if (source) result.source = source
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
mapResolve(file) {
|
||||
if (/^\w+:\/\//.test(file)) {
|
||||
return file
|
||||
}
|
||||
return resolve(this.map.consumer().sourceRoot || this.map.root || '.', file)
|
||||
}
|
||||
|
||||
get from() {
|
||||
return this.file || this.id
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
let json = {}
|
||||
for (let name of ['hasBOM', 'css', 'file', 'id']) {
|
||||
if (this[name] != null) {
|
||||
json[name] = this[name]
|
||||
}
|
||||
}
|
||||
if (this.map) {
|
||||
json.map = { ...this.map }
|
||||
if (json.map.consumerCache) {
|
||||
json.map.consumerCache = undefined
|
||||
}
|
||||
}
|
||||
return json
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Input
|
||||
Input.default = Input
|
||||
|
||||
if (terminalHighlight && terminalHighlight.registerInput) {
|
||||
terminalHighlight.registerInput(Input)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { observable as Symbol_observable } from '../symbol/observable';
|
||||
export function scheduleObservable(input, scheduler) {
|
||||
return new Observable(subscriber => {
|
||||
const sub = new Subscription();
|
||||
sub.add(scheduler.schedule(() => {
|
||||
const observable = input[Symbol_observable]();
|
||||
sub.add(observable.subscribe({
|
||||
next(value) { sub.add(scheduler.schedule(() => subscriber.next(value))); },
|
||||
error(err) { sub.add(scheduler.schedule(() => subscriber.error(err))); },
|
||||
complete() { sub.add(scheduler.schedule(() => subscriber.complete())); },
|
||||
}));
|
||||
}));
|
||||
return sub;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=scheduleObservable.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"webSocket.js","sources":["../../../src/internal/observable/dom/webSocket.ts"],"names":[],"mappings":";;AAAA,uDAA8E;AAyJ9E,SAAgB,SAAS,CAAI,iBAAqD;IAChF,OAAO,IAAI,mCAAgB,CAAI,iBAAiB,CAAC,CAAC;AACpD,CAAC;AAFD,8BAEC"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0,"108":0.86251,"109":0.67769,"110":0,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0.03262,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0.03262,"108":1.14156,"109":2.40271,"110":0,"111":0,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0.03262,"108":0.83352,"109":0.30804},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":4.59161,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0.83352,"14.1":0.09422,"15.1":0,"15.2-15.3":0,"15.4":0.03262,"15.5":0,"15.6":0.15583,"16.0":0,"16.1":0.58709,"16.2":0,"16.3":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0,"8.1-8.4":0,"9.0-9.2":0,"9.3":0,"10.0-10.2":0,"10.3":0,"11.0-11.2":0,"11.3-11.4":0,"12.0-12.1":0,"12.2-12.5":0.23384,"13.0-13.1":0,"13.2":0,"13.3":0,"13.4-13.7":0,"14.0-14.4":0,"14.5-14.8":0.11692,"15.0-15.1":0.11692,"15.2-15.3":0.9412,"15.4":0.11692,"15.5":0.35076,"15.6":1.40887,"16.0":17.02338,"16.1":28.05467,"16.2":7.97971,"16.3":0.11692},P:{"4":0,"5.0-5.4":0,"6.2-6.4":0,"7.2-7.4":0,"8.2":0,"9.2":0,"10.1":0,"11.1-11.2":0,"12.0":0,"13.0":0,"14.0":0,"15.0":0,"16.0":0.26051,"17.0":0,"18.0":0,"19.0":1.7033},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":0},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.18482,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},R:{_:"0"},M:{"0":0},Q:{"13.1":0},O:{"0":0},H:{"0":0},L:{"0":27.8339},S:{"2.5":0}};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,107 @@
|
||||
import { canReportError } from './util/canReportError';
|
||||
import { toSubscriber } from './util/toSubscriber';
|
||||
import { observable as Symbol_observable } from './symbol/observable';
|
||||
import { pipeFromArray } from './util/pipe';
|
||||
import { config } from './config';
|
||||
export class Observable {
|
||||
constructor(subscribe) {
|
||||
this._isScalar = false;
|
||||
if (subscribe) {
|
||||
this._subscribe = subscribe;
|
||||
}
|
||||
}
|
||||
lift(operator) {
|
||||
const observable = new Observable();
|
||||
observable.source = this;
|
||||
observable.operator = operator;
|
||||
return observable;
|
||||
}
|
||||
subscribe(observerOrNext, error, complete) {
|
||||
const { operator } = this;
|
||||
const sink = toSubscriber(observerOrNext, error, complete);
|
||||
if (operator) {
|
||||
sink.add(operator.call(sink, this.source));
|
||||
}
|
||||
else {
|
||||
sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
|
||||
this._subscribe(sink) :
|
||||
this._trySubscribe(sink));
|
||||
}
|
||||
if (config.useDeprecatedSynchronousErrorHandling) {
|
||||
if (sink.syncErrorThrowable) {
|
||||
sink.syncErrorThrowable = false;
|
||||
if (sink.syncErrorThrown) {
|
||||
throw sink.syncErrorValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sink;
|
||||
}
|
||||
_trySubscribe(sink) {
|
||||
try {
|
||||
return this._subscribe(sink);
|
||||
}
|
||||
catch (err) {
|
||||
if (config.useDeprecatedSynchronousErrorHandling) {
|
||||
sink.syncErrorThrown = true;
|
||||
sink.syncErrorValue = err;
|
||||
}
|
||||
if (canReportError(sink)) {
|
||||
sink.error(err);
|
||||
}
|
||||
else {
|
||||
console.warn(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
forEach(next, promiseCtor) {
|
||||
promiseCtor = getPromiseCtor(promiseCtor);
|
||||
return new promiseCtor((resolve, reject) => {
|
||||
let subscription;
|
||||
subscription = this.subscribe((value) => {
|
||||
try {
|
||||
next(value);
|
||||
}
|
||||
catch (err) {
|
||||
reject(err);
|
||||
if (subscription) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
}, reject, resolve);
|
||||
});
|
||||
}
|
||||
_subscribe(subscriber) {
|
||||
const { source } = this;
|
||||
return source && source.subscribe(subscriber);
|
||||
}
|
||||
[Symbol_observable]() {
|
||||
return this;
|
||||
}
|
||||
pipe(...operations) {
|
||||
if (operations.length === 0) {
|
||||
return this;
|
||||
}
|
||||
return pipeFromArray(operations)(this);
|
||||
}
|
||||
toPromise(promiseCtor) {
|
||||
promiseCtor = getPromiseCtor(promiseCtor);
|
||||
return new promiseCtor((resolve, reject) => {
|
||||
let value;
|
||||
this.subscribe((x) => value = x, (err) => reject(err), () => resolve(value));
|
||||
});
|
||||
}
|
||||
}
|
||||
Observable.create = (subscribe) => {
|
||||
return new Observable(subscribe);
|
||||
};
|
||||
function getPromiseCtor(promiseCtor) {
|
||||
if (!promiseCtor) {
|
||||
promiseCtor = config.Promise || Promise;
|
||||
}
|
||||
if (!promiseCtor) {
|
||||
throw new Error('no Promise impl found');
|
||||
}
|
||||
return promiseCtor;
|
||||
}
|
||||
//# sourceMappingURL=Observable.js.map
|
||||
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
}
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Subject_1 = require("../Subject");
|
||||
var innerSubscribe_1 = require("../innerSubscribe");
|
||||
function window(windowBoundaries) {
|
||||
return function windowOperatorFunction(source) {
|
||||
return source.lift(new WindowOperator(windowBoundaries));
|
||||
};
|
||||
}
|
||||
exports.window = window;
|
||||
var WindowOperator = (function () {
|
||||
function WindowOperator(windowBoundaries) {
|
||||
this.windowBoundaries = windowBoundaries;
|
||||
}
|
||||
WindowOperator.prototype.call = function (subscriber, source) {
|
||||
var windowSubscriber = new WindowSubscriber(subscriber);
|
||||
var sourceSubscription = source.subscribe(windowSubscriber);
|
||||
if (!sourceSubscription.closed) {
|
||||
windowSubscriber.add(innerSubscribe_1.innerSubscribe(this.windowBoundaries, new innerSubscribe_1.SimpleInnerSubscriber(windowSubscriber)));
|
||||
}
|
||||
return sourceSubscription;
|
||||
};
|
||||
return WindowOperator;
|
||||
}());
|
||||
var WindowSubscriber = (function (_super) {
|
||||
__extends(WindowSubscriber, _super);
|
||||
function WindowSubscriber(destination) {
|
||||
var _this = _super.call(this, destination) || this;
|
||||
_this.window = new Subject_1.Subject();
|
||||
destination.next(_this.window);
|
||||
return _this;
|
||||
}
|
||||
WindowSubscriber.prototype.notifyNext = function () {
|
||||
this.openWindow();
|
||||
};
|
||||
WindowSubscriber.prototype.notifyError = function (error) {
|
||||
this._error(error);
|
||||
};
|
||||
WindowSubscriber.prototype.notifyComplete = function () {
|
||||
this._complete();
|
||||
};
|
||||
WindowSubscriber.prototype._next = function (value) {
|
||||
this.window.next(value);
|
||||
};
|
||||
WindowSubscriber.prototype._error = function (err) {
|
||||
this.window.error(err);
|
||||
this.destination.error(err);
|
||||
};
|
||||
WindowSubscriber.prototype._complete = function () {
|
||||
this.window.complete();
|
||||
this.destination.complete();
|
||||
};
|
||||
WindowSubscriber.prototype._unsubscribe = function () {
|
||||
this.window = null;
|
||||
};
|
||||
WindowSubscriber.prototype.openWindow = function () {
|
||||
var prevWindow = this.window;
|
||||
if (prevWindow) {
|
||||
prevWindow.complete();
|
||||
}
|
||||
var destination = this.destination;
|
||||
var newWindow = this.window = new Subject_1.Subject();
|
||||
destination.next(newWindow);
|
||||
};
|
||||
return WindowSubscriber;
|
||||
}(innerSubscribe_1.SimpleOuterSubscriber));
|
||||
//# sourceMappingURL=window.js.map
|
||||
@@ -0,0 +1,15 @@
|
||||
export interface ObjectUnsubscribedError extends Error {
|
||||
}
|
||||
export interface ObjectUnsubscribedErrorCtor {
|
||||
new (): ObjectUnsubscribedError;
|
||||
}
|
||||
/**
|
||||
* An error thrown when an action is invalid because the object has been
|
||||
* unsubscribed.
|
||||
*
|
||||
* @see {@link Subject}
|
||||
* @see {@link BehaviorSubject}
|
||||
*
|
||||
* @class ObjectUnsubscribedError
|
||||
*/
|
||||
export declare const ObjectUnsubscribedError: ObjectUnsubscribedErrorCtor;
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operator/materialize"));
|
||||
//# sourceMappingURL=materialize.js.map
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Observer } from './types';
|
||||
import { config } from './config';
|
||||
import { hostReportError } from './util/hostReportError';
|
||||
|
||||
export const empty: Observer<any> = {
|
||||
closed: true,
|
||||
next(value: any): void { /* noop */},
|
||||
error(err: any): void {
|
||||
if (config.useDeprecatedSynchronousErrorHandling) {
|
||||
throw err;
|
||||
} else {
|
||||
hostReportError(err);
|
||||
}
|
||||
},
|
||||
complete(): void { /*noop*/ }
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
/** PURE_IMPORTS_START tslib,_Subject,_Subscription PURE_IMPORTS_END */
|
||||
import * as tslib_1 from "tslib";
|
||||
import { Subject } from './Subject';
|
||||
import { Subscription } from './Subscription';
|
||||
var AsyncSubject = /*@__PURE__*/ (function (_super) {
|
||||
tslib_1.__extends(AsyncSubject, _super);
|
||||
function AsyncSubject() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.value = null;
|
||||
_this.hasNext = false;
|
||||
_this.hasCompleted = false;
|
||||
return _this;
|
||||
}
|
||||
AsyncSubject.prototype._subscribe = function (subscriber) {
|
||||
if (this.hasError) {
|
||||
subscriber.error(this.thrownError);
|
||||
return Subscription.EMPTY;
|
||||
}
|
||||
else if (this.hasCompleted && this.hasNext) {
|
||||
subscriber.next(this.value);
|
||||
subscriber.complete();
|
||||
return Subscription.EMPTY;
|
||||
}
|
||||
return _super.prototype._subscribe.call(this, subscriber);
|
||||
};
|
||||
AsyncSubject.prototype.next = function (value) {
|
||||
if (!this.hasCompleted) {
|
||||
this.value = value;
|
||||
this.hasNext = true;
|
||||
}
|
||||
};
|
||||
AsyncSubject.prototype.error = function (error) {
|
||||
if (!this.hasCompleted) {
|
||||
_super.prototype.error.call(this, error);
|
||||
}
|
||||
};
|
||||
AsyncSubject.prototype.complete = function () {
|
||||
this.hasCompleted = true;
|
||||
if (this.hasNext) {
|
||||
_super.prototype.next.call(this, this.value);
|
||||
}
|
||||
_super.prototype.complete.call(this);
|
||||
};
|
||||
return AsyncSubject;
|
||||
}(Subject));
|
||||
export { AsyncSubject };
|
||||
//# sourceMappingURL=AsyncSubject.js.map
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/observable/fromEventPattern");
|
||||
//# sourceMappingURL=fromEventPattern.js.map
|
||||
Reference in New Issue
Block a user