@typescript/ata
Advanced tools
Comparing version 0.9.0 to 0.9.2
@@ -20,8 +20,2 @@ var __defProp = Object.defineProperty; | ||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
__markAsModule(target); | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __async = (__this, __arguments, generator) => { | ||
@@ -48,10 +42,2 @@ return new Promise((resolve, reject) => { | ||
// src/index.ts | ||
__export(exports, { | ||
getFileTreeForModuleWithTag: () => getFileTreeForModuleWithTag, | ||
getNewDependencies: () => getNewDependencies, | ||
getReferencesForModule: () => getReferencesForModule, | ||
setupTypeAcquisition: () => setupTypeAcquisition | ||
}); | ||
// src/apis.ts | ||
@@ -81,3 +67,3 @@ var getNPMVersionsForModule = (config, moduleName) => { | ||
const f = config.fetcher || fetch; | ||
const res = yield f(url, { headers: { "User-Agent": `Type Acquisition ${config.projectName}` } }); | ||
const res = yield f(url); | ||
if (res.ok) { | ||
@@ -91,6 +77,3 @@ return res.text(); | ||
const f = config.fetcher || fetch; | ||
const isWebWorker = typeof self !== "undefined" && typeof self.WorkerGlobalScope !== "undefined"; | ||
const isBrowser = isWebWorker || typeof window !== "undefined" && typeof window.document !== "undefined" && typeof fetch !== "undefined"; | ||
const headers = isBrowser ? {} : { "User-Agent": `Type Acquisition ${config.projectName}` }; | ||
return f(url, { headers }).then((res) => { | ||
return f(url).then((res) => { | ||
if (res.ok) { | ||
@@ -312,4 +295,3 @@ return res.json().then((f2) => f2); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
export { | ||
getFileTreeForModuleWithTag, | ||
@@ -319,2 +301,2 @@ getNewDependencies, | ||
setupTypeAcquisition | ||
}); | ||
}; |
{ | ||
"name": "@typescript/ata", | ||
"version": "0.9.0", | ||
"version": "0.9.2", | ||
"license": "MIT", | ||
@@ -15,3 +15,3 @@ "homepage": "https://github.com/microsoft/TypeScript-Website", | ||
"scripts": { | ||
"build": "esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node && cpy src/userFacingTypes.d.ts dist/ --rename=index.d.ts && cpy src/ ../sandbox/src/vendor/ata", | ||
"build": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=esm --platform=node && cpy src/userFacingTypes.d.ts dist/ --rename=index.d.ts && cpy src/ ../sandbox/src/vendor/ata", | ||
"test": "jest", | ||
@@ -28,3 +28,6 @@ "bootstrap": "yarn build" | ||
"jest": "*" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^4.4.4" | ||
} | ||
} |
@@ -14,3 +14,3 @@ # TypeScript - Automatic Type Acquisition | ||
delegate: { | ||
receivedFile: (path: string, code: string) => { | ||
receivedFile: (code: string, path: string) => { | ||
// Add code to your runtime at the path... | ||
@@ -17,0 +17,0 @@ }, |
@@ -41,6 +41,6 @@ import { ATABootstrapConfig } from "." | ||
) => { | ||
// file has a prefix / in falr mode | ||
// file comes with a prefix / | ||
const url = `https://cdn.jsdelivr.net/npm/${moduleName}@${version}${file}` | ||
const f = config.fetcher || fetch | ||
const res = await f(url, { headers: { "User-Agent": `Type Acquisition ${config.projectName}` } }) | ||
const res = await f(url) | ||
if (res.ok) { | ||
@@ -56,19 +56,3 @@ return res.text() | ||
const isWebWorker = | ||
typeof self !== 'undefined' && | ||
// @ts-ignore | ||
typeof self.WorkerGlobalScope !== 'undefined' | ||
const isBrowser = | ||
isWebWorker || ( | ||
typeof window !== 'undefined' && | ||
typeof window.document !== 'undefined' && | ||
typeof fetch !== 'undefined' | ||
) | ||
// Don't pass in custom headers when the user-agent is a browser, this is | ||
// so we keep the request classed as a COR "simple" request | ||
const headers: any = isBrowser ? {} : { "User-Agent": `Type Acquisition ${config.projectName}` } | ||
return f(url, { headers }).then(res => { | ||
return f(url).then(res => { | ||
if (res.ok) { | ||
@@ -75,0 +59,0 @@ return res.json().then(f => f as T) |
2
30596
1
776