@somewhere-tech/cli 0.31.17 → 0.31.18

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.
Files changed (77) hide show
  1. package/dist/commands/browser.js +1 -1
  2. package/dist/commands/browser.js.map +1 -1
  3. package/dist/commands/check.js +1 -2
  4. package/dist/commands/check.js.map +1 -1
  5. package/dist/commands/dev.js +18 -383
  6. package/dist/commands/dev.js.map +1 -1
  7. package/dist/commands/status.js +0 -36
  8. package/dist/commands/status.js.map +1 -1
  9. package/dist/commands/typecheck.js +1 -1
  10. package/dist/commands/typecheck.js.map +1 -1
  11. package/dist/commands/verify.js +1 -1
  12. package/dist/commands/verify.js.map +1 -1
  13. package/dist/index.js +0 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/{local → lib}/browser-run.js +1 -1
  16. package/dist/lib/browser-run.js.map +1 -0
  17. package/dist/lib/chrome.js.map +1 -0
  18. package/dist/lib/envfile-write.js +2 -2
  19. package/dist/lib/envfile-write.js.map +1 -1
  20. package/dist/lib/frontend-dev.js +122 -0
  21. package/dist/lib/frontend-dev.js.map +1 -0
  22. package/dist/lib/init-agent-guide.js +15 -19
  23. package/dist/lib/init-agent-guide.js.map +1 -1
  24. package/dist/lib/init-green-template.js +1 -1
  25. package/dist/lib/project-urls.js +13 -0
  26. package/dist/lib/project-urls.js.map +1 -1
  27. package/npm-shrinkwrap.json +2 -17
  28. package/package.json +4 -6
  29. package/runtime/VENDOR.json +0 -2
  30. package/dist/commands/exec.js +0 -145
  31. package/dist/commands/exec.js.map +0 -1
  32. package/dist/local/browser-run.js.map +0 -1
  33. package/dist/local/chrome.js.map +0 -1
  34. package/dist/local/compiler-core.js +0 -51
  35. package/dist/local/compiler-core.js.map +0 -1
  36. package/dist/local/compiler.js +0 -683
  37. package/dist/local/compiler.js.map +0 -1
  38. package/dist/local/dev-server.js +0 -517
  39. package/dist/local/dev-server.js.map +0 -1
  40. package/dist/local/envfile.js +0 -40
  41. package/dist/local/envfile.js.map +0 -1
  42. package/dist/local/loader.js +0 -299
  43. package/dist/local/loader.js.map +0 -1
  44. package/dist/local/loopback.js +0 -129
  45. package/dist/local/loopback.js.map +0 -1
  46. package/dist/local/request-timing.js +0 -101
  47. package/dist/local/request-timing.js.map +0 -1
  48. package/dist/local/router.js +0 -114
  49. package/dist/local/router.js.map +0 -1
  50. package/dist/local/runtime.js +0 -345
  51. package/dist/local/runtime.js.map +0 -1
  52. package/dist/local/server.js +0 -309
  53. package/dist/local/server.js.map +0 -1
  54. package/dist/local/telemetry-filter.js +0 -120
  55. package/dist/local/telemetry-filter.js.map +0 -1
  56. package/node_modules/esbuild-wasm/LICENSE.md +0 -21
  57. package/node_modules/esbuild-wasm/README.md +0 -3
  58. package/node_modules/esbuild-wasm/bin/esbuild +0 -91
  59. package/node_modules/esbuild-wasm/esbuild.wasm +0 -0
  60. package/node_modules/esbuild-wasm/esm/browser.d.ts +0 -705
  61. package/node_modules/esbuild-wasm/esm/browser.js +0 -2393
  62. package/node_modules/esbuild-wasm/esm/browser.min.js +0 -20
  63. package/node_modules/esbuild-wasm/lib/browser.d.ts +0 -705
  64. package/node_modules/esbuild-wasm/lib/browser.js +0 -2438
  65. package/node_modules/esbuild-wasm/lib/browser.min.js +0 -22
  66. package/node_modules/esbuild-wasm/lib/main.d.ts +0 -705
  67. package/node_modules/esbuild-wasm/lib/main.js +0 -2051
  68. package/node_modules/esbuild-wasm/package.json +0 -19
  69. package/node_modules/esbuild-wasm/wasm_exec.js +0 -561
  70. package/node_modules/esbuild-wasm/wasm_exec_node.js +0 -39
  71. package/runtime/compiler/VENDOR.json +0 -64
  72. package/runtime/compiler/compile-core.cjs +0 -2007
  73. package/runtime/compiler/graph-contract.cjs +0 -124
  74. package/runtime/compiler/typed-functions.cjs +0 -575
  75. package/runtime/platform-context.mjs +0 -8193
  76. package/runtime/sw-init.mjs +0 -283
  77. /package/dist/{local → lib}/chrome.js +0 -0
