jsii-rosetta 6.0.15-dev.4 → 6.0.16-dev.0

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.
package/lib/json.d.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  import { Readable } from 'node:stream';
2
+ /**
3
+ * Load 'stream-json' eagerly, not lazily.
4
+ *
5
+ * Necessary for tests that use mockfs, otherwise the mocks will
6
+ * interfere with the lazy import() call.
7
+ */
8
+ export declare function eagerlyLoadStreamJsonBeforeMockFs(): Promise<void>;
2
9
  /**
3
10
  * Asynchronously parses a single JSON value from the provided reader. The JSON
4
11
  * text might be longer than what could fit in a single string value, since the
package/lib/json.js CHANGED
@@ -1,18 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eagerlyLoadStreamJsonBeforeMockFs = eagerlyLoadStreamJsonBeforeMockFs;
6
4
  exports.parse = parse;
7
5
  exports.stringify = stringify;
8
6
  const node_stream_1 = require("node:stream");
9
7
  const node_util_1 = require("node:util");
10
- const stream_json_1 = require("stream-json");
11
- const Assembler_1 = __importDefault(require("stream-json/Assembler"));
12
- const Disassembler_1 = require("stream-json/Disassembler");
13
- const Stringer_1 = require("stream-json/Stringer");
14
8
  // NB: In node 15+, there is a node:stream.promises object that has this built-in.
15
9
  const asyncPipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
10
+ /**
11
+ * Load 'stream-json' eagerly, not lazily.
12
+ *
13
+ * Necessary for tests that use mockfs, otherwise the mocks will
14
+ * interfere with the lazy import() call.
15
+ */
16
+ async function eagerlyLoadStreamJsonBeforeMockFs() {
17
+ await loadStreamJson();
18
+ }
19
+ async function loadStreamJson() {
20
+ // Must not be loaded through Promise.all() because then we get race conditions
21
+ // on Node 20-22.
22
+ const { parser } = await import('stream-json/parser.js');
23
+ const { Assembler } = await import('stream-json/assembler.js');
24
+ const { disassembler } = await import('stream-json/disassembler.js');
25
+ const { stringer } = await import('stream-json/stringer.js');
26
+ return { parser, Assembler, disassembler, stringer };
27
+ }
16
28
  /**
17
29
  * Asynchronously parses a single JSON value from the provided reader. The JSON
18
30
  * text might be longer than what could fit in a single string value, since the
@@ -25,9 +37,13 @@ const asyncPipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
25
37
  *
26
38
  * @returns the parse JSON value as a Javascript value.
27
39
  */
