@nocobase/plugin-workflow-javascript 2.1.0-beta.10 → 2.1.0-beta.12

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 (107) hide show
  1. package/dist/externalVersion.js +4 -4
  2. package/dist/node_modules/isolated-vm/.clang-tidy +13 -0
  3. package/dist/node_modules/isolated-vm/.dockerignore +9 -0
  4. package/dist/node_modules/isolated-vm/Dockerfile.alpine +9 -0
  5. package/dist/node_modules/isolated-vm/Dockerfile.debian +12 -0
  6. package/dist/node_modules/isolated-vm/LICENSE +13 -0
  7. package/dist/node_modules/isolated-vm/binding.gyp +120 -0
  8. package/dist/node_modules/isolated-vm/include.js +3 -0
  9. package/dist/node_modules/isolated-vm/inspector-example.js +59 -0
  10. package/dist/node_modules/isolated-vm/isolated-vm.d.ts +820 -0
  11. package/dist/node_modules/isolated-vm/isolated-vm.js +1 -0
  12. package/dist/node_modules/isolated-vm/native-example/binding.gyp +23 -0
  13. package/dist/node_modules/isolated-vm/native-example/example.cc +61 -0
  14. package/dist/node_modules/isolated-vm/native-example/package.json +13 -0
  15. package/dist/node_modules/isolated-vm/native-example/usage.js +35 -0
  16. package/dist/node_modules/isolated-vm/out/isolated_vm.node +0 -0
  17. package/dist/node_modules/isolated-vm/package.json +1 -0
  18. package/dist/node_modules/isolated-vm/src/external_copy/error.h +33 -0
  19. package/dist/node_modules/isolated-vm/src/external_copy/external_copy.cc +509 -0
  20. package/dist/node_modules/isolated-vm/src/external_copy/external_copy.h +117 -0
  21. package/dist/node_modules/isolated-vm/src/external_copy/serializer.cc +85 -0
  22. package/dist/node_modules/isolated-vm/src/external_copy/serializer.h +136 -0
  23. package/dist/node_modules/isolated-vm/src/external_copy/serializer_nortti.cc +73 -0
  24. package/dist/node_modules/isolated-vm/src/external_copy/string.cc +124 -0
  25. package/dist/node_modules/isolated-vm/src/external_copy/string.h +28 -0
  26. package/dist/node_modules/isolated-vm/src/isolate/allocator.h +32 -0
  27. package/dist/node_modules/isolated-vm/src/isolate/allocator_nortti.cc +142 -0
  28. package/dist/node_modules/isolated-vm/src/isolate/class_handle.h +334 -0
  29. package/dist/node_modules/isolated-vm/src/isolate/cpu_profile_manager.cc +220 -0
  30. package/dist/node_modules/isolated-vm/src/isolate/cpu_profile_manager.h +100 -0
  31. package/dist/node_modules/isolated-vm/src/isolate/environment.cc +626 -0
  32. package/dist/node_modules/isolated-vm/src/isolate/environment.h +381 -0
  33. package/dist/node_modules/isolated-vm/src/isolate/executor.cc +198 -0
  34. package/dist/node_modules/isolated-vm/src/isolate/executor.h +183 -0
  35. package/dist/node_modules/isolated-vm/src/isolate/external.h +64 -0
  36. package/dist/node_modules/isolated-vm/src/isolate/functor_runners.h +97 -0
  37. package/dist/node_modules/isolated-vm/src/isolate/generic/array.h +145 -0
  38. package/dist/node_modules/isolated-vm/src/isolate/generic/callbacks.h +272 -0
  39. package/dist/node_modules/isolated-vm/src/isolate/generic/error.h +140 -0
  40. package/dist/node_modules/isolated-vm/src/isolate/generic/extract_params.h +145 -0
  41. package/dist/node_modules/isolated-vm/src/isolate/generic/handle_cast.h +257 -0
  42. package/dist/node_modules/isolated-vm/src/isolate/generic/read_option.h +47 -0
  43. package/dist/node_modules/isolated-vm/src/isolate/holder.cc +88 -0
  44. package/dist/node_modules/isolated-vm/src/isolate/holder.h +63 -0
  45. package/dist/node_modules/isolated-vm/src/isolate/inspector.cc +200 -0
  46. package/dist/node_modules/isolated-vm/src/isolate/inspector.h +70 -0
  47. package/dist/node_modules/isolated-vm/src/isolate/node_wrapper.h +15 -0
  48. package/dist/node_modules/isolated-vm/src/isolate/platform_delegate.cc +22 -0
  49. package/dist/node_modules/isolated-vm/src/isolate/platform_delegate.h +46 -0
  50. package/dist/node_modules/isolated-vm/src/isolate/remote_handle.h +164 -0
  51. package/dist/node_modules/isolated-vm/src/isolate/run_with_timeout.h +171 -0
  52. package/dist/node_modules/isolated-vm/src/isolate/runnable.h +29 -0
  53. package/dist/node_modules/isolated-vm/src/isolate/scheduler.cc +191 -0
  54. package/dist/node_modules/isolated-vm/src/isolate/scheduler.h +165 -0
  55. package/dist/node_modules/isolated-vm/src/isolate/specific.h +35 -0
  56. package/dist/node_modules/isolated-vm/src/isolate/stack_trace.cc +219 -0
  57. package/dist/node_modules/isolated-vm/src/isolate/stack_trace.h +24 -0
  58. package/dist/node_modules/isolated-vm/src/isolate/strings.h +127 -0
  59. package/dist/node_modules/isolated-vm/src/isolate/three_phase_task.cc +385 -0
  60. package/dist/node_modules/isolated-vm/src/isolate/three_phase_task.h +136 -0
  61. package/dist/node_modules/isolated-vm/src/isolate/transferable.h +15 -0
  62. package/dist/node_modules/isolated-vm/src/isolate/util.h +45 -0
  63. package/dist/node_modules/isolated-vm/src/isolate/v8_inspector_wrapper.h +12 -0
  64. package/dist/node_modules/isolated-vm/src/isolate/v8_version.h +12 -0
  65. package/dist/node_modules/isolated-vm/src/isolated_vm.h +71 -0
  66. package/dist/node_modules/isolated-vm/src/lib/covariant.h +50 -0
  67. package/dist/node_modules/isolated-vm/src/lib/lockable.h +178 -0
  68. package/dist/node_modules/isolated-vm/src/lib/suspend.h +106 -0
  69. package/dist/node_modules/isolated-vm/src/lib/thread_pool.cc +98 -0
  70. package/dist/node_modules/isolated-vm/src/lib/thread_pool.h +45 -0
  71. package/dist/node_modules/isolated-vm/src/lib/timer.cc +233 -0
  72. package/dist/node_modules/isolated-vm/src/lib/timer.h +36 -0
  73. package/dist/node_modules/isolated-vm/src/module/callback.cc +151 -0
  74. package/dist/node_modules/isolated-vm/src/module/callback.h +64 -0
  75. package/dist/node_modules/isolated-vm/src/module/context_handle.cc +241 -0
  76. package/dist/node_modules/isolated-vm/src/module/context_handle.h +35 -0
  77. package/dist/node_modules/isolated-vm/src/module/evaluation.cc +109 -0
  78. package/dist/node_modules/isolated-vm/src/module/evaluation.h +99 -0
  79. package/dist/node_modules/isolated-vm/src/module/external_copy_handle.cc +119 -0
  80. package/dist/node_modules/isolated-vm/src/module/external_copy_handle.h +64 -0
  81. package/dist/node_modules/isolated-vm/src/module/isolate.cc +136 -0
  82. package/dist/node_modules/isolated-vm/src/module/isolate_handle.cc +611 -0
  83. package/dist/node_modules/isolated-vm/src/module/isolate_handle.h +47 -0
  84. package/dist/node_modules/isolated-vm/src/module/lib_handle.cc +77 -0
  85. package/dist/node_modules/isolated-vm/src/module/lib_handle.h +28 -0
  86. package/dist/node_modules/isolated-vm/src/module/module_handle.cc +475 -0
  87. package/dist/node_modules/isolated-vm/src/module/module_handle.h +68 -0
  88. package/dist/node_modules/isolated-vm/src/module/native_module_handle.cc +104 -0
  89. package/dist/node_modules/isolated-vm/src/module/native_module_handle.h +49 -0
  90. package/dist/node_modules/isolated-vm/src/module/reference_handle.cc +636 -0
  91. package/dist/node_modules/isolated-vm/src/module/reference_handle.h +106 -0
  92. package/dist/node_modules/isolated-vm/src/module/script_handle.cc +107 -0
  93. package/dist/node_modules/isolated-vm/src/module/script_handle.h +37 -0
  94. package/dist/node_modules/isolated-vm/src/module/session_handle.cc +173 -0
  95. package/dist/node_modules/isolated-vm/src/module/session_handle.h +31 -0
  96. package/dist/node_modules/isolated-vm/src/module/transferable.cc +268 -0
  97. package/dist/node_modules/isolated-vm/src/module/transferable.h +42 -0
  98. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v18.0.0.h +360 -0
  99. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v18.3.0.h +376 -0
  100. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v20.0.0.h +397 -0
  101. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v22.0.0.h +419 -0
  102. package/dist/node_modules/winston-transport/package.json +1 -1
  103. package/dist/server/IsolatedVm.js +75 -0
  104. package/dist/server/ScriptInstruction.d.ts +6 -0
  105. package/dist/server/ScriptInstruction.js +11 -1
  106. package/dist/server/Vm.js +42 -27
  107. package/package.json +3 -2
