2019-10-23 16:26:32 +00:00
|
|
|
// Copyright (c) 2019 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
|
|
|
#define ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2024-09-16 20:53:04 +00:00
|
|
|
#include <string_view>
|
2019-10-23 16:26:32 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2024-07-29 17:42:57 +00:00
|
|
|
#include "v8/include/v8-forward.h"
|
2019-10-23 16:26:32 +00:00
|
|
|
|
|
|
|
namespace node {
|
|
|
|
class Environment;
|
2021-07-02 00:51:37 +00:00
|
|
|
}
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
namespace electron::util {
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2024-09-16 20:53:04 +00:00
|
|
|
// Emit a warning via node's process.emitWarning()
|
|
|
|
void EmitWarning(v8::Isolate* isolate,
|
|
|
|
std::string_view warning_msg,
|
|
|
|
std::string_view warning_type);
|
|
|
|
|
|
|
|
// Emit a warning via node's process.emitWarning(),
|
|
|
|
// using JavscriptEnvironment's isolate
|
|
|
|
void EmitWarning(std::string_view warning_msg, std::string_view warning_type);
|
|
|
|
|
2019-10-23 16:26:32 +00:00
|
|
|
// Run a script with JS source bundled inside the binary as if it's wrapped
|
|
|
|
// in a function called with a null receiver and arguments specified in C++.
|
|
|
|
// The returned value is empty if an exception is encountered.
|
|
|
|
// JS code run with this method can assume that their top-level
|
|
|
|
// declarations won't affect the global scope.
|
|
|
|
v8::MaybeLocal<v8::Value> CompileAndCall(
|
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
const char* id,
|
|
|
|
std::vector<v8::Local<v8::String>>* parameters,
|
2023-11-30 14:51:35 +00:00
|
|
|
std::vector<v8::Local<v8::Value>>* arguments);
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
} // namespace electron::util
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|