@mcpher/gas-fakes 1.2.13 → 1.2.14

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/package.json CHANGED
@@ -20,12 +20,9 @@
20
20
  "keyv": "^5.5.0",
21
21
  "keyv-file": "^5.1.3",
22
22
  "mime": "^4.0.7",
23
- "sinon": "^21.0.0",
24
23
  "sleep-synchronously": "^2.0.0",
25
- "subsume": "^4.0.0",
26
24
  "to-readable-stream": "^4.0.0",
27
25
  "unzipper": "^0.12.3",
28
- "yoctocolors": "^2.1.2",
29
26
  "zod": "^3.25.76"
30
27
  },
31
28
  "type": "module",
@@ -37,7 +34,7 @@
37
34
  },
38
35
  "name": "@mcpher/gas-fakes",
39
36
  "author": "bruce mcpherson",
40
- "version": "1.2.13",
37
+ "version": "1.2.14",
41
38
  "license": "MIT",
42
39
  "main": "main.js",
43
40
  "description": "A proof of concept implementation of Apps Script Environment on Node",
@@ -1,80 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import childProcess from 'node:child_process';
3
- import v8 from 'node:v8';
4
- import process from 'node:process';
5
- import Subsume from 'subsume';
6
-
7
- const HUNDRED_MEGABYTES = 1000 * 1000 * 100;
8
-
9
- export default function makeSynchronous(function_) {
10
- return (...arguments_) => {
11
- const serializedArguments = v8.serialize(arguments_).toString('hex');
12
- const subsume = new Subsume();
13
-
14
- // TODO: Use top-level await here when targeting Node.js 14.
15
- const input = `
16
- import v8 from 'node:v8';
17
- import Subsume from 'subsume';
18
-
19
- const subsume = new Subsume('${subsume.id}');
20
-
21
- const send = value => {
22
- const serialized = v8.serialize(value).toString('hex');
23
- process.stdout.write(subsume.compose(serialized));
24
- };
25
-
26
- (async () => {
27
- try {
28
- const arguments_ = v8.deserialize(Buffer.from('${serializedArguments}', 'hex'));
29
- const result = await (${function_})(...arguments_);
30
- send({result});
31
- } catch (error) {
32
- send({error});
33
- }
34
- })();
35
- `;
36
- //------- avoid spawing node options
37
- const customEnv = { ...process.env }
38
- if (customEnv.NODE_OPTIONS) {
39
- // drop inherited debug options
40
- customEnv.NODE_OPTIONS = customEnv.NODE_OPTIONS.split(" ")
41
- .filter(f => !f.startsWith("--inspect"))
42
- .filter(f => !f.startsWith('--require') && f.includes('ms-vscode.js-debug'))
43
- .join(" ")
44
- }
45
-
46
-
47
- //-------
48
- const { error: subprocessError, stdout, stderr } = childProcess.spawnSync(process.execPath, ['--input-type=module', '-'], {
49
- input,
50
- encoding: 'utf8',
51
- maxBuffer: HUNDRED_MEGABYTES,
52
- env: {
53
- // replace ...process.env
54
- ...customEnv,
55
- ELECTRON_RUN_AS_NODE: '1',
56
- },
57
- });
58
-
59
- if (subprocessError) {
60
- throw subprocessError;
61
- }
62
-
63
- const { data, rest } = subsume.parse(stdout);
64
-
65
- process.stdout.write(rest);
66
- process.stderr.write(stderr);
67
-
68
- if (!data) {
69
- return;
70
- }
71
-
72
- const { error, result } = v8.deserialize(Buffer.from(data, 'hex'));
73
-
74
- if (error) {
75
- throw error;
76
- }
77
-
78
- return result;
79
- };
80
- }