@@ -0,0 +1,419 @@
1
+ // Copyright 2016 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef V8_V8_INSPECTOR_H_
6
+ #define V8_V8_INSPECTOR_H_
7
+
8
+ #include <stdint.h>
9
+
10
+ #include <cctype>
11
+ #include <memory>
12
+
13
+ #include "v8-isolate.h" // NOLINT(build/include_directory)
14
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
15
+
16
+ namespace v8 {
17
+ class Context;
18
+ class Name;
19
+ class Object;
20
+ class StackTrace;
21
+ class Value;
22
+ } // namespace v8
23
+
24
+ namespace v8_inspector {
25
+
26
+ namespace internal {
27
+ class V8DebuggerId;
28
+ } // namespace internal
29
+
30
+ namespace protocol {
31
+ namespace Debugger {
32
+ namespace API {
33
+ class SearchMatch;
34
+ }
35
+ } // namespace Debugger
36
+ namespace Runtime {
37
+ namespace API {
38
+ class RemoteObject;
39
+ class StackTrace;
40
+ class StackTraceId;
41
+ } // namespace API
42
+ } // namespace Runtime
43
+ namespace Schema {
44
+ namespace API {
45
+ class Domain;
46
+ }
47
+ } // namespace Schema
48
+ } // namespace protocol
49
+
50
+ class V8_EXPORT StringView {
51
+ public:
52
+ StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
53
+
54
+ StringView(const uint8_t* characters, size_t length)
55
+ : m_is8Bit(true), m_length(length), m_characters8(characters) {}
56
+
57
+ StringView(const uint16_t* characters, size_t length)
58
+ : m_is8Bit(false), m_length(length), m_characters16(characters) {}
59
+
60
+ bool is8Bit() const { return m_is8Bit; }
61
+ size_t length() const { return m_length; }
62
+
63
+ // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used
64
+ // here.
65
+ const uint8_t* characters8() const { return m_characters8; }
66
+ const uint16_t* characters16() const { return m_characters16; }
67
+
68
+ private:
69
+ bool m_is8Bit;
70
+ size_t m_length;
71
+ union {
72
+ const uint8_t* m_characters8;
73
+ const uint16_t* m_characters16;
74
+ };
75
+ };
76
+
77
+ class V8_EXPORT StringBuffer {
78
+ public:
79
+ virtual ~StringBuffer() = default;
80
+ virtual StringView string() const = 0;
81
+ // This method copies contents.
82
+ static std::unique_ptr<StringBuffer> create(StringView);
83
+ };
84
+
85
+ class V8_EXPORT V8ContextInfo {
86
+ public:
87
+ V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
88
+ StringView humanReadableName)
89
+ : context(context),
90
+ contextGroupId(contextGroupId),
91
+ humanReadableName(humanReadableName),
92
+ hasMemoryOnConsole(false) {}
93
+
94
+ v8::Local<v8::Context> context;
95
+ // Each v8::Context is a part of a group. The group id must be non-zero.
96
+ int contextGroupId;
97
+ StringView humanReadableName;
98
+ StringView origin;
99
+ StringView auxData;
100
+ bool hasMemoryOnConsole;
101
+
102
+ static int executionContextId(v8::Local<v8::Context> context);
103
+
104
+ // Disallow copying and allocating this one.
105
+ enum NotNullTagEnum { NotNullLiteral };
106
+ void* operator new(size_t) = delete;
107
+ void* operator new(size_t, NotNullTagEnum, void*) = delete;
108
+ void* operator new(size_t, void*) = delete;
109
+ V8ContextInfo(const V8ContextInfo&) = delete;
110
+ V8ContextInfo& operator=(const V8ContextInfo&) = delete;
111
+ };
112
+
113
+ // This debugger id tries to be unique by generating two random
114
+ // numbers, which should most likely avoid collisions.
115
+ // Debugger id has a 1:1 mapping to context group. It is used to
116
+ // attribute stack traces to a particular debugging, when doing any
117
+ // cross-debugger operations (e.g. async step in).
118
+ // See also Runtime.UniqueDebuggerId in the protocol.
119
+ class V8_EXPORT V8DebuggerId {
120
+ public:
121
+ V8DebuggerId() = default;
122
+ V8DebuggerId(const V8DebuggerId&) = default;
123
+ V8DebuggerId& operator=(const V8DebuggerId&) = default;
124
+
125
+ std::unique_ptr<StringBuffer> toString() const;
126
+ bool isValid() const;
127
+ std::pair<int64_t, int64_t> pair() const;
128
+
129
+ private:
130
+ friend class internal::V8DebuggerId;
131
+ explicit V8DebuggerId(std::pair<int64_t, int64_t>);
132
+
133
+ int64_t m_first = 0;
134
+ int64_t m_second = 0;
135
+ };
136
+
137
+ struct V8_EXPORT V8StackFrame {
138
+ StringView sourceURL;
139
+ StringView functionName;
140
+ int lineNumber;
141
+ int columnNumber;
142
+ };
143
+
144
+ class V8_EXPORT V8StackTrace {
145
+ public:
146
+ virtual StringView firstNonEmptySourceURL() const = 0;
147
+ virtual bool isEmpty() const = 0;
148
+ virtual StringView topSourceURL() const = 0;
149
+ virtual int topLineNumber() const = 0;
150
+ virtual int topColumnNumber() const = 0;
151
+ virtual int topScriptId() const = 0;
152
+ virtual StringView topFunctionName() const = 0;
153
+
154
+ virtual ~V8StackTrace() = default;
155
+ virtual std::unique_ptr<protocol::Runtime::API::StackTrace>
156
+ buildInspectorObject(int maxAsyncDepth) const = 0;
157
+ virtual std::unique_ptr<StringBuffer> toString() const = 0;
158
+
159
+ // Safe to pass between threads, drops async chain.
160
+ virtual std::unique_ptr<V8StackTrace> clone() = 0;
161
+
162
+ virtual std::vector<V8StackFrame> frames() const = 0;
163
+ };
164
+
165
+ class V8_EXPORT V8InspectorSession {
166
+ public:
167
+ virtual ~V8InspectorSession() = default;
168
+
169
+ // Cross-context inspectable values (DOM nodes in different worlds, etc.).
170
+ class V8_EXPORT Inspectable {
171
+ public:
172
+ virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0;
173
+ virtual ~Inspectable() = default;
174
+ };
175
+ virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
176
+
177
+ // Dispatching protocol messages.
178
+ static bool canDispatchMethod(StringView method);
179
+ virtual void dispatchProtocolMessage(StringView message) = 0;
180
+ virtual std::vector<uint8_t> state() = 0;
181
+ virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
182
+ supportedDomains() = 0;
183
+
184
+ // Debugger actions.
185
+ virtual void schedulePauseOnNextStatement(StringView breakReason,
186
+ StringView breakDetails) = 0;
187
+ virtual void cancelPauseOnNextStatement() = 0;
188
+ virtual void breakProgram(StringView breakReason,
189
+ StringView breakDetails) = 0;
190
+ virtual void setSkipAllPauses(bool) = 0;
191
+ virtual void resume(bool setTerminateOnResume = false) = 0;
192
+ virtual void stepOver() = 0;
193
+ virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
194
+ searchInTextByLines(StringView text, StringView query, bool caseSensitive,
195
+ bool isRegex) = 0;
196
+
197
+ // Remote objects.
198
+ virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
199
+ v8::Local<v8::Context>, v8::Local<v8::Value>, StringView groupName,
200
+ bool generatePreview) = 0;
201
+
202
+ virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
203
+ StringView objectId, v8::Local<v8::Value>*,
204
+ v8::Local<v8::Context>*,
205
+ std::unique_ptr<StringBuffer>* objectGroup) = 0;
206
+ virtual void releaseObjectGroup(StringView) = 0;
207
+ virtual void triggerPreciseCoverageDeltaUpdate(StringView occasion) = 0;
208
+
209
+ struct V8_EXPORT EvaluateResult {
210
+ enum class ResultType {
211
+ kNotRun,
212
+ kSuccess,
213
+ kException,
214
+ };
215
+
216
+ ResultType type;
217
+ v8::Local<v8::Value> value;
218
+ };
219
+ // Evalaute 'expression' in the provided context. Does the same as
220
+ // Runtime#evaluate under-the-hood but exposed on the C++ side.
221
+ virtual EvaluateResult evaluate(v8::Local<v8::Context> context,
222
+ StringView expression,
223
+ bool includeCommandLineAPI = false) = 0;
224
+
225
+ // Prepare for shutdown (disables debugger pausing, etc.).
226
+ virtual void stop() = 0;
227
+ };
228
+
229
+ struct V8_EXPORT DeepSerializedValue {
230
+ explicit DeepSerializedValue(std::unique_ptr<StringBuffer> type,
231
+ v8::MaybeLocal<v8::Value> value = {})
232
+ : type(std::move(type)), value(value) {}
233
+ std::unique_ptr<StringBuffer> type;
234
+ v8::MaybeLocal<v8::Value> value;
235
+ };
236
+
237
+ struct V8_EXPORT DeepSerializationResult {
238
+ explicit DeepSerializationResult(
239
+ std::unique_ptr<DeepSerializedValue> serializedValue)
240
+ : serializedValue(std::move(serializedValue)), isSuccess(true) {}
241
+ explicit DeepSerializationResult(std::unique_ptr<StringBuffer> errorMessage)
242
+ : errorMessage(std::move(errorMessage)), isSuccess(false) {}
243
+
244
+ // Use std::variant when available.
245
+ std::unique_ptr<DeepSerializedValue> serializedValue;
246
+ std::unique_ptr<StringBuffer> errorMessage;
247
+ bool isSuccess;
248
+ };
249
+
250
+ class V8_EXPORT V8InspectorClient {
251
+ public:
252
+ virtual ~V8InspectorClient() = default;
253
+
254
+ virtual void runMessageLoopOnPause(int contextGroupId) {}
255
+ virtual void runMessageLoopOnInstrumentationPause(int contextGroupId) {
256
+ runMessageLoopOnPause(contextGroupId);
257
+ }
258
+ virtual void quitMessageLoopOnPause() {}
259
+ virtual void runIfWaitingForDebugger(int contextGroupId) {}
260
+
261
+ virtual void muteMetrics(int contextGroupId) {}
262
+ virtual void unmuteMetrics(int contextGroupId) {}
263
+
264
+ virtual void beginUserGesture() {}
265
+ virtual void endUserGesture() {}
266
+
267
+ virtual std::unique_ptr<DeepSerializationResult> deepSerialize(
268
+ v8::Local<v8::Value> v8Value, int maxDepth,
269
+ v8::Local<v8::Object> additionalParameters) {
270
+ return nullptr;
271
+ }
272
+ virtual std::unique_ptr<StringBuffer> valueSubtype(v8::Local<v8::Value>) {
273
+ return nullptr;
274
+ }
275
+ virtual std::unique_ptr<StringBuffer> descriptionForValueSubtype(
276
+ v8::Local<v8::Context>, v8::Local<v8::Value>) {
277
+ return nullptr;
278
+ }
279
+ virtual bool isInspectableHeapObject(v8::Local<v8::Object>) { return true; }
280
+
281
+ virtual v8::Local<v8::Context> ensureDefaultContextInGroup(
282
+ int contextGroupId) {
283
+ return v8::Local<v8::Context>();
284
+ }
285
+ virtual void beginEnsureAllContextsInGroup(int contextGroupId) {}
286
+ virtual void endEnsureAllContextsInGroup(int contextGroupId) {}
287
+
288
+ virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>,
289
+ v8::Local<v8::Object>) {}
290
+ virtual void consoleAPIMessage(int contextGroupId,
291
+ v8::Isolate::MessageErrorLevel level,
292
+ const StringView& message,
293
+ const StringView& url, unsigned lineNumber,
294
+ unsigned columnNumber, V8StackTrace*) {}
295
+ virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*,
296
+ v8::Local<v8::Context>) {
297
+ return v8::MaybeLocal<v8::Value>();
298
+ }
299
+
300
+ virtual void consoleTime(const StringView& title) {}
301
+ virtual void consoleTimeEnd(const StringView& title) {}
302
+ virtual void consoleTimeStamp(const StringView& title) {}
303
+ virtual void consoleClear(int contextGroupId) {}
304
+ virtual double currentTimeMS() { return 0; }
305
+ typedef void (*TimerCallback)(void*);
306
+ virtual void startRepeatingTimer(double, TimerCallback, void* data) {}
307
+ virtual void cancelTimer(void* data) {}
308
+
309
+ // TODO(dgozman): this was added to support service worker shadow page. We
310
+ // should not connect at all.
311
+ virtual bool canExecuteScripts(int contextGroupId) { return true; }
312
+
313
+ virtual void maxAsyncCallStackDepthChanged(int depth) {}
314
+
315
+ virtual std::unique_ptr<StringBuffer> resourceNameToUrl(
316
+ const StringView& resourceName) {
317
+ return nullptr;
318
+ }
319
+
320
+ // The caller would defer to generating a random 64 bit integer if
321
+ // this method returns 0.
322
+ virtual int64_t generateUniqueId() { return 0; }
323
+
324
+ virtual void dispatchError(v8::Local<v8::Context>, v8::Local<v8::Message>,
325
+ v8::Local<v8::Value>) {}
326
+ };
327
+
328
+ // These stack trace ids are intended to be passed between debuggers and be
329
+ // resolved later. This allows to track cross-debugger calls and step between
330
+ // them if a single client connects to multiple debuggers.
331
+ struct V8_EXPORT V8StackTraceId {
332
+ uintptr_t id;
333
+ std::pair<int64_t, int64_t> debugger_id;
334
+ bool should_pause = false;
335
+
336
+ V8StackTraceId();
337
+ V8StackTraceId(const V8StackTraceId&) = default;
338
+ V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id);
339
+ V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id,
340
+ bool should_pause);
341
+ explicit V8StackTraceId(StringView);
342
+ V8StackTraceId& operator=(const V8StackTraceId&) = default;
343
+ V8StackTraceId& operator=(V8StackTraceId&&) noexcept = default;
344
+ ~V8StackTraceId() = default;
345
+
346
+ bool IsInvalid() const;
347
+ std::unique_ptr<StringBuffer> ToString();
348
+ };
349
+
350
+ class V8_EXPORT V8Inspector {
351
+ public:
352
+ static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*);
353
+ virtual ~V8Inspector() = default;
354
+
355
+ // Contexts instrumentation.
356
+ virtual void contextCreated(const V8ContextInfo&) = 0;
357
+ virtual void contextDestroyed(v8::Local<v8::Context>) = 0;
358
+ virtual void resetContextGroup(int contextGroupId) = 0;
359
+ virtual v8::MaybeLocal<v8::Context> contextById(int contextId) = 0;
360
+ virtual V8DebuggerId uniqueDebuggerId(int contextId) = 0;
361
+
362
+ // Various instrumentation.
363
+ virtual void idleStarted() = 0;
364
+ virtual void idleFinished() = 0;
365
+
366
+ // Async stack traces instrumentation.
367
+ virtual void asyncTaskScheduled(StringView taskName, void* task,
368
+ bool recurring) = 0;
369
+ virtual void asyncTaskCanceled(void* task) = 0;
370
+ virtual void asyncTaskStarted(void* task) = 0;
371
+ virtual void asyncTaskFinished(void* task) = 0;
372
+ virtual void allAsyncTasksCanceled() = 0;
373
+
374
+ virtual V8StackTraceId storeCurrentStackTrace(StringView description) = 0;
375
+ virtual void externalAsyncTaskStarted(const V8StackTraceId& parent) = 0;
376
+ virtual void externalAsyncTaskFinished(const V8StackTraceId& parent) = 0;
377
+
378
+ // Exceptions instrumentation.
379
+ virtual unsigned exceptionThrown(v8::Local<v8::Context>, StringView message,
380
+ v8::Local<v8::Value> exception,
381
+ StringView detailedMessage, StringView url,
382
+ unsigned lineNumber, unsigned columnNumber,
383
+ std::unique_ptr<V8StackTrace>,
384
+ int scriptId) = 0;
385
+ virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
386
+ StringView message) = 0;
387
+ virtual bool associateExceptionData(v8::Local<v8::Context>,
388
+ v8::Local<v8::Value> exception,
389
+ v8::Local<v8::Name> key,
390
+ v8::Local<v8::Value> value) = 0;
391
+
392
+ // Connection.
393
+ class V8_EXPORT Channel {
394
+ public:
395
+ virtual ~Channel() = default;
396
+ virtual void sendResponse(int callId,
397
+ std::unique_ptr<StringBuffer> message) = 0;
398
+ virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
399
+ virtual void flushProtocolNotifications() = 0;
400
+ };
401
+ enum ClientTrustLevel { kUntrusted, kFullyTrusted };
402
+ enum SessionPauseState { kWaitingForDebugger, kNotWaitingForDebugger };
403
+ // TODO(chromium:1352175): remove default value once downstream change lands.
404
+ virtual std::unique_ptr<V8InspectorSession> connect(
405
+ int contextGroupId, Channel*, StringView state,
406
+ ClientTrustLevel client_trust_level,
407
+ SessionPauseState = kNotWaitingForDebugger) {
408
+ return nullptr;
409
+ }
410
+
411
+ // API methods.
412
+ virtual std::unique_ptr<V8StackTrace> createStackTrace(
413
+ v8::Local<v8::StackTrace>) = 0;
414
+ virtual std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) = 0;
415
+ };
416
+
417
+ } // namespace v8_inspector
418
+
419
+ #endif // V8_V8_INSPECTOR_H_
@@ -1 +1 @@
1
- {"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-03-19T03:17:04.548Z"}
1
+ {"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-04-08T08:19:15.597Z"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ const { parentPort, workerData } = require("node:worker_threads");
11
+ const ivm = require("isolated-vm");
12
+ async function main() {
13
+ const { source, args = {}, options = {} } = workerData;
14
+ const isolate = new ivm.Isolate({ memoryLimit: 128 });
15
+ try {
16
+ const context = await isolate.createContext();
17
+ const jail = context.global;
18
+ const logCb = new ivm.Callback((...a) => console.log(...a));
19
+ const warnCb = new ivm.Callback((...a) => console.warn(...a));
20
+ const errorCb = new ivm.Callback((...a) => console.error(...a));
21
+ await jail.set("__logCb", logCb);
22
+ await jail.set("__warnCb", warnCb);
23
+ await jail.set("__errorCb", errorCb);
24
+ await context.eval(`
25
+ const console = Object.freeze({
26
+ log: __logCb,
27
+ info: __logCb,
28
+ warn: __warnCb,
29
+ error: __errorCb,
30
+ debug: __logCb,
31
+ trace: __logCb,
32
+ dir: __logCb,
33
+ dirxml: __logCb,
34
+ table: __logCb,
35
+ time: function() {},
36
+ timeEnd: function() {},
37
+ timeLog: function() {},
38
+ count: function() {},
39
+ countReset: function() {},
40
+ group: function() {},
41
+ groupCollapsed: function() {},
42
+ groupEnd: function() {},
43
+ clear: function() {},
44
+ assert: function(cond, ...a) { if (!cond) __errorCb('Assertion failed:', ...a); },
45
+ });
46
+ delete globalThis.__logCb;
47
+ delete globalThis.__warnCb;
48
+ delete globalThis.__errorCb;
49
+ `);
50
+ for (const [key, value] of Object.entries(args)) {
51
+ const val = value === void 0 ? null : value;
52
+ await jail.set(key, new ivm.ExternalCopy(val).copyInto());
53
+ }
54
+ const code = `
55
+ (async function __main() {
56
+ ${source}
57
+ })()
58
+ `;
59
+ const result = await context.eval(code, {
60
+ timeout: options.timeout || void 0,
61
+ promise: true,
62
+ copy: true
63
+ });
64
+ return result;
65
+ } finally {
66
+ if (!isolate.isDisposed) {
67
+ isolate.dispose();
68
+ }
69
+ }
70
+ }
71
+ main().then((result) => {
72
+ parentPort.postMessage({ type: "result", result });
73
+ }).catch((error) => {
74
+ throw error;
75
+ });
@@ -17,6 +17,12 @@ type ScriptConfig = {
17
17
  }[];
18
18
  };
