بيئة تشغيل QuickJS المحدودة بحدود
HPDFQuickJS and HPDFQuickJSStatic expose the same application-controlled JavaScript evaluation API on Win32 and Win64
اختر نمط نشر
HPDFQuickJSloads the ABI-neutralquickjs.dllbridge and keeps QuickJS values inside C codeHPDFQuickJSStaticlinks the platform-specific OMF objects into the application and requires no runtime DLL- لا تشمل الوحدتين معًا في برنامج واحد لأنهما تنشران أسماء الأنواع العامة نفسها
The DLL binding accepts an explicit path, the HOTPDF_QUICKJS_DLL environment value, or the platform directory found below an executable ancestor
Default builds place the bridge at Lib\thirdparty\QuickJS\bin\Win32\quickjs.dll or Lib\thirdparty\QuickJS\bin\Win64\quickjs.dll
On Linux x86-64, HPDFQuickJS loads the native libhpdfquickjs.so bridge built by tools/Build-HotPDFQuickJSLinux.sh; the explicit path and environment variable follow the same ownership and ABI rules
Linux default discovery checks the executable directory and Lib/thirdparty/QuickJS/bin/Linux64; native static OMF deployment remains specific to Windows
قيّم سكربتًا
uses
HPDFQuickJS;
var
Engine: THPDFQuickJS;
EvalResult: THPDFQuickJSResult;
begin
Engine := THPDFQuickJS.Create;
try
if not Engine.Available then
raise Exception.Create(Engine.LoadError);
EvalResult := Engine.Eval('JSON.stringify([1, 2, 3].map(x => x * 2))');
if not EvalResult.Success then
raise Exception.Create(EvalResult.Error);
finally
Engine.Free;
end;
end;
Eval converts the final JavaScript value to UTF-8 text and preserves Unicode when returning a Delphi string
EvalInt and EvalFloat add strict numeric conversion without exposing engine values across the ABI boundary
حدود التنفيذ
Limits := THPDFQuickJSLimits.CreateDefault;
Limits.MemoryBytes := 32 * 1024 * 1024;
Limits.StackBytes := 64 * 1024;
Limits.MaxScriptBytes := 256 * 1024;
Limits.TimeoutMs := 250;
Limits.MaxInterruptChecks := 250000;
Engine := THPDFQuickJS.Create(Limits);
الافتراضيات تسمح بـ 64 MiB ذاكرة محرك ومكدس 64 KiB وسكربت UTF-8 بـ 1 MiB وثانية زمن حائط ومليون فحص مقاطعة
بيئة التشغيل الساكنة لـ Win32 تُسقف ميزانية مكدس مطلوبة صفريةً أو أكبر عند 48 KiB للبقاء داخل حد الاستدعاء الذاتي الآمن للمترجم؛ ونمطا DLL وWin64 يراعيان القيمة المطلوبة مباشرةً
حدود الذاكرة والمكدس على مستوى بيئة التشغيل بينما حدود السكربت والزمن والمقاطعة تطبق لكل تقييم
الحالة والاستعادة
qjsSuccessreports a converted resultqjsScriptErrorreports syntax errors, thrown values, and conversion failuresqjsTimeLimitandqjsInterruptLimitdistinguish the two execution budgetsqjsBusy,qjsInvalidArgument,qjsResourceError, andqjsUnavailablepreserve infrastructure failures
التقييم المرفوض أو المقاطع يمسح استثناءه المعلق ومخازنه فتستطيع نسخة المحرك نفسها تنفيذ سكربت صالحًا لاحقًا
نسخة المحرك الواحدة غير قابلة لإعادة الدخول؛ واستخدم نسخة واحدة لكل عامل متزامن
سكربت نماذج XFA
The XFA flattening engine reuses this runtime only when THotPDF.XFAJavaScriptEnabled is explicitly set; it supplies a restricted data facade, native typed arrays, validated instance requests, and no file, process, browser, or network objects
TXFAFormScriptOptions.JavaScriptEvaluator can adapt the static runtime without forcing static QuickJS objects into every HotPDF application
راجع FormCalc وJavaScript في XFA محدودين بحدود
بناء بيئة تشغيل قابل للإنتاج
powershell -ExecutionPolicy Bypass -File Lib\thirdparty\build-quickjs-runtime.ps1
سكربت البناء ينتج مجموعتي الكائنات الساكنة وكلتا DLLs الجسر من المصدر المضمّن ثم تجمع مصفوفة بيئة التشغيل وتجرّب مسوح الساكنة وDLL لـ Win32 وWin64