electron/patches/node/build_modify_js2c_py_to_all...

60 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 11 Apr 2019 17:16:13 +0900
Subject: build: modify js2c.py to allow injection of original-fs and custom
embedder JS
This patch ensures that internal/fs/watchers can be loaded twice without
JS errors and ensures embedder JS is loaded via LoadEmbedderJavaScriptSource.
That method is generated by our modifications to js2c.cc in the BUILD.gn patch
diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js
index f5ecc15159f457cd0b8069c0427b7c758c916c4e..c9ce67391f321989b0af48159b4da3ab8ffc3e65 100644
--- a/lib/internal/fs/watchers.js
+++ b/lib/internal/fs/watchers.js
@@ -292,12 +292,13 @@ function emitCloseNT(self) {
}
// Legacy alias on the C++ wrapper object. This is not public API, so we may
-// want to runtime-deprecate it at some point. There's no hurry, though.
-ObjectDefineProperty(FSEvent.prototype, 'owner', {
- __proto__: null,
- get() { return this[owner_symbol]; },
- set(v) { return this[owner_symbol] = v; },
-});
+if (!'owner' in FSEvent.prototype) {
+ ObjectDefineProperty(FSEvent.prototype, 'owner', {
+ __proto__: null,
+ get() { return this[owner_symbol]; },
+ set(v) { return this[owner_symbol] = v; }
+ });
+}
let kResistStopPropagation;
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 804296db12f7864f72648f5f36834a924503e4a6..2cac503e92640a4683a4be6969f1ed40e42785a0 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -35,6 +35,7 @@ using v8::Value;
BuiltinLoader::BuiltinLoader()
: config_(GetConfig()), code_cache_(std::make_shared<BuiltinCodeCache>()) {
LoadJavaScriptSource();
+ LoadEmbedderJavaScriptSource();
#ifdef NODE_SHARED_BUILTIN_CJS_MODULE_LEXER_LEXER_PATH
AddExternalizedBuiltin(
"internal/deps/cjs-module-lexer/lexer",
diff --git a/src/node_builtins.h b/src/node_builtins.h
index 9a20a275fbe5df9f384b7b1d1d26806e7cd05384..a1a9fe7d592f0d57b70dcee8c865b99d71248bf2 100644
--- a/src/node_builtins.h
+++ b/src/node_builtins.h
@@ -132,6 +132,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
// Generated by tools/js2c.py as node_javascript.cc
void LoadJavaScriptSource(); // Loads data into source_
+ void LoadEmbedderJavaScriptSource(); // Loads embedder data into source_
UnionBytes GetConfig(); // Return data for config.gypi
struct BuiltinCategories {