nwinread 1.1.0 → 1.2.0
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.
- package/README.md +779 -96
- package/binding.gyp +30 -0
- package/build/binding.sln +6 -0
- package/build/eventlogasync.vcxproj +148 -0
- package/build/eventlogasync.vcxproj.filters +43 -0
- package/doc/ASYNC_STATUS.md +104 -0
- package/doc/COHERENCIA_APIS.md +154 -0
- package/doc/CONTRIBUTING.md +64 -0
- package/doc/CORRECCION_NAPI.md +74 -0
- package/doc/CPU_EFFICIENCY_GUIDE.md +199 -0
- package/doc/NAPI-SETUP.md +294 -0
- package/doc/PREBUILDS.md +180 -0
- package/doc/README_eventlogasync.md +134 -0
- package/doc/RESUMABLE_READER.md +250 -0
- package/doc/USAGE.md +527 -0
- package/index.js +202 -25
- package/native/eventlogasync.cc +687 -0
- package/package.json +37 -9
- package/prebuilds/metadata.json +24 -0
- package/prebuilds/win32-x64/eventlog.node +0 -0
- package/prebuilds/win32-x64/eventlogasync.node +0 -0
- package/prebuilds/win32-x64/meta.json +20 -0
- package/prebuilds/win32-x64/nwinread.node +0 -0
- package/scripts/generate-prebuilds-advanced.js +186 -0
- package/scripts/generate-prebuilds.js +86 -0
- package/scripts/prebuilds/win32-x64/meta.json +20 -0
- package/scripts/verify-setup.js +2 -1
- package/test/README.md +105 -0
- package/test/example_async.js +107 -0
- package/test/example_sync.js +76 -0
- package/test/test_beginning_mode.js +40 -0
- package/test/test_build_version.js +46 -0
- package/test/test_callback_simple.js +46 -0
- package/test/test_modes_comparison.js +74 -0
- package/test/test_watermark_realistic.js +75 -0
- package/test/test_watermark_specific.js +88 -0
- package/test/test_wrapper_vs_native.js +58 -0
- package/test/verify_sync_events.js +19 -0
- package/CHANGES.md +0 -120
- package/NAPI-SETUP.md +0 -142
- package/test.js +0 -34
package/binding.gyp
CHANGED
|
@@ -29,6 +29,36 @@
|
|
|
29
29
|
}
|
|
30
30
|
}]
|
|
31
31
|
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"target_name": "eventlogasync",
|
|
35
|
+
"sources": [ "native/eventlogasync.cc" ],
|
|
36
|
+
"cflags!": [ "-fno-exceptions" ],
|
|
37
|
+
"cflags_cc!": [ "-fno-exceptions" ],
|
|
38
|
+
"defines": [
|
|
39
|
+
"UNICODE",
|
|
40
|
+
"_UNICODE",
|
|
41
|
+
"WIN32_LEAN_AND_MEAN",
|
|
42
|
+
"_WIN32_WINNT=0x0600",
|
|
43
|
+
"NAPI_DISABLE_CPP_EXCEPTIONS",
|
|
44
|
+
"NAPI_VERSION=8"
|
|
45
|
+
],
|
|
46
|
+
"include_dirs": [
|
|
47
|
+
"<!(node -p \"require('node-addon-api').include_dir\")"
|
|
48
|
+
],
|
|
49
|
+
"conditions": [
|
|
50
|
+
['OS=="win"', {
|
|
51
|
+
"link_settings": {
|
|
52
|
+
"libraries": [ "-lwevtapi.lib" ]
|
|
53
|
+
},
|
|
54
|
+
"msvs_settings": {
|
|
55
|
+
"VCCLCompilerTool": {
|
|
56
|
+
"ExceptionHandling": 1,
|
|
57
|
+
"AdditionalOptions": [ "/utf-8" ]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}]
|
|
61
|
+
]
|
|
32
62
|
}
|
|
33
63
|
]
|
|
34
64
|
}
|
package/build/binding.sln
CHANGED
|
@@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|
|
2
2
|
# Visual Studio 2015
|
|
3
3
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eventlog", "eventlog.vcxproj", "{93B27CD6-DFF5-C767-15F7-D272884843E0}"
|
|
4
4
|
EndProject
|
|
5
|
+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eventlogasync", "eventlogasync.vcxproj", "{D0136086-1823-D149-4721-DBD52D31BAA6}"
|
|
6
|
+
EndProject
|
|
5
7
|
Global
|
|
6
8
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
7
9
|
Debug|x64 = Debug|x64
|
|
@@ -12,6 +14,10 @@ Global
|
|
|
12
14
|
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Debug|x64.Build.0 = Debug|x64
|
|
13
15
|
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Release|x64.ActiveCfg = Release|x64
|
|
14
16
|
{93B27CD6-DFF5-C767-15F7-D272884843E0}.Release|x64.Build.0 = Release|x64
|
|
17
|
+
{D0136086-1823-D149-4721-DBD52D31BAA6}.Debug|x64.ActiveCfg = Debug|x64
|
|
18
|
+
{D0136086-1823-D149-4721-DBD52D31BAA6}.Debug|x64.Build.0 = Debug|x64
|
|
19
|
+
{D0136086-1823-D149-4721-DBD52D31BAA6}.Release|x64.ActiveCfg = Release|x64
|
|
20
|
+
{D0136086-1823-D149-4721-DBD52D31BAA6}.Release|x64.Build.0 = Release|x64
|
|
15
21
|
EndGlobalSection
|
|
16
22
|
GlobalSection(SolutionProperties) = preSolution
|
|
17
23
|
HideSolutionNode = FALSE
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup Label="ProjectConfigurations">
|
|
4
|
+
<ProjectConfiguration Include="Debug|x64">
|
|
5
|
+
<Configuration>Debug</Configuration>
|
|
6
|
+
<Platform>x64</Platform>
|
|
7
|
+
</ProjectConfiguration>
|
|
8
|
+
<ProjectConfiguration Include="Release|x64">
|
|
9
|
+
<Configuration>Release</Configuration>
|
|
10
|
+
<Platform>x64</Platform>
|
|
11
|
+
</ProjectConfiguration>
|
|
12
|
+
</ItemGroup>
|
|
13
|
+
<PropertyGroup Label="Globals">
|
|
14
|
+
<ProjectGuid>{D0136086-1823-D149-4721-DBD52D31BAA6}</ProjectGuid>
|
|
15
|
+
<Keyword>Win32Proj</Keyword>
|
|
16
|
+
<RootNamespace>eventlogasync</RootNamespace>
|
|
17
|
+
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
|
18
|
+
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
|
19
|
+
<WindowsTargetPlatformVersion>10.0.22000.0</WindowsTargetPlatformVersion>
|
|
20
|
+
</PropertyGroup>
|
|
21
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
|
22
|
+
<PropertyGroup Label="Configuration">
|
|
23
|
+
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
24
|
+
</PropertyGroup>
|
|
25
|
+
<PropertyGroup Label="Locals">
|
|
26
|
+
<PlatformToolset>v143</PlatformToolset>
|
|
27
|
+
</PropertyGroup>
|
|
28
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
|
29
|
+
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props"/>
|
|
30
|
+
<ImportGroup Label="ExtensionSettings"/>
|
|
31
|
+
<ImportGroup Label="PropertySheets">
|
|
32
|
+
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
|
33
|
+
</ImportGroup>
|
|
34
|
+
<PropertyGroup Label="UserMacros"/>
|
|
35
|
+
<PropertyGroup>
|
|
36
|
+
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\</ExecutablePath>
|
|
37
|
+
<IgnoreImportLibrary>true</IgnoreImportLibrary>
|
|
38
|
+
<IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
|
|
39
|
+
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
40
|
+
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
41
|
+
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
|
42
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
|
|
43
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
|
|
44
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.node</TargetExt>
|
|
45
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.node</TargetExt>
|
|
46
|
+
<TargetName>$(ProjectName)</TargetName>
|
|
47
|
+
<TargetPath>$(OutDir)\$(ProjectName).node</TargetPath>
|
|
48
|
+
</PropertyGroup>
|
|
49
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
50
|
+
<ClCompile>
|
|
51
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
52
|
+
<AdditionalOptions>/Zc:__cplusplus -std:c++20 /Zm2000 /utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
53
|
+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
54
|
+
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
55
|
+
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
|
56
|
+
<DisableSpecificWarnings>4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
57
|
+
<ExceptionHandling>Sync</ExceptionHandling>
|
|
58
|
+
<MinimalRebuild>false</MinimalRebuild>
|
|
59
|
+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
60
|
+
<OmitFramePointers>false</OmitFramePointers>
|
|
61
|
+
<Optimization>Disabled</Optimization>
|
|
62
|
+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
63
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlogasync;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
64
|
+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
65
|
+
<StringPooling>true</StringPooling>
|
|
66
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
67
|
+
<TreatWarningAsError>false</TreatWarningAsError>
|
|
68
|
+
<WarningLevel>Level3</WarningLevel>
|
|
69
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
70
|
+
</ClCompile>
|
|
71
|
+
<Lib>
|
|
72
|
+
<AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
|
|
73
|
+
</Lib>
|
|
74
|
+
<Link>
|
|
75
|
+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\solzi\\AppData\\Local\\Temp\\prebuildify\\node\\25.0.0\\x64\\node.lib";wevtapi.lib</AdditionalDependencies>
|
|
76
|
+
<AdditionalOptions>/LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
|
|
77
|
+
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
|
|
78
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
79
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
80
|
+
<OptimizeReferences>true</OptimizeReferences>
|
|
81
|
+
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
|
|
82
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
83
|
+
<TargetExt>.node</TargetExt>
|
|
84
|
+
<TargetMachine>MachineX64</TargetMachine>
|
|
85
|
+
</Link>
|
|
86
|
+
<ResourceCompile>
|
|
87
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
88
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlogasync;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
89
|
+
</ResourceCompile>
|
|
90
|
+
</ItemDefinitionGroup>
|
|
91
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
92
|
+
<ClCompile>
|
|
93
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
94
|
+
<AdditionalOptions>/Zc:__cplusplus -std:c++20 /Zm2000 /utf-8 %(AdditionalOptions)</AdditionalOptions>
|
|
95
|
+
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
96
|
+
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
|
97
|
+
<DisableSpecificWarnings>4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
98
|
+
<ExceptionHandling>Sync</ExceptionHandling>
|
|
99
|
+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
|
100
|
+
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
101
|
+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
102
|
+
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
103
|
+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
104
|
+
<OmitFramePointers>true</OmitFramePointers>
|
|
105
|
+
<Optimization>Full</Optimization>
|
|
106
|
+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
107
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlogasync;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
108
|
+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
109
|
+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
|
110
|
+
<StringPooling>true</StringPooling>
|
|
111
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
112
|
+
<TreatWarningAsError>false</TreatWarningAsError>
|
|
113
|
+
<WarningLevel>Level3</WarningLevel>
|
|
114
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
115
|
+
</ClCompile>
|
|
116
|
+
<Lib>
|
|
117
|
+
<AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
|
|
118
|
+
</Lib>
|
|
119
|
+
<Link>
|
|
120
|
+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib;"C:\\Users\\solzi\\AppData\\Local\\Temp\\prebuildify\\node\\25.0.0\\x64\\node.lib";wevtapi.lib</AdditionalDependencies>
|
|
121
|
+
<AdditionalOptions>/LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
|
|
122
|
+
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
|
|
123
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
124
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
125
|
+
<OptimizeReferences>true</OptimizeReferences>
|
|
126
|
+
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
|
|
127
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
128
|
+
<TargetExt>.node</TargetExt>
|
|
129
|
+
<TargetMachine>MachineX64</TargetMachine>
|
|
130
|
+
</Link>
|
|
131
|
+
<ResourceCompile>
|
|
132
|
+
<AdditionalIncludeDirectories>C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\include\node;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\src;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\config;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\openssl\openssl\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\uv\include;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\zlib;C:\Users\solzi\AppData\Local\Temp\prebuildify\node\25.0.0\deps\v8\include;..\node_modules\node-addon-api;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
133
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=eventlogasync;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;UNICODE;_UNICODE;WIN32_LEAN_AND_MEAN;_WIN32_WINNT=0x0600;NAPI_DISABLE_CPP_EXCEPTIONS;NAPI_VERSION=8;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
134
|
+
</ResourceCompile>
|
|
135
|
+
</ItemDefinitionGroup>
|
|
136
|
+
<ItemGroup>
|
|
137
|
+
<None Include="..\binding.gyp"/>
|
|
138
|
+
</ItemGroup>
|
|
139
|
+
<ItemGroup>
|
|
140
|
+
<ClCompile Include="..\native\eventlogasync.cc">
|
|
141
|
+
<ObjectFileName>$(IntDir)\native\eventlogasync.obj</ObjectFileName>
|
|
142
|
+
</ClCompile>
|
|
143
|
+
<ClCompile Include="C:\opt\nwinread\node_modules\node-gyp\src\win_delay_load_hook.cc"/>
|
|
144
|
+
</ItemGroup>
|
|
145
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
|
146
|
+
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets"/>
|
|
147
|
+
<ImportGroup Label="ExtensionTargets"/>
|
|
148
|
+
</Project>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup>
|
|
4
|
+
<Filter Include="..">
|
|
5
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
6
|
+
</Filter>
|
|
7
|
+
<Filter Include="..\native">
|
|
8
|
+
<UniqueIdentifier>{D56EDB24-21BF-8816-5D92-25C635122F26}</UniqueIdentifier>
|
|
9
|
+
</Filter>
|
|
10
|
+
<Filter Include="C:">
|
|
11
|
+
<UniqueIdentifier>{7B735499-E5DD-1C2B-6C26-70023832A1CF}</UniqueIdentifier>
|
|
12
|
+
</Filter>
|
|
13
|
+
<Filter Include="C:\opt">
|
|
14
|
+
<UniqueIdentifier>{D5C58566-FA08-660A-46DB-0850F8635347}</UniqueIdentifier>
|
|
15
|
+
</Filter>
|
|
16
|
+
<Filter Include="C:\opt\nwinread">
|
|
17
|
+
<UniqueIdentifier>{0F6E36B6-918C-0825-91C2-4592D9AAA8A7}</UniqueIdentifier>
|
|
18
|
+
</Filter>
|
|
19
|
+
<Filter Include="C:\opt\nwinread\node_modules">
|
|
20
|
+
<UniqueIdentifier>{56DF7A98-063D-FB9D-485C-089023B4C16A}</UniqueIdentifier>
|
|
21
|
+
</Filter>
|
|
22
|
+
<Filter Include="C:\opt\nwinread\node_modules\node-gyp">
|
|
23
|
+
<UniqueIdentifier>{77348C0E-2034-7791-74D5-63C077DF5A3B}</UniqueIdentifier>
|
|
24
|
+
</Filter>
|
|
25
|
+
<Filter Include="C:\opt\nwinread\node_modules\node-gyp\src">
|
|
26
|
+
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
|
|
27
|
+
</Filter>
|
|
28
|
+
<Filter Include="..">
|
|
29
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
30
|
+
</Filter>
|
|
31
|
+
</ItemGroup>
|
|
32
|
+
<ItemGroup>
|
|
33
|
+
<ClCompile Include="..\native\eventlogasync.cc">
|
|
34
|
+
<Filter>..\native</Filter>
|
|
35
|
+
</ClCompile>
|
|
36
|
+
<ClCompile Include="C:\opt\nwinread\node_modules\node-gyp\src\win_delay_load_hook.cc">
|
|
37
|
+
<Filter>C:\opt\nwinread\node_modules\node-gyp\src</Filter>
|
|
38
|
+
</ClCompile>
|
|
39
|
+
<None Include="..\binding.gyp">
|
|
40
|
+
<Filter>..</Filter>
|
|
41
|
+
</None>
|
|
42
|
+
</ItemGroup>
|
|
43
|
+
</Project>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Estado de Implementación: Async Event Log Reader
|
|
2
|
+
|
|
3
|
+
## ✅ FUNCIONANDO PERFECTAMENTE
|
|
4
|
+
|
|
5
|
+
### Eventos Futuros (Tiempo Real)
|
|
6
|
+
```javascript
|
|
7
|
+
// ✅ RECOMENDADO: Monitoreo en tiempo real
|
|
8
|
+
const subscription = eventLog.subscribeFromEnd("Application",
|
|
9
|
+
(event) => console.log(`Nuevo evento: ${event.recordId}`),
|
|
10
|
+
(error) => console.error(error.message)
|
|
11
|
+
);
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**✅ Casos de uso:**
|
|
15
|
+
- Monitoreo en tiempo real
|
|
16
|
+
- Alertas de eventos nuevos
|
|
17
|
+
- Logs de actividad en vivo
|
|
18
|
+
|
|
19
|
+
## ⚠️ LIMITACIONES IDENTIFICADAS
|
|
20
|
+
|
|
21
|
+
### Eventos Históricos via Async
|
|
22
|
+
```javascript
|
|
23
|
+
// ❌ NO FUNCIONA: EvtSubscribeStartAtOldestRecord no entrega históricos inmediatamente
|
|
24
|
+
const historical = eventLog.subscribeFromBeginning("Application", ...);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Filtros Watermark via Async
|
|
28
|
+
```javascript
|
|
29
|
+
// ❌ NO FUNCIONA: Filtros XPath no funcionan como esperado
|
|
30
|
+
const watermark = eventLog.subscribeFromWatermark("Application", 50000, ...);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🛠️ SOLUCIONES RECOMENDADAS
|
|
34
|
+
|
|
35
|
+
### Para Eventos Históricos: Usar Sync API
|
|
36
|
+
```javascript
|
|
37
|
+
// ✅ FUNCIONA PERFECTAMENTE
|
|
38
|
+
const historical = eventLog.readEvents("Application",
|
|
39
|
+
eventLog.START_MODE.BEGINNING, 0, 100);
|
|
40
|
+
|
|
41
|
+
console.log(`${historical.records.length} eventos históricos`);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Para Filtros por Record ID: Usar Sync API
|
|
45
|
+
```javascript
|
|
46
|
+
// ✅ FUNCIONA PERFECTAMENTE
|
|
47
|
+
const fromId = eventLog.readEvents("Application",
|
|
48
|
+
eventLog.START_MODE.WATERMARK, 50000, 50);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 🎯 PATRÓN DE USO RECOMENDADO
|
|
52
|
+
|
|
53
|
+
### Análisis Completo: Históricos + Tiempo Real
|
|
54
|
+
```javascript
|
|
55
|
+
// 1. Procesar eventos históricos (sync)
|
|
56
|
+
const historical = eventLog.readEvents("Application",
|
|
57
|
+
eventLog.START_MODE.BEGINNING, 0, 1000);
|
|
58
|
+
|
|
59
|
+
console.log(`Procesando ${historical.records.length} eventos históricos...`);
|
|
60
|
+
historical.records.forEach(processEvent);
|
|
61
|
+
|
|
62
|
+
// 2. Suscribirse a eventos futuros (async)
|
|
63
|
+
const subscription = eventLog.subscribeFromEnd("Application",
|
|
64
|
+
(event) => {
|
|
65
|
+
console.log(`Evento en tiempo real: ${event.recordId}`);
|
|
66
|
+
processEvent(event);
|
|
67
|
+
},
|
|
68
|
+
(error) => console.error(error.message)
|
|
69
|
+
);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 🔒 PERMISOS
|
|
73
|
+
|
|
74
|
+
### Canales sin Admin
|
|
75
|
+
- ✅ **System**: Eventos del sistema
|
|
76
|
+
- ✅ **Application**: Eventos de aplicaciones
|
|
77
|
+
- ✅ **Setup**: Instalaciones y actualizaciones
|
|
78
|
+
|
|
79
|
+
### Canales con Admin (ejecutar como administrador)
|
|
80
|
+
- 🔐 **Security**: Eventos de seguridad, login/logout
|
|
81
|
+
|
|
82
|
+
## 📊 RESUMEN ESTADO ACTUAL
|
|
83
|
+
|
|
84
|
+
| Funcionalidad | Sync API | Async API | Estado |
|
|
85
|
+
|---------------|----------|-----------|--------|
|
|
86
|
+
| Eventos recientes | ✅ | ✅ | Perfecto |
|
|
87
|
+
| Eventos futuros | N/A | ✅ | Perfecto |
|
|
88
|
+
| Eventos históricos | ✅ | ❌ | Sync funciona |
|
|
89
|
+
| Filtros por ID | ✅ | ❌ | Sync funciona |
|
|
90
|
+
| Filtros por Event ID | ✅ | ✅ | Perfecto |
|
|
91
|
+
|
|
92
|
+
## 🎉 CONCLUSIÓN
|
|
93
|
+
|
|
94
|
+
**El async event reader funciona perfectamente para su caso de uso principal: monitoreo en tiempo real.**
|
|
95
|
+
|
|
96
|
+
Para casos de uso que requieren eventos históricos o filtros específicos, la combinación de:
|
|
97
|
+
1. **Sync API** (para históricos/filtros)
|
|
98
|
+
2. **Async API** (para tiempo real)
|
|
99
|
+
|
|
100
|
+
Proporciona una solución completa y robusta.
|
|
101
|
+
|
|
102
|
+
## 🚀 EJEMPLO COMPLETO
|
|
103
|
+
|
|
104
|
+
Ejecuta: `node test/simple_async.js` para ver el ejemplo funcionando.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# API Coherente entre Modo Síncrono y Asíncrono
|
|
2
|
+
|
|
3
|
+
## Problema Resuelto
|
|
4
|
+
|
|
5
|
+
**ANTES**: Las APIs síncronas y asíncronas tenían diferentes parámetros para especificar modos de lectura:
|
|
6
|
+
- **Síncronos**: `readEvents(channel, mode, watermark, maxEvents, eventIds)`
|
|
7
|
+
- **Asíncronos**: `subscribe(channel, watermark, onEvent, onError, eventIds)`
|
|
8
|
+
|
|
9
|
+
**DESPUÉS**: Ambas APIs ahora soportan los mismo modos de lectura de forma coherente.
|
|
10
|
+
|
|
11
|
+
## Nuevas APIs Coherentes
|
|
12
|
+
|
|
13
|
+
### 1. Métodos Helper Específicos
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// Equivalente a readEvents(channel, START_MODE.BEGINNING, ...)
|
|
17
|
+
eventLog.subscribeFromBeginning(channel, onEvent, onError, eventIds);
|
|
18
|
+
|
|
19
|
+
// Equivalente a readEvents(channel, START_MODE.END, ...)
|
|
20
|
+
eventLog.subscribeFromEnd(channel, onEvent, onError, eventIds);
|
|
21
|
+
|
|
22
|
+
// Equivalente a readEvents(channel, START_MODE.WATERMARK, watermark, ...)
|
|
23
|
+
eventLog.subscribeFromWatermark(channel, watermark, onEvent, onError, eventIds);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 2. subscribe() con Opciones
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
// Nuevo formato con mode explícito
|
|
30
|
+
eventLog.subscribe(channel, {
|
|
31
|
+
mode: eventLog.START_MODE.BEGINNING, // o END, WATERMARK
|
|
32
|
+
watermark: 12345, // Para mode=WATERMARK
|
|
33
|
+
eventIds: [1000, 1001] // Filtros opcionales
|
|
34
|
+
}, onEvent, onError);
|
|
35
|
+
|
|
36
|
+
// Formato anterior sigue funcionando (compatibilidad)
|
|
37
|
+
eventLog.subscribe(channel, watermark, onEvent, onError, eventIds);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. EventEmitter con Mode
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
const emitter = eventLog.createEventEmitter('System', {
|
|
44
|
+
mode: eventLog.START_MODE.BEGINNING, // Procesar todos los eventos
|
|
45
|
+
eventIds: [1074, 6005, 6006]
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
emitter.on('event', (event) => {
|
|
49
|
+
console.log(`Event: ${event.recordId}`);
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Equivalencias Exactas
|
|
54
|
+
|
|
55
|
+
| Modo Síncrono | API Síncrona | API Asíncrona Equivalente |
|
|
56
|
+
|---------------|--------------|---------------------------|
|
|
57
|
+
| `BEGINNING` (0) | `readEvents(ch, 0, 0, max, ids)` | `subscribeFromBeginning(ch, onEvent, onError, ids)` |
|
|
58
|
+
| `END` (1) | `readEvents(ch, 1, 0, max, ids)` | `subscribeFromEnd(ch, onEvent, onError, ids)` |
|
|
59
|
+
| `WATERMARK` (2) | `readEvents(ch, 2, wm, max, ids)` | `subscribeFromWatermark(ch, wm, onEvent, onError, ids)` |
|
|
60
|
+
|
|
61
|
+
## Comportamientos Específicos
|
|
62
|
+
|
|
63
|
+
### BEGINNING Mode
|
|
64
|
+
- **Síncrono**: Lee los primeros N eventos disponibles
|
|
65
|
+
- **Asíncrono**: Se suscribe desde el primer evento disponible y procesa todo el historial
|
|
66
|
+
|
|
67
|
+
### END Mode
|
|
68
|
+
- **Síncrono**: Lee los últimos N eventos disponibles
|
|
69
|
+
- **Asíncrono**: Se suscribe solo a eventos futuros (comportamiento estándar)
|
|
70
|
+
|
|
71
|
+
### WATERMARK Mode
|
|
72
|
+
- **Síncrono**: Lee N eventos desde el Record ID especificado
|
|
73
|
+
- **Asíncrono**: Se suscribe desde el Record ID especificado en adelante
|
|
74
|
+
|
|
75
|
+
## Ejemplos Completos
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
const eventLog = require('nwinread');
|
|
79
|
+
|
|
80
|
+
// === LECTURA SÍNCRONA ===
|
|
81
|
+
|
|
82
|
+
// Obtener primeros 10 eventos del sistema
|
|
83
|
+
const beginning = eventLog.readEvents("System", eventLog.START_MODE.BEGINNING, 0, 10);
|
|
84
|
+
|
|
85
|
+
// Obtener últimos 5 eventos de seguridad
|
|
86
|
+
const latest = eventLog.readEvents("Security", eventLog.START_MODE.END, 0, 5);
|
|
87
|
+
|
|
88
|
+
// Obtener 3 eventos desde Record ID 50000
|
|
89
|
+
const fromPoint = eventLog.readEvents("Application", eventLog.START_MODE.WATERMARK, 50000, 3);
|
|
90
|
+
|
|
91
|
+
// === SUSCRIPCIÓN ASÍNCRONA COHERENTE ===
|
|
92
|
+
|
|
93
|
+
// Procesar todos los eventos históricos y futuros del sistema
|
|
94
|
+
const allEvents = eventLog.subscribeFromBeginning("System",
|
|
95
|
+
(event) => console.log(`Historical: ${event.recordId}`),
|
|
96
|
+
(error) => console.error(error.message)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// Monitorear solo nuevos eventos de seguridad
|
|
100
|
+
const newEvents = eventLog.subscribeFromEnd("Security",
|
|
101
|
+
(event) => console.log(`New security event: ${event.recordId}`),
|
|
102
|
+
(error) => console.error(error.message)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// Procesar desde un punto específico con filtros
|
|
106
|
+
const filtered = eventLog.subscribeFromWatermark("Application", 100000,
|
|
107
|
+
(event) => console.log(`App event: ${event.recordId}`),
|
|
108
|
+
(error) => console.error(error.message),
|
|
109
|
+
[1000, 1001, 1002] // Solo Event IDs específicos
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// === EVENTÉMITTER CON MODOS ===
|
|
113
|
+
|
|
114
|
+
// Emitter para todos los eventos de aplicación
|
|
115
|
+
const appEmitter = eventLog.createEventEmitter('Application', {
|
|
116
|
+
mode: eventLog.START_MODE.BEGINNING
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
appEmitter.on('event', (event) => {
|
|
120
|
+
console.log(`App event: ${event.recordId}`);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Limpiar suscripciones
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
allEvents.unsubscribe();
|
|
126
|
+
newEvents.unsubscribe();
|
|
127
|
+
filtered.unsubscribe();
|
|
128
|
+
appEmitter.unsubscribe();
|
|
129
|
+
}, 30000);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Compatibilidad
|
|
133
|
+
|
|
134
|
+
✅ **100% Compatible hacia atrás**: El formato anterior sigue funcionando
|
|
135
|
+
✅ **Nuevas funcionalidades**: Modos coherentes entre sync/async
|
|
136
|
+
✅ **Sin breaking changes**: Código existente no requiere modificaciones
|
|
137
|
+
✅ **Migración gradual**: Puedes adoptar las nuevas APIs gradualmente
|
|
138
|
+
|
|
139
|
+
## Testing
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm run test:coherence # Demo de coherencia entre APIs
|
|
143
|
+
npm test # Suite completa de tests
|
|
144
|
+
npm run test:quick # Test rápido de funcionalidades básicas
|
|
145
|
+
npm run test:async # Test completo de APIs asíncronas
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Beneficios
|
|
149
|
+
|
|
150
|
+
1. **Coherencia Conceptual**: Los mismos modos funcionan igual en sync y async
|
|
151
|
+
2. **Potencia Completa**: Acceso a todo el historial del Event Log de forma asíncrona
|
|
152
|
+
3. **APIs Intuitivas**: Métodos con nombres descriptivos (`subscribeFromBeginning`)
|
|
153
|
+
4. **Flexibilidad**: Puedes elegir el nivel de abstracción que prefieras
|
|
154
|
+
5. **Compatibilidad Garantizada**: Tus scripts existentes siguen funcionando
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Contributing to nwinread
|
|
2
|
+
|
|
3
|
+
¡Gracias por tu interés en contribuir a **nwinread**!
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start for Contributors
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Fork & Clone
|
|
9
|
+
git clone https://github.com/your-username/nwinread.git
|
|
10
|
+
cd nwinread
|
|
11
|
+
|
|
12
|
+
# 2. Setup Development Environment
|
|
13
|
+
npm install
|
|
14
|
+
npm run build
|
|
15
|
+
npm test
|
|
16
|
+
|
|
17
|
+
# 3. Verify Setup
|
|
18
|
+
npm run verify
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 📋 Development Workflow
|
|
22
|
+
|
|
23
|
+
1. **Make your changes** to the C++ code in `native/` or JavaScript in `index.js`
|
|
24
|
+
2. **Test locally**: `npm run build && npm test`
|
|
25
|
+
3. **Generate prebuilds**: `npm run prebuildify` (optional)
|
|
26
|
+
4. **Submit PR** with clear description
|
|
27
|
+
|
|
28
|
+
## 🔧 Available Scripts
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run build # Compile native module locally
|
|
32
|
+
npm run prebuildify # Generate precompiled binary for current platform
|
|
33
|
+
npm run clean # Clean build artifacts
|
|
34
|
+
npm test # Run functionality tests
|
|
35
|
+
npm run verify # Comprehensive setup verification
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 📚 Documentation
|
|
39
|
+
|
|
40
|
+
For detailed information about:
|
|
41
|
+
- **N-API setup and configuration** → See [NAPI-SETUP.md](NAPI-SETUP.md)
|
|
42
|
+
- **Release process and CI/CD** → See [NAPI-SETUP.md](NAPI-SETUP.md)
|
|
43
|
+
- **Supported Node.js versions** → See [README.md](README.md)
|
|
44
|
+
|
|
45
|
+
## 🐛 Reporting Issues
|
|
46
|
+
|
|
47
|
+
When reporting issues, please include:
|
|
48
|
+
- Node.js version (`node --version`)
|
|
49
|
+
- Windows version
|
|
50
|
+
- Error message and stack trace
|
|
51
|
+
- Minimal reproduction code
|
|
52
|
+
|
|
53
|
+
## 💡 Feature Requests
|
|
54
|
+
|
|
55
|
+
Feel free to suggest new features via GitHub Issues. Popular requests:
|
|
56
|
+
- Support for additional event log channels
|
|
57
|
+
- Performance optimizations
|
|
58
|
+
- Additional filtering options
|
|
59
|
+
|
|
60
|
+
## 🙏 Questions?
|
|
61
|
+
|
|
62
|
+
- Check existing issues
|
|
63
|
+
- Read [NAPI-SETUP.md](NAPI-SETUP.md) for technical details
|
|
64
|
+
- Open a discussion for general questions
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Corrección de Excepciones N-API
|
|
2
|
+
|
|
3
|
+
## Problema Original
|
|
4
|
+
```
|
|
5
|
+
(node:26176) [DEP0168] DeprecationWarning: Uncaught N-API callback exception detected,
|
|
6
|
+
please run node with option --force-node-api-uncaught-exceptions-policy=true to handle those exceptions properly.
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Causa del Problema
|
|
10
|
+
Las funciones `CallJS` y `CallJSError` en `eventlogasync.cc` no manejaban adecuadamente las excepciones que podían ocurrir durante:
|
|
11
|
+
1. Llamadas a `napi_call_function`
|
|
12
|
+
2. Callbacks de JavaScript que generaban excepciones
|
|
13
|
+
3. Falta de validación de parámetros de entrada
|
|
14
|
+
|
|
15
|
+
## Soluciones Implementadas
|
|
16
|
+
|
|
17
|
+
### 1. Manejo Robusto de Excepciones en CallJS
|
|
18
|
+
```cpp
|
|
19
|
+
// ANTES (PROBLEMÁTICO)
|
|
20
|
+
if (js_callback != nullptr) {
|
|
21
|
+
napi_value global, result;
|
|
22
|
+
napi_get_global(env, &global);
|
|
23
|
+
napi_call_function(env, global, js_callback, 1, &event_obj, &result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// DESPUÉS (CORREGIDO)
|
|
27
|
+
napi_value global, result;
|
|
28
|
+
status = napi_get_global(env, &global);
|
|
29
|
+
if (status == napi_ok) {
|
|
30
|
+
status = napi_call_function(env, global, js_callback, 1, &event_obj, &result);
|
|
31
|
+
if (status != napi_ok) {
|
|
32
|
+
// Limpiar cualquier excepción pendiente
|
|
33
|
+
bool pending;
|
|
34
|
+
if (napi_is_exception_pending(env, &pending) == napi_ok && pending) {
|
|
35
|
+
napi_value exception;
|
|
36
|
+
napi_get_and_clear_last_exception(env, &exception);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### 2. Validación Mejorada de Parámetros
|
|
43
|
+
```cpp
|
|
44
|
+
// ANTES
|
|
45
|
+
if (data == nullptr) return;
|
|
46
|
+
|
|
47
|
+
// DESPUÉS
|
|
48
|
+
if (data == nullptr || js_callback == nullptr) return;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. Verificación de Estados N-API
|
|
52
|
+
- Verificar todos los retornos de `napi_status`
|
|
53
|
+
- Limpiar excepciones pendientes automáticamente
|
|
54
|
+
- Evitar llamadas a funciones JavaScript cuando el entorno no es válido
|
|
55
|
+
|
|
56
|
+
## Archivos Modificados
|
|
57
|
+
- `native/eventlogasync.cc`: Funciones CallJS y CallJSError
|
|
58
|
+
- `test/test_async.js`: Test corregido con variables declaradas y timeout apropiado
|
|
59
|
+
|
|
60
|
+
## Resultado
|
|
61
|
+
✅ **Sin más excepciones N-API**
|
|
62
|
+
✅ **Callbacks JavaScript funcionando correctamente**
|
|
63
|
+
✅ **Manejo robusto de errores en callbacks**
|
|
64
|
+
✅ **APIs asíncronas estables y confiables**
|
|
65
|
+
|
|
66
|
+
## Tests de Verificación
|
|
67
|
+
- `test_async.js`: Test básico sin excepciones
|
|
68
|
+
- `test_async_mejorado.js`: Test completo con generación de eventos
|
|
69
|
+
- `prueba_offset_simple.js`: Test de offsets funcionando correctamente
|
|
70
|
+
|
|
71
|
+
## Compatibilidad
|
|
72
|
+
- Windows Vista o superior
|
|
73
|
+
- Node.js 18+
|
|
74
|
+
- N-API versión 8+
|