libwz 0.1.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/LICENSE +21 -0
- package/README.md +165 -0
- package/binding.gyp +149 -0
- package/deps/tiny-aes/.github/workflows/c-cpp.yml +27 -0
- package/deps/tiny-aes/CMakeLists.txt +17 -0
- package/deps/tiny-aes/Makefile +61 -0
- package/deps/tiny-aes/README.md +83 -0
- package/deps/tiny-aes/aes.c +572 -0
- package/deps/tiny-aes/aes.h +91 -0
- package/deps/tiny-aes/aes.hpp +12 -0
- package/deps/tiny-aes/conanfile.py +73 -0
- package/deps/tiny-aes/library.json +19 -0
- package/deps/tiny-aes/library.properties +11 -0
- package/deps/tiny-aes/test.c +316 -0
- package/deps/tiny-aes/test.cpp +2 -0
- package/deps/tiny-aes/test_package/CMakeLists.txt +11 -0
- package/deps/tiny-aes/test_package/conanfile.py +17 -0
- package/deps/tiny-aes/unlicense.txt +24 -0
- package/deps/zlib/.cmake-format.yaml +245 -0
- package/deps/zlib/.github/workflows/c-std.yml +268 -0
- package/deps/zlib/.github/workflows/cmake.yml +147 -0
- package/deps/zlib/.github/workflows/configure.yml +146 -0
- package/deps/zlib/.github/workflows/contribs.yml +64 -0
- package/deps/zlib/.github/workflows/fuzz.yml +25 -0
- package/deps/zlib/.github/workflows/msys-cygwin.yml +92 -0
- package/deps/zlib/.github/workflows/others.yml +153 -0
- package/deps/zlib/BUILD.bazel +134 -0
- package/deps/zlib/CMakeLists.txt +310 -0
- package/deps/zlib/ChangeLog +1669 -0
- package/deps/zlib/FAQ +371 -0
- package/deps/zlib/INDEX +67 -0
- package/deps/zlib/LICENSE +22 -0
- package/deps/zlib/MODULE.bazel +9 -0
- package/deps/zlib/Makefile.in +426 -0
- package/deps/zlib/README +115 -0
- package/deps/zlib/README-cmake.md +79 -0
- package/deps/zlib/adler32.c +164 -0
- package/deps/zlib/amiga/Makefile.pup +69 -0
- package/deps/zlib/amiga/Makefile.sas +68 -0
- package/deps/zlib/compress.c +99 -0
- package/deps/zlib/configure +1078 -0
- package/deps/zlib/contrib/CMakeLists.txt +61 -0
- package/deps/zlib/contrib/README.contrib +57 -0
- package/deps/zlib/contrib/ada/CMakeLists.txt +217 -0
- package/deps/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADACompiler.cmake.in +23 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADAInformation.cmake +133 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeDetermineADACompiler.cmake +33 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeTestADACompiler.cmake +46 -0
- package/deps/zlib/contrib/ada/cmake/binder_helper.cmake +47 -0
- package/deps/zlib/contrib/ada/cmake/compile_helper.cmake +32 -0
- package/deps/zlib/contrib/ada/cmake/exe_link_helper.cmake +53 -0
- package/deps/zlib/contrib/ada/cmake/shared_link_helper.cmake +52 -0
- package/deps/zlib/contrib/ada/cmake/static_link_helper.cmake +25 -0
- package/deps/zlib/contrib/ada/mtest.adb +156 -0
- package/deps/zlib/contrib/ada/read.adb +156 -0
- package/deps/zlib/contrib/ada/readme.txt +65 -0
- package/deps/zlib/contrib/ada/test.adb +463 -0
- package/deps/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/deps/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/deps/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/deps/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/deps/zlib/contrib/ada/zlib.adb +701 -0
- package/deps/zlib/contrib/ada/zlib.ads +328 -0
- package/deps/zlib/contrib/ada/zlib.gpr +20 -0
- package/deps/zlib/contrib/blast/CMakeLists.txt +166 -0
- package/deps/zlib/contrib/blast/Makefile +14 -0
- package/deps/zlib/contrib/blast/README +4 -0
- package/deps/zlib/contrib/blast/blast-test.c +42 -0
- package/deps/zlib/contrib/blast/blast.c +422 -0
- package/deps/zlib/contrib/blast/blast.h +84 -0
- package/deps/zlib/contrib/blast/blastConfig.cmake.in +18 -0
- package/deps/zlib/contrib/blast/test/CMakeLists.txt +193 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/blast/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test.pk +0 -0
- package/deps/zlib/contrib/blast/test.txt +1 -0
- package/deps/zlib/contrib/blast/tester.cmake +28 -0
- package/deps/zlib/contrib/crc32vx/CMakeLists.txt +67 -0
- package/deps/zlib/contrib/crc32vx/README +9 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx.c +254 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx_hooks.h +9 -0
- package/deps/zlib/contrib/delphi/ZLib.pas +557 -0
- package/deps/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/deps/zlib/contrib/delphi/readme.txt +76 -0
- package/deps/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/deps/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/deps/zlib/contrib/dotzlib/readme.txt +58 -0
- package/deps/zlib/contrib/gcc_gvmat64/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/gcc_gvmat64/gvmat64.S +570 -0
- package/deps/zlib/contrib/infback9/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/infback9/README +1 -0
- package/deps/zlib/contrib/infback9/infback9.c +603 -0
- package/deps/zlib/contrib/infback9/infback9.h +37 -0
- package/deps/zlib/contrib/infback9/inffix9.h +107 -0
- package/deps/zlib/contrib/infback9/inflate9.h +47 -0
- package/deps/zlib/contrib/infback9/inftree9.c +319 -0
- package/deps/zlib/contrib/infback9/inftree9.h +61 -0
- package/deps/zlib/contrib/iostream/test.cpp +24 -0
- package/deps/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/deps/zlib/contrib/iostream/zfstream.h +128 -0
- package/deps/zlib/contrib/iostream2/zstream.h +306 -0
- package/deps/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/deps/zlib/contrib/iostream3/CMakeLists.txt +200 -0
- package/deps/zlib/contrib/iostream3/README +35 -0
- package/deps/zlib/contrib/iostream3/TODO +17 -0
- package/deps/zlib/contrib/iostream3/iostream3Config.cmake.in +23 -0
- package/deps/zlib/contrib/iostream3/test/CMakeLists.txt +191 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test.cc +50 -0
- package/deps/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/deps/zlib/contrib/iostream3/zfstream.h +466 -0
- package/deps/zlib/contrib/minizip/CMakeLists.txt +387 -0
- package/deps/zlib/contrib/minizip/LICENSE.Info-Zip +58 -0
- package/deps/zlib/contrib/minizip/Makefile +33 -0
- package/deps/zlib/contrib/minizip/Makefile.am +45 -0
- package/deps/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/deps/zlib/contrib/minizip/MiniZip64_info.txt +69 -0
- package/deps/zlib/contrib/minizip/configure.ac +32 -0
- package/deps/zlib/contrib/minizip/crypt.h +125 -0
- package/deps/zlib/contrib/minizip/ints.h +57 -0
- package/deps/zlib/contrib/minizip/ioapi.c +231 -0
- package/deps/zlib/contrib/minizip/ioapi.h +183 -0
- package/deps/zlib/contrib/minizip/iowin32.c +447 -0
- package/deps/zlib/contrib/minizip/iowin32.h +27 -0
- package/deps/zlib/contrib/minizip/make_vms.com +25 -0
- package/deps/zlib/contrib/minizip/miniunz.c +647 -0
- package/deps/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/deps/zlib/contrib/minizip/minizip.1 +46 -0
- package/deps/zlib/contrib/minizip/minizip.c +511 -0
- package/deps/zlib/contrib/minizip/minizip.pc.in +13 -0
- package/deps/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/deps/zlib/contrib/minizip/minizipConfig.cmake.in +27 -0
- package/deps/zlib/contrib/minizip/mztools.c +294 -0
- package/deps/zlib/contrib/minizip/mztools.h +37 -0
- package/deps/zlib/contrib/minizip/skipset.h +366 -0
- package/deps/zlib/contrib/minizip/test/CMakeLists.txt +176 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/deps/zlib/contrib/minizip/unzip.c +1984 -0
- package/deps/zlib/contrib/minizip/unzip.h +442 -0
- package/deps/zlib/contrib/minizip/zip.c +2246 -0
- package/deps/zlib/contrib/minizip/zip.h +371 -0
- package/deps/zlib/contrib/nuget/nuget.csproj +45 -0
- package/deps/zlib/contrib/nuget/nuget.sln +22 -0
- package/deps/zlib/contrib/pascal/example.pas +599 -0
- package/deps/zlib/contrib/pascal/readme.txt +76 -0
- package/deps/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/deps/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/deps/zlib/contrib/puff/CMakeLists.txt +154 -0
- package/deps/zlib/contrib/puff/Makefile +42 -0
- package/deps/zlib/contrib/puff/README +63 -0
- package/deps/zlib/contrib/puff/bin-writer.c +26 -0
- package/deps/zlib/contrib/puff/puff.c +840 -0
- package/deps/zlib/contrib/puff/puff.h +35 -0
- package/deps/zlib/contrib/puff/puffConfig.cmake.in +18 -0
- package/deps/zlib/contrib/puff/pufftest.c +168 -0
- package/deps/zlib/contrib/puff/test/CMakeLists.txt +262 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in +26 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/puff/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/tester-cov.cmake +58 -0
- package/deps/zlib/contrib/puff/test/tester.cmake +16 -0
- package/deps/zlib/contrib/puff/zeros.raw +0 -0
- package/deps/zlib/contrib/testzlib/CMakeLists.txt +44 -0
- package/deps/zlib/contrib/testzlib/testzlib.c +275 -0
- package/deps/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/deps/zlib/contrib/vstudio/readme.txt +22 -0
- package/deps/zlib/contrib/zlib1-dll/CMakeLists.txt +196 -0
- package/deps/zlib/contrib/zlib1-dll/readme.txt +21 -0
- package/deps/zlib/crc32.c +983 -0
- package/deps/zlib/crc32.h +9446 -0
- package/deps/zlib/deflate.c +2185 -0
- package/deps/zlib/deflate.h +383 -0
- package/deps/zlib/doc/algorithm.txt +209 -0
- package/deps/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/deps/zlib/doc/rfc1950.txt +619 -0
- package/deps/zlib/doc/rfc1951.txt +955 -0
- package/deps/zlib/doc/rfc1952.txt +675 -0
- package/deps/zlib/doc/txtvsbin.txt +107 -0
- package/deps/zlib/examples/README.examples +54 -0
- package/deps/zlib/examples/enough.c +597 -0
- package/deps/zlib/examples/fitblk.c +233 -0
- package/deps/zlib/examples/gun.c +702 -0
- package/deps/zlib/examples/gzappend.c +504 -0
- package/deps/zlib/examples/gzjoin.c +449 -0
- package/deps/zlib/examples/gzlog.c +1061 -0
- package/deps/zlib/examples/gzlog.h +91 -0
- package/deps/zlib/examples/gznorm.c +474 -0
- package/deps/zlib/examples/zlib_how.html +550 -0
- package/deps/zlib/examples/zpipe.c +206 -0
- package/deps/zlib/examples/zran.c +546 -0
- package/deps/zlib/examples/zran.h +53 -0
- package/deps/zlib/gzclose.c +23 -0
- package/deps/zlib/gzguts.h +216 -0
- package/deps/zlib/gzlib.c +609 -0
- package/deps/zlib/gzread.c +668 -0
- package/deps/zlib/gzwrite.c +700 -0
- package/deps/zlib/infback.c +581 -0
- package/deps/zlib/inffast.c +321 -0
- package/deps/zlib/inffast.h +11 -0
- package/deps/zlib/inffixed.h +94 -0
- package/deps/zlib/inflate.c +1413 -0
- package/deps/zlib/inflate.h +126 -0
- package/deps/zlib/inftrees.c +424 -0
- package/deps/zlib/inftrees.h +64 -0
- package/deps/zlib/make_vms.com +867 -0
- package/deps/zlib/msdos/Makefile.bor +115 -0
- package/deps/zlib/msdos/Makefile.dj2 +104 -0
- package/deps/zlib/msdos/Makefile.emx +69 -0
- package/deps/zlib/msdos/Makefile.msc +112 -0
- package/deps/zlib/msdos/Makefile.tc +100 -0
- package/deps/zlib/os400/README400 +48 -0
- package/deps/zlib/os400/bndsrc +144 -0
- package/deps/zlib/os400/make.sh +383 -0
- package/deps/zlib/os400/zlibfixed.rpgle +578 -0
- package/deps/zlib/os400/zlibfree.rpgle +634 -0
- package/deps/zlib/qnx/package.qpg +141 -0
- package/deps/zlib/test/CMakeLists.txt +318 -0
- package/deps/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/test/example.c +552 -0
- package/deps/zlib/test/find_package_no_components_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_wrong_components_test.cmake.in +27 -0
- package/deps/zlib/test/infcover.c +672 -0
- package/deps/zlib/test/minigzip.c +592 -0
- package/deps/zlib/treebuild.xml +116 -0
- package/deps/zlib/trees.c +1119 -0
- package/deps/zlib/trees.h +128 -0
- package/deps/zlib/uncompr.c +101 -0
- package/deps/zlib/watcom/watcom_f.mak +43 -0
- package/deps/zlib/watcom/watcom_l.mak +43 -0
- package/deps/zlib/win32/DLL_FAQ.txt +381 -0
- package/deps/zlib/win32/Makefile.bor +109 -0
- package/deps/zlib/win32/Makefile.gcc +177 -0
- package/deps/zlib/win32/Makefile.msc +159 -0
- package/deps/zlib/win32/README-WIN32.txt +103 -0
- package/deps/zlib/win32/VisualC.txt +3 -0
- package/deps/zlib/win32/zlib.def +104 -0
- package/deps/zlib/win32/zlib1.rc +37 -0
- package/deps/zlib/zconf.h.in +551 -0
- package/deps/zlib/zlib.3 +149 -0
- package/deps/zlib/zlib.3.pdf +0 -0
- package/deps/zlib/zlib.h +2057 -0
- package/deps/zlib/zlib.map +116 -0
- package/deps/zlib/zlib.pc.cmakein +14 -0
- package/deps/zlib/zlib.pc.in +14 -0
- package/deps/zlib/zlibConfig.cmake.in +18 -0
- package/deps/zlib/zutil.c +313 -0
- package/deps/zlib/zutil.h +331 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +1146 -0
- package/dist/libwz.js +5632 -0
- package/dist/libwz.wasm +0 -0
- package/include/wz/CRC32.h +182 -0
- package/include/wz/PngUtility.h +72 -0
- package/include/wz/PortalType.h +124 -0
- package/include/wz/Properties/WzBinaryProperty.h +70 -0
- package/include/wz/Properties/WzCanvasProperty.h +55 -0
- package/include/wz/Properties/WzConvexProperty.h +34 -0
- package/include/wz/Properties/WzDoubleProperty.h +32 -0
- package/include/wz/Properties/WzFloatProperty.h +30 -0
- package/include/wz/Properties/WzIntProperty.h +30 -0
- package/include/wz/Properties/WzLongProperty.h +30 -0
- package/include/wz/Properties/WzLuaProperty.h +31 -0
- package/include/wz/Properties/WzNullProperty.h +15 -0
- package/include/wz/Properties/WzPngProperty.h +53 -0
- package/include/wz/Properties/WzRawDataProperty.h +46 -0
- package/include/wz/Properties/WzShortProperty.h +31 -0
- package/include/wz/Properties/WzStringProperty.h +32 -0
- package/include/wz/Properties/WzSubProperty.h +35 -0
- package/include/wz/Properties/WzUOLProperty.h +44 -0
- package/include/wz/Properties/WzVectorProperty.h +40 -0
- package/include/wz/Properties/WzVideoProperty.h +43 -0
- package/include/wz/Result.h +58 -0
- package/include/wz/Util/Defines.h +16 -0
- package/include/wz/Util/ListFileParser.h +20 -0
- package/include/wz/Util/WzBinaryReader.h +95 -0
- package/include/wz/Util/WzBinaryWriter.h +72 -0
- package/include/wz/Util/WzBlobDataSource.h +30 -0
- package/include/wz/Util/WzDataSource.h +49 -0
- package/include/wz/Util/WzKeyGenerator.h +28 -0
- package/include/wz/Util/WzMutableKey.h +39 -0
- package/include/wz/Util/WzPath.h +37 -0
- package/include/wz/Util/WzStream.h +86 -0
- package/include/wz/Util/WzTool.h +42 -0
- package/include/wz/WzAESConstant.h +17 -0
- package/include/wz/WzDirectory.h +97 -0
- package/include/wz/WzEnums.h +76 -0
- package/include/wz/WzFile.h +99 -0
- package/include/wz/WzHeader.h +47 -0
- package/include/wz/WzImage.h +97 -0
- package/include/wz/WzImageProperty.h +92 -0
- package/include/wz/WzObject.h +55 -0
- package/include/wz/WzPropertyCollection.h +115 -0
- package/include/wz/wz.h +41 -0
- package/include/wz/wz_api.h +432 -0
- package/package.json +93 -0
- package/src/PngUtility.cpp +328 -0
- package/src/Properties/WzBinaryProperty.cpp +183 -0
- package/src/Properties/WzCanvasProperty.cpp +262 -0
- package/src/Properties/WzConvexProperty.cpp +159 -0
- package/src/Properties/WzDoubleProperty.cpp +12 -0
- package/src/Properties/WzFloatProperty.cpp +17 -0
- package/src/Properties/WzIntProperty.cpp +12 -0
- package/src/Properties/WzLongProperty.cpp +12 -0
- package/src/Properties/WzLuaProperty.cpp +37 -0
- package/src/Properties/WzNullProperty.cpp +11 -0
- package/src/Properties/WzPngProperty.cpp +637 -0
- package/src/Properties/WzRawDataProperty.cpp +116 -0
- package/src/Properties/WzShortProperty.cpp +12 -0
- package/src/Properties/WzStringProperty.cpp +44 -0
- package/src/Properties/WzSubProperty.cpp +129 -0
- package/src/Properties/WzUOLProperty.cpp +136 -0
- package/src/Properties/WzVectorProperty.cpp +22 -0
- package/src/Properties/WzVideoProperty.cpp +115 -0
- package/src/Util/ListFileParser.cpp +48 -0
- package/src/Util/WzBinaryReader.cpp +368 -0
- package/src/Util/WzBinaryWriter.cpp +305 -0
- package/src/Util/WzBlobDataSource.cpp +47 -0
- package/src/Util/WzDataSource.cpp +61 -0
- package/src/Util/WzKeyGenerator.cpp +43 -0
- package/src/Util/WzMutableKey.cpp +59 -0
- package/src/Util/WzStream.cpp +196 -0
- package/src/Util/WzTool.cpp +266 -0
- package/src/WzAESConstant.cpp +12 -0
- package/src/WzDirectory.cpp +669 -0
- package/src/WzEnums.cpp +20 -0
- package/src/WzFile.cpp +450 -0
- package/src/WzImage.cpp +350 -0
- package/src/WzImageProperty.cpp +469 -0
- package/src/WzObject.cpp +174 -0
- package/src/WzPropertyCollection.cpp +84 -0
- package/src/capi/wz_api.cpp +1996 -0
- package/src/node/binding.cpp +1776 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1146 @@
|
|
|
1
|
+
let currentNative;
|
|
2
|
+
let currentCapabilities;
|
|
3
|
+
let currentType;
|
|
4
|
+
function setWzBinding(native, capabilities, type) {
|
|
5
|
+
currentNative = native;
|
|
6
|
+
currentCapabilities = capabilities;
|
|
7
|
+
currentType = type;
|
|
8
|
+
}
|
|
9
|
+
function getWzBinding() {
|
|
10
|
+
if (currentNative === undefined) {
|
|
11
|
+
throw new Error('libwz binding is not initialized');
|
|
12
|
+
}
|
|
13
|
+
return currentNative;
|
|
14
|
+
}
|
|
15
|
+
function getWzCapabilities() {
|
|
16
|
+
if (currentCapabilities === undefined) {
|
|
17
|
+
throw new Error('libwz binding is not initialized');
|
|
18
|
+
}
|
|
19
|
+
return currentCapabilities;
|
|
20
|
+
}
|
|
21
|
+
function getWzBindingType() {
|
|
22
|
+
if (currentType === undefined) {
|
|
23
|
+
throw new Error('libwz binding is not initialized');
|
|
24
|
+
}
|
|
25
|
+
return currentType;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function installNativeBinding() {
|
|
29
|
+
try {
|
|
30
|
+
const native = loadNative();
|
|
31
|
+
if (native === null)
|
|
32
|
+
return false;
|
|
33
|
+
setWzBinding(native, {
|
|
34
|
+
blobInput: false,
|
|
35
|
+
pathInput: true,
|
|
36
|
+
saveToDisk: true
|
|
37
|
+
}, 'native');
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function loadNative() {
|
|
45
|
+
const moduleBuiltin = getBuiltinModule('module');
|
|
46
|
+
const path = getBuiltinModule('path');
|
|
47
|
+
const url = getBuiltinModule('url');
|
|
48
|
+
if (moduleBuiltin === null || path === null || url === null)
|
|
49
|
+
return null;
|
|
50
|
+
const nodeRequire = moduleBuiltin.createRequire(import.meta.url);
|
|
51
|
+
const moduleDir = import.meta.dirname
|
|
52
|
+
?? path.dirname(url.fileURLToPath(import.meta.url));
|
|
53
|
+
for (const candidate of nativeCandidates(path, moduleDir)) {
|
|
54
|
+
try {
|
|
55
|
+
return nodeRequire(candidate);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
const { code } = err;
|
|
59
|
+
if (code !== 'MODULE_NOT_FOUND')
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
throw new Error('libwz native addon is not built. Run `npm run build`.');
|
|
64
|
+
}
|
|
65
|
+
function nativeCandidates(path, moduleDir) {
|
|
66
|
+
return [
|
|
67
|
+
path.join(moduleDir, '..', 'build', 'Release', 'wz.node'),
|
|
68
|
+
path.join(moduleDir, '..', 'build', 'Release', 'libwz.node'),
|
|
69
|
+
path.join(moduleDir, '..', 'build', 'Debug', 'wz.node'),
|
|
70
|
+
path.join(moduleDir, '..', 'build', 'Debug', 'libwz.node')
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
function getBuiltinModule(id) {
|
|
74
|
+
if (typeof process !== 'object' || process === null)
|
|
75
|
+
return null;
|
|
76
|
+
if (typeof process.getBuiltinModule !== 'function')
|
|
77
|
+
return null;
|
|
78
|
+
try {
|
|
79
|
+
return process.getBuiltinModule(id);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function configureWasmBinding(loaded, _options) {
|
|
87
|
+
const isNode = isNodeRuntime();
|
|
88
|
+
const pathMapper = isNode ? createNodePathMapper(loaded.module) : undefined;
|
|
89
|
+
const binding = isNode ? normalizeNodePathBinding(loaded.binding, pathMapper) : loaded.binding;
|
|
90
|
+
setWzBinding(binding, {
|
|
91
|
+
blobInput: true,
|
|
92
|
+
pathInput: isNode,
|
|
93
|
+
saveToDisk: isNode
|
|
94
|
+
}, 'wasm');
|
|
95
|
+
}
|
|
96
|
+
const nodeMountedRoots = new WeakMap();
|
|
97
|
+
function normalizeNodePathBinding(binding, pathMapper) {
|
|
98
|
+
return Object.defineProperties(Object.create(binding), {
|
|
99
|
+
openFile: {
|
|
100
|
+
value(path, gameVersionOrIv, mapleVersion) {
|
|
101
|
+
const wasmPath = toWasmNodePath(path, pathMapper);
|
|
102
|
+
if (gameVersionOrIv instanceof Uint8Array)
|
|
103
|
+
return binding.openFile(wasmPath, gameVersionOrIv);
|
|
104
|
+
if (mapleVersion === undefined)
|
|
105
|
+
throw new TypeError('mapleVersion is required');
|
|
106
|
+
return binding.openFile(wasmPath, gameVersionOrIv, mapleVersion);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
fileSaveToDisk: {
|
|
110
|
+
value(ptr, path) {
|
|
111
|
+
binding.fileSaveToDisk(ptr, toWasmNodePath(path, pathMapper));
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
canvasSaveToFile: {
|
|
115
|
+
value(ptr, path) {
|
|
116
|
+
return binding.canvasSaveToFile(ptr, toWasmNodePath(path, pathMapper));
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
pngSaveToFile: {
|
|
120
|
+
value(ptr, path) {
|
|
121
|
+
return binding.pngSaveToFile(ptr, toWasmNodePath(path, pathMapper));
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
binarySaveToFile: {
|
|
125
|
+
value(ptr, path) {
|
|
126
|
+
return binding.binarySaveToFile(ptr, toWasmNodePath(path, pathMapper));
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
detectMapleVersion: {
|
|
130
|
+
value(path) {
|
|
131
|
+
return binding.detectMapleVersion(toWasmNodePath(path, pathMapper));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function toWasmNodePath(path, pathMapper) {
|
|
137
|
+
return pathMapper?.toWasmPath(path) ?? normalizePath(path);
|
|
138
|
+
}
|
|
139
|
+
function normalizePath(path) {
|
|
140
|
+
const normalizedPath = path.replaceAll('\\', '/');
|
|
141
|
+
if (normalizedPath.length > 1 && normalizedPath.endsWith('/')) {
|
|
142
|
+
return normalizedPath.replace(/\/+$/u, '');
|
|
143
|
+
}
|
|
144
|
+
return normalizedPath;
|
|
145
|
+
}
|
|
146
|
+
function createNodePathMapper(module) {
|
|
147
|
+
if (module.FS === undefined || module.NODEFS === undefined) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
const nodePath = getNodePathModule();
|
|
151
|
+
if (nodePath === undefined)
|
|
152
|
+
return undefined;
|
|
153
|
+
let mountedRoots = nodeMountedRoots.get(module);
|
|
154
|
+
if (mountedRoots === undefined) {
|
|
155
|
+
mountedRoots = new Map();
|
|
156
|
+
nodeMountedRoots.set(module, mountedRoots);
|
|
157
|
+
}
|
|
158
|
+
const mountRoot = '/mnt';
|
|
159
|
+
return {
|
|
160
|
+
toWasmPath(path) {
|
|
161
|
+
const hostPath = normalizePath(nodePath.resolve(path));
|
|
162
|
+
const hostRoot = normalizePath(nodePath.parse(hostPath).root);
|
|
163
|
+
let wasmRoot = mountedRoots.get(hostRoot);
|
|
164
|
+
if (wasmRoot === undefined) {
|
|
165
|
+
wasmRoot = hostRoot === '/'
|
|
166
|
+
? mountRoot
|
|
167
|
+
: `${mountRoot}/${hostRoot.replaceAll(':', '').replace(/^\/+|\/+$/gu, '')}`;
|
|
168
|
+
module.FS?.mkdirTree(wasmRoot);
|
|
169
|
+
module.FS?.mount(module.NODEFS, { root: hostRoot }, wasmRoot);
|
|
170
|
+
mountedRoots.set(hostRoot, wasmRoot);
|
|
171
|
+
}
|
|
172
|
+
if (hostPath === hostRoot)
|
|
173
|
+
return wasmRoot;
|
|
174
|
+
const suffix = hostPath.slice(hostRoot.length).replace(/^\/+/u, '');
|
|
175
|
+
return suffix.length === 0 ? wasmRoot : `${wasmRoot}/${suffix}`;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function isNodeRuntime() {
|
|
180
|
+
const maybeProcess = globalThis.process;
|
|
181
|
+
return typeof maybeProcess?.versions?.node === 'string';
|
|
182
|
+
}
|
|
183
|
+
function getNodePathModule() {
|
|
184
|
+
const maybeProcess = globalThis.process;
|
|
185
|
+
if (typeof maybeProcess?.getBuiltinModule === 'function') {
|
|
186
|
+
return maybeProcess.getBuiltinModule('path');
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const asyncCache = new Map();
|
|
192
|
+
async function initializeWasm(wasmUrl) {
|
|
193
|
+
const resolvedWasmUrl = wasmUrl.toString();
|
|
194
|
+
const cached = asyncCache.get(resolvedWasmUrl);
|
|
195
|
+
if (cached !== undefined)
|
|
196
|
+
return await cached;
|
|
197
|
+
const loaded = loadWasmDependencies().then(async ({ createLibwzModule, getDefaultContext }) => {
|
|
198
|
+
const module = await createLibwzModule({
|
|
199
|
+
locateFile(path, prefix) {
|
|
200
|
+
if (path.endsWith('.wasm')) {
|
|
201
|
+
return resolvedWasmUrl;
|
|
202
|
+
}
|
|
203
|
+
return `${prefix}${path}`;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
binding: module.emnapiInit({
|
|
208
|
+
context: getDefaultContext(),
|
|
209
|
+
filename: 'libwz.wasm'
|
|
210
|
+
}),
|
|
211
|
+
module
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
asyncCache.set(resolvedWasmUrl, loaded);
|
|
215
|
+
return await loaded;
|
|
216
|
+
}
|
|
217
|
+
async function loadWzModule() {
|
|
218
|
+
return await initializeWasm(defaultWasmUrl());
|
|
219
|
+
}
|
|
220
|
+
function defaultWasmUrl() {
|
|
221
|
+
return new URL('./libwz.wasm', import.meta.url);
|
|
222
|
+
}
|
|
223
|
+
async function loadWasmDependencies() {
|
|
224
|
+
const [runtime, generated] = await Promise.all([
|
|
225
|
+
import('@emnapi/runtime'),
|
|
226
|
+
importGeneratedLibwzModule()
|
|
227
|
+
]);
|
|
228
|
+
return {
|
|
229
|
+
createLibwzModule: generated,
|
|
230
|
+
getDefaultContext: () => runtime.getDefaultContext()
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
async function importGeneratedLibwzModule() {
|
|
234
|
+
// @ts-expect-error Emscripten generates this module during build:wasm.
|
|
235
|
+
const generated = await import('./libwz.js');
|
|
236
|
+
return generated.default;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var MapleVersion;
|
|
240
|
+
(function (MapleVersion) {
|
|
241
|
+
MapleVersion[MapleVersion["GMS"] = 0] = "GMS";
|
|
242
|
+
MapleVersion[MapleVersion["EMS"] = 1] = "EMS";
|
|
243
|
+
MapleVersion[MapleVersion["BMS"] = 2] = "BMS";
|
|
244
|
+
MapleVersion[MapleVersion["CLASSIC"] = 3] = "CLASSIC";
|
|
245
|
+
MapleVersion[MapleVersion["GENERATE"] = 4] = "GENERATE";
|
|
246
|
+
MapleVersion[MapleVersion["GETFROMZLZ"] = 5] = "GETFROMZLZ";
|
|
247
|
+
MapleVersion[MapleVersion["CUSTOM"] = 6] = "CUSTOM";
|
|
248
|
+
MapleVersion[MapleVersion["UNKNOWN"] = 99] = "UNKNOWN";
|
|
249
|
+
})(MapleVersion || (MapleVersion = {}));
|
|
250
|
+
var ParseStatus;
|
|
251
|
+
(function (ParseStatus) {
|
|
252
|
+
ParseStatus[ParseStatus["PATH_IS_NULL"] = -1] = "PATH_IS_NULL";
|
|
253
|
+
ParseStatus[ParseStatus["ERROR_GAME_VER_HASH"] = -2] = "ERROR_GAME_VER_HASH";
|
|
254
|
+
ParseStatus[ParseStatus["FAILED_UNKNOWN"] = 0] = "FAILED_UNKNOWN";
|
|
255
|
+
ParseStatus[ParseStatus["SUCCESS"] = 1] = "SUCCESS";
|
|
256
|
+
})(ParseStatus || (ParseStatus = {}));
|
|
257
|
+
var PropertyType;
|
|
258
|
+
(function (PropertyType) {
|
|
259
|
+
PropertyType[PropertyType["NULL"] = 0] = "NULL";
|
|
260
|
+
PropertyType[PropertyType["SHORT"] = 1] = "SHORT";
|
|
261
|
+
PropertyType[PropertyType["INT"] = 2] = "INT";
|
|
262
|
+
PropertyType[PropertyType["LONG"] = 3] = "LONG";
|
|
263
|
+
PropertyType[PropertyType["FLOAT"] = 4] = "FLOAT";
|
|
264
|
+
PropertyType[PropertyType["DOUBLE"] = 5] = "DOUBLE";
|
|
265
|
+
PropertyType[PropertyType["STRING"] = 6] = "STRING";
|
|
266
|
+
PropertyType[PropertyType["SUB"] = 7] = "SUB";
|
|
267
|
+
PropertyType[PropertyType["CANVAS"] = 8] = "CANVAS";
|
|
268
|
+
PropertyType[PropertyType["VECTOR"] = 9] = "VECTOR";
|
|
269
|
+
PropertyType[PropertyType["CONVEX"] = 10] = "CONVEX";
|
|
270
|
+
PropertyType[PropertyType["SOUND"] = 11] = "SOUND";
|
|
271
|
+
PropertyType[PropertyType["RAW"] = 12] = "RAW";
|
|
272
|
+
PropertyType[PropertyType["UOL"] = 13] = "UOL";
|
|
273
|
+
PropertyType[PropertyType["LUA"] = 14] = "LUA";
|
|
274
|
+
PropertyType[PropertyType["PNG"] = 15] = "PNG";
|
|
275
|
+
})(PropertyType || (PropertyType = {}));
|
|
276
|
+
var ObjectType;
|
|
277
|
+
(function (ObjectType) {
|
|
278
|
+
ObjectType[ObjectType["FILE"] = 0] = "FILE";
|
|
279
|
+
ObjectType[ObjectType["IMAGE"] = 1] = "IMAGE";
|
|
280
|
+
ObjectType[ObjectType["DIRECTORY"] = 2] = "DIRECTORY";
|
|
281
|
+
ObjectType[ObjectType["PROPERTY"] = 3] = "PROPERTY";
|
|
282
|
+
ObjectType[ObjectType["LIST"] = 4] = "LIST";
|
|
283
|
+
})(ObjectType || (ObjectType = {}));
|
|
284
|
+
var BinaryType;
|
|
285
|
+
(function (BinaryType) {
|
|
286
|
+
BinaryType[BinaryType["RAW"] = 0] = "RAW";
|
|
287
|
+
BinaryType[BinaryType["MP3"] = 1] = "MP3";
|
|
288
|
+
BinaryType[BinaryType["WAV"] = 2] = "WAV";
|
|
289
|
+
})(BinaryType || (BinaryType = {}));
|
|
290
|
+
const native = new Proxy({}, {
|
|
291
|
+
get(_target, property) {
|
|
292
|
+
const binding = getWzBinding();
|
|
293
|
+
const value = binding[property];
|
|
294
|
+
return typeof value === 'function' ? value.bind(binding) : value;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
const capabilities = new Proxy({}, {
|
|
298
|
+
get(_target, property) {
|
|
299
|
+
return getWzCapabilities()[property];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
function assertHandle(ptr) {
|
|
303
|
+
if (typeof ptr !== 'bigint' || ptr === 0n) {
|
|
304
|
+
throw new TypeError('native handle must be a non-zero bigint');
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function isPresent(value) {
|
|
308
|
+
return value !== null;
|
|
309
|
+
}
|
|
310
|
+
function createWzFile(ptr, ownsNative = false) {
|
|
311
|
+
const NativeWzFile = WzFile;
|
|
312
|
+
return new NativeWzFile(ptr, ownsNative);
|
|
313
|
+
}
|
|
314
|
+
const handleRegistry = new Map();
|
|
315
|
+
function registerHandle(ptr, obj) {
|
|
316
|
+
let entries = handleRegistry.get(ptr);
|
|
317
|
+
if (entries === undefined) {
|
|
318
|
+
entries = new Set();
|
|
319
|
+
handleRegistry.set(ptr, entries);
|
|
320
|
+
}
|
|
321
|
+
entries.add(obj);
|
|
322
|
+
}
|
|
323
|
+
function unregisterHandle(ptr, obj) {
|
|
324
|
+
const entries = handleRegistry.get(ptr);
|
|
325
|
+
if (entries === undefined)
|
|
326
|
+
return;
|
|
327
|
+
entries.delete(obj);
|
|
328
|
+
if (entries.size === 0)
|
|
329
|
+
handleRegistry.delete(ptr);
|
|
330
|
+
}
|
|
331
|
+
function markHandleBorrowed(ptr) {
|
|
332
|
+
const entries = handleRegistry.get(ptr);
|
|
333
|
+
if (entries === undefined)
|
|
334
|
+
return;
|
|
335
|
+
for (const entry of entries)
|
|
336
|
+
entry._markBorrowedInstance();
|
|
337
|
+
}
|
|
338
|
+
function markHandleOwned(ptr) {
|
|
339
|
+
const entries = handleRegistry.get(ptr);
|
|
340
|
+
if (entries === undefined)
|
|
341
|
+
return;
|
|
342
|
+
for (const entry of entries)
|
|
343
|
+
entry._markOwnedInstance();
|
|
344
|
+
}
|
|
345
|
+
function invalidateHandle(ptr) {
|
|
346
|
+
const entries = handleRegistry.get(ptr);
|
|
347
|
+
if (entries === undefined)
|
|
348
|
+
return;
|
|
349
|
+
handleRegistry.delete(ptr);
|
|
350
|
+
for (const entry of entries)
|
|
351
|
+
entry._markDisposedInstance();
|
|
352
|
+
}
|
|
353
|
+
function invalidateHandles(ptrs) {
|
|
354
|
+
for (const ptr of ptrs)
|
|
355
|
+
invalidateHandle(ptr);
|
|
356
|
+
}
|
|
357
|
+
function registeredObjectsSnapshot() {
|
|
358
|
+
const objects = new Set();
|
|
359
|
+
for (const entries of handleRegistry.values()) {
|
|
360
|
+
for (const entry of entries)
|
|
361
|
+
objects.add(entry);
|
|
362
|
+
}
|
|
363
|
+
return Array.from(objects);
|
|
364
|
+
}
|
|
365
|
+
function livePtr(obj) {
|
|
366
|
+
try {
|
|
367
|
+
return obj.nativePtr();
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function collectKnownFilePtrs(file) {
|
|
374
|
+
const filePtr = file.nativePtr();
|
|
375
|
+
const ptrs = new Set([filePtr]);
|
|
376
|
+
for (const obj of registeredObjectsSnapshot()) {
|
|
377
|
+
const ptr = livePtr(obj);
|
|
378
|
+
if (ptr === null || ptr === filePtr)
|
|
379
|
+
continue;
|
|
380
|
+
try {
|
|
381
|
+
if (native.objectWzFileParent(ptr) === filePtr)
|
|
382
|
+
ptrs.add(ptr);
|
|
383
|
+
}
|
|
384
|
+
catch {
|
|
385
|
+
// Detached properties and already-invalid objects are not file-owned.
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return ptrs;
|
|
389
|
+
}
|
|
390
|
+
function isDescendantPath(path, rootPath) {
|
|
391
|
+
return path === rootPath
|
|
392
|
+
|| path.startsWith(`${rootPath}/`)
|
|
393
|
+
|| path.startsWith(`${rootPath}\\`);
|
|
394
|
+
}
|
|
395
|
+
function collectKnownSubtreePtrs(root) {
|
|
396
|
+
const rootPtr = root.nativePtr();
|
|
397
|
+
const rootPath = native.objectFullPath(rootPtr);
|
|
398
|
+
const ptrs = new Set([rootPtr]);
|
|
399
|
+
for (const obj of registeredObjectsSnapshot()) {
|
|
400
|
+
const ptr = livePtr(obj);
|
|
401
|
+
if (ptr === null || ptr === rootPtr)
|
|
402
|
+
continue;
|
|
403
|
+
try {
|
|
404
|
+
if (isDescendantPath(native.objectFullPath(ptr), rootPath)) {
|
|
405
|
+
ptrs.add(ptr);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
// Some detached properties do not have a tree path.
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return ptrs;
|
|
413
|
+
}
|
|
414
|
+
function collectPropertySubtreePtrs(prop, out = new Set()) {
|
|
415
|
+
const ptr = prop.nativePtr();
|
|
416
|
+
if (out.has(ptr))
|
|
417
|
+
return out;
|
|
418
|
+
out.add(ptr);
|
|
419
|
+
for (const child of prop.wzProperties())
|
|
420
|
+
collectPropertySubtreePtrs(child, out);
|
|
421
|
+
return out;
|
|
422
|
+
}
|
|
423
|
+
function collectImagePropertyPtrs(image) {
|
|
424
|
+
const ptrs = new Set();
|
|
425
|
+
for (const prop of image.wzProperties())
|
|
426
|
+
collectPropertySubtreePtrs(prop, ptrs);
|
|
427
|
+
return ptrs;
|
|
428
|
+
}
|
|
429
|
+
function collectPropertyChildrenPtrs(prop) {
|
|
430
|
+
const ptrs = new Set();
|
|
431
|
+
for (const child of prop.wzProperties())
|
|
432
|
+
collectPropertySubtreePtrs(child, ptrs);
|
|
433
|
+
return ptrs;
|
|
434
|
+
}
|
|
435
|
+
class WzObject {
|
|
436
|
+
_ptr;
|
|
437
|
+
_ownsNative;
|
|
438
|
+
constructor(ptr, ownsNative = false) {
|
|
439
|
+
if (new.target === WzObject) {
|
|
440
|
+
throw new TypeError('WzObject is abstract');
|
|
441
|
+
}
|
|
442
|
+
assertHandle(ptr);
|
|
443
|
+
this._ptr = ptr;
|
|
444
|
+
this._ownsNative = ownsNative;
|
|
445
|
+
registerHandle(ptr, this);
|
|
446
|
+
}
|
|
447
|
+
nativePtr() {
|
|
448
|
+
this._assertAlive();
|
|
449
|
+
return this._ptr;
|
|
450
|
+
}
|
|
451
|
+
_assertAlive() {
|
|
452
|
+
if (this._ptr === 0n)
|
|
453
|
+
throw new Error('native object is disposed');
|
|
454
|
+
}
|
|
455
|
+
_markBorrowed() {
|
|
456
|
+
this._assertAlive();
|
|
457
|
+
markHandleBorrowed(this._ptr);
|
|
458
|
+
}
|
|
459
|
+
_markOwned() {
|
|
460
|
+
this._assertAlive();
|
|
461
|
+
markHandleOwned(this._ptr);
|
|
462
|
+
}
|
|
463
|
+
_markDisposed() {
|
|
464
|
+
this._assertAlive();
|
|
465
|
+
invalidateHandle(this._ptr);
|
|
466
|
+
}
|
|
467
|
+
_markBorrowedInstance() {
|
|
468
|
+
this._ownsNative = false;
|
|
469
|
+
}
|
|
470
|
+
_markOwnedInstance() {
|
|
471
|
+
this._ownsNative = true;
|
|
472
|
+
}
|
|
473
|
+
_markDisposedInstance() {
|
|
474
|
+
this._ptr = 0n;
|
|
475
|
+
this._ownsNative = false;
|
|
476
|
+
}
|
|
477
|
+
ownsNative() {
|
|
478
|
+
return this._ownsNative;
|
|
479
|
+
}
|
|
480
|
+
getObjectType() {
|
|
481
|
+
return native.objectType(this.nativePtr());
|
|
482
|
+
}
|
|
483
|
+
getName() {
|
|
484
|
+
return native.objectName(this.nativePtr());
|
|
485
|
+
}
|
|
486
|
+
getParent() {
|
|
487
|
+
return wrapObjectInfo(native.objectParent(this.nativePtr()));
|
|
488
|
+
}
|
|
489
|
+
getFullPath() {
|
|
490
|
+
return native.objectFullPath(this.nativePtr());
|
|
491
|
+
}
|
|
492
|
+
getWzFileParent() {
|
|
493
|
+
const ptr = native.objectWzFileParent(this.nativePtr());
|
|
494
|
+
return ptr === null ? null : createWzFile(ptr);
|
|
495
|
+
}
|
|
496
|
+
getTopMostWzDirectory() {
|
|
497
|
+
return wrapObjectInfo(native.objectTopMostDirectory(this.nativePtr()));
|
|
498
|
+
}
|
|
499
|
+
getTopMostWzImage() {
|
|
500
|
+
return wrapObjectInfo(native.objectTopMostImage(this.nativePtr()));
|
|
501
|
+
}
|
|
502
|
+
at(name) {
|
|
503
|
+
return wrapObjectInfo(native.objectAt(this.nativePtr(), name));
|
|
504
|
+
}
|
|
505
|
+
setName(name) {
|
|
506
|
+
native.objectSetName(this.nativePtr(), name);
|
|
507
|
+
}
|
|
508
|
+
remove() {
|
|
509
|
+
const ptr = this.nativePtr();
|
|
510
|
+
native.objectRemove(this.nativePtr());
|
|
511
|
+
markHandleOwned(ptr);
|
|
512
|
+
}
|
|
513
|
+
close() {
|
|
514
|
+
if (this._ownsNative && this._ptr !== 0n) {
|
|
515
|
+
const ptr = this._ptr;
|
|
516
|
+
const ptrs = collectKnownSubtreePtrs(this);
|
|
517
|
+
try {
|
|
518
|
+
native.objectFree(ptr);
|
|
519
|
+
}
|
|
520
|
+
finally {
|
|
521
|
+
invalidateHandles(ptrs);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
else if (this._ptr !== 0n) {
|
|
525
|
+
unregisterHandle(this._ptr, this);
|
|
526
|
+
this._ptr = 0n;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
[Symbol.dispose]() {
|
|
530
|
+
this.close();
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
class WzFile extends WzObject {
|
|
534
|
+
disposeCallbacks = [];
|
|
535
|
+
static create(gameVersion, mapleVersion) {
|
|
536
|
+
const ptr = native.createFile(gameVersion, mapleVersion);
|
|
537
|
+
if (ptr === null)
|
|
538
|
+
throw new Error('failed to create WZ file');
|
|
539
|
+
return createWzFile(ptr, true);
|
|
540
|
+
}
|
|
541
|
+
static fromBytes(name, bytes, gameVersionOrMapleVersionOrIv, mapleVersion) {
|
|
542
|
+
let ptr;
|
|
543
|
+
if (gameVersionOrMapleVersionOrIv instanceof Uint8Array) {
|
|
544
|
+
ptr = native.openMemory(name, bytes, gameVersionOrMapleVersionOrIv);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
const gameVersion = mapleVersion === undefined ? -1 : gameVersionOrMapleVersionOrIv;
|
|
548
|
+
const version = mapleVersion === undefined
|
|
549
|
+
? gameVersionOrMapleVersionOrIv
|
|
550
|
+
: mapleVersion;
|
|
551
|
+
ptr = native.openMemory(name, bytes, gameVersion, version);
|
|
552
|
+
}
|
|
553
|
+
if (ptr === null)
|
|
554
|
+
throw new Error('failed to open WZ file from bytes');
|
|
555
|
+
return createWzFile(ptr, true);
|
|
556
|
+
}
|
|
557
|
+
static fromBlobSource(name, size, gameVersionOrMapleVersionOrIv, mapleVersionOrReadRange, readRange) {
|
|
558
|
+
if (!capabilities.blobInput) {
|
|
559
|
+
throw new Error('Blob-backed WZ input is not supported in this runtime');
|
|
560
|
+
}
|
|
561
|
+
if (native.openBlobSource === undefined) {
|
|
562
|
+
throw new Error('Blob-backed WZ input is not supported by this binding');
|
|
563
|
+
}
|
|
564
|
+
let ptr;
|
|
565
|
+
if (gameVersionOrMapleVersionOrIv instanceof Uint8Array) {
|
|
566
|
+
const callback = mapleVersionOrReadRange;
|
|
567
|
+
ptr = native.openBlobSource(size, name, gameVersionOrMapleVersionOrIv, callback);
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
const mapleVersion = typeof mapleVersionOrReadRange === 'function'
|
|
571
|
+
? undefined
|
|
572
|
+
: mapleVersionOrReadRange;
|
|
573
|
+
const callback = (readRange ?? mapleVersionOrReadRange);
|
|
574
|
+
const gameVersion = mapleVersion === undefined ? -1 : gameVersionOrMapleVersionOrIv;
|
|
575
|
+
const version = mapleVersion === undefined
|
|
576
|
+
? gameVersionOrMapleVersionOrIv
|
|
577
|
+
: mapleVersion;
|
|
578
|
+
ptr = native.openBlobSource(size, name, gameVersion, version, callback);
|
|
579
|
+
}
|
|
580
|
+
if (ptr === null)
|
|
581
|
+
throw new Error('failed to open WZ file from Blob');
|
|
582
|
+
return createWzFile(ptr, true);
|
|
583
|
+
}
|
|
584
|
+
constructor(pathOrPtr, gameVersionOrMapleVersion = MapleVersion.GMS, mapleVersion) {
|
|
585
|
+
if (typeof pathOrPtr === 'bigint') {
|
|
586
|
+
super(pathOrPtr, gameVersionOrMapleVersion === true);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (!capabilities.pathInput) {
|
|
590
|
+
throw new Error('WZ file path input is not supported by this binding');
|
|
591
|
+
}
|
|
592
|
+
let ptr;
|
|
593
|
+
if (gameVersionOrMapleVersion instanceof Uint8Array) {
|
|
594
|
+
ptr = native.openFile(pathOrPtr, gameVersionOrMapleVersion);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
const gameVersion = mapleVersion === undefined ? -1 : gameVersionOrMapleVersion;
|
|
598
|
+
const version = mapleVersion === undefined
|
|
599
|
+
? gameVersionOrMapleVersion
|
|
600
|
+
: mapleVersion;
|
|
601
|
+
ptr = native.openFile(pathOrPtr, gameVersion, version);
|
|
602
|
+
}
|
|
603
|
+
if (ptr === null)
|
|
604
|
+
throw new Error('failed to open WZ file');
|
|
605
|
+
super(ptr, true);
|
|
606
|
+
}
|
|
607
|
+
addDisposeCallback(callback) {
|
|
608
|
+
this.disposeCallbacks.push(callback);
|
|
609
|
+
}
|
|
610
|
+
parseWzFile() {
|
|
611
|
+
return native.parseFile(this.nativePtr());
|
|
612
|
+
}
|
|
613
|
+
saveToDisk(path) {
|
|
614
|
+
if (!capabilities.saveToDisk) {
|
|
615
|
+
throw new Error('saving WZ files to disk is not supported by this binding');
|
|
616
|
+
}
|
|
617
|
+
native.fileSaveToDisk(this.nativePtr(), path);
|
|
618
|
+
}
|
|
619
|
+
getName() {
|
|
620
|
+
return native.fileName(this.nativePtr());
|
|
621
|
+
}
|
|
622
|
+
getFilePath() {
|
|
623
|
+
return native.filePath(this.nativePtr());
|
|
624
|
+
}
|
|
625
|
+
getVersion() {
|
|
626
|
+
return native.fileVersion(this.nativePtr());
|
|
627
|
+
}
|
|
628
|
+
getMapleVersion() {
|
|
629
|
+
return native.fileMapleVersion(this.nativePtr());
|
|
630
|
+
}
|
|
631
|
+
getWzDirectory() {
|
|
632
|
+
const ptr = native.fileWzDirectory(this.nativePtr());
|
|
633
|
+
return ptr === null ? null : new WzDirectory(ptr);
|
|
634
|
+
}
|
|
635
|
+
is64BitWzFile() {
|
|
636
|
+
return native.fileIs64Bit(this.nativePtr());
|
|
637
|
+
}
|
|
638
|
+
isUnloaded() {
|
|
639
|
+
return native.fileIsUnloaded(this.nativePtr());
|
|
640
|
+
}
|
|
641
|
+
getVersionHash() {
|
|
642
|
+
return native.fileVersionHash(this.nativePtr());
|
|
643
|
+
}
|
|
644
|
+
getObjectFromPath(path, checkFirstDirectoryName = true) {
|
|
645
|
+
return wrapObjectInfo(native.fileObjectFromPath(this.nativePtr(), path, checkFirstDirectoryName));
|
|
646
|
+
}
|
|
647
|
+
close() {
|
|
648
|
+
if (this._ownsNative && this._ptr !== 0n) {
|
|
649
|
+
const ptr = this._ptr;
|
|
650
|
+
const ptrs = collectKnownFilePtrs(this);
|
|
651
|
+
try {
|
|
652
|
+
native.closeFile(ptr);
|
|
653
|
+
}
|
|
654
|
+
finally {
|
|
655
|
+
invalidateHandles(ptrs);
|
|
656
|
+
for (const callback of this.disposeCallbacks.splice(0))
|
|
657
|
+
callback();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
class WzDirectory extends WzObject {
|
|
663
|
+
getName() {
|
|
664
|
+
return native.dirName(this.nativePtr());
|
|
665
|
+
}
|
|
666
|
+
countImages() {
|
|
667
|
+
return native.dirCountImagesTotal(this.nativePtr());
|
|
668
|
+
}
|
|
669
|
+
wzImages() {
|
|
670
|
+
const count = native.dirCountImages(this.nativePtr());
|
|
671
|
+
return Array.from({ length: count }, (_, i) => this.getImage(i));
|
|
672
|
+
}
|
|
673
|
+
wzDirectories() {
|
|
674
|
+
const count = native.dirCountDirectories(this.nativePtr());
|
|
675
|
+
return Array.from({ length: count }, (_, i) => this.getDirectory(i));
|
|
676
|
+
}
|
|
677
|
+
getImage(index) {
|
|
678
|
+
const ptr = native.dirGetImage(this.nativePtr(), index);
|
|
679
|
+
return ptr === null ? null : new WzImage(ptr);
|
|
680
|
+
}
|
|
681
|
+
getImageByName(name) {
|
|
682
|
+
const ptr = native.dirGetImageByName(this.nativePtr(), name);
|
|
683
|
+
return ptr === null ? null : new WzImage(ptr);
|
|
684
|
+
}
|
|
685
|
+
getDirectory(index) {
|
|
686
|
+
const ptr = native.dirGetDirectory(this.nativePtr(), index);
|
|
687
|
+
return ptr === null ? null : new WzDirectory(ptr);
|
|
688
|
+
}
|
|
689
|
+
getDirectoryByName(name) {
|
|
690
|
+
const ptr = native.dirGetDirectoryByName(this.nativePtr(), name);
|
|
691
|
+
return ptr === null ? null : new WzDirectory(ptr);
|
|
692
|
+
}
|
|
693
|
+
createDirectory(name) {
|
|
694
|
+
const ptr = native.dirCreateDirectory(this.nativePtr(), name);
|
|
695
|
+
if (ptr === null)
|
|
696
|
+
throw new Error('failed to create WZ directory');
|
|
697
|
+
return new WzDirectory(ptr);
|
|
698
|
+
}
|
|
699
|
+
createImage(name) {
|
|
700
|
+
const ptr = native.dirCreateImage(this.nativePtr(), name);
|
|
701
|
+
if (ptr === null)
|
|
702
|
+
throw new Error('failed to create WZ image');
|
|
703
|
+
return new WzImage(ptr);
|
|
704
|
+
}
|
|
705
|
+
removeDirectory(child) {
|
|
706
|
+
native.dirRemoveDirectory(this.nativePtr(), child.nativePtr());
|
|
707
|
+
child._markOwned();
|
|
708
|
+
}
|
|
709
|
+
removeImage(child) {
|
|
710
|
+
native.dirRemoveImage(this.nativePtr(), child.nativePtr());
|
|
711
|
+
child._markOwned();
|
|
712
|
+
}
|
|
713
|
+
getBlockSize() {
|
|
714
|
+
return native.dirBlockSize(this.nativePtr());
|
|
715
|
+
}
|
|
716
|
+
getChecksum() {
|
|
717
|
+
return native.dirChecksum(this.nativePtr());
|
|
718
|
+
}
|
|
719
|
+
getOffset() {
|
|
720
|
+
return native.dirOffset(this.nativePtr());
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
class WzImage extends WzObject {
|
|
724
|
+
static fromFile(path, mapleVersion) {
|
|
725
|
+
if (!capabilities.pathInput || native.openImage === undefined) {
|
|
726
|
+
throw new Error('WZ image path input is not supported by this binding');
|
|
727
|
+
}
|
|
728
|
+
const ptr = native.openImage(path, mapleVersion);
|
|
729
|
+
if (ptr === null)
|
|
730
|
+
throw new Error('failed to open WZ image');
|
|
731
|
+
return new WzImage(ptr, true);
|
|
732
|
+
}
|
|
733
|
+
getName() {
|
|
734
|
+
return native.imageName(this.nativePtr());
|
|
735
|
+
}
|
|
736
|
+
isParsed() {
|
|
737
|
+
return native.imageParsed(this.nativePtr());
|
|
738
|
+
}
|
|
739
|
+
isChanged() {
|
|
740
|
+
return native.imageChanged(this.nativePtr());
|
|
741
|
+
}
|
|
742
|
+
getBlockSize() {
|
|
743
|
+
return native.imageBlockSize(this.nativePtr());
|
|
744
|
+
}
|
|
745
|
+
getChecksum() {
|
|
746
|
+
return native.imageChecksum(this.nativePtr());
|
|
747
|
+
}
|
|
748
|
+
getOffset() {
|
|
749
|
+
return native.imageOffset(this.nativePtr());
|
|
750
|
+
}
|
|
751
|
+
isLuaWzImage() {
|
|
752
|
+
return native.imageIsLua(this.nativePtr());
|
|
753
|
+
}
|
|
754
|
+
parseImage() {
|
|
755
|
+
native.imageParse(this.nativePtr());
|
|
756
|
+
}
|
|
757
|
+
wzProperties() {
|
|
758
|
+
const count = native.imageCountProperties(this.nativePtr());
|
|
759
|
+
return new WzPropertyCollection(...Array.from({ length: count }, (_, i) => {
|
|
760
|
+
const ptr = native.imageGetProperty(this.nativePtr(), i);
|
|
761
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
762
|
+
}).filter(isPresent));
|
|
763
|
+
}
|
|
764
|
+
getFromPath(path) {
|
|
765
|
+
const ptr = native.imageGetFromPath(this.nativePtr(), path);
|
|
766
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
767
|
+
}
|
|
768
|
+
addProperty(prop) {
|
|
769
|
+
native.imageAddProperty(this.nativePtr(), prop.nativePtr());
|
|
770
|
+
prop._markBorrowed();
|
|
771
|
+
}
|
|
772
|
+
removeProperty(prop) {
|
|
773
|
+
native.imageRemoveProperty(this.nativePtr(), prop.nativePtr());
|
|
774
|
+
prop._markOwned();
|
|
775
|
+
}
|
|
776
|
+
clearProperties() {
|
|
777
|
+
const ptrs = collectImagePropertyPtrs(this);
|
|
778
|
+
native.imageClearProperties(this.nativePtr());
|
|
779
|
+
invalidateHandles(ptrs);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
class WzPropertyCollection extends Array {
|
|
783
|
+
get(index) {
|
|
784
|
+
return this[index];
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
class WzImageProperty extends WzObject {
|
|
788
|
+
getPropertyType() {
|
|
789
|
+
return native.propType(this.nativePtr());
|
|
790
|
+
}
|
|
791
|
+
getName() {
|
|
792
|
+
return native.propName(this.nativePtr());
|
|
793
|
+
}
|
|
794
|
+
wzProperties() {
|
|
795
|
+
const count = native.propCountChildren(this.nativePtr());
|
|
796
|
+
return new WzPropertyCollection(...Array.from({ length: count }, (_, i) => this.getChild(i)).filter(isPresent));
|
|
797
|
+
}
|
|
798
|
+
getChild(index) {
|
|
799
|
+
const ptr = native.propGetChild(this.nativePtr(), index);
|
|
800
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
801
|
+
}
|
|
802
|
+
getChildByName(name) {
|
|
803
|
+
const ptr = native.propGetChildByName(this.nativePtr(), name);
|
|
804
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
805
|
+
}
|
|
806
|
+
getFromPath(path) {
|
|
807
|
+
const ptr = native.propGetFromPath(this.nativePtr(), path);
|
|
808
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
809
|
+
}
|
|
810
|
+
getLinkedWzImageProperty() {
|
|
811
|
+
const ptr = native.propLinked(this.nativePtr());
|
|
812
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
813
|
+
}
|
|
814
|
+
getInt() {
|
|
815
|
+
return native.propGetInt(this.nativePtr());
|
|
816
|
+
}
|
|
817
|
+
getShort() {
|
|
818
|
+
return native.propGetShort(this.nativePtr());
|
|
819
|
+
}
|
|
820
|
+
getLong() {
|
|
821
|
+
return native.propGetLong(this.nativePtr());
|
|
822
|
+
}
|
|
823
|
+
getFloat() {
|
|
824
|
+
return native.propGetFloat(this.nativePtr());
|
|
825
|
+
}
|
|
826
|
+
getDouble() {
|
|
827
|
+
return native.propGetDouble(this.nativePtr());
|
|
828
|
+
}
|
|
829
|
+
getString() {
|
|
830
|
+
return native.propGetString(this.nativePtr());
|
|
831
|
+
}
|
|
832
|
+
getBytes() {
|
|
833
|
+
return native.propGetBytes(this.nativePtr());
|
|
834
|
+
}
|
|
835
|
+
addProperty(child) {
|
|
836
|
+
native.propertyAddChild(this.nativePtr(), child.nativePtr());
|
|
837
|
+
child._markBorrowed();
|
|
838
|
+
}
|
|
839
|
+
removeProperty(child) {
|
|
840
|
+
native.propertyRemoveChild(this.nativePtr(), child.nativePtr());
|
|
841
|
+
child._markOwned();
|
|
842
|
+
}
|
|
843
|
+
clearProperties() {
|
|
844
|
+
const ptrs = collectPropertyChildrenPtrs(this);
|
|
845
|
+
native.propertyClearChildren(this.nativePtr());
|
|
846
|
+
invalidateHandles(ptrs);
|
|
847
|
+
}
|
|
848
|
+
close() {
|
|
849
|
+
super.close();
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
class WzNullProperty extends WzImageProperty {
|
|
853
|
+
}
|
|
854
|
+
class WzShortProperty extends WzImageProperty {
|
|
855
|
+
getValue() {
|
|
856
|
+
return native.propertyValue(this.nativePtr());
|
|
857
|
+
}
|
|
858
|
+
setValue(value) {
|
|
859
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
class WzIntProperty extends WzImageProperty {
|
|
863
|
+
getValue() {
|
|
864
|
+
return native.propertyValue(this.nativePtr());
|
|
865
|
+
}
|
|
866
|
+
setValue(value) {
|
|
867
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
class WzLongProperty extends WzImageProperty {
|
|
871
|
+
getValue() {
|
|
872
|
+
return native.propertyValue(this.nativePtr());
|
|
873
|
+
}
|
|
874
|
+
setValue(value) {
|
|
875
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
class WzFloatProperty extends WzImageProperty {
|
|
879
|
+
getValue() {
|
|
880
|
+
return native.propertyValue(this.nativePtr());
|
|
881
|
+
}
|
|
882
|
+
setValue(value) {
|
|
883
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
class WzDoubleProperty extends WzImageProperty {
|
|
887
|
+
getValue() {
|
|
888
|
+
return native.propertyValue(this.nativePtr());
|
|
889
|
+
}
|
|
890
|
+
setValue(value) {
|
|
891
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
class WzStringProperty extends WzImageProperty {
|
|
895
|
+
getValue() {
|
|
896
|
+
return native.propertyValue(this.nativePtr());
|
|
897
|
+
}
|
|
898
|
+
setValue(value) {
|
|
899
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
class WzSubProperty extends WzImageProperty {
|
|
903
|
+
}
|
|
904
|
+
class WzCanvasProperty extends WzImageProperty {
|
|
905
|
+
getPngProperty() {
|
|
906
|
+
const ptr = native.canvasPng(this.nativePtr());
|
|
907
|
+
return ptr === null ? null : new WzPngProperty(ptr);
|
|
908
|
+
}
|
|
909
|
+
containsInlinkProperty() {
|
|
910
|
+
return native.canvasContainsInlink(this.nativePtr());
|
|
911
|
+
}
|
|
912
|
+
containsOutlinkProperty() {
|
|
913
|
+
return native.canvasContainsOutlink(this.nativePtr());
|
|
914
|
+
}
|
|
915
|
+
getLinkedWzImageProperty() {
|
|
916
|
+
const ptr = native.canvasLinked(this.nativePtr());
|
|
917
|
+
return ptr === null ? null : wrapProperty(ptr);
|
|
918
|
+
}
|
|
919
|
+
saveToFile(path) {
|
|
920
|
+
return native.canvasSaveToFile(this.nativePtr(), path);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
class WzPngProperty extends WzImageProperty {
|
|
924
|
+
getWidth() {
|
|
925
|
+
return native.pngWidth(this.nativePtr());
|
|
926
|
+
}
|
|
927
|
+
getHeight() {
|
|
928
|
+
return native.pngHeight(this.nativePtr());
|
|
929
|
+
}
|
|
930
|
+
getFormat() {
|
|
931
|
+
return native.pngFormat(this.nativePtr());
|
|
932
|
+
}
|
|
933
|
+
isListWzUsed() {
|
|
934
|
+
return native.pngListWzUsed(this.nativePtr());
|
|
935
|
+
}
|
|
936
|
+
getImage() {
|
|
937
|
+
return native.pngImage(this.nativePtr());
|
|
938
|
+
}
|
|
939
|
+
getCompressedBytes() {
|
|
940
|
+
return native.pngCompressedBytes(this.nativePtr());
|
|
941
|
+
}
|
|
942
|
+
saveToFile(path) {
|
|
943
|
+
return native.pngSaveToFile(this.nativePtr(), path);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
class WzVectorProperty extends WzImageProperty {
|
|
947
|
+
getX() {
|
|
948
|
+
return native.vectorX(this.nativePtr());
|
|
949
|
+
}
|
|
950
|
+
getY() {
|
|
951
|
+
return native.vectorY(this.nativePtr());
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
class WzConvexProperty extends WzImageProperty {
|
|
955
|
+
}
|
|
956
|
+
class WzBinaryProperty extends WzImageProperty {
|
|
957
|
+
getBytes() {
|
|
958
|
+
return native.binaryData(this.nativePtr());
|
|
959
|
+
}
|
|
960
|
+
getWAVPlayback() {
|
|
961
|
+
return native.binaryWav(this.nativePtr());
|
|
962
|
+
}
|
|
963
|
+
getLength() {
|
|
964
|
+
return native.binaryLength(this.nativePtr());
|
|
965
|
+
}
|
|
966
|
+
getFrequency() {
|
|
967
|
+
return native.binaryFrequency(this.nativePtr());
|
|
968
|
+
}
|
|
969
|
+
getType() {
|
|
970
|
+
return native.binaryType(this.nativePtr());
|
|
971
|
+
}
|
|
972
|
+
isHeaderEncrypted() {
|
|
973
|
+
return native.binaryHeaderEncrypted(this.nativePtr());
|
|
974
|
+
}
|
|
975
|
+
saveToFile(path) {
|
|
976
|
+
return native.binarySaveToFile(this.nativePtr(), path);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
class WzRawDataProperty extends WzImageProperty {
|
|
980
|
+
getBytes() {
|
|
981
|
+
return native.rawData(this.nativePtr());
|
|
982
|
+
}
|
|
983
|
+
getRawType() {
|
|
984
|
+
return native.rawType(this.nativePtr());
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
class WzVideoProperty extends WzImageProperty {
|
|
988
|
+
getData() {
|
|
989
|
+
return native.videoData(this.nativePtr());
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
class WzUOLProperty extends WzImageProperty {
|
|
993
|
+
getValue() {
|
|
994
|
+
return native.propertyValue(this.nativePtr());
|
|
995
|
+
}
|
|
996
|
+
setValue(value) {
|
|
997
|
+
native.propertySetValue(this.nativePtr(), value);
|
|
998
|
+
}
|
|
999
|
+
getLinkValue() {
|
|
1000
|
+
return wrapObjectInfo(native.uolLinkValue(this.nativePtr()));
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
class WzLuaProperty extends WzImageProperty {
|
|
1004
|
+
getData() {
|
|
1005
|
+
return native.luaData(this.nativePtr());
|
|
1006
|
+
}
|
|
1007
|
+
getString() {
|
|
1008
|
+
return native.luaString(this.nativePtr());
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function wrapObjectInfo(info) {
|
|
1012
|
+
if (info === null)
|
|
1013
|
+
return null;
|
|
1014
|
+
return wrapObject(info.type, info.ptr);
|
|
1015
|
+
}
|
|
1016
|
+
function wrapObject(type, ptr) {
|
|
1017
|
+
if (type === ObjectType.FILE)
|
|
1018
|
+
return createWzFile(ptr);
|
|
1019
|
+
if (type === ObjectType.IMAGE)
|
|
1020
|
+
return new WzImage(ptr);
|
|
1021
|
+
if (type === ObjectType.DIRECTORY)
|
|
1022
|
+
return new WzDirectory(ptr);
|
|
1023
|
+
if (type === ObjectType.PROPERTY)
|
|
1024
|
+
return wrapProperty(ptr);
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
function requireProperty(ptr) {
|
|
1028
|
+
if (ptr === null)
|
|
1029
|
+
throw new Error('failed to create WZ property');
|
|
1030
|
+
return wrapProperty(ptr, true);
|
|
1031
|
+
}
|
|
1032
|
+
class WzProperty {
|
|
1033
|
+
static createNull(name) {
|
|
1034
|
+
return requireProperty(native.propertyCreateNull(name));
|
|
1035
|
+
}
|
|
1036
|
+
static createShort(name, value) {
|
|
1037
|
+
return requireProperty(native.propertyCreateShort(name, value));
|
|
1038
|
+
}
|
|
1039
|
+
static createInt(name, value) {
|
|
1040
|
+
return requireProperty(native.propertyCreateInt(name, value));
|
|
1041
|
+
}
|
|
1042
|
+
static createLong(name, value) {
|
|
1043
|
+
return requireProperty(native.propertyCreateLong(name, value));
|
|
1044
|
+
}
|
|
1045
|
+
static createFloat(name, value) {
|
|
1046
|
+
return requireProperty(native.propertyCreateFloat(name, value));
|
|
1047
|
+
}
|
|
1048
|
+
static createDouble(name, value) {
|
|
1049
|
+
return requireProperty(native.propertyCreateDouble(name, value));
|
|
1050
|
+
}
|
|
1051
|
+
static createString(name, value) {
|
|
1052
|
+
return requireProperty(native.propertyCreateString(name, value));
|
|
1053
|
+
}
|
|
1054
|
+
static createSub(name) {
|
|
1055
|
+
return requireProperty(native.propertyCreateSub(name));
|
|
1056
|
+
}
|
|
1057
|
+
static createVector(name, x, y) {
|
|
1058
|
+
return requireProperty(native.propertyCreateVector(name, x, y));
|
|
1059
|
+
}
|
|
1060
|
+
static createUol(name, value) {
|
|
1061
|
+
return requireProperty(native.propertyCreateUol(name, value));
|
|
1062
|
+
}
|
|
1063
|
+
static createCanvasFromPng(name, path) {
|
|
1064
|
+
return requireProperty(native.propertyCreateCanvasFromPng(name, path));
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function wrapProperty(ptr, ownsNative = false) {
|
|
1068
|
+
const type = native.propType(ptr);
|
|
1069
|
+
if (type === PropertyType.NULL)
|
|
1070
|
+
return new WzNullProperty(ptr, ownsNative);
|
|
1071
|
+
if (type === PropertyType.SHORT)
|
|
1072
|
+
return new WzShortProperty(ptr, ownsNative);
|
|
1073
|
+
if (type === PropertyType.INT)
|
|
1074
|
+
return new WzIntProperty(ptr, ownsNative);
|
|
1075
|
+
if (type === PropertyType.LONG)
|
|
1076
|
+
return new WzLongProperty(ptr, ownsNative);
|
|
1077
|
+
if (type === PropertyType.FLOAT)
|
|
1078
|
+
return new WzFloatProperty(ptr, ownsNative);
|
|
1079
|
+
if (type === PropertyType.DOUBLE)
|
|
1080
|
+
return new WzDoubleProperty(ptr, ownsNative);
|
|
1081
|
+
if (type === PropertyType.STRING)
|
|
1082
|
+
return new WzStringProperty(ptr, ownsNative);
|
|
1083
|
+
if (type === PropertyType.SUB)
|
|
1084
|
+
return new WzSubProperty(ptr, ownsNative);
|
|
1085
|
+
if (type === PropertyType.CANVAS)
|
|
1086
|
+
return new WzCanvasProperty(ptr, ownsNative);
|
|
1087
|
+
if (type === PropertyType.VECTOR)
|
|
1088
|
+
return new WzVectorProperty(ptr, ownsNative);
|
|
1089
|
+
if (type === PropertyType.CONVEX)
|
|
1090
|
+
return new WzConvexProperty(ptr, ownsNative);
|
|
1091
|
+
if (type === PropertyType.SOUND)
|
|
1092
|
+
return new WzBinaryProperty(ptr, ownsNative);
|
|
1093
|
+
if (type === PropertyType.RAW) {
|
|
1094
|
+
return native.propIsVideo(ptr)
|
|
1095
|
+
? new WzVideoProperty(ptr, ownsNative)
|
|
1096
|
+
: new WzRawDataProperty(ptr, ownsNative);
|
|
1097
|
+
}
|
|
1098
|
+
if (type === PropertyType.UOL)
|
|
1099
|
+
return new WzUOLProperty(ptr, ownsNative);
|
|
1100
|
+
if (type === PropertyType.LUA)
|
|
1101
|
+
return new WzLuaProperty(ptr, ownsNative);
|
|
1102
|
+
if (type === PropertyType.PNG)
|
|
1103
|
+
return new WzPngProperty(ptr, ownsNative);
|
|
1104
|
+
return new WzImageProperty(ptr, ownsNative);
|
|
1105
|
+
}
|
|
1106
|
+
const WzTool = Object.freeze({
|
|
1107
|
+
detectMapleVersion(path) {
|
|
1108
|
+
if (!capabilities.pathInput) {
|
|
1109
|
+
throw new Error('path-based WZ input is not supported in this runtime');
|
|
1110
|
+
}
|
|
1111
|
+
return native.detectMapleVersion(path);
|
|
1112
|
+
},
|
|
1113
|
+
getIvForVersion(version) {
|
|
1114
|
+
return native.ivForVersion(version);
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
async function init(wasmUrlOrOptions, options = {}) {
|
|
1119
|
+
const request = parseInitArgs(wasmUrlOrOptions, options);
|
|
1120
|
+
const shouldUseNative = nativeReady && !request.needsWasm;
|
|
1121
|
+
if (shouldUseNative) {
|
|
1122
|
+
await Promise.resolve();
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
nativeReady = false;
|
|
1126
|
+
const loaded = request.wasmUrl === undefined
|
|
1127
|
+
? await loadWzModule()
|
|
1128
|
+
: await initializeWasm(request.wasmUrl);
|
|
1129
|
+
configureWasmBinding(loaded);
|
|
1130
|
+
}
|
|
1131
|
+
function parseInitArgs(wasmUrlOrOptions, options) {
|
|
1132
|
+
const hasOptionsOnly = isInitOptions(wasmUrlOrOptions);
|
|
1133
|
+
const initOptions = hasOptionsOnly ? wasmUrlOrOptions : options;
|
|
1134
|
+
const wasmUrl = hasOptionsOnly ? undefined : wasmUrlOrOptions;
|
|
1135
|
+
return {
|
|
1136
|
+
needsWasm: wasmUrl !== undefined || initOptions.forceWasm === true,
|
|
1137
|
+
options: initOptions,
|
|
1138
|
+
wasmUrl
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
function isInitOptions(value) {
|
|
1142
|
+
return typeof value === 'object' && value !== null && !(value instanceof URL);
|
|
1143
|
+
}
|
|
1144
|
+
let nativeReady = installNativeBinding();
|
|
1145
|
+
|
|
1146
|
+
export { BinaryType, MapleVersion, ObjectType, ParseStatus, PropertyType, WzBinaryProperty, WzCanvasProperty, WzConvexProperty, WzDirectory, WzDoubleProperty, WzFile, WzFloatProperty, WzImage, WzImageProperty, WzIntProperty, WzLongProperty, WzLuaProperty, WzNullProperty, WzObject, WzPngProperty, WzProperty, WzPropertyCollection, WzRawDataProperty, WzShortProperty, WzStringProperty, WzSubProperty, WzTool, WzUOLProperty, WzVectorProperty, WzVideoProperty, getWzBindingType, init };
|