From b588ff243de404476d4b5714883129a64674be09 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 30 Jul 2022 19:59:38 +0200 Subject: [PATCH] wasmjob: added cachestorage --- demo/wasienv/dom/job_js.pas | 64 ++++----- demo/wasienv/dom/job_web.pas | 261 ++++++++++++++++++++++++++++++++++- 2 files changed, 292 insertions(+), 33 deletions(-) diff --git a/demo/wasienv/dom/job_js.pas b/demo/wasienv/dom/job_js.pas index 749c6a2..ef25452 100644 --- a/demo/wasienv/dom/job_js.pas +++ b/demo/wasienv/dom/job_js.pas @@ -835,24 +835,24 @@ type IJSPromise = interface(IJSObject) ['{2BFE673B-B5D4-4F31-96CD-5E1A60EFBE26}'] - function all(arg: IJSArray): IJSPromise; overload; - function all(arg: TJOB_JSValue): IJSPromise; overload; - function allSettled(arg: IJSArray): IJSPromise; overload; - function allSettled(arg: TJOB_JSValue): IJSPromise; overload; - function race(arg: IJSArray): IJSPromise; overload; - function race(arg: TJOB_JSValue): IJSPromise; overload; + function all(const arg: IJSArray): IJSPromise; overload; + function all(const arg: TJOB_JSValue): IJSPromise; overload; + function allSettled(const arg: IJSArray): IJSPromise; overload; + function allSettled(const arg: TJOB_JSValue): IJSPromise; overload; + function race(const arg: IJSArray): IJSPromise; overload; + function race(const arg: TJOB_JSValue): IJSPromise; overload; function reject(const reason: UnicodeString): IJSPromise; overload; - function reject(reason: TJOB_JSValue): IJSPromise; overload; + function reject(const reason: TJOB_JSValue): IJSPromise; overload; function resolve(const value: boolean): IJSPromise; overload; function resolve(const value: longint): IJSPromise; overload; function resolve(const value: double): IJSPromise; overload; function resolve(const value: IJSObject): IJSPromise; overload; function resolve(const value: UnicodeString): IJSPromise; overload; - function resolve(value: TJOB_JSValue): IJSPromise; overload; + function resolve(const value: TJOB_JSValue): IJSPromise; overload; function resolve: IJSPromise; overload; - function _then (const OnAccepted: TJSPromiseResolver): IJSPromise; overload; - function _then (const OnAccepted, OnRejected: TJSPromiseResolver) : IJSPromise; overload; - function catch (const OnRejected: TJSPromiseResolver): IJSPromise; overload; + function _then(const OnAccepted: TJSPromiseResolver): IJSPromise; overload; + function _then(const OnAccepted, OnRejected: TJSPromiseResolver) : IJSPromise; overload; + function catch(const OnRejected: TJSPromiseResolver): IJSPromise; overload; function _finally(const Handler: TJSPromiseFinallyHandler): IJSPromise; overload; end; @@ -861,26 +861,26 @@ type TJSPromise = class(TJSObject,IJSPromise) public //class function Create(const Executor: TJSPromiseExecutor): IJSPromise; overload; - function all(arg: IJSArray): IJSPromise; overload; - function all(arg: TJOB_JSValue): IJSPromise; overload; - function allSettled(arg: IJSArray): IJSPromise; overload; - function allSettled(arg: TJOB_JSValue): IJSPromise; overload; - function race(arg: IJSArray): IJSPromise; overload; - function race(arg: TJOB_JSValue): IJSPromise; overload; + function all(const arg: IJSArray): IJSPromise; overload; + function all(const arg: TJOB_JSValue): IJSPromise; overload; + function allSettled(const arg: IJSArray): IJSPromise; overload; + function allSettled(const arg: TJOB_JSValue): IJSPromise; overload; + function race(const arg: IJSArray): IJSPromise; overload; + function race(const arg: TJOB_JSValue): IJSPromise; overload; function reject(const reason: UnicodeString): IJSPromise; overload; - function reject(reason: TJOB_JSValue): IJSPromise; overload; + function reject(const reason: TJOB_JSValue): IJSPromise; overload; function resolve(const value: boolean): IJSPromise; overload; function resolve(const value: longint): IJSPromise; overload; function resolve(const value: double): IJSPromise; overload; function resolve(const value: IJSObject): IJSPromise; overload; function resolve(const value: UnicodeString): IJSPromise; overload; - function resolve(value: TJOB_JSValue): IJSPromise; overload; + function resolve(const value: TJOB_JSValue): IJSPromise; overload; function resolve: IJSPromise; overload; - function _then (const OnAccepted: TJSPromiseResolver): IJSPromise; overload; - function _then (const OnAccepted, OnRejected: TJSPromiseResolver) : IJSPromise; overload; - function catch (const OnRejected: TJSPromiseResolver): IJSPromise; overload; + function _then(const OnAccepted: TJSPromiseResolver): IJSPromise; overload; + function _then(const OnAccepted, OnRejected: TJSPromiseResolver) : IJSPromise; overload; + function catch(const OnRejected: TJSPromiseResolver): IJSPromise; overload; function _finally(const Handler: TJSPromiseFinallyHandler): IJSPromise; overload; - class function Cast(Intf: IJSObject): IJSPromise; overload; + class function Cast(const Intf: IJSObject): IJSPromise; overload; end; { IJSTextDecoder } @@ -1175,32 +1175,32 @@ end; { TJSPromise } -function TJSPromise.all(arg: IJSArray): IJSPromise; +function TJSPromise.all(const arg: IJSArray): IJSPromise; begin Result:=InvokeJSObjectResult('all',[arg],TJSPromise) as IJSPromise; end; -function TJSPromise.all(arg: TJOB_JSValue): IJSPromise; +function TJSPromise.all(const arg: TJOB_JSValue): IJSPromise; begin Result:=InvokeJSObjectResult('all',[arg],TJSPromise) as IJSPromise; end; -function TJSPromise.allSettled(arg: IJSArray): IJSPromise; +function TJSPromise.allSettled(const arg: IJSArray): IJSPromise; begin Result:=InvokeJSObjectResult('allSettled',[arg],TJSPromise) as IJSPromise; end; -function TJSPromise.allSettled(arg: TJOB_JSValue): IJSPromise; +function TJSPromise.allSettled(const arg: TJOB_JSValue): IJSPromise; begin Result:=InvokeJSObjectResult('allSettled',[arg],TJSPromise) as IJSPromise; end; -function TJSPromise.race(arg: IJSArray): IJSPromise; +function TJSPromise.race(const arg: IJSArray): IJSPromise; begin Result:=InvokeJSObjectResult('race',[arg],TJSPromise) as IJSPromise; end; -function TJSPromise.race(arg: TJOB_JSValue): IJSPromise; +function TJSPromise.race(const arg: TJOB_JSValue): IJSPromise; begin Result:=InvokeJSObjectResult('race',[arg],TJSPromise) as IJSPromise; end; @@ -1210,7 +1210,7 @@ begin Result:=InvokeJSObjectResult('reject',[reason],TJSPromise) as IJSPromise; end; -function TJSPromise.reject(reason: TJOB_JSValue): IJSPromise; +function TJSPromise.reject(const reason: TJOB_JSValue): IJSPromise; begin Result:=InvokeJSObjectResult('reject',[reason],TJSPromise) as IJSPromise; end; @@ -1240,7 +1240,7 @@ begin Result:=InvokeJSObjectResult('resolve',[value],TJSPromise) as IJSPromise; end; -function TJSPromise.resolve(value: TJOB_JSValue): IJSPromise; +function TJSPromise.resolve(const value: TJOB_JSValue): IJSPromise; begin Result:=InvokeJSObjectResult('resolve',[value],TJSPromise) as IJSPromise; end; @@ -1302,7 +1302,7 @@ begin end; end; -class function TJSPromise.Cast(Intf: IJSObject): IJSPromise; +class function TJSPromise.Cast(const Intf: IJSObject): IJSPromise; begin Result:=TJSPromise.Cast(Intf); end; diff --git a/demo/wasienv/dom/job_web.pas b/demo/wasienv/dom/job_web.pas index f820114..8bfa8ca 100644 --- a/demo/wasienv/dom/job_web.pas +++ b/demo/wasienv/dom/job_web.pas @@ -333,6 +333,14 @@ Type TJSFileSystemDirectoryReader = class; IJSFormData = interface; TJSFormData = class; + IJSServiceWorker = interface; + TJSServiceWorker = class; + IJSAbstractWorker = interface; + TJSAbstractWorker = class; + IJSWindowOrWorkerGlobalScope = interface; + TJSWindowOrWorkerGlobalScope = class; + IJSCacheStorage = interface; + TJSCacheStorage = class; TJSEventListenerOptions = TJOB_Dictionary; TJSAddEventListenerOptions = TJOB_Dictionary; TJSGetRootNodeOptions = TJOB_Dictionary; @@ -370,6 +378,7 @@ Type TJSFileSystemFlags = TJOB_Dictionary; TJSChannelPixelLayout = TJOB_Dictionary; TJSImageBitmapOptions = TJOB_Dictionary; + TJSMultiCacheQueryOptions = TJOB_Dictionary; TVisibilityState = UnicodeString; TDocumentAutoplayPolicy = UnicodeString; TFlashClassification = UnicodeString; @@ -393,6 +402,8 @@ Type TImageOrientation = UnicodeString; TPremultiplyAlpha = UnicodeString; TColorSpaceConversion = UnicodeString; + TServiceWorkerState = UnicodeString; + TCacheStorageNamespace = UnicodeString; TEventListener = function (event: IJSEvent): Boolean of object; TEventHandlerNonNull = function (event: IJSEvent): TJOB_JSValue of object; TEventHandler = TEventHandlerNonNull; @@ -823,6 +834,14 @@ Type resizeHeight: LongWord; end; + { -------------------------------------------------------------------- + TJSMultiCacheQueryOptions + --------------------------------------------------------------------} + + TJSMultiCacheQueryOptionsRec = record + cacheName: UnicodeString; + end; + { -------------------------------------------------------------------- TJSEventTarget --------------------------------------------------------------------} @@ -4476,6 +4495,96 @@ Type class function Cast(Intf: IJSObject): IJSFormData; end; + { -------------------------------------------------------------------- + TJSAbstractWorker + --------------------------------------------------------------------} + + IJSAbstractWorker = interface(IJSObject) + ['{2D2E9E9C-BF21-3301-BE30-7D8E8AF584D5}'] + // property onerror: TEventHandler read _Getonerror write _Setonerror; + end; + + TJSAbstractWorker = class(TJSObject,IJSAbstractWorker) + Private + Public + class function Cast(Intf: IJSObject): IJSAbstractWorker; + // property onerror: TEventHandler read _Getonerror write _Setonerror; + end; + + { -------------------------------------------------------------------- + TJSWindowOrWorkerGlobalScope + --------------------------------------------------------------------} + + IJSWindowOrWorkerGlobalScope = interface(IJSObject) + ['{A638F512-23A4-3CE5-9F80-7BDB74A6E1BB}'] + function _Getorigin: UnicodeString; + function _GetcrossOriginIsolated: Boolean; + function _GetisSecureContext: Boolean; + function _Getcaches: IJSCacheStorage; + procedure reportError(aE: TJOB_JSValue); + function btoa(const aBtoa: UnicodeString): UnicodeString; + function atob(const _atob: UnicodeString): UnicodeString; + function setTimeout(aHandler: IJSFunction; aTimeout: Integer; arguments: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setTimeout(aHandler: IJSFunction): Integer{; ToDo:varargs}; overload; + function setTimeout(const aHandler: UnicodeString; aTimeout: Integer; aUnused: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setTimeout(const aHandler: UnicodeString): Integer{; ToDo:varargs}; overload; + procedure clearTimeout(aHandle: Integer); overload; + procedure clearTimeout; overload; + function setInterval(aHandler: IJSFunction; aTimeout: Integer; arguments: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setInterval(aHandler: IJSFunction): Integer{; ToDo:varargs}; overload; + function setInterval(const aHandler: UnicodeString; aTimeout: Integer; aUnused: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setInterval(const aHandler: UnicodeString): Integer{; ToDo:varargs}; overload; + procedure clearInterval(aHandle: Integer); overload; + procedure clearInterval; overload; + property origin: UnicodeString read _Getorigin; + property crossOriginIsolated: Boolean read _GetcrossOriginIsolated; + property isSecureContext: Boolean read _GetisSecureContext; + property caches: IJSCacheStorage read _Getcaches; + end; + + TJSWindowOrWorkerGlobalScope = class(TJSObject,IJSWindowOrWorkerGlobalScope) + Private + function _Getorigin: UnicodeString; + function _GetcrossOriginIsolated: Boolean; + function _GetisSecureContext: Boolean; + function _Getcaches: IJSCacheStorage; + Public + procedure reportError(aE: TJOB_JSValue); + function btoa(const aBtoa: UnicodeString): UnicodeString; + function atob(const _atob: UnicodeString): UnicodeString; + function setTimeout(aHandler: IJSFunction; aTimeout: Integer; arguments: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setTimeout(aHandler: IJSFunction): Integer{; ToDo:varargs}; overload; + function setTimeout(const aHandler: UnicodeString; aTimeout: Integer; aUnused: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setTimeout(const aHandler: UnicodeString): Integer{; ToDo:varargs}; overload; + procedure clearTimeout(aHandle: Integer); overload; + procedure clearTimeout; overload; + function setInterval(aHandler: IJSFunction; aTimeout: Integer; arguments: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setInterval(aHandler: IJSFunction): Integer{; ToDo:varargs}; overload; + function setInterval(const aHandler: UnicodeString; aTimeout: Integer; aUnused: TJOB_JSValue): Integer{; ToDo:varargs}; overload; + function setInterval(const aHandler: UnicodeString): Integer{; ToDo:varargs}; overload; + procedure clearInterval(aHandle: Integer); overload; + procedure clearInterval; overload; + class function Cast(Intf: IJSObject): IJSWindowOrWorkerGlobalScope; + property origin: UnicodeString read _Getorigin; + property crossOriginIsolated: Boolean read _GetcrossOriginIsolated; + property isSecureContext: Boolean read _GetisSecureContext; + property caches: IJSCacheStorage read _Getcaches; + end; + + { -------------------------------------------------------------------- + TJSCacheStorage + --------------------------------------------------------------------} + + IJSCacheStorage = interface(IJSObject) + ['{E6CE12C8-9006-3FF9-944A-1ED81AA2A621}'] + end; + + TJSCacheStorage = class(TJSObject,IJSCacheStorage) + Private + Public + class function Cast(Intf: IJSObject): IJSCacheStorage; + end; + { -------------------------------------------------------------------- TJSNode --------------------------------------------------------------------} @@ -5974,6 +6083,32 @@ Type class function Cast(Intf: IJSObject): IJSFileSystemDirectoryEntry; end; + { -------------------------------------------------------------------- + TJSServiceWorker + --------------------------------------------------------------------} + + IJSServiceWorker = interface(IJSEventTarget) + ['{578B7E11-8576-31FB-96D8-0793D46C61C4}'] + function _GetscriptURL: UnicodeString; + function _Getstate: TServiceWorkerState; + property scriptURL: UnicodeString read _GetscriptURL; + property state: TServiceWorkerState read _Getstate; + // property onstatechange: TEventHandler read _Getonstatechange write _Setonstatechange; + // property onerror: TEventHandler read _Getonerror write _Setonerror; + end; + + TJSServiceWorker = class(TJSEventTarget,IJSServiceWorker) + Private + function _GetscriptURL: UnicodeString; + function _Getstate: TServiceWorkerState; + Public + class function Cast(Intf: IJSObject): IJSServiceWorker; + property scriptURL: UnicodeString read _GetscriptURL; + property state: TServiceWorkerState read _Getstate; + // property onstatechange: TEventHandler read _Getonstatechange write _Setonstatechange; + // property onerror: TEventHandler read _Getonerror write _Setonerror; + end; + { -------------------------------------------------------------------- TJSDocument --------------------------------------------------------------------} @@ -13657,6 +13792,116 @@ begin Result:=TJSFormData.JOBCast(Intf); end; +class function TJSAbstractWorker.Cast(Intf: IJSObject): IJSAbstractWorker; +begin + Result:=TJSAbstractWorker.JOBCast(Intf); +end; + +function TJSWindowOrWorkerGlobalScope._Getorigin: UnicodeString; +begin + Result:=ReadJSPropertyUnicodeString('origin'); +end; + +function TJSWindowOrWorkerGlobalScope._GetcrossOriginIsolated: Boolean; +begin + Result:=ReadJSPropertyBoolean('crossOriginIsolated'); +end; + +function TJSWindowOrWorkerGlobalScope._GetisSecureContext: Boolean; +begin + Result:=ReadJSPropertyBoolean('isSecureContext'); +end; + +function TJSWindowOrWorkerGlobalScope._Getcaches: IJSCacheStorage; +begin + Result:=ReadJSPropertyObject('caches',TJSCacheStorage) as IJSCacheStorage; +end; + +procedure TJSWindowOrWorkerGlobalScope.reportError(aE: TJOB_JSValue); +begin + InvokeJSNoResult('reportError',[aE]); +end; + +function TJSWindowOrWorkerGlobalScope.btoa(const aBtoa: UnicodeString): UnicodeString; +begin + Result:=InvokeJSUnicodeStringResult('btoa',[aBtoa]); +end; + +function TJSWindowOrWorkerGlobalScope.atob(const _atob: UnicodeString): UnicodeString; +begin + Result:=InvokeJSUnicodeStringResult('atob',[_atob]); +end; + +function TJSWindowOrWorkerGlobalScope.setTimeout(aHandler: IJSFunction; aTimeout: Integer; arguments: TJOB_JSValue): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setTimeout',[aHandler,aTimeout,arguments]); +end; + +function TJSWindowOrWorkerGlobalScope.setTimeout(aHandler: IJSFunction): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setTimeout',[aHandler]); +end; + +function TJSWindowOrWorkerGlobalScope.setTimeout(const aHandler: UnicodeString; aTimeout: Integer; aUnused: TJOB_JSValue): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setTimeout',[aHandler,aTimeout,aUnused]); +end; + +function TJSWindowOrWorkerGlobalScope.setTimeout(const aHandler: UnicodeString): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setTimeout',[aHandler]); +end; + +procedure TJSWindowOrWorkerGlobalScope.clearTimeout(aHandle: Integer); overload; +begin + InvokeJSNoResult('clearTimeout',[aHandle]); +end; + +procedure TJSWindowOrWorkerGlobalScope.clearTimeout; overload; +begin + InvokeJSNoResult('clearTimeout',[]); +end; + +function TJSWindowOrWorkerGlobalScope.setInterval(aHandler: IJSFunction; aTimeout: Integer; arguments: TJOB_JSValue): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setInterval',[aHandler,aTimeout,arguments]); +end; + +function TJSWindowOrWorkerGlobalScope.setInterval(aHandler: IJSFunction): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setInterval',[aHandler]); +end; + +function TJSWindowOrWorkerGlobalScope.setInterval(const aHandler: UnicodeString; aTimeout: Integer; aUnused: TJOB_JSValue): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setInterval',[aHandler,aTimeout,aUnused]); +end; + +function TJSWindowOrWorkerGlobalScope.setInterval(const aHandler: UnicodeString): Integer{; ToDo:varargs}; overload; +begin + Result:=InvokeJSLongIntResult('setInterval',[aHandler]); +end; + +procedure TJSWindowOrWorkerGlobalScope.clearInterval(aHandle: Integer); overload; +begin + InvokeJSNoResult('clearInterval',[aHandle]); +end; + +procedure TJSWindowOrWorkerGlobalScope.clearInterval; overload; +begin + InvokeJSNoResult('clearInterval',[]); +end; + +class function TJSWindowOrWorkerGlobalScope.Cast(Intf: IJSObject): IJSWindowOrWorkerGlobalScope; +begin + Result:=TJSWindowOrWorkerGlobalScope.JOBCast(Intf); +end; + +class function TJSCacheStorage.Cast(Intf: IJSObject): IJSCacheStorage; +begin + Result:=TJSCacheStorage.JOBCast(Intf); +end; + function TJSNode._GetnodeType: Word; begin Result:=ReadJSPropertyLongInt('nodeType'); @@ -15557,6 +15802,21 @@ begin Result:=TJSFileSystemDirectoryEntry.JOBCast(Intf); end; +function TJSServiceWorker._GetscriptURL: UnicodeString; +begin + Result:=ReadJSPropertyUnicodeString('scriptURL'); +end; + +function TJSServiceWorker._Getstate: TServiceWorkerState; +begin + Result:=ReadJSPropertyUnicodeString('state'); +end; + +class function TJSServiceWorker.Cast(Intf: IJSObject): IJSServiceWorker; +begin + Result:=TJSServiceWorker.JOBCast(Intf); +end; + function TJSDocument._Getimplementation_: IJSDOMImplementation; begin Result:=ReadJSPropertyObject('implementation',TJSDOMImplementation) as IJSDOMImplementation; @@ -20608,4 +20868,3 @@ finalization JSDocument.Free; JSWindow.Free; end. -