From f7d19b504183e81c9bbffcd769f2c63c16dedb14 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sat, 12 May 2018 19:03:19 -0700 Subject: [PATCH 1/4] Add 'tslib.umd.js' to avoid global pollution --- .npmignore | 2 + CopyrightNotice.txt | 13 +- package-lock.json | 20 +++ package.json | 12 +- scripts/generator.js | 257 +++++++++++++++++++++++++++++++++++++ scripts/generator.ts | 293 +++++++++++++++++++++++++++++++++++++++++++ src/tslib.js | 164 ++++++++++++++++++++++++ src/umd.js | 17 +++ src/umdGlobals.js | 23 ++++ tslib.umd.js | 218 ++++++++++++++++++++++++++++++++ 10 files changed, 1010 insertions(+), 9 deletions(-) create mode 100644 package-lock.json create mode 100644 scripts/generator.js create mode 100644 scripts/generator.ts create mode 100644 src/tslib.js create mode 100644 src/umd.js create mode 100644 src/umdGlobals.js create mode 100644 tslib.umd.js diff --git a/.npmignore b/.npmignore index e69de29..83b016a 100644 --- a/.npmignore +++ b/.npmignore @@ -0,0 +1,2 @@ +src +scripts \ No newline at end of file diff --git a/CopyrightNotice.txt b/CopyrightNotice.txt index 0f6db1f..ca1a0e8 100644 --- a/CopyrightNotice.txt +++ b/CopyrightNotice.txt @@ -1,15 +1,14 @@ /*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. +Copyright (c) Microsoft Corporation. All rights reserved. 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 - +License at http://www.apache.org/licenses/LICENSE-2.0 + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ - diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..92a1f3f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "tslib", + "version": "1.9.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "6.0.110", + "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.110.tgz", + "integrity": "sha512-LiaH3mF+OAqR+9Wo1OTJDbZDtCewAVjTbMhF1ZgUJ3fc8xqOJq6VqbpBh9dJVCVzByGmYIg2fREbuXNX0TKiJA==", + "dev": true + }, + "typescript": { + "version": "2.9.0-dev.20180512", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.0-dev.20180512.tgz", + "integrity": "sha512-IoShsqB7aix2NsKnaKqlCuerZdWp0OHIrWufUY2mfV1vDf8FTmBA49AODKbWySTQCi2YBB6SGqih9FLMEBjZJA==", + "dev": true + } + } +} diff --git a/package.json b/package.json index edb808e..d2c8747 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,10 @@ "tslib", "runtime" ], + "scripts": { + "build-generator": "tsc scripts/generator.ts --module commonjs --target es2015", + "build": "npm run build-generator && node scripts/generator.js src ." + }, "bugs": { "url": "https://github.com/Microsoft/TypeScript/issues" }, @@ -21,8 +25,12 @@ "type": "git", "url": "https://github.com/Microsoft/tslib.git" }, - "main": "tslib.js", + "main": "tslib.umd.js", "module": "tslib.es6.js", "jsnext:main": "tslib.es6.js", - "typings": "tslib.d.ts" + "typings": "tslib.d.ts", + "devDependencies": { + "@types/node": "^6.0.110", + "typescript": "^2.9.0-dev.20180512" + } } diff --git a/scripts/generator.js b/scripts/generator.js new file mode 100644 index 0000000..480a6c4 --- /dev/null +++ b/scripts/generator.js @@ -0,0 +1,257 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = require("fs"); +const path = require("path"); +const ts = require("typescript"); +const rootDir = path.resolve(__dirname, `..`); +const srcDir = path.resolve(rootDir, `src`); +const copyrightNotice = fs.readFileSync(path.resolve(rootDir, "CopyrightNotice.txt"), "utf8"); +const umdGlobalsExporter = fs.readFileSync(path.resolve(srcDir, "umdGlobals.js"), "utf8"); +const umdExporter = fs.readFileSync(path.resolve(srcDir, "umd.js"), "utf8"); +const tslibFile = path.resolve(srcDir, "tslib.js"); +const indentStrings = ["", " "]; +const MAX_SMI_X86 = 1073741823; +class TextWriter { + constructor() { + this.indent = 0; + this.output = ""; + this.pendingNewLines = 0; + } + write(s) { + if (s && s.length) { + this.writePendingNewLines(); + this.output += s; + } + } + writeLine(s) { + this.write(s); + this.pendingNewLines++; + } + writeLines(s) { + if (s) { + const lines = s.split(/\r\n?|\n/g); + const indentation = guessIndentation(lines); + for (const lineText of lines) { + const line = indentation ? lineText.slice(indentation) : lineText; + if (!this.pendingNewLines && this.output.length > 0) { + this.writeLine(); + } + this.writeLine(line); + } + } + } + toString() { + return this.output; + } + writePendingNewLines() { + if (this.pendingNewLines > 0) { + do { + this.output += "\n"; + this.pendingNewLines--; + } while (this.pendingNewLines > 0); + this.output += getIndentString(this.indent); + } + } +} +main(); +function main() { + const sourceFiles = parseSources(); + generateSingleFileVariations(sourceFiles, rootDir); +} +function getIndentString(level) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; +} +function guessIndentation(lines) { + let indentation = MAX_SMI_X86; + for (const line of lines) { + if (!line.length) { + continue; + } + let i = 0; + for (; i < line.length && i < indentation; i++) { + if (!/^[\s\r\n]/.test(line.charAt(i))) { + break; + } + } + if (i < indentation) { + indentation = i; + } + if (indentation === 0) { + return 0; + } + } + return indentation === MAX_SMI_X86 ? undefined : indentation; +} +function mkdirpSync(dir) { + try { + fs.mkdirSync(dir); + } + catch (e) { + if (e.code === "EEXIST") + return; + if (e.code === "ENOENT") { + const parent = path.dirname(dir); + if (parent && parent !== dir) { + mkdirpSync(parent); + fs.mkdirSync(dir); + return; + } + } + throw e; + } +} +function parse(file) { + const sourceText = fs.readFileSync(file, "utf8"); + const sourceFile = ts.createSourceFile(file, sourceText, ts.ScriptTarget.ES3, /*setParentNodes*/ true, ts.ScriptKind.JS); + return sourceFile; +} +function parseSources() { + const sourceFiles = []; + sourceFiles.push(parse(tslibFile)); + return sourceFiles; +} +function generateSingleFileVariations(sourceFiles, outDir) { + generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.js"), 1 /* UmdGlobal */); + generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.umd.js"), 0 /* Umd */); + generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.es6.js"), 2 /* ES2015 */); +} +function generateSingleFile(sourceFiles, outFile, libKind) { + const bundle = ts.createBundle(sourceFiles); + const output = write(bundle, libKind); + mkdirpSync(path.dirname(outFile)); + fs.writeFileSync(outFile, output, "utf8"); +} +function formatMessage(node, message) { + const sourceFile = node.getSourceFile(); + if (sourceFile) { + const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)); + return `${sourceFile.fileName}(${line + 1}, ${character + 1}): ${message}`; + } + return message; +} +function reportError(node, message) { + console.error(formatMessage(node, message)); +} +function write(source, libKind) { + const globalWriter = new TextWriter(); + const bodyWriter = new TextWriter(); + const exportWriter = new TextWriter(); + let sourceFile; + return writeBundle(source); + function writeBundle(node) { + switch (libKind) { + case 0 /* Umd */: + case 1 /* UmdGlobal */: + return writeUmdBundle(node); + case 2 /* ES2015 */: + return writeES2015Bundle(node); + } + } + function writeUmdBundle(node) { + visit(node); + const writer = new TextWriter(); + writer.writeLines(copyrightNotice); + writer.writeLines(globalWriter.toString()); + writer.writeLines(libKind === 1 /* UmdGlobal */ ? umdGlobalsExporter : umdExporter); + writer.writeLine(`(function (exporter) {`); + writer.indent++; + writer.writeLines(bodyWriter.toString()); + writer.writeLine(); + writer.writeLines(exportWriter.toString()); + writer.indent--; + writer.writeLine(`});`); + return writer.toString(); + } + function writeES2015Bundle(node) { + visit(node); + const writer = new TextWriter(); + writer.writeLines(copyrightNotice); + writer.writeLines(bodyWriter.toString()); + return writer.toString(); + } + function visit(node) { + switch (node.kind) { + case ts.SyntaxKind.Bundle: return visitBundle(node); + case ts.SyntaxKind.SourceFile: return visitSourceFile(node); + case ts.SyntaxKind.VariableStatement: return visitVariableStatement(node); + case ts.SyntaxKind.FunctionDeclaration: return visitFunctionDeclaration(node); + default: + reportError(node, `${ts.SyntaxKind[node.kind]} not supported at the top level.`); + return undefined; + } + } + function visitBundle(node) { + node.sourceFiles.forEach(visit); + } + function visitSourceFile(node) { + sourceFile = node; + node.statements.forEach(visit); + } + function visitFunctionDeclaration(node) { + if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { + if (libKind === 0 /* Umd */ || libKind === 1 /* UmdGlobal */) { + exportWriter.writeLine(`exporter("${ts.idText(node.name)}", ${ts.idText(node.name)});`); + const parametersText = sourceFile.text.slice(node.parameters.pos, node.parameters.end); + const bodyText = node.body.getText(); + if (libKind === 1 /* UmdGlobal */) { + globalWriter.writeLine(`var ${ts.idText(node.name)};`); + bodyWriter.writeLines(`${ts.idText(node.name)} = function (${parametersText}) ${bodyText};`); + } + else { + bodyWriter.writeLines(`function ${ts.idText(node.name)}(${parametersText}) ${bodyText}`); + } + bodyWriter.writeLine(); + return; + } + } + bodyWriter.writeLines(node.getText()); + bodyWriter.writeLine(); + } + function visitVariableStatement(node) { + if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { + if (node.declarationList.declarations.length > 1) { + reportError(node, `Only single variables are supported on exported variable statements.`); + return; + } + const variable = node.declarationList.declarations[0]; + if (variable.name.kind !== ts.SyntaxKind.Identifier) { + reportError(variable.name, `Only identifier names are supported on exported variable statements.`); + return; + } + if (!variable.initializer) { + reportError(variable.name, `Exported variables must have an initializer.`); + return; + } + if (libKind === 0 /* Umd */ || libKind === 1 /* UmdGlobal */) { + if (libKind === 1 /* UmdGlobal */) { + globalWriter.writeLine(`var ${ts.idText(variable.name)};`); + bodyWriter.writeLines(`${ts.idText(variable.name)} = ${variable.initializer.getText()};`); + } + else if (ts.isFunctionExpression(variable.initializer)) { + const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); + const bodyText = variable.initializer.body.getText(); + bodyWriter.writeLines(`function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); + bodyWriter.writeLine(); + } + else { + bodyWriter.writeLines(`var ${ts.idText(variable.name)} = ${variable.initializer.getText()};`); + } + bodyWriter.writeLine(); + exportWriter.writeLine(`exporter("${ts.idText(variable.name)}", ${ts.idText(variable.name)});`); + return; + } + if (ts.isFunctionExpression(variable.initializer)) { + const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); + const bodyText = variable.initializer.body.getText(); + bodyWriter.writeLines(`export function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); + bodyWriter.writeLine(); + return; + } + } + bodyWriter.writeLines(node.getText()); + bodyWriter.writeLine(); + } +} diff --git a/scripts/generator.ts b/scripts/generator.ts new file mode 100644 index 0000000..ac5618d --- /dev/null +++ b/scripts/generator.ts @@ -0,0 +1,293 @@ +import * as fs from "fs"; +import * as path from "path"; +import * as os from "os"; +import * as ts from "typescript"; + +const rootDir = path.resolve(__dirname, `..`); +const srcDir = path.resolve(rootDir, `src`); +const copyrightNotice = fs.readFileSync(path.resolve(rootDir, "CopyrightNotice.txt"), "utf8"); +const umdGlobalsExporter = fs.readFileSync(path.resolve(srcDir, "umdGlobals.js"), "utf8"); +const umdExporter = fs.readFileSync(path.resolve(srcDir, "umd.js"), "utf8"); +const tslibFile = path.resolve(srcDir, "tslib.js"); +const indentStrings: string[] = ["", " "]; +const MAX_SMI_X86 = 0x3fff_ffff; + +const enum LibKind { + Umd, + UmdGlobal, + ES2015 +} + +class TextWriter { + public indent = 0; + private output = ""; + private pendingNewLines = 0; + + write(s: string) { + if (s && s.length) { + this.writePendingNewLines(); + this.output += s; + } + } + + writeLine(s?: string) { + this.write(s); + this.pendingNewLines++; + } + + writeLines(s: string): void { + if (s) { + const lines = s.split(/\r\n?|\n/g); + const indentation = guessIndentation(lines); + for (const lineText of lines) { + const line = indentation ? lineText.slice(indentation) : lineText; + if (!this.pendingNewLines && this.output.length > 0) { + this.writeLine(); + } + this.writeLine(line); + } + } + } + + toString() { + return this.output; + } + + private writePendingNewLines() { + if (this.pendingNewLines > 0) { + do { + this.output += "\n"; + this.pendingNewLines--; + } + while (this.pendingNewLines > 0); + this.output += getIndentString(this.indent); + } + } +} + +main(); + +function main() { + const sourceFiles = parseSources(); + generateSingleFileVariations(sourceFiles, rootDir); +} + +function getIndentString(level: number) { + if (indentStrings[level] === undefined) { + indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; + } + return indentStrings[level]; +} + +function guessIndentation(lines: string[]) { + let indentation = MAX_SMI_X86; + for (const line of lines) { + if (!line.length) { + continue; + } + let i = 0; + for (; i < line.length && i < indentation; i++) { + if (!/^[\s\r\n]/.test(line.charAt(i))) { + break; + } + } + if (i < indentation) { + indentation = i; + } + if (indentation === 0) { + return 0; + } + } + return indentation === MAX_SMI_X86 ? undefined : indentation; +} + +function mkdirpSync(dir: string) { + try { + fs.mkdirSync(dir); + } + catch (e) { + if (e.code === "EEXIST") return; + if (e.code === "ENOENT") { + const parent = path.dirname(dir); + if (parent && parent !== dir) { + mkdirpSync(parent); + fs.mkdirSync(dir); + return; + } + } + throw e; + } +} + +function parse(file: string) { + const sourceText = fs.readFileSync(file, "utf8"); + const sourceFile = ts.createSourceFile(file, sourceText, ts.ScriptTarget.ES3, /*setParentNodes*/ true, ts.ScriptKind.JS); + return sourceFile; +} + +function parseSources() { + const sourceFiles: ts.SourceFile[] = []; + sourceFiles.push(parse(tslibFile)); + return sourceFiles; +} + +function generateSingleFileVariations(sourceFiles: ts.SourceFile[], outDir: string) { + generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.js"), LibKind.UmdGlobal); + generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.umd.js"), LibKind.Umd); + generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.es6.js"), LibKind.ES2015); +} + +function generateSingleFile(sourceFiles: ts.SourceFile[], outFile: string, libKind: LibKind) { + const bundle = ts.createBundle(sourceFiles); + const output = write(bundle, libKind); + mkdirpSync(path.dirname(outFile)); + fs.writeFileSync(outFile, output, "utf8"); +} + +function formatMessage(node: ts.Node, message: string) { + const sourceFile = node.getSourceFile(); + if (sourceFile) { + const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)); + return `${sourceFile.fileName}(${line + 1}, ${character + 1}): ${message}`; + } + return message; +} + +function reportError(node: ts.Node, message: string) { + console.error(formatMessage(node, message)); +} + +function write(source: ts.Bundle, libKind: LibKind) { + const globalWriter = new TextWriter(); + const bodyWriter = new TextWriter(); + const exportWriter = new TextWriter(); + let sourceFile: ts.SourceFile | undefined; + + return writeBundle(source); + + function writeBundle(node: ts.Bundle) { + switch (libKind) { + case LibKind.Umd: + case LibKind.UmdGlobal: + return writeUmdBundle(node); + case LibKind.ES2015: + return writeES2015Bundle(node); + } + } + + function writeUmdBundle(node: ts.Bundle) { + visit(node); + const writer = new TextWriter(); + writer.writeLines(copyrightNotice); + writer.writeLines(globalWriter.toString()); + writer.writeLines(libKind === LibKind.UmdGlobal ? umdGlobalsExporter : umdExporter); + writer.writeLine(`(function (exporter) {`); + writer.indent++; + writer.writeLines(bodyWriter.toString()); + writer.writeLine(); + writer.writeLines(exportWriter.toString()); + writer.indent--; + writer.writeLine(`});`); + return writer.toString(); + } + + function writeES2015Bundle(node: ts.Bundle) { + visit(node); + const writer = new TextWriter(); + writer.writeLines(copyrightNotice); + writer.writeLines(bodyWriter.toString()); + return writer.toString(); + } + + function visit(node: ts.Node) { + switch (node.kind) { + case ts.SyntaxKind.Bundle: return visitBundle(node); + case ts.SyntaxKind.SourceFile: return visitSourceFile(node); + case ts.SyntaxKind.VariableStatement: return visitVariableStatement(node); + case ts.SyntaxKind.FunctionDeclaration: return visitFunctionDeclaration(node); + default: + reportError(node, `${ts.SyntaxKind[node.kind]} not supported at the top level.`); + return undefined; + } + } + + function visitBundle(node: ts.Bundle) { + node.sourceFiles.forEach(visit); + } + + function visitSourceFile(node: ts.SourceFile) { + sourceFile = node; + node.statements.forEach(visit); + } + + function visitFunctionDeclaration(node: ts.FunctionDeclaration) { + if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { + if (libKind === LibKind.Umd || libKind === LibKind.UmdGlobal) { + exportWriter.writeLine(`exporter("${ts.idText(node.name)}", ${ts.idText(node.name)});`); + const parametersText = sourceFile.text.slice(node.parameters.pos, node.parameters.end); + const bodyText = node.body.getText(); + if (libKind === LibKind.UmdGlobal) { + globalWriter.writeLine(`var ${ts.idText(node.name)};`); + bodyWriter.writeLines(`${ts.idText(node.name)} = function (${parametersText}) ${bodyText};`); + } + else { + bodyWriter.writeLines(`function ${ts.idText(node.name)}(${parametersText}) ${bodyText}`); + } + bodyWriter.writeLine(); + return; + } + } + bodyWriter.writeLines(node.getText()); + bodyWriter.writeLine(); + } + + function visitVariableStatement(node: ts.VariableStatement) { + if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { + if (node.declarationList.declarations.length > 1) { + reportError(node, `Only single variables are supported on exported variable statements.`); + return; + } + + const variable = node.declarationList.declarations[0]; + if (variable.name.kind !== ts.SyntaxKind.Identifier) { + reportError(variable.name, `Only identifier names are supported on exported variable statements.`); + return; + } + + if (!variable.initializer) { + reportError(variable.name, `Exported variables must have an initializer.`); + return; + } + + if (libKind === LibKind.Umd || libKind === LibKind.UmdGlobal) { + if (libKind === LibKind.UmdGlobal) { + globalWriter.writeLine(`var ${ts.idText(variable.name)};`); + bodyWriter.writeLines(`${ts.idText(variable.name)} = ${variable.initializer.getText()};`); + } + else if (ts.isFunctionExpression(variable.initializer)) { + const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); + const bodyText = variable.initializer.body.getText(); + bodyWriter.writeLines(`function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); + bodyWriter.writeLine(); + } + else { + bodyWriter.writeLines(`var ${ts.idText(variable.name)} = ${variable.initializer.getText()};`); + } + bodyWriter.writeLine(); + exportWriter.writeLine(`exporter("${ts.idText(variable.name)}", ${ts.idText(variable.name)});`); + return; + } + + if (ts.isFunctionExpression(variable.initializer)) { + const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); + const bodyText = variable.initializer.body.getText(); + bodyWriter.writeLines(`export function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); + bodyWriter.writeLine(); + return; + } + } + + bodyWriter.writeLines(node.getText()); + bodyWriter.writeLine(); + } +} diff --git a/src/tslib.js b/src/tslib.js new file mode 100644 index 0000000..48050b2 --- /dev/null +++ b/src/tslib.js @@ -0,0 +1,164 @@ +var 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]; }; + +export function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +export var __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; +}; + +export function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +export function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +export function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +export function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +export function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +export function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +export function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +export function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +export function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +export function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +export function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +export function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +export function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +export function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +export function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +} + +export function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +} + +export function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} \ No newline at end of file diff --git a/src/umd.js b/src/umd.js new file mode 100644 index 0000000..d9c108c --- /dev/null +++ b/src/umd.js @@ -0,0 +1,17 @@ +(function (factory) { + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(exports)); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(module.exports)); + } + function createExporter(exports) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + return function (id, v) { return exports[id] = v; }; + } +}) \ No newline at end of file diff --git a/src/umdGlobals.js b/src/umdGlobals.js new file mode 100644 index 0000000..bb09c99 --- /dev/null +++ b/src/umdGlobals.js @@ -0,0 +1,23 @@ +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) \ No newline at end of file diff --git a/tslib.umd.js b/tslib.umd.js new file mode 100644 index 0000000..d93b0f8 --- /dev/null +++ b/tslib.umd.js @@ -0,0 +1,218 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +(function (factory) { + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(exports)); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(module.exports)); + } + function createExporter(exports) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + return function (id, v) { return exports[id] = v; }; + } +}) +(function (exporter) { + var 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]; }; + + function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + var __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; + } + + function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + } + + function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + } + + function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + } + + function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + } + + function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + } + + function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + + function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + } + + function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + } + + function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + } + + function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + } + + function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + } + + function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + } + + function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + } + + function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + } + + function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + } + + function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + } + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); +}); \ No newline at end of file From e2f84342c48af3f111df05659b1a4e4a66e849ab Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 May 2018 13:24:28 -0700 Subject: [PATCH 2/4] Remove generator.js from repo --- .gitignore | 1 + scripts/generator.js | 257 ------------------------------------------- 2 files changed, 1 insertion(+), 257 deletions(-) delete mode 100644 scripts/generator.js diff --git a/.gitignore b/.gitignore index bca51b3..8a4d850 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +scripts/generator.js \ No newline at end of file diff --git a/scripts/generator.js b/scripts/generator.js deleted file mode 100644 index 480a6c4..0000000 --- a/scripts/generator.js +++ /dev/null @@ -1,257 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const fs = require("fs"); -const path = require("path"); -const ts = require("typescript"); -const rootDir = path.resolve(__dirname, `..`); -const srcDir = path.resolve(rootDir, `src`); -const copyrightNotice = fs.readFileSync(path.resolve(rootDir, "CopyrightNotice.txt"), "utf8"); -const umdGlobalsExporter = fs.readFileSync(path.resolve(srcDir, "umdGlobals.js"), "utf8"); -const umdExporter = fs.readFileSync(path.resolve(srcDir, "umd.js"), "utf8"); -const tslibFile = path.resolve(srcDir, "tslib.js"); -const indentStrings = ["", " "]; -const MAX_SMI_X86 = 1073741823; -class TextWriter { - constructor() { - this.indent = 0; - this.output = ""; - this.pendingNewLines = 0; - } - write(s) { - if (s && s.length) { - this.writePendingNewLines(); - this.output += s; - } - } - writeLine(s) { - this.write(s); - this.pendingNewLines++; - } - writeLines(s) { - if (s) { - const lines = s.split(/\r\n?|\n/g); - const indentation = guessIndentation(lines); - for (const lineText of lines) { - const line = indentation ? lineText.slice(indentation) : lineText; - if (!this.pendingNewLines && this.output.length > 0) { - this.writeLine(); - } - this.writeLine(line); - } - } - } - toString() { - return this.output; - } - writePendingNewLines() { - if (this.pendingNewLines > 0) { - do { - this.output += "\n"; - this.pendingNewLines--; - } while (this.pendingNewLines > 0); - this.output += getIndentString(this.indent); - } - } -} -main(); -function main() { - const sourceFiles = parseSources(); - generateSingleFileVariations(sourceFiles, rootDir); -} -function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; -} -function guessIndentation(lines) { - let indentation = MAX_SMI_X86; - for (const line of lines) { - if (!line.length) { - continue; - } - let i = 0; - for (; i < line.length && i < indentation; i++) { - if (!/^[\s\r\n]/.test(line.charAt(i))) { - break; - } - } - if (i < indentation) { - indentation = i; - } - if (indentation === 0) { - return 0; - } - } - return indentation === MAX_SMI_X86 ? undefined : indentation; -} -function mkdirpSync(dir) { - try { - fs.mkdirSync(dir); - } - catch (e) { - if (e.code === "EEXIST") - return; - if (e.code === "ENOENT") { - const parent = path.dirname(dir); - if (parent && parent !== dir) { - mkdirpSync(parent); - fs.mkdirSync(dir); - return; - } - } - throw e; - } -} -function parse(file) { - const sourceText = fs.readFileSync(file, "utf8"); - const sourceFile = ts.createSourceFile(file, sourceText, ts.ScriptTarget.ES3, /*setParentNodes*/ true, ts.ScriptKind.JS); - return sourceFile; -} -function parseSources() { - const sourceFiles = []; - sourceFiles.push(parse(tslibFile)); - return sourceFiles; -} -function generateSingleFileVariations(sourceFiles, outDir) { - generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.js"), 1 /* UmdGlobal */); - generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.umd.js"), 0 /* Umd */); - generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.es6.js"), 2 /* ES2015 */); -} -function generateSingleFile(sourceFiles, outFile, libKind) { - const bundle = ts.createBundle(sourceFiles); - const output = write(bundle, libKind); - mkdirpSync(path.dirname(outFile)); - fs.writeFileSync(outFile, output, "utf8"); -} -function formatMessage(node, message) { - const sourceFile = node.getSourceFile(); - if (sourceFile) { - const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)); - return `${sourceFile.fileName}(${line + 1}, ${character + 1}): ${message}`; - } - return message; -} -function reportError(node, message) { - console.error(formatMessage(node, message)); -} -function write(source, libKind) { - const globalWriter = new TextWriter(); - const bodyWriter = new TextWriter(); - const exportWriter = new TextWriter(); - let sourceFile; - return writeBundle(source); - function writeBundle(node) { - switch (libKind) { - case 0 /* Umd */: - case 1 /* UmdGlobal */: - return writeUmdBundle(node); - case 2 /* ES2015 */: - return writeES2015Bundle(node); - } - } - function writeUmdBundle(node) { - visit(node); - const writer = new TextWriter(); - writer.writeLines(copyrightNotice); - writer.writeLines(globalWriter.toString()); - writer.writeLines(libKind === 1 /* UmdGlobal */ ? umdGlobalsExporter : umdExporter); - writer.writeLine(`(function (exporter) {`); - writer.indent++; - writer.writeLines(bodyWriter.toString()); - writer.writeLine(); - writer.writeLines(exportWriter.toString()); - writer.indent--; - writer.writeLine(`});`); - return writer.toString(); - } - function writeES2015Bundle(node) { - visit(node); - const writer = new TextWriter(); - writer.writeLines(copyrightNotice); - writer.writeLines(bodyWriter.toString()); - return writer.toString(); - } - function visit(node) { - switch (node.kind) { - case ts.SyntaxKind.Bundle: return visitBundle(node); - case ts.SyntaxKind.SourceFile: return visitSourceFile(node); - case ts.SyntaxKind.VariableStatement: return visitVariableStatement(node); - case ts.SyntaxKind.FunctionDeclaration: return visitFunctionDeclaration(node); - default: - reportError(node, `${ts.SyntaxKind[node.kind]} not supported at the top level.`); - return undefined; - } - } - function visitBundle(node) { - node.sourceFiles.forEach(visit); - } - function visitSourceFile(node) { - sourceFile = node; - node.statements.forEach(visit); - } - function visitFunctionDeclaration(node) { - if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { - if (libKind === 0 /* Umd */ || libKind === 1 /* UmdGlobal */) { - exportWriter.writeLine(`exporter("${ts.idText(node.name)}", ${ts.idText(node.name)});`); - const parametersText = sourceFile.text.slice(node.parameters.pos, node.parameters.end); - const bodyText = node.body.getText(); - if (libKind === 1 /* UmdGlobal */) { - globalWriter.writeLine(`var ${ts.idText(node.name)};`); - bodyWriter.writeLines(`${ts.idText(node.name)} = function (${parametersText}) ${bodyText};`); - } - else { - bodyWriter.writeLines(`function ${ts.idText(node.name)}(${parametersText}) ${bodyText}`); - } - bodyWriter.writeLine(); - return; - } - } - bodyWriter.writeLines(node.getText()); - bodyWriter.writeLine(); - } - function visitVariableStatement(node) { - if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { - if (node.declarationList.declarations.length > 1) { - reportError(node, `Only single variables are supported on exported variable statements.`); - return; - } - const variable = node.declarationList.declarations[0]; - if (variable.name.kind !== ts.SyntaxKind.Identifier) { - reportError(variable.name, `Only identifier names are supported on exported variable statements.`); - return; - } - if (!variable.initializer) { - reportError(variable.name, `Exported variables must have an initializer.`); - return; - } - if (libKind === 0 /* Umd */ || libKind === 1 /* UmdGlobal */) { - if (libKind === 1 /* UmdGlobal */) { - globalWriter.writeLine(`var ${ts.idText(variable.name)};`); - bodyWriter.writeLines(`${ts.idText(variable.name)} = ${variable.initializer.getText()};`); - } - else if (ts.isFunctionExpression(variable.initializer)) { - const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); - const bodyText = variable.initializer.body.getText(); - bodyWriter.writeLines(`function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); - bodyWriter.writeLine(); - } - else { - bodyWriter.writeLines(`var ${ts.idText(variable.name)} = ${variable.initializer.getText()};`); - } - bodyWriter.writeLine(); - exportWriter.writeLine(`exporter("${ts.idText(variable.name)}", ${ts.idText(variable.name)});`); - return; - } - if (ts.isFunctionExpression(variable.initializer)) { - const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); - const bodyText = variable.initializer.body.getText(); - bodyWriter.writeLines(`export function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); - bodyWriter.writeLine(); - return; - } - } - bodyWriter.writeLines(node.getText()); - bodyWriter.writeLine(); - } -} From 5317363f97744cdb2e28ef47c480ec34921ff8b8 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 May 2018 13:26:18 -0700 Subject: [PATCH 3/4] Generate cjs and make it the default. --- CopyrightNotice.txt | 1 + README.md | 10 + bower.json | 2 +- package.json | 4 +- scripts/generator.ts | 279 ++++++++++++++++++------- src/umd.js | 17 -- src/umdGlobals.js | 23 -- tslib.amd.js | 202 ++++++++++++++++++ tslib.cjs.js | 200 ++++++++++++++++++ tslib.es6.js | 360 ++++++++++++++++---------------- tslib.global.js | 180 ++++++++++++++++ tslib.js | 487 ++++++++++++++++++++++--------------------- tslib.umd.js | 1 + 13 files changed, 1225 insertions(+), 541 deletions(-) delete mode 100644 src/umd.js delete mode 100644 src/umdGlobals.js create mode 100644 tslib.amd.js create mode 100644 tslib.cjs.js create mode 100644 tslib.global.js diff --git a/CopyrightNotice.txt b/CopyrightNotice.txt index ca1a0e8..9956040 100644 --- a/CopyrightNotice.txt +++ b/CopyrightNotice.txt @@ -12,3 +12,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ + diff --git a/README.md b/README.md index 02f2a77..9821efa 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,16 @@ For JSPM users: } ``` +#### Variants + +There are several variants of `tslib` available in this package: + +- `tslib.js` - A bundle of all helpers that supports both CommonJS and AMD modules as well as adds global (for use with `` tags). +- `tslib.umd.js` - A bundle of all helpers that supports both CommonJS and AMD modules, but does not add global variables. +- `tslib.cjs.js` - A bundle of all helpers that supports only CommonJS (this is the variant used as `"main"` in _package.json_). +- `tslib.amd.js` - A bundle of all helpers that supports only AMD. +- `tslib.es6.js` - A bundle of all helpers that supports ECMAScript module syntax. +- `tslib.global.js` - A bundle of all helpers that only adds globals (for use with `` tags). # Contribute diff --git a/bower.json b/bower.json index 15eb518..fb774f2 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,7 @@ "type": "git", "url": "https://github.com/Microsoft/tslib.git" }, - "main": "tslib.js", + "main": "tslib.cjs.js", "ignore": [ "**/.*", "node_modules", diff --git a/package.json b/package.json index d2c8747..9629b75 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ ], "scripts": { "build-generator": "tsc scripts/generator.ts --module commonjs --target es2015", - "build": "npm run build-generator && node scripts/generator.js src ." + "build": "npm run build-generator && node scripts/generator.js" }, "bugs": { "url": "https://github.com/Microsoft/TypeScript/issues" @@ -25,7 +25,7 @@ "type": "git", "url": "https://github.com/Microsoft/tslib.git" }, - "main": "tslib.umd.js", + "main": "tslib.cjs.js", "module": "tslib.es6.js", "jsnext:main": "tslib.es6.js", "typings": "tslib.d.ts", diff --git a/scripts/generator.ts b/scripts/generator.ts index ac5618d..0a9a325 100644 --- a/scripts/generator.ts +++ b/scripts/generator.ts @@ -5,16 +5,17 @@ import * as ts from "typescript"; const rootDir = path.resolve(__dirname, `..`); const srcDir = path.resolve(rootDir, `src`); -const copyrightNotice = fs.readFileSync(path.resolve(rootDir, "CopyrightNotice.txt"), "utf8"); -const umdGlobalsExporter = fs.readFileSync(path.resolve(srcDir, "umdGlobals.js"), "utf8"); -const umdExporter = fs.readFileSync(path.resolve(srcDir, "umd.js"), "utf8"); +const copyrightNotice = fs.readFileSync(path.resolve(rootDir, "CopyrightNotice.txt"), "utf8").trim(); const tslibFile = path.resolve(srcDir, "tslib.js"); const indentStrings: string[] = ["", " "]; const MAX_SMI_X86 = 0x3fff_ffff; const enum LibKind { + CommonJS, + Amd, Umd, UmdGlobal, + Global, ES2015 } @@ -39,12 +40,15 @@ class TextWriter { if (s) { const lines = s.split(/\r\n?|\n/g); const indentation = guessIndentation(lines); + let firstLine = true; for (const lineText of lines) { const line = indentation ? lineText.slice(indentation) : lineText; + if (!line.trim() && firstLine) continue; if (!this.pendingNewLines && this.output.length > 0) { this.writeLine(); } this.writeLine(line); + firstLine = false; } } } @@ -68,8 +72,20 @@ class TextWriter { main(); function main() { - const sourceFiles = parseSources(); - generateSingleFileVariations(sourceFiles, rootDir); + const options: ts.CompilerOptions = { + allowJs: true, + noResolve: true, + noEmit: true, + target: ts.ScriptTarget.ES3, + types: [] + }; + const host = ts.createCompilerHost(options, /*setParentNodes*/ true); + const program = ts.createProgram({ + rootNames: [tslibFile], + options, + host, + }); + generateSingleFileVariations(program, rootDir); } function getIndentString(level: number) { @@ -119,27 +135,19 @@ function mkdirpSync(dir: string) { } } -function parse(file: string) { - const sourceText = fs.readFileSync(file, "utf8"); - const sourceFile = ts.createSourceFile(file, sourceText, ts.ScriptTarget.ES3, /*setParentNodes*/ true, ts.ScriptKind.JS); - return sourceFile; +function generateSingleFileVariations(program: ts.Program, outDir: string) { + generateSingleFile(program, path.resolve(outDir, "tslib.js"), LibKind.UmdGlobal); + generateSingleFile(program, path.resolve(outDir, "tslib.umd.js"), LibKind.Umd); + generateSingleFile(program, path.resolve(outDir, "tslib.cjs.js"), LibKind.CommonJS); + generateSingleFile(program, path.resolve(outDir, "tslib.amd.js"), LibKind.Amd); + generateSingleFile(program, path.resolve(outDir, "tslib.global.js"), LibKind.Global); + generateSingleFile(program, path.resolve(outDir, "tslib.es6.js"), LibKind.ES2015); } -function parseSources() { - const sourceFiles: ts.SourceFile[] = []; - sourceFiles.push(parse(tslibFile)); - return sourceFiles; -} - -function generateSingleFileVariations(sourceFiles: ts.SourceFile[], outDir: string) { - generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.js"), LibKind.UmdGlobal); - generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.umd.js"), LibKind.Umd); - generateSingleFile(sourceFiles, path.resolve(outDir, "tslib.es6.js"), LibKind.ES2015); -} - -function generateSingleFile(sourceFiles: ts.SourceFile[], outFile: string, libKind: LibKind) { +function generateSingleFile(program: ts.Program, outFile: string, libKind: LibKind) { + const sourceFiles = program.getSourceFiles().filter(file => path.extname(file.fileName) === ".js"); const bundle = ts.createBundle(sourceFiles); - const output = write(bundle, libKind); + const output = write(bundle, program.getTypeChecker(), libKind); mkdirpSync(path.dirname(outFile)); fs.writeFileSync(outFile, output, "utf8"); } @@ -157,10 +165,16 @@ function reportError(node: ts.Node, message: string) { console.error(formatMessage(node, message)); } -function write(source: ts.Bundle, libKind: LibKind) { +function write(source: ts.Bundle, checker: ts.TypeChecker, libKind: LibKind) { const globalWriter = new TextWriter(); const bodyWriter = new TextWriter(); const exportWriter = new TextWriter(); + const unknownGlobals = new Set(); + const rewriteExports = libKind === LibKind.Umd || libKind === LibKind.UmdGlobal || libKind === LibKind.CommonJS || libKind === LibKind.Amd; + const useExporter = libKind === LibKind.Umd || libKind === LibKind.UmdGlobal; + const useExports = libKind === LibKind.CommonJS || libKind === LibKind.Amd; + const useGlobals = libKind === LibKind.UmdGlobal || libKind === LibKind.Global; + let knownLocals = new Set(); let sourceFile: ts.SourceFile | undefined; return writeBundle(source); @@ -170,17 +184,93 @@ function write(source: ts.Bundle, libKind: LibKind) { case LibKind.Umd: case LibKind.UmdGlobal: return writeUmdBundle(node); + case LibKind.Amd: + return writeAmdBundle(node); + case LibKind.CommonJS: + return writeCommonJSBundle(node); case LibKind.ES2015: - return writeES2015Bundle(node); + case LibKind.Global: + return writeES2015OrGlobalBundle(node); } } + function writeHeader(writer: TextWriter) { + writer.writeLines(copyrightNotice); + writeLintGlobals(writer); + writer.writeLine(); + } + + function writeLintGlobals(writer: TextWriter) { + if (unknownGlobals.size > 0) { + writer.writeLine(`/* global ${[...unknownGlobals].join(", ")} */`); + } + } + + function writeUmdHeader(writer: TextWriter) { + writer.writeLines(` + (function (factory) { + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(exports)); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(module.exports)); + } + function createExporter(exports) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + return function (id, v) { return exports[id] = v; }; + } + })`); + } + + function writeUmdGlobalHeader(writer: TextWriter) { + writer.writeLines(` + (function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } + })`); + } + function writeUmdBundle(node: ts.Bundle) { + if (libKind === LibKind.UmdGlobal) { + unknownGlobals.add("global"); + } + + unknownGlobals.add("define").add("module"); visit(node); const writer = new TextWriter(); - writer.writeLines(copyrightNotice); + writeHeader(writer); writer.writeLines(globalWriter.toString()); - writer.writeLines(libKind === LibKind.UmdGlobal ? umdGlobalsExporter : umdExporter); + if (libKind === LibKind.Umd) { + writeUmdHeader(writer); + } + else { + writeUmdGlobalHeader(writer); + } + writer.writeLine(`(function (exporter) {`); writer.indent++; writer.writeLines(bodyWriter.toString()); @@ -191,15 +281,41 @@ function write(source: ts.Bundle, libKind: LibKind) { return writer.toString(); } - function writeES2015Bundle(node: ts.Bundle) { + function writeAmdBundle(node: ts.Bundle) { + unknownGlobals.add("define"); visit(node); const writer = new TextWriter(); - writer.writeLines(copyrightNotice); + writeHeader(writer); + writer.writeLine(`define("tslib", ["exports"], function (exports) {`); + writer.indent++; + writer.writeLines(bodyWriter.toString()); + writer.writeLine(); + writer.writeLines(exportWriter.toString()); + writer.indent--; + writer.writeLine(`});`); + return writer.toString(); + } + + function writeCommonJSBundle(node: ts.Bundle) { + visit(node); + const writer = new TextWriter(); + writeHeader(writer); + writer.writeLines(bodyWriter.toString()); + writer.writeLine(); + writer.writeLines(exportWriter.toString()); + return writer.toString(); + } + + function writeES2015OrGlobalBundle(node: ts.Bundle) { + visit(node); + const writer = new TextWriter(); + writeHeader(writer); writer.writeLines(bodyWriter.toString()); return writer.toString(); } function visit(node: ts.Node) { + visitNames(node); switch (node.kind) { case ts.SyntaxKind.Bundle: return visitBundle(node); case ts.SyntaxKind.SourceFile: return visitSourceFile(node); @@ -220,74 +336,87 @@ function write(source: ts.Bundle, libKind: LibKind) { node.statements.forEach(visit); } + function isExport(node: ts.Node) { + return !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export); + } + function visitFunctionDeclaration(node: ts.FunctionDeclaration) { - if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { - if (libKind === LibKind.Umd || libKind === LibKind.UmdGlobal) { - exportWriter.writeLine(`exporter("${ts.idText(node.name)}", ${ts.idText(node.name)});`); - const parametersText = sourceFile.text.slice(node.parameters.pos, node.parameters.end); - const bodyText = node.body.getText(); - if (libKind === LibKind.UmdGlobal) { - globalWriter.writeLine(`var ${ts.idText(node.name)};`); - bodyWriter.writeLines(`${ts.idText(node.name)} = function (${parametersText}) ${bodyText};`); - } - else { - bodyWriter.writeLines(`function ${ts.idText(node.name)}(${parametersText}) ${bodyText}`); - } - bodyWriter.writeLine(); - return; + if (isExport(node) && rewriteExports) { + const nameText = ts.idText(node.name); + const parametersText = sourceFile.text.slice(node.parameters.pos, node.parameters.end); + const bodyText = node.body.getText(); + if (useGlobals) { + globalWriter.writeLine(`var ${nameText};`); + bodyWriter.writeLines(`${nameText} = function (${parametersText}) ${bodyText};`); + } + else { + bodyWriter.writeLines(`function ${nameText}(${parametersText}) ${bodyText}`); } + if (useExporter) exportWriter.writeLine(`exporter(${JSON.stringify(nameText)}, ${nameText});`); + if (useExports) exportWriter.writeLine(`exports.${nameText} = ${nameText};`); + } + else { + bodyWriter.writeLines(node.getText()); } - bodyWriter.writeLines(node.getText()); bodyWriter.writeLine(); } - function visitVariableStatement(node: ts.VariableStatement) { - if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) { + function checkVariableStatement(node: ts.VariableStatement) { + if (isExport(node)) { if (node.declarationList.declarations.length > 1) { reportError(node, `Only single variables are supported on exported variable statements.`); - return; + return false; } const variable = node.declarationList.declarations[0]; if (variable.name.kind !== ts.SyntaxKind.Identifier) { reportError(variable.name, `Only identifier names are supported on exported variable statements.`); - return; + return false; } if (!variable.initializer) { reportError(variable.name, `Exported variables must have an initializer.`); - return; + return false; } + } + return true; + } - if (libKind === LibKind.Umd || libKind === LibKind.UmdGlobal) { - if (libKind === LibKind.UmdGlobal) { - globalWriter.writeLine(`var ${ts.idText(variable.name)};`); - bodyWriter.writeLines(`${ts.idText(variable.name)} = ${variable.initializer.getText()};`); - } - else if (ts.isFunctionExpression(variable.initializer)) { - const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); - const bodyText = variable.initializer.body.getText(); - bodyWriter.writeLines(`function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); - bodyWriter.writeLine(); - } - else { - bodyWriter.writeLines(`var ${ts.idText(variable.name)} = ${variable.initializer.getText()};`); - } - bodyWriter.writeLine(); - exportWriter.writeLine(`exporter("${ts.idText(variable.name)}", ${ts.idText(variable.name)});`); - return; + function visitVariableStatement(node: ts.VariableStatement) { + if (!checkVariableStatement(node)) return; + if (isExport(node) && rewriteExports) { + const variable = node.declarationList.declarations[0] as ts.VariableDeclaration & { name: ts.Identifier }; + const nameText = ts.idText(variable.name); + if (useGlobals) { + globalWriter.writeLine(`var ${nameText};`); + bodyWriter.writeLines(`${nameText} = ${variable.initializer.getText()};`); } - - if (ts.isFunctionExpression(variable.initializer)) { - const parametersText = sourceFile.text.slice(variable.initializer.parameters.pos, variable.initializer.parameters.end); - const bodyText = variable.initializer.body.getText(); - bodyWriter.writeLines(`export function ${ts.idText(variable.name)}(${parametersText}) ${bodyText}`); - bodyWriter.writeLine(); - return; + else { + bodyWriter.writeLines(`var ${nameText} = ${variable.initializer.getText()};`); } + if (useExporter) exportWriter.writeLine(`exporter(${JSON.stringify(nameText)}, ${nameText});`); + if (useExports) exportWriter.writeLine(`exports.${nameText} = ${nameText};`); } - - bodyWriter.writeLines(node.getText()); + else { + bodyWriter.writeLines(node.getText()); + } bodyWriter.writeLine(); } + + function visitNames(node: ts.Node) { + if (!node) return; + if (ts.isIdentifier(node)) return visitIdentifier(node); + ts.forEachChild(node, visitNames); + } + + function visitIdentifier(node: ts.Identifier) { + const nameText = ts.idText(node); + const parent = node.parent; + if (ts.isPropertyAccessExpression(parent) && parent.name === node || + ts.isPropertyAssignment(parent) && parent.name === node || + unknownGlobals.has(nameText)) return; + + const sym = checker.getSymbolAtLocation(node); + if (!sym) unknownGlobals.add(nameText); + } } diff --git a/src/umd.js b/src/umd.js deleted file mode 100644 index d9c108c..0000000 --- a/src/umd.js +++ /dev/null @@ -1,17 +0,0 @@ -(function (factory) { - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(exports)); }); - } - else if (typeof module === "object" && typeof module.exports === "object") { - factory(createExporter(module.exports)); - } - function createExporter(exports) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - return function (id, v) { return exports[id] = v; }; - } -}) \ No newline at end of file diff --git a/src/umdGlobals.js b/src/umdGlobals.js deleted file mode 100644 index bb09c99..0000000 --- a/src/umdGlobals.js +++ /dev/null @@ -1,23 +0,0 @@ -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if (typeof module === "object" && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) \ No newline at end of file diff --git a/tslib.amd.js b/tslib.amd.js new file mode 100644 index 0000000..30d15c7 --- /dev/null +++ b/tslib.amd.js @@ -0,0 +1,202 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global define, Reflect, Promise, Symbol */ + +define("tslib", ["exports"], function (exports) { + var 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]; }; + + function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + var __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; + } + + function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + } + + function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + } + + function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + } + + function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + } + + function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + } + + function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + + function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + } + + function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + } + + function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + } + + function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + } + + function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + } + + function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + } + + function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + } + + function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + } + + function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + } + + function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + } + + exports.__extends = __extends; + exports.__assign = __assign; + exports.__rest = __rest; + exports.__decorate = __decorate; + exports.__param = __param; + exports.__metadata = __metadata; + exports.__awaiter = __awaiter; + exports.__generator = __generator; + exports.__exportStar = __exportStar; + exports.__values = __values; + exports.__read = __read; + exports.__spread = __spread; + exports.__await = __await; + exports.__asyncGenerator = __asyncGenerator; + exports.__asyncDelegator = __asyncDelegator; + exports.__asyncValues = __asyncValues; + exports.__makeTemplateObject = __makeTemplateObject; + exports.__importStar = __importStar; + exports.__importDefault = __importDefault; +}); \ No newline at end of file diff --git a/tslib.cjs.js b/tslib.cjs.js new file mode 100644 index 0000000..1091ac9 --- /dev/null +++ b/tslib.cjs.js @@ -0,0 +1,200 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise, Symbol */ + +var 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]; }; + +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; +}; + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +} + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} + +exports.__extends = __extends; +exports.__assign = __assign; +exports.__rest = __rest; +exports.__decorate = __decorate; +exports.__param = __param; +exports.__metadata = __metadata; +exports.__awaiter = __awaiter; +exports.__generator = __generator; +exports.__exportStar = __exportStar; +exports.__values = __values; +exports.__read = __read; +exports.__spread = __spread; +exports.__await = __await; +exports.__asyncGenerator = __asyncGenerator; +exports.__asyncDelegator = __asyncDelegator; +exports.__asyncValues = __asyncValues; +exports.__makeTemplateObject = __makeTemplateObject; +exports.__importStar = __importStar; +exports.__importDefault = __importDefault; \ No newline at end of file diff --git a/tslib.es6.js b/tslib.es6.js index ecb0eb8..a744447 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -1,180 +1,180 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var 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]; }; - -export function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - -export var __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; -} - -export function __rest(s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; -} - -export function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - -export function __param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -} - -export function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - -export function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - -export function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [0, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -} - -export function __exportStar(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} - -export function __values(o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -} - -export function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -} - -export function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} - -export function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - -export function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } -} - -export function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } -} - -export function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } -} - -export function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; -}; - -export function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result.default = mod; - return result; -} - -export function __importDefault(mod) { - return (mod && mod.__esModule) ? mod : { default: mod }; -} +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise, Symbol */ + +var 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]; }; + +export function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +export var __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; +}; + +export function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +export function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +export function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +export function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +export function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +export function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +export function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +export function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +export function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +export function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +export function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +export function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +export function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +export function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +export function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +} + +export function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +} + +export function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} \ No newline at end of file diff --git a/tslib.global.js b/tslib.global.js new file mode 100644 index 0000000..a744447 --- /dev/null +++ b/tslib.global.js @@ -0,0 +1,180 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise, Symbol */ + +var 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]; }; + +export function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +export var __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; +}; + +export function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +} + +export function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +export function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +export function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +export function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +export function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +export function __exportStar(m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} + +export function __values(o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +} + +export function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +export function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +export function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +export function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +export function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } +} + +export function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +export function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +} + +export function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +} + +export function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} \ No newline at end of file diff --git a/tslib.js b/tslib.js index d8d32c0..ebbc9ae 100644 --- a/tslib.js +++ b/tslib.js @@ -1,243 +1,244 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -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 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global global, define, System, Reflect, Promise */ -var __extends; -var __assign; -var __rest; -var __decorate; -var __param; -var __metadata; -var __awaiter; -var __generator; -var __exportStar; -var __values; -var __read; -var __spread; -var __await; -var __asyncGenerator; -var __asyncDelegator; -var __asyncValues; -var __makeTemplateObject; -var __importStar; -var __importDefault; -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if (typeof module === "object" && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) -(function (exporter) { - var 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]; }; - - __extends = function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) - t[p[i]] = s[p[i]]; - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __awaiter = function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - }; - - __generator = function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [0, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } - }; - - __exportStar = function (m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; - }; - - __values = function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - }; - - __read = function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; - }; - - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - __importStar = function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); -}); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +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 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global global, define, module, Reflect, Promise, Symbol */ + +var __extends; +var __assign; +var __rest; +var __decorate; +var __param; +var __metadata; +var __awaiter; +var __generator; +var __exportStar; +var __values; +var __read; +var __spread; +var __await; +var __asyncGenerator; +var __asyncDelegator; +var __asyncValues; +var __makeTemplateObject; +var __importStar; +var __importDefault; +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if (typeof module === "object" && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) +(function (exporter) { + var 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]; }; + + __extends = function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __awaiter = function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + + __generator = function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + + __exportStar = function (m, exports) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + }; + + __values = function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + }; + + __read = function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + }; + + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + __importStar = function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); +}); \ No newline at end of file diff --git a/tslib.umd.js b/tslib.umd.js index d93b0f8..fb08c79 100644 --- a/tslib.umd.js +++ b/tslib.umd.js @@ -12,6 +12,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +/* global define, module, Reflect, Promise, Symbol */ (function (factory) { if (typeof define === "function" && define.amd) { From 58ff634e00329491db9ed9be60fd0b31a350517c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 14 May 2018 13:31:16 -0700 Subject: [PATCH 4/4] Generate html import files --- scripts/generator.ts | 3 +++ tslib.amd.html | 1 + tslib.cjs.html | 1 + tslib.global.html | 1 + tslib.umd.html | 1 + 5 files changed, 7 insertions(+) create mode 100644 tslib.amd.html create mode 100644 tslib.cjs.html create mode 100644 tslib.global.html create mode 100644 tslib.umd.html diff --git a/scripts/generator.ts b/scripts/generator.ts index 0a9a325..f216daf 100644 --- a/scripts/generator.ts +++ b/scripts/generator.ts @@ -150,6 +150,9 @@ function generateSingleFile(program: ts.Program, outFile: string, libKind: LibKi const output = write(bundle, program.getTypeChecker(), libKind); mkdirpSync(path.dirname(outFile)); fs.writeFileSync(outFile, output, "utf8"); + + const htmlOutFile = outFile.replace(/\.js$/, ".html"); + fs.writeFileSync(htmlOutFile, ``); } function formatMessage(node: ts.Node, message: string) { diff --git a/tslib.amd.html b/tslib.amd.html new file mode 100644 index 0000000..152f22a --- /dev/null +++ b/tslib.amd.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tslib.cjs.html b/tslib.cjs.html new file mode 100644 index 0000000..097b8ac --- /dev/null +++ b/tslib.cjs.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tslib.global.html b/tslib.global.html new file mode 100644 index 0000000..cba4d34 --- /dev/null +++ b/tslib.global.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tslib.umd.html b/tslib.umd.html new file mode 100644 index 0000000..699d82f --- /dev/null +++ b/tslib.umd.html @@ -0,0 +1 @@ + \ No newline at end of file