28
- function parse(reader) {
29
- const assembler = new Assembler_1.default();
30
- const jsonParser = (0, stream_json_1.parser)();
40
+ async function parse(reader) {
41
+ // Load ESM package from CJS. Not in parallel to avoid triggering a bug in Nodes 20-22.
42
+ const { parser, Assembler } = await loadStreamJson();
43
+ const assembler = new Assembler();
44
+ // v3's subpath factories expose `.asStream()` to obtain a Node Duplex stream
45
+ // (the bare factory returns a `stream-chain` stage, not a Node stream).
46
+ const jsonParser = parser.asStream();
31
47
  assembler.connectTo(jsonParser);
32
48
  return asyncPipeline(reader, jsonParser).then(() => assembler.current);
33
49
  }
@@ -43,9 +59,13 @@ function parse(reader) {
43
59
  * @param writers the sequence of write streams to use to output the JSON text.
44
60
  */
45
61
  async function stringify(value, ...writers) {
62
+ // Load ESM package from CJS. Not in parallel to avoid triggering a bug in Nodes 20-22.
63
+ const { disassembler, stringer } = await loadStreamJson();
46
64
  const reader = new node_stream_1.Readable({ objectMode: true });
47
65
  reader.push(value);
48
66
  reader.push(null);
49
- return asyncPipeline(reader, (0, Disassembler_1.disassembler)(), (0, Stringer_1.stringer)(), ...writers);
67
+ // v3's subpath factories expose `.asStream()` to obtain a Node Duplex stream
68
+ // (the bare factory returns a `stream-chain` stage, not a Node stream).
69
+ return asyncPipeline(reader, disassembler.asStream(), stringer.asStream(), ...writers);
50
70
  }
51
71
  //# sourceMappingURL=json.js.map
package/lib/json.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;;;;AAsBA,sBAKC;AAaD,8BASC;AAjDD,6CAAiD;AACjD,yCAAsC;AACtC,6CAAqC;AACrC,sEAA8C;AAC9C,2DAAwD;AACxD,mDAAgD;AAEhD,kFAAkF;AAClF,MAAM,aAAa,GAAG,IAAA,qBAAS,EAAC,sBAAQ,CAAC,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,SAAgB,KAAK,CAAC,MAAgB;IACpC,MAAM,SAAS,GAAG,IAAI,mBAAS,EAAE,CAAC;IAClC,MAAM,UAAU,GAAG,IAAA,oBAAM,GAAE,CAAC;IAC5B,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAChC,OAAO,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,SAAS,CAC7B,KAAU,EACV,GAAG,OAA8D;IAEjE,MAAM,MAAM,GAAG,IAAI,sBAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElB,OAAO,aAAa,CAAC,MAAM,EAAE,IAAA,2BAAY,GAAE,EAAE,IAAA,mBAAQ,GAAE,EAAE,GAAG,OAAO,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { Readable, pipeline } from 'node:stream';\nimport { promisify } from 'node:util';\nimport { parser } from 'stream-json';\nimport Assembler from 'stream-json/Assembler';\nimport { disassembler } from 'stream-json/Disassembler';\nimport { stringer } from 'stream-json/Stringer';\n\n// NB: In node 15+, there is a node:stream.promises object that has this built-in.\nconst asyncPipeline = promisify(pipeline);\n\n/**\n * Asynchronously parses a single JSON value from the provided reader. The JSON\n * text might be longer than what could fit in a single string value, since the\n * processing is done in a streaming manner.\n *\n * Prefer using JSON.parse if you know the entire JSON text is always small\n * enough to fit in a string value, as this would have better performance.\n *\n * @param reader the reader from which to consume JSON text.\n *\n * @returns the parse JSON value as a Javascript value.\n */\nexport function parse(reader: Readable): Promise<any> {\n const assembler = new Assembler();\n const jsonParser = parser();\n assembler.connectTo(jsonParser);\n return asyncPipeline(reader, jsonParser).then(() => assembler.current);\n}\n\n/**\n * Serializes a possibly large object into the provided writer. The object may\n * be large enough that the JSON text cannot fit in a single string value.\n *\n * Prefer using JSON.stringify if you know the object is always small enough\n * that the JSON text can fit in a single string value, as this would have\n * better performance.\n *\n * @param value the value to be serialized.\n * @param writers the sequence of write streams to use to output the JSON text.\n */\nexport async function stringify(\n value: any,\n ...writers: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream>\n): Promise<void> {\n const reader = new Readable({ objectMode: true });\n reader.push(value);\n reader.push(null);\n\n return asyncPipeline(reader, disassembler(), stringer(), ...writers);\n}\n"]}
1
+ {"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":";;AAYA,8EAEC;AAwBD,sBAUC;AAaD,8BAcC;AA3ED,6CAAiD;AACjD,yCAAsC;AAEtC,kFAAkF;AAClF,MAAM,aAAa,GAAG,IAAA,qBAAS,EAAC,sBAAQ,CAAC,CAAC;AAE1C;;;;;GAKG;AACI,KAAK,UAAU,iCAAiC;IACrD,MAAM,cAAc,EAAE,CAAC;AACzB,CAAC;AAED,KAAK,UAAU,cAAc;IAC3B,+EAA+E;IAC/E,iBAAiB;IACjB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;IACzD,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAC/D,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IACrE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAC7D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,KAAK,CAAC,MAAgB;IAC1C,uFAAuF;IACvF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,EAAE,CAAC;IAErD,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAClC,6EAA6E;IAC7E,wEAAwE;IACxE,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACrC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAChC,OAAO,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;;GAUG;AACI,KAAK,UAAU,SAAS,CAC7B,KAAU,EACV,GAAG,OAA8D;IAEjE,uFAAuF;IACvF,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,MAAM,cAAc,EAAE,CAAC;IAE1D,MAAM,MAAM,GAAG,IAAI,sBAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElB,6EAA6E;IAC7E,wEAAwE;IACxE,OAAO,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC;AACzF,CAAC","sourcesContent":["import { Readable, pipeline } from 'node:stream';\nimport { promisify } from 'node:util';\n\n// NB: In node 15+, there is a node:stream.promises object that has this built-in.\nconst asyncPipeline = promisify(pipeline);\n\n/**\n * Load 'stream-json' eagerly, not lazily.\n *\n * Necessary for tests that use mockfs, otherwise the mocks will\n * interfere with the lazy import() call.\n */\nexport async function eagerlyLoadStreamJsonBeforeMockFs() {\n await loadStreamJson();\n}\n\nasync function loadStreamJson() {\n // Must not be loaded through Promise.all() because then we get race conditions\n // on Node 20-22.\n const { parser } = await import('stream-json/parser.js');\n const { Assembler } = await import('stream-json/assembler.js');\n const { disassembler } = await import('stream-json/disassembler.js');\n const { stringer } = await import('stream-json/stringer.js');\n return { parser, Assembler, disassembler, stringer };\n}\n\n/**\n * Asynchronously parses a single JSON value from the provided reader. The JSON\n * text might be longer than what could fit in a single string value, since the\n * processing is done in a streaming manner.\n *\n * Prefer using JSON.parse if you know the entire JSON text is always small\n * enough to fit in a string value, as this would have better performance.\n *\n * @param reader the reader from which to consume JSON text.\n *\n * @returns the parse JSON value as a Javascript value.\n */\nexport async function parse(reader: Readable): Promise<any> {\n // Load ESM package from CJS. Not in parallel to avoid triggering a bug in Nodes 20-22.\n const { parser, Assembler } = await loadStreamJson();\n\n const assembler = new Assembler();\n // v3's subpath factories expose `.asStream()` to obtain a Node Duplex stream\n // (the bare factory returns a `stream-chain` stage, not a Node stream).\n const jsonParser = parser.asStream();\n assembler.connectTo(jsonParser);\n return asyncPipeline(reader, jsonParser).then(() => assembler.current);\n}\n\n/**\n * Serializes a possibly large object into the provided writer. The object may\n * be large enough that the JSON text cannot fit in a single string value.\n *\n * Prefer using JSON.stringify if you know the object is always small enough\n * that the JSON text can fit in a single string value, as this would have\n * better performance.\n *\n * @param value the value to be serialized.\n * @param writers the sequence of write streams to use to output the JSON text.\n */\nexport async function stringify(\n value: any,\n ...writers: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream>\n): Promise<void> {\n // Load ESM package from CJS. Not in parallel to avoid triggering a bug in Nodes 20-22.\n const { disassembler, stringer } = await loadStreamJson();\n\n const reader = new Readable({ objectMode: true });\n reader.push(value);\n reader.push(null);\n\n // v3's subpath factories expose `.asStream()` to obtain a Node Duplex stream\n // (the bare factory returns a `stream-chain` stage, not a Node stream).\n return asyncPipeline(reader, disassembler.asStream(), stringer.asStream(), ...writers);\n}\n"]}
package/package.json CHANGED
@@ -34,11 +34,10 @@
34
34
  "@actions/core": "^1.11.1",
35
35
  "@actions/github": "^5.1.1",
36
36
  "@types/commonmark": "^0.27.10",
37
- "@types/jest": "^29.5.14",
37
+ "@types/jest": "^30",
38
38
  "@types/mock-fs": "^4.13.4",
39
39
  "@types/node": "^20",
40
40
  "@types/semver": "^7.8.0",
41
- "@types/stream-json": "^1.7.8",
42
41
  "@types/tar": "^6.1.13",
43
42
  "@types/workerpool": "^6.4.7",
44
43
  "@typescript-eslint/eslint-plugin": "^8",
@@ -51,13 +50,13 @@
51
50
  "eslint-plugin-prettier": "^4.2.5",
52
51
  "eslint-plugin-unicorn": "^56.0.1",
53
52
  "fs-monkey": "^1.1.0",
54
- "jest": "^29.7.0",
55
- "memfs": "^4.71.0",
53
+ "jest": "^30",
54
+ "memfs": "^4.74.0",
56
55
  "mock-fs": "^5.5.0",
57
56
  "prettier": "^2.8.8",
58
- "projen": "^0.103.20",
57
+ "projen": "^0.103.23",
59
58
  "tar": "^6.2.1",
60
- "ts-jest": "^29.4.12",
59
+ "ts-jest": "^29",
61
60
  "ts-node": "^10.9.2"
62
61
  },
63
62
  "dependencies": {
@@ -70,7 +69,7 @@
70
69
  "jsii": "~6.0.0",
71
70
  "semver": "^7.8.5",
72
71
  "semver-intersect": "^1.5.0",
73
- "stream-json": "^1.9.1",
72
+ "stream-json": "^3.6.0",
74
73
  "typescript": "~6.0",
75
74
  "workerpool": "^6.5.1",
76
75
  "yargs": "^17.7.3"
@@ -91,7 +90,7 @@
91
90
  "publishConfig": {
92
91
  "access": "public"
93
92
  },
94
- "version": "6.0.15-dev.4",
93
+ "version": "6.0.16-dev.0",
95
94
  "packageManager": "yarn@4.13.0",
96
95
  "types": "lib/index.d.ts",
97
96
  "exports": {