19
19
  export default class ScriptInstruction extends Instruction {
20
+ /**
21
+ * Returns the worker script path based on whether WORKFLOW_SCRIPT_MODULES is configured.
22
+ * - WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (module whitelist)
23
+ * - WORKFLOW_SCRIPT_MODULES unset: uses isolated-vm for maximum security (no require, no Node.js APIs)
24
+ */
25
+ static get workerScript(): string;
20
26
  static run(source: any, args: any, options: {
21
27
  logger: Logger;
22
28
  timeout?: number;
@@ -46,10 +46,20 @@ var import_winston = __toESM(require("winston"));
46
46
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
47
47
  var import_cache_logger = require("./cache-logger");
48
48
  class ScriptInstruction extends import_plugin_workflow.Instruction {
49
+ /**
50
+ * Returns the worker script path based on whether WORKFLOW_SCRIPT_MODULES is configured.
51
+ * - WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (module whitelist)
52
+ * - WORKFLOW_SCRIPT_MODULES unset: uses isolated-vm for maximum security (no require, no Node.js APIs)
53
+ */
54
+ static get workerScript() {
55
+ var _a;
56
+ const hasModules = ((_a = process.env.WORKFLOW_SCRIPT_MODULES) == null ? void 0 : _a.split(",").filter(Boolean).length) > 0;
57
+ return import_node_path.default.join(__dirname, hasModules ? "Vm.js" : "IsolatedVm.js");
58
+ }
49
59
  static async run(source, args, options) {
50
60
  const { logger, timeout } = options;
51
61
  let result;
52
- const worker = new import_node_worker_threads.Worker(import_node_path.default.join(__dirname, "Vm.js"), {
62
+ const worker = new import_node_worker_threads.Worker(this.workerScript, {
53
63
  workerData: { source, args, options: timeout ? { timeout } : {} }
54
64
  });
55
65
  worker.on("message", (message) => {
package/dist/server/Vm.js CHANGED
@@ -28,43 +28,58 @@ function customRequire(m) {
28
28
  }
29
29
  throw new Error(`module "${m}" not supported`);
30
30
  }
31
- customRequire.constructor = null;
32
- function createSafeConsole(originalConsole) {
33
- const safe = /* @__PURE__ */ Object.create(null);
34
- Object.defineProperty(safe, "constructor", {
31
+ function hardenFunction(fn) {
32
+ Object.setPrototypeOf(fn, null);
33
+ Object.defineProperty(fn, "constructor", {
35
34
  value: null,
36
35
  writable: false,
37
36
  enumerable: false,
38
37
  configurable: false
39
38
  });
40
- const allKeys = Reflect.ownKeys(originalConsole);
41
- for (const key of allKeys) {
42
- const descriptor = Object.getOwnPropertyDescriptor(originalConsole, key);
43
- if (!descriptor) {
44
- continue;
45
- }
46
- const wrap = (fn) => {
47
- const bound = fn.bind(originalConsole);
48
- Object.defineProperty(bound, "constructor", {
49
- value: null,
39
+ return fn;
40
+ }
41
+ hardenFunction(customRequire);
42
+ function createSafeConsole(originalConsole) {
43
+ const safe = /* @__PURE__ */ Object.create(null);
44
+ const allowedMethods = [
45
+ "log",
46
+ "info",
47
+ "warn",
48
+ "error",
49
+ "debug",
50
+ "trace",
51
+ "dir",
52
+ "dirxml",
53
+ "table",
54
+ "time",
55
+ "timeEnd",
56
+ "timeLog",
57
+ "count",
58
+ "countReset",
59
+ "group",
60
+ "groupCollapsed",
61
+ "groupEnd",
62
+ "clear",
63
+ "assert"
64
+ ];
65
+ for (const key of allowedMethods) {
66
+ if (typeof originalConsole[key] === "function") {
67
+ const bound = originalConsole[key].bind(originalConsole);
68
+ hardenFunction(bound);
69
+ Object.defineProperty(safe, key, {
70
+ value: bound,
50
71
  writable: false,
51
- enumerable: false,
72
+ enumerable: true,
52
73
  configurable: false
53
74
  });
54
- return bound;
55
- };
56
- if (typeof descriptor.value === "function") {
57
- descriptor.value = wrap(descriptor.value);
58
- }
59
- if (typeof descriptor.get === "function") {
60
- descriptor.get = wrap(descriptor.get);
61
75
  }
62
- if (typeof descriptor.set === "function") {
63
- descriptor.set = wrap(descriptor.set);
64
- }
65
- descriptor.configurable = false;
66
- Object.defineProperty(safe, key, descriptor);
67
76
  }
77
+ Object.defineProperty(safe, "constructor", {
78
+ value: null,
79
+ writable: false,
80
+ enumerable: false,
81
+ configurable: false
82
+ });
68
83
  return Object.freeze(safe);
69
84
  }
70
85
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow-javascript",
3
- "version": "2.1.0-beta.10",
3
+ "version": "2.1.0-beta.12",
4
4
  "displayName": "Workflow: JavaScript",
5
5
  "displayName.zh-CN": "工作流:JavaScript 节点",
6
6
  "description": "Execute a piece of JavaScript in an isolated Node.js environment.",
@@ -25,6 +25,7 @@
25
25
  "@codemirror/state": "^6.4.1",
26
26
  "@codemirror/view": "^6.37.2",
27
27
  "codemirror": "^6.0.2",
28
+ "isolated-vm": "^5.0.4",
28
29
  "jshint": "^2.13.6",
29
30
  "node-gyp": "^10.2.0"
30
31
  },
@@ -36,5 +37,5 @@
36
37
  "Workflow"
37
38
  ],
38
39
  "license": "Apache-2.0",
39
- "gitHead": "f7e467710d4748f7089b779494b220025b39bc02"
40
+ "gitHead": "25cee9643f42f850afc4adc33c55a56850ac730d"
40
41
  }