quicktype-core 23.3.19 → 23.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Readable } from "readable-stream";
|
|
2
2
|
export declare function readableFromFileOrURL(fileOrURL: string, httpHeaders?: string[]): Promise<Readable>;
|
|
3
3
|
export declare function readFromFileOrURL(fileOrURL: string, httpHeaders?: string[]): Promise<string>;
|
package/dist/input/io/NodeIO.js
CHANGED
|
@@ -41,6 +41,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
45
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
46
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
47
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
48
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
49
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
50
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
51
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
52
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
53
|
+
function fulfill(value) { resume("next", value); }
|
|
54
|
+
function reject(value) { resume("throw", value); }
|
|
55
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
56
|
+
};
|
|
44
57
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
58
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
59
|
};
|
|
@@ -52,6 +65,7 @@ const path = __importStar(require("path"));
|
|
|
52
65
|
const ts_necessities_1 = require("@glideapps/ts-necessities");
|
|
53
66
|
const browser_or_node_1 = require("browser-or-node");
|
|
54
67
|
const is_url_1 = __importDefault(require("is-url"));
|
|
68
|
+
const readable_stream_1 = require("readable-stream");
|
|
55
69
|
const Messages_1 = require("../../Messages");
|
|
56
70
|
const Support_1 = require("../../support/Support");
|
|
57
71
|
const get_stream_1 = require("./get-stream");
|
|
@@ -73,6 +87,35 @@ function parseHeaders(httpHeaders) {
|
|
|
73
87
|
return result;
|
|
74
88
|
}, {});
|
|
75
89
|
}
|
|
90
|
+
function webStreamChunks(stream) {
|
|
91
|
+
return __asyncGenerator(this, arguments, function* webStreamChunks_1() {
|
|
92
|
+
const reader = stream.getReader();
|
|
93
|
+
try {
|
|
94
|
+
for (;;) {
|
|
95
|
+
const { done, value } = yield __await(reader.read());
|
|
96
|
+
if (done)
|
|
97
|
+
return yield __await(void 0);
|
|
98
|
+
yield yield __await((0, ts_necessities_1.defined)(value));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
reader.releaseLock();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// readable-stream implements Readable.from (it can't do Readable.fromWeb),
|
|
107
|
+
// but @types/readable-stream doesn't declare it, hence this cast.
|
|
108
|
+
const ReadableWithFrom = readable_stream_1.Readable;
|
|
109
|
+
function readableFromResponseBody(body) {
|
|
110
|
+
// Native fetch (Node >= 18, browsers) returns a WHATWG ReadableStream,
|
|
111
|
+
// which lacks the Node stream API that our consumers rely on, so we have
|
|
112
|
+
// to wrap it. The cross-fetch fallback (node-fetch) already returns a
|
|
113
|
+
// Node stream, which we pass through unchanged.
|
|
114
|
+
if (typeof body.getReader === "function") {
|
|
115
|
+
return ReadableWithFrom.from(webStreamChunks(body), { objectMode: false });
|
|
116
|
+
}
|
|
117
|
+
return body;
|
|
118
|
+
}
|
|
76
119
|
function resolveSymbolicLink(filePath) {
|
|
77
120
|
if (!fs.lstatSync(filePath).isSymbolicLink()) {
|
|
78
121
|
return filePath;
|
|
@@ -90,7 +133,7 @@ function readableFromFileOrURL(fileOrURL, httpHeaders) {
|
|
|
90
133
|
const response = yield (0, _fetch_1.fetch)(fileOrURL, {
|
|
91
134
|
headers: parseHeaders(httpHeaders),
|
|
92
135
|
});
|
|
93
|
-
return (0, ts_necessities_1.defined)(response.body);
|
|
136
|
+
return readableFromResponseBody((0, ts_necessities_1.defined)(response.body));
|
|
94
137
|
}
|
|
95
138
|
if (browser_or_node_1.isNode) {
|
|
96
139
|
if (fileOrURL === "-") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const keywords: readonly ["Serialize", "Deserialize", "{{root}}", "$crate", "as", "async", "box", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", "use", "where", "while", "abstract", "alignof", "become", "do", "final", "macro", "offsetof", "override", "priv", "proc", "pure", "sizeof", "typeof", "unsized", "virtual", "yield", "catch", "default", "dyn", "'static", "union", "option"];
|
|
1
|
+
export declare const keywords: readonly ["Serialize", "Deserialize", "{{root}}", "$crate", "as", "async", "box", "break", "const", "continue", "crate", "else", "enum", "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move", "mut", "pub", "ref", "return", "self", "Self", "static", "struct", "super", "trait", "true", "type", "unsafe", "use", "where", "while", "abstract", "alignof", "become", "do", "final", "macro", "offsetof", "override", "priv", "proc", "pure", "sizeof", "typeof", "unsized", "virtual", "yield", "catch", "default", "dyn", "'static", "union", "option", "Option", "Some", "None", "Result", "Ok", "Err", "String", "Vec", "Box", "HashMap"];
|
|
@@ -71,4 +71,19 @@ exports.keywords = [
|
|
|
71
71
|
"union",
|
|
72
72
|
// Conflict between `std::Option` and potentially generated Option
|
|
73
73
|
"option",
|
|
74
|
+
// Prelude and standard-library names that generated code refers to
|
|
75
|
+
// unqualified; a generated type with one of these names would shadow
|
|
76
|
+
// them and break compilation (e.g. a struct named `Option`).
|
|
77
|
+
"Option",
|
|
78
|
+
"Some",
|
|
79
|
+
"None",
|
|
80
|
+
"Result",
|
|
81
|
+
"Ok",
|
|
82
|
+
"Err",
|
|
83
|
+
"String",
|
|
84
|
+
"Vec",
|
|
85
|
+
"Box",
|
|
86
|
+
// Generated code contains `use std::collections::HashMap;`, which a
|
|
87
|
+
// type of the same name would conflict with.
|
|
88
|
+
"HashMap",
|
|
74
89
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quicktype-core",
|
|
3
|
-
"version": "23.3.
|
|
3
|
+
"version": "23.3.21",
|
|
4
4
|
"description": "The quicktype engine as a library",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"repository": "https://github.com/glideapps/quicktype",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"clean": "rm -rf dist node_modules *~",
|
|
11
|
-
"build": "
|
|
11
|
+
"build": "tsc"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@glideapps/ts-necessities": "2.2.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetch: any;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetch = void 0;
|
|
4
|
-
// No logging here: this module runs at import time, and anything written to
|
|
5
|
-
// stdout corrupts redirected CLI output (issue #2874).
|
|
6
|
-
exports.fetch = require("cross-fetch").default;
|