@yao-pkg/pkg-fetch 3.5.10 → 3.5.11

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.
@@ -42,5 +42,15 @@
42
42
  "node-v20.17.0-macos-arm64": "2e59df5e88c90f1457fd89abcea47fa0f2b7c66cbf93116d0ab3e5b29c87bc5f",
43
43
  "node-v20.17.0-macos-x64": "cb37f44c3cdc12fe6e2e6b461cfdacba35177426bd8ab85f39e4c3d279fca11b",
44
44
  "node-v20.17.0-win-arm64": "9769ad72c8ab0f6b1705c9bffb03585044a917511a30d74c68205b7923ff9fa2",
45
- "node-v20.17.0-win-x64": "9c15a64b3babd2e7cd6c0cb1770495c331bea6df4544df92f734a23cc55bc1bf"
45
+ "node-v20.17.0-win-x64": "9c15a64b3babd2e7cd6c0cb1770495c331bea6df4544df92f734a23cc55bc1bf",
46
+ "node-v22.8.0-alpine-arm64": "ef3970e833cd66b05874e971c36ec4c7599727abfd62b35b268b1813c93545f0",
47
+ "node-v22.8.0-alpine-x64": "b7def0565556b6772b25d00ef80431e7801fb8e1df2a1a5a7c5b1d190a7b4475",
48
+ "node-v22.8.0-linux-arm64": "63d71da9bf16ce51f329667d60b17c6de1fc8c0e09202ccb992426cdaf52aa9f",
49
+ "node-v22.8.0-linux-x64": "bfa58557605fd0056001bc179a16ca7c6ee541e185f4c39cd2ff50b466bd2ac7",
50
+ "node-v22.8.0-linuxstatic-arm64": "4f8cee723c5951c3dc7352f88c1a68e43575f0c5af9e47916114aad409849b69",
51
+ "node-v22.8.0-linuxstatic-armv7": "17b81975a64fd03b1bc64fe9b1d924f68cb96e1c6a2cb3b48178c77761b4b56f",
52
+ "node-v22.8.0-linuxstatic-x64": "10fce22c1481a68f47a9a03a694f4d9abbd7cef3f33e744a9c609253695288c7",
53
+ "node-v22.8.0-macos-x64": "d9970ffebac736af31485d128cec1dc98ed96b1e49ce4f7e5d74ef19ac913627",
54
+ "node-v22.8.0-win-arm64": "817e57d49fa9e8b7787ea972f6942f9d3dfc80c81ec169d25d7d0fa4abb402c1",
55
+ "node-v22.8.0-win-x64": "be5dc1b1928d9d63ccb7c7fc1c6db245cf205b2d733ee0196f10e29f14239211"
46
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yao-pkg/pkg-fetch",
3
- "version": "3.5.10",
3
+ "version": "3.5.11",
4
4
  "description": "Compiles and stores base binaries for pkg",
5
5
  "main": "lib-es5/index.js",
6
6
  "license": "MIT",