@@ -1,309 +0,0 @@
1
- import { readFileSync, statSync } from 'node:fs';
2
- import { Readable } from 'node:stream';
3
- import { extname, join, relative, resolve, sep } from 'node:path';
4
- import chokidar from 'chokidar';
5
- import { IGNORE } from '../lib/files.js';
6
- import { bold, dim, green, red, teal, warn, yellow } from '../lib/output.js';
7
- import { bumpGeneration } from './loader.js';
8
- import { dispatchRequest, refreshRoutes } from './runtime.js';
9
- import { serveLoopback } from './loopback.js';
10
- const RELOAD_EXTS = /\.(ts|tsx|mts|js|mjs|jsx|json)$/i;
11
- async function toFetchRequest(req, port) {
12
- const url = `http://localhost:${port}${req.url ?? '/'}`;
13
- const method = (req.method ?? 'GET').toUpperCase();
14
- const headers = new Headers();
15
- for (const [k, v] of Object.entries(req.headers)) {
16
- if (v === undefined)
17
- continue;
18
- if (Array.isArray(v))
19
- for (const item of v)
20
- headers.append(k, item);
21
- else
22
- headers.set(k, v);
23
- }
24
- let body;
25
- if (method !== 'GET' && method !== 'HEAD') {
26
- const chunks = [];
27
- for await (const chunk of req)
28
- chunks.push(chunk);
29
- body = Buffer.concat(chunks);
30
- }
31
- return new Request(url, { method, headers, body });
32
- }
33
- async function writeNodeResponse(response, res) {
34
- const headers = {};
35
- for (const [k, v] of response.headers.entries()) {
36
- if (k.toLowerCase() === 'set-cookie')
37
- continue;
38
- headers[k] = v;
39
- }
40
- const cookies = response.headers.getSetCookie();
41
- if (cookies.length)
42
- headers['set-cookie'] = cookies;
43
- res.writeHead(response.status, headers);
44
- if (response.body) {
45
- Readable.fromWeb(response.body).pipe(res);
46
- }
47
- else {
48
- res.end();
49
- }
50
- }
51
- function statusColor(status) {
52
- if (status >= 500)
53
- return red;
54
- if (status >= 400)
55
- return yellow;
56
- return green;
57
- }
58
- function stamp() {
59
- const d = new Date();
60
- const p = (n) => String(n).padStart(2, '0');
61
- return `[${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}]`;
62
- }
63
- // ─── Static-file fallthrough ────────────────────────────────────────────────
64
- //
65
- // When the function router matches NO route, serve the project's frontend
66
- // straight off disk: index.html + assets, with an SPA fallback to index.html
67
- // for extensionless paths (client-side routes). This is what makes
68
- // `http://localhost:<port>/` render the actual app while `/api/*` and any
69
- // matched function keep precedence (static only runs after a null match).
70
- //
71
- // SCOPE: raw/plain files only. We do NOT compile TSX/JSX here — the platform
72
- // compiles TSX on deploy (CLAUDE.md rule 11), and serving a raw `.tsx` with a
73
- // JS MIME type would not execute in the browser. Compile-parity for
74
- // `dev --local` (so an uncompiled `src/main.tsx` entry runs locally) is a
75
- // deliberate follow-up; serving already-built/plain static files closes the
76
- // "open localhost and see your app" gap on its own.
77
- const STATIC_MIME = {
78
- '.html': 'text/html; charset=utf-8',
79
- '.htm': 'text/html; charset=utf-8',
80
- '.js': 'text/javascript; charset=utf-8',
81
- '.mjs': 'text/javascript; charset=utf-8',
82
- '.cjs': 'text/javascript; charset=utf-8',
83
- '.css': 'text/css; charset=utf-8',
84
- '.json': 'application/json; charset=utf-8',
85
- '.map': 'application/json; charset=utf-8',
86
- '.svg': 'image/svg+xml',
87
- '.png': 'image/png',
88
- '.jpg': 'image/jpeg',
89
- '.jpeg': 'image/jpeg',
90
- '.gif': 'image/gif',
91
- '.webp': 'image/webp',
92
- '.avif': 'image/avif',
93
- '.ico': 'image/x-icon',
94
- '.bmp': 'image/bmp',
95
- '.woff': 'font/woff',
96
- '.woff2': 'font/woff2',
97
- '.ttf': 'font/ttf',
98
- '.otf': 'font/otf',
99
- '.eot': 'application/vnd.ms-fontobject',
100
- '.txt': 'text/plain; charset=utf-8',
101
- '.md': 'text/markdown; charset=utf-8',
102
- '.xml': 'application/xml; charset=utf-8',
103
- '.wasm': 'application/wasm',
104
- '.pdf': 'application/pdf',
105
- '.mp3': 'audio/mpeg',
106
- '.mp4': 'video/mp4',
107
- '.webm': 'video/webm',
108
- '.wav': 'audio/wav',
109
- '.ogg': 'audio/ogg',
110
- };
111
- function safeStat(p) {
112
- try {
113
- return statSync(p);
114
- }
115
- catch {
116
- return null;
117
- }
118
- }
119
- /** Resolve `rel` under `cwd`, returning null if it would escape the root. */
120
- function resolveWithinCwd(cwd, rel) {
121
- const root = resolve(cwd);
122
- const abs = resolve(root, rel);
123
- if (abs !== root && !abs.startsWith(root + sep))
124
- return null;
125
- return abs;
126
- }
127
- /** True if any path segment is `..`, an IGNORE'd dir, or a dotfile/dotdir —
128
- * never serve `.env`, `.git`, `.somewhere.json`, etc. off disk. */
129
- function isBlockedPath(rel) {
130
- return rel
131
- .split('/')
132
- .some((seg) => seg === '..' || IGNORE.has(seg) || (seg !== '' && seg.startsWith('.')));
133
- }
134
- function fileResponse(abs, method) {
135
- const buf = readFileSync(abs);
136
- const type = STATIC_MIME[extname(abs).toLowerCase()] ?? 'application/octet-stream';
137
- const headers = {
138
- 'Content-Type': type,
139
- 'Content-Length': String(buf.byteLength),
140
- 'Cache-Control': 'no-store', // local dev — always fresh
141
- };
142
- // HEAD: headers only, no body.
143
- return new Response(method === 'HEAD' ? null : buf, { status: 200, headers });
144
- }
145
- /**
146
- * Serve a static file for a request the function router did not match.
147
- * Returns the response + a log label, or null to fall through to the 404.
148
- * GET/HEAD only — other methods on an unmatched path stay a 404.
149
- */
150
- function serveStaticFile(cwd, request) {
151
- const method = request.method.toUpperCase();
152
- if (method !== 'GET' && method !== 'HEAD')
153
- return null;
154
- let pathname;
155
- try {
156
- pathname = decodeURIComponent(new URL(request.url).pathname);
157
- }
158
- catch {
159
- return null;
160
- }
161
- const rel = pathname.replace(/^\/+/, '');
162
- // 1. Literal file on disk ("/" → index.html, "/dir/" → dir/index.html).
163
- const target = rel === '' ? 'index.html' : rel;
164
- if (!isBlockedPath(target)) {
165
- const abs = resolveWithinCwd(cwd, target);
166
- if (abs) {
167
- const st = safeStat(abs);
168
- if (st?.isFile()) {
169
- return { response: fileResponse(abs, method), label: `static:${relative(cwd, abs) || 'index.html'}` };
170
- }
171
- if (st?.isDirectory()) {
172
- const idx = resolveWithinCwd(cwd, join(target, 'index.html'));
173
- const idxStat = idx ? safeStat(idx) : null;
174
- if (idx && idxStat?.isFile()) {
175
- return { response: fileResponse(idx, method), label: `static:${relative(cwd, idx)}` };
176
- }
177
- }
178
- }
179
- }
180
- // 2. SPA fallback: extensionless paths (client routes like /about) → index.html.
181
- if (extname(pathname) === '') {
182
- const indexAbs = resolveWithinCwd(cwd, 'index.html');
183
- const st = indexAbs ? safeStat(indexAbs) : null;
184
- if (indexAbs && st?.isFile()) {
185
- return { response: fileResponse(indexAbs, method), label: 'static:index.html (spa)' };
186
- }
187
- }
188
- return null;
189
- }
190
- export function startLocalServer(state, opts) {
191
- const { port } = opts;
192
- const handleRequest = (req, res) => {
193
- void (async () => {
194
- const t0 = Date.now();
195
- let request;
196
- try {
197
- request = await toFetchRequest(req, port);
198
- }
199
- catch (err) {
200
- res.writeHead(400, { 'Content-Type': 'application/json' });
201
- res.end(JSON.stringify({ ok: false, error: 'BAD_REQUEST', message: String(err) }));
202
- return;
203
- }
204
- let result = await dispatchRequest(request, state);
205
- // Static-file fallthrough: no function route matched → try to serve the
206
- // frontend (index.html + assets, SPA fallback) from disk. Functions keep
207
- // precedence — this only runs when dispatch returned no route.
208
- if (!result.route) {
209
- const served = serveStaticFile(state.cwd, request);
210
- if (served)
211
- result = { response: served.response, route: served.label };
212
- }
213
- const ms = Date.now() - t0;
214
- const color = statusColor(result.response.status);
215
- console.log(`${dim(stamp())} ${request.method} ${new URL(request.url).pathname} ${color(String(result.response.status))} ${dim(`${ms}ms`)}${result.route ? dim(` → ${result.route}`) : ''}`);
216
- if (result.error) {
217
- const err = result.error;
218
- console.error(red(err instanceof Error ? err.stack ?? err.message : String(err)));
219
- }
220
- await writeNodeResponse(result.response, res);
221
- })().catch((err) => {
222
- console.error(red(`Internal local-server error: ${err instanceof Error ? err.stack ?? err.message : String(err)}`));
223
- if (!res.headersSent) {
224
- res.writeHead(500, { 'Content-Type': 'application/json' });
225
- }
226
- res.end(JSON.stringify({ ok: false, error: 'LOCAL_SERVER_ERROR', message: 'See terminal.' }));
227
- });
228
- };
229
- // Bind loopback only: these functions run with the developer's real CLI token
230
- // (PROJECT_API_KEY) and hit the real project, so exposing them on the LAN
231
- // would let anyone on the network invoke sw.db/sw.email etc. as the
232
- // developer. A `--host` opt-in can be added later for the deliberate
233
- // device-testing case. Both loopback FAMILIES though — see loopback.ts
234
- // (tsk_737ff0d2).
235
- void serveLoopback(handleRequest, port, (p) => {
236
- console.error(red(`Port ${p} is already in use — pass --port <n> to pick another.`));
237
- process.exit(1);
238
- }).then(() => {
239
- console.log('');
240
- console.log(`${green('▲')} ${bold('Local function runtime')} ${dim('— functions run here, sw.* talks to the real project')}`);
241
- console.log(`${teal('🌐')} ${bold('Listening:')} ${teal(`http://localhost:${port}`)}`);
242
- for (const r of state.routes) {
243
- console.log(` ${dim('•')} ${r.displayPath} ${dim(`(${r.file})`)}`);
244
- }
245
- console.log(dim(' unmatched paths → static files from this folder (index.html + assets, SPA fallback). ' +
246
- 'raw TSX is compiled on deploy, not locally.'));
247
- if (state.missingEnvKeys.length) {
248
- warn(`Platform env keys with no local value (access will throw): ${state.missingEnvKeys.join(', ')}. ` +
249
- 'Add them to .env in this directory to use them locally.');
250
- }
251
- console.log(dim(' save a file to hot-reload. Ctrl-C to stop.\n'));
252
- });
253
- // Hot reload: any source change bumps the module generation; add/remove
254
- // also recompiles the route table.
255
- let reloadTimer = null;
256
- const scheduleReload = (rel, structural) => {
257
- if (reloadTimer)
258
- clearTimeout(reloadTimer);
259
- reloadTimer = setTimeout(() => {
260
- bumpGeneration();
261
- if (structural) {
262
- try {
263
- refreshRoutes(state);
264
- }
265
- catch (err) {
266
- console.error(red(`Route compile failed: ${err instanceof Error ? err.message : String(err)}`));
267
- return;
268
- }
269
- }
270
- console.log(`${dim(stamp())} ${teal(rel)} ${dim('reloaded')}`);
271
- if (opts.onReloadTypecheck) {
272
- void Promise.resolve(opts.onReloadTypecheck()).catch((err) => {
273
- console.error(red(`Typecheck failed to run: ${err instanceof Error ? err.message : String(err)}`));
274
- });
275
- }
276
- }, 150);
277
- };
278
- const watcher = chokidar.watch(state.cwd, {
279
- ignoreInitial: true,
280
- ignored: (p) => {
281
- const rel = relative(state.cwd, p);
282
- if (!rel || rel.startsWith('..'))
283
- return false;
284
- return rel
285
- .split(/[\\/]/)
286
- .some((seg) => IGNORE.has(seg) || (seg.startsWith('.') && seg !== '.' && seg !== ''));
287
- },
288
- });
289
- watcher.on('change', (abs) => {
290
- const rel = relative(state.cwd, abs);
291
- if (RELOAD_EXTS.test(rel))
292
- scheduleReload(rel, false);
293
- });
294
- watcher.on('add', (abs) => {
295
- const rel = relative(state.cwd, abs);
296
- if (RELOAD_EXTS.test(rel))
297
- scheduleReload(rel, true);
298
- });
299
- watcher.on('unlink', (abs) => {
300
- const rel = relative(state.cwd, abs);
301
- if (RELOAD_EXTS.test(rel))
302
- scheduleReload(rel, true);
303
- });
304
- process.on('SIGINT', () => {
305
- console.log(`\n${dim('Stopped.')}`);
306
- watcher.close().finally(() => process.exit(0));
307
- });
308
- }
309
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/local/server.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,aAAa,EAA0B,MAAM,cAAc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ep the platform's own telemetry out of the developer's terminal
3
- * (tsk_eef0a0ef).
4
- *
5
- * `somewhere dev` runs the DEPLOYED function runtime, vendored verbatim. That
6
- * runtime instruments itself for the platform's telemetry sink: it writes a
7
- * `SW_QUERY` line per database call, a `SW_DB_*` timing blob when a call is
8
- * slow or first-touch, and a warning when its background flush of query
9
- * observations is refused. In the deployed worker those lines go to the
10
- * platform's log pipeline. Locally there is no pipeline — they land in the
11
- * developer's terminal, next to their own console.log:
12
- *
13
- * [SW_QUERY_OBSERVATIONS] deferred flush failed: HTTP 403
14
- * [SW_DB_FIRST_TOUCH] {"event":"SW_DB_FIRST_TOUCH","execution_path":"rest",
15
- * "database_region":"WNAM","edge_region":null,…}
16
- *
17
- * Two things wrong with that, and this module fixes both without touching the
18
- * vendored file (it is hash-guarded; a hand-edit is a failing build, and a
19
- * local fork of the runtime is the divergence the whole loop exists to remove).
20
- *
21
- * 1. THE 403 IS NOT THE DEVELOPER'S. The observation channel is ours, it is
22
- * entitlement-gated, and a plan without the entitlement is refused by
23
- * design. Nothing in the app is wrong and nothing the developer can do
24
- * changes it — but an agent reading the terminal treats a repeated
25
- * "failed: HTTP 403" as a symptom of the code it just wrote.
26
- * 2. IT LEAKS OUR PLUMBING. `execution_path`, `database_region`, `edge_region`,
27
- * "activation, placement, transport, queueing, binding" — internal database
28
- * mechanics, rendered as raw JSON into a customer's terminal.
29
- *
30
- * WHAT IS NOT SUPPRESSED: anything the developer's own code prints, every
31
- * error the runtime raises, and every failure of a call they made. Only the
32
- * background telemetry channel is quiet, and only by default —
33
- * `SOMEWHERE_DEV_TELEMETRY=1` prints every line through untouched, so the
34
- * channel stays inspectable when we are the ones debugging it.
35
- */
36
- /** Set this to any non-empty value other than `0`/`false` to see the raw lines. */
37
- export const TELEMETRY_ENV = 'SOMEWHERE_DEV_TELEMETRY';
38
- export function telemetryVisible(env = process.env) {
39
- const raw = env[TELEMETRY_ENV];
40
- if (raw === undefined)
41
- return false;
42
- const value = raw.trim().toLowerCase();
43
- return value !== '' && value !== '0' && value !== 'false' && value !== 'no';
44
- }
45
- /**
46
- * Is this console call the vendored runtime reporting to the platform, rather
47
- * than the app reporting to its developer?
48
- *
49
- * Matched by SHAPE, never by an enumerated list of event names — a list goes
50
- * stale on the next re-vendor and the leak comes back silently. The runtime
51
- * emits exactly three shapes, and each is self-identifying:
52
- *
53
- * a. `[<EVENT>] <json>` where the JSON's own `event` field equals <EVENT>
54
- * and starts with `SW_`. That pairing is what makes it ours; a developer
55
- * logging a string that merely begins with `[SW_` does not produce it.
56
- * b. `[SW_QUERY_OBSERVATIONS] …` — the background flush channel, whose only
57
- * output is the failure of a request the developer did not make.
58
- * c. a bare JSON object whose `event` starts with `SW_` (the per-query
59
- * `SW_QUERY` line, emitted with no prefix at all).
60
- */
61
- export function isPlatformTelemetry(args) {
62
- if (args.length === 0)
63
- return false;
64
- const first = args[0];
65
- if (typeof first !== 'string')
66
- return false;
67
- const line = first.trimStart();
68
- // (b) the observation channel — its own name is the whole signal.
69
- if (line.startsWith('[SW_QUERY_OBSERVATIONS]'))
70
- return true;
71
- // (a) `[EVENT] {json}` where the JSON agrees it is that event.
72
- const prefixed = /^\[(SW_[A-Z0-9_]+)\]\s*(\{[\s\S]*)$/.exec(line);
73
- if (prefixed)
74
- return eventNameOf(prefixed[2]) === prefixed[1];
75
- // (c) a bare telemetry object.
76
- if (line.startsWith('{')) {
77
- const event = eventNameOf(line);
78
- return event !== null && event.startsWith('SW_');
79
- }
80
- return false;
81
- }
82
- function eventNameOf(json) {
83
- try {
84
- const parsed = JSON.parse(json);
85
- if (!parsed || typeof parsed !== 'object')
86
- return null;
87
- const event = parsed.event;
88
- return typeof event === 'string' ? event : null;
89
- }
90
- catch {
91
- return null;
92
- }
93
- }
94
- let installed = false;
95
- /**
96
- * Filter the platform's telemetry out of console.log / warn / error for the
97
- * rest of this process. Idempotent, and a no-op when the developer asked to
98
- * see it. Returns a restore function — the tests use it; the CLI does not,
99
- * because the local loop owns the process for its whole life.
100
- */
101
- export function installTelemetryFilter(env = process.env) {
102
- if (installed || telemetryVisible(env))
103
- return () => { };
104
- installed = true;
105
- const methods = ['log', 'warn', 'error'];
106
- const original = methods.map((m) => [m, console[m]]);
107
- for (const [method, fn] of original) {
108
- console[method] = (...args) => {
109
- if (isPlatformTelemetry(args))
110
- return;
111
- fn(...args);
112
- };
113
- }
114
- return () => {
115
- for (const [method, fn] of original)
116
- console[method] = fn;
117
- installed = false;
118
- };
119
- }
120
- //# sourceMappingURL=telemetry-filter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"telemetry-filter.js","sourceRoot":"","sources":["../../src/local/telemetry-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACnE,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/B,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACvC,OAAO,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAe;IACjD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAE/B,kEAAkE;IAClE,IAAI,IAAI,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M,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAU,CAAC,CAAC;IAC9D,KAAK,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;QACpC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;YACvC,IAAI,mBAAmB,CAAC,IAAI,CAAC;gBAAE,OAAO;YACtC,EAAE,CAAC,GAAI,IAAW,CAAC,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,EAAE;QACV,KAAK,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ;YAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QAC1D,SAAS,GAAG,KAAK,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Evan Wallace
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,3 +0,0 @@
1
- # esbuild
2
-
3
- This is the cross-platform WebAssembly binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Forward to the automatically-generated WebAssembly loader from the Go compiler
4
-
5
- const module_ = require('module');
6
- const path = require('path');
7
- const fs = require('fs');
8
-
9
- const wasm_exec_node = path.join(__dirname, '..', 'wasm_exec_node.js');
10
- const esbuild_wasm = path.join(__dirname, '..', 'esbuild.wasm');
11
-
12
- const code = fs.readFileSync(wasm_exec_node, 'utf8');
13
- const wrapper = new Function('require', 'WebAssembly', code);
14
-
15
- function instantiate(bytes, importObject) {
16
- // Using this API causes "./esbuild --version" to run around 1 second faster
17
- // than using the "WebAssembly.instantiate()" API when run in node (v12.16.2)
18
- const module = new WebAssembly.Module(bytes);
19
- const instance = new WebAssembly.Instance(module, importObject);
20
- return Promise.resolve({ instance, module });
21
- }
22
-
23
- // Node has another bug where using "fs.read" to read from stdin reads
24
- // everything successfully and then throws an error, but only on Windows. Go's
25
- // WebAssembly support uses "fs.read" so it hits this problem. This is a patch
26
- // to try to work around the bug in node. This bug has been reported to node
27
- // at least twice in https://github.com/nodejs/node/issues/35997 and in
28
- // https://github.com/nodejs/node/issues/19831. This issue has also been
29
- // reported to the Go project: https://github.com/golang/go/issues/43913.
30
- const read = fs.read;
31
- fs.read = function () {
32
- const callback = arguments[5];
33
- arguments[5] = function (err, count) {
34
- if (count === 0 && err && err.code === 'EOF') {
35
- arguments[0] = null;
36
- }
37
- return callback.apply(this, arguments);
38
- };
39
- return read.apply(this, arguments);
40
- };
41
-
42
- // Hack around a Unicode bug in node: https://github.com/nodejs/node/issues/24550.
43
- // See this for the matching Go issue: https://github.com/golang/go/issues/43917.
44
- const write = fs.write;
45
- fs.write = function (fd, buf, offset, length, position, callback) {
46
- if (offset === 0 && length === buf.length && position === null) {
47
- if (fd === process.stdout.fd) {
48
- try {
49
- process.stdout.write(buf, err => err ? callback(err, 0, null) : callback(null, length, buf));
50
- } catch (err) {
51
- callback(err, 0, null);
52
- }
53
- return;
54
- }
55
- if (fd === process.stderr.fd) {
56
- try {
57
- process.stderr.write(buf, err => err ? callback(err, 0, null) : callback(null, length, buf));
58
- } catch (err) {
59
- callback(err, 0, null);
60
- }
61
- return;
62
- }
63
- }
64
- return write.apply(this, arguments);
65
- };
66
- const writeSync = fs.writeSync;
67
- fs.writeSync = function (fd, buf) {
68
- if (fd === process.stdout.fd) return process.stdout.write(buf), buf.length;
69
- if (fd === process.stderr.fd) return process.stderr.write(buf), buf.length;
70
- return writeSync.apply(this, arguments);
71
- };
72
-
73
- // WASM code generated with Go 1.17.2+ will crash when run in a situation with
74
- // many environment variables: https://github.com/golang/go/issues/49011. An
75
- // example of this situation is running a Go-compiled WASM executable in GitHub
76
- // Actions. Work around this by filtering node's copy of environment variables
77
- // down to only include the environment variables that esbuild currently uses.
78
- const esbuildUsedEnvVars = [
79
- 'NO_COLOR',
80
- 'NODE_PATH',
81
- 'npm_config_user_agent',
82
- 'WT_SESSION',
83
- ]
84
- for (let key in process.env) {
85
- if (esbuildUsedEnvVars.indexOf(key) < 0) {
86
- delete process.env[key]
87
- }
88
- }
89
-
90
- process.argv.splice(2, 0, esbuild_wasm);
91
- wrapper(module_.createRequire(wasm_exec_node), Object.assign(Object.create(WebAssembly), { instantiate }));