@@ -0,0 +1,686 @@
1
+ diff --git node/common.gypi node/common.gypi
2
+ index a97e77860e..09444e795f 100644
3
+ --- node/common.gypi
4
+ +++ node/common.gypi
5
+ @@ -187,7 +187,7 @@
6
+ ['clang==1', {
7
+ 'lto': ' -flto ', # Clang
8
+ }, {
9
+ - 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
10
+ + 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
11
+ }],
12
+ ],
13
+ },
14
+ diff --git node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c
15
+ index 61a7d06cad..eeebf67796 100644
16
+ --- node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c
17
+ +++ node/deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c
18
+ @@ -33,17 +33,6 @@
19
+
20
+ #include "nghttp3_macro.h"
21
+
22
+ -#if defined(_MSC_VER) && !defined(__clang__) && \
23
+ - (defined(_M_ARM) || defined(_M_ARM64))
24
+ -unsigned int __popcnt(unsigned int x) {
25
+ - unsigned int c = 0;
26
+ - for (; x; ++c) {
27
+ - x &= x - 1;
28
+ - }
29
+ - return c;
30
+ -}
31
+ -#endif
32
+ -
33
+ int nghttp3_ringbuf_init(nghttp3_ringbuf *rb, size_t nmemb, size_t size,
34
+ const nghttp3_mem *mem) {
35
+ if (nmemb) {
36
+ diff --git node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c
37
+ index c381c23127..6894bc2308 100644
38
+ --- node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c
39
+ +++ node/deps/ngtcp2/ngtcp2/lib/ngtcp2_ringbuf.c
40
+ @@ -31,17 +31,6 @@
41
+
42
+ #include "ngtcp2_macro.h"
43
+
44
+ -#if defined(_MSC_VER) && !defined(__clang__) && \
45
+ - (defined(_M_ARM) || defined(_M_ARM64))
46
+ -static unsigned int __popcnt(unsigned int x) {
47
+ - unsigned int c = 0;
48
+ - for (; x; ++c) {
49
+ - x &= x - 1;
50
+ - }
51
+ - return c;
52
+ -}
53
+ -#endif
54
+ -
55
+ int ngtcp2_ringbuf_init(ngtcp2_ringbuf *rb, size_t nmemb, size_t size,
56
+ const ngtcp2_mem *mem) {
57
+ uint8_t *buf = ngtcp2_mem_malloc(mem, nmemb * size);
58
+ diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h
59
+ index d3e35d6ec5..6e9bbe3849 100644
60
+ --- node/deps/v8/include/v8-initialization.h
61
+ +++ node/deps/v8/include/v8-initialization.h
62
+ @@ -89,6 +89,10 @@ class V8_EXPORT V8 {
63
+ static void SetFlagsFromCommandLine(int* argc, char** argv,
64
+ bool remove_flags);
65
+
66
+ + static void EnableCompilationForSourcelessUse();
67
+ + static void DisableCompilationForSourcelessUse();
68
+ + static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
69
+ +
70
+ /** Get the version string. */
71
+ static const char* GetVersion();
72
+
73
+ diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc
74
+ index 2dd476dda3..8a51f25b57 100644
75
+ --- node/deps/v8/src/api/api.cc
76
+ +++ node/deps/v8/src/api/api.cc
77
+ @@ -624,6 +624,28 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
78
+ HelpOptions(HelpOptions::kDontExit));
79
+ }
80
+
81
+ +bool save_lazy;
82
+ +bool save_predictable;
83
+ +
84
+ +void V8::EnableCompilationForSourcelessUse() {
85
+ + save_lazy = i::v8_flags.lazy;
86
+ + i::v8_flags.lazy = false;
87
+ + save_predictable = i::v8_flags.predictable;
88
+ + i::v8_flags.predictable = true;
89
+ +}
90
+ +
91
+ +void V8::DisableCompilationForSourcelessUse() {
92
+ + i::v8_flags.lazy = save_lazy;
93
+ + i::v8_flags.predictable = save_predictable;
94
+ +}
95
+ +
96
+ +void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
97
+ + auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
98
+ + auto function_info = i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
99
+ + i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
100
+ + script->SetSource(isolate, script, isolate->factory()->empty_string());
101
+ +}
102
+ +
103
+ RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
104
+
105
+ RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
106
+ diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc
107
+ index 49afab11b6..4c81f9f90b 100644
108
+ --- node/deps/v8/src/codegen/compiler.cc
109
+ +++ node/deps/v8/src/codegen/compiler.cc
110
+ @@ -3627,7 +3627,7 @@ MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScriptImpl(
111
+ maybe_script = lookup_result.script();
112
+ maybe_result = lookup_result.toplevel_sfi();
113
+ is_compiled_scope = lookup_result.is_compiled_scope();
114
+ - if (!maybe_result.is_null()) {
115
+ + if (!maybe_result.is_null() && source->length()) {
116
+ compile_timer.set_hit_isolate_cache();
117
+ } else if (can_consume_code_cache) {
118
+ compile_timer.set_consuming_code_cache();
119
+ diff --git node/deps/v8/src/compiler/wasm-compiler.cc node/deps/v8/src/compiler/wasm-compiler.cc
120
+ index 16f1f1470b..4bfeca49e6 100644
121
+ --- node/deps/v8/src/compiler/wasm-compiler.cc
122
+ +++ node/deps/v8/src/compiler/wasm-compiler.cc
123
+ @@ -8613,12 +8613,13 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
124
+ '-');
125
+
126
+ auto compile_with_turboshaft = [&]() {
127
+ + wasm::WrapperCompilationInfo info;
128
+ + info.code_kind = CodeKind::WASM_TO_JS_FUNCTION;
129
+ + info.import_info.import_kind = kind;
130
+ + info.import_info.expected_arity = expected_arity;
131
+ + info.import_info.suspend = suspend;
132
+ return Pipeline::GenerateCodeForWasmNativeStubFromTurboshaft(
133
+ - env->module, sig,
134
+ - wasm::WrapperCompilationInfo{
135
+ - .code_kind = CodeKind::WASM_TO_JS_FUNCTION,
136
+ - .import_info = {kind, expected_arity, suspend}},
137
+ - func_name, WasmStubAssemblerOptions(), nullptr);
138
+ + env->module, sig, info, func_name, WasmStubAssemblerOptions(), nullptr);
139
+ };
140
+ auto compile_with_turbofan = [&]() {
141
+ //--------------------------------------------------------------------------
142
+ @@ -8774,13 +8775,15 @@ MaybeHandle<Code> CompileWasmToJSWrapper(Isolate* isolate,
143
+ base::VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen, sig);
144
+
145
+ auto compile_with_turboshaft = [&]() {
146
+ + wasm::WrapperCompilationInfo info;
147
+ + info.code_kind = CodeKind::WASM_TO_JS_FUNCTION;
148
+ + info.import_info.import_kind = kind;
149
+ + info.import_info.expected_arity = expected_arity;
150
+ + info.import_info.suspend = suspend;
151
+ std::unique_ptr<turboshaft::TurboshaftCompilationJob> job =
152
+ Pipeline::NewWasmTurboshaftWrapperCompilationJob(
153
+ - isolate, sig,
154
+ - wasm::WrapperCompilationInfo{
155
+ - .code_kind = CodeKind::WASM_TO_JS_FUNCTION,
156
+ - .import_info = {kind, expected_arity, suspend}},
157
+ - nullptr, std::move(name_buffer), WasmAssemblerOptions());
158
+ + isolate, sig, info, nullptr, std::move(name_buffer),
159
+ + WasmAssemblerOptions());
160
+
161
+ // Compile the wrapper
162
+ if (job->ExecuteJob(isolate->counters()->runtime_call_stats()) ==
163
+ diff --git node/deps/v8/src/heap/marking-visitor-inl.h node/deps/v8/src/heap/marking-visitor-inl.h
164
+ index 39a5bbd22c..4b860f55d5 100644
165
+ --- node/deps/v8/src/heap/marking-visitor-inl.h
166
+ +++ node/deps/v8/src/heap/marking-visitor-inl.h
167
+ @@ -329,6 +329,13 @@ bool MarkingVisitorBase<ConcreteVisitor>::HasBytecodeArrayForFlushing(
168
+ template <typename ConcreteVisitor>
169
+ bool MarkingVisitorBase<ConcreteVisitor>::ShouldFlushCode(
170
+ Tagged<SharedFunctionInfo> sfi) const {
171
+ + auto script_obj = sfi->script();
172
+ + if (!IsUndefined(script_obj)) {
173
+ + auto script = i::Script::cast(script_obj);
174
+ + if (IsUndefined(script->source())) {
175
+ + return false;
176
+ + }
177
+ + }
178
+ return IsStressFlushingEnabled(code_flush_mode_) || IsOld(sfi);
179
+ }
180
+
181
+ diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc
182
+ index 529e283bbf..c997c53a18 100644
183
+ --- node/deps/v8/src/objects/js-function.cc
184
+ +++ node/deps/v8/src/objects/js-function.cc
185
+ @@ -1308,6 +1308,10 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
186
+ Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
187
+ isolate, function, isolate->factory()->class_positions_symbol());
188
+ if (IsClassPositions(*maybe_class_positions)) {
189
+ + if (IsUndefined(
190
+ + String::cast(Script::cast(shared_info->script())->source()))) {
191
+ + return isolate->factory()->NewStringFromAsciiChecked("class {}");
192
+ + }
193
+ Tagged<ClassPositions> class_positions =
194
+ ClassPositions::cast(*maybe_class_positions);
195
+ int start_position = class_positions->start();
196
+ diff --git node/deps/v8/src/objects/objects.cc node/deps/v8/src/objects/objects.cc
197
+ index 8e013c2544..7ac03149d8 100644
198
+ --- node/deps/v8/src/objects/objects.cc
199
+ +++ node/deps/v8/src/objects/objects.cc
200
+ @@ -4263,7 +4263,12 @@ void Script::InitLineEndsInternal(IsolateT* isolate, Handle<Script> script) {
201
+
202
+ void Script::SetSource(Isolate* isolate, Handle<Script> script,
203
+ Handle<String> source) {
204
+ - script->set_source(*source);
205
+ + if (source->length() > 0) {
206
+ + script->set_source(*source);
207
+ + } else {
208
+ + Tagged<PrimitiveHeapObject> und = *isolate->factory()->undefined_value();
209
+ + script->set_source(und);
210
+ + }
211
+ if (isolate->NeedsSourcePositions()) InitLineEnds(isolate, script);
212
+ }
213
+
214
+ diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc
215
+ index f160b27ea4..748452ba45 100644
216
+ --- node/deps/v8/src/parsing/parsing.cc
217
+ +++ node/deps/v8/src/parsing/parsing.cc
218
+ @@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
219
+ DCHECK(info->flags().is_toplevel());
220
+ DCHECK_NULL(info->literal());
221
+
222
+ + if (IsUndefined(String::cast(script->source()))) return false;
223
+ VMState<PARSER> state(isolate);
224
+
225
+ // Create a character stream for the parser.
226
+ @@ -74,6 +75,8 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
227
+
228
+ // Create a character stream for the parser.
229
+ Handle<Script> script(Script::cast(shared_info->script()), isolate);
230
+ + if (IsUndefined(String::cast(script->source()))) return false;
231
+ +
232
+ Handle<String> source(String::cast(script->source()), isolate);
233
+ std::unique_ptr<Utf16CharacterStream> stream(
234
+ ScannerStream::For(isolate, source, shared_info->StartPosition(),
235
+ diff --git node/deps/v8/src/snapshot/code-serializer.cc node/deps/v8/src/snapshot/code-serializer.cc
236
+ index ec69ad5123..1894032344 100644
237
+ --- node/deps/v8/src/snapshot/code-serializer.cc
238
+ +++ node/deps/v8/src/snapshot/code-serializer.cc
239
+ @@ -703,10 +703,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheck(
240
+
241
+ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckJustSource(
242
+ uint32_t expected_source_hash) const {
243
+ - uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
244
+ - if (source_hash != expected_source_hash) {
245
+ - return SerializedCodeSanityCheckResult::kSourceMismatch;
246
+ - }
247
+ return SerializedCodeSanityCheckResult::kSuccess;
248
+ }
249
+
250
+ @@ -723,10 +719,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckWithoutSource(
251
+ if (version_hash != Version::Hash()) {
252
+ return SerializedCodeSanityCheckResult::kVersionMismatch;
253
+ }
254
+ - uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
255
+ - if (flags_hash != FlagList::Hash()) {
256
+ - return SerializedCodeSanityCheckResult::kFlagsMismatch;
257
+ - }
258
+ uint32_t ro_snapshot_checksum =
259
+ GetHeaderValue(kReadOnlySnapshotChecksumOffset);
260
+ if (ro_snapshot_checksum != expected_ro_snapshot_checksum) {
261
+ diff --git node/lib/child_process.js node/lib/child_process.js
262
+ index 4e15255a01..987da265e6 100644
263
+ --- node/lib/child_process.js
264
+ +++ node/lib/child_process.js
265
+ @@ -168,7 +168,7 @@ function fork(modulePath, args = [], options) {
266
+ throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
267
+ }
268
+
269
+ - return spawn(options.execPath, args, options);
270
+ + return module.exports.spawn(options.execPath, args, options);
271
+ }
272
+
273
+ function _forkChild(fd, serializationMode) {
274
+ diff --git node/lib/internal/bootstrap/pkg.js node/lib/internal/bootstrap/pkg.js
275
+ new file mode 100644
276
+ index 0000000000..a697294fdf
277
+ --- /dev/null
278
+ +++ node/lib/internal/bootstrap/pkg.js
279
+ @@ -0,0 +1,49 @@
280
+ +'use strict';
281
+ +
282
+ +const {
283
+ + prepareWorkerThreadExecution,
284
+ + prepareMainThreadExecution
285
+ +} = require('internal/process/pre_execution');
286
+ +
287
+ +if (internalBinding('worker').isMainThread) {
288
+ + prepareMainThreadExecution(true);
289
+ +} else {
290
+ + prepareWorkerThreadExecution();
291
+ +}
292
+ +
293
+ +(function () {
294
+ + var __require__ = require;
295
+ + var fs = __require__('fs');
296
+ + var vm = __require__('vm');
297
+ + function readPrelude (fd) {
298
+ + var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
299
+ + var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
300
+ + var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
301
+ + var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
302
+ + if (!PRELUDE_POSITION) {
303
+ + // no prelude - remove entrypoint from argv[1]
304
+ + process.argv.splice(1, 1);
305
+ + return { undoPatch: true };
306
+ + }
307
+ + var prelude = Buffer.alloc(PRELUDE_SIZE);
308
+ + var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
309
+ + if (read !== PRELUDE_SIZE) {
310
+ + console.error('Pkg: Error reading from file.');
311
+ + process.exit(1);
312
+ + }
313
+ + var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
314
+ + var fn = s.runInThisContext();
315
+ + return fn(process, __require__,
316
+ + console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
317
+ + }
318
+ + (function () {
319
+ + var fd = fs.openSync(process.execPath, 'r');
320
+ + var result = readPrelude(fd);
321
+ + if (result && result.undoPatch) {
322
+ + var bindingFs = process.binding('fs');
323
+ + fs.internalModuleStat = bindingFs.internalModuleStat;
324
+ + fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
325
+ + fs.closeSync(fd);
326
+ + }
327
+ + }());
328
+ +}());
329
+ diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
330
+ index 451b7c2195..203be65195 100644
331
+ --- node/lib/internal/modules/cjs/loader.js
332
+ +++ node/lib/internal/modules/cjs/loader.js
333
+ @@ -234,7 +234,10 @@ function stat(filename) {
334
+ const result = statCache.get(filename);
335
+ if (result !== undefined) { return result; }
336
+ }
337
+ - const result = internalFsBinding.internalModuleStat(filename);
338
+ + const fs = require('fs');
339
+ + const result = fs.existsSync(filename) ?
340
+ + (fs.statSync(filename).isDirectory() ? 1 : 0) : -1;
341
+ +
342
+ if (statCache !== null && result >= 0) {
343
+ // Only set cache when `internalModuleStat(filename)` succeeds.
344
+ statCache.set(filename, result);
345
+ diff --git node/lib/internal/modules/package_json_reader.js node/lib/internal/modules/package_json_reader.js
346
+ index 9a9dcebb79..9f00ec6a85 100644
347
+ --- node/lib/internal/modules/package_json_reader.js
348
+ +++ node/lib/internal/modules/package_json_reader.js
349
+ @@ -80,14 +80,19 @@ function deserializePackageJSON(path, contents) {
350
+ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
351
+ // This function will be called by both CJS and ESM, so we need to make sure
352
+ // non-null attributes are converted to strings.
353
+ - const parsed = modulesBinding.readPackageJSON(
354
+ - jsonPath,
355
+ - isESM,
356
+ - base == null ? undefined : `${base}`,
357
+ - specifier == null ? undefined : `${specifier}`,
358
+ - );
359
+ -
360
+ - return deserializePackageJSON(jsonPath, parsed);
361
+ + const fs = require('fs');
362
+ + if (fs.existsSync(jsonPath)) {
363
+ + const json = JSONParse(fs.readFileSync(jsonPath, { encoding: "utf8" }).trim());
364
+ + return deserializePackageJSON(jsonPath, [
365
+ + json['name'],
366
+ + json['main'],
367
+ + json['type'],
368
+ + json['exports'],
369
+ + json['imports'],
370
+ + ]);
371
+ + } else {
372
+ + return deserializePackageJSON(jsonPath, undefined);
373
+ + }
374
+ }
375
+
376
+ /**
377
+ diff --git node/lib/internal/process/pre_execution.js node/lib/internal/process/pre_execution.js
378
+ index ea420b84da..756c84ea18 100644
379
+ --- node/lib/internal/process/pre_execution.js
380
+ +++ node/lib/internal/process/pre_execution.js
381
+ @@ -49,7 +49,11 @@ const {
382
+ },
383
+ } = require('internal/v8/startup_snapshot');
384
+
385
+ +let _alreadyPrepared = false;
386
+ +
387
+ function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {
388
+ + if (_alreadyPrepared === true) return;
389
+ + _alreadyPrepared = true;
390
+ return prepareExecution({
391
+ expandArgv1,
392
+ initializeModules,
393
+ @@ -241,7 +245,8 @@ function patchProcessObject(expandArgv1) {
394
+ // If requested, update process.argv[1] to replace whatever the user provided with the resolved absolute file path of
395
+ // the entry point.
396
+ if (expandArgv1 && process.argv[1] &&
397
+ - !StringPrototypeStartsWith(process.argv[1], '-')) {
398
+ + !StringPrototypeStartsWith(process.argv[1], '-') &&
399
+ + process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
400
+ // Expand process.argv[1] into a full path.
401
+ const path = require('path');
402
+ try {
403
+ @@ -722,6 +727,7 @@ function loadPreloadModules() {
404
+ // For user code, we preload modules if `-r` is passed
405
+ const preloadModules = getOptionValue('--require');
406
+ if (preloadModules && preloadModules.length > 0) {
407
+ + assert(false, '--require is not supported');
408
+ const {
409
+ Module: {
410
+ _preloadModules,
411
+ diff --git node/lib/vm.js node/lib/vm.js
412
+ index 3eea66b3f0..86fd70ac89 100644
413
+ --- node/lib/vm.js
414
+ +++ node/lib/vm.js
415
+ @@ -98,6 +98,7 @@ class Script extends ContextifyScript {
416
+ produceCachedData = false,
417
+ importModuleDynamically,
418
+ [kParsingContext]: parsingContext,
419
+ + sourceless = false,
420
+ } = options;
421
+
422
+ validateString(filename, 'options.filename');
423
+ @@ -121,7 +122,8 @@ class Script extends ContextifyScript {
424
+ cachedData,
425
+ produceCachedData,
426
+ parsingContext,
427
+ - hostDefinedOptionId);
428
+ + hostDefinedOptionId,
429
+ + sourceless);
430
+ } catch (e) {
431
+ throw e; /* node-do-not-add-exception-line */
432
+ }
433
+ diff --git node/src/inspector_agent.cc node/src/inspector_agent.cc
434
+ index bb39a0cb42..5fa6cb65cc 100644
435
+ --- node/src/inspector_agent.cc
436
+ +++ node/src/inspector_agent.cc
437
+ @@ -766,11 +766,6 @@ bool Agent::Start(const std::string& path,
438
+ StartIoThreadAsyncCallback));
439
+ uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
440
+ start_io_thread_async.data = this;
441
+ - if (parent_env_->should_start_debug_signal_handler()) {
442
+ - // Ignore failure, SIGUSR1 won't work, but that should not block node
443
+ - // start.
444
+ - StartDebugSignalHandler();
445
+ - }
446
+
447
+ parent_env_->AddCleanupHook([](void* data) {
448
+ Environment* env = static_cast<Environment*>(data);
449
+ diff --git node/src/node.cc node/src/node.cc
450
+ index e1614e60f5..c19041aab2 100644
451
+ --- node/src/node.cc
452
+ +++ node/src/node.cc
453
+ @@ -394,6 +394,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
454
+ return env->RunSnapshotDeserializeMain();
455
+ }
456
+
457
+ + StartExecution(env, "internal/bootstrap/pkg");
458
+ +
459
+ if (env->worker_context() != nullptr) {
460
+ return StartExecution(env, "internal/main/worker_thread");
461
+ }
462
+ @@ -618,14 +620,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
463
+ }
464
+
465
+ if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) {
466
+ -#if HAVE_INSPECTOR
467
+ - sigset_t sigmask;
468
+ - sigemptyset(&sigmask);
469
+ - sigaddset(&sigmask, SIGUSR1);
470
+ - const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
471
+ - CHECK_EQ(err, 0);
472
+ -#endif // HAVE_INSPECTOR
473
+ -
474
+ ResetSignalHandlers();
475
+ }
476
+
477
+ diff --git node/src/node_contextify.cc node/src/node_contextify.cc
478
+ index fc137486f5..81388a8812 100644
479
+ --- node/src/node_contextify.cc
480
+ +++ node/src/node_contextify.cc
481
+ @@ -85,6 +85,7 @@ using v8::Symbol;
482
+ using v8::Uint32;
483
+ using v8::UnboundScript;
484
+ using v8::Value;
485
+ +using v8::V8;
486
+
487
+ // The vm module executes code in a sandboxed environment with a different
488
+ // global object than the rest of the code. This is achieved by applying
489
+ @@ -981,13 +982,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
490
+ Local<ArrayBufferView> cached_data_buf;
491
+ bool produce_cached_data = false;
492
+ Local<Context> parsing_context = context;
493
+ -
494
+ + bool sourceless = false;
495
+ Local<Symbol> id_symbol;
496
+ if (argc > 2) {
497
+ // new ContextifyScript(code, filename, lineOffset, columnOffset,
498
+ // cachedData, produceCachedData, parsingContext,
499
+ - // hostDefinedOptionId)
500
+ - CHECK_EQ(argc, 8);
501
+ + // hostDefinedOptionId, sourceless)
502
+ + CHECK_GE(argc, 8);
503
+ CHECK(args[2]->IsNumber());
504
+ line_offset = args[2].As<Int32>()->Value();
505
+ CHECK(args[3]->IsNumber());
506
+ @@ -1008,6 +1009,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
507
+ }
508
+ CHECK(args[7]->IsSymbol());
509
+ id_symbol = args[7].As<Symbol>();
510
+ + if (argc > 8) {
511
+ + CHECK(args[8]->IsBoolean());
512
+ + sourceless = args[8]->IsTrue();
513
+ + }
514
+ }
515
+
516
+ ContextifyScript* contextify_script =
517
+ @@ -1055,6 +1060,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
518
+ ShouldNotAbortOnUncaughtScope no_abort_scope(env);
519
+ Context::Scope scope(parsing_context);
520
+
521
+ + if (sourceless && produce_cached_data) {
522
+ + V8::EnableCompilationForSourcelessUse();
523
+ + }
524
+ +
525
+ MaybeLocal<UnboundScript> maybe_v8_script =
526
+ ScriptCompiler::CompileUnboundScript(isolate, &source, compile_options);
527
+
528
+ @@ -1069,6 +1078,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
529
+ return;
530
+ }
531
+
532
+ + if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
533
+ + if (!source.GetCachedData()->rejected) {
534
+ + V8::FixSourcelessScript(env->isolate(), v8_script);
535
+ + }
536
+ + }
537
+ +
538
+ contextify_script->script_.Reset(isolate, v8_script);
539
+ contextify_script->script_.SetWeak();
540
+ contextify_script->object()->SetInternalField(kUnboundScriptSlot, v8_script);
541
+ @@ -1101,6 +1116,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
542
+ .IsNothing())
543
+ return;
544
+
545
+ + if (sourceless && produce_cached_data) {
546
+ + V8::DisableCompilationForSourcelessUse();
547
+ + }
548
+ +
549
+ TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
550
+ }
551
+
552
+ diff --git node/src/node_main.cc node/src/node_main.cc
553
+ index f66099a557..4048f6bd93 100644
554
+ --- node/src/node_main.cc
555
+ +++ node/src/node_main.cc
556
+ @@ -22,6 +22,8 @@
557
+ #include "node.h"
558
+ #include <cstdio>
559
+
560
+ +int reorder(int argc, char** argv);
561
+ +
562
+ #ifdef _WIN32
563
+ #include <windows.h>
564
+ #include <VersionHelpers.h>
565
+ @@ -88,12 +90,95 @@ int wmain(int argc, wchar_t* wargv[]) {
566
+ }
567
+ argv[argc] = nullptr;
568
+ // Now that conversion is done, we can finally start.
569
+ - return node::Start(argc, argv);
570
+ + return reorder(argc, argv);
571
+ }
572
+ #else
573
+ // UNIX
574
+
575
+ int main(int argc, char* argv[]) {
576
+ + return reorder(argc, argv);
577
+ +}
578
+ +#endif
579
+ +
580
+ +#include <string.h>
581
+ +
582
+ +int strlen2 (char* s) {
583
+ + int len = 0;
584
+ + while (*s) {
585
+ + len += 1;
586
+ + s += 1;
587
+ + }
588
+ + return len;
589
+ +}
590
+ +
591
+ +bool should_set_dummy() {
592
+ +#ifdef _WIN32
593
+ + #define MAX_ENV_LENGTH 32767
594
+ + wchar_t execpath_env[MAX_ENV_LENGTH];
595
+ + DWORD result = GetEnvironmentVariableW(L"PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
596
+ + if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
597
+ + return wcscmp(execpath_env, L"PKG_INVOKE_NODEJS") != 0;
598
+ +#else
599
+ + const char* execpath_env = getenv("PKG_EXECPATH");
600
+ + if (!execpath_env) return true;
601
+ + return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
602
+ +#endif
603
+ +}
604
+ +
605
+ +// for uv_setup_args
606
+ +int adjacent(int argc, char** argv) {
607
+ + size_t size = 0;
608
+ + for (int i = 0; i < argc; i++) {
609
+ + size += strlen(argv[i]) + 1;
610
+ + }
611
+ + char* args = new char[size];
612
+ + size_t pos = 0;
613
+ + for (int i = 0; i < argc; i++) {
614
+ + memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
615
+ + argv[i] = &args[pos];
616
+ + pos += strlen(argv[i]) + 1;
617
+ + }
618
+ return node::Start(argc, argv);
619
+ }
620
+ +
621
+ +volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
622
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
623
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
624
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
625
+ +
626
+ +#ifdef __clang__
627
+ +__attribute__((optnone))
628
+ +#elif defined(__GNUC__)
629
+ +__attribute__((optimize(0)))
630
+ #endif
631
+ +
632
+ +int load_baked(char** nargv) {
633
+ + int c = 1;
634
+ +
635
+ + char* bakery = (char*) BAKERY;
636
+ + while (true) {
637
+ + size_t width = strlen2(bakery);
638
+ + if (width == 0) break;
639
+ + nargv[c++] = bakery;
640
+ + bakery += width + 1;
641
+ + }
642
+ +
643
+ + return c;
644
+ +}
645
+ +
646
+ +int reorder(int argc, char** argv) {
647
+ + char** nargv = new char*[argc + 64];
648
+ +
649
+ + nargv[0] = argv[0];
650
+ + int c = load_baked(nargv);
651
+ +
652
+ + if (should_set_dummy()) {
653
+ + nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
654
+ + }
655
+ +
656
+ + for (int i = 1; i < argc; i++) {
657
+ + nargv[c++] = argv[i];
658
+ + }
659
+ +
660
+ + return adjacent(c, nargv);
661
+ +}
662
+ diff --git node/src/node_options.cc node/src/node_options.cc
663
+ index 545db1dbbc..183af9dbad 100644
664
+ --- node/src/node_options.cc
665
+ +++ node/src/node_options.cc
666
+ @@ -307,6 +307,7 @@ void Parse(
667
+ // TODO(addaleax): Make that unnecessary.
668
+
669
+ DebugOptionsParser::DebugOptionsParser() {
670
+ + return;
671
+ #ifndef DISABLE_SINGLE_EXECUTABLE_APPLICATION
672
+ if (sea::IsSingleExecutable()) return;
673
+ #endif
674
+ diff --git node/tools/icu/icu-generic.gyp node/tools/icu/icu-generic.gyp
675
+ index 2655b9e694..1d951571c7 100644
676
+ --- node/tools/icu/icu-generic.gyp
677
+ +++ node/tools/icu/icu-generic.gyp
678
+ @@ -52,7 +52,7 @@
679
+ 'conditions': [
680
+ [ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
681
+ 'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
682
+ - 'cflags_cc': [ '-frtti' ],
683
+ + 'cflags_cc': [ '-frtti', '-fno-lto' ],
684
+ 'cflags_cc!': [ '-fno-rtti' ],
685
+ }],
686
+ [ 'OS == "mac" or OS == "ios"', {
@@ -1,4 +1,5 @@
1
1
  {
2
+ "v22.8.0": ["node.v22.8.0.cpp.patch"],
2
3
  "v20.17.0": ["node.v20.17.0.cpp.patch"],
3
4
  "v18.20.4": ["node.v18.20.4.cpp.patch"],
4
5
  "v16.20.2": ["node.v16.20.2.cpp.